Skip to content

Commit d10ff67

Browse files
committed
derive cast-* lemmas from it
1 parent 52faa1d commit d10ff67

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

src/Data/Vec/Properties.agda

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,7 @@ map-const (_ ∷ xs) y = cong (y ∷_) (map-const xs y)
400400

401401
map-cast : (f : A B) .(eq : m ≡ n) (xs : Vec A m)
402402
map f (cast eq xs) ≡ cast eq (map f xs)
403-
map-cast {n = zero} f eq [] = refl
404-
map-cast {n = suc _} f eq (x ∷ xs)
405-
= cong (f x ∷_) (map-cast f (suc-injective eq) xs)
403+
map-cast f _ _ = sym (≈-cong′ (map f) refl)
406404

407405
map-++ : (f : A B) (xs : Vec A m) (ys : Vec A n)
408406
map f (xs ++ ys) ≡ map f xs ++ map f ys
@@ -481,13 +479,11 @@ toList-map f (x ∷ xs) = cong (f x List.∷_) (toList-map f xs)
481479

482480
cast-++ˡ : .(eq : m ≡ o) (xs : Vec A m) {ys : Vec A n}
483481
cast (cong (_+ n) eq) (xs ++ ys) ≡ cast eq xs ++ ys
484-
cast-++ˡ {o = zero} eq [] {ys} = cast-is-id refl (cast eq [] ++ ys)
485-
cast-++ˡ {o = suc o} eq (x ∷ xs) {ys} = cong (x ∷_) (cast-++ˡ (cong pred eq) xs)
482+
cast-++ˡ _ _ {ys} = ≈-cong′ (_++ ys) refl
486483

487484
cast-++ʳ : .(eq : n ≡ o) (xs : Vec A m) {ys : Vec A n}
488485
cast (cong (m +_) eq) (xs ++ ys) ≡ xs ++ cast eq ys
489-
cast-++ʳ {m = zero} eq [] {ys} = refl
490-
cast-++ʳ {m = suc m} eq (x ∷ xs) {ys} = cong (x ∷_) (cast-++ʳ eq xs)
486+
cast-++ʳ _ xs = ≈-cong′ (xs ++_) refl
491487

492488
lookup-++-< : (xs : Vec A m) (ys : Vec A n)
493489
i (i<m : toℕ i < m)
@@ -916,8 +912,7 @@ map-∷ʳ f x (y ∷ xs) = cong (f y ∷_) (map-∷ʳ f x xs)
916912

917913
cast-∷ʳ : .(eq : suc n ≡ suc m) x (xs : Vec A n)
918914
cast eq (xs ∷ʳ x) ≡ (cast (cong pred eq) xs) ∷ʳ x
919-
cast-∷ʳ {m = zero} eq x [] = refl
920-
cast-∷ʳ {m = suc m} eq x (y ∷ xs) = cong (y ∷_) (cast-∷ʳ (cong pred eq) x xs)
915+
cast-∷ʳ _ x _ = ≈-cong′ (_∷ʳ x) refl
921916

922917
-- _++_ and _∷ʳ_
923918

@@ -1029,15 +1024,7 @@ reverse-++ {m = suc m} {n = n} eq (x ∷ xs) ys = begin
10291024
where open CastReasoning
10301025

10311026
cast-reverse : .(eq : m ≡ n) cast eq ∘ reverse {A = A} {n = m} ≗ reverse ∘ cast eq
1032-
cast-reverse {n = zero} eq [] = refl
1033-
cast-reverse {n = suc n} eq (x ∷ xs) = begin
1034-
reverse (x ∷ xs) ≂⟨ reverse-∷ x xs ⟩
1035-
reverse xs ∷ʳ x ≈⟨ ≈-cong (_∷ʳ x) (cast-∷ʳ eq x (reverse xs))
1036-
(cast-reverse (cong pred eq) xs) ⟩
1037-
reverse (cast _ xs) ∷ʳ x ≂⟨ reverse-∷ x (cast (cong pred eq) xs) ⟨
1038-
reverse (x ∷ cast _ xs) ≈⟨⟩
1039-
reverse (cast eq (x ∷ xs)) ∎
1040-
where open CastReasoning
1027+
cast-reverse _ _ = ≈-cong′ reverse refl
10411028

10421029
------------------------------------------------------------------------
10431030
-- _ʳ++_

0 commit comments

Comments
 (0)