coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Gaëtan Gilbert <gaetan.gilbert AT skyskimmer.net>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Unexpected behavior passing Ltac to tactics
- Date: Mon, 16 Aug 2021 10:28:18 +0200
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gaetan.gilbert AT skyskimmer.net; spf=Pass smtp.mailfrom=gaetan.gilbert AT skyskimmer.net; spf=None smtp.helo=postmaster AT relay12.mail.gandi.net
- Ironport-hdrordr: A9a23:bL+R/6msOWP+Ib2q6uj+0zS0q17pDfJL3DAbv31ZSRFFG/Fw8PrOoB1773HJYVkqKRIdcLy7Scu9qBDnmqKdn7NwAV7KZmCP0wGVxepZgbcKrQeMJxHD
- Ironport-phdr: A9a23:pgZY5hUUqDmhLHI7dMN2NzeNEqrV8Kw8VTF92vMcY1JmTK2v8tzYMVDF4r011RmVB92duqoP0rOH+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxtUiDanZb5+MBq6oRjMusQSnIBvNrs/xhzVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNXs15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRTiv6bpgRRn1gykFKjE56nnahNFugqJVoByvpBJxzIDbb46XKPVwcbjQfc8ZSGdbQspdSyJMD4G6YoASD+QBJ+FYr4zlqlUPtxS5GRWsC/npyjBQh3H23Kk63P8/HgHcwAwrAtUDsHvOo9rrKKcdS+a1wLPHzTXCa/NZwiny6JLUch06uvGMXrJxcdHSyUkuEgPFi0ufqZb/MzOTyOsNr3GW4ux9Xu2gl2ApsRt+oiSzxsgykInJgJoYxFDA+Chk3oo4ONK2RU14bNK5EZZcqyWXOoRqT84tR2xluzg3xLIFtJOlciYHyYkqyhHdZvKId4WE/wzuWeWeLzp+mXlre6q/ig6s/US9yODwTMu53EpQoiZYkNTBtWoB2wLd58SZTPZ2412v1iyV1w/J7+FJOUA0mrTfK54m2rMwjIQcsUDZES72hUn6krWadkA+9eip7+TreLrmqYWaN4BpiwHyKKIuldKjAeggMwgOWXaU+fik2bH94EH0Qq9Gg/8qnqXDrZzXJ8cWqrSnDwJbzIov8xO/AC2n0NQck3kHNlVFeBefgojmIV7BPuz4Au25g1i2nzdrxvTGMab/DZXXMnjOi6zhfbV96k5HywozzNVf55dKBbEbOv7zXFH+tMDAAh8jLwO02/rnCMl61o4GRW2PBbaZPLrOvl+M++IgOPKBZJQVuTb4M/gq/eTijX4/mV8HfKmmx4EbaH6iHqcuH0LMan31x9wFDG0ivwwkTeWshkfRfyRUYiOdViEg7zcMJ4OiB4rZWsj5j7WMwC69WJJXYmpLEEykCnT5bIaFXvIBcmSUL9M3wW9MbqSoV4J0jULmjwT90bcydoI8HwUDtoP419lw4uDJ0xc/6W4sZyx8+3uAS2hlxzlOQjY32OZwqEpxyxGF3LQq25Sw+vRI5OJSUQY/MJPGiep3F4KrMj8=
Indeed ltac delays argument evaluation some of the time. This is one of the
less well understood part of ltac.
If you dislike this, other languages such as ltac2 exist.
Gaëtan Gilbert
On 09/08/2021 20:35, Grant Jurgensen wrote:
Hi all,
I have been having trouble with higher-order Ltac and hoping someone here
might be able to illuminate the issue or point me in the right direction. I
have repeatedly run into unexpected behavior when passing Ltac to another
tactic. My best guess is that I am misunderstanding when Ltac arguments are
evaluated.
Here is an example:
```
Ltac hyp_eq H H' :=
match H with
| H' => idtac
end.
Ltac revert_all_but H :=
repeat (match goal with
| H': _ |- _ =>
assert_fails (hyp_eq H H');
revert H'
end).
Ltac revert_all_but2 H :=
repeat (match goal with
| H': _ |- _ =>
assert_fails (idtac; hyp_eq H H');
revert H'
end).
Goal forall n m, n + m = m + n.
Proof.
intros *.
(* This one does nothing *)
Fail progress revert_all_but m.
(* This one acts as expected *)
revert_all_but2 m.
Abort.
```
In this snippet, `revert_all_but H` is expected to revert all hypotheses
except `H`. However, the real behavior is that it does nothing. The alternate
tactic `revert_all_but2` adds an `idtac` statement to the Ltac passed to
`assert_fails`, and somehow this manages to fix the problem.
I would have expected the two definitions to be equivalent, and I'm unsure
why adding the `idtac` statement changes its behavior. My best guess is that
in the original definition, the Ltac is executed before the function call in
a call-by-value style, whereas in the second, it is essentially being called
by name. Is this true? If so, why is some Ltac executed immediately, and some
not?
Thanks,
Grant Jurgensen
- [Coq-Club] Unexpected behavior passing Ltac to tactics, Grant Jurgensen, 08/09/2021
- Re: [Coq-Club] Unexpected behavior passing Ltac to tactics, Gaëtan Gilbert, 08/16/2021
Archive powered by MHonArc 2.6.19+.