Skip to content

fix: make theorems opaque to the kernel as well - #14896

Draft
nomeata wants to merge 3 commits into
joachim/prop-casesOn-projectionsfrom
joachim/kernel-thms-opaque
Draft

fix: make theorems opaque to the kernel as well#14896
nomeata wants to merge 3 commits into
joachim/prop-casesOn-projectionsfrom
joachim/kernel-thms-opaque

Conversation

@nomeata

@nomeata nomeata commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

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-side ConstantInfo.hasValue was already adjusted in #12973, but the kernel consults the C++ constant_info::has_value, which was missed. That is what type_checker::is_delta looks at, so Acc.rec applications, for instance, still reduced through theorem proofs in the kernel even though the elaborator refused to.

has_constructor in src/library/util.cpp switches to an explicit is_constructor check, so it no longer piggybacks on has_value.

Stacked on #14925, which makes casesOn of a proposition reduce without unfolding the proof. Without it, a proof that abstractNestedProofs has moved into an auxiliary theorem can no longer be eliminated into data.

@nomeata
nomeata marked this pull request as ready for review August 23, 2026 07:43
@nomeata
nomeata requested a review from leodemoura as a code owner August 23, 2026 07:43
@nomeata nomeata added the awaiting-mathlib We should not merge this until we have a successful Mathlib build label Aug 23, 2026
@github-actions github-actions Bot added toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN labels Aug 23, 2026
@leanprover-bot leanprover-bot added the builds-manual CI has verified that the Lean Language Reference builds against this PR label Aug 23, 2026
@leanprover-bot

leanprover-bot commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ✅ Reference manual branch lean-pr-testing-14896 has successfully built against this PR. (2026-08-23 08:11:25) View Log
  • 🟡 Reference manual branch lean-pr-testing-14896 build against this PR didn't complete normally. (2026-08-23 08:12:15) View Log
  • ✅ Reference manual branch lean-pr-testing-14896 has successfully built against this PR. (2026-08-23 10:31:47) View Log
  • 🟡 Reference manual branch lean-pr-testing-14896 build against this PR didn't complete normally. (2026-08-23 10:32:40) View Log
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 47680c2e62831da4daa01abe567b3e4fc509fbae --onto 16e77c407779fde9a649adf3478204d1915371a3. You can force reference manual CI using the force-manual-ci label. (2026-08-23 13:25:48)
  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 0dc10a41e6be57ef72d7f103c98c263620076b6c --onto 16e77c407779fde9a649adf3478204d1915371a3. You can force reference manual CI using the force-manual-ci label. (2026-08-25 11:47:19)

@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Aug 23, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 23, 2026

Copy link
Copy Markdown
  • 💥 Mathlib branch lean-pr-testing-14896 build failed against this PR. (2026-08-23 08:32:57) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 47680c2e62831da4daa01abe567b3e4fc509fbae --onto 16e77c407779fde9a649adf3478204d1915371a3. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-23 13:25:47)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 47680c2e62831da4daa01abe567b3e4fc509fbae --onto fd0efc4306a7773c2cd4e079ddaa907426d0f5da. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-25 10:30:47)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 0dc10a41e6be57ef72d7f103c98c263620076b6c --onto fd0efc4306a7773c2cd4e079ddaa907426d0f5da. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-25 11:47:17)

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 nomeata added the changelog-language Language features and metaprograms label Aug 23, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed awaiting-mathlib We should not merge this until we have a successful Mathlib build breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Aug 23, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

@nomeata
nomeata enabled auto-merge August 23, 2026 13:00
@nomeata
nomeata disabled auto-merge August 23, 2026 13:27
@nomeata
nomeata marked this pull request as draft August 23, 2026 17:36
@nomeata

nomeata commented Aug 23, 2026

Copy link
Copy Markdown
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.

@nomeata

nomeata commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

!perf

nomeata and others added 2 commits August 25, 2026 09:46
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M5jcJjLLjxhiAueieK4KEj
@nomeata
nomeata force-pushed the joachim/kernel-thms-opaque branch from 8da35e5 to cec8033 Compare August 25, 2026 09:55
@nomeata
nomeata changed the base branch from master to joachim/prop-casesOn-projections August 25, 2026 09:55
@nomeata

nomeata commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

!bench

@leanprover-radar

leanprover-radar commented Aug 25, 2026

Copy link
Copy Markdown

Benchmark results for cec8033 against 8f5e057 are in. No significant results found. @nomeata

  • 🟥 build//instructions: +892.3M (+0.01%)

Small changes (2✅, 1🟥)

  • elab/bv_decide_mul//wall-clock: -74ms (-3.14%)
  • 🟥 elab/bv_decide_realworld//instructions: +485.0M (+1.01%)
  • elab/cbv_arm_ldst//instructions: -163.2M (-0.30%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-manual CI has verified that the Lean Language Reference builds against this PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants