fix: build casesOn for propositions from projections - #14925
Open
nomeata wants to merge 3 commits into
Open
Conversation
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XzL163q5FYpbZmT8EHQb3j
Collaborator
Author
|
!bench |
|
Benchmark results for 8f5e057 against 47680c2 are in. There are significant results. @nomeata
Large changes (1✅, 2🟥)
Medium changes (1🟥)
Small changes (3✅, 4🟥)
|
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
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) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GSbnoYQjyFAGmX75t7snrX
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 makes
casesOnandrecOnof 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, soAnd.casesOnand friends no longer require the proof itself to reduce.This matters for proofs that
abstractNestedProofshas 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 anAndthat is stored in aSubtypeand 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 whatExistsmay not do. The minor premise expects the fields ofI.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.leanmoves totests/elab: both of its sides now reduce tomkNat eapplied to a proof ofF e, which proof irrelevance identifies, and the elaborator and the kernel agree on that.