Skip to content

feat: no large elimination for recursive inductive predicates - #70

Draft
nomeata wants to merge 4 commits into
digama0:masterfrom
nomeata:no-large-elim
Draft

nomeata wants to merge 4 commits into
digama0:masterfrom
nomeata:no-large-elim

Conversation

@nomeata

@nomeata nomeata commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Mirrors leanprover/lean4#13851: recursors of recursive Prop inductives such as Acc only eliminate into Prop. Without this, lean4lean rejects Acc.recOn in Init exported from current Lean master.

Opened as a draft for visibility. The branch is based on Kha's lean4-bundle-4.35 tag, which Lean currently pins, so only the last commit is new here. Lean bundles this branch from the nomeata fork as a stop-gap until the Lean Kernel Renovation (leanprover/lean4#14977) is done and the checkers have caught up upstream.

🤖 Generated with Claude Code

digama0 and others added 4 commits August 26, 2026 21:28
Add `--import <file.ndjson>`, which parses a Lean 4 NDJSON export with
`lean4export`'s parser and replays it into an empty environment, rather than
replaying from `.olean`s. This is the entry point the Lean Kernel Arena uses.

`Quot.mk`/`Quot.lift`/`Quot.ind` are dropped from the constant map because
adding `Quot` initializes all of them at once, so replaying them individually
would fail as duplicates; `checkQuot := false` for the same reason.

`initSearchPath` moves after the early return: the import path reads a
self-contained file and needs no module search path.

`lean4export` is pinned to the tag matching our `lean-toolchain` rather than
tracking its master, which now requires a newer Lean than this branch builds
against.

Co-Authored-By: Claude Opus 5 <[email protected]>
The binary is 231 MB, nearly all of it the statically linked Lean library rather than `lean4lean`'s own code. Two changes bring it to 119 MB with no behavioural change.

`supportInterpreter` exports every symbol in the executable, which stops `--gc-sections` from dropping anything. The checker replays declarations through the kernel and never interprets Lean source, so it does not need the interpreter.

`Lean4Lean/Level.lean` is the only module in the executable's import closure that imports all of `Lean`; it needs only `Lean.Level`. Narrowing it also unblocks a further reduction to roughly 12 MB via `-linitialize_minimal`, once the pinned toolchain is new enough to ship `libinitialize_minimal.a` (leanprover/lean4#14936, first released in v4.35.0).

Checked against v4.33.1 by replaying `Init.Data.List.Basic` from oleans (711 declarations) and by parsing a 10 MB export file through `--import`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPPJuXrRxwXgsWEAqM62dd
Bumps `lean-toolchain` to `nightly-2026-09-06`, with `batteries` on `nightly-testing` and `lean4export` on `master`.

`Decidable` is no longer a `class inductive` with `isTrue`/`isFalse` constructors; it is a structure with a `decide : Bool` field and a `reflects_decide : decide.Reflects p` proof, and `Nat.decLe`, `Nat.decEq` and friends now take that shape. Two changes bring `Primitive.lean`'s reflection layer back in line.

`Reflection.toDec` builds `⟨b, _⟩` directly, so its `decide` field is literally the reflecting `Bool`. Structure eta and proof irrelevance then match it against the real instances, which the old `dite` form could not: a `dite` on an abstract condition has no `decide` field to project.

`Condition.decide` uses the `Decidable.decide` projection instead of `ite _ true false`. Those coincided when `ite` eliminated the `Decidable` inductive directly, but `ite` now goes through `dite`, leaving a `Bool.casesOn` on an abstract `decide` that does not reduce.

The reflection proof deliberately uses only `Bool.noConfusion` and `▸`, mirroring `Nat.decLe`'s own proof: the primitive check runs while replaying the primitive itself, so it may only mention constants in that primitive's dependency closure. `Eq.symm` and `Eq.trans` are not.

Also drops `reduceNative` and its three call sites. Kernel native reduction is gone, so `Lean.reduceBool` and `Lean.reduceNat` no longer exist; the hook only ever returned `none` or threw on those two constants.

Checked by replaying `Init.Data.List.Basic` into a fresh environment (5558 declarations, which exercises every primitive) and through `--import` on a 10 MB export file (4866 declarations), including an export produced by a different Lean build.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JPPJuXrRxwXgsWEAqM62dd
Mirror leanprover/lean4#13851 (leanprover/lean4#13851): recursors of recursive Prop inductives such as `Acc` only eliminate into `Prop`.

This fork is a stop-gap so that Lean can bundle a checker compatible with leanprover/lean4#13851 until the Lean Kernel Renovation (leanprover/lean4#14977) is done and the checkers have caught up upstream.

🤖 Built with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
nomeata added a commit to leanprover/lean4 that referenced this pull request Nov 22, 2026
…cursive Prop inductives (#16671)

This PR points the bundled `lean4lean` and `nanoda` checkers at forks
that mirror the kernel change from #13851, so that they accept recursors
of recursive `Prop` inductives such as `Acc.rec` that only eliminate
into `Prop`. The forks are a stop-gap until the Lean Kernel Renovation
(#14977) is done and the checkers have caught up upstream.

The corresponding changes are proposed upstream as draft PRs
digama0/lean4lean#70 and ammkrn/nanoda_lib#86.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants