-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: oversight in isReadOnlyOrSyntheticOpaque
#4206
Conversation
Mathlib CI status (docs):
|
isReadOnlyOrSyntheticOpaque
Do my changes on the |
@JovanGerb, they don't automatically get merged. I really need to set up a bot that generates notifications about merged PRs that have associated In the meantime, if this happens again, the right thing to do is ping me on zulip so I know to look for it! |
This backports some changes that fill in a few implicit arguments. nightly-2024-05-19 has trouble with these and the bug fix in leanprover/lean4#4206, and needs some fixes. I *think* all these changes are not actually problematic, and perhaps even improve readability. If a maintainer agrees, let's just do this on master. If any of these look at all bad, please just say so and I'll remove it from this PR and consider doing a minimization to understand if/why it is really necessary.
This backports some changes that fill in a few implicit arguments. nightly-2024-05-19 has trouble with these and the bug fix in leanprover/lean4#4206, and needs some fixes. I *think* all these changes are not actually problematic, and perhaps even improve readability. If a maintainer agrees, let's just do this on master. If any of these look at all bad, please just say so and I'll remove it from this PR and consider doing a minimization to understand if/why it is really necessary.
This backports some changes that fill in a few implicit arguments. nightly-2024-05-19 has trouble with these and the bug fix in leanprover/lean4#4206, and needs some fixes. I *think* all these changes are not actually problematic, and perhaps even improve readability. If a maintainer agrees, let's just do this on master. If any of these look at all bad, please just say so and I'll remove it from this PR and consider doing a minimization to understand if/why it is really necessary.
Explanation
In the case that
assignSyntheticOpaque := true
and the given metavariable issyntheticOpaque
and the depth of the metavariable is not the current depth,isReadOnlyOrSyntheticOpaque
returns false, even though the metavariable is read-only because of being declared at a smaller depth. This causes the metavariable to (wrongly) be able to be instantiated byisDefEq
.This bug was found at the proof of RingHom.PropertyIsLocal.sourceAffineLocally_of_source_openCover, which involves a type class synthesis for
CommRing ?m.2404
, and the synthesis manages to instantiate this metavariable into different values, even thoughsynthInstance?
increases the metavariable depth. This synthesis fails after 1 second.I found the bug while modifying the instance synthesis code: the modified code spent several minutes on this failed synthesis.
Test
The problem can be verified with the test:
this unification used to succeed, giving
true
, and this fix makes it returnfalse
.Impact on Mathlib
This fix causes a change in the behaviour of
congr
,convert
and friends, which breaks a couple of proofs in mathlib. Most of these are fixed by supplying more arguments.I fixed these proofs, and benched mathlib. The result is that most files are unaffected, but some files are significantly improved. This is most prominent in Mathlib.RingTheory.Jacobson, where the number of instructions has decreased by 28%. The overall improvement is a 0.3% reduction in instructions.
Zulip message