[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"dTMvUojFXR":3},"# smallest-one-point-basis\n\nThe currently known smallest one-point bases[^5] for untyped lambda calculus, measured by Fokker size, have size 7.\nThere are three such one-point bases of Fokker size 7.\nThe first one (λx.λy.λz. y (λt.z) (x z)) was discovered by Meredith in 1963[^11]. Another two (λx.λy.λz.y z(x(λt.z))) (λx.λy.λz.x z(y(λt.z))) were found in 2022 by John Tromp[^4] and Mtv Europe[^10].\n\n| Lambda term                | De Bruijn index    | Discovered by          | Year | Fokker size | BLC size | Reference  |\n| -------------------------- | ------------------ | ---------------------- | ---: | ----------: | -------: | ---------- |\n| `λx.λy.λz. y (λt.z) (x z)` | `λλλ 1 (λ1) (2 0)` | Meredith               | 1963 |           7 |       26 | [^11]      |\n| `λx.λy.λz. y z (x (λt.z))` | `λλλ 1 0 (2 (λ1))` | John Tromp, Mtv Europe | 2022 |           7 |       26 | [^4] [^10] |\n| `λx.λy.λz. x z (y (λt.z))` | `λλλ 2 0 (1 (λ1))` | John Tromp, Mtv Europe | 2022 |           7 |       26 | [^4] [^10] |\n\n\nTake ɑ for example:\n\n```\nα = λλλ2 0 (1 (λ1))\nB = λλλ2 (1 0) = α(α(α(α(α α) α))(α α) α)(α(α(α α)))\nC = λλλ2 0 1 = α(α α α(α α α)(α α)(α α)) α α\nK = λλ1 = α α(α(α α) α α α) α(α α)\nW = λλ1 0 0 = α α(α(α(α α) α))\nI = λ0 = α(α(α(α α) α))(α(α α) α)\nF = λλ0 = α α α(α(α α)(α α)(α α)) α\nS = λλλ (2 0) (1 0) = α(α(α α(α α(α α))(α(α(α α(α α))))))α α\n```\n\nThe Fokker size of a closed term is the number of abstractions and applications it contains when written.\n\n```\ndef fokker_size : (Term String) -> Nat\n| bvar _ => 0\n| fvar _ => 0\n| abs t => 1 + fokker_size t\n| app t1 t2 => 1 + fokker_size t1 + fokker_size t2\n```\n\n\nOur goal:\n- Verify the smallest basis have fokker size 7 Or\n- Find the smallest basis\n\nWe use lean4 to formalize that all smaller closed term can't be basis.\n\nOur proof is based on [cslib](https://github.com/leanprover/cslib).\n\n## Status\n\n**Both search spaces we set out to clear are now completely closed, for arbitrary\nterms (not just normal forms).** The library builds with `lake build` and contains\nno `sorry` / `admit`, and no `axiom` declarations of its own.\n\nThe two headline theorems are\n\n* `not_basis_of_closed_lc_small_fokker_size`\n  (`FokkerChallenge/FokkerResolved.lean`)\n\n  ```lean\n  theorem not_basis_of_closed_lc_small_fokker_size (M : Term String)\n      (hm : M.LC ∧ M.fv = ∅ ∧ M.fokker_size \u003C 7) : not_basis M\n  ```\n\n  Every closed, locally closed term of Fokker size at most 6 — the 5420 terms\n  enumerated by `terms_fokker_lt_7` — fails to be a one-point basis. Together\n  with Meredith's basis this says\n  that the minimal Fokker size of a one-point basis is exactly 7 (the fact that\n  the size-7 term *is* a basis is not formalized here).\n\n* `not_basis_of_closed_lc_small_blc`\n  (`FokkerChallenge/BLC/BLCResolved.lean`)\n\n  ```lean\n  theorem not_basis_of_closed_lc_small_blc (M : Term String)\n      (hm : M.fv = ∅ ∧ M.blcT.length \u003C 26) (h_lc : M.LC) : not_basis M\n  ```\n\n  Every closed, locally closed term whose binary-lambda-calculus code[^9] is\n  shorter than 26 bits — 33382 terms, out of the 360965 de Bruijn terms of that\n  code length — fails to be a one-point basis.\n\nA third result, general rather than tied to a finite search space, is the\n**two-variables-per-node criterion** of `FokkerChallenge/Decider/TwoVarsPerNode.lean`:\nany closed term that uses at most two variables at every node of its tree is not\na one-point basis. It has its own section [below](#the-two-variables-per-node-criterion);\nit alone settles 5060 of the 5420 terms of the Fokker-size space.\n\nHere `not_basis M` is the strong statement (`FokkerChallenge/EnhancedCslib/GenFinset.lean`)\nthat there is a closed, locally closed term `y` such that *no* applicative\ncombination of `M` βη-reduces to `y`:\n\n```lean\ndef not_basises (atoms : List (Term String)) : Prop :=\n  ∃ y, y.LC ∧ y.fv = ∅ ∧ ∀ t, GenFinset atoms t → t ↠βηᶠ y → False\n\ndef not_basis (atom : Term String) : Prop := not_basises [atom]\n```\n\nBoth classification theorems rely on `native_decide` for the one enumeration\nstep that dispatches the whole search space to the deciders below\n(`mem_terms_fokker_lt_7_iff`, `mem_terms_blc_lt_26_iff`, both isolated in\n`FokkerChallenge/NativeEnum.lean`); apart from that they use\nonly `propext`, `Classical.choice` and `Quot.sound`. Every individual decider and\nevery certificate check is verified by the kernel. The only other `native_decide`\nuses are the two coverage statistics over `terms_fokker_lt_7` in\n`FokkerCertsTwoVarsPerNode.lean`, which nothing else depends on.\n\nThe two executables re-run the corresponding filters outside the kernel:\n\n```\n$ lake exe fokker_challenge\n0 undecided\n[]\n\n$ lake exe blc\n4 undecided\n[λλλ0 (λ1 0 2), λλλ0 (λ2 0 1), λλ0 (λλ1 0 2), λλ0 (λλ2 0 1)]\n```\n\nThe four terms reported by `lake exe blc` are the ones with no generic decider;\neach has its own dedicated proof file (see below), so the Lean classification\ncovers them too.\n\n## How it is proved\n\nThe classification splits the search space into a handful of decidable classes,\neach handled by a reusable criterion, plus a short list of hand-proved terms.\n\n| criterion | file | idea |\n| --- | --- | --- |\n| `every_bvar_used` → `not_reaches_K` | `Decider/EveryBvarUsed.lean` | free/bound variable use is preserved, so `K` is unreachable |\n| `no_duplicate` → `not_reaches_omega` | `Decider/NoDuplicate.lean` | non-duplicating terms cannot build `Ω` |\n| `only_one_var_used` → `only_one_var_used_not_reaches_S` | `Decider/OnlyOneVarUsed.lean` | a term using at most one variable per block cannot build `S` |\n| `all0_no_fvar_inside_abs` → `all0_no_fvar_inside_abs_not_reaches_S` | `Decider/All0.lean` | degenerate variable usage, `S` unreachable |\n| `argOk` → `argOk_not_basis` | `Decider/ArgNotVar.lean` | shape of the arguments along the spine |\n| `rigid` → `rigid_not_basis` | `Decider/RigidHead.lean` | every abstraction block `λx₁…x_s. z M₁…M_k` has `k ≥ 1` and head `z` the innermost binder |\n| `tailOk` → `tailOk_not_basis` | `Decider/TailNotVar.lean` | every block has `k ≥ 1` arguments with a non-variable last argument (hence no η-redex) |\n| `noCompositive`, `is_combinator` | `Decider/CompositiveEffect.lean` | Curry's \"no compositive effect\": such terms cannot build `B` |\n| `is_combinator` → `isProperBody_lc_not_basis` | `Decider/CraigTheorem.lean` | Craig's theorem: a proper combinator (body an applicative combination of variables) is never a basis; no parentheses → no compositive effect (`B` unreachable), parentheses → argument-safe (`K` unreachable) |\n| `isNamedOfXY` → `isNamedOfXY_not_basis` | `TwoVarsAreNotEnough/*` | terms nameable with only two variable names, following Statman's *two variables are not enough*[^3]; proved here without extra hypotheses |\n| `closedNodeTwoVars` → `closedNodeTwoVars_not_basis` | `Decider/TwoVarsPerNode.lean` | at most two variables are used at every node of the term tree; the unused binders are then created by β-steps from `K`, so the term is a β-reduct of a two-name term — see [the section below](#the-two-variables-per-node-criterion) |\n| `BetaReductOfNamable` → `BetaReductOfNamable_not_basis` | `BetaCheck.lean`, `BetaNamableClosure.lean` | certificate: the term is a β-reduct of a two-name term |\n| `not_basis_of_betaStar_namableXY` | `BetaReducesToNamable.lean` | certificate: the term β-reduces *to* a two-name term |\n\nEach decider follows the same scheme: a Boolean test that holds of the term, is\npreserved by β- and η-steps and by application, and fails for the target term\n(`K`, `Ω`, `B`, …); hence no applicative combination of a term passing the test\ncan βη-reduce to that target.\n\nThe certificate-driven criteria are checked by kernel computation on explicit\nlists: 785 terms in `fokkerUndecidedCerts`\n(`FokkerCerts1.lean` … `FokkerCerts9.lean`, assembled in `FokkerResolved.lean`)\nand 16 terms in `fokkerUpdatedOpenCerts` (`BLC/BLCResolved.lean`).\n\nThe first of these two certificate lists is largely superseded by the\ntwo-variables-per-node criterion, described in the next section.\n\nFour terms resist every generic criterion and get individual proofs:\n\n* `λλ0(λλ102)` — `NotBasisLamLam102.lean`\n* `λλ0(λλ201)` — `NotBasisLamLam201.lean`\n* `λλλ0(λ102)` — `NotBasisLamLamLam0Lam102.lean`\n* `λλλ0(λ201)` — `NotBasisLamLamLam0Lam201.lean`\n\nFor the first two the reachable βη-normal forms are classified completely — there\nare exactly three, and every other applicative combination is unsolvable — so\nneither `I` nor `K` is reachable. For the last two an explicit head-reduction\nmachine shows that no applicative combination βη-reduces to `I`. The supporting\nhead-reduction and divergence machinery lives in `PairT.lean` and\n`EnhancedCslib/Head*.lean`.\n\n`FokkerChallenge/EnhancedCslib/` collects the general λ-calculus theory the proofs\nneeded and that was not available upstream: βη normal forms, head reduction and\nhead strong normalization, η-spines, parallel reduction, and the `GenFinset`\nclosure of a set of atoms under application.\n\n## The two-variables-per-node criterion\n\nThis is the most general criterion in the development, and the only one that\nreplaces a whole search-certificate list by a theorem.\n\n**Files.** `FokkerChallenge/Decider/TwoVarsPerNode.lean` (the criterion and its\nproof) and `FokkerChallenge/FokkerCertsTwoVarsPerNode.lean` (its coverage,\nchecked by computation).\n\n### The test\n\nRead a term as a tree. Every node carries the set of de Bruijn indices that\npoint outside of the subtree sitting at it — i.e. the enclosing binders whose\nvariable is used somewhere below that node:\n\n```lean\ndef fidx : Term String → Finset ℕ\n  | .bvar i  => {i}\n  | .fvar _  => ∅\n  | .app a b => fidx a ∪ fidx b\n  | .abs t   => ((fidx t).erase 0).image (· - 1)\n```\n\nThe test asks that at most **two** variables are used at every node, and that\nthe term is closed:\n\n```lean\ndef nodeTwoVars : Term String → Bool\n  | .bvar _  => true\n  | .fvar _  => false\n  | .app a b => nodeTwoVars a && nodeTwoVars b\n  | .abs M   => decide ((fidx M).card ≤ 2) && nodeTwoVars M\n\ndef closedNodeTwoVars (t : Term String) : Bool :=\n  nodeTwoVars t && decide (fidx t = ∅)\n```\n\nBoth are Boolean and decidable by kernel computation, so applying the criterion\nto a concrete term is a `by decide`.\n\n### The theorem\n\n```lean\n/-- A closed term using at most two variables at every node is not a one-point basis. -/\ntheorem closedNodeTwoVars_not_basis {t : Term String} (h : closedNodeTwoVars t = true) :\n    not_basis t\n```\n\nIt is obtained from the sharper statement\n\n```lean\ntheorem betaReductOfNamable_of_closedNodeTwoVars {t : Term String}\n    (h : closedNodeTwoVars t = true) : BetaReductOfNamable t\n\ntheorem isNamedOfXY_namify_and_betaStar {t : Term String} (h : closedNodeTwoVars t = true) :\n    isNamedOfXY (namify t) = true ∧ namify t ↠βᶠ t\n```\n\n— such a `t` is a β-reduct of a term nameable with only the two variable names\n`x`, `y` — together with Statman's *two variables are not enough*[^3], which is\nproved in `TwoVarsAreNotEnough/` and lifted to β-reducts in\n`BetaNamableClosure.lean`.\n\n### Why it is true\n\nA closed term is nameable with two names exactly when at every abstraction node\n`λ.M` at most **one** *enclosing* binder is used inside `M` (`nameableNodes`,\n`namableXY_of_nameableNodes`); the binder introduced by the abstraction itself\nalways needs a name of its own. So a term passing the weaker per-node test can\nfail to be nameable, but only because of binders that are *unused* in their\nbody. Each such binder is created by a single β-step from `K = λx.λy.x`:\n\n```\nK N  ⭢β  λ_.N\n```\n\n`namify t` performs exactly this β-expansion at every unused binder of `t`. The\nproof is then constructive and splits in two halves:\n\n* `namify_betaStar` : `namify t ↠βᶠ t` — the expansion reduces back to `t`;\n* `nameableNodes_namify` + `namableXY_of_nameableNodes` : `namify t` really is\n  nameable with `x` and `y`, via the explicit naming function `nameIt` and its\n  correctness lemma `nameIt_spec`.\n\nNo search and no certificate is involved.\n\n### Coverage\n\n`FokkerCertsTwoVarsPerNode.lean` measures how much the criterion buys, by\ncomputation:\n\n| statement | content |\n| --- | --- |\n| `fokkerUndecided_nodeTwoVars_count` | 757 of the 785 search certificates of `FokkerCerts1`–`FokkerCerts9` are subsumed by the criterion |\n| `fokkerUndecided_not_basis_of_notMem` | consequently those 757 terms are `not_basis` without their certificates |\n| `fokkerUndecided_filter_not_nodeTwoVars` | the 28 exceptions are exactly the terms of `fokkerCertsNotNodeTwoVars` — each has a node using three variables (`λλλλ0(0(12))`, `λλλλ1200`, `λλ0(λλ210)`, …), so the criterion genuinely does not apply and they keep their certificates (`fokkerCertsNotNodeTwoVars_not_basis`) |\n| `fokkerUndecided_namify_eq_cert_count` | for 384 of the covered terms `namify` even reproduces literally the term the search had found, e.g. `namify λλλ1(12) = λλ(λλ1)(0(01))` |\n| `terms_fokker_lt_7_closedNodeTwoVars_count` | 5060 of the 5420 closed, locally closed terms of Fokker size `\u003C 7` pass the criterion outright |\n| `fokkerUpdatedOpenReduces_not_closedNodeTwoVars` | none of the 16 terms of `fokkerUpdatedOpenCerts` does, so the criterion and the \"β-reduces *to* a two-name term\" criterion of `BetaReducesToNamable.lean` are complementary |\n\nAll of these are kernel computations (`decide`) except the two statistics over\n`terms_fokker_lt_7` (`terms_fokker_lt_7_length`,\n`terms_fokker_lt_7_closedNodeTwoVars_count`), which use `native_decide` because\nthe enumeration `terms_fokker_lt_7` is defined by a well-founded recursion that\nthe kernel does not reduce.\n\n## Building\n\n```\nlake update\nlake exe cache get   # Mathlib cache, pulled in via cslib\nlake build\nlake exe fokker_challenge\nlake exe blc\n```\n\nThe `native_decide` steps in the two classification theorems are memory hungry;\nbuilding `FokkerChallenge.NativeEnum` is the slowest part of the build.\n\n## Independent checking\n\nThe two headline theorems are packaged for\n[Comparator](https://github.com/leanprover/comparator), which checks that a\nsolution proves the stated theorems, uses only permitted axioms, and is accepted\nby the Lean kernel replayed from an export file: see `Challenge.lean`,\n`Solution.lean`, `comparator-config.json` and [`COMPARATOR.md`](COMPARATOR.md).\n\nWe use `native_decide` because `decide` can cause an OutOfMemoryError (OOM).\n\n## Next step\n\n1. Formalize only 3 basis of fokker size 7\n2. Formalize only 3 basis of blc size 26\n\n### Related papers\n\nOnly 3 papers discuss single basis: [^1] [^2] [^3] \n\nThere are also some online discussion: [^6] [^7] [^8]\n\n\n### References\n\n[^1]: Legrand, Remi. \"A basis result in combinatory logic.\" The Journal of symbolic logic 53.4 (1988): 1224-1226.\n[^2]: Statman, Richard. \"Combinators hereditarily of order two.\" (1988).\n[^3]: Rick Statman. **Two Variables Are Not Enough**. In *Proceedings of the 9th Italian Conference on Theoretical Computer Science (ICTCS 2005)*, Lecture Notes in Computer Science, vol. 3701, pp. 406–409, Springer, 2005.  [DOI](https://doi.org/10.1007/11560586_32)\n[^4]: https://github.com/tromp/AIT/blob/master/Bases.lhs\n[^5]: https://en.wikipedia.org/wiki/Combinatory_logic\n[^6]: https://esolangs.org/wiki/Closed_lambda_term\n[^7]: https://mathoverflow.net/questions/415334/do-combinatory-logic-bases-need-a-function-of-3-variables#\n[^8]: https://cstheory.stackexchange.com/questions/36276/incomplete-basis-of-combinators\n[^9]: https://tromp.github.io/cl/Binary_lambda_calculus.html\n[^10]: http://frox25.no-ip.org/~mtve/wiki/LambdaOnePoint.html \n[^11]: https://github.com/tromp/AIT/blob/master/ait/minbase.lam\n",1795981097767]