Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Unexpected behavior passing Ltac to tactics

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Unexpected behavior passing Ltac to tactics


Chronological Thread 
  • From: "Grant Jurgensen" <grant AT jurgensen.dev>
  • To: coq-club AT inria.fr
  • Subject: [Coq-Club] Unexpected behavior passing Ltac to tactics
  • Date: Mon, 09 Aug 2021 13:35:30 -0500
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=grant AT jurgensen.dev; spf=Pass smtp.mailfrom=grant AT jurgensen.dev; spf=Pass smtp.helo=postmaster AT wout1-smtp.messagingengine.com
  • Ironport-hdrordr: A9a23:vEGwm6z07ZtfUFMkLc4KKrPw8r1zdoMgy1knxilNoH1uA7elfqWV8ZgmPHDP+VEssR0b6La90de7MBfhHO9OkOws1N6ZNWGM0guVxepZnPPfKlPbalTDH6JmpMVdWpk7LPG1NEN9nNaS2miFOudl5PXCybuvlPeb5X9wVw0CUc9dxjY8LireKEFwSQVcbKBXKHPl3Lslmwad
  • Ironport-phdr: A9a23:t/NqyRd0eky/c2g+LeZLYVCwlGM+c97LVj580XLHo4xHfqnrxZn+JkuXvawr0AWRG9qEoKMUw8Pt8InYEVQa5piAtH1QOLdtbDQizfssogo7HcSeAlf6JvO5JwYzHcBFSUM3tyrjaRsdF8nxfUDdrWOv5jAOBBr/KRB1JuPoEYLOksi7ze+/94PPbwlShjewY7x+IRG1oA7MqsQYnIxuJ7orxBDUuHVIYeNWxW1pJVKXgRnx49q78YBg/SpNpf8v7tZMXqrmcas2S7xYFykmPHsu5ML3rxnDTBCA6WUaX24LjxdHGQnF7BX9Xpfsriv3s/d21SeGMcHqS70/RDKv5LppRhD1kicKLzk3/2/YhcJzgqxVoAyvqQFjzIPPeo6ZKOBzc7nHcN4AWWZMWNtaWSxbAoO7aosCF+QNM+dCr4bnoVsOsQa1Cw2xBOP1xT9HmHn23bYk3OQnHw3NwQstH90UsHvOqtX1KLwfUeKozKnSwjXMcfVW2Szj54jOaBwuvO+DXaxpfMfX1EIgGB/LgE+Kpoz5IzOayP4Ns26D4ud8Se+iiGwqpx1vrzWrx8ohjorEi4YUx1zZ9Sh0zok7KMG4RUN0btCpEJtdujyEOoZyXM4sTH9ktSQ1xLMJpJO2ejUBxpc/xxPHavGKfJKE7g/sWeuTOzt0mWxpdbylixqs/kWtzPD3W9ew0FZXtSpFjsfDtmoQ2RzS68mIVONw8lun1D2SzQ7c8PtELloxlafDK54u3Lowlp0LvEXNGS/2hVn2gLKPekU//+io9/znbq/jppCCLI90kRvxMqsvmsy5DuQ3LA4OX2ea+eS6yrLv51H2QLJPjvEuk6nZto7VJdgDq6O4DAJZyJsv5hm9Aju8zdgUg3cKIEhbdB+Il4TpPkvBIPH8DfexmVSslzJryujJPr37GJrNKGTDnazjfbZg8U5cxxQ8zdZE551KDLENOu/8VVHvtNDAFB82LxS0w/r7CNV6zo4RRWWPAraAPKzOtV+I+/kgLvKXZI4VvTb9M+Iq6+TvjX8/g18dfLOm0YEZaHCiTbxaJBCSZmOpidMcG08LuBA/Rarkkg6sSzlWMjydRas6+nkZFZipAIHYS4bnyOiOxi69ArVUe3pJB1aXHHGue4iaDaRfIBmOK9Nsx2RXHYOqTJUsgEnGXO7S1L16MrOR4SgErdTm2cNu7uLSkx4/8zN1Ccnb2GaIHTgcdowgRSIs0615ukF7jFuOz/oh6xS9Pd5O/fxEVBw3M9jQwvIoU7jP

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



Archive powered by MHonArc 2.6.19+.

Top of Page