coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "Kumar, Ashish" <azk640 AT psu.edu>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: Re: [Coq-Club] How to avoid code-duplication in this proof?
- Date: Mon, 14 Sep 2020 13:26:07 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=psu.edu; dmarc=pass action=none header.from=psu.edu; dkim=pass header.d=psu.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dgIqgEEGoy4AAEr9/8Z+m7gnNUskXUntkBQLaFI/JPs=; b=AbsDUqIg5/TVr3jQft5PlY8cI7AWM1k9t34g+MPXua+tb1nRtYRnWEAxm9sb1Z8kLs+Ni81VeRUZcNX/SIp5XCzawjpOZ6fgBBXSwHrRU/b1uV2Q5HvE5sTxV4F+EAzKww/Z48YYCFE2+yMUDpY231IqbEMd1T++Daogp+Wq4XDJByACQQ6KDUBJZSsKVT3DPTOv5H7Xvy+ACGQ6osYAPg8bE4Xd4tiXqXO+We0UVEZI4x2QOj4rg1Ti6xENBnj5A6+vfzhFC3QSCRuKEOCz6wyZtHU15lmsZhWSWffip1NXXgLfX03NeW4VahO2L3L+K3KMMv6EP9B1jlHysgBCTg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SI1CJf4ejqv+Br8BOWxP566VhKBcz/TdTrTwOLTm/oTLGJLIRP044LS5L03LihpTCAReq0SJskm2TyTZymHcSQZl4LiBUnd9rVaMgaZWRrFVLR3fLf7x4goa2vECBxR3S027+aMJK/FdO5o0bU/1zjETwMCQCR4QBvjmFM/iDKeTwy8Pw5s3xU+04TKZO1nSSg8G+YqJj5N5dtchFEZoS1QAdmHced1djJO7v0IqHb86ytnRtceMBWDroiNaYmU1FnIywljlkdbgToMoGyLcOIE45v7SOUFCLkjKmrxPtDGmVXKNiDVwf/liBVX0CbUIUnhA3VjKu9xVA3uy6gkYkQ==
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=azk640 AT psu.edu; spf=Pass smtp.mailfrom=azk640 AT psu.edu; spf=Pass smtp.helo=postmaster AT NAM11-CO1-obe.outbound.protection.outlook.com
- Ironport-phdr: 9a23:OV2YsxWR7oN55YgrKU+O3mVFUVXV8LGtZVwlr6E/grcLSJyIuqrYbROFt8tkgFKBZ4jH8fUM07OQ7/m+HzVavd3R6TgrS99lb1c9k8IYnggtUoauKHbQC7rUVRE8B9lIT1R//nu2YgB/Ecf6YEDO8DXptWZBUhrwOhBoKevrB4Xck9q41/yo+53Ufg5EmCexbal9IRmrrAjdrNQajZVtJ6o+yRbFv2ZDdvhLy29vOV+dhQv36N2q/J5k/SRQuvYh+NBFXK7nYak2TqFWASo/PWwt68LlqRfMTQ2U5nsBSWoWiQZHAxLE7B7hQJj8tDbxu/dn1ymbOc32Sq00WSin4qx2RhLklDsLOjgk+2zRl8d+jr9UoAi5qhJ/3YDafZ2VOvR9cKPTf9waRHZOUclKWiNbHo+wc5ECA/YdMepGqYT2ulsArQG5BQmpHO7jxDpGhmLz3aIgyeQtCRzN0RA7H9IOsXTUt9X1OKkPWu2y1qbJzDbDYvJZ1Dvh84XIagshoeyWUb1ubMXR1FAiGgXYhVqftYLrJSma1vgRs2eF9epgU/qihm86pgxvrDaixskih4vNi44Jyl3J9Th0zZs1K9GlVEN2b8KoHZteuSyZKYd6X8MsTn90tSsnxbMKpIO2cSoKxZkh2hXRZfuHc42S7RLiUuacOTB4hG95eLK7gBay9kugxvfgWcmz1VZGtitFkt/WtnAMzRPf8MaHSuF780y82jiPzxje5+5YLUwuiKbXN5wszqQumpYNrUjPBDL6lFj2gaOOa0ko5uel5/7pb7jlvJOROJF4hhv/P6gzgsCzH+U1PhQAUmWe5OiwyKbs8Ez8TblUkvE7kazUvZDeKMkeo6O1HhJZ34A+4BilFTimys4XnXwfIVJFZh2Hi4/pNknWLv3kCvmznkmgnC51yv7fI7HtG5LNIWPdn7v7erZ99lJcxxE0zdBC4ZJbF6sNIOrpWk/2qNzXEAM2MxC1w+bgDtVxzIQeWX+TAq+dN6PStlyI6vgzLOmLYY8ZoDf9K/476P7ylXI0lkMRcbO00ZcLan20BOpqL1uFbXb2n9sNDGcHshI7TOPwiV2CVTBTZ2y1X6I5/jw0EoOnDYTCS42inLCMxz+7HoZLZmxcFF+DDGroe52eW/gQcCKSPtNhkjscWLe9TI8hzAiiuxP+y7p6NeXZ4TYYtJLm1Nht/eLfjxAy9TpuD8ScyW6BVW90nnlbDwMxiep0plU4wVOe24B5heZZHJpd/bkBBgw9LNvXy/FwI9H0QAPIONmTHgWIWNKjVHsSU9c42ZtGSl19Gs6ixFiX1jipXeNNv6SQGdo5/r+KjCu5HNp013uTjPpptFIhWMYabTT31J46zBDaAsvyq2vckq+rcaoG2yucpn+Y0CyDsFwKCVctA5WAZmgWYw7tlfq85k7GSOPxW5IOF1IYjOWlc+5NYNCvikhaTvD+PtiYe3i2h2q7GRePwPWLcZbufGIemi7aDRpdylxBzTO9LQE7QxyZjSfGFjU/R0r0fgXh/fQs8H4=
Thank you, that works.
For the first one, I realized later that we could I could use: 'Tactic Notation' instead of Ltac, which uses the tactical || .
With regards,
Ashish
For the first one, I realized later that we could I could use: 'Tactic Notation' instead of Ltac, which uses the tactical || .
With regards,
Ashish
From: coq-club-request AT inria.fr <coq-club-request AT inria.fr> on behalf of Jasper Hugunin <jasper AT hugunin.net>
Sent: Sunday, September 13, 2020 4:02 PM
To: coq-club AT inria.fr <coq-club AT inria.fr>
Subject: Re: [Coq-Club] How to avoid code-duplication in this proof?
Sent: Sunday, September 13, 2020 4:02 PM
To: coq-club AT inria.fr <coq-club AT inria.fr>
Subject: Re: [Coq-Club] How to avoid code-duplication in this proof?
Hi Ashish,
I'm not an expert on Ltac programming, so hopefully someone else will chime in here, but here is how I would solve your two issues.
(1) The first tactic
lets you define `Ltac symmetric_apply H := first [ apply H | symmetry in H; apply H ].` which I believe has exactly the behavior you describe. You can also replace first with solve if
you want to require that `symmetric_apply H''` finishes the proof.
(2) Consider using the form `assert (H'' : S1) by (apply L1; assumption);` This avoids the use of `{` which is causing you trouble when chaining with `;`.
Sincerely,
- Jasper Hugunin
On Sun, Sep 13, 2020 at 8:10 AM Kumar, Ashish <azk640 AT psu.edu> wrote:
Hi,
I am trying to prove a theorem (proof code given below). The issue is there is a lot of repeated code in the proof, which I would like to avoid. Is there a way to do so?
Proof has been summarized below to show only relevant details - In below proof,
(1) Let T1 and T2 denote a sequence of tactics of the form t1 ; t2 ; t3 ... ; tn.
(2) Let S1 be some lemma statement, which has type Prop.
(3) Let L1 be a lemma proved earlier.
Proof.
intros. split; intros H'; inversion_clear H'; T1.
+ assert (H" : S1). { apply L1; assumption. }
T2 ; apply H''.
+ assert (H" : S1). { apply L1; assumption. }
T2; symmetry in H''; apply H''.
Qed.
After the intros, we have a goal of the form (A -> B) /\ (B -> A).
The inversion_clear H' statement generates a total of 4 subgoals from the 2 subgoals generated by split, and T1 solves 2 of these 4 subgoals.
As you can see the proof code for the remaining 2 subgoals is almost identical (excluding the symmetry tactic). Note that I cannot push the assert statement earlier in the proof, as inversion_clear H' generates a variable st'0 which is used in the assert statements.
I have 2 issues:
(1) Is there a way I can write a customized tactic 'symmetric_apply H' which applies either H or the reversed version of H, and fails if both fail.
(2) Once (1) is done, the proof statement of the remaining 2 subgoals becomes exactly identical (using 'symmetric_apply' instead of apply).
Then is there a way, I could use the tactical ';' with the assert statement - Coq doesn't seem to be allowing me to do so?
Or if there is some other way of avoiding the code duplication, that would be great.
With regards,
Ashish
- [Coq-Club] How to avoid code-duplication in this proof?, Kumar, Ashish, 09/13/2020
- Re: [Coq-Club] How to avoid code-duplication in this proof?, Jasper Hugunin, 09/13/2020
- Re: [Coq-Club] How to avoid code-duplication in this proof?, Kumar, Ashish, 09/14/2020
- Re: [Coq-Club] How to avoid code-duplication in this proof?, Jasper Hugunin, 09/13/2020
Archive powered by MHonArc 2.6.19+.