Skip to content

Commit 50924e4

Browse files
committed
feat(CombinatoryLogic): SKI ↔ Partrec equivalence
Prove that every Nat.Partrec function on ℕ is SKI-computable (nat_partrec_ski_computable). Translates all eight Nat.Partrec.Code constructors to SKI terms and proves correctness, exercising the Recursion.lean infrastructure: primitive recursion (Rec), μ-recursion (RFind/RFindAbove), Nat pairing/unpairing, and integer square root.
1 parent 5a72d6a commit 50924e4

5 files changed

Lines changed: 539 additions & 1 deletion

File tree

Cslib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public import Cslib.Languages.CombinatoryLogic.Confluence
7676
public import Cslib.Languages.CombinatoryLogic.Defs
7777
public import Cslib.Languages.CombinatoryLogic.Evaluation
7878
public import Cslib.Languages.CombinatoryLogic.List
79+
public import Cslib.Languages.CombinatoryLogic.PartrecEquivalence
7980
public import Cslib.Languages.CombinatoryLogic.Recursion
8081
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Context
8182
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Fsub.Basic

Cslib/Languages/CombinatoryLogic/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ theorem cond_correct (a x y : SKI) (u : Bool) (h : IsBool u a) :
288288

289289
/-- Neg := λ a. Cond FF TT a -/
290290
protected def Neg : SKI := SKI.Cond ⬝ FF ⬝ TT
291+
@[scoped grind →]
291292
theorem neg_correct (a : SKI) (ua : Bool) (h : IsBool ua a) : IsBool (¬ ua) (SKI.Neg ⬝ a) := by
292293
apply isBool_trans (a' := if ua then FF else TT)
293294
· apply cond_correct (h := h)

Cslib/Languages/CombinatoryLogic/List.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ theorem nil_def (c n : SKI) : (Nil ⬝ c ⬝ n) ↠ n :=
7474
NilPoly.toSKI_correct [c, n] (by simp)
7575

7676
/-- The empty list term correctly represents `[]`. -/
77+
@[scoped grind .]
7778
theorem nil_correct : IsChurchList [] Nil := nil_def
7879

7980
/-! ### Cons: Consing an element onto a list -/

0 commit comments

Comments
 (0)