Repository navigation
feat: define well-founded recursion without large elimination of Acc - #14892
Merged
Merged
Conversation
This PR redefines `WellFounded.fix`, `WellFounded.fixF` and `WellFounded.recursion` so that they no longer eliminate an accessibility proof into data. They are now characterised by a `FixGraph` relation and obtained from `Classical.choice`, which means they depend on `Classical.choice` where they previously did not, and `#print axioms` reports that for anything defined by well-founded recursion. Their fixpoint equations are unchanged, compiled code is unaffected, and `Acc.rec` itself is untouched. For code that genuinely needs to eliminate an accessibility proof into data, the PR adds `Acc.rec'`, `Acc.recOn'`, `Acc.ndrec'` and `Acc.ndrecOn'`. These have the same signatures as `Acc.rec` and friends, but are `@[irreducible]` and go through the same `Classical.choice` construction, so they carry no iota rule: `Acc.rec'_intro` and `Acc.rec'_eq` replace the definitional unfolding. `Acc.rec'_eq` is the one to reach for where `rfl` used to close an unfolding equation, and since `rw` matches on the head symbol, wrappers like `Acc.recOn'` have to be unfolded first, as in `rw [myDef, Acc.recOn', Acc.rec'_eq]`. Together these remove the last uses of large elimination of `Acc` from the definition of well-founded recursion, and give downstream code a way to do the same. `@[csimp]` lemmas continue to rewrite `WellFounded.fixF`, `WellFounded.fix` and the whole `Acc.rec` / `Acc.rec'` family to directly recursive implementations. The universe parameters of the primed declarations are pinned motive-first to match the unprimed ones, because `@[csimp]` requires both sides of a replacement theorem to have identical universe parameter lists. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
nomeata
marked this pull request as draft
August 22, 2026 10:29
…lean4 into joachim/wf-without-large-elim
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Aug 25, 2026
7 of 12 tasks
…f-without-large-elim
…k` tests Well-founded definitions now use `Classical.choice`, so the axiom collection reaches it before `Quot.sound` in these tests' solutions. 🤖 Built with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
The adaptation PR for this PR is leanprover/downstream-lean4#162. |
`fixF` is now the choice-based definition itself rather than a wrapper around a separate `fixFImpl`, and `recursion` and `Acc.rec'` are defined through it. The lemmas follow the naming conventions: `FixGraph.nonempty`, `FixGraph.unique` and `fixGraph_fixF`. 🤖 Built with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
nomeata
marked this pull request as ready for review
October 13, 2026 17:18
nomeata
enabled auto-merge
October 13, 2026 17:18
nomeata
added a commit
to leanprover/downstream-lean4
that referenced
this pull request
Oct 13, 2026
…nto data The three definitions that recurse on an accessibility proof to produce data go through `Acc.recOn'` / `Acc.rec'` (added in leanprover/lean4#14892), and their unfolding equations, previously closed by `rfl`, go through `Acc.rec'_eq`. This prepares for leanprover/lean4#13851, which restricts `Acc.rec` to `Prop` motives. Ported from mathlib4-nightly-testing's `lean-pr-testing-13851` (f88713414c). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 14, 2026
Declarations outside a `public section` of a `module` are private already; the `redundantVisibility` linter flags the explicit keyword. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y7syR5U28E9wRjXxSWb41s
nomeata
enabled auto-merge
October 14, 2026 21:04
downstream-lean4 Bot
added a commit
to leanprover/downstream-lean4
that referenced
this pull request
Oct 15, 2026
…n of `Acc` (#162) This is the adaptation PR for leanprover/lean4#14892. --------- Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com> Co-authored-by: Joachim Breitner <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
meefs
pushed a commit
to meefs/lean4
that referenced
this pull request
Nov 21, 2026
…rover#13851) This PR restricts `Acc.rec` and other recursors for recursive `Prop` inductives to motives in `Prop`, removing large elimination for them while preserving it for non-recursive subsingleton-style products like `Eq`, `And`, `Iff`, `Or`, and `Unit`. The motivation is to ensure the kernel never has to look at a proof term of a `Prop`, which would in turn enable downstream tooling (e.g. external checkers) to drop proof subterms after typechecking. This is part of the Lean Kernel Renovation (leanprover#14977). The library-level work already happened in leanprover#14892: defining well-founded recursion without large elimination of `Acc`, and adding `Acc.rec'` and friends as the replacement for eliminating an accessibility proof into data. What is left here is the kernel change itself and the fallout from it. `elim_only_at_universe_zero` in `src/kernel/inductive.cpp` now returns true for `is_rec()` inductives. `Acc.ndrec` and `Acc.ndrecOn` are removed along with their `@[csimp]` pairs, since their signatures no longer typecheck; the primed replacements added by the base PR take over. Test expectations adjusted: `casesOnAcc.lean` is dropped (it tested large elimination of `Acc.casesOn` into `Nat`, which is exactly what the restriction removes), `print_cmd.lean`'s `#print Acc.rec` snapshot is updated to the restricted signature, and `csimpCore.lean` no longer lists `(Acc.rec, Acc.recC)`. Four kernel soundness regression tests are also dropped: `kernel_is_def_eq_equiv_manager_1.lean`, `kernel_is_def_eq_equiv_manager_2.lean`, `kernel_is_prop_ensure_sort.lean` and `kernel_is_prop_issue.lean`. All four build their exploit on `Acc.rec` at a `Bool` motive, so they no longer elaborate, and `Acc.rec'` cannot stand in for it: being `Classical.choice`-backed and without an iota rule, it does not produce the definitionally-distinct reducts the exploits depend on. This is a real loss of coverage for the `is_def_eq` cache and `is_prop` fixes, and reinstating it needs an exploit vehicle that does not go through a recursive `Prop` inductive. --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR redefines
WellFounded.fix,WellFounded.fixFandWellFounded.recursionso that they no longer eliminate an accessibility proof into data, and addsAcc.rec',Acc.recOn',Acc.ndrec'andAcc.ndrecOn'for code that needs to do so itself. Fixpoint equations and compiled code are unchanged, andAcc.recis untouched. The one visible change is that well-founded definitions now depend onClassical.choice, which#print axiomsreports.The new definitions are characterised by a
FixGraphrelation — a recursivePropinductive relating an argument to the value obtained by unfoldingFalong the accessibility tree — and are obtained fromClassical.choice.FixGraphis single-valued, which is whatWellFounded.fixF_eqandWellFounded.fix_eqare now proved from.Classical.choiceis taken from the prelude to avoid the import cycle thatimport Init.Classicalwould create.Acc.rec'and friends have the same signatures asAcc.rec,Acc.recOn,Acc.ndrecandAcc.ndrecOn, but are@[irreducible]and go through the same construction, so they carry no iota rule.Acc.rec'_introandAcc.rec'_eqreplace the definitional unfolding;Acc.rec'_eqis the one to reach for whererflused to close an unfolding equation, and sincerwmatches on the head symbol, wrappers likeAcc.recOn'have to be unfolded first, as inrw [myDef, Acc.recOn', Acc.rec'_eq].@[csimp]lemmas continue to rewriteWellFounded.fixF,WellFounded.fixand the wholeAcc.rec/Acc.rec'family to directly recursive implementations, so nothing becomes noncomputable in practice. The universe parameters of the primed declarations are pinned motive-first to match the unprimed ones, because@[csimp]requires both sides of a replacement theorem to have identical universe parameter lists.This is a prerequisite for #13851, which restricts
Acc.rectoPropmotives; it is useful on its own as a migration path, since downstream code can move toAcc.rec'before that lands.