Basic results for the SKI calculus #
Main definition #
Polynomial: the type of SKI terms with fixed number of "holes" (read: free variables).
Notation #
⬝': application between polynomials,&i: the ith free variable of a polynomial.
Main results #
- Bracket abstraction: an algorithm
Polynomial.toSKIto convert a polynomial $Γ(x_0, ..., x_{n-1})$ into a term such that (Polynomial.toSKI_correct)Γ.toSKI ⬝ t₁ ⬝ ... ⬝ tₙreduces toΓ(t₁, ..., tₙ).
References #
For a presentation of the bracket abstraction algorithm see: https://web.archive.org/web/19970727171324/http://www.cs.oberlin.edu/classes/cs280/labs/lab4/lab43.html#@l13
Polynomials and the bracket astraction algorithm #
A polynomial is an SKI terms with free variables.
- term {n : ℕ} : SKI → SKI.Polynomial n
- var {n : ℕ} : Fin n → SKI.Polynomial n
- app {n : ℕ} : SKI.Polynomial n → SKI.Polynomial n → SKI.Polynomial n
Instances For
Application between polynomials
Equations
- Cslib.SKI.«term_⬝'_» = Lean.ParserDescr.trailingNode `Cslib.SKI.«term_⬝'_» 100 100 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ⬝' ") (Lean.ParserDescr.cat `term 101))
Instances For
Notation by analogy with pointers in C
Equations
- Cslib.SKI.«term&_» = Lean.ParserDescr.node `Cslib.SKI.«term&_» 101 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol "&") (Lean.ParserDescr.cat `term 101))
Instances For
Equations
Substitute terms for the free variables of a polynomial
Equations
Instances For
A polynomial with no free variables is a term
Equations
Instances For
Inductively define a polynomial Γ' so that (up to the fact that we haven't
defined reduction on polynomials) Γ' ⬝ t ↠ Γ[xₙ ← t].
Equations
- (Cslib.SKI.Polynomial.term x_1).elimVar = (Cslib.SKI.Polynomial.term Cslib.SKI.K).app (Cslib.SKI.Polynomial.term x_1)
- (Cslib.SKI.Polynomial.var i).elimVar = if h : ↑i < n then (Cslib.SKI.Polynomial.term Cslib.SKI.K).app (Cslib.SKI.Polynomial.var (Fin.ofNat n ↑i)) else Cslib.SKI.Polynomial.term Cslib.SKI.I
- (Γ.app Δ).elimVar = ((Cslib.SKI.Polynomial.term Cslib.SKI.S).app Γ.elimVar).app Δ.elimVar
Instances For
Correctness for the elimVar algorithm, which provides the inductive step of the bracket abstraction algorithm. We induct backwards on the list, corresponding to applying the transformation from the inside out. Since we haven't defined reduction for polynomials, we substitute arbitrary terms for the inner variables.
Bracket abstraction, by induction using SKI.Polynomial.elimVar
Instances For
Basic auxiliary combinators. #
Each combinator is defined by a polynomial, which is then proved to have the reduction property we want. Before each definition we provide its lambda calculus equivalent. If there is accepted notation for a given combinator, we use that (given everywhere a capital letter), otherwise we choose a descriptive name.
Reversal: R := λ x y. y x
Equations
Instances For
A SKI term representing R
Equations
Instances For
Composition: B := λ f g x. f (g x)
Equations
Instances For
A SKI term representing B
Equations
Instances For
C := λ f x y. f y x
Equations
Instances For
A SKI term representing C
Equations
Instances For
Rotate right: RotR := λ x y z. z x y
Equations
Instances For
A SKI term representing RotR
Equations
Instances For
Rotate left: RotR := λ x y z. y z x
Equations
Instances For
A SKI term representing RotL
Equations
Instances For
Self application: δ := λ x. x x
Equations
Instances For
A SKI term representing δ
Equations
Instances For
H := λ f x. f (x x)
Equations
Instances For
A SKI term representing H
Equations
Instances For
Curry's fixed-point combinator: Y := λ f. H f (H f)
Equations
Instances For
A SKI term representing Y
Equations
Instances For
The fixed-point property of the Y-combinator
It is useful to be able to produce a term such that the fixed point property holds on-the-nose, rather than up to a common reduct. An alternative is to use Turing's fixed-point combinator (defined below).
Equations
- f.fixedPoint = (Cslib.SKI.H.app f).app (Cslib.SKI.H.app f)
Instances For
Auxiliary definition for Turing's fixed-point combinator: ΘAux := λ x y. y (x x y)
Equations
Instances For
A term representing ΘAux
Equations
Instances For
Turing's fixed-point combinator: Θ := (λ x y. y (x x y)) (λ x y. y (x x y))
Equations
Instances For
Church Booleans #
Standard true: TT := λ x y. x
Equations
Instances For
Standard false: FF := λ x y. y
Equations
Instances For
Conditional: Cond x y b := if b then x else y
Equations
Instances For
Neg := λ a. Cond FF TT a
Equations
Instances For
And := λ a b. Cond (Cond TT FF b) FF a
Equations
- One or more equations did not get rendered due to their size.
Instances For
A SKI term representing And
Equations
Instances For
Or := λ a b. Cond TT (Cond TT FF b) b
Equations
- One or more equations did not get rendered due to their size.
Instances For
A SKI term representing Or
Equations
Instances For
Pairs #
MkPair := λ a b. ⟨a,b⟩
Equations
Instances For
First projection
Equations
Instances For
Second projection
Equations
Instances For
Unpaired f ⟨x, y⟩ := f x y, cf Nat.unparied.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A term representing Unpaired
Equations
Instances For
Pair f g x := ⟨f x, g x⟩, cf Primrec.Pair.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A SKI term representing Pair