Church-Encoded Lists in SKI Combinatory Logic #
Church-encoded lists for proving SKI ≃ TM equivalence. A list is encoded as
λ c n. c a₀ (c a₁ (... (c aₖ n)...)) where each aᵢ is a Church numeral.
Church List Representation #
A term correctly Church-encodes a list of natural numbers.
Equations
- One or more equations did not get rendered due to their size.
- Cslib.SKI.IsChurchList [] x✝ = ∀ (c n : Cslib.SKI), Relation.ReflTransGen Cslib.SKI.Red ((x✝.app c).app n) n
Instances For
IsChurchList is preserved under multi-step reduction of the term.
Both components of a pair are Church lists.
- fst : IsChurchList prev (Fst.app p)
- snd : IsChurchList curr (Snd.app p)
Instances For
IsChurchListPair is preserved under reduction.
Nil: The empty list #
nil = λ c n. n
Equations
Instances For
The SKI term for the empty list.
Equations
Instances For
Reduction: Nil ⬝ c ⬝ n ↠ n.
The empty list term correctly represents [].
Cons: Consing an element onto a list #
cons = λ x xs c n. c x (xs c n)
Equations
Instances For
The SKI term for list cons.
Equations
Instances For
Cons preserves Church list representation.
Singleton list correctness.
The canonical SKI term for a Church-encoded list.
Equations
- Cslib.SKI.List.toChurch [] = Cslib.SKI.List.Nil
- Cslib.SKI.List.toChurch (x_1 :: xs) = (Cslib.SKI.List.Cons.app (Cslib.SKI.toChurch x_1)).app (Cslib.SKI.List.toChurch xs)
Instances For
toChurch ns correctly represents ns.
Head: Extract the head of a list #
headD d xs = xs K d (returns d for empty list)
Equations
Instances For
The SKI term for list head with default.
Equations
Instances For
General head-with-default correctness.
The SKI term for list head (default 0).
Equations
Instances For
Head correctness (default 0).
Tail: Extract the tail of a list #
Step function for tail: (prev, curr) → (curr, cons h curr)
Equations
- One or more equations did not get rendered due to their size.
Instances For
The step function for computing list tail.
Instances For
tail xs = Fst (xs TailStep (MkPair Nil Nil))
Equations
- One or more equations did not get rendered due to their size.
Instances For
The tail of a Church-encoded list.
Equations
Instances For
The initial pair (nil, nil) satisfies the invariant.
The step function preserves the tail-computing invariant.
Tail correctness.
Prepending zero to a list (for Code.zero') #
PrependZero xs = cons 0 xs = Cons ⬝ Zero ⬝ xs
Equations
Instances For
Prepend zero to a Church-encoded list.
Instances For
Reduction: PrependZero ⬝ xs ↠ Cons ⬝ Zero ⬝ xs.
Prepending zero preserves Church list representation.
Successor on list head (for Code.succ) #
SuccHead xs = cons (succ (head xs)) nil
Equations
Instances For
SuccHead correctly computes a singleton containing succ(head ns).