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

congruence fails if universes differ, results in weird f_equal behavior #9979

Closed
samuelgruetter opened this issue Apr 23, 2019 · 5 comments · Fixed by #18106
Closed

congruence fails if universes differ, results in weird f_equal behavior #9979

samuelgruetter opened this issue Apr 23, 2019 · 5 comments · Fixed by #18106

Comments

@samuelgruetter
Copy link
Contributor

Set Universe Polymorphism.

Record Map(K V: Type) := {
  rep: Type;
  put: rep -> K -> V -> rep;
}.

Section Test.
  Universes u1 u2 u3 u4 u5 u6.

  Goal forall K V (M: Map K V) (k: K) (v: V) (m: rep K V M),
      put@{u1 u2 u3} K V M m k v = put@{u4 u5 u6} K V M m k v.
  Proof.
    intros.
    Fail congruence.
    reflexivity.

Desired behavior: congruence should succeed and solve the goal.

Moreover, since f_equal calls congruence, the following

  Goal forall K V (M: Map K V) (k: K) (v1 v2: V) (m: rep K V M),
      put@{u1 u2 u3} K V M m k v1 = put@{u4 u5 u6} K V M m k v2.
  Proof.
    intros.
    f_equal.

results in

2 subgoals (ID 28)
  
  K : Type
  V : Type
  M : Map K V
  k : K
  v1, v2 : V
  m : rep K V M
  ============================
  K = K -> V = V -> M = M -> m = m -> k = k -> v1 = v2 -> put K V M m k v1 = put K V M m k v2

subgoal 2 (ID 19) is:
 v1 = v2

instead of just the second subgoal.

Coq version: Both master (424c197, Apr 1), and 8.9 are affected.

Might be the same as #5481.

Thx @JasonGross for helping me isolate the problem.
/cc @andres-erbsen

@ejgallego
Copy link
Member

You can try ssreflect congr put which will work for this case; dunno if an improvement in general.

@samuelgruetter
Copy link
Contributor Author

If I do Require Import ssreflect., then congr put and congr _ indeed works. Why does ssreflect's congr need an extra argument?

@samuelgruetter
Copy link
Contributor Author

The documentation of congr says that it "may expand some definitions or fixpoints". This sounds dangerous from a performance point of view and I would not like to depend on this, but rather use a congruence which does not do any unfolding.

samuelgruetter added a commit to mit-plv/bedrock2 that referenced this issue Apr 23, 2019
…umption and to allow me to get to the lemma I want to work on faster), does not compile yet, stuck on f_equal/congruence not dealing correctly with universes (coq/coq#9979)
@ppedrot
Copy link
Member

ppedrot commented Apr 23, 2019

AFAICT this really looks like a duplicate of #5481.

@ppedrot
Copy link
Member

ppedrot commented May 5, 2019

Duplicate of #5481

@ppedrot ppedrot marked this as a duplicate of #5481 May 5, 2019
@ppedrot ppedrot closed this as completed May 5, 2019
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 1, 2023
…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).
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 3, 2023
…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.
herbelin added a commit to herbelin/github-coq that referenced this issue Oct 10, 2023
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants