Skip to content

Commit

Permalink
Merge branch 'master' into sliced-adjoints
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinjangrzybowski authored Sep 2, 2024
2 parents 03244d0 + e2cf0ab commit cfeffb0
Show file tree
Hide file tree
Showing 198 changed files with 13,371 additions and 1,821 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
\.*#*
\#*
Cubical/*/Everything.agda
!Cubical/Core/Everything.agda
!Cubical/Foundations/Everything.agda
!Cubical/Codata/Everything.agda
17 changes: 7 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ When preparing a PR here are some general guidelines:
- Use copattern-matching when instantiating records for efficiency.
This seems especially important when constructing Iso's.

- New records should be defined with the ```no-eta-equality``` modifier,
unless you have a good reason to drop it - keep in mind that dropping it
can lead to type checking speed problems.

- If typechecking starts becoming slow try to fix the efficiency
problems directly. We don't want to merge files that are very slow
to typecheck so they will have to optimized at some point and it's
Expand All @@ -99,21 +103,14 @@ When preparing a PR here are some general guidelines:
as well as various versions of function extensionality in
[FunExtEquiv.agda](https://github.com/agda/cubical/blob/master/Cubical/Functions/FunExtEquiv.agda).

- Unless a file is in the `Core`, `Foundations`, `Codata` or
`Experiments` package you don't need to add it manually to the
`Everything` file as it is automatically generated when running
`make`.
- Unless a file is in the `Core`, `Foundations` or `Codata` package you
don't need to add it manually to the `Everything` file as it is
automatically generated when running `make`.

- For folders with `Base` and `Properties` submodules, the `Base` file
can contain some basic consequences of the main definition, but
shouldn't include theorems that would require additional imports.

- Avoid importing `Foundations.Everything`; import only the modules in
`Foundations` you are using. Be reasonably specific in general when
importing.
In particular, avoid importing useless files or useless renaming
and try to group them by folder like `Foundations` or `Data`

- Avoid `public` imports, except in modules that are specifically meant
to collect and re-export results from several modules.

Expand Down
403 changes: 402 additions & 1 deletion Cubical/Algebra/AbGroup/Instances/FreeAbGroup.agda

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cubical/Algebra/AbGroup/Instances/Pi.agda
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.Group.Instances.Pi
open import Cubical.Algebra.AbGroup.Instances.Int

module _ {ℓ ℓ' : Level} {X : Type ℓ} (G : X AbGroup ℓ') where
ΠAbGroup : AbGroup (ℓ-max ℓ ℓ')
ΠAbGroup = Group→AbGroup (ΠGroup (λ x AbGroup→Group (G x)))
λ f g i x IsAbGroup.+Comm (AbGroupStr.isAbGroup (G x .snd)) (f x) (g x) i

ΠℤAbGroup : {ℓ} (A : Type ℓ) AbGroup ℓ
ΠℤAbGroup A = ΠAbGroup {X = A} λ _ ℤAbGroup
25 changes: 21 additions & 4 deletions Cubical/Algebra/AbGroup/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module Cubical.Algebra.AbGroup.Properties where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function

open import Cubical.Algebra.AbGroup.Base
open import Cubical.Algebra.Group
Expand All @@ -16,9 +17,10 @@ open import Cubical.HITs.SetQuotients as SQ hiding (_/_)
open import Cubical.Data.Int using (ℤ ; pos ; negsuc)
open import Cubical.Data.Nat hiding (_+_)
open import Cubical.Data.Sigma
open import Cubical.Data.Fin.Inductive

private variable
: Level
ℓ' : Level

module AbGroupTheory (A : AbGroup ℓ) where
open GroupTheory (AbGroup→Group A)
Expand All @@ -36,15 +38,15 @@ module AbGroupTheory (A : AbGroup ℓ) where
implicitInverse : {a b} a + b ≡ 0g b ≡ - a
implicitInverse b+a≡0 = invUniqueR b+a≡0

addGroupHom : (A B : AbGroup ℓ) (ϕ ψ : AbGroupHom A B) AbGroupHom A B
addGroupHom : (A : AbGroup ℓ) (B : AbGroup ℓ') (ϕ ψ : AbGroupHom A B) AbGroupHom A B
fst (addGroupHom A B ϕ ψ) x = AbGroupStr._+_ (snd B) (ϕ .fst x) (ψ .fst x)
snd (addGroupHom A B ϕ ψ) = makeIsGroupHom
λ x y cong₂ (AbGroupStr._+_ (snd B))
(IsGroupHom.pres· (snd ϕ) x y)
(IsGroupHom.pres· (snd ψ) x y)
∙ AbGroupTheory.comm-4 B (fst ϕ x) (fst ϕ y) (fst ψ x) (fst ψ y)

negGroupHom : (A B : AbGroup ℓ) (ϕ : AbGroupHom A B) AbGroupHom A B
negGroupHom : (A : AbGroup ℓ) (B : AbGroup ℓ') (ϕ : AbGroupHom A B) AbGroupHom A B
fst (negGroupHom A B ϕ) x = AbGroupStr.-_ (snd B) (ϕ .fst x)
snd (negGroupHom A B ϕ) =
makeIsGroupHom λ x y
Expand All @@ -56,7 +58,7 @@ snd (negGroupHom A B ϕ) =
(IsGroupHom.presinv (snd ϕ) x)
(IsGroupHom.presinv (snd ϕ) y)

subtrGroupHom : (A B : AbGroup ℓ) (ϕ ψ : AbGroupHom A B) AbGroupHom A B
subtrGroupHom : (A : AbGroup ℓ) (B : AbGroup ℓ') (ϕ ψ : AbGroupHom A B) AbGroupHom A B
subtrGroupHom A B ϕ ψ = addGroupHom A B ϕ (negGroupHom A B ψ)


Expand Down Expand Up @@ -118,3 +120,18 @@ G [ n ]ₜ =
(kerSubgroup (multₗHom G (pos n))))
λ {(x , p) (y , q) Σ≡Prop (λ _ isPropIsInKer (multₗHom G (pos n)) _)
(AbGroupStr.+Comm (snd G) _ _)}

-- finite sums commute with negations
sumFinG-neg : (n : ℕ) {A : AbGroup ℓ}
(f : Fin n fst A)
sumFinGroup (AbGroup→Group A) {n} (λ x AbGroupStr.-_ (snd A) (f x))
≡ AbGroupStr.-_ (snd A) (sumFinGroup (AbGroup→Group A) {n} f)
sumFinG-neg zero {A} f = sym (GroupTheory.inv1g (AbGroup→Group A))
sumFinG-neg (suc n) {A} f =
cong₂ compA refl (sumFinG-neg n {A = A} (f ∘ injectSuc))
∙∙ AbGroupStr.+Comm (snd A) _ _
∙∙ sym (GroupTheory.invDistr (AbGroup→Group A) _ _)
where
-A = AbGroupStr.-_ (snd A)
0A = AbGroupStr.0g (snd A)
compA = AbGroupStr._+_ (snd A)
6 changes: 6 additions & 0 deletions Cubical/Algebra/ChainComplex.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{-# OPTIONS --safe #-}
module Cubical.Algebra.ChainComplex where

open import Cubical.Algebra.ChainComplex.Base public
open import Cubical.Algebra.ChainComplex.Homology public
open import Cubical.Algebra.ChainComplex.Finite public
114 changes: 114 additions & 0 deletions Cubical/Algebra/ChainComplex/Base.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{-# OPTIONS --safe --lossy-unification #-}
module Cubical.Algebra.ChainComplex.Base where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv

open import Cubical.Data.Sigma
open import Cubical.Data.Nat

open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.AbGroup

private
variable
ℓ ℓ' ℓ'' : Level

record ChainComplex (ℓ : Level) : Type (ℓ-suc ℓ) where
field
chain : (i : ℕ) AbGroup ℓ
bdry : (i : ℕ) AbGroupHom (chain (suc i)) (chain i)
bdry²=0 : (i : ℕ) compGroupHom (bdry (suc i)) (bdry i) ≡ trivGroupHom

record ChainComplexMap {ℓ ℓ' : Level}
(A : ChainComplex ℓ) (B : ChainComplex ℓ') : Type (ℓ-max ℓ ℓ') where
open ChainComplex
field
chainmap : (i : ℕ) AbGroupHom (chain A i) (chain B i)
bdrycomm : (i : ℕ)
compGroupHom (chainmap (suc i)) (bdry B i) ≡ compGroupHom (bdry A i) (chainmap i)

record ChainHomotopy {ℓ : Level} {A : ChainComplex ℓ} {B : ChainComplex ℓ'}
(f g : ChainComplexMap A B) : Type (ℓ-max ℓ' ℓ) where
open ChainComplex
open ChainComplexMap
field
htpy : (i : ℕ) AbGroupHom (chain A i) (chain B (suc i))
bdryhtpy : (i : ℕ)
subtrGroupHom (chain A (suc i)) (chain B (suc i))
(chainmap f (suc i)) (chainmap g (suc i))
≡ addGroupHom (chain A (suc i)) (chain B (suc i))
(compGroupHom (htpy (suc i)) (bdry B (suc i)))
(compGroupHom (bdry A i) (htpy i))

record CoChainComplex (ℓ : Level) : Type (ℓ-suc ℓ) where
field
cochain : (i : ℕ) AbGroup ℓ
cobdry : (i : ℕ) AbGroupHom (cochain i) (cochain (suc i))
cobdry²=0 : (i : ℕ) compGroupHom (cobdry i) (cobdry (suc i))
≡ trivGroupHom

open ChainComplexMap
ChainComplexMap≡ : {A : ChainComplex ℓ} {B : ChainComplex ℓ'}
{f g : ChainComplexMap A B}
((i : ℕ) chainmap f i ≡ chainmap g i)
f ≡ g
chainmap (ChainComplexMap≡ p i) n = p n i
bdrycomm (ChainComplexMap≡ {A = A} {B = B} {f = f} {g = g} p i) n =
isProp→PathP {B = λ i compGroupHom (p (suc n) i) (ChainComplex.bdry B n)
≡ compGroupHom (ChainComplex.bdry A n) (p n i)}
(λ i isSetGroupHom _ _)
(bdrycomm f n) (bdrycomm g n) i

compChainMap : {A : ChainComplex ℓ} {B : ChainComplex ℓ'} {C : ChainComplex ℓ''}
(f : ChainComplexMap A B) (g : ChainComplexMap B C)
ChainComplexMap A C
compChainMap {A = A} {B} {C} ϕ' ψ' = main
where
ϕ = chainmap ϕ'
commϕ = bdrycomm ϕ'
ψ = chainmap ψ'
commψ = bdrycomm ψ'

main : ChainComplexMap A C
chainmap main n = compGroupHom (ϕ n) (ψ n)
bdrycomm main n =
Σ≡Prop (λ _ isPropIsGroupHom _ _)
(funExt λ x
(funExt⁻ (cong fst (commψ n)) (ϕ (suc n) .fst x))
∙ cong (fst (ψ n)) (funExt⁻ (cong fst (commϕ n)) x))

isChainEquiv : {A : ChainComplex ℓ} {B : ChainComplex ℓ'}
ChainComplexMap A B Type (ℓ-max ℓ ℓ')
isChainEquiv f = ((n : ℕ) isEquiv (chainmap f n .fst))

_≃Chain_ : (A : ChainComplex ℓ) (B : ChainComplex ℓ') Type (ℓ-max ℓ ℓ')
A ≃Chain B = Σ[ f ∈ ChainComplexMap A B ] (isChainEquiv f)

idChainMap : (A : ChainComplex ℓ) ChainComplexMap A A
chainmap (idChainMap A) _ = idGroupHom
bdrycomm (idChainMap A) _ =
Σ≡Prop (λ _ isPropIsGroupHom _ _) refl

invChainMap : {A : ChainComplex ℓ} {B : ChainComplex ℓ'}
(A ≃Chain B) ChainComplexMap B A
chainmap (invChainMap (ϕ , eq)) n =
GroupEquiv→GroupHom (invGroupEquiv ((chainmap ϕ n .fst , eq n) , snd (chainmap ϕ n)))
bdrycomm (invChainMap {B = B} (ϕ' , eq)) n =
Σ≡Prop (λ _ isPropIsGroupHom _ _)
(funExt λ x
sym (retEq (_ , eq n ) _)
∙∙ cong (invEq (_ , eq n ))
(sym (funExt⁻ (cong fst (ϕcomm n)) (invEq (_ , eq (suc n)) x)))
∙∙ cong (invEq (ϕ n .fst , eq n ) ∘ fst (ChainComplex.bdry B n))
(secEq (_ , eq (suc n)) x))
where
ϕ = chainmap ϕ'
ϕcomm = bdrycomm ϕ'

invChainEquiv : {A : ChainComplex ℓ} {B : ChainComplex ℓ'}
A ≃Chain B B ≃Chain A
fst (invChainEquiv e) = invChainMap e
snd (invChainEquiv e) n = snd (invEquiv (chainmap (fst e) n .fst , snd e n))
123 changes: 123 additions & 0 deletions Cubical/Algebra/ChainComplex/Finite.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{-# OPTIONS --safe --lossy-unification #-}
module Cubical.Algebra.ChainComplex.Finite where

{- When dealing with chain maps and chain homotopies constructively,
it is often the case the case that one only is able to obtain a finite
approximation rather than the full thing. This file contains
definitions of
(1) finite chain maps,
(2) finite chain homotopies
(3) finite chain equivalences
and proof their induced behaviour on homology
-}

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv

open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Data.Fin.Inductive.Base

open import Cubical.Algebra.ChainComplex.Base
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.AbGroup

private
variable
ℓ ℓ' ℓ'' : Level

module _ where
record finChainComplexMap {ℓ ℓ' : Level} (m : ℕ)
(A : ChainComplex ℓ) (B : ChainComplex ℓ') : Type (ℓ-max ℓ ℓ') where
open ChainComplex
field
fchainmap : (i : Fin (suc m))
AbGroupHom (chain A (fst i)) (chain B (fst i))
fbdrycomm : (i : Fin m)
compGroupHom (fchainmap (fsuc i)) (bdry B (fst i))
≡ compGroupHom (bdry A (fst i)) (fchainmap (injectSuc i))

record finChainHomotopy {ℓ : Level} (m : ℕ)
{A : ChainComplex ℓ} {B : ChainComplex ℓ'}
(f g : finChainComplexMap m A B) : Type (ℓ-max ℓ' ℓ) where
open ChainComplex
open finChainComplexMap
field
fhtpy : (i : Fin (suc m))
AbGroupHom (chain A (fst i)) (chain B (suc (fst i)))
fbdryhtpy : (i : Fin m)
subtrGroupHom (chain A (suc (fst i))) (chain B (suc (fst i)))
(fchainmap f (fsuc i)) (fchainmap g (fsuc i))
≡ addGroupHom (chain A (suc (fst i))) (chain B (suc (fst i)))
(compGroupHom (fhtpy (fsuc i)) (bdry B (suc (fst i))))
(compGroupHom (bdry A (fst i)) (fhtpy (injectSuc i)))

open finChainComplexMap
finChainComplexMap≡ :
{A : ChainComplex ℓ} {B : ChainComplex ℓ'} {m : ℕ}
{f g : finChainComplexMap m A B}
((i : Fin (suc m)) fchainmap f i ≡ fchainmap g i)
f ≡ g
fchainmap (finChainComplexMap≡ p i) n = p n i
fbdrycomm (finChainComplexMap≡ {A = A} {B = B} {f = f} {g = g} p i) n =
isProp→PathP {B = λ i
compGroupHom (p (fsuc n) i) (ChainComplex.bdry B (fst n))
≡ compGroupHom (ChainComplex.bdry A (fst n)) (p (injectSuc n) i)}
(λ i isSetGroupHom _ _)
(fbdrycomm f n) (fbdrycomm g n) i

compFinChainMap :
{A : ChainComplex ℓ} {B : ChainComplex ℓ'} {C : ChainComplex ℓ''} {m : ℕ}
(f : finChainComplexMap m A B) (g : finChainComplexMap m B C)
finChainComplexMap m A C
compFinChainMap {A = A} {B} {C} {m = m} ϕ' ψ' = main
where
ϕ = fchainmap ϕ'
commϕ = fbdrycomm ϕ'
ψ = fchainmap ψ'
commψ = fbdrycomm ψ'

main : finChainComplexMap m A C
fchainmap main n = compGroupHom (ϕ n) (ψ n)
fbdrycomm main n =
Σ≡Prop (λ _ isPropIsGroupHom _ _)
(funExt λ x
(funExt⁻ (cong fst (commψ n)) (ϕ (fsuc n) .fst x))
∙ cong (fst (ψ (injectSuc n))) (funExt⁻ (cong fst (commϕ n)) x))

isFinChainEquiv : {A : ChainComplex ℓ} {B : ChainComplex ℓ'} {m : ℕ}
finChainComplexMap m A B Type (ℓ-max ℓ ℓ')
isFinChainEquiv {m = m} f = ((n : Fin (suc m)) isEquiv (fchainmap f n .fst))

_≃⟨_⟩Chain_ : (A : ChainComplex ℓ) (m : ℕ) (B : ChainComplex ℓ')
Type (ℓ-max ℓ ℓ')
A ≃⟨ m ⟩Chain B = Σ[ f ∈ finChainComplexMap m A B ] (isFinChainEquiv f)

idFinChainMap : (m : ℕ) (A : ChainComplex ℓ) finChainComplexMap m A A
fchainmap (idFinChainMap m A) _ = idGroupHom
fbdrycomm (idFinChainMap m A) _ =
Σ≡Prop (λ _ isPropIsGroupHom _ _) refl

invFinChainMap : {A : ChainComplex ℓ} {B : ChainComplex ℓ'} {m : ℕ}
(A ≃⟨ m ⟩Chain B) finChainComplexMap m B A
fchainmap (invFinChainMap {m = m} (ϕ , eq)) n =
GroupEquiv→GroupHom
(invGroupEquiv ((fchainmap ϕ n .fst , eq n) , snd (fchainmap ϕ n)))
fbdrycomm (invFinChainMap {B = B} {m = m} (ϕ' , eq)) n =
Σ≡Prop (λ _ isPropIsGroupHom _ _)
(funExt λ x
sym (retEq (_ , eq (injectSuc n) ) _)
∙∙ cong (invEq (_ , eq (injectSuc n) ))
(sym (funExt⁻ (cong fst (ϕcomm n)) (invEq (_ , eq (fsuc n)) x)))
∙∙ cong (invEq (ϕ (injectSuc n) .fst , eq (injectSuc n) )
∘ fst (ChainComplex.bdry B (fst n)))
(secEq (_ , eq (fsuc n)) x))
where
ϕ = fchainmap ϕ'
ϕcomm = fbdrycomm ϕ'

invFinChainEquiv : {A : ChainComplex ℓ} {B : ChainComplex ℓ'} {m : ℕ}
A ≃⟨ m ⟩Chain B B ≃⟨ m ⟩Chain A
fst (invFinChainEquiv e) = invFinChainMap e
snd (invFinChainEquiv e) n = snd (invEquiv (fchainmap (fst e) n .fst , snd e n))
Loading

0 comments on commit cfeffb0

Please sign in to comment.