Skip to content

Commit

Permalink
adding pullback stability (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
PHart3 authored Oct 8, 2024
1 parent 4a392ea commit 53ef7b0
Show file tree
Hide file tree
Showing 12 changed files with 836 additions and 22 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
# Ignore Emacs backup files
*~
# Ignore Agda-generated files
html/
MAlonzo/
# Other files to ignore
Unclassified/
Test.agda
html1/
html2/
# Ignore build output
_build/
2 changes: 1 addition & 1 deletion Colimit-code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ check the entire development in a reasonable amount of time.
# Manual Type-Checking

1. Install Agda 2.6.3.
2. Install the stripped, modified HoTT-Agda under `../HoTT-Agda`.
2. Install the stripped, modified HoTT-Agda library under `../HoTT-Agda`.
3. Type check the file `Main-Theorem/CosColim-Adjunction.agda`.

# License
Expand Down
34 changes: 23 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
####################################################################################################
# Stage 1: building Agda
# Build Agda
####################################################################################################

ARG GHC_VERSION=9.4.7
Expand All @@ -23,24 +23,25 @@ RUN \
cabal v1-install --bindir=/dist --datadir=/dist --datasubdir=/dist/data --enable-executable-static

####################################################################################################
# Stage 2: Download HoTT-Agda
# Type check Agda files
####################################################################################################

FROM alpine AS hottagda

RUN apk add --no-cache git

COPY ["HoTT-Agda", "/dist/Hott-Agda"]
RUN echo "/dist/Hott-Agda/hott-core.agda-lib" > /dist/libraries

###############################################################################################################
COPY ["HoTT-Agda", "/build/Hott-Agda"]
COPY ["Colimit-code", "/build/Colimit-code"]

FROM alpine

COPY --from=agda /dist /dist
COPY --from=hottagda /dist /dist
COPY --from=hottagda /build /build

COPY ["Colimit-code", "/build/Colimit-code"]
COPY ["Pullback-stability", "/build/Pullback-stability"]
COPY agdacheck.sh /

RUN echo "/build/Hott-Agda/hott-core.agda-lib" >> /dist/libraries
RUN echo "/build/Colimit-code/cos-colim.agda-lib" >> /dist/libraries
RUN echo "/build/Pullback-stability/stab.agda-lib" >> /dist/libraries

WORKDIR /build/Colimit-code
RUN /dist/agda --library-file=/dist/libraries ./R-L-R/CC-Equiv-RLR-0.agda
Expand All @@ -55,6 +56,7 @@ RUN /dist/agda --library-file=/dist/libraries ./L-R-L/CC-Equiv-LRL-3.agda
RUN /dist/agda --library-file=/dist/libraries ./L-R-L/CC-Equiv-LRL-4.agda
RUN /dist/agda --library-file=/dist/libraries ./L-R-L/CC-Equiv-LRL-5.agda
RUN /dist/agda --library-file=/dist/libraries ./L-R-L/CC-Equiv-LRL-6.agda
RUN /dist/agda --library-file=/dist/libraries ./L-R-L/CC-Equiv-LRL-7.agda
RUN /dist/agda --library-file=/dist/libraries ./Map-Nat/CosColimitMap00.agda
RUN /dist/agda --library-file=/dist/libraries ./Map-Nat/CosColimitMap01.agda
RUN /dist/agda --library-file=/dist/libraries ./Map-Nat/CosColimitMap02.agda
Expand All @@ -80,4 +82,14 @@ RUN /dist/agda --library-file=/dist/libraries ./Map-Nat/CosColimitMap21.agda
RUN /dist/agda --library-file=/dist/libraries ./Map-Nat/CosColimitMap22.agda
RUN /dist/agda --library-file=/dist/libraries ./Main-Theorem/CosColim-Adjunction.agda

CMD ["/dist/agda", "--html", "--library-file=/dist/libraries", "./Main-Theorem/CosColim-Adjunction.agda"]
WORKDIR /build/Pullback-stability
RUN /dist/agda --library-file=/dist/libraries ./Stability.agda

####################################################################################################
# Execute shell script to create html files
####################################################################################################

WORKDIR /build
RUN ["chmod", "+x", "/agdacheck.sh"]

CMD ["sh", "/agdacheck.sh"]
28 changes: 28 additions & 0 deletions HoTT-Agda/core/lib/types/Cospan.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# OPTIONS --without-K --rewriting #-}

open import lib.Basics
open import lib.types.Pi

module lib.types.Cospan where

record Cospan {i j k : ULevel} : Type (lsucc (lmax (lmax i j) k)) where
constructor cospan
field
A : Type i
B : Type j
C : Type k
f : A C
g : B C

record ⊙Cospan {i j k : ULevel} : Type (lsucc (lmax (lmax i j) k)) where
constructor ⊙cospan
field
X : Ptd i
Y : Ptd j
Z : Ptd k
f : X ⊙→ Z
g : Y ⊙→ Z

⊙cospan-out : {i j k} ⊙Cospan {i} {j} {k} Cospan {i} {j} {k}
⊙cospan-out (⊙cospan X Y Z f g) =
cospan (de⊙ X) (de⊙ Y) (de⊙ Z) (fst f) (fst g)
78 changes: 78 additions & 0 deletions HoTT-Agda/core/lib/types/Pullback.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{-# OPTIONS --without-K --rewriting --overlapping-instances #-}

open import lib.Basics
open import lib.NType
open import lib.types.Cospan
open import lib.types.Pointed
open import lib.types.Sigma

module lib.types.Pullback where

module _ {i j k} (D : Cospan {i} {j} {k}) where

open Cospan D

record Pullback : Type (lmax i (lmax j k)) where
constructor pullback
field
a : A
b : B
h : f a == g b

pullback= : {a a' : A} (p : a == a') {b b' : B} (q : b == b')
{h : f a == g b} {h' : f a' == g b'} (r : h ∙ ap g q == ap f p ∙ h')
pullback a b h == pullback a' b' h'
pullback= idp idp r =
ap (pullback _ _) (! (∙-unit-r _) ∙ r)

pullback-aβ : {a a' : A} (p : a == a') {b b' : B} (q : b == b')
{h : f a == g b} {h' : f a' == g b'} (r : h ∙ ap g q == ap f p ∙ h')
ap Pullback.a (pullback= p q {h = h} {h' = h'} r) == p
pullback-aβ idp idp r =
ap Pullback.a (ap (pullback _ _) (! (∙-unit-r _) ∙ r))
=⟨ ∘-ap Pullback.a (pullback _ _) _ ⟩
ap (λ _ _) (! (∙-unit-r _) ∙ r)
=⟨ ap-cst _ _ ⟩
idp =∎

pullback-bβ : {a a' : A} (p : a == a') {b b' : B} (q : b == b')
{h : f a == g b} {h' : f a' == g b'} (r : h ∙ ap g q == ap f p ∙ h')
ap Pullback.b (pullback= p q {h = h} {h' = h'} r) == q
pullback-bβ idp idp r =
ap Pullback.b (ap (pullback _ _) (! (∙-unit-r _) ∙ r))
=⟨ ∘-ap Pullback.b (pullback _ _) _ ⟩
ap (λ _ _) (! (∙-unit-r _) ∙ r)
=⟨ ap-cst _ _ ⟩
idp =∎

module _ {i j k} (D : ⊙Cospan {i} {j} {k}) where

⊙Pullback : Ptd (lmax i (lmax j k))
⊙Pullback =
⊙[ Pullback (⊙cospan-out D) ,
pullback (pt X) (pt Y) (snd f ∙ ! (snd g)) ]
where open ⊙Cospan D

module _ {i j k} (D : Cospan {i} {j} {k}) where
open Cospan D

pullback-decomp-equiv : Pullback D ≃ Σ (A × B) (λ {(a , b) f a == g b})
pullback-decomp-equiv = equiv
(λ {(pullback a b h) ((a , b) , h)})
(λ {((a , b) , h) pullback a b h})
(λ _ idp)
(λ _ idp)

module _ {i j k} (n : ℕ₋₂) {D : Cospan {i} {j} {k}} where
open Cospan D

pullback-level : has-level n A has-level n B has-level n C
has-level n (Pullback D)
pullback-level pA pB pC =
equiv-preserves-level ((pullback-decomp-equiv D)⁻¹) where instance _ = pA; _ = pB; _ = pC

instance
pullback-level-instance : {i j k : ULevel} {n : ℕ₋₂} {D : Cospan {i} {j} {k}}
{{has-level n (Cospan.A D)}} {{has-level n (Cospan.B D)}} {{has-level n (Cospan.C D)}}
has-level n (Pullback D)
pullback-level-instance {n = n} {{pA}} {{pB}} {{pC}} = pullback-level n pA pB pC
Loading

0 comments on commit 53ef7b0

Please sign in to comment.