1

I was going through software foundations and got the example:

repeat (try (left; reflexivity); right).

and was confused what this meant. For example do we get:

try [ (left; reflexivity); right ]

or

[try (left; reflexivity);] right

second or first?


in particular I was trying to understand:

Theorem In10 : In 10 [1;2;3;4;5;6;7;8;9;10].
Proof.
  repeat (try (left; reflexivity); right).
Qed.
user4035
  • 22,508
  • 11
  • 59
  • 94
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
  • what is the best way to find out what left/right tactics mean? I saw the official docs but didn't make sense... – Charlie Parker Dec 13 '18 at 00:02
  • Re "I saw the official docs but didn't make sense" If there's a particular part of it that is confusing or nonsensical, please open an issue on github (https://github.com/coq/coq/issues/new) with specific requests for clearer documentation – Jason Gross Feb 16 '19 at 21:16

1 Answers1

3

A good way of solving those problems on your own is to use tactics like idtac (always succeeds) and fail (always fails) to disambiguate:

try (idtac; idtac); fail.     (* FAILS *)
try ((idtac; idtac); fail).   (* SUCCEEDS *)
(try (idtac; idtac)); fail.   (* FAILS *)

So indeed, the application of try binds tighter than the semicolon:

try (idtac; idtac); fail.   is the same as   (try (idtac; idtac)); fail.
Ptival
  • 9,167
  • 36
  • 53
  • sorry I am new to coq, how do I search what `idtac` is/does? – Charlie Parker Dec 12 '18 at 23:55
  • does it bind tighter because its left associative in general? this was helpful for this particular example, but how do I know this in general? – Charlie Parker Dec 12 '18 at 23:57
  • If I'm not mistaken, the semicolon operator for tactics is associative, so `((a ; b); c)` is the same as `a ; (b ; c)`, and parentheses are unnecessary. However, your initial question had less to do with associativity, and more to do with the precedence of the `;` operator v.s. the ` ` operator. Whitespace binds tighter, so that `a b c ; d e f ; g h i` always means `(a b c) ; (d e f) ; (g h i)`. – Ptival Dec 13 '18 at 04:30
  • @Ptival Whitespace does not always bind tighter. See for example https://github.com/coq/coq/issues/5441 and also the `now` tactical. See also https://github.com/coq/coq/issues/9447 – Jason Gross Feb 16 '19 at 21:14
  • @Pinocchio You can see the grammar for the tactic language at https://coq.inria.fr/refman/proof-engine/ltac.html . You can see what `idtac` does at https://coq.inria.fr/refman/proof-engine/ltac.html#coq:tacn.idtac – Jason Gross Feb 16 '19 at 21:15