Skip to content

Commit 574e570

Browse files
committed
actually get it building
1 parent 85056cf commit 574e570

File tree

7 files changed

+35
-29
lines changed

7 files changed

+35
-29
lines changed

src/1Lab/Type.lagda.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,8 @@ instance
138138
Number-Lift : ∀ {ℓ ℓ'} {A : Type ℓ} → ⦃ Number A ⦄ → Number (Lift ℓ' A)
139139
Number-Lift {ℓ' = ℓ'} ⦃ a ⦄ .Number.Constraint n = Lift ℓ' (a .Number.Constraint n)
140140
Number-Lift ⦃ a ⦄ .Number.fromNat n ⦃ lift c ⦄ = lift (a .Number.fromNat n ⦃ c ⦄)
141+
142+
absurdω : {A : Typeω} → .⊥ → A
143+
absurdω ()
141144
```
142145
-->

src/Cat/Instances/Simplex.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ unquoteDecl H-Level-Δ-map = declare-record-hlevel 2 H-Level-Δ-map (quote Δ-ma
4646
→ f ≡ g
4747
Δ-map-path p i .map x = p x i
4848
Δ-map-path {f = f} {g} p i .ascending x y w =
49-
is-prop→pathp (λ j → Nat.≤-is-prop {to-nat (p x j)} {to-nat (p y j)})
49+
is-prop→pathp (λ j → Nat.≤-is-prop {p x j .lower} {p y j .lower})
5050
(f .ascending x y w) (g .ascending x y w) i
5151
```
5252
-->

src/Data/Fin/Base.lagda.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,29 @@ would like to enforce that constructions on $\operatorname{Fin}(n)$
4242
wrapped it in `Irr`{.Agda}.
4343

4444
In dependent type theory, it's common to instead define the finite sets
45-
as a family indexed over `Nat`{.Agda}. However, we prefer the definition
46-
above because it lets us `cast`{.Agda} elements of
47-
$\operatorname{Fin}(n)$ along a path $n = m$ in a way that
48-
definitionally preserves the underlying number:
45+
as an inductive family indexed over `Nat`{.Agda}. However, in cubical
46+
type theory, there is a good reason to avoid inductive families: they
47+
have `subst`{.Agda} as an additional constructor, *including* along
48+
constant paths. This makes the normal form of any expression involving
49+
substitution in an indexed family, even if the thing being transported
50+
is a constructor form, very bad.
51+
52+
Instead, we would like the `subst`{.Agda} operation on `Fin`{.Agda} to
53+
definitionally commute with the constructors, and (if possible) to
54+
definitionally preserve the underlying numeric value. Defining
55+
`Fin`{.Agda} as an indexed type with an irrelevant proof field achieves
56+
exactly this:
4957

5058
```agda
51-
cast : ∀ {m n} → m ≡ n → Fin m → Fin n
52-
cast p (fin n ⦃ i ⦄) = record
53-
{ lower = n
54-
; bounded = subst (n Nat.<_) p <$> i
55-
}
59+
private
60+
cast : ∀ {m n} → m ≡ n → Fin m → Fin n
61+
cast p (fin n ⦃ i ⦄) = record
62+
{ lower = n
63+
; bounded = subst (n Nat.<_) p <$> i
64+
}
65+
66+
_ : ∀ {m n} {p : m ≡ n} {x : Fin m} → subst Fin p x ≡ cast p x
67+
_ = refl
5668
```
5769

5870
<!--
@@ -141,15 +153,6 @@ Fin-elim P pfzero pfsuc i with fin-view i
141153
```agda
142154
fin-ap : ∀ {n} {x y : Fin n} → x .lower ≡ y .lower → x ≡ y
143155
fin-ap p = ap₂ (λ x y → fin x ⦃ y ⦄) p (to-pathp refl)
144-
145-
cast-uncast : ∀ {m n} → (p : m ≡ n) → ∀ x → cast (sym p) (cast p x) ≡ x
146-
cast-uncast p x = refl
147-
148-
cast-is-equiv : ∀ {m n} (p : m ≡ n) → is-equiv (cast p)
149-
cast-is-equiv p = is-iso→is-equiv $ iso
150-
(cast (sym p))
151-
(cast-uncast (sym p))
152-
(cast-uncast p)
153156
```
154157
-->
155158

src/Data/Fin/Closure.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ binary products:
116116
Finite-multiply : (Fin n × Fin m) ≃ Fin (n * m)
117117
Finite-multiply {n} {m} =
118118
(Fin n × Fin m) ≃⟨ Finite-sum (λ _ → m) ⟩
119-
Fin (sum n (λ _ → m)) ≃⟨ cast (sum≡* n m) , cast-is-equiv (sum≡* n m) ⟩
119+
Fin (sum n (λ _ → m)) ≃⟨ path→equiv (ap Fin (sum≡* n m)) ⟩
120120
Fin (n * m) ≃∎
121121
where
122122
sum≡* : ∀ n m → sum n (λ _ → m) ≡ n * m

src/Data/Fin/Finite.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ same-cardinality→equiv
160160
same-cardinality→equiv ⦃ fa ⦄ ⦃ fb ⦄ p = do
161161
ea ← fa .Finite.enumeration
162162
eb ← fb .Finite.enumeration
163-
pure (ea ∙e (_ , cast-is-equiv p) ∙e eb e⁻¹)
163+
pure (ea ∙e path→equiv (ap Fin p) ∙e eb e⁻¹)
164164
165165
module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} ⦃ fb : Finite B ⦄
166166
(e : ∥ A ≃ B ∥) (f : A → B) where

src/Data/List/Membership.lagda.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ member→member-nub {xs = x ∷ xs} (there α) with elem? x (nub xs)
184184

185185
<!--
186186
```agda
187-
!-tabulate : ∀ {n} (f : Fin n → A) i → tabulate f ! i ≡ f (cast (length-tabulate f) i)
187+
!-tabulate : ∀ {n} (f : Fin n → A) i → tabulate f ! i ≡ f (subst Fin (length-tabulate f) i)
188188
!-tabulate _ ix with fin-view ix
189189
!-tabulate {n = suc n} f _ | zero = refl
190190
!-tabulate {n = suc n} f _ | suc i = !-tabulate (f ∘ fsuc) i
191191
192192
!-tabulate-fibre : ∀ {n} (f : Fin n → A) x → fibre (tabulate f !_) x ≃ fibre f x
193-
!-tabulate-fibre f x = Σ-ap (cast (length-tabulate f) , cast-is-equiv (length-tabulate f)) λ i →
193+
!-tabulate-fibre f x = Σ-ap (path→equiv (ap Fin (length-tabulate f))) λ i →
194194
path→equiv (ap (_≡ x) (!-tabulate f i))
195195
196196
member-tabulate : ∀ {n} (f : Fin n → A) x → (x ∈ tabulate f) ≃ fibre f x

src/Data/Nat/Prime.lagda.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ distinct-primes→coprime {a@(suc a')} {b@(suc b')} apr bpr a≠b = record
150150
```agda
151151
is-prime-or-composite : ∀ n → 1 < n → is-prime n ⊎ is-composite n
152152
is-prime-or-composite n@(suc (suc m)) (s≤s p)
153-
with Fin-omniscience {n = n} (λ k → 1 < to-nat k × to-nat k ∣ n)
153+
with Fin-omniscience {n = n} (λ k → 1 < k .lower × k .lower ∣ n)
154154
... | inr prime = inl record { prime≠1 = suc≠zero ∘ suc-inj ; primality = no-divisors→prime } where
155155
no-divisors→prime : ∀ d → d ∣ n → d ≡ 1 ⊎ d ≡ n
156156
no-divisors→prime d div with d ≡? 1
@@ -172,18 +172,18 @@ is-prime-or-composite n@(suc (suc m)) (s≤s p)
172172
open Σ (∣→fibre div) renaming (fst to quot ; snd to path)
173173
174174
abstract
175-
least' : (p' : Nat) → 1 < p' → p' ∣ n → to-nat ix ≤ p'
175+
least' : (p' : Nat) → 1 < p' → p' ∣ n → ix .lower ≤ p'
176176
least' p' x div with ≤-strengthen (m∣n→m≤n div)
177-
... | inl same = ≤-trans ≤-ascend (subst (to-nat ix <_) (sym same) (to-ℕ< ix .snd))
177+
... | inl same = ≤-trans ≤-ascend (subst (ix .lower <_) (sym same) (to-ℕ< ix .snd))
178178
... | inr less = least (from-ℕ< (p' , less)) (x , div)
179179
180-
prime : is-prime (to-nat ix)
181-
prime = least-divisor→is-prime (to-nat ix) n proper div least'
180+
prime : is-prime (ix .lower)
181+
prime = least-divisor→is-prime (ix .lower) n proper div least'
182182
183183
proper' : 1 < quot
184184
proper' with quot | path
185185
... | 0 | q = absurd (<-irrefl q (s≤s 0≤x))
186-
... | 1 | q = absurd (<-irrefl (sym (+-zeror (to-nat ix)) ∙ q) (to-ℕ< ix .snd))
186+
... | 1 | q = absurd (<-irrefl (sym (+-zeror (ix .lower)) ∙ q) (to-ℕ< ix .snd))
187187
... | suc (suc n) | p = s≤s (s≤s 0≤x)
188188
189189
record Factorisation (n : Nat) : Type where

0 commit comments

Comments
 (0)