Package list-nth: The list nth function

Information

namelist-nth
version1.32
descriptionThe list nth function
authorJoe Hurd <joe@gilith.com>
licenseMIT
requiresbool
natural
set
list-def
list-thm
list-dest
list-length
list-set
list-append
list-map
list-quant
list-last
showData.Bool
Data.List
Number.Natural
Set

Files

Defined Constant

Theorems

h t. nth 0 (h :: t) = h

l i. i < length l nth i l toSet l

l. ¬(l = []) last l = nth (length l - 1) l

P l. all P l i. i < length l P (nth i l)

P l. exists P l i. i < length l P (nth i l)

h t n. n < length t nth (suc n) (h :: t) = nth n t

x l. x toSet l i. i < length l x = nth i l

f l i. i < length l nth i (map f l) = f (nth i l)

l m.
    length l = length m (i. i < length l nth i l = nth i m) l = m

k l m.
    k < length l + length m
    nth k (l @ m) = if k < length l then nth k l else nth (k - length l) m

Input Type Operators

Input Constants

Assumptions

T

¬F T

¬T F

length [] = 0

bit0 0 = 0

toSet [] =

t. t t

F p. p

x. ¬(x )

n. ¬(n < n)

n. 0 < suc n

n. n < suc n

(¬) = λp. p F

() = λp. p ((select) p)

t. (x. t) t

() = λp. p = λx. T

t. F t F

t. T t t

t. t T t

t. F t T

t. T t t

t. t T T

t. T t T

n. ¬(suc n = 0)

m. m < 0 F

m. m - 0 = m

n. n - n = 0

l. [] @ l = l

n. bit1 n = suc (bit0 n)

() = λp q. p q p

n. suc n - 1 = n

t1 t2. (if F then t1 else t2) = t2

t1 t2. (if T then t1 else t2) = t1

h t. ¬(h :: t = [])

h t. head (h :: t) = h

h t. tail (h :: t) = t

l. length l = 0 l = []

x y. x = y y = x

l f. length (map f l) = length l

h t. length (h :: t) = suc (length t)

m n. ¬(m < n) n m

m. m = 0 n. m = suc n

() = λp q. (λf. f p q) = λf. f T T

() = λp. q. (x. p x q) q

h t. toSet (h :: t) = insert h (toSet t)

m n. suc m + n = suc (m + n)

m n. suc m = suc n m = n

m n. suc m < suc n m < n

l m. length (l @ m) = length l + length m

() = λp q. r. (p r) (q r) r

p. (x y. p x y) y x. p x y

h t. last (h :: t) = if t = [] then h else last t

l h t. (h :: t) @ l = h :: t @ l

P l. all P l x. x toSet l P x

P l. exists P l x. x toSet l P x

p. (x. y. p x y) y. x. p x (y x)

m n. n m suc m - suc n = m - n

f h t. map f (h :: t) = f h :: map f t

P. P 0 (n. P n P (suc n)) n. P n

x y s. x insert y s x = y x s

(∃!) = λ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 [] (a0 a1. P a1 P (a0 :: a1)) x. P x

h1 h2 t1 t2. h1 :: t1 = h2 :: t2 h1 = h2 t1 = t2

p c x y. p (if c then x else y) (c p x) (¬c p y)