coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Jason Gross <jasongross9 AT gmail.com>
- To: coq-club <coq-club AT inria.fr>
- Cc: Eddy Westbrook <westbrook AT galois.com>
- Subject: Re: [Coq-Club] Finding a pattern-matching fix in a term?
- Date: Mon, 1 Jun 2020 17:24:35 -0400
- 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-ej1-f46.google.com
- Ironport-phdr: 9a23:RUGyNRDNyOqqdORRKljiUyQJP3N1i/DPJgcQr6AfoPdwSPT+p8bcNUDSrc9gkEXOFd2Cra4d1qyP6P2rADFZqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba5yIRmssAncuMkbjYR/Jqsx1xfCv2dFdflRyW50P1yYggzy5t23/J5t8iRQv+wu+stdWqjkfKo2UKJVAi0+P286+MPkux/DTRCS5nQHSWUZjgBIAwne4x7kWJr6rzb3ufB82CmeOs32UKw0VDG/5KplVBPklCEKPCMi/WrJlsJ/kr5UoBO5pxx+3YHUZp2VNOFjda/ZZN8WWHZNUtpUWyFHH4iybZYAD/AZMOlXoYnypVsAoxW9CwexGu3g1iRFiWXq0aAgyektDR3K0Q4mEtkTsHrUttL1NKIKXO6x1qbI1jLDb/VL0jn88ojIdQshoeqRVr93c8re01IvFwTDjlWfs4zlOCiV1v8JvmWA4OpgUPigi28jqw1rvjevwcIsh5DPi4kIxV/K6T93z5wpJd2kVkF7e9ikHYNSuiyYK4Z7Q8wvTmNptSsm1rAKpJ62cSwOxZkk2RPRZP6KfYaV7x/gUOudPzd2iWxldr+/mhq//1Wsx+zgWsS71ltBsylLksHUu3wTyxDe7tKLR/h980u7xzqDygPe5vtLLE01k6fQNoQvzaQqlpUJtETOBi/2l1vyjK+Rbkgk//Kn6+XjYrn/uJCcNZJ4hhjwMqkhm8GzG+s4Mg8JX2iU/eSzyqfv8lH+QLVPlvE2k6/Zv47GJckDuKK1HwtY3pwg5hu/FTuqzskUkHodIF9KeR+Ll43pNEvPIPD8A/e/mVOskDJzyvDEJLLhGZLNLn7MkLf7erZ98FVcxQ4owNBQ4pJbELABIPbpVkDts9zYCwc1MxaozOb/FNV9yoQeVHqTDa+eKaPeqEOH5uYyI+aXf4IVozb8K/095/H0l3M5mFkdfbOo3ZQNcny4EO5mcA2lZi/nhc5EGmMXtEJqR+vzzVaGTDR7ZnCoXqt66CttW6y8CoKWZIm2h7rJ8z28BYYeMmJPEVeKHm3vbJ7Vc/gJYSOWZMRml2pXBvCaV4Y92ET250fBwL19I7+Ro3VA7MOx5J1O/+TW0CoK23lxBsWZ3XuKSjgtzGwNTj4ymqt4pB4kkwrR4e1Dm/VdUOdrybZJXwM9b8OOyuV7D5X/WFuEcIvXDlmhRdqiDHc6Sddjm4ZSMXY4IM2ri1X45wTvG6UczuXZC5k986aa1H/0dZ5w
Note that the following works in Coq 8.11:
Goal forall x y, x + y = y + x.
unfold "+".
intros.
lazymatch goal with
| [ |- context[fix f (a : ?A) (b : ?B) {struct a} : ?C := _] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := _] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := match a with _ => _ end] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := match a with O => @?O_case a b | S n => _ end] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := match a with O => @?O_case f a b | S n => @?S_case f a b n end] ] => idtac
end.
unfold "+".
intros.
lazymatch goal with
| [ |- context[fix f (a : ?A) (b : ?B) {struct a} : ?C := _] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := _] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := match a with _ => _ end] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := match a with O => @?O_case a b | S n => _ end] ] => idtac
end.
lazymatch goal with
| [ |- context[fix f a b {struct a} := match a with O => @?O_case f a b | S n => @?S_case f a b n end] ] => idtac
end.
Note that the struct annotation is mandatory, and so you need separate cases for different numbers of arguments and different recursive arguments.
On Mon, Jun 1, 2020 at 3:44 PM Gregory Malecha <gregory AT bedrocksystems.com> wrote:
It is late, but you can do this in template-coq simply by quoting the term and writing a function to check what you want. It wouldn't be truly gorgeous, but it doesn't require anything that is unsafe. Note that what template-coq gives you is a Gallina inductive type that reifies a Gallina term, so inspecting a term is *literally* just Coq pattern matching. That said, this is definitely not unification, so if you want "definitionally equal to" rather than "syntactically equal to you are currently out of luck with template-coq.On Mon, May 18, 2020 at 5:40 AM Pierre-Marie Pédrot <pierre-marie.pedrot AT inria.fr> wrote:Hi,
On 16/05/2020 03:17, Eddy Westbrook wrote:
> Is there any way to pattern-match on a fix + match term like (fix foo
> (x1:A1) … := match xi with … ) in a term? I am trying to write some
> tactics to determine if a particular argument is being destructed in
> a term, in order to apply the destruct or induction tactic on it, but
> it seems that Ltac at least won’t let me search for fix terms…?
if you're using Coq >= 8.11, it is possible to do this in Ltac2, albeit
in a way deemed "unsafe". Once done, you can also wrap the resulting
Ltac2 tactic into a proper Ltac1 tactic, so that it is transparent for
the end-user. Look at the Ltac2.Constr.Unsafe module for more details.
PMP
--Gregory Malecha
Mail: gregory AT bedrocksystems.com
BedRock
Systems Inc
FORMALLY SECURED COMPUTING
UNBREAKABLE FOUNDATION FOR
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Gregory Malecha, 06/01/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/01/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/01/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Eddy Westbrook, 06/03/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/03/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/03/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/03/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Eddy Westbrook, 06/03/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/01/2020
- Re: [Coq-Club] Finding a pattern-matching fix in a term?, Jason Gross, 06/01/2020
Archive powered by MHonArc 2.6.19+.