Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Binary Sum Types and Truncations #12

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
778eb6e
adding union types
vrahli Dec 17, 2023
a1637c8
still adding union types
vrahli Dec 18, 2023
0f1e422
still adding union types
vrahli Dec 18, 2023
8820cf3
still adding union types (got started on Fundamental)
vrahli Dec 18, 2023
ccc8f38
still on unions
vrahli Dec 19, 2023
44b2a0f
still adding unions
vrahli Dec 21, 2023
ad2fda2
still working on unions
vrahli Dec 22, 2023
05ee04d
some progress on cases
vrahli Jan 9, 2024
910a795
a bit more on cases
vrahli Jan 10, 2024
0c1cc98
changed the logical relation for unit
vrahli Jan 12, 2024
ad8fb90
still on cases
vrahli Jan 12, 2024
b0b0f0c
some progress with cases
vrahli Jan 13, 2024
f7b90de
still on cases
vrahli Jan 13, 2024
8a7afe1
some progress with cases
vrahli Jan 13, 2024
1114c97
still working on unions
vrahli Jan 13, 2024
04962d2
not much
vrahli Jan 14, 2024
2734d50
still fixing cases
vrahli Jan 16, 2024
ea2cae1
still fixing cases
vrahli Jan 16, 2024
eb901db
still fixing cases
vrahli Jan 16, 2024
62782bb
not much
vrahli Jan 16, 2024
fcb4382
not much
vrahli Jan 16, 2024
ccc260d
not much
vrahli Jan 17, 2024
f9f6222
still working on cases
vrahli Jan 19, 2024
2c5f8a8
a bit of progress on unions
vrahli Feb 2, 2024
d2eea7c
still experimenting
vrahli Feb 3, 2024
abbbda7
still experimenting
vrahli Feb 4, 2024
18ff19f
still experimenting
vrahli Feb 4, 2024
fcf9c5c
still experimenting
vrahli Feb 4, 2024
1085c09
still experimenting
vrahli Feb 5, 2024
786cb08
finished adding union types
vrahli Feb 5, 2024
cb08374
removed commented out code
vrahli Feb 5, 2024
2acee10
started adding truncations
vrahli Feb 5, 2024
4feaabb
still adding truncations
vrahli Feb 5, 2024
94da668
still looking into truncation
vrahli Feb 5, 2024
9c3a2ac
still on truncations
vrahli Feb 6, 2024
1aad983
still on truncations
vrahli Feb 7, 2024
4f9f4d9
still on truncation
vrahli Feb 7, 2024
a5dcf8a
still on truncation
vrahli Feb 7, 2024
a83b6b6
still on truncation
vrahli Feb 7, 2024
97d1dcc
still on truncations
vrahli Feb 8, 2024
479f5a6
still on truncation
vrahli Feb 8, 2024
374f15c
finished adding truncations
vrahli Feb 8, 2024
f173455
removed some unncessary hyps
vrahli Feb 11, 2024
ca25e67
not much
vrahli Mar 1, 2024
15bbade
cubical compatible
vrahli Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Application/NegativeAxioms/Canonicity.agda
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Application.NegativeAxioms.Canonicity where

open import Definition.Untyped as U
open import Definition.Untyped as U hiding (ℕ≢∪ ; Empty≢∪ ; ℕ≢∥ ; Empty≢∥)

open import Definition.Typed
open import Definition.Typed.Properties
Expand Down Expand Up @@ -142,6 +142,18 @@ appNeg (conv n c) c' = appNeg n (trans c c')
¬negℕ (sigma _ _ _) c = ℕ≢Σ (sym c)
¬negℕ (conv n c) c' = ¬negℕ n (trans c c')

¬neg∪ : NegativeType Γ C → Γ ⊢ C ≡ A ∪ B → ⊥
¬neg∪ empty c = Empty≢∪ c
¬neg∪ (pi _ _) c = B≢∪ BΠ c
¬neg∪ (sigma _ _ _) c = B≢∪ BΣ c
¬neg∪ (conv n c) c' = ¬neg∪ n (trans c c')

¬neg∥ : NegativeType Γ C → Γ ⊢ C ≡ ∥ A ∥ → ⊥
¬neg∥ empty c = Empty≢∥ c
¬neg∥ (pi _ _) c = B≢∥ BΠ c
¬neg∥ (sigma _ _ _) c = B≢∥ BΣ c
¬neg∥ (conv n c) c' = ¬neg∥ n (trans c c')

-- Negative contexts
---------------------------------------------------------------------------

Expand Down Expand Up @@ -174,6 +186,8 @@ module Main (nΓ : NegativeContext Γ) (consistent : ∀{t} → Γ ⊢ t ∷ Emp
neNeg (fstⱼ ⊢A A⊢B d ) (fstₙ n ) = fstNeg (neNeg d n) (refl (Σⱼ ⊢A ▹ A⊢B))
neNeg (sndⱼ ⊢A A⊢B d ) (sndₙ n ) = sndNeg (neNeg d n) (refl (Σⱼ ⊢A ▹ A⊢B)) (fstⱼ ⊢A A⊢B d)
neNeg (natrecⱼ _ _ _ d) (natrecₙ _ _ _ n ) = ⊥-elim (¬negℕ (neNeg d n) ⊢ℕ) where ⊢ℕ = refl (ℕⱼ (wfTerm d))
neNeg (casesⱼ d _ _ _ ) (casesₙ _ n _ _ ) = ⊥-elim (¬neg∪ (neNeg d n) (refl (syntacticTerm d)))
neNeg (∥ₑⱼ d _ _ ) (∥ₑₙ _ n _ ) = ⊥-elim (¬neg∥ (neNeg d n) (refl (syntacticTerm d)))
neNeg (Emptyrecⱼ _ d ) (Emptyrecₙ _ _ ) = ⊥-elim (consistent d)
neNeg (conv d c ) n = conv (neNeg d n) c

Expand All @@ -199,13 +213,18 @@ module Main (nΓ : NegativeContext Γ) (consistent : ∀{t} → Γ ⊢ t ∷ Emp
-- * Canonical types
nfN (Πⱼ _ ▹ _) (Πₙ _ _) c = ⊥-elim (U≢ℕ c)
nfN (Σⱼ _ ▹ _) (Σₙ _ _) c = ⊥-elim (U≢ℕ c)
nfN (_ ∪ⱼ _) (∪ₙ _ _) c = ⊥-elim (U≢ℕ c)
nfN (∥ _ ∥ⱼ) (∥ₙ _) c = ⊥-elim (U≢ℕ c)
nfN (ℕⱼ _) ℕₙ c = ⊥-elim (U≢ℕ c)
nfN (Emptyⱼ _) Emptyₙ c = ⊥-elim (U≢ℕ c)
nfN (Unitⱼ _) Unitₙ c = ⊥-elim (U≢ℕ c)

-- * Canonical forms
nfN (lamⱼ _ _) (lamₙ _) c = ⊥-elim (ℕ≢Π (sym c))
nfN (prodⱼ _ _ _ _) (prodₙ _ _) c = ⊥-elim (ℕ≢Σ (sym c))
nfN (injlⱼ _ _) (injlₙ _) c = ⊥-elim (ℕ≢∪ (sym c))
nfN (injrⱼ _ _) (injrₙ _) c = ⊥-elim (ℕ≢∪ (sym c))
nfN (∥ᵢⱼ _) (∥ᵢₙ _) c = ⊥-elim (ℕ≢∥ (sym c))
nfN (starⱼ _) starₙ c = ⊥-elim (ℕ≢Unitⱼ (sym c))
-- q.e.d

Expand Down
48 changes: 48 additions & 0 deletions Definition/Conversion.agda
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ mutual
→ Γ ⊢ h [conv↑] g ∷ Π ℕ ▹ (F ▹▹ F [ suc (var x0) ]↑)
→ Γ ⊢ k ~ l ↓ ℕ
→ Γ ⊢ natrec F a₀ h k ~ natrec G b₀ g l ↑ F [ k ]
cases-cong : ∀ {t t' u u' v v' A B C C'}
→ Γ ⊢ C [conv↑] C'
→ Γ ⊢ t ~ t' ↓ A ∪ B
→ Γ ⊢ u [conv↑] u' ∷ A ▹▹ C
→ Γ ⊢ v [conv↑] v' ∷ B ▹▹ C
→ Γ ⊢ cases C t u v ~ cases C' t' u' v' ↑ C
∥ₑ-cong : ∀ {a a' f f' A B B'}
→ Γ ⊢ B [conv↑] B'
→ Γ ⊢ a ~ a' ↓ ∥ A ∥
→ Γ ⊢ f [conv↑] f' ∷ A ▹▹ ∥ B ∥
→ Γ ⊢ ∥ₑ B a f ~ ∥ₑ B' a' f' ↑ ∥ B ∥
Emptyrec-cong : ∀ {k l F G}
→ Γ ⊢ F [conv↑] G
→ Γ ⊢ k ~ l ↓ Empty
Expand Down Expand Up @@ -94,6 +105,13 @@ mutual
→ Γ ⊢ F [conv↑] H
→ Γ ∙ F ⊢ G [conv↑] E
→ Γ ⊢ Σ F ▹ G [conv↓] Σ H ▹ E
∪-cong : ∀ {A B C D}
→ Γ ⊢ A [conv↑] B
→ Γ ⊢ C [conv↑] D
→ Γ ⊢ A ∪ C [conv↓] B ∪ D
∥-cong : ∀ {A B}
→ Γ ⊢ A [conv↑] B
→ Γ ⊢ ∥ A ∥ [conv↓] ∥ B ∥

-- Term equality.
record _⊢_[conv↑]_∷_ (Γ : Con Term n) (t u A : Term n) : Set where
Expand Down Expand Up @@ -150,6 +168,36 @@ mutual
→ Γ ⊢ fst p [conv↑] fst r ∷ F
→ Γ ⊢ snd p [conv↑] snd r ∷ G [ fst p ]
→ Γ ⊢ p [conv↓] r ∷ Σ F ▹ G
∪₁-η : ∀ {p r pa ra A B}
→ Γ ⊢ p ∷ A ∪ B
→ Γ ⊢ r ∷ A ∪ B
→ InjectionL p pa
→ InjectionL r ra
→ Γ ⊢ pa [conv↑] ra ∷ A
→ Γ ⊢ p [conv↓] r ∷ A ∪ B
∪₂-η : ∀ {p r pa ra A B}
→ Γ ⊢ p ∷ A ∪ B
→ Γ ⊢ r ∷ A ∪ B
→ InjectionR p pa
→ InjectionR r ra
→ Γ ⊢ pa [conv↑] ra ∷ B
→ Γ ⊢ p [conv↓] r ∷ A ∪ B
∪₃-η : ∀ {p r A B C D}
→ Γ ⊢ A ≡ C
→ Γ ⊢ B ≡ D
→ Γ ⊢ p ~ r ↓ A ∪ B
→ Γ ⊢ p [conv↓] r ∷ C ∪ D
∥₁-η : ∀ {p r pa ra A}
→ Γ ⊢ p ∷ ∥ A ∥
→ Γ ⊢ r ∷ ∥ A ∥
→ TruncI p pa
→ TruncI r ra
→ Γ ⊢ pa [conv↑] ra ∷ A
→ Γ ⊢ p [conv↓] r ∷ ∥ A ∥
∥₂-η : ∀ {p r A B}
→ Γ ⊢ A ≡ B
→ Γ ⊢ p ~ r ↓ ∥ A ∥
→ Γ ⊢ p [conv↓] r ∷ ∥ B ∥
η-unit : ∀ {k l}
→ Γ ⊢ k ∷ Unit
→ Γ ⊢ l ∷ Unit
Expand Down
49 changes: 44 additions & 5 deletions Definition/Conversion/Conversion.agda
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ open import Definition.Typed.Properties
open import Definition.Conversion
open import Definition.Conversion.Stability
open import Definition.Conversion.Soundness
open import Definition.Conversion.Whnf using (ne~↑ ; ne~↓)
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.Substitution
open import Definition.Typed.Consequences.Injectivity
Expand Down Expand Up @@ -84,14 +85,52 @@ mutual
rProd
(convConv↑Term Γ≡Δ F≡ fstConv)
(convConv↑Term Γ≡Δ (substTypeEq G≡ (refl ⊢fst)) sndConv)
convConv↓Term Γ≡Δ A≡B whnfB (∪₁-η ⊢p ⊢r pInj rInj cnv)
with ∪≡A A≡B whnfB
... | C , D , PE.refl =
let C≡ , D≡ = ∪-injectivity A≡B
in ∪₁-η (stabilityTerm Γ≡Δ (conv ⊢p A≡B))
(stabilityTerm Γ≡Δ (conv ⊢r A≡B))
pInj rInj
(convConv↑Term Γ≡Δ C≡ cnv)
convConv↓Term Γ≡Δ A≡B whnfB (∪₂-η ⊢p ⊢r pInj rInj cnv)
with ∪≡A A≡B whnfB
... | C , D , PE.refl =
let C≡ , D≡ = ∪-injectivity A≡B
in ∪₂-η (stabilityTerm Γ≡Δ (conv ⊢p A≡B))
(stabilityTerm Γ≡Δ (conv ⊢r A≡B))
pInj rInj
(convConv↑Term Γ≡Δ D≡ cnv)
convConv↓Term Γ≡Δ A≡B whnfB (∪₃-η c₁ c₂ p~r)
with ∪≡A A≡B whnfB
... | C , D , PE.refl =
let C≡ , D≡ = ∪-injectivity A≡B
in ∪₃-η (stabilityEq Γ≡Δ (trans c₁ C≡))
(stabilityEq Γ≡Δ (trans c₂ D≡))
(stability~↓ Γ≡Δ p~r)
convConv↓Term Γ≡Δ A≡B whnfB (∥₁-η ⊢p ⊢r pi ri cnv)
with ∥≡A A≡B whnfB
... | C , PE.refl =
let C≡ = ∥-injectivity A≡B
in ∥₁-η (stabilityTerm Γ≡Δ (conv ⊢p A≡B))
(stabilityTerm Γ≡Δ (conv ⊢r A≡B))
pi ri
(convConv↑Term Γ≡Δ C≡ cnv)
convConv↓Term Γ≡Δ A≡B whnfB (∥₂-η c₁ p~r)
with ∥≡A A≡B whnfB
... | C , PE.refl =
let C≡ = ∥-injectivity A≡B
in ∥₂-η (stabilityEq Γ≡Δ (trans c₁ C≡))
(stability~↓ Γ≡Δ p~r)
convConv↓Term Γ≡Δ A≡B whnfB (η-unit [t] [u] tUnit uUnit) rewrite Unit≡A A≡B whnfB =
let [t] = stabilityTerm Γ≡Δ [t]
[u] = stabilityTerm Γ≡Δ [u]
in η-unit [t] [u] tUnit uUnit

-- Conversion of algorithmic equality with the same context.
convConvTerm : ∀ {t u A B}
→ Γ ⊢ t [conv↑] u ∷ A
→ Γ ⊢ A ≡ B
→ Γ ⊢ t [conv↑] u ∷ B
convConvTerm t<>u A≡B = convConv↑Term (reflConEq (wfEq A≡B)) A≡B t<>u
abstract
convConvTerm : ∀ {t u A B}
→ Γ ⊢ t [conv↑] u ∷ A
→ Γ ⊢ A ≡ B
→ Γ ⊢ t [conv↑] u ∷ B
convConvTerm t<>u A≡B = convConv↑Term (reflConEq (wfEq A≡B)) A≡B t<>u
Loading
Loading