Documentation

LeanPool.PartialCombinatoryAlgebras.Programming

Programming with PCAs #

A (non-trivial) PCA is Turing-complete in the sense that it implements every partial computable function. We develop here basic programming constructs that witness this fact:

For each combinator C we prove a definedness lemma df_C characterizing totality of expressions involving C. Characteristic equations for the simpler combinators (I, K', pair, fst, snd, the booleans, X, W, and the fixed-point combinators) are also proved here; equations for the more complex Curry-numeral predecessor and primitive-recursion combinators are omitted in this v4.30 port — they remain expressible in terms of the combinators themselves.

@[simp]
theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_I {A : Type u} [PCA A] {u : Part A} (hu : u ⇓) :
I ⬝ u = u
@[simp]
theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_K' {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
K' ⬝ u ⬝ v = v

Pairing #

The pairing combinator.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[simp]
    @[simp]
    theorem LeanPool.PartialCombinatoryAlgebras.PCA.df_pair_app_app {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
    (pair ⬝ u ⬝ v) ⇓
    @[simp]
    theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_pair {A : Type u} [PCA A] (u v w : Part A) (hu : u ⇓) (hv : v ⇓) (hw : w ⇓) :
    pair ⬝ u ⬝ v ⬝ w = w ⬝ u ⬝ v

    The first projection.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      @[simp]
      theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_fst {A : Type u} [PCA A] (u : Part A) (hu : u ⇓) :
      fst ⬝ u = u ⬝ K

      The second projection.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        @[simp]
        theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_snd {A : Type u} [PCA A] (u : Part A) (hu : u ⇓) :
        snd ⬝ u = u ⬝ K'
        theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_fst_pair {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
        fst ⬝ (pair ⬝ u ⬝ v) = u
        theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_snd_pair {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
        snd ⬝ (pair ⬝ u ⬝ v) = v
        @[simp]
        theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_fal {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
        fal ⬝ u ⬝ v = v
        @[simp]
        theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_ite_fal {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
        ite ⬝ fal ⬝ u ⬝ v = v
        @[simp]
        theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_ite_tru {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
        ite ⬝ tru ⬝ u ⬝ v = u

        The fixed point combinator #

        Auxiliary combinator used to define the fixed point combinator Z.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          @[simp]
          theorem LeanPool.PartialCombinatoryAlgebras.PCA.df_X_app {A : Type u} [PCA A] (u : Part A) (hu : u ⇓) :
          (X ⬝ u) ⇓
          @[simp]
          theorem LeanPool.PartialCombinatoryAlgebras.PCA.df_X_app_app {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
          (X ⬝ u ⬝ v) ⇓
          theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_X {A : Type u} [PCA A] (u v w : Part A) (hu : u ⇓) (hv : v ⇓) (hw : w ⇓) :
          X ⬝ u ⬝ v ⬝ w = v ⬝ (u ⬝ u ⬝ v) ⬝ w
          @[simp]
          theorem LeanPool.PartialCombinatoryAlgebras.PCA.df_Z_app {A : Type u} [PCA A] (u : Part A) (hu : u ⇓) :
          (Z ⬝ u) ⇓
          theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_Z {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
          Z ⬝ u ⬝ v = u ⬝ (Z ⬝ u) ⬝ v

          Auxiliary combinator used to define the call-by-value fixed point combinator Y.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[simp]
            theorem LeanPool.PartialCombinatoryAlgebras.PCA.df_W_app {A : Type u} [PCA A] (u : Part A) (hu : u ⇓) :
            (W ⬝ u) ⇓
            theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_W {A : Type u} [PCA A] (u v : Part A) (hu : u ⇓) (hv : v ⇓) :
            W ⬝ u ⬝ v = v ⬝ (u ⬝ u ⬝ v)
            theorem LeanPool.PartialCombinatoryAlgebras.PCA.eq_Y {A : Type u} [PCA A] (u : Part A) (hu : u ⇓) :
            Y ⬝ u = u ⬝ (Y ⬝ u)

            Curry numerals #

            Curry numeral

            Equations
            Instances For
              @[simp]

              Predecessor of a Curry numeral

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Auxiliary combinator used in the definition of primitive recursion.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Primitive recursion

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For