Skip to content

fix: add expected type hints to Sym rules modified by preprocessing - #16140

Open
kmehltretter82 wants to merge 3 commits into
leanprover:masterfrom
kmehltretter82:fix-sym-thm-expected-prop-hint
Open

kmehltretter82 wants to merge 3 commits into
leanprover:masterfrom
kmehltretter82:fix-sym-thm-expected-prop-hint

Conversation

@kmehltretter82

@kmehltretter82 kmehltretter82 commented Oct 31, 2026 •

Copy link
Copy Markdown

This PR adds an expected type hint to the proofs of Sym rewrite and backward rules whose statement is changed by Sym.preprocessType, so that the kernel checks the change once on the rule rather than at each instantiation, where it can re-evaluate match discriminants.

Local hypotheses always get the hint, because Sym.preprocessMVar rewrites their types in the local context while the kernel still sees the original binder types. Backward rules for data stay unhinted, since their values occur in later goals, where id would block structural matching.

Closes #15759

Prepared with AI assistance.

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Oct 31, 2026
…ssing

When Sym.preprocessType modifies a theorem statement (e.g., unfolding Unit to PUnit in match equation theorems, unfolding reducible definitions, or beta/eta reduction), wrap the theorem proof in mkExpectedPropHint with the preprocessed type before instantiating its parameters. This ensures the kernel checks definitional equality between the original and preprocessed types once on the polymorphic theorem rather than re-evaluating match discriminants at each instantiated rewrite step.
…rocessing

Similarly wrap BackwardRule proofs in mkExpectedTypeHint when Sym.preprocessType modifies the rule statement or when the rule expression contains free variables whose local declarations may have been preprocessed in place.
Wrapping a data rule in an expected type hint puts `id` into the value
assigned to the goal. Later goals then contain `id f x` instead of
`f x`, so structural matching in `apply` and `Sym.simp` fails. Hint only
rules whose type is a proposition.

Document why the hint exists and remove the redundant `Theorem.declName`
alias. Make the regression test fail with a kernel timeout rather than
running out of memory.
@kmehltretter82
kmehltretter82 force-pushed the fix-sym-thm-expected-prop-hint branch from da7ee0a to 4b24d09 Compare November 7, 2026 17:05
@kmehltretter82

Copy link
Copy Markdown
Author

changelog-tactics
awaiting-review

@github-actions github-actions Bot added awaiting-review Waiting for someone to review the PR changelog-tactics User facing tactics labels Nov 7, 2026

This branch has not been deployed

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

Labels

awaiting-review Waiting for someone to review the PR changelog-tactics User facing tactics 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.

Sym rewrite proofs re-evaluate match discriminants when preprocessing changes the rule statement

1 participant