Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Writing a tactic to automatically destruct pairs in hypothesis

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Writing a tactic to automatically destruct pairs in hypothesis


Chronological Thread 
  • From: Carl Patenaude-Poulin <carlpaten AT protonmail.com>
  • To: "coq-club AT inria.fr" <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Writing a tactic to automatically destruct pairs in hypothesis
  • Date: Tue, 14 Apr 2020 16:50:47 +0000
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=carlpaten AT protonmail.com; spf=Pass smtp.mailfrom=carlpaten AT protonmail.com; spf=Pass smtp.helo=postmaster AT mail-40134.protonmail.ch
  • Ironport-phdr: 9a23:fJEf0xBeIxrXnLosLBASUyQJP3N1i/DPJgcQr6AfoPdwSP7/r8bcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6i760TlHUB74LE9+Ivn/Mo/UlcW+ke6osdWHaAJRwTG5fLlaLROsrAyXuNNA0rFvMqIg9hyciXJSf6xuzH9lI1uOkxu53sCt+J9lu3Bbsugl78dcXKPSZ74/UbteCT0nNyY+48i95jfZSg7azXIGVi0umwZFBQHY4By/ZpDstir8/r520TOeJcTqQLYcQS6l86BtTRbpjGEMMDtvozKfsdB5kK8O+EHpnBd42YOBONjIZso7RbvUeJYhfUQEXstVUHYfUIa1bo9KU7JYZroet5P6u1wIqBK/AU+nBLG2k2MatjrNxaQ/lt8ZP0TexgV5QYAWqnPIq9PwPaYWF+uyyfuQlGSRX7ZtwT74rbPwXFUkqPCIU6h3dJOPm1E1EB/CiFCZqIijNDSQhL0A

If you add idtac H; (basically a printf) at the start of each pattern branch, you can see that in your example the first branch is entered, but is then exited. This points to one of the tactics in that branch failing. You can pinpoint the problem further by testing with parts of the branch commented out. In particular, commenting out the call to specialize makes the tactic succeed, so you know there's something wrong with that part.

Hope that helps.



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, April 14, 2020 12:32 PM, Agnishom Chattopadhyay <agnishom AT cmi.ac.in> wrote:

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.

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.
However, I can't get this to work:

Goal 2 = 2.
  pose proof silly.
  introsP H a b.

How do I get this tactic to work?

--Agnishom




Archive powered by MHonArc 2.6.18.

Top of Page