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

Improve: unification message in case of disallowed variable #3126

Closed
coqbot opened this issue Sep 11, 2013 · 3 comments
Closed

Improve: unification message in case of disallowed variable #3126

coqbot opened this issue Sep 11, 2013 · 3 comments

Comments

@coqbot
Copy link
Contributor

coqbot commented Sep 11, 2013

Note: the issue was created automatically with bugzilla2github tool

Original bug ID: BZ#3126
From: ruibaptista@live.com
Reported version: 8.4
CC: @aspiwack, @herbelin, @JasonGross

See also: #3823
See also: #5264

@coqbot
Copy link
Contributor Author

coqbot commented Sep 11, 2013

Comment author: ruibaptista@live.com

Goal forall T1 (P1 : T1 -> Type), sigT P1 -> sigT P1.

(* For this goal the following series of tactics fails. *)

(*

intros T1 P1 H1.
eexists.
destruct H1 as [x1 H1].
apply H1.

*)

(* But it's possible to get them to work simply by reordering them. *)

intros T1 P1 H1.
destruct H1 as [x1 H1].
eexists.
apply H1.

@coqbot
Copy link
Contributor Author

coqbot commented Sep 11, 2013

Comment author: @aspiwack

This is not a bug: an existential variable cannot be instantiated using variables introduced later. It would create ill-typed proof terms.

In fact it would allow proofs of False along the lines of:

Definition Top {A} (x:A) := True.

Goal exists x:False, Top x -> False -> False.
Proof.
  eexists.
  intros x y.
  instantiate (1:=y) in x.
  exact y.
Qed.

The error message of instanciate is much better :

Error: Instance is not well-typed in the environment of ?9

The apply tactic fails with:

Error: Impossible to unify "?9" with "x1".

I'm leaving this bug as a request for a better error message. (and changing the title along these lines)

@coqbot
Copy link
Contributor Author

coqbot commented Jul 13, 2016

Comment author: @herbelin

Backtracking on setting the bug as invalid (I was too quick on reading Arnaud's comment).

Actually, the error message improved and shows that there is a solution:

Goal forall T1 (P1 : T1 -> Type), sigT P1 -> sigT P1.
intros T1 P1 H1.
eexists ?[x].
destruct H1 as [x1 H1].
Fail apply H1.
(* Unable to unify "?x@ {H1:=existT P1 x1 H1}" with "x1" (cannot instantiate 
"?x" because "x1" is not in its scope: available arguments are "T1" "P1"
"existT P1 x1 H1"). *)
(* The diagnosis of Coq is wrong, since x1 can be extracted from "existT P1 x1 H1". But the unification is not strong enough to do it. *)
(* Indeed, the following, which renounces to use x1 but redoes a case on the initial H1, works: *)
instantiate (x:=projT1 H1).
apply H1.
Qed.

In any case, my conclusions at this time are the following:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant