Package list-take-drop: The list take and drop functions
Information
name | list-take-drop |
version | 1.63 |
description | The list take and drop functions |
author | Joe Leslie-Hurd <joe@gilith.com> |
license | MIT |
checksum | a8d0f2a72e094d860531d9c8b76c38997eebf6b2 |
requires | bool list-append list-def list-dest list-length list-nth list-replicate list-thm natural |
show | Data.Bool Data.List Number.Natural |
Files
- Package tarball list-take-drop-1.63.tgz
- Theory source file list-take-drop.thy (included in the package tarball)
Defined Constants
- Data
- List
- drop
- take
- List
Theorems
⊦ ∀l. drop 0 l = l
⊦ ∀l. take 0 l = []
⊦ ∀l. drop (length l) l = []
⊦ ∀l. take (length l) l = l
⊦ ∀l1 l2. drop (length l1) (l1 @ l2) = l2
⊦ ∀l1 l2. take (length l1) (l1 @ l2) = l1
⊦ ∀h t. take 1 (h :: t) = h :: []
⊦ ∀n l. n ≤ length l ⇒ length (take n l) = n
⊦ ∀n l. n ≤ length l ⇒ length (drop n l) = length l - n
⊦ ∀n l. n ≤ length l ⇒ n + length (drop n l) = length l
⊦ ∀n l. n ≤ length l ⇒ take n l @ drop n l = l
⊦ ∀m n x. m ≤ n ⇒ take m (replicate x n) = replicate x m
⊦ ∀n h t. n ≤ length t ⇒ drop (suc n) (h :: t) = drop n t
⊦ ∀m n x. m ≤ n ⇒ drop m (replicate x n) = replicate x (n - m)
⊦ ∀n h t. n ≤ length t ⇒ take (suc n) (h :: t) = h :: take n t
⊦ ∀m n l. m + n ≤ length l ⇒ drop (m + n) l = drop m (drop n l)
⊦ ∀n l i. n + i < length l ⇒ nth (drop n l) i = nth l (n + i)
⊦ ∀n l i. n ≤ length l ∧ i < n ⇒ nth (take n l) i = nth l i
⊦ ∀m n l. m + n ≤ length l ⇒ take (m + n) l = take m l @ take n (drop m l)
⊦ ∀n l i.
n ≤ length l ∧ i < length l ⇒
nth l i = if i < n then nth (take n l) i else nth (drop n l) (i - n)
External Type Operators
- →
- bool
- Data
- List
- list
- List
- Number
- Natural
- natural
- Natural
External Constants
- =
- select
- Data
- Bool
- ∀
- ∧
- ⇒
- ∃
- ∃!
- ¬
- cond
- ⊥
- ⊤
- List
- ::
- @
- []
- head
- length
- nth
- replicate
- tail
- Bool
- Number
- Natural
- +
- -
- <
- ≤
- bit0
- bit1
- suc
- zero
- Natural
Assumptions
⊦ ⊤
⊦ length [] = 0
⊦ bit0 0 = 0
⊦ ∀t. t ⇒ t
⊦ ∀n. 0 ≤ n
⊦ ∀n. n ≤ n
⊦ ⊥ ⇔ ∀p. p
⊦ (¬) = λp. p ⇒ ⊥
⊦ (∃) = λp. p ((select) p)
⊦ ∀t. (∀x. t) ⇔ t
⊦ (∀) = λp. p = λx. ⊤
⊦ ∀t. ⊤ ∧ t ⇔ t
⊦ ∀t. t ∧ ⊤ ⇔ t
⊦ ∀t. ⊥ ⇒ t ⇔ ⊤
⊦ ∀t. ⊤ ⇒ t ⇔ t
⊦ ∀t. t ⇒ ⊤ ⇔ ⊤
⊦ ∀n. ¬(suc n = 0)
⊦ ∀m. m + 0 = m
⊦ ∀n. n - n = 0
⊦ ∀l. [] @ l = l
⊦ ∀l. l @ [] = l
⊦ ∀t. (t ⇔ ⊥) ⇔ ¬t
⊦ ∀n. bit1 n = suc (bit0 n)
⊦ ∀m n. m ≤ m + n
⊦ ∀m n. n ≤ m + n
⊦ (⇒) = λp q. p ∧ q ⇔ p
⊦ ∀m. suc m = m + 1
⊦ ∀m. m ≤ 0 ⇔ m = 0
⊦ ∀t1 t2. (if ⊥ then t1 else t2) = t2
⊦ ∀t1 t2. (if ⊤ then t1 else t2) = t1
⊦ ∀x n. length (replicate x n) = n
⊦ ∀h t. head (h :: t) = h
⊦ ∀h t. tail (h :: t) = t
⊦ ∀l. length l = 0 ⇔ l = []
⊦ ∀x y. x = y ⇒ y = x
⊦ ∀m n. m + n = n + m
⊦ ∀m n. m + n - m = n
⊦ ∀h t. length (h :: t) = suc (length t)
⊦ ∀m n. ¬(m < n) ⇔ n ≤ m
⊦ ∀m n. suc m ≤ n ⇔ m < n
⊦ (∧) = λp q. (λf. f p q) = λf. f ⊤ ⊤
⊦ (∃) = λp. ∀q. (∀x. p x ⇒ q) ⇒ q
⊦ ∀m n. m + suc n = suc (m + n)
⊦ ∀m n. suc m = suc n ⇔ m = n
⊦ ∀m n. suc m ≤ suc n ⇔ m ≤ n
⊦ ∀l1 l2. length (l1 @ l2) = length l1 + length l2
⊦ ∀m n p. m + (n + p) = m + n + p
⊦ ∀m n p. m + n ≤ m + p ⇔ n ≤ p
⊦ ∀m n p. m < n ∧ n ≤ p ⇒ m < p
⊦ ∀m n p. m ≤ n ∧ n ≤ p ⇒ m ≤ p
⊦ ∀l h t. (h :: t) @ l = h :: t @ l
⊦ ∀l1 l2 l3. l1 @ l2 @ l3 = (l1 @ l2) @ l3
⊦ ∀l l1 l2. l1 @ l = l2 @ l ⇔ l1 = l2
⊦ ∀l l1 l2. l1 @ l = l2 @ l ⇒ l1 = l2
⊦ ∀p. p 0 ∧ (∀n. p n ⇒ p (suc n)) ⇒ ∀n. p n
⊦ (∃!) = λp. (∃) p ∧ ∀x y. p x ∧ p y ⇒ x = y
⊦ ∀e f. ∃!fn. fn 0 = e ∧ ∀n. fn (suc n) = f (fn n) n
⊦ ∀p. p [] ∧ (∀h t. p t ⇒ p (h :: t)) ⇒ ∀l. p l
⊦ ∀h1 h2 t1 t2. h1 :: t1 = h2 :: t2 ⇔ h1 = h2 ∧ t1 = t2
⊦ ∀l1 l2 k.
k < length l1 + length l2 ⇒
nth (l1 @ l2) k =
if k < length l1 then nth l1 k else nth l2 (k - length l1)
⊦ ∀x n l1 l2.
l1 @ l2 = replicate x n ⇔
replicate x (length l1) = l1 ∧ replicate x (length l2) = l2 ∧
length l1 + length l2 = n