@@ -86,7 +86,7 @@ example1a-fromList-∷ʳ : ∀ (x : A) xs .(eq : L.length (xs L.∷ʳ x) ≡ suc
86
86
cast eq (fromList (xs L.∷ʳ x)) ≡ fromList xs ∷ʳ x
87
87
example1a-fromList-∷ʳ x xs eq = begin
88
88
cast eq (fromList (xs L.∷ʳ x)) ≡⟨⟩
89
- cast eq (fromList (xs L.++ L.[ x ])) ≡˘ ⟨ cast-trans eq₁ eq₂ (fromList (xs L.++ L.[ x ])) ⟩
89
+ cast eq (fromList (xs L.++ L.[ x ])) ≡⟨ cast-trans eq₁ eq₂ (fromList (xs L.++ L.[ x ])) ⟨
90
90
cast eq₂ (cast eq₁ (fromList (xs L.++ L.[ x ]))) ≡⟨ cong (cast eq₂) (fromList-++ xs) ⟩
91
91
cast eq₂ (fromList xs ++ [ x ]) ≡⟨ ≈-sym (unfold-∷ʳ (sym eq₂) x (fromList xs)) ⟩
92
92
fromList xs ∷ʳ x ∎
@@ -105,7 +105,7 @@ example1b-fromList-∷ʳ : ∀ (x : A) xs .(eq : L.length (xs L.∷ʳ x) ≡ suc
105
105
example1b-fromList-∷ʳ x xs eq = begin
106
106
fromList (xs L.∷ʳ x) ≈⟨⟩
107
107
fromList (xs L.++ L.[ x ]) ≈⟨ fromList-++ xs ⟩
108
- fromList xs ++ [ x ] ≈˘ ⟨ unfold-∷ʳ (+-comm 1 (L.length xs)) x (fromList xs) ⟩
108
+ fromList xs ++ [ x ] ≈⟨ unfold-∷ʳ (+-comm 1 (L.length xs)) x (fromList xs) ⟨
109
109
fromList xs ∷ʳ x ∎
110
110
where open CastReasoning
111
111
@@ -120,10 +120,10 @@ example1b-fromList-∷ʳ x xs eq = begin
120
120
-- ≈-trans : xs ≈[ m≡n ] ys → ys ≈[ n≡o ] zs → xs ≈[ trans m≡n n≡o ] zs
121
121
-- Accordingly, `_≈[_]_` admits the standard set of equational reasoning
122
122
-- combinators. Suppose `≈-eqn : xs ≈[ m≡n ] ys`,
123
- -- xs ≈⟨ ≈-eqn ⟩ -- `_≈⟨_⟩_` takes a `_≈[_]_` step, adjusting
124
- -- ys -- the index at the same time
123
+ -- xs ≈⟨ ≈-eqn ⟩ -- `_≈⟨_⟩_` takes a `_≈[_]_` step, adjusting
124
+ -- ys -- the index at the same time
125
125
--
126
- -- ys ≈˘ ⟨ ≈-eqn ⟩ -- `_≈˘⟨_⟩ _` takes a symmetric `_≈[_]_` step
126
+ -- ys ≈⟨ ≈-eqn ⟨ -- `_≈⟨_⟨ _` takes a symmetric `_≈[_]_` step
127
127
-- xs
128
128
example2a : ∀ .(eq : suc m + n ≡ m + suc n) (xs : Vec A m) a ys →
129
129
cast eq ((reverse xs ∷ʳ a) ++ ys) ≡ reverse xs ++ (a ∷ ys)
@@ -138,7 +138,7 @@ example2a eq xs a ys = begin
138
138
-- xs ≂⟨ ≡-eqn ⟩ -- Takes a `_≡_` step; no change to the index
139
139
-- ys
140
140
--
141
- -- ys ≂˘ ⟨ ≡-eqn ⟩ -- Takes a symmetric `_≡_` step
141
+ -- ys ≂⟨ ≡-eqn ⟨ -- Takes a symmetric `_≡_` step
142
142
-- xs
143
143
-- Equivalently, `≈-reflexive` injects `_≡_` into `_≈[_]_`. That is,
144
144
-- `xs ≂⟨ ≡-eqn ⟩ ys` is the same as `xs ≈⟨ ≈-reflexive ≡-eqn ⟩ ys`.
@@ -149,7 +149,7 @@ example2b eq xs a ys = begin
149
149
(a ∷ xs) ʳ++ ys ≂⟨ unfold-ʳ++ (a ∷ xs) ys ⟩ -- index: suc m + n
150
150
reverse (a ∷ xs) ++ ys ≂⟨ cong (_++ ys) (reverse-∷ a xs) ⟩ -- index: suc m + n
151
151
(reverse xs ∷ʳ a) ++ ys ≈⟨ ∷ʳ-++ eq a (reverse xs) ⟩ -- index: suc m + n
152
- reverse xs ++ (a ∷ ys) ≂˘ ⟨ unfold-ʳ++ xs (a ∷ ys) ⟩ -- index: m + suc n
152
+ reverse xs ++ (a ∷ ys) ≂⟨ unfold-ʳ++ xs (a ∷ ys) ⟨ -- index: m + suc n
153
153
xs ʳ++ (a ∷ ys) ∎ -- index: m + suc n
154
154
where open CastReasoning
155
155
@@ -201,11 +201,11 @@ example3b-fromList-++-++′ {xs = xs} {ys} {zs} eq = begin
201
201
example4-cong² : ∀ .(eq : (m + 1 ) + n ≡ n + suc m) a (xs : Vec A m) ys →
202
202
cast eq (reverse ((xs ++ [ a ]) ++ ys)) ≡ ys ʳ++ reverse (xs ∷ʳ a)
203
203
example4-cong² {m = m} {n} eq a xs ys = begin
204
- reverse ((xs ++ [ a ]) ++ ys) ≈˘ ⟨ ≈-cong reverse (cast-reverse (cong (_+ n) (+-comm 1 m)) ((xs ∷ʳ a) ++ ys))
204
+ reverse ((xs ++ [ a ]) ++ ys) ≈⟨ ≈-cong reverse (cast-reverse (cong (_+ n) (+-comm 1 m)) ((xs ∷ʳ a) ++ ys))
205
205
(≈-cong (_++ ys) (cast-++ˡ (+-comm 1 m) (xs ∷ʳ a))
206
- (unfold-∷ʳ _ a xs)) ⟩
206
+ (unfold-∷ʳ _ a xs)) ⟨
207
207
reverse ((xs ∷ʳ a) ++ ys) ≈⟨ reverse-++ (+-comm (suc m) n) (xs ∷ʳ a) ys ⟩
208
- reverse ys ++ reverse (xs ∷ʳ a) ≂˘ ⟨ unfold-ʳ++ ys (reverse (xs ∷ʳ a)) ⟩
208
+ reverse ys ++ reverse (xs ∷ʳ a) ≂⟨ unfold-ʳ++ ys (reverse (xs ∷ʳ a)) ⟨
209
209
ys ʳ++ reverse (xs ∷ʳ a) ∎
210
210
where open CastReasoning
211
211
@@ -237,7 +237,7 @@ example5-fromList-++-++′ {xs = xs} {ys} {zs} eq = begin
237
237
-- and then switch to the reasoning system of `_≈[_]_`.
238
238
example6a-reverse-∷ʳ : ∀ x (xs : Vec A n) → reverse (xs ∷ʳ x) ≡ x ∷ reverse xs
239
239
example6a-reverse-∷ʳ {n = n} x xs = begin-≡
240
- reverse (xs ∷ʳ x) ≡˘ ⟨ ≈-reflexive refl ⟩
240
+ reverse (xs ∷ʳ x) ≡⟨ ≈-reflexive refl ⟨
241
241
reverse (xs ∷ʳ x) ≈⟨ ≈-cong reverse (cast-reverse _ _) (unfold-∷ʳ (+-comm 1 n) x xs) ⟩
242
242
reverse (xs ++ [ x ]) ≈⟨ reverse-++ (+-comm n 1 ) xs [ x ] ⟩
243
243
x ∷ reverse xs ∎
@@ -249,6 +249,6 @@ example6b-reverse-∷ʳ-by-induction x (y ∷ xs) = begin
249
249
reverse (y ∷ (xs ∷ʳ x)) ≡⟨ reverse-∷ y (xs ∷ʳ x) ⟩
250
250
reverse (xs ∷ʳ x) ∷ʳ y ≡⟨ cong (_∷ʳ y) (example6b-reverse-∷ʳ-by-induction x xs) ⟩
251
251
(x ∷ reverse xs) ∷ʳ y ≡⟨⟩
252
- x ∷ (reverse xs ∷ʳ y) ≡˘ ⟨ cong (x ∷_) (reverse-∷ y xs) ⟩
252
+ x ∷ (reverse xs ∷ʳ y) ≡⟨ cong (x ∷_) (reverse-∷ y xs) ⟨
253
253
x ∷ reverse (y ∷ xs) ∎
254
254
where open ≡-Reasoning
0 commit comments