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

Unification should be able to invert constructors in evar instances #5264

Open
coqbot opened this issue Dec 14, 2016 · 4 comments
Open

Unification should be able to invert constructors in evar instances #5264

coqbot opened this issue Dec 14, 2016 · 4 comments
Labels
kind: wish Feature or enhancement requests. part: unification The unification mechanism.

Comments

@coqbot
Copy link
Contributor

coqbot commented Dec 14, 2016

Note: the issue was created automatically with bugzilla2github tool

Original bug ID: BZ#5264
From: @JasonGross
Reported version: 8.6
CC: @silene, @jonleivent

See also: BZ#3126
See also: BZ#3823

@coqbot
Copy link
Contributor Author

coqbot commented Dec 14, 2016

Comment author: @JasonGross

As in https://coq.inria.fr/cocorico/CoqDevelopment/UnificationProblems#Inverting_tuples_in_instances_of_existential_variables:

Goal forall T1 (P1 : T1 -> Type), sigT P1 -> sigT P1.
  intros T1 P1 H1.
  eexists ?[x].
  destruct H1 as [x1 H1].
  Fail apply H1. (* Error: In environment
T1 : Type
P1 : T1 -> Type
x1 : T1
H1 : P1 x1
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"). *)
  instantiate (x:=projT1 H1).
  apply H1.

@coqbot
Copy link
Contributor Author

coqbot commented Dec 14, 2016

Comment author: @JasonGross

Here is another case I'd like solved:

Goal forall T1 (ls : list T1), { ls' : _ | ls = nil \/ List.tl ls = ls' }.
  intros T1 ls.
  eexists ?[x].
  destruct ls as [|x xs]; [ left; reflexivity | right ].
  simpl.
  Fail reflexivity. (* In nested Ltac calls to "reflexivity" and "reflexivity", last call failed.
Error: In environment
T1 : Type
x : T1
xs : list T1
Unable to unify "?x@ {ls:=(x :: xs)%list}" with "xs" (cannot instantiate "?x" because "xs" is not in its scope: available arguments
are "T1" "(x :: xs)%list").
                     *)
  instantiate (x:=match ls with cons x xs => xs | _ => _ end).
  reflexivity.

@coqbot
Copy link
Contributor Author

coqbot commented Dec 14, 2016

Comment author: @jonleivent

This ties into this CEP: https://github.com/coq/ceps/blob/master/text/011-coevolving-evars.md

Here's how it would pan out with the first example:

Goal forall T1 (P1 : T1 -> Type), sigT P1 -> sigT P1.
  intros T1 P1 H1.
  eexists ?[x].
  destruct H1 as [x1 H1].
  instantiate (1:=ltac:(destruct H1 as [x1 H1])).
  apply H1.
Qed.

and in the second example:

Require List.
Goal forall T1 (ls : list T1), { ls' : _ | ls = nil \/ List.tl ls = ls' }.
  intros T1 ls.
  eexists ?[x].
  destruct ls as [|x xs]; [ left; reflexivity | right ].
  simpl.
  instantiate (1:=ltac:(destruct ls as [|x xs])).
  reflexivity.
Grab Existential Variables.
  constructor.
Qed.

@coqbot coqbot added the part: ltac Issues and PRs related to the Ltac tactic language. label Oct 18, 2017
@JasonGross
Copy link
Member

Note that when the constructor is for a record with judgmental eta, projecting the arguments is never wrong (destructing a record with judgmental eta is a reversible step; we can never learn a later constraint that will forbid a solution obtained by projecting out the fields).

cc also @herbelin

@JasonGross JasonGross added part: unification The unification mechanism. and removed part: ltac Issues and PRs related to the Ltac tactic language. labels Mar 9, 2021
@Alizter Alizter added the kind: wish Feature or enhancement requests. label Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: wish Feature or enhancement requests. part: unification The unification mechanism.
Projects
None yet
Development

No branches or pull requests

3 participants