Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] any down side to making all definitions Instances?

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] any down side to making all definitions Instances?


Chronological Thread 
  • From: Jonathan Leivent <jonikelee AT gmail.com>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] any down side to making all definitions Instances?
  • Date: Thu, 8 Sep 2016 09:36:01 -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-qk0-f180.google.com
  • Ironport-phdr: 9a23:xfLXCRbd1iP37Mzf9WS/5Zf/LSx+4OfEezUN459isYplN5qZpsu+bnLW6fgltlLVR4KTs6sC0LuP9f66EjJQqdbZ6TZZL8wKD0dEwewt3CUeQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2a3IyL0LW5/ISWaAFVjhK8Z6lzJVO4t1b/rM4T1KllLK8tyhLP6l9Fevpbw38gcVCUmRf/68O98bZs9i1Rv7Qq8MsWAvayRLgxUbENVGduCGsy/sC+7RQ=



On 09/08/2016 07:38 AM, Théo Zimmermann wrote:
You might be interested by Pierre-Évariste's, still experimental,
"cortouche" plugin:
https://github.com/pedagand/cortouche
So far it only looks for witnesses in the proof environment though, so it
is not exactly the same as what you are proposing.

Théo

It is possible to almost duplicate the functionality in Cortouche's readme using just 2 instance-free typeclasses and 2 hints:

Class Hyp (T : Type) := hyp : T.
Hint Extern 10 (Hyp _) => exactly_once multimatch goal with H : _ |- _ => exact H end : typeclass_instances.
Class AHyp (T : Type) := ahyp : T.
Hint Extern 10 (AHyp _) => exactly_once multimatch goal with H : _ |- _ => eapply H end : typeclass_instances.

Parameter typ: Type.
Parameter exp: Type.
Parameter is_foo: exp -> typ -> Prop.

Lemma example:
forall t e1 e2 ,
is_foo e1 t -> is_foo e2 t -> is_foo e1 t.
Proof.
intros.
exact (hyp: is_foo e1 t).
Qed.

Lemma example_patt:
forall t e1 e2 ,
is_foo e1 t -> is_foo e2 t -> is_foo e1 t.
Proof.
intros.
exact (hyp: is_foo e1 _).
Qed.

Lemma example_too_general:
forall t e1 e2 ,
is_foo e1 t -> is_foo e2 t -> is_foo e1 t.
Proof.
intros.
exact (hyp: is_foo _ _).
Abort.

Lemma example_too_many_successes :
forall t e1 e2 ,
is_foo e1 t -> is_foo e2 t -> exists e, is_foo e t.
Proof.
intros.
eexists.
Fail exact (hyp: is_foo _ _). (*Error: This tactic has more than one success.*)
exact (hyp: is_foo e1 _).
Qed.

Lemma example_concl:
(forall e t, is_foo e t) -> forall e t, is_foo e t.
Proof.
intros.
Fail exact (hyp: is_foo _ _).
exact (ahyp: is_foo _ _).
Qed.


Note that I could not get is_foo _ _ to fail in example_too_general - but that is because it isn't too general based on successes, but is based on matching. In terms of successes, there is only one possible success, which is is_foo e1 t. I added example_too_many_successes to show that multiple successes can be made to fail (due to the "exactly_one multimatch" combo in the hints).

-- Jonathan




Archive powered by MHonArc 2.6.18.

Top of Page