coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gaetan Gilbert <gaetan.gilbert AT ens-lyon.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Simplification for typeclass instances
- Date: Fri, 9 Sep 2016 19:47:46 +0200
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gaetan.gilbert AT ens-lyon.fr; spf=Pass smtp.mailfrom=gaetan.gilbert AT ens-lyon.fr; spf=None smtp.helo=postmaster AT labbe.ens-lyon.fr
- Ironport-phdr: 9a23:zV7XLBE2okRx8uACcdX9wp1GYnF86YWxBRYc798ds5kLTJ75ociwAkXT6L1XgUPTWs2DsrQf2rOQ7fyrADVfqdbZ6TZZIcQKD0dEwewt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEtfre9JIfegoyN2vyo/NWLOkMT1WP7P+85dUzp5UWJ749N0NMkcv5wgjLy4VJwM9xMwm1pIV/B1z3d3eyXuKBZziJLpvg6/NRBW6ipN44xTLhfESh0ezttvJ6j5lH/Sl6E4WJZWWELmDJJBRLE5Vf0RMTfqCz/48V01TWTO4XZTLQ+VC6+p/NkQRL0gSFBOD89+mzNluR9irkepAOmoVpx2diHM8muKPNic/aFLpshTm1bU5MJWg==
If you do
Arguments plus {A Plus} !_ !_ /.
then simpl on
0 + (a, b) == (a, b)
reduces to
prod_equiv A B (0 + a, 0 + b) (a, b)
without reducing 0 + x == x for x : A * B
I don't know that it would do the right thing (whatever that means) in other situations though.
Gaëtan Gilbert
On 09/09/2016 19:09, 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.
)
So, is there an existing tactic which would do this, that I'm missing?
- [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, 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.