【发布时间】:2020-05-14 03:04:48
【问题描述】:
我正在研究编程语言基础,但对这一行感到困惑:
"存在变量不能 用包含普通变量的术语实例化 在存在变量创建时存在。 "
为什么不呢?我可以举一个表现出不良行为的例子吗?
谢谢。
【问题讨论】:
标签: coq
我正在研究编程语言基础,但对这一行感到困惑:
"存在变量不能 用包含普通变量的术语实例化 在存在变量创建时存在。 "
为什么不呢?我可以举一个表现出不良行为的例子吗?
谢谢。
【问题讨论】:
标签: coq
这是一个说明性示例:
(* An empty type *)
Inductive empty : Type := .
(* A proposition quantifying existentially over an empty type can only be false... *)
Lemma this_cannot_be_true : exists x : empty, (forall y : empty, x = y).
Proof.
eexists. (* I'm telling you there is such an x, just put an evar ?x for now. *)
intros y. (* Now we must prove a universal property, so we introduce a new variable... *)
Fail instantiate (1 := y). (* Oh look, y : empty, let's instantiate our evar with it! *)
(* If this didn't fail, we would have the goal (y = y), which would be proved by reflexivity. Luckily, the previous tactic failed. *)
Abort.
(* To clear out any doubt that the above proposition is false. *)
Lemma empty_type_is_empty {P : empty -> Prop} : (exists x : empty, P x) -> False.
Proof.
intros [[]].
Qed.
【讨论】:
intros y 之后,证明项看起来像this_cannot_be_true := ex_intro _ _ ?X (fun y => ?Goal)。 instantiate 正在尝试设置 X := y,而下面的 reflexivity 会留下 ex_intro _ _ y (fun y => eq_refl y)。这被拒绝了,因为您试图在绑定/定义的上下文之外使用y(在fun y 下)。