coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Agnishom Chattopadhyay <agnishom AT cmi.ac.in>
- To: coq-club AT inria.fr
- Subject: [Coq-Club] Writing a tactic to automatically destruct pairs in hypothesis
- Date: Tue, 14 Apr 2020 11:32:00 -0500
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=agnishom AT cmi.ac.in; spf=Pass smtp.mailfrom=agnishom AT cmi.ac.in; spf=None smtp.helo=postmaster AT mail.cmi.ac.in
- Ironport-phdr: 9a23:IcP+8hD0eRMZdOgG8imNUyQJP3N1i/DPJgcQr6AfoPdwSP39o8bcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6i760TlHERLmcAFxO+7dG4jIjs3x2frh1YfUZlBhizy8erN1KV2drQzNqs4OiIdiO68ggk/ArX1JYORRwEtjIFPVlh2658Hmr80ryDhZp/90r50Iaq79ZaltFeUEXgRjCHg84YjQjTeGVRGGvyJOWWAX1BNDRQnDvkmjD8XB9xDiv+844xG0eMj/TLQ6QzOntv45Qxrpzi4McT8/ojiO155AyZlDqRfknCRRho7ZZIbMaqh7d6LZO9gfRCxIVYBQUX4ZDw==
I have a lot of theorems in which I implicitly destruct pairs by using a forall construct. Here is an example:
Definition f : nat -> nat * nat := fun x => (x, x).
Lemma silly : forall x y, f 1 = (x, y) -> x = y.
Proof. Admitted.
Lemma silly : forall x y, f 1 = (x, y) -> x = y.
Proof. Admitted.
Now, I'd like to use lemmas like silly as hypothesis in other proofs. But the point is that there is an obvious value for x and y which can be used since f is a function.
I tried writing a tactic that automatically destructs the term (f 1) and finds x and y so that the part after the -> can be used.
Ltac introsP H a b :=
match goal with
| [ H : (forall x y, ?f ?t = (x, y) -> ?X) |- _ ] =>
destruct (f t) as [a b] eqn:XX; specialize (H x y XX)
| [ H : (forall x y, (x, y) = ?f ?t -> ?X) |- _ ] =>
destruct (f t) as [a b] eqn:XX; specialize (H x y XX)
end.
match goal with
| [ H : (forall x y, ?f ?t = (x, y) -> ?X) |- _ ] =>
destruct (f t) as [a b] eqn:XX; specialize (H x y XX)
| [ H : (forall x y, (x, y) = ?f ?t -> ?X) |- _ ] =>
destruct (f t) as [a b] eqn:XX; specialize (H x y XX)
end.
However, I can't get this to work:
Goal 2 = 2.
pose proof silly.
introsP H a b.
pose proof silly.
introsP H a b.
How do I get this tactic to work?
--Agnishom
- [Coq-Club] Writing a tactic to automatically destruct pairs in hypothesis, Agnishom Chattopadhyay, 04/14/2020
- Re: [Coq-Club] Writing a tactic to automatically destruct pairs in hypothesis, Carl Patenaude-Poulin, 04/14/2020
Archive powered by MHonArc 2.6.18.