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
    theorem Cslib.SKI.evalStep_right_correct (x y : SKI) :
    x.evalStep = Sum.inr y โ†’ x.Red y

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

    theorem Cslib.SKI.RedexFree.no_red {x : SKI} :
    x.RedexFree โ†’ โˆ€ (y : SKI), ยฌx.Red y
    theorem Cslib.SKI.redexFree_iff {x : SKI} :
    x.RedexFree โ†” โˆ€ (y : SKI), ยฌx.Red y

    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_commonReduct_redexFree {x y : SKI} (h : x.CommonReduct 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 : x.CommonReduct y) :
    u = v

    Injectivity for booleans.

    A specialisation of Church : Nat โ†’ SKI.

    Equations
    Instances For
      theorem Cslib.SKI.isChurch_injective (x y : SKI) (n m : โ„•) (hx : IsChurch n x) (hy : IsChurch m y) (hxy : x.CommonReduct y) :
      n = m

      Injectivity for Church numerals

      theorem Cslib.SKI.rice {P : SKI} (hP : โˆ€ (x : SKI), Relation.ReflTransGen Red (P.app x) TT โˆจ Relation.ReflTransGen Red (P.app x) FF) (hxt : โˆƒ (x : SKI), Relation.ReflTransGen Red (P.app x) TT) (hxf : โˆƒ (x : SKI), Relation.ReflTransGen Red (P.app x) FF) :

      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).