1

I have the following Ltac (from here), which used to work on Coq 8.4pl6, but it's not working on Coq 8.5 beta 3:

Ltac maybe_intro_sym A B :=
  match goal with
    |[H:B=A|-_] => fail 1
    |[H:A=B|-_] => assert (B=A) by auto
  end.

Ltac maybe_intro_sym_neg A B :=
  match goal with
    |[H:B<>A|-_] => fail 1
    |[H:A<>B|-_] => assert (B<>A) by auto
  end.

Ltac intro_sym :=
  repeat match goal with
    |[H:?A=?B|-_] => maybe_intro_sym A B
    |[H:?A<>?B|-_] => maybe_intro_sym_neg A B
end.

I got an error message saying

Error: The reference B was not found
in the current environment.

I don't know enough about Ltac. Can anyone help explain how to fix this?

Community
  • 1
  • 1
thor
  • 21,418
  • 31
  • 87
  • 173
  • There is no problem for me. Which of the three Ltac definitions sends this error ? – eponier Dec 02 '15 at 13:32
  • @eponier It's the last one `intro_sym`. – thor Dec 02 '15 at 13:48
  • Are you sure that it's not something stupid such as an unbreakable space after one of the `B` ? – eponier Dec 02 '15 at 16:24
  • Yes, it seems strange that it shouldn't work.... Have you copied and pasted it from the page? Or could there be a missing '?' before the B in the pattern? (The pattern is what's before the '=>') (Note that only intro_sym should have question marks, as it should match any _ = _ term, but the others shouldn't, as they should only match the specific term with the given A and B) – larsr Dec 02 '15 at 20:47
  • I have copy-and-pasted the above into a library file `SfLib.v` from described and available from https://www.cis.upenn.edu/~bcpierce/sf/current/SfLib.html to be included in other `.v` files. This worked on Coq 8.4pl6 without a problem, but gave me the quoted error when 8.5beta3 is used. I am not sure if it could be a conflict with content in that file, but otherwise things are copy-pasted without missing a white space. – thor Dec 02 '15 at 22:53
  • Ok, I have found what the problem is. `SfLib.v` requires `Arith`, and `Arith` defines the notation `=?` which is used here. Just add a space between `=` and `?B` and it will work. – eponier Dec 03 '15 at 08:22
  • @eponier, thanks, if you make that an answer, I will accept it. – thor Dec 03 '15 at 13:52

1 Answers1

2

In Coq 8.5, Arith defines the notation =?. Because of this, what was interpreted as = ?B is now interpreted as =? B. Adding a space between = and ?B should be enough.

eponier
  • 3,062
  • 9
  • 20