Documentation

Cslib.Languages.CombinatoryLogic.Evaluation

Evaluation results #

This file formalises evaluation and normal forms of SKI terms.

Main definitions #

Main results #

References #

This file draws heavily from https://gist.github.com/b-mehta/e412c837818223b8f16ca0b4aa19b166.

One-step evaluation as a function: either it returns a term that has been reduced by one step, or a proof that the term is redex free. Uses normal-order reduction.

Equations
Instances For

    The normal-order reduction implemented by evalStep indeed computes a one-step reduction.

    A term is redex free iff it has no one-step reductions.

    A term is redex free iff its only many-step reduction is itself.

    If a term has a common reduct with a normal term, it in fact reduces to that term.

    If x reduces to both y and z, and z is not reducible, then y reduces to z.

    theorem Cslib.SKI.unique_normal_form {x y z : SKI} (hxy : Relation.ReflTransGen Red x y) (hxz : Relation.ReflTransGen Red x z) (hy : y.RedexFree) (hz : z.RedexFree) :
    y = z

    If x reduces to both y and z, and both y and z are in normal form, then they are equal.

    theorem Cslib.SKI.eq_of_mJoin_red_redexFree {x y : SKI} (h : Relation.MJoin Red x y) (hx : x.RedexFree) (hy : y.RedexFree) :
    x = y

    If x and y are normal and have a common reduct, then they are equal.

    Injectivity for datatypes #

    theorem Cslib.SKI.isBool_injective (x y : SKI) (u v : Bool) (hx : IsBool u x) (hy : IsBool v y) (hxy : Relation.MJoin Red x y) :
    u = v

    Injectivity for booleans.

    A specialisation of Church : Nat → SKI.

    Equations
    Instances For
      @[simp]
      theorem Cslib.SKI.churchK_size (n : ) :
      (churchK n).size = n + 1
      theorem Cslib.SKI.isChurch_injective (x y : SKI) (n m : ) (hx : IsChurch n x) (hy : IsChurch m y) (hxy : Relation.MJoin Red x y) :
      n = m

      Injectivity for Church numerals

      Rice's theorem: no SKI term is a non-trivial predicate.

      More specifically, say a term P is a predicate if, for every term x, P · x reduces to either TT or FF. A predicate P is trivial if either it always reduces to true, or always to false. This version of Rice's theorem derives a contradiction from the existence of a predicate P and the existence of terms x for which P · x is true (P · x ↠ TT) and for which P · x is false (P · x ↠ FF).

      theorem Cslib.SKI.rice' {P : SKI} (hP : ∀ (x : SKI), Relation.ReflTransGen Red (P.app x) TT Relation.ReflTransGen Red (P.app x) FF) :
      (∀ (x : SKI), Relation.ReflTransGen Red (P.app x) TT) ∀ (x : SKI), Relation.ReflTransGen Red (P.app x) FF

      Rice's theorem: any SKI predicate is trivial.

      This version of Rice's theorem proves (classically) that any SKI predicate P either is constantly true (ie P · x ↠ TT for every x) or is constantly false (P · x ↠ FF for every x).