- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 setoid_replace
时遇到了一个奇怪的情况,其中的证明步骤如下:
setoid_replace (a - c + d) with b by my_tactic
因错误:没有匹配目标的匹配子句
而失败,但是在将额外的idtac
附加到策略之后:
setoid_replace (a - c + d) with b by (my_tactic; idtac)
证明成功。我对 idtac
的理解是它本质上是一个空操作。为什么 idtac
的存在在这里有所不同?
这是完整的代码。我通过 Proof General 使用 Coq 8.4pl6。
Require Import QArith.
Open Scope Q.
Lemma rearrange_eq_r a b c d :
a == b -> b + d == a + c -> c == d.
Proof.
intro a_eq_b; rewrite a_eq_b; symmetry; now apply Qplus_inj_l with (z := b).
Qed.
Ltac rearrange :=
match goal with
| [ H : _ == _ |- _ == _ ] => apply rearrange_eq_r with (1 := H); ring
end.
Lemma test_rearrange a b c d e (H0 : e < b) (H1 : b + c == a + d) : e < a - c + d.
Proof.
(* Why is the extra 'idtac' required in the line below? *)
setoid_replace (a - c + d) with b by (rearrange; idtac).
assumption.
Qed.
注意:正如 Matt 所观察到的,idtac
在这里似乎并不特别:似乎任何策略(包括 fail
!)都可以用来代替 idtac
使证明成功。
最佳答案
感谢 Coq 错误跟踪器上的 Jason Gross 对此进行了解释。这与 Ltac 策略语言中的求值顺序有关。在失败的情况下,rearrange
中的匹配应用于直接目标中的不等式,而不是 setoid_replace
生成的等式。这是 Jason 对错误报告的回应:
This is because the [match] is evaluated before the [setoid_replace] is run. It is one of the unfortunate trip-ups of Ltac that things like [match] and [let ... in ...] are evaluated eagerly until a statement with semicolons, or other non-match non-let-in statement is reached. If you add [idtac; ] before the [match] in [rearrange], your problem will go away.
关于coq - 为什么使用 Coq 的 setoid_replace "by"子句需要额外的 idtac?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31279517/
我在使用 setoid_replace 时遇到了一个奇怪的情况,其中的证明步骤如下: setoid_replace (a - c + d) with b by my_tactic 因错误:没有匹配目标
我是一名优秀的程序员,十分优秀!