coq - Coq 证明语言中的 `No more subgoals, but there are non-instantiated existential variables`?

标签 coq

我正在遵循 Coq 8.5p1 引用手册第 11 章中有关数学/声明性证明语言的(不完整)示例。在下面的迭代等式示例中( ~==~ ),我收到警告 Insufficient Justification用于重写4进入2+2 ,最终得到一个错误:

No more subgoals, but there are non-instantiated existential variables:

?Goal : [x : R H : x = 2 _eq0 : 4 = x * x |- 2 + 2 = 4]

You can use Grab Existential Variables.

示例:

Goal forall x, x = 2 -> x + x = x * x.
Proof. 
proof. Show.
let x:R. 
assume H: (x = 2). Show. 
have ( 4 = 4). Show.
~= (2*2). Show. 
~= (x*x) by H. Show.
=~ (2+2). Show. (*Problem Here: Insufficient Justification*)
=~ H':(x + x) by H.
thus thesis by H'.
end proof.
Fail Qed.

我不熟悉 Coq 中的数学证明语言,无法理解为什么会发生这种情况。有人可以帮助解释如何修复该错误吗?

--编辑-- @文兹

在示例之前我有这些随机导入:

Require Import Reals.
Require Import Fourier.

最佳答案

您的证明对于 natZ 有效,但对于 R 则失败。

来自 Coq Reference Manual (v8.5):

The purpose of a declarative proof language is to take the opposite approach where intermediate states are always given by the user, but the transitions of the system are automated as much as possible.

4 = 2 + 2 的自动化似乎失败了。我不知道哪种自动化使用声明性证明引擎,但是,例如,auto 策略无法证明几乎所有简单的等式,如下所示:

Open Scope R_scope.
Goal 2 + 2 = 4. auto. Fail Qed.

如@ejgallego points out我们只能偶然使用 auto 证明 2 * 2 = 4:

Open Scope R_scope.
Goal 2 * 2 = 4. auto. Qed.
(* `reflexivity.` would do here *)

但是,field 策略非常有效。因此,一种方法是建议使用 field 策略的声明性证明引擎:

Require Import Coq.Reals.Reals.
Open Scope R_scope.
Unset Printing Notations.  (* to better understand what we prove *)
Goal forall x, x = 2 -> x + x = x * x.
Proof.
  proof.
  let x : R. 
  assume H: (x = 2).
  have (4 = 4).
  ~= (x*x) by H.
  =~ (2+2) using field.  (* we're using the `field` tactic here *)
  =~ H':(x + x) by H.
  thus thesis by H'.
  end proof.
Qed.

关于coq - Coq 证明语言中的 `No more subgoals, but there are non-instantiated existential variables`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37936362/

相关文章:

recursion - Coq无法在Z上计算有据可依的函数,但可以在nat上运行

coq - Coq证明中如何加强归纳假设?

recursion - 归纳类型和 nat 上的相互递归

coq - 没有基数参数的类型不等式

coq - CoQ 中的有根据的诱导

coq - 在匹配 block 的分支内,如何使用匹配表达式等于分支的数据构造函数表达式的断言?

coq - 如何在假设中将具体变量更改为存在量化的变量?

equality - 证明 Coq 中 Martin-Lof 等式和路径归纳之间的同构

coq - 证明助手中的认证计算

coq - Coq 中的矛盾证明