coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Adam Chlipala <adamc AT csail.mit.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] How do you do conditional rewriting?
- Date: Mon, 21 Sep 2015 09:04:27 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=adamc AT csail.mit.edu; spf=Pass smtp.mailfrom=adamc AT csail.mit.edu; spf=None smtp.helo=postmaster AT outgoing.csail.mit.edu
- Ironport-phdr: 9a23:g+mcExfXSS4qPAVr598pA1zjlGMj4u6mDksu8pMizoh2WeGdxc6+YB7h7PlgxGXEQZ/co6odzbGG7+a5BSQp2tWojjMrSNR0TRgLiMEbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpQAbFhi3DwdpPOO9QteU1JTrkbnus7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cYjdt6qJUFCfmyP/lgDO8QMDNzOGcsocbvqBPrTA2V53JaXH9FvABPBl3s4Bj/Frzxtiriv+50kH2TMcTzRpg/Qj2j6+FuSQOuhSsaYW1quFrLg9B92foI6CmqoAZyltOMbQ==
Have you tried [rewrite LEMMA by LTAC]? Admittedly it doesn't work quite the way I'd like, missing some rewrite opportunities, but it also only succeeds if the lemma side conditions are proved by [LTAC].
On 09/21/2015 09:02 AM, Hugo Carvalho wrote:
Club,
I'm interested in rewriting conditionally. That is, to use the rewrite tactic only if some condition applies. For example, say we have some way of testing two numbers and will only apply the commutativity of addition if the test goes through. Right now, my tactic looks like this:
Ltac condrewrite :=
match goal with
| [ |- context[(plus ?a ?b)] ] =>
let extravars := (*Some extra computation, such as reflecting a and b into ASTs*) in
let cmp := (eval compute in (*Test goes here, depends on extravars*) ) in
match cmp with
| Gt => rewrite -> (plus_comm a b)
| _ => fail
end
end.
As you might imagine, this is fairly unwieldy. Notice the "context[(plus ?a ?b)]"; i'm replicating, within a ltac match, something i know the rewrite tactic is perfectly capable of doing by itself.
Is there any way of doing this in a cleaner way?
- [Coq-Club] How do you do conditional rewriting?, Hugo Carvalho, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Adam Chlipala, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Hugo Carvalho, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Adam Chlipala, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Hugo Carvalho, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Adam Chlipala, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Hugo Carvalho, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Ilya Sergey, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Jonathan Leivent, 09/21/2015
- Re: [Coq-Club] How do you do conditional rewriting?, Adam Chlipala, 09/21/2015
Archive powered by MHonArc 2.6.18.