Skip to content

Conversation

Tragicus
Copy link
Contributor

In one of the tests, rocq-prover/rocq#21180 encounters a non-pattern fragment unification problem and produces an eta-expansion that breaks Rocq-Elpi's unifier.

@Tragicus
Copy link
Contributor Author

This is a bit weird because the point of the eta-expansion is to make an evar instantiation succeed by making another evar forget one of its arguments. Yet, once the arguments make it into the second evar's context, the algorithm stops complaining about them and leaves them be. It would be best to detect this and make the instantiation work without absorbing the arguments, but I am not sure if there is a way to do this.

@gares
Copy link
Contributor

gares commented Oct 17, 2025

I had the impression Rocq's evars had a filter on the context to implement pruning without having to assign them (to a lambda ignoring the argument).

@Tragicus
Copy link
Contributor Author

If I understand correctly, that is for the arguments that are already in the context of the evar, not those that the evar is applied to.

@gares
Copy link
Contributor

gares commented Oct 17, 2025

Yes. Oh, I think I misread the test. I think it should be lp:(K u) and not (lp:K u), as you changed it.
But once you do that, I don't see why the evar would not have u in its scope.

IMO the old test had a mistake. Fixing that still requires the call to unify-eq?

@Tragicus
Copy link
Contributor Author

You need K : term for K = global GR to typecheck.

std.assert-ok! (coq.elaborate-skeleton T _ T1) "does not typecheck",
T1 = {{ fun u => SubType _ _ _ _ (lp:K u) _ }},
T1 = {{ fun u => SubType _ _ _ _ lp:(X u) _ }},
(@pi-decl _ {{ nat }} u\ coq.unify-eq (X u) {{ lp:K lp:u }} ok),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see now what you are doing. Maybe

(pi u\ X u = app[global GR,u]) % Rocq <= 9.1
;
(pi u\ X u = app[(fun _ _ _\ app[global GR,u]),_]) % Rocq > 9.1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, the test checks that the "magic record constructor" of mathcomp infers Ord. If now it infers something different, it may have consequences in MC as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That also works.

@gares gares merged commit 997aa9b into LPCIC:master Oct 20, 2025
134 of 135 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants