Skip to content

Commit 513117b

Browse files
authored
Cleanup README comments to catch up with #2424 (#2541)
1 parent 279fa18 commit 513117b

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

doc/README/Data/Vec/Relation/Binary/Equality/Cast.agda

+8-16
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,9 @@ example2b eq xs a ys = begin
166166

167167
-- Oftentimes index-changing identities apply to only part of the proof
168168
-- term. When reasoning about `_≡_`, `cong` shifts the focus to the
169-
-- subterm of interest. In this library, `≈-cong` does a similar job.
170-
-- Suppose `f : A → B`, `xs : B`, `ys zs : A`, `ys≈zs : ys ≈[ _ ] zs`
171-
-- and `xs≈f⟨c·ys⟩ : xs ≈[ _ ] f (cast _ ys)`, we have
172-
-- xs ≈⟨ ≈-cong f xs≈f⟨c·ys⟩ ys≈zs ⟩
173-
-- f zs
174-
-- The reason for having the extra argument `xs≈f⟨c·ys⟩` is to expose
175-
-- `cast` in the subterm in order to apply the step `ys≈zs`. When using
176-
-- ordinary `cong` the proof has to explicitly push `cast` inside:
177-
-- xs ≈⟨ xs≈f⟨c·ys⟩ ⟩
178-
-- f (cast _ ys) ≂⟨ cong f ys≈zs ⟩
179-
-- f zs
180-
-- Note. Technically, `A` and `B` should be vectors of different length
181-
-- and that `ys`, `zs` are vectors of non-definitionally equal index.
169+
-- subterm of interest. In this library, `≈-cong′` does a similar job.
170+
-- For the typechecker to infer the congruence function `f`, it must be
171+
-- polymorphic in the length of the given vector,
182172
example3a-fromList-++-++ : {xs ys zs : List A}
183173
.(eq : List.length (xs List.++ ys List.++ zs) ≡
184174
List.length xs + (List.length ys + List.length zs))
@@ -211,15 +201,17 @@ example3b-fromList-++-++′ {xs = xs} {ys} {zs} eq = begin
211201
212202
where open CastReasoning
213203

214-
-- `≈-cong` can be chained together much like how `cong` can be nested.
204+
-- `≈-cong` can be chained together much like how `cong` can be nested.
215205
-- In this example, `unfold-∷ʳ` is applied to the term `xs ++ [ a ]`
216206
-- in `(_++ ys)` inside of `reverse`. Thus the proof employs two
217-
-- `≈-cong`.
207+
-- `≈-cong′` usages, which is equivalent to using one `≈-cong′` with
208+
-- a single composed function.
218209
example4-cong² : .(eq : (m + 1) + n ≡ n + suc m) a (xs : Vec A m) ys
219210
cast eq (reverse ((xs ++ [ a ]) ++ ys)) ≡ ys ʳ++ reverse (xs ∷ʳ a)
220211
example4-cong² {m = m} {n} eq a xs ys = begin
221212
reverse ((xs ++ [ a ]) ++ ys)
222-
≈⟨ ≈-cong′ (reverse ∘ (_++ ys)) (unfold-∷ʳ-eqFree a xs) ⟨
213+
≈⟨ ≈-cong′ reverse (≈-cong′ (_++ ys) (unfold-∷ʳ-eqFree a xs)) ⟨
214+
-- the same as ≈-cong′ (reverse ∘ (_++ ys)) ...
223215
reverse ((xs ∷ʳ a) ++ ys)
224216
≈⟨ reverse-++-eqFree (xs ∷ʳ a) ys ⟩
225217
reverse ys ++ reverse (xs ∷ʳ a)

src/Data/Vec/Properties.agda

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ open import Data.Sum.Base using ([_,_]′)
2424
open import Data.Sum.Properties using ([,]-map)
2525
open import Data.Vec.Base
2626
open import Data.Vec.Relation.Binary.Equality.Cast as VecCast
27-
using (_≈[_]_; ≈-sym; module CastReasoning)
27+
using (_≈[_]_; ≈-sym; ≈-cong′; module CastReasoning)
2828
open import Function.Base using (_∘_; id; _$_; const; _ˢ_; flip)
2929
open import Function.Bundles using (_↔_; mk↔ₛ′)
3030
open import Level using (Level)
@@ -375,8 +375,6 @@ lookup∘update′ {i = i} {j} i≢j xs y = lookup∘updateAt′ i j i≢j xs
375375
open VecCast public
376376
using (cast-is-id; cast-trans)
377377

378-
open VecCast using (≈-cong′)
379-
380378
subst-is-cast : (eq : m ≡ n) (xs : Vec A m) subst (Vec A) eq xs ≡ cast eq xs
381379
subst-is-cast refl xs = sym (cast-is-id refl xs)
382380

0 commit comments

Comments
 (0)