Skip to content
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

Fixes #5481: support for unification of universe variables in congruence and f_equal #18106

Merged
merged 4 commits into from Oct 20, 2023

Conversation

herbelin
Copy link
Member

@herbelin herbelin commented Oct 1, 2023

We hash declarations without their universe instances while the universe constraints are (anyway) reinferred at the time of building the proof.

Giving two arguments to Ccalgo.Symb as I did is a bit hackish. The alternative would be to have a hash-consing function that discards universes but I did not find one.

Fixes #5481
Fixes #9979

Now also added: unification of universe levels so that congruence works on e.g. Type -> Type, the same way as it works for any non-Type T -> T.

  • Added / updated test-suite.
  • Added changelog.

@herbelin herbelin added kind: fix This fixes a bug or incorrect documentation. part: tactics part: congruence The congruence tactic. labels Oct 1, 2023
@herbelin herbelin added this to the 8.19+rc1 milestone Oct 1, 2023
@herbelin herbelin requested a review from a team as a code owner October 1, 2023 14:37
@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Oct 1, 2023
@herbelin herbelin force-pushed the master+fix5481-congruence-polyuniv branch from 68d4f1d to 631b962 Compare October 3, 2023 06:28
@herbelin
Copy link
Member Author

herbelin commented Oct 3, 2023

@coqbot run full ci

@coqbot-app coqbot-app bot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Oct 3, 2023
@ppedrot
Copy link
Member

ppedrot commented Oct 7, 2023

This is very hackish, and somewhat only side-stepping the real problem that we shouldn't ever rely on an ill-defined notion of "equality" for terms in an unification state... I guess this can qualify as a hotfix but I really don't like neither the original code nor the change.

@herbelin
Copy link
Member Author

herbelin commented Oct 7, 2023

an ill-defined notion of "equality" for terms in an unification state

Can't we just say that congruence works with its own notion of quotient over terms and that it does not have to be a standard one?

That is, from the moment that congruence is able to reconstruct a CIC proof that the terms it equates are equal, is it blamable that it uses its own quotient?

[This being said, I don't like particularly the patch either, but I don't know what else to do.]

plugins/cc/ccalgo.ml Outdated Show resolved Hide resolved
@ppedrot
Copy link
Member

ppedrot commented Oct 7, 2023

That is, from the moment that congruence is able to reconstruct a CIC proof that the terms it equates are equal

Equality only makes sense when the state is around. If you change the values of evars for instance, you'd get a different term. You cannot even EConstr.kind these things without the state.

@herbelin
Copy link
Member Author

herbelin commented Oct 7, 2023

The union-find part of congruence currently reasons on the nf_evar-form of the term (EConstr.to_constr ~abort_on_undefined_evars:false sigma t in cctac.decompose_term). Then, it does no unification at all between evars and treat them equal only if syntactically equal.

In the PR, there is unification involved but only between universe levels. With the PR, any two universe levels are assumed unifiable by default and an attempt to actually unify them happens at proof reconstruction, when we are back in the econstr stateful world. (Note that I did not test what happens when it fails to reconstruct, so let's try, ah, it says "Not convertible", which maybe should be turned instead into "congruence failed"...).

Back to evars, would we like to have congruence work also modulo evar-unification? At least, it is unclear to me how to implement union-find up to unification, if that's your point.

@ppedrot
Copy link
Member

ppedrot commented Oct 10, 2023

@herbelin if you implement @SkySkimmer 's change I can merge.

@ppedrot ppedrot self-assigned this Oct 10, 2023
herbelin and others added 4 commits October 10, 2023 18:09
Also turn a tclFAIL into a NotConvertible so that it can be caught.
…ruence.

We hash declarations without their universe instances while the
universe constraints are reinferred at the time of building the proof.

Also fixes coq#9979 (f_equal with universe polymorphism).

Also now solves "Goal Type -> Type" by unifying universe levels.

Co-authored-by: SkySkimmer <SkySkimmer@users.noreply.github.com>
…ils.

We address here the new case of unification failure between universe
variables (see previous commit).
@herbelin herbelin force-pushed the master+fix5481-congruence-polyuniv branch from 631b962 to 2f2ea93 Compare October 10, 2023 16:12
@herbelin herbelin requested a review from a team as a code owner October 10, 2023 16:12
@coqbot-app coqbot-app bot added the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Oct 10, 2023
@herbelin
Copy link
Member Author

@herbelin if you implement @SkySkimmer 's change I can merge.

Done.

I also added catching a typing error so that a proper error message is issued when unification of levels fails.

@ppedrot ppedrot removed the needs: full CI The latest GitLab pipeline that ran was a light CI. Say "@coqbot run full ci" to get a full CI. label Oct 20, 2023
@ppedrot
Copy link
Member

ppedrot commented Oct 20, 2023

@coqbot merge now

@coqbot-app coqbot-app bot merged commit f202dcb into coq:master Oct 20, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: fix This fixes a bug or incorrect documentation. part: congruence The congruence tactic. part: tactics
Projects
None yet
3 participants