coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gregory Malecha <gregory AT bedrocksystems.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Question about rewrite: feature or bug?
- Date: Sun, 18 Aug 2019 21:13:26 -0400
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gregory AT bedrocksystems.com; spf=None smtp.mailfrom=gregory AT bedrocksystems.com; spf=None smtp.helo=postmaster AT mail-pg1-f182.google.com
- Ironport-phdr: 9a23:JGg9LRKoJ1mEX+CwAdmcpTZWNBhigK39O0sv0rFitYgRL/zxwZ3uMQTl6Ol3ixeRBMOHsqgC0rGG+Py6EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCejbb9oMRm7owbcusYZjId8N6081gbHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhSEaPDA77W7XkNR9g61VoB2jpxJxzY3abpyLOvViZa7SZ88WSHBbU8pNSyBMAIWxZJYPAeobOuZYqpHwqVoUrRSgCgmsA/nvyz9VjXHxx6I61/ouHh3G3AM6AtkDt3vUrM/rO6cdVuC11qnJwC7YYPxIxDj98o/IfQwiofGXXbNwatbRxlcqFwPelFmftYvlPzaM2+kLrmOV7PJgWPqxh2I7rwx9uDuiy8c2hoXXm44YykrI+Th6zYorI9CzVVR1bsS+EJRKsiGXL4t2Td0mQ2FvoCs6z6cJuZ+/fCQT0JQnyAPTZ+WJc4SV4R/vSvydITh/hHJid7K/gwi9/VK8xe37U8m4yFdKrixbndnQrn0ByQDf58ydRvZ+/kqtwyiD2x3T5+1ePEw5lrTXJ4YkwrEql5oTtUrDHjXxmEXzlKKWeV8k9fan6+TgeLXnpoSROJRqhQ7jKKQundCwAecjMgkORGib5fqz1Lj4/UHjXLpKifg2nrHDsJ/GPcQburK5AwhN34k/7Ba/Fi6q38gcnXkaN11IYwmHjojsO1HWOv/0F/a/g1K2kDdq3f/KJLPhAo+eZkTExbzmZPN271NW4As119FWoZxOWZ8bJ/emdVX8u9vCH1ccOgi5yObuQIFyzI4RXnieKqWUPLnVulyT9/kzLuyXIoQSvWCueLAe+/fygCphyhcmdq6z0M5PMSHqLrFdO0ycJEHUrJIEGGYOsBA5Sbay2lePXSRUbHWpTrkg6zQgTomhCNWbH9z/sPm6xC6+W6ZuSCVeEFnWSSXieomeXPwPczOJPsJkiXoPUr3zE9Z8hyHrjxfzzv9cFsSR+iAcssi9ht185umWjR5rsDItX57b3GaKQGV52GgPQm1u0Q==
Hello --
My intuition, which may be incorrect, about rewrite at is that it performs unification to find possible rewrites and replaces them. If you don't have an "at", then it rewrites all occurences of the *first* match. If you say, "at" then it will only rewrite one occurence and it will pick the occurance by skipping the first n-1 matches (though the numbers can seem quite arbitrary).
While I haven't used it, I believe that ssreflect has a much nicer mechanism for picking particular instantiations based on what is matched rather than by position number, and I believe that this matches has been integrated into Coq-proper at this point, so I would suggest using it.
On Thu, Aug 15, 2019 at 1:26 PM David Holland <dholland-coq AT netbsd.org> wrote:
On Sun, Aug 11, 2019 at 11:38:35AM +0800, Cao Qinxiang wrote:
> Dear Coq clubbers,
>
> I find that the behavior of "rewrite ... at ..." is quite strange. I am
> wondering whether it is actually a feature or a bug. Here is a tiny example.
>
> [...]
I don't know officially, but, as strange as that behavior seems, I
think it's at least mostly what's intended. The understanding I have,
which may be incomplete, is that the idea of "at N" is to pick which
of several matches in the target term you want to operate on...
*after* the matches have been found by instantiating binders and so
on. So you can't use "at N" to tell it whether to operate on x or y or
z.
In your setting, one gets
Goal forall x y, foo x y y.
intros.
rewrite <- app_nil_l with (l := y). (* foo x (nil ++ y) (nil ++ y) *)
rewrite <- app_nil_l with (l := y) at 1. (* foo x (nil ++ y) y *)
rewrite <- app_nil_l with (l := y) at 2. (* foo x y (nil ++ y) *)
and my understanding is that this is the control that "at N" is
supposed to give.
However, I apparently don't have the full picture because one also gets
rewrite <- (@app_nil_l (list _)) at 1. (* foo x (nil ++ y) y *)
rewrite <- (@app_nil_l (list _)) at 2. (* foo x y (nil ++ y) *)
rewrite <- (@app_nil_l (list _)). (* foo x y (nil ++ y) *)
I guess this matching works differently? Maybe someone else can shed
further light.
--
David A. Holland
dholland AT netbsd.org
--
- [Coq-Club] Question about rewrite: feature or bug?, Cao Qinxiang, 08/11/2019
- Re: [Coq-Club] Question about rewrite: feature or bug?, David Holland, 08/15/2019
- Re: [Coq-Club] Question about rewrite: feature or bug?, Gregory Malecha, 08/19/2019
- Re: [Coq-Club] Question about rewrite: feature or bug?, David Holland, 08/15/2019
Archive powered by MHonArc 2.6.18.