Skip to content

Commit 7e8dc73

Browse files
4e554c4cTOTBWF
andcommitted
refactor: use a refinement type for Data.Vec
resolves: #567 Co-authored-by: Reed Mullanix <reedmullanix@gmail.com>
1 parent ed52d94 commit 7e8dc73

23 files changed

Lines changed: 373 additions & 259 deletions

src/1Lab/Reflection.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ open import Meta.Alt public
3131
3232
open Data.Product.NAry using ([_]) public
3333
open Data.List.Base hiding (lookup ; tabulate) public
34-
open Data.Vec.Base using (Vec ; [] ; _∷_ ; lookup ; tabulate) public
34+
open Data.Vec.Base hiding (_++_ ; tail ; head; zero; suc) public
3535
open Data.Bool.Base public
3636
open Data.Dec.Base public
3737

src/1Lab/Reflection/Deriving/Show.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open import Data.String.Show
99
open import Data.String.Base
1010
open import Data.Char.Base
1111
open import Data.Fin.Base
12-
open import Data.Vec.Base hiding (map)
12+
open import Data.Vec.Base
1313
open import Data.Nat.Base
1414
open import Data.Int.Base using (Int ; pos ; negsuc)
1515

src/1Lab/Reflection/List.lagda.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,11 @@ not-member! {not-mem = not-mem} = not-mem
184184

185185
```agda
186186
private
187-
member-example : true ∈ [ false , true , false , true , false ]
187+
member-example : true ∈ [ false , true , false , true , false ]L
188188
member-example = member!
189-
190-
not-member-example : true ∉ [ false , false , false ]
189+
not-member-example : true ∉ [ false , false , false ]L
191190
not-member-example = not-member!
192191
193-
unique-member-example : is-contr (true ∈ [ false , true , false , false ])
192+
unique-member-example : is-contr (true ∈ [ false , true , false , false ]L)
194193
unique-member-example = unique-member!
195194
```

src/1Lab/Reflection/Variables.agda

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private
8181
env-rec Mot _▷*_ []* (xs ▷ x) = env-rec (Mot ∘ suc) _▷*_ ([]* ▷* x) xs
8282

8383
reverse : Env A n Vec A n
84-
reverse {A = A} env = env-rec (Vec A) (λ xs x x ∷ xs) [] env
84+
reverse {A = A} env = env-rec (Vec A) (λ xs x x ∷v xs) []v env
8585

8686

8787

src/Algebra/Ring/Solver.agda

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ module Impl {ℓ} {R : Type ℓ} (cring : CRing-on R) where
7373
En : {n} Normal n Vec R n R
7474

7575
Ep ∅ i = R.0r
76-
Ep (p *x+ c) (x ∷ e) = Ep p (x ∷ e) R.* x R.+ En c e
76+
Ep (p *x+ c) v with (x ∷ e) vec-view v = Ep p (x ∷v e) R.* x R.+ En c e
7777

7878
En (con x) i = embed-coe x
7979
En (poly x) i = Ep x i
@@ -234,32 +234,34 @@ module Impl {ℓ} {R : Type ℓ} (cring : CRing-on R) where
234234
⟦ x ⟧ₙ ρ = En (normal x) ρ
235235

236236
0n-hom : {n} (ρ : Vec R n) En 0n ρ ≡ R.0r
237-
0n-hom [] = ℤ↪R.pres-0
238-
0n-hom (x ∷ ρ) = refl
237+
0n-hom v with vec-view v
238+
... | [] = ℤ↪R.pres-0
239+
... | (x ∷ ρ) = refl
239240

240241
1n-hom : {n} (ρ : Vec R n) En 1n ρ ≡ R.1r
241-
1n-hom [] = ℤ↪R.pres-id
242-
1n-hom (x ∷ ρ) =
242+
1n-hom v with vec-view v
243+
... | [] = ℤ↪R.pres-id
244+
... | (x ∷ ρ) =
243245
(R.0r R.* x) R.+ (En 1n ρ) ≡⟨ R.eliml R.*-zerol ⟩
244246
En 1n ρ ≡⟨ 1n-hom ρ ⟩
245247
R.1r ∎
246248

247249
*x+ₙ-sound
248250
: {n} (p : Poly (suc n)) (c : Normal n) ρ
249251
Ep (p *x+ₙ c) ρ ≡ Ep (p *x+ c) ρ
250-
*x+ₙ-sound ∅ c (e ∷ ρ) with c ==ₙ 0n
251-
... | just x = sym $
252-
Ep (∅ *x+ ⌜ c ⌝) (e ∷ ρ) ≡⟨ ap! x ⟩
253-
Ep (∅ *x+ 0n) (e ∷ ρ) ≡⟨⟩
252+
*x+ₙ-sound ∅ c v with vec-view v | c ==ₙ 0n
253+
... | (e ∷ ρ) | just x = sym $
254+
Ep (∅ *x+ ⌜ c ⌝) (e ∷v ρ) ≡⟨ ap! x ⟩
255+
Ep (∅ *x+ 0n) (e ∷v ρ) ≡⟨⟩
254256
(R.0r R.* e) R.+ En 0n ρ ≡⟨ R.eliml R.*-zerol ⟩
255257
En 0n ρ ≡⟨ 0n-hom ρ ⟩
256258
R.0r ∎
257-
... | nothing = refl
259+
... | (e ∷ ρ) | nothing = refl
258260
*x+ₙ-sound (p *x+ x) c ρ = refl
259261

260262
∅*x+ₙ-hom
261263
: {n} (c : Normal n) x ρ
262-
Ep (∅ *x+ₙ c) (x ∷ ρ) ≡ En c ρ
264+
Ep (∅ *x+ₙ c) (x ∷v ρ) ≡ En c ρ
263265
∅*x+ₙ-hom c x ρ with c ==ₙ 0n
264266
... | just x = sym (ap (λ c En c ρ) x ∙ 0n-hom ρ)
265267
... | nothing = R.eliml R.*-zerol
@@ -273,48 +275,48 @@ module Impl {ℓ} {R : Type ℓ} (cring : CRing-on R) where
273275

274276
+ₚ-hom ∅ q ρ = sym R.+-idl
275277
+ₚ-hom (p *x+ x) ∅ ρ = sym R.+-idr
276-
+ₚ-hom (p *x+ c) (q *x+ d) (x ∷ ρ) =
277-
Ep ((p +ₚ q) *x+ₙ (c +ₙ d)) (x ∷ ρ) ≡⟨ *x+ₙ-sound (p +ₚ q) (c +ₙ d) (x ∷ ρ) ⟩
278-
Ep ((p +ₚ q) *x+ (c +ₙ d)) (x ∷ ρ) ≡⟨⟩
279-
⌜ Ep (p +ₚ q) (x ∷ ρ) ⌝ R.* x R.+ En (c +ₙ d) ρ ≡⟨ ap! (+ₚ-hom p q (x ∷ ρ)) ⟩
280-
(Ep p (x ∷ ρ) R.+ Ep q (x ∷ ρ)) R.* x R.+ ⌜ En (c +ₙ d) ρ ⌝ ≡⟨ ap! (+ₙ-hom c d ρ) ⟩
281-
⌜ (Ep p (x ∷ ρ) R.+ Ep q (x ∷ ρ)) R.* x ⌝ R.+ (En c ρ R.+ En d ρ) ≡⟨ ap! R.*-distribr ⟩
282-
Ep p (x ∷ ρ) R.* x R.+ Ep q (x ∷ ρ) R.* x R.+ (En c ρ R.+ En d ρ) ≡⟨ R.a.pullr (R.pulll R.+-commutes) ⟩
283-
Ep p (x ∷ ρ) R.* x R.+ (En c ρ R.+ Ep q (x ∷ ρ) R.* x R.+ En d ρ) ≡⟨ R.a.extendl (R.a.pulll refl) ⟩
284-
Ep p (x ∷ ρ) R.* x R.+ En c ρ R.+ (Ep q (x ∷ ρ) R.* x R.+ En d ρ)
278+
+ₚ-hom (p *x+ c) (q *x+ d) v with (x ∷ ρ) vec-view v =
279+
Ep ((p +ₚ q) *x+ₙ (c +ₙ d)) (x ∷v ρ) ≡⟨ *x+ₙ-sound (p +ₚ q) (c +ₙ d) (x ∷v ρ) ⟩
280+
Ep ((p +ₚ q) *x+ (c +ₙ d)) (x ∷v ρ) ≡⟨⟩
281+
⌜ Ep (p +ₚ q) (x ∷v ρ) ⌝ R.* x R.+ En (c +ₙ d) ρ ≡⟨ ap! (+ₚ-hom p q (x ∷v ρ)) ⟩
282+
(Ep p (x ∷v ρ) R.+ Ep q (x ∷v ρ)) R.* x R.+ ⌜ En (c +ₙ d) ρ ⌝ ≡⟨ ap! (+ₙ-hom c d ρ) ⟩
283+
⌜ (Ep p (x ∷v ρ) R.+ Ep q (x ∷v ρ)) R.* x ⌝ R.+ (En c ρ R.+ En d ρ) ≡⟨ ap! R.*-distribr ⟩
284+
Ep p (x ∷v ρ) R.* x R.+ Ep q (x ∷v ρ) R.* x R.+ (En c ρ R.+ En d ρ) ≡⟨ R.a.pullr (R.pulll R.+-commutes) ⟩
285+
Ep p (x ∷v ρ) R.* x R.+ (En c ρ R.+ Ep q (x ∷v ρ) R.* x R.+ En d ρ) ≡⟨ R.a.extendl (R.a.pulll refl) ⟩
286+
Ep p (x ∷v ρ) R.* x R.+ En c ρ R.+ (Ep q (x ∷v ρ) R.* x R.+ En d ρ) ∎
285287
+ₙ-hom (con x) (con y) ρ = ℤ↪R.pres-+ (lift x) (lift y)
286288
+ₙ-hom (poly p) (poly q) ρ = +ₚ-hom p q ρ
287289

288290
*x+-hom
289291
: {n} (p q : Poly (suc n)) x ρ
290-
Ep (p *x+ₚ q) (x ∷ ρ)
291-
≡ Ep p (x ∷ ρ) R.* x R.+ Ep q (x ∷ ρ)
292+
Ep (p *x+ₚ q) (x ∷v ρ)
293+
≡ Ep p (x ∷v ρ) R.* x R.+ Ep q (x ∷v ρ)
292294
*x+-hom ∅ ∅ x ρ = R.introl R.*-zerol
293295
*x+-hom (p *x+ c) ∅ x ρ = ap₂ R._+_ refl (0n-hom ρ)
294296
*x+-hom p (q *x+ d) x ρ =
295-
Ep (p *x+ₚ (q *x+ d)) (x ∷ ρ) ≡⟨⟩
296-
Ep ((p +ₚ q) *x+ₙ d) (x ∷ ρ) ≡⟨ *x+ₙ-sound (p +ₚ q) d (x ∷ ρ) ⟩
297-
⌜ Ep (p +ₚ q) (x ∷ ρ) ⌝ R.* x R.+ En d ρ ≡⟨ ap! (+ₚ-hom p q (x ∷ ρ)) ⟩
298-
⌜ (Ep p (x ∷ ρ) R.+ Ep q (x ∷ ρ)) R.* x ⌝ R.+ En d ρ ≡⟨ ap! R.*-distribr ⟩
299-
Ep p (x ∷ ρ) R.* x R.+ Ep q (x ∷ ρ) R.* x R.+ En d ρ ≡⟨ R.pullr refl ⟩
300-
Ep p (x ∷ ρ) R.* x R.+ (Ep q (x ∷ ρ) R.* x R.+ En d ρ) ∎
297+
Ep (p *x+ₚ (q *x+ d)) (x ∷v ρ) ≡⟨⟩
298+
Ep ((p +ₚ q) *x+ₙ d) (x ∷v ρ) ≡⟨ *x+ₙ-sound (p +ₚ q) d (x ∷v ρ) ⟩
299+
⌜ Ep (p +ₚ q) (x ∷v ρ) ⌝ R.* x R.+ En d ρ ≡⟨ ap! (+ₚ-hom p q (x ∷v ρ)) ⟩
300+
⌜ (Ep p (x ∷v ρ) R.+ Ep q (x ∷v ρ)) R.* x ⌝ R.+ En d ρ ≡⟨ ap! R.*-distribr ⟩
301+
Ep p (x ∷v ρ) R.* x R.+ Ep q (x ∷v ρ) R.* x R.+ En d ρ ≡⟨ R.pullr refl ⟩
302+
Ep p (x ∷v ρ) R.* x R.+ (Ep q (x ∷v ρ) R.* x R.+ En d ρ) ∎
301303

302304
*ₙₚ-hom
303305
: {n} (c : Normal n) (p : Poly (suc n)) x ρ
304-
Ep (c *ₙₚ p) (x ∷ ρ) ≡ En c ρ R.* Ep p (x ∷ ρ)
306+
Ep (c *ₙₚ p) (x ∷v ρ) ≡ En c ρ R.* Ep p (x ∷v ρ)
305307
*ₚₙ-hom
306308
: {n} (c : Normal n) (p : Poly (suc n)) x ρ
307-
Ep (p *ₚₙ c) (x ∷ ρ) ≡ Ep p (x ∷ ρ) R.* En c ρ
309+
Ep (p *ₚₙ c) (x ∷v ρ) ≡ Ep p (x ∷v ρ) R.* En c ρ
308310
*ₙ-hom : {n} (c d : Normal n) ρ En (c *ₙ d) ρ ≡ En c ρ R.* En d ρ
309311
*ₚ-hom : {n} (p q : Poly (suc n)) ρ Ep (p *ₚ q) ρ ≡ Ep p ρ R.* Ep q ρ
310312

311313
*ₚ-hom ∅ q ρ = sym R.*-zerol
312314
*ₚ-hom (p *x+ c) ∅ ρ = sym R.*-zeror
313-
*ₚ-hom (p *x+ c) (q *x+ d) (x ∷ ρ) =
314-
*x+ₙ-sound ((p *ₚ q) *x+ₚ ((p *ₚₙ d) +ₚ (c *ₙₚ q))) _ (x ∷ ρ)
315+
*ₚ-hom (p *x+ c) (q *x+ d) v with (x ∷ ρ) vec-view v =
316+
*x+ₙ-sound ((p *ₚ q) *x+ₚ ((p *ₚₙ d) +ₚ (c *ₙₚ q))) _ (x ∷v ρ)
315317
∙ ap₂ R._+_ (ap₂ R._*_ (*x+-hom (p *ₚ q) ((p *ₚₙ d) +ₚ (c *ₙₚ q)) x ρ) refl) refl
316-
∙ ap₂ R._+_ (ap₂ R._*_ (ap₂ R._+_ (ap (R._* x) (*ₚ-hom p q (x ∷ ρ)))
317-
(+ₚ-hom (p *ₚₙ d) (c *ₙₚ q) (x ∷ ρ))) refl
318+
∙ ap₂ R._+_ (ap₂ R._*_ (ap₂ R._+_ (ap (R._* x) (*ₚ-hom p q (x ∷v ρ)))
319+
(+ₚ-hom (p *ₚₙ d) (c *ₙₚ q) (x ∷v ρ))) refl
318320
∙ ap₂ R._*_ (ap₂ R._+_ refl (ap₂ R._+_ (*ₚₙ-hom d p x ρ) (*ₙₚ-hom c q x ρ)))
319321
refl) refl
320322
∙ ap₂ R._+_ refl (*ₙ-hom c d ρ) ∙ lemma _ _ _ _ _
@@ -372,26 +374,27 @@ module Impl {ℓ} {R : Type ℓ} (cring : CRing-on R) where
372374
-ₚ-hom : {n} (p : Poly (suc n)) ρ Ep (-ₚ p) ρ ≡ R.- Ep p ρ
373375
-ₙ-hom : {n} (n : Normal n) ρ En (-ₙ n) ρ ≡ R.- En n ρ
374376

375-
-ₚ-hom p (x ∷ ρ) =
376-
*ₙₚ-hom (-ₙ 1n) p x ρ
377+
-ₚ-hom p v with (x ∷ ρ) vec-view v =
378+
*ₙₚ-hom (-ₙ 1n) p x ρ
377379
∙ ap₂ R._*_ (-ₙ-hom 1n ρ ∙ ap R.-_ (1n-hom ρ)) refl
378380
∙ R.*-negatel ∙ ap R.-_ R.*-idl
379381
-ₙ-hom (con x) ρ = ℤ↪R.pres-neg {x = lift x}
380382
-ₙ-hom (poly x) ρ = -ₚ-hom x ρ
381383

382384
sound-coe
383385
: {n} (c : Int) (ρ : Vec R n) En (normal-coe c) ρ ≡ embed-coe c
384-
sound-coe c [] = refl
385-
sound-coe c (x ∷ ρ) = ∅*x+ₙ-hom (normal-coe c) x ρ ∙ sound-coe c ρ
386+
sound-coe c v with vec-view v
387+
... | [] = refl
388+
... | (x ∷ ρ) = ∅*x+ₙ-hom (normal-coe c) x ρ ∙ sound-coe c ρ
386389

387390
sound-var : {n} (j : Fin n) ρ En (normal-var j) ρ ≡ lookup ρ j
388-
sound-var i _ with fin-view i
389-
sound-var _ (x ∷ ρ) | zero =
390-
Ep (∅ *x+ 1n) (x ∷ ρ) R.* x R.+ En 0n ρ ≡⟨ R.elimr (0n-hom ρ) ⟩
391-
⌜ Ep (∅ *x+ 1n) (x ∷ ρ) ⌝ R.* x ≡⟨ ap! (R.eliml R.*-zerol ∙ 1n-hom ρ) ⟩
392-
R.1r R.* x ≡⟨ R.*-idl ⟩
393-
x ∎
394-
sound-var _ (x ∷ ρ) | suc j = ∅*x+ₙ-hom (normal-var j) x ρ ∙ sound-var j ρ
391+
sound-var i v with vec-view v | fin-view i
392+
... | (x ∷ ρ) | zero =
393+
Ep (∅ *x+ 1n) (x ∷v ρ) R.* x R.+ En 0n ρ ≡⟨ R.elimr (0n-hom ρ) ⟩
394+
⌜ Ep (∅ *x+ 1n) (x ∷v ρ) ⌝ R.* x ≡⟨ ap! (R.eliml R.*-zerol ∙ 1n-hom ρ) ⟩
395+
R.1r R.* x ≡⟨ R.*-idl ⟩
396+
x
397+
... | (x ∷ ρ) | suc j = ∅*x+ₙ-hom (normal-var j) x ρ ∙ sound-var j ρ
395398

396399
sound : {n} (p : Polynomial n) ρ En (normal p) ρ ≡ ⟦ p ⟧ ρ
397400
sound (op [+] p q) ρ = +ₙ-hom (normal p) (normal q) ρ ∙ ap₂ R._+_ (sound p ρ) (sound q ρ)
@@ -411,11 +414,11 @@ module Impl {ℓ} {R : Type ℓ} (cring : CRing-on R) where
411414
private
412415
test-distrib : x y z x R.* (y R.+ z) ≡ y R.* x R.+ z R.* x
413416
test-distrib x y z =
414-
solve (var 0 :* (var 1 :+ var 2)) ((var 1 :* var 0) :+ (var 2 :* var 0)) (x ∷ y z ∷ []) refl
417+
solve (var 0 :* (var 1 :+ var 2)) ((var 1 :* var 0) :+ (var 2 :* var 0)) ([ x , y , z ]) refl
415418

416419
test-identities : x x R.+ (R.0r R.* R.1r) ≡ (R.1r R.+ R.0r) R.* x
417420
test-identities x =
418-
solve (var 0 :+ (con 0 :* con 1)) ((con 1 :+ con 0) :* var 0) (x ∷ []) refl
421+
solve (var 0 :+ (con 0 :* con 1)) ((con 1 :+ con 0) :* var 0) [ x ] refl
419422

420423
module Explicit {ℓ} (R : CRing ℓ) where
421424
private module I = Impl (R .snd)

src/Cat/Instances/Assemblies.lagda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ x$ is that $e$ is defined, and assemblies are defined so that if $e
330330
extend {X = X} f = to-assembly-hom record where
331331
map x = f x
332332
realiser = val ⟨ x ⟩ x
333-
tracks ha = subst ⌞_⌟ (sym (abs-β _ [] (_ , X .def ha))) (X .def ha)
333+
tracks ha = subst ⌞_⌟ (sym (abs-β _ []v (_ , X .def ha))) (X .def ha)
334334
```
335335
336336
<details>

src/Cat/Instances/Assemblies/Exponentials.lagda.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ open import Cat.Prelude
88
99
open import Data.Partial.Total
1010
open import Data.Partial.Base
11-
open import Data.Vec.Base using ([] ; _∷_)
11+
open import Data.Vec.Base using ([]v ; _∷v_)
1212
1313
open import Realisability.PCA
1414
@@ -93,7 +93,7 @@ asm-ev {X = X} {Y = Y} = to-assembly-hom record where
9393
realiser = val ⟨ u ⟩ `fst `· u `· (`snd `· u)
9494
9595
tracks {a = x} = elim! λ p q α pp p⊩f q⊩a → subst⊩ Y (p⊩f _ _ q⊩a) $
96-
(val ⟨ u ⟩ `fst `· u `· (`snd `· u)) ⋆ x ≡⟨ abs-β _ [] (_ , subst ⌞_⌟ (sym α) (`pair↓₂ pp (X .def q⊩a))) ⟩
96+
(val ⟨ u ⟩ `fst `· u `· (`snd `· u)) ⋆ x ≡⟨ abs-β _ []v (_ , subst ⌞_⌟ (sym α) (`pair↓₂ pp (X .def q⊩a))) ⟩
9797
`fst ⋆ ⌜ x ⌝ ⋆ (`snd ⋆ ⌜ x ⌝) ≡⟨ ap! α ⟩
9898
`fst ⋆ (`pair ⋆ p ⋆ q) ⋆ (`snd ⋆ (`pair ⋆ p ⋆ q)) ≡⟨ ap₂ _%_ (`fst-β pp (X .def q⊩a)) (`snd-β pp (X .def q⊩a)) ⟩
9999
p ⋆ q ∎
@@ -120,7 +120,7 @@ curry-asm {X = X} {Y = Y} {Z = Z} h .map x = record where
120120
realiser = val ⟨ v ⟩ `h `· (`pair `· const (u , X .def u⊩x) `· v)
121121
122122
tracks a⊩x = subst⊩ Z (t (inc (u , _ , refl , u⊩x , a⊩x))) $
123-
abs-β _ [] (_ , Y .def a⊩x)
123+
abs-β _ []v (_ , Y .def a⊩x)
124124
```
125125
-->
126126
@@ -137,9 +137,9 @@ curry-asm {X = X} {Y = Y} {Z = Z} h .tracked = do
137137
realiser = val ⟨ u ⟩ ⟨ v ⟩ `h `· (`pair `· u `· v)
138138
139139
tracks a⊩x = record where
140-
fst = subst ⌞_⌟ (sym (abs-βₙ [] ((_ , X .def a⊩x) ∷ []))) (abs↓ _ _)
140+
fst = subst ⌞_⌟ (sym (abs-βₙ []v ((_ , X .def a⊩x) ∷v []v))) (abs↓ _ _)
141141
snd = inc λ y b b⊩y → subst⊩ Z (t (inc (_ , _ , refl , a⊩x , b⊩y))) $
142-
abs-βₙ [] ((b , Y .def b⊩y) ∷ (_ , X .def a⊩x) ∷ [])
142+
abs-βₙ []v ((b , Y .def b⊩y) ∷v (_ , X .def a⊩x) ∷v []v)
143143
```
144144
145145
<details>

src/Cat/Instances/Assemblies/Limits.lagda.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ open import Cat.Prelude
1010
1111
open import Data.Partial.Total
1212
open import Data.Partial.Base
13-
open import Data.Vec.Base using ([] ; _∷_)
13+
open import Data.Vec.Base using ([]v ; _∷v_)
1414
1515
open import Realisability.PCA
1616
@@ -156,7 +156,7 @@ tracked by the constant function with value $\sf{x}$.
156156
!Asm {X = X} = to-assembly-hom record where
157157
map _ = lift tt
158158
realiser = val ⟨ x ⟩ x
159-
tracks ha = subst ⌞_⌟ (sym (abs-β _ [] (_ , X .def ha))) (X .def ha)
159+
tracks ha = subst ⌞_⌟ (sym (abs-β _ []v (_ , X .def ha))) (X .def ha)
160160
```
161161

162162
<!--
@@ -191,7 +191,7 @@ Assemblies-equalisers f g .apex = Equ-asm f g
191191
Assemblies-equalisers {a = A} f g .equ = to-assembly-hom record where
192192
map (x , _) = x
193193
realiser = val ⟨ x ⟩ x
194-
tracks ha = subst⊩ A ha (abs-β _ [] (_ , A .def ha))
194+
tracks ha = subst⊩ A ha (abs-β _ []v (_ , A .def ha))
195195
Assemblies-equalisers f g .has-is-eq .equal = ext λ x p → p
196196
```
197197

src/Data/List/Base.lagda.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ open import Data.Maybe.Base
99
open import Data.Bool.Base
1010
open import Data.Dec.Base
1111
open import Data.Fin.Base
12+
open import Data.Irr
1213
1314
open import Meta.Traversable
1415
open import Meta.Foldable
1516
open import Meta.Append
1617
open import Meta.Idiom
1718
open import Meta.Bind
1819
open import Meta.Alt
20+
21+
import Data.Nat.Base as Nat
1922
```
2023
-->
2124

@@ -62,6 +65,9 @@ instance
6265
go (suc zero) xs = xs ∷ []
6366
go (suc (suc n)) (x , xs) = x ∷ go (suc n) xs
6467
68+
[_]L : ∀ {ℓ} {A : Type ℓ} {n} → Vecₓ A n → List A
69+
[ p ]L = [ p ]
70+
6571
-- Test:
6672
_ : Path (List Nat) [ 1 , 2 , 3 ] (1 ∷ 2 ∷ 3 ∷ [])
6773
_ = refl
@@ -335,10 +341,18 @@ lookup x ((k , v) ∷ xs) with x ≡? k
335341
... | yes _ = just v
336342
... | no _ = lookup x xs
337343
344+
_!?_ : List A → Nat → Maybe A
345+
[] !? n = nothing
346+
(x ∷ xs) !? zero = just x
347+
(x ∷ xs) !? suc n = xs !? n
348+
349+
!?-just : ∀ (xs : List A) (n : Nat) → (n Nat.< length xs) → is-just (xs !? n)
350+
!?-just {A = a} (x ∷ xs) zero n<xs = lift oh
351+
!?-just {A = a} (x ∷ xs) (suc n) n<xs = !?-just xs n (Nat.≤-peel n<xs)
352+
338353
_!_ : (l : List A) → Fin (length l) → A
339-
(x ∷ xs) ! n with fin-view n
340-
... | zero = x
341-
... | suc i = xs ! i
354+
xs ! (fin n ⦃ pf ⦄) = from-just! _ $ !?-just xs n pf
355+
342356
343357
tabulate : ∀ {n} (f : Fin n → A) → List A
344358
tabulate {n = zero} f = []

src/Data/List/Sigma.agda

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ module _ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'} where
4949
p b q q'
5050

5151
rem₁ : {x a} (ys : a List (B a)) (b : B _) (p : a ≡ᵢ x) fibre' (ys x) p b fibreᵢ (ys a !_) b
52-
rem₁ {x = x} {a} ys b p (fin ix ⦃ q ⦄ , r) = fin ix ⦃ q' ⦄ , Equiv.to (rem₀ ys b p ix) r where
52+
rem₁ {x = x} {a} ys b p (fin ix ⦃ q ⦄ , r) = fin ix ⦃ q' ⦄ , Equiv.to (rem₀ ys b p ix {q} {q'} ) r where
5353
q' = transport (λ i suc ix Nat.≤ length (ys (Id≃path.to p (~ i)))) q
5454

5555
rem₂ : {x a} (ys : a List (B a)) (b : B _) (p : a ≡ᵢ x) fibreᵢ (ys a !_) b fibre' (ys x) p b
56-
rem₂ {x = x} {a} ys b p (fin ix ⦃ q ⦄ , r) = fin ix ⦃ q' ⦄ , Equiv.from (rem₀ ys b p ix) r where
56+
rem₂ {x = x} {a} ys b p (fin ix ⦃ q ⦄ , r) = fin ix ⦃ q' ⦄ , Equiv.from (rem₀ ys b p ix {q'} {q}) r where
5757
q' = transport (λ i suc ix Nat.≤ length (ys (Id≃path.to p i))) q
5858

5959
sigma-member : {a b xs ys} a ∈ₗ xs b ∈ₗ ys a (a , b) ∈ₗ sigma xs ys

0 commit comments

Comments
 (0)