-
Notifications
You must be signed in to change notification settings - Fork 636
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 9663 (Miller pattern unification fails on evars) #9690
Conversation
@mattam82 you are fresh on this code, please tell me if my fix is too aggressive. In particular I start to doubt that the fast path for simple_eqn is just making things more buggy. |
Would you mind submitting depending PRs as Drafts in the future? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does fix the evar-to-Miller issue, but perhaps a related Miller-to-Miller problem should be also be addressed, e.g.:
Definition id_depfn21 {T A R} f := f : forall x y : T, A x -> R.
Definition id_depfn22 {T A R} f := f : forall x y : T, A y -> R.
Fail Definition idn2 f : nat -> nat -> nat := id_depfn21 (id_depfn22 f).
In general, all NotClean
errors should check whether the offending occurrences of variables occur only in evar contexts or in arguments of applied evars, as in such cases they can be unambiguously resolved by filtering the evars or assigning them K-terms, respectively.
pretyping/evarconv.ml
Outdated
@@ -502,13 +502,13 @@ let rec evar_conv_x flags env evd pbty term1 term2 = | |||
| Evar ev, _ when Evd.is_undefined evd (fst ev) && not (is_frozen flags ev) -> | |||
(match solve_simple_eqn (conv_fun evar_conv_x) flags env evd | |||
(position_problem true pbty,ev,term2) with | |||
| UnifFailure (_,OccurCheck _) -> | |||
| UnifFailure (_,(OccurCheck _ | NotClean _)) -> | |||
(* Eta-expansion might apply *) default () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on the following line need to be modified.
I think the second bug is morally from the same source, but this time is in This PR is still OK I think, I'll rebase and fix the comment (I can't make sense of it even for the existing case, ideas?). |
@mattam82 can you take and review this one? |
I'd like this to get in 8.10 since math-comp/math-comp#294 needs it and math-comp tries to be compatible with 2 versions of Coq. So if it misses 8.10 we won't even be able to merge the other PR in 6 months... |
Right, it's on my TODO for next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment was meant as a reminder that ?X = {| foo := ?X.(foo) |} can fail due to occur-check, while eta-expansion can solve it. IIUC, NotClean can also be raised, while pruning more would succeed, I guess the comment should reflect that.
I'm rebasing & updating the comment right away |
In particular evar_eqappr_x tries to find a miller pattern on both sides, while the fast path for evars tries solve_simple_eqn in one direction only. So if you have (Evar-not-miller = Evar-miller) the code was not trying to solve the RHS.
done |
Thanks, I'll wait for a last CI just in case and merge. |
Funny enough, this uncovers a bug in equations, unification is stronger which leads it to produce an ill-typed proof term. I'm working on a fix and will report here. |
@gares I made the fix to equations, basically now a constraint is postponed when it was failing before, I just switched to the new |
Ack-by: ggonthier Reviewed-by: mattam82
In particular evar_eqappr_x tries to find a Miller pattern on both sides,
while the fast path for evars tries solve_simple_eqn in one direction
only. So if you have (Evar-not-Miller = Evar-Miller) the code was not
trying to solve the RHS.
Depends on: #7819 (to avoid conflicts)