coq-club AT inria.fr
Subject: The Coq mailing list
List archive
Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.)
Chronological Thread
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.)
- Date: Mon, 16 Apr 2018 17:45:55 +0000
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=jasongross9 AT gmail.com; spf=Pass smtp.mailfrom=jasongross9 AT gmail.com; spf=None smtp.helo=postmaster AT mail-qt0-f172.google.com
- Ironport-phdr: 9a23:Rb4y8RZX8Jymjs1XqrWMux//LSx+4OfEezUN459isYplN5qZoM+/bnLW6fgltlLVR4KTs6sC17KN9fi4EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCazbL9oMBm6sRjau9ULj4dlNqs/0AbCrGFSe+RRy2NoJFaTkAj568yt4pNt8Dletuw4+cJYXqr0Y6o3TbpDDDQ7KG81/9HktQPCTQSU+HQRVHgdnwdSDAjE6BH6WYrxsjf/u+Fg1iSWIdH6QLYpUjmk8qxlSgLniD0fOjE2/mHYiMx+gqxYrhy8uRJw35XZb5uJOPdkZK7RYc8WSGhHU81MVyJBGIS8b44XAuQFJ+lYtI79p10TphW/HwmsA/jvyiRVjXLx3601yf8hEQbA3AwvBdIOt2/UrM7xOaoJXuC1ybPHzTTHb/9MxTj9743IfwknrPqRU7xwds/RxlMuFwPDlliQqIrlPymU1usXqWSb4fBgWOSygGAkswF8uiajytsoh4XThY8YykrI+TtkzIs0P9G0VUx2bcCiHZBNrS+VLZF2TdknQ2xwuCY11LkGuZmjcSgP0psnxhrfZ+Wec4iU/h7vTeiRLSp6iX57Yr6/iBGy8U+vyu34SMa4ykpFri1AktXUt3AN0QLc6tSfR/dj4kus3SyD2gPT5+1eP0w4iKvWJ4Q8zrMyiJYfqUHDETX3mEXygq+WbEIk+u2w5uTleLrmvZicN4l7igHkNaQugde/DOAjPwgBWmiU4+W81Ln58ULlR7VKi+U6krPFv5DCOcQbuqm5DhdJ3YYk8hazFiup0NAFnXYcN19FYxKGj43xO17UOvz4DPG/g06tkDhx3fzGMKfhUd3xKS3Il66kdrJg4WZdzhAyxJZR/cF6ELYEddD6QUj3/PPCCQQie1i2yv3gDtpn0ZgFCEqAB6aYNOXZtlretbFnGPWFeIJA4GW1EPMi/fO71SZoy29YRrGg2N4sUF79G/1nJ0uDZn+124UOFG4Lukw1S+m40QTeAw4WXG67WucH3h9+EJivVN6RSYWkgbjH1yC+TMUPOzJ2T2uUGHKtTL2qHvcBbCXIfJ1kmz0AEKG9E8ovjE708gD9zLVjI6zf/ShK7Z8=
> I am not sure why it's like that. Maybe someone else can give you more insight.
Thank you very much! This is very helpful.QinxiangOn Mon, Apr 16, 2018 at 12:50 AM, Jason -Zhong Sheng- Hu <fdhzs2010 AT hotmail.com> wrote:It's due to a quirk in how [match] interactive with closure that does not take argument(I call that a thunk). Whenever a Ltac [match] appear in the first position of any argument, instead of being wrapped into a thunk, [match] will be run, that's why it escaped from the [try]. The workaround is to prepend the sequence with some other tactic that is not [match], in which case [idtac] is frequently used. In short, following code would work:
foo_tac ltac:(idtac; TA1).
foo_tac ltac:(idtac; TA2).
I am not sure why it's like that. Maybe someone else can give you more insight. In general, you will want to distinguish Ltac term and Gallina term by spelling out ltac:() in arguments. FYI, when in argument position, Ltac prioritizes Gallina terms, so if TA2 was one, then it will give a different output. Following program illustrates that:
Ltac bar_tac tac :=
idtac tac.
Goal True.
bar_tac TA2.
(* <tactic> *)
Inductive TA2 : Set :=.
bar_tac TA2.
(* TA2 *)
Abort.
Also,
foo_tac destruct_one_ex. (* This succeed. *)
This one did not work for me, and it also failed for the same reason. Following code works for me:
foo_tac ltac:(idtac; destruct_one_ex).
From: coq-club-request AT inria.fr <coq-club-request AT inria.fr> on behalf of Cao Qinxiang <caoqinxiang AT gmail.com>
Sent: April 16, 2018 12:27:28 AM
To: coq-club AT inria.fr
Subject: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.)Hello,
Do you have any idea why the following tactics fail?
Best,Qinxiang
Ltac foo_tac tac :=try tac.
Ltac TA1 :=match goal with| |- _ _ => idtacend.
Ltac TA2 :=match goal with| |- _ _ => idtac| |- _ => idtacend.
Goal True.foo_tac TA2. (* This succeed. *)foo_tac TA1. (* WHY fail? *)foo_tac destruct_one_ex. (* This succeed. *)
Ltac destruct_one_ex := (* copied from https://coq.inria.fr/library/Coq.Program.Tactics.html *)let tac H := let ph := fresh "H" in (destruct H as [H ph]) inlet tac2 H := let ph := fresh "H" in let ph' := fresh "H" in(destruct H as [H ph ph'])inlet tacT H := let ph := fresh "X" in (destruct H as [H ph]) inlet tacT2 H := let ph := fresh "X" in let ph' := fresh "X" in(destruct H as [H ph ph'])inmatch goal with| [H : (ex _) |- _] => tac H| [H : (sig ?P) |- _ ] => tac H| [H : (sigT ?P) |- _ ] => tacT H| [H : (ex2 _ _) |- _] => tac2 H| [H : (sig2 ?P _) |- _ ] => tac2 H| [H : (sigT2 ?P _) |- _ ] => tacT2 Hend.
foo_tac destruct_one_ex. (* WHY fail? *)
- [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Cao Qinxiang, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason -Zhong Sheng- Hu, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Cao Qinxiang, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason Gross, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason Gross, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason -Zhong Sheng- Hu, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason Gross, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason Gross, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Cao Qinxiang, 04/16/2018
- Re: [Coq-Club] Why this Ltac program fail? (Ltac program use another Ltac program as an argument.), Jason -Zhong Sheng- Hu, 04/16/2018
Archive powered by MHonArc 2.6.18.