Ltac checkForall H :=
let T := type of H in
match T with
| forall x, ?P x =>
idtac
| _ =>
fail 1 "not a forall"
end.
Example test : (forall x, x) -> True.
Proof.
intros H.
Fail checkForall H. (* not a forall *)
Abort.
我会天真地期待checkForall H
成功,但它不会。Ltac模式匹配:为什么`forall x,?P x`不匹配`forall x,x`?
在他的书中认证的程序与相关类型,亚当Chlipala discusses模式匹配的上依赖类型的限制:
的问题是,统一的变量可能不包含本地绑定变量。
这是我在这里看到的行为的原因?
我会补充说'?P x'代表一个[应用](https://coq.inria.fr/refman/Reference-Manual003.html#applications),而'x'是一个[标识符](https ://coq.inria.fr/refman/Reference-Manual003.html#qualid)。它们在语法上是不同的,不能统一。 –