Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] non-automatic type class resolution

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] non-automatic type class resolution


Chronological Thread 
  • From: Jonathan Leivent <jonikelee AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] non-automatic type class resolution
  • Date: Thu, 1 Sep 2016 21:36:40 -0400
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jonikelee AT gmail.com; spf=Pass smtp.mailfrom=jonikelee AT gmail.com; spf=None smtp.helo=postmaster AT mail-qk0-f176.google.com
  • Ironport-phdr: 9a23:I+3O1B3bmpztKcD9smDT+DRfVm0co7zxezQtwd8ZsegTLfad9pjvdHbS+e9qxAeQG96KsrQZ0aGL6+igATVGusfZ9ihaMdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfTR8Kum9IIPOlcP/j7n0oMyKJVgSz2flKfMqdVPt/F2X7pFXyaJZaY8JgiPTpXVJf+kEjUhJHnm02yjG28Gr4ZR4+D5Rsf9yv+RJUKH9YrhqBecAVGduYCgJ45jgsgCGRg+S7FMdVH8Xm1xGGVvr9hb/C7X2tCLmtuN7kA2XPNP7S6x8DTal6aZoRRvlhQ8IMjc49Cfcjckm3/ETmw6ouxEqm92cW4qSLvcrJq4=



On 09/01/2016 07:38 PM, Jonathan Leivent wrote:


On 09/01/2016 07:19 PM, Vadim Zaliva wrote:
Sometimes I wish I can avoid automatic typeclass resolution and make it
generate sub-goals for all unresolved type class instances. Then I can
proceed and prove them manually, instead of using Hints, etc. Something
like 'unshelve':

The following example:

Class A (n:nat) : Prop.
Definition f (n:nat) `{A n} := n.
Definition g (n:nat) := n.
Lemma Foo: forall x, f (g x) = x.

In absence of:

Instance A_g: forall x, A (g x).

gives me:

Error:
Unable to satisfy the following constraints:
In environment:
x : nat

?H : "A (g x)"

And I could not proceed with the proof. Why couldn't it just generate a
sub-goal for A (g x) ?

Is there is a way to achieve this behavior in current version?

Is this sufficient?:

Class A (n:nat) : Prop.
Definition f (n:nat)`{A n} := n.
Definition g (n:nat) := n.

Lemma Foo: exists w, forall x, @f (g x) (w x) = x.
unshelve eexists.

This might be better:

Lemma Foo: forall x, exists w, @f (g x) w = x.
intro x.
unshelve eexists.

I think using an evar - either one created by exists or by the evar tactic (not refine) - are the only ways to create a subgoal of a class type that Coq doesn't immediately try to resolve. To use refine to do this, I think you have to create the hole with some other type that you can reduce to the desired class.

-- Jonathan




Archive powered by MHonArc 2.6.18.

Top of Page