{-# OPTIONS --safe --lossy-unification #-}
module Cubical.Algebra.CommAlgebra.FP.Instances where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Structure
open import Cubical.Data.FinData
open import Cubical.Data.Nat
open import Cubical.Data.Vec
open import Cubical.Data.Sigma
open import Cubical.Data.Empty
open import Cubical.HITs.PropositionalTruncation
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.FGIdeal using (inclOfFGIdeal)
open import Cubical.Algebra.CommAlgebra
open import Cubical.Algebra.CommAlgebra.Polynomials as Poly
open import Cubical.Algebra.CommAlgebra.Quotient as Quot
open import Cubical.Algebra.CommAlgebra.Ideal using (IdealsIn; 0Ideal)
open import Cubical.Algebra.CommAlgebra.FGIdeal
open import Cubical.Algebra.CommAlgebra.Instances.Initial
open import Cubical.Algebra.CommAlgebra.Instances.Terminal
open import Cubical.Algebra.CommAlgebra.Notation
open import Cubical.Algebra.CommAlgebra.FP as FP
private variable
ℓ ℓ' : Level
module _ (R : CommRing ℓ) where
open FinitePresentation
module _ (n : ℕ) where
private
opaque
p : 0Ideal R (Polynomials R n) ≡ ⟨ emptyFinVec ⟨ Polynomials R n ⟩ₐ ⟩[ _ ]
p = sym $ 0FGIdeal≡0Ideal (Polynomials R n)
compute :
CommAlgebraEquiv (Polynomials R n)
((Polynomials R n) / ⟨ emptyFinVec ⟨ Polynomials R n ⟩ₐ ⟩[ _ ])
compute =
transport (λ i → CommAlgebraEquiv (Polynomials R n) ((Polynomials R n) / (p i))) $
zeroIdealQuotient (Polynomials R n)
polynomialsFP : FinitePresentation R
polynomialsFP =
record {
n = n ;
m = 0 ;
relations = emptyFinVec ⟨ Polynomials R n ⟩ₐ
}
opaque
unfolding fpAlg fgIdeal
isFPPolynomials : isFP R (Polynomials R n)
isFPPolynomials = ∣ polynomialsFP , invCommAlgebraEquiv compute ∣₁
private
R[⊥] : CommAlgebra R ℓ
R[⊥] = Polynomials R 0
emptyGen : FinVec ⟨ R[⊥] ⟩ₐ 0
emptyGen = λ ()
initialAlgFP : FinitePresentation R
initialAlgFP = record { n = 0 ; m = 0 ; relations = emptyGen }
R[⊥]/⟨0⟩ : CommAlgebra R ℓ
R[⊥]/⟨0⟩ = fpAlg initialAlgFP
R[⊥]/⟨0⟩IsInitial : (B : CommAlgebra R ℓ)
→ isContr (CommAlgebraHom R[⊥]/⟨0⟩ B)
R[⊥]/⟨0⟩IsInitial B = indHom , uniqueness
where
indHom : CommAlgebraHom R[⊥]/⟨0⟩ B
indHom = FP.inducedHom R initialAlgFP B (emptyFinVec ⟨ B ⟩ₐ) (λ ())
uniqueness : (f : CommAlgebraHom R[⊥]/⟨0⟩ B) →
indHom ≡ f
uniqueness f = FP.inducedHomUnique R initialAlgFP B (emptyFinVec ⟨ B ⟩ₐ) (λ ()) f (λ ())
initialCAlgIsFP : isFP R (initialCAlg R)
initialCAlgIsFP = ∣ (initialAlgFP , equivByInitiality R R[⊥]/⟨0⟩ R[⊥]/⟨0⟩IsInitial) ∣₁
private
unitGen : FinVec ⟨ R[⊥] ⟩ₐ 1
unitGen zero = 1r
where open InstancesForCAlg R[⊥]
terminalCAlgFP : FinitePresentation R
terminalCAlgFP = record { n = 0 ; m = 1 ; relations = unitGen }
R[⊥]/⟨1⟩ : CommAlgebra R ℓ
R[⊥]/⟨1⟩ = fpAlg terminalCAlgFP
opaque
unfolding fpAlg fgIdeal
terminalCAlgIsFP : isFP R (terminalCAlg R)
terminalCAlgIsFP = ∣ (terminalCAlgFP ,
(equivFrom1≡0 R R[⊥]/⟨1⟩
(1r ≡⟨ sym pres1 ⟩
(π terminalCAlgFP) $ca 1r ≡⟨ isZeroFromIdeal 1r (incInIdeal (Polynomials R 0) unitGen zero) ⟩
0r ∎))) ∣₁
where open InstancesForCAlg (fpAlg terminalCAlgFP)
open InstancesForCAlg (Polynomials R 0)
open IsCommAlgebraHom (π terminalCAlgFP .snd)