Skip to content

Commit 6bd4afb

Browse files
Sofia-Insaandreasabel
authored andcommitted
Add new proof take-all to Data.List.Properties (#1983)
1 parent 7b352f6 commit 6bd4afb

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2152,7 +2152,8 @@ Other minor changes
21522152
21532153
length-isMagmaHomomorphism : (A : Set a) → IsMagmaHomomorphism (++-rawMagma A) +-rawMagma length
21542154
length-isMonoidHomomorphism : (A : Set a) → IsMonoidHomomorphism (++-[]-rawMonoid A) +-0-rawMonoid length
2155-
2155+
2156+
take-all : n ≥ length xs → take n xs ≡ xs
21562157
take-[] : ∀ m → take m [] ≡ []
21572158
drop-[] : ∀ m → drop m [] ≡ []
21582159
```

src/Data/List/Properties.agda

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,12 @@ length-take zero xs = refl
759759
length-take (suc n) [] = refl
760760
length-take (suc n) (x ∷ xs) = cong suc (length-take n xs)
761761

762+
-- If you take at least as many elements from a list as it has, you get the whole list.
763+
take-all :(n : ℕ) (xs : List A) n ≥ length xs take n xs ≡ xs
764+
take-all zero [] _ = refl
765+
take-all (suc _) [] _ = refl
766+
take-all (suc n) (x ∷ xs) (s≤s pf) = cong (x ∷_) (take-all n xs pf)
767+
762768
-- Taking from an empty list does nothing.
763769
take-[] : m take {A = A} m [] ≡ []
764770
take-[] zero = refl

0 commit comments

Comments
 (0)