我正在研究编程语言基础,对此感到困惑:
“现有变量不能为 用包含普通变量但不包含普通变量的术语实例化 存在变量创建时已存在。 “
为什么不呢?我能举个例子,表现出不想要的行为吗?
谢谢。
答案 0 :(得分:2)
这是一个说明性示例:
(* 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.