coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Matthieu Sozeau <matthieu.sozeau AT gmail.com>
- To: Tom Prince <tom.prince AT ualberta.net>
- Cc: Daniel Schepler <dschepler AT gmail.com>, Coq Club <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] Typeclasses and implicit arguments
- Date: Fri, 11 Mar 2011 10:21:34 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=OpFTuUyTVtUfQl2kSoV80iuGGECE+WVZw20Awtntb4szGNEQsZSYHYcKxbqzrf4VjY T5zsYF+uLyFQyNi3KEtrXseQv+PEuCTNT6tulNy6+pzf/MVZYheUFFuB3rq+sdm8xj+y eyzooBs8ec7JlsPM7wM/rSSVZIh4SHxxm9k18=
Hi,
Le 11 mars 2011 à 02:13, Tom Prince a écrit :
> On 2011-03-10, Daniel Schepler wrote:
>> Let me add my own question on typeclasses:
>>
>> Suppose I define
>>
>> Generalizable All Variables.
>>
>> Class ExtEqual {X Y} (f g:X->Y) : Prop :=
>> extensional_equality : forall x:X, f x = g x.
>>
>> Class injective `(f:X->Y) : Prop :=
>> injectivity: forall x1 x2:X, f x1 = f x2 -> x1 = x2.
>>
>> Instance injective_properness
>> `{ExtEqual X Y f g} `{injective _ _ f} :
>> injective g.
>>
>> Here why do I have to fill in the implicit arguments for ExtEqual and
>> injective? Is that the intended behavior?
>
> You can get the usual handling of implicit arguments by inserting ! at
> the begining of an generalizing binder, which also turns off the
> implicit generalization of unspecified arguments. I don't know what the
> rational for this behaviour is.
The idea is that one can easily bind all the parameters in one go, as in
`{ExtEqual X Y f g}. Compare with [{X Y} {f : X -> Y} {g} {ExtEqual f g}].
You could simply write {_:injective f} for the second binder.
>
>> Also, it seems if I add too many instances along these lines (fg injective
>> ->
>> g injective, id injective and surjective, etc.) I tend to end up with the
>> resolver failing in simple situations, and "typeclasses eauto" looping.
>
> I think that this is a known issue. I don't know of any general
> workarounds. One suggestion that I have seen for some cases, is to add a
> hint conditioned with a more specific pattern to the typeclass_instances
> database. (An instance is, as far as I can tell, essentially a hint in
> this databse)
Indeed it is. Clearly [fg injective -> g injective] is dangerous as it may
be applied infinitely often, starting with any [injective] goal.
-- Matthieu
- [Coq-Club] Typeclasses and implicit arguments, Daniel Schepler
- Re: [Coq-Club] Typeclasses and implicit arguments,
Tom Prince
- Re: [Coq-Club] Typeclasses and implicit arguments, Matthieu Sozeau
- Re: [Coq-Club] Typeclasses and implicit arguments,
Tom Prince
Archive powered by MhonArc 2.6.16.