coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jonathan Leivent <jonikelee AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Simplification for typeclass instances
- Date: Fri, 9 Sep 2016 13:46:10 -0400
- Authentication-results: mail2-smtp-roc.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-qt0-f170.google.com
- Ironport-phdr: 9a23:2Hgbaxdh/DleKP9BlCC3vSLPlGMj4u6mDksu8pMizoh2WeGdxc29YR7h7PlgxGXEQZ/co6odzbGH6ua+BSdZuMnJ8ChbNscTB1ld0YRetjdjKfDGIHWzFOTtYS0+EZYKf35e1Fb/D3JoHt3jbUbZuHy44G1aMBz+MQ1oOra9QdaK3Izkn9y1rpbUekBDgCe3SbJ0NhS/6wvL5ecMho43CKE3wwfJq30AX+lX225uORrHnRH658S9+JNu2ytVsvMlscVHVPOpLOwDUbVEAWF+YCgO78rxuEybQA==
On 09/09/2016 01:09 PM, Daniel Schepler wrote:
When working with typeclasses, I often find myself wanting something
like a class_simpl tactic which would unfold typeclass projections and
instances (except where the instance is an atomic variable, section
hypothesis, axiom/parameter, etc.). So, for example, in this:
Require Import Morphisms.
Class Zero (A:Type) : Type :=
zero : A.
Class Plus (A:Type) : Type :=
plus : A -> A -> A.
Class Equiv (A:Type) : Type :=
equiv : A -> A -> Prop.
Notation "0" := zero.
Infix "+" := plus.
Infix "==" := equiv (at level 70).
Class Plus0L (A:Type) `{Zero A} `{Plus A}
`{Equiv A} : Prop :=
plus_0_l : forall x:A, 0 + x == x.
Instance prod_zero (A B:Type) `{Zero A} `{Zero B} :
Zero (A * B) :=
(0, 0).
Instance prod_plus (A B:Type) `{Plus A} `{Plus B} :
Plus (A * B) :=
fun p1 => let '(a1, b1) := p1 in
fun p2 => let '(a2, b2) := p2 in
(a1 + a2, b1 + b2).
Inductive prod_equiv (A B:Type) `{Equiv A} `{Equiv B} :
Equiv (A * B) :=
| pair_proper_pre : Proper (equiv ==> equiv ==> prod_equiv A B)
(@pair A B).
Existing Instance prod_equiv.
Instance pair_proper (A B:Type) `{Equiv A} `{Equiv B} :
Proper (equiv ==> equiv ==> equiv) (@pair A B) :=
pair_proper_pre A B.
Instance prod_plus0l (A B:Type) `{Plus0L A} `{Plus0L B} :
Plus0L (A * B).
Proof.
intros [a b].
Here, I would love a class_simpl tactic to do the equivalent of:
unfold equiv, plus, prod_plus, zero, prod_zero.
to convert:
0 + (a, b) == (a, b)
to:
prod_equiv (0 + a, 0 + b) (a, b)
(And then the proof would finish with:
constructor; apply plus_0_l.
Qed.
)
One can use "constructor; apply plus_0_l" to prove this without doing any unfolding. So, I suppose you are just asking for the unfold so that you see the simplification interactively first?
I don't think there is a way tactically to decide if a definition is an instance, let alone a particular kind of instance. Similarly for projections - although in 8.6, there is an is_proj tactic (thanks to Jason), but I think that is only for primitive projections.
However, it might be possible to get something close to what you want via the Arguments notations that interact with cbn and simpl.
Otherwise, probably autounfold using a db that you populate with just the instances and projections you want is your best bet.
-- Jonathan
- [Coq-Club] Simplification for typeclass instances, Daniel Schepler, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jonathan Leivent, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jonathan Leivent, 09/09/2016
- RE: [Coq-Club] Simplification for typeclass instances, Soegtrop, Michael, 09/12/2016
- RE: [Coq-Club] Simplification for typeclass instances, Soegtrop, Michael, 09/12/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jonathan Leivent, 09/12/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jason Gross, 09/12/2016
- RE: [Coq-Club] Simplification for typeclass instances, Soegtrop, Michael, 09/12/2016
- RE: [Coq-Club] Simplification for typeclass instances, Soegtrop, Michael, 09/12/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jason Gross, 09/12/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jonathan Leivent, 09/12/2016
- RE: [Coq-Club] Simplification for typeclass instances, Soegtrop, Michael, 09/12/2016
- RE: [Coq-Club] Simplification for typeclass instances, Soegtrop, Michael, 09/12/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jonathan Leivent, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Gaetan Gilbert, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Daniel Schepler, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Gaetan Gilbert, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Daniel Schepler, 09/09/2016
- Re: [Coq-Club] Simplification for typeclass instances, Jonathan Leivent, 09/09/2016
Archive powered by MHonArc 2.6.18.