coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "Soegtrop, Michael" <michael.soegtrop AT intel.com>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: RE: [Coq-Club] Simplification for typeclass instances
- Date: Mon, 12 Sep 2016 08:15:07 +0000
- Accept-language: de-DE, en-US
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=michael.soegtrop AT intel.com; spf=Pass smtp.mailfrom=michael.soegtrop AT intel.com; spf=None smtp.helo=postmaster AT mga11.intel.com
- Ironport-phdr: 9a23:1ZnwJRzrc7etJXbXCy+O+j09IxM/srCxBDY+r6Qd0eMXIJqq85mqBkHD//Il1AaPBtSCrawbwLGP6+igATVGusfZ9ihaMdRlbFwssY0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfTR8Kum9IIPOlcP/j7n0oMyKJVsXz2HkOfsydEzw9lSJ8JFOwMNLEeUY8lPxuHxGeuBblytDBGm4uFLC3Pq254Np6C9KuvgspIZqWKT+eLkkH/QDVGx1ezN92Mq+/xLEVE6E4mYWemQQiBtBRQbfplmuVZDo9yD+q+BV2S+APMSwQ6piChq46KI+AiTvhSgbLTkhtCnyi8dwha9f6lr1oh10w4fZZMeOM/dxYrnaZfsbQ3ZMWoBaUCkXUdD0VJcGE+dUZbUQlIL6vVZb9RY=
Dear Jonathan, Daniel,
> I don't think there is a way tactically to decide if a definition is an
> instance
I thought about it once more: one issue with eauto is that it will also use
local hypothesis. So these must be cleared before the test and this must be
undone after the test. Below is a tactic which does this with a few test
cases.
Best regards,
Michael
Inductive t := Inst | Hyp | Def.
Class C := { c : t }.
Instance i : C := { c:= Inst }.
Definition d : C := Build_C Def.
Definition h : C := Build_C Hyp.
(* Basic is instance tactic *)
Ltac is_instance_basic term :=
let Hex := fresh "InstExists" in
let Heq := fresh "InstEqual" in
let T := type of term in
pose ( ltac:(eauto 1 with nocore typeclass_instances) : T ) as Hex;
assert( Hex = term ) as Heq by reflexivity;
clear Heq;
clear Hex.
(* Remove all hypotheis of the type in question and wrap this in a double
inversion to undo the removal *)
Ltac is_instance term :=
tryif (
let T := type of term in
repeat match goal with H : T |- _ => clear H end;
tryif is_instance_basic term then fail else idtac
) then fail else idtac.
Goal True.
(* is_instance_basic and is_instance work fine without hypotheis of type C *)
is_instance_basic i.
Fail (is_instance_basic d).
Fail (is_instance_basic h).
is_instance i.
Fail (is_instance d).
Fail (is_instance h).
(* With hypothesis of type C, only is_instance works *)
pose( Build_C Hyp ) as Chyp.
Fail (is_instance_basic i).
Fail (is_instance_basic d).
is_instance_basic h.
is_instance i.
Fail (is_instance d).
Fail (is_instance h).
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
- [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.