Repository navigation
fix: make theorems opaque to the kernel as well - #14896
Merged
Merged
Conversation
nomeata
marked this pull request as ready for review
August 23, 2026 07:43
Collaborator
|
Reference manual CI status:
|
|
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Aug 23, 2026
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Aug 23, 2026
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Aug 23, 2026
|
nomeata
enabled auto-merge
August 23, 2026 13:00
nomeata
disabled auto-merge
August 23, 2026 13:27
nomeata
marked this pull request as draft
August 23, 2026 17:36
Collaborator
Author
|
This is ready to go and painless, it seems. But I’m inclined to bundle it with other kernel logic changes, else the coordination on the arena becomes a mess. |
Collaborator
Author
|
!perf |
This PR completes #12973: theorems are now also opaque to the kernel, which until now would still delta-reduce them. So the value of a theorem no longer affects whether a declaration type-checks, and conflicting theorem declarations with the same type can no longer make type checking depend on import order. The `Lean`-side `ConstantInfo.hasValue` was already adjusted in #12973, but the kernel uses the C++ `constant_info::has_value`, which was missed. That is what `type_checker::is_delta` consults, so `Acc.rec` applications, for instance, still reduced through theorem proofs in the kernel even though the elaborator refused to. Also switches `has_constructor` in `src/library/util.cpp` to an explicit `is_constructor` check, so it no longer piggybacks on `has_value`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01XzL163q5FYpbZmT8EHQb3j
This PR makes `casesOn` and `recOn` of a proposition apply the minor premise to the projections of the major premise, instead of going through the recursor. A recursor only reduces once its major premise is a constructor application, which a proof may never become, so `And.casesOn` and friends no longer require the proof itself to reduce. This matters for proofs that `abstractNestedProofs` has moved into auxiliary theorems, whose values are not available for reduction: the module system does not expose them outside their defining module, and theorems are opaque. An abstracted proof of an `And` that is stored in a `Subtype` and later pattern-matched, or eliminated into data directly, otherwise makes the enclosing definition ill-typed. `Lean.mkCasesOnViaProjs?` applies to a proposition with a single constructor, no indices and no recursion, whose recursor supports large elimination. Large elimination forces every field to be a proof, which is what makes the projections available, since projecting data out of a proposition is what `Exists` may not do. The minor premise expects the fields of `I.mk x₁ … xₙ` rather than those of the major premise, but both are proofs of the same proposition, so proof irrelevance identifies them. `tests/elab_fail/etaStructIssue.lean` moves to `tests/elab`: both of its sides now reduce to `mkNat e` applied to a proof of `F e`, which proof irrelevance identifies, and the elaborator and the kernel agree on that. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01XzL163q5FYpbZmT8EHQb3j
Passed inline, these proofs are abstracted into theorems, which the kernel no longer unfolds, so `Acc.rec` gets stuck on them and the test's defeq gate fails before it reaches its actual assertion. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01M5jcJjLLjxhiAueieK4KEj
nomeata
force-pushed
the
joachim/kernel-thms-opaque
branch
from
August 25, 2026 09:55
8da35e5 to
cec8033
Compare
nomeata
changed the base branch from
master
to
joachim/prop-casesOn-projections
August 25, 2026 09:55
Collaborator
Author
|
!bench |
|
Benchmark results for cec8033 against 8f5e057 are in. No significant results found. @nomeata
Small changes (2✅, 1🟥)
|
Replaces the inline level-parameter comparison with the predicate from #14909, which documents the extra-motive-universe encoding at its own definition. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GSbnoYQjyFAGmX75t7snrX
nomeata
changed the base branch from
joachim/prop-casesOn-projections
to
master
November 23, 2026 08:46
…ernel-thms-opaque Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 of 12 tasks
nomeata
marked this pull request as ready for review
November 23, 2026 09:26
…eKernel Since #15371 the kernel does not whnf a major premise that is a proof, so the `def` proof variant is now rejected by the kernel too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 23, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 23, 2026
Since #13851, `Acc.rec` no longer eliminates into `Type` and the kernel no longer reduces proofs in major premise position, so the test's `Acc` example no longer applies. Test kernel opacity of theorems directly via `Kernel.whnf`, and use a non-recursive, non-K, indexed Prop inductive for the recursor example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 23, 2026
nomeata
enabled auto-merge
November 23, 2026 14:20
|
The adaptation PR for this PR is leanprover/downstream-lean4#276. |
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 completes #12973: theorems are now opaque to the kernel as well, which until now would still delta-reduce them. The value of a theorem no longer affects whether a declaration type-checks, so conflicting theorem declarations of the same type can no longer make type checking depend on import order.
The
Lean-sideConstantInfo.hasValuewas already adjusted in #12973, but the kernel consults the C++constant_info::has_value, which was missed. That is whattype_checker::is_deltalooks at, so the kernel'swhnfstill unfolded theorems even though the elaborator refused to.has_constructorinsrc/library/util.cppswitches to an explicitis_constructorcheck, so it no longer piggybacks onhas_value.This is part of the kernel renovation #14977.