Last active
October 20, 2019 18:00
-
-
Save Blaisorblade/b22dc557018e6ee8c048df9cec206f1b to your computer and use it in GitHub Desktop.
Using ssreflect fancy `rewrite` `r_pattern` conflicts with Ltac (found on #coq)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* Based on example from | |
| https://coq.github.io/doc/V8.10.0/refman/proof-engine/ssreflect-proof-language.html#contextual-patterns-in-rewrite *) | |
| (* Find `Fail` to see the error *) | |
| From Coq Require Import ssreflect. | |
| Notation "n .+1" := (Datatypes.S n) (at level 2, left associativity, | |
| format "n .+1") : nat_scope. | |
| Axiom addSn : forall m n, m.+1 + n = (m + n).+1. | |
| (* addSn is declared *) | |
| Axiom addn0 : forall m, m + 0 = m. | |
| (* addn0 is declared *) | |
| Axiom addnC : forall m n, m + n = n + m. | |
| (* addnC is declared *) | |
| Lemma test x y z f : (x.+1 + y) + f (x.+1 + y) (z + (x + y).+1) = 0. | |
| (* 1 subgoal | |
| x, y, z : nat | |
| f : nat -> nat -> nat | |
| ============================ | |
| x.+1 + y + f (x.+1 + y) (z + (x + y).+1) = 0 *) | |
| rewrite [in f _ _]addSn. | |
| (* 1 subgoal | |
| x, y, z : nat | |
| f : nat -> nat -> nat | |
| ============================ | |
| x.+1 + y + f (x + y).+1 (z + (x + y).+1) = 0 *) | |
| rewrite addSn. | |
| (* The bug. This works: *) | |
| rewrite -[ER in (_ = ER)]addn0. | |
| Undo. | |
| (* So let's lift it into a tactic! But we can't: *) | |
| Fail Ltac foo := rewrite -[ER in (_ = ER)]addn0. | |
| (* The command has indeed failed with message: | |
| The reference ER was not found in the current environment. *) | |
| (* We need a hack. Note the extra parens! *) | |
| Ltac foo := rewrite -[(ER in (_ = ER))]addn0. | |
| foo. | |
| Abort. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment