Coq 包含局部绑定变量的Ltac统一变量
的Ltac章节显示了一种“错误”策略: 这本书接着解释道Coq 包含局部绑定变量的Ltac统一变量,coq,coq-tactic,Coq,Coq Tactic,的Ltac章节显示了一种“错误”策略: 这本书接着解释道 The problem is that unification variables may not contain locally bound variables. In this case, [?P] would need to be bound to [x = x], which contains the local quantified variable [x]. By using a wildcard in the earlie
The problem is that unification variables may not contain locally bound variables.
In this case, [?P] would need to be bound to [x = x], which contains the local quantified
variable [x]. By using a wildcard in the earlier version, we avoided this restriction.
然而,上述策略实际上在COQ8.11中有效
统一变量现在可以包含局部绑定变量吗?如果是的话,上述与实际情况有什么区别吗
Theorem t1' : forall x : nat, x = x.
match goal with
| [ |- forall x, _ ] => trivial
end.
(我们将
?p
替换为\u
)?与\u
之间的区别在于,您实际上可以在分支中引用p
。不幸的是,P
是一个开放的术语,因此它可能很快就会以格式错误而告终,因此您对此无能为力。所以,我不会依赖它。最好将用于所有x,@?px
作为一个模式,这样P
是一个封闭的术语。与
\uu
之间的区别在于,您实际上可以在分支中引用P
。不幸的是,P
是一个开放的术语,因此它可能很快就会以格式错误而告终,因此您对此无能为力。所以,我不会依赖它。最好使用作为模式,以便P
是一个封闭术语。本书稍后提供了更多信息:
Actually, the behavior demonstrated here applies to Coq version 8.4,
but not 8.4pl1. The latter version will allow regular Ltac pattern
variables to match terms that contain locally bound variables, but a
tactic failure occurs if that variable is later used as a Gallina term.
这意味着
Ltac dummy :=
match goal with
| [ H: forall x, ?P |- _ ] => assert True
end.
Lemma foo (a x : nat) :
(forall n, n = 42) ->
True.
Proof.
intros.
dummy.
可以应用dummy
策略(因为我们匹配?p
,但以后不参考它),但是如果我们将dummy
更改为
Ltac dummy :=
match goal with
| [ H: forall x, ?P |- _ ] => assert ?P
end.
那么这将失败,因为我们所指的是?p
,这可能是一个开放的术语 本书稍后将提供更多信息:
Actually, the behavior demonstrated here applies to Coq version 8.4,
but not 8.4pl1. The latter version will allow regular Ltac pattern
variables to match terms that contain locally bound variables, but a
tactic failure occurs if that variable is later used as a Gallina term.
这意味着
Ltac dummy :=
match goal with
| [ H: forall x, ?P |- _ ] => assert True
end.
Lemma foo (a x : nat) :
(forall n, n = 42) ->
True.
Proof.
intros.
dummy.
可以应用dummy
策略(因为我们匹配?p
,但以后不参考它),但是如果我们将dummy
更改为
Ltac dummy :=
match goal with
| [ H: forall x, ?P |- _ ] => assert ?P
end.
那么这将失败,因为我们所指的是?p
,这可能是一个开放的术语