coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Samuel Gruetter <gruetter AT mit.edu>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: [Coq-Club] Obtaining the term matched by "context"
- Date: Mon, 13 Nov 2017 15:10:52 +0000
- Accept-language: en-US
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gruetter AT mit.edu; spf=Pass smtp.mailfrom=gruetter AT mit.edu; spf=None smtp.helo=postmaster AT dmz-mailsec-scanner-3.mit.edu
- Ironport-phdr: 9a23:Ft3/VBxpUsc068vXCy+O+j09IxM/srCxBDY+r6Qd0u0RIJqq85mqBkHD//Il1AaPBtqLra8cw8Pt8IneGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2NBXupSj45jkLXx77KABdJ+LvG4eUgd79n7S5/ISWaAFVjhK8Z6lzJVO4t1OCmNMRhN5ZI6Msxx+BjWFVdvhKyHkgcV2Jghvg+sqq1Jti72Jdt+93pJ0IarnzY6ltFe8QNz8hKW1gvMA=
Dear coq-club,
I have two questions about Ltac's match with "context".
I often write code like this:
Goal forall a b c, a + (1 + b) = c -> (1 + a) + b = c.
intros.
repeat match goal with
| _: context [1 + ?x] |- _ => change (1 + x) with (S x) in *
| |- context [1 + ?x] => change (1 + x) with (S x) in *
end.
Abort.
There are two things I'd like to improve, but don't know how to do it:
1) I write the same line twice, once for matching in the hypotheses, once
for matching in the goal. Can this be unified?
2) On the right-hand side of "=>", I have to repeat the term (1 + x), just
without the question marks. This is bad because it's code duplication,
and it gets even worse if the term contains implicit arguments: It
happens often to me that the implicit arguments inferred on the right-
hand side of "=>" don't match the original ones, so that "change" does
nothing. Therefore, I wonder if there's a way to refer to the
"term matched inside context"?
(I'm aware that I can write "context C[1 + ?x]", but C gives me the
context *around* the term, i.e. everything *except* what I want)
Thanks in advance,
Sam
- [Coq-Club] Obtaining the term matched by "context", Samuel Gruetter, 11/13/2017
- Re: [Coq-Club] Obtaining the term matched by "context", Pierre Courtieu, 11/13/2017
- Re: [Coq-Club] Obtaining the term matched by "context", Samuel Gruetter, 11/14/2017
- Re: [Coq-Club] Obtaining the term matched by "context", Pierre Courtieu, 11/13/2017
Archive powered by MHonArc 2.6.18.