通过证明" forall n:nat,(n< = 0) - > COQ错误了。 n = 0时"

时间:2015-01-07 21:15:01

标签: coq

有人可以向我解释以下 - 显然是错误的 - COQ推导?

Theorem test: forall n:nat,  ( n <= 0) -> n=0.  
intros n H.  
elim H.  
auto.  

COQ回答:

1 subgoal  
n : nat  
H : n <= 0 

=================  
forall m : nat, n <= m -> n = m -> n = S m

3 个答案:

答案 0 :(得分:2)

le<=)有两个构造函数。在n <= 0中,两者(某种程度上)可以适用:

Inductive le (n : nat) : nat -> Prop :=
    le_n : n <= n
  | le_S : forall m : nat, n <= m -> n <= S m
您的证明中的

auto解决了第一个目标/案例。第二个是无法证实的。你应该在n上进行归纳以证明这个定理:

Theorem test: forall n, n <= 0 -> n = 0.
intros n H.
induction n.
reflexivity.
inversion H. Qed.

或者你可以使用inversion H策略(不是elim):

Theorem test: forall n, n <= 0 -> n = 0.
intros n H.
inversion H.
auto. Qed.

答案 1 :(得分:1)

在谓词上使用归纳时,通常需要确保谓词的参数是变量而不是术语。你可以通过添加一些方程式来实现。您通常还需要确保这些变量是不同的,并且在谓词之前没有任何不必要的假设或量词。

Goal forall n1, n1 <= 0 -> n1 = 0.

assert (H1 : forall n1 n2, n1 <= n2 -> n2 = 0 -> n1 = 0).
induction 1 as [| n2 H1 H2].
intros H1.
eapply H1.
intros H3.
discriminate.

intros n1 H2.
eapply H1.
eapply H2.
eapply eq_refl.
Qed.

答案 2 :(得分:0)

反过来说:你原来的目标并不意味着无法实现的目标;它是暗示原始目标的无法证明的目标。

目标

A : B
_____
C

等同于后续

A : B |- C.

当在Coq中以交互方式证明某些内容时,您正在从下到上构建一个后续树。这是一个例子。

   -------------------- apply H
   P : Prop, H : P |- P
   -------------------- intro H
    P : Prop |- P -> P
-------------------------- intro P
|- forall P : Prop, P -> P

当然,当向后移动到证据时,你可能会做出错误的举动。

            ?
      ------------- ?
      P : Prop |- P
   -------------------- clear H
   P : Prop, H : P |- P
   -------------------- intro H
    P : Prop |- P -> P
-------------------------- intro P
|- forall P : Prop, P -> P

您可以从互联网上了解更多有关后续计算的信息。

相关问题