COQ证明“错误”;对于所有n:nat,(n<;=0)->;n=0“;
有人能给我解释一下以下明显错误的COQ推导吗COQ证明“错误”;对于所有n:nat,(n<;=0)->;n=0“;,coq,Coq,有人能给我解释一下以下明显错误的COQ推导吗 Theorem test: forall n:nat, ( n <= 0) -> n=0. intros n H. elim H. auto. 定理测试:forall n:nat,(n=0。 介绍n H。 艾琳H。 自动的。 问题解答: 1子目标 n:纳特 H:n=SM le(相反:你最初的目标并不意味着不可实现的目标;不可实现的目标意味着最初的目标 目标 A : B _____ C 相当于序列 A : B |-
Theorem test: forall n:nat, ( n <= 0) -> n=0.
intros n H.
elim H.
auto.
定理测试:forall n:nat,(n=0。
介绍n H。
艾琳H。
自动的。
问题解答:
1子目标
n:纳特
H:n=SM
le
(相反:你最初的目标并不意味着不可实现的目标;不可实现的目标意味着最初的目标
目标
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
你可以从互联网上了解更多关于序列演算的知识。在谓词上使用归纳法时,你通常需要确保谓词的参数是变量而不是术语。你可以通过添加一些等式来做到这一点。你通常还需要确保这些变量是不同的,并且没有任何不必要的形合谓语前的形容词或量词
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.
所有n1的目标,n1=0。
断言(H1:forall n1 n2,n1 n2=0->n1=0)。
诱导1为[| n2 H1 H2]。
介绍H1。
EAPPLYH1。
简介H3。
区别对待
简介n1h2。
EAPPLYH1。
EAPPLYH2。
eapply eq_refl。
Qed。
我仍然不理解COQs推导这个无法验证的子目标背后的逻辑。elim
是一个非常基本的策略。它忘记了在H
假设0中,“错”是什么意思?这里没有错。Coq没有弄错,你弄错了。
A : B |- C.
-------------------- 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
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.