Skip to content

Commit b1cf9ef

Browse files
committed
use it in proofs
1 parent d10ff67 commit b1cf9ef

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ open import Data.Nat.Properties
2020
open import Data.Vec.Base
2121
open import Data.Vec.Properties
2222
open import Data.Vec.Relation.Binary.Equality.Cast
23+
open import Function using (_∘_)
2324
open import Relation.Binary.PropositionalEquality
2425
using (_≡_; refl; sym; cong; module ≡-Reasoning)
2526

@@ -187,7 +188,7 @@ example3a-fromList-++-++ {xs = xs} {ys} {zs} eq = begin
187188
fromList (xs List.++ ys List.++ zs)
188189
≈⟨ fromList-++ xs ⟩
189190
fromList xs ++ fromList (ys List.++ zs)
190-
≈⟨ ≈-cong (fromList xs ++_) (cast-++ʳ (List.length-++ ys) (fromList xs)) (fromList-++ ys) ⟩
191+
≈⟨ ≈-cong (fromList xs ++_) (fromList-++ ys) ⟩
191192
fromList xs ++ fromList ys ++ fromList zs
192193
193194
where open CastReasoning
@@ -218,9 +219,7 @@ example4-cong² : ∀ .(eq : (m + 1) + n ≡ n + suc m) a (xs : Vec A m) ys →
218219
cast eq (reverse ((xs ++ [ a ]) ++ ys)) ≡ ys ʳ++ reverse (xs ∷ʳ a)
219220
example4-cong² {m = m} {n} eq a xs ys = begin
220221
reverse ((xs ++ [ a ]) ++ ys)
221-
≈⟨ ≈-cong reverse (cast-reverse (cong (_+ n) (+-comm 1 m)) ((xs ∷ʳ a) ++ ys))
222-
(≈-cong (_++ ys) (cast-++ˡ (+-comm 1 m) (xs ∷ʳ a))
223-
(unfold-∷ʳ _ a xs)) ⟨
222+
≈⟨ ≈-cong′ (reverse ∘ (_++ ys)) (unfold-∷ʳ (+-comm 1 m) a xs) ⟨
224223
reverse ((xs ∷ʳ a) ++ ys)
225224
≈⟨ reverse-++ (+-comm (suc m) n) (xs ∷ʳ a) ys ⟩
226225
reverse ys ++ reverse (xs ∷ʳ a)
@@ -264,7 +263,7 @@ example6a-reverse-∷ʳ {n = n} x xs = begin-≡
264263
reverse (xs ∷ʳ x)
265264
≡⟨ ≈-reflexive refl ⟨
266265
reverse (xs ∷ʳ x)
267-
≈⟨ ≈-cong reverse (cast-reverse _ _) (unfold-∷ʳ (+-comm 1 n) x xs) ⟩
266+
≈⟨ ≈-cong reverse (unfold-∷ʳ (+-comm 1 n) x xs) ⟩
268267
reverse (xs ++ [ x ])
269268
≈⟨ reverse-++ (+-comm n 1) xs [ x ] ⟩
270269
x ∷ reverse xs

src/Data/Vec/Properties.agda

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,7 @@ reverse-++ : ∀ .(eq : m + n ≡ n + m) (xs : Vec A m) (ys : Vec A n) →
10161016
reverse-++ {m = zero} {n = n} eq [] ys = ≈-sym (++-identityʳ (sym eq) (reverse ys))
10171017
reverse-++ {m = suc m} {n = n} eq (x ∷ xs) ys = begin
10181018
reverse (x ∷ xs ++ ys) ≂⟨ reverse-∷ x (xs ++ ys) ⟩
1019-
reverse (xs ++ ys) ∷ʳ x ≈⟨ ≈-cong (_∷ʳ x) (cast-∷ʳ (cong suc (+-comm m n)) x (reverse (xs ++ ys)))
1020-
(reverse-++ _ xs ys) ⟩
1019+
reverse (xs ++ ys) ∷ʳ x ≈⟨ ≈-cong′ (_∷ʳ x) (reverse-++ (+-comm m n) xs ys) ⟩
10211020
(reverse ys ++ reverse xs) ∷ʳ x ≈⟨ ++-∷ʳ (sym (+-suc n m)) x (reverse ys) (reverse xs) ⟩
10221021
reverse ys ++ (reverse xs ∷ʳ x) ≂⟨ cong (reverse ys ++_) (reverse-∷ x xs) ⟨
10231022
reverse ys ++ (reverse (x ∷ xs)) ∎
@@ -1068,8 +1067,7 @@ map-ʳ++ {ys = ys} f xs = begin
10681067
cast eq ((xs ++ ys) ʳ++ zs) ≡ ys ʳ++ (xs ʳ++ zs)
10691068
++-ʳ++ {m = m} {n} {o} eq xs {ys} {zs} = begin
10701069
((xs ++ ys) ʳ++ zs) ≂⟨ unfold-ʳ++ (xs ++ ys) zs ⟩
1071-
reverse (xs ++ ys) ++ zs ≈⟨ ≈-cong (_++ zs) (cast-++ˡ (+-comm m n) (reverse (xs ++ ys)))
1072-
(reverse-++ (+-comm m n) xs ys) ⟩
1070+
reverse (xs ++ ys) ++ zs ≈⟨ ≈-cong′ (_++ zs) (reverse-++ (+-comm m n) xs ys) ⟩
10731071
(reverse ys ++ reverse xs) ++ zs ≈⟨ ++-assoc (trans (cong (_+ o) (+-comm n m)) eq) (reverse ys) (reverse xs) zs ⟩
10741072
reverse ys ++ (reverse xs ++ zs) ≂⟨ cong (reverse ys ++_) (unfold-ʳ++ xs zs) ⟨
10751073
reverse ys ++ (xs ʳ++ zs) ≂⟨ unfold-ʳ++ ys (xs ʳ++ zs) ⟨
@@ -1081,8 +1079,7 @@ map-ʳ++ {ys = ys} f xs = begin
10811079
ʳ++-ʳ++ {m = m} {n} {o} eq xs {ys} {zs} = begin
10821080
(xs ʳ++ ys) ʳ++ zs ≂⟨ cong (_ʳ++ zs) (unfold-ʳ++ xs ys) ⟩
10831081
(reverse xs ++ ys) ʳ++ zs ≂⟨ unfold-ʳ++ (reverse xs ++ ys) zs ⟩
1084-
reverse (reverse xs ++ ys) ++ zs ≈⟨ ≈-cong (_++ zs) (cast-++ˡ (+-comm m n) (reverse (reverse xs ++ ys)))
1085-
(reverse-++ (+-comm m n) (reverse xs) ys) ⟩
1082+
reverse (reverse xs ++ ys) ++ zs ≈⟨ ≈-cong′ (_++ zs) (reverse-++ (+-comm m n) (reverse xs) ys) ⟩
10861083
(reverse ys ++ reverse (reverse xs)) ++ zs ≂⟨ cong ((_++ zs) ∘ (reverse ys ++_)) (reverse-involutive xs) ⟩
10871084
(reverse ys ++ xs) ++ zs ≈⟨ ++-assoc (+-assoc n m o) (reverse ys) xs zs ⟩
10881085
reverse ys ++ (xs ++ zs) ≂⟨ unfold-ʳ++ ys (xs ++ zs) ⟨
@@ -1312,8 +1309,7 @@ fromList-reverse (x List.∷ xs) = begin
13121309
fromList (List.reverse (x List.∷ xs)) ≈⟨ cast-fromList (List.ʳ++-defn xs) ⟩
13131310
fromList (List.reverse xs List.++ List.[ x ]) ≈⟨ fromList-++ (List.reverse xs) ⟩
13141311
fromList (List.reverse xs) ++ [ x ] ≈⟨ unfold-∷ʳ (+-comm 1 _) x (fromList (List.reverse xs)) ⟨
1315-
fromList (List.reverse xs) ∷ʳ x ≈⟨ ≈-cong (_∷ʳ x) (cast-∷ʳ (cong suc (List.length-reverse xs)) _ _)
1316-
(fromList-reverse xs) ⟩
1312+
fromList (List.reverse xs) ∷ʳ x ≈⟨ ≈-cong′ (_∷ʳ x) (fromList-reverse xs) ⟩
13171313
reverse (fromList xs) ∷ʳ x ≂⟨ reverse-∷ x (fromList xs) ⟨
13181314
reverse (x ∷ fromList xs) ≈⟨⟩
13191315
reverse (fromList (x List.∷ xs)) ∎

0 commit comments

Comments
 (0)