Skip to content

Commit f5497b0

Browse files
authored
Add proofs take-step and lookup-inject≤-take (#1250)
1 parent e5cf568 commit f5497b0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,13 @@ Other minor additions
452452
inject≤-injective : (n≤m : n ℕ.≤ m) x y → inject≤ x n≤m ≡ inject≤ y n≤m → x ≡ y
453453
```
454454

455+
* Added new proofs to `Data.Vec.Properties`:
456+
```agda
457+
unfold-take : ∀ n {m} x (xs : Vec A (n + m)) → take (suc n) (x ∷ xs) ≡ x ∷ take n xs
458+
lookup-inject≤-take : ∀ m {n} (m≤m+n : m ≤ m + n) (i : Fin m) (xs : Vec A (m + n)) →
459+
lookup xs (Fin.inject≤ i m≤m+n) ≡ lookup (take m xs) i
460+
```
461+
455462
* Added new functions to `Data.Vec.Functional`:
456463
```agda
457464
length : ∀ {n} → Vector A n → ℕ

src/Data/Vec/Properties.agda

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ module _ {n} {x y : A} {xs ys : Vec A n} where
6969

7070
-- See also Data.Vec.Properties.WithK.[]=-irrelevant.
7171

72+
------------------------------------------------------------------------
73+
-- take
74+
75+
unfold-take : n {m} x (xs : Vec A (n + m)) take (suc n) (x ∷ xs) ≡ x ∷ take n xs
76+
unfold-take n x xs with splitAt n xs
77+
unfold-take n x .(xs ++ ys) | xs , ys , refl = refl
78+
7279
------------------------------------------------------------------------
7380
-- lookup
7481

@@ -102,6 +109,15 @@ lookup⇒[]= (suc i) (_ ∷ xs) p = there (lookup⇒[]= i xs p)
102109
[]=⇒lookup∘lookup⇒[]= (x ∷ xs) (suc i) p =
103110
[]=⇒lookup∘lookup⇒[]= xs i p
104111

112+
lookup-inject≤-take : m {n} (m≤m+n : m ≤ m + n) (i : Fin m) (xs : Vec A (m + n))
113+
lookup xs (Fin.inject≤ i m≤m+n) ≡ lookup (take m xs) i
114+
lookup-inject≤-take (suc m) m≤m+n zero (x ∷ xs)
115+
rewrite unfold-take m x xs = refl
116+
lookup-inject≤-take (suc (suc m)) m≤m+n (suc zero) (x ∷ x' ∷ xs)
117+
rewrite unfold-take (suc m) x (x' ∷ xs) | unfold-take m x' xs = refl
118+
lookup-inject≤-take (suc (suc m)) (s≤s (s≤s m≤m+n)) (suc (suc i)) (x ∷ x' ∷ xs)
119+
rewrite unfold-take (suc m) x (x' ∷ xs) | unfold-take m x' xs = lookup-inject≤-take m m≤m+n i xs
120+
105121
------------------------------------------------------------------------
106122
-- updateAt (_[_]%=_)
107123

0 commit comments

Comments
 (0)