Coq nat中从不等于到等于的转换
我有一个函数,它的输出是一些自然数。我证明了一个引理,这个函数的输出不能为零。这意味着输出等于某个自然数SM。我想转换上面的引理Coq nat中从不等于到等于的转换,coq,Coq,我有一个函数,它的输出是一些自然数。我证明了一个引理,这个函数的输出不能为零。这意味着输出等于某个自然数SM。我想转换上面的引理 Theorem greater:forall (m :nat)(l:list nat), m=?0=false -> 0=? (f1 + m)=false-> (f1 + m)= S m. 您输入的对账单未进行类型检查。不管怎样,我看不出它是如何成立的——例如,如果l是指f1:nat,那么该语句将暗示3=2 证明不为零的事物是后继事物的方法如下:
Theorem greater:forall (m :nat)(l:list nat),
m=?0=false ->
0=? (f1 + m)=false->
(f1 + m)= S m.
您输入的对账单未进行类型检查。不管怎样,我看不出它是如何成立的——例如,如果l是指f1:nat,那么该语句将暗示3=2 证明不为零的事物是后继事物的方法如下:
Require Import Coq.Arith.Arith.
Lemma not_zero_succ :
forall n, n <> 0 ->
exists m, n = S m.
Proof. destruct n as [|n]; eauto; easy. Qed.
编辑您在下面编写的完整语句也是矛盾的:
Require Import Coq.Arith.Arith.
Require Import Coq.Lists.List.
Import ListNotations.
Fixpoint lt_numb (n: nat) (l: list nat) : nat :=
match l with
| nil => 0
| h::tl =>
if h <? n then S (lt_numb n tl) else lt_numb n tl
end.
Fixpoint greatest (large: nat) (l: list nat) : nat :=
match large with
| O => 0
| S m' => (lt_numb large l) + (greatest m' l)
end.
Definition change (n: nat) (l: list nat) : list nat :=
match l with
| nil => l
| h::tl => if n <? h then l else n::tl
end.
Fixpoint g_value (elements: nat) (l: list nat) : nat :=
match l with
| nil => 0
| [n] => n
| h :: l =>
match elements with
| O => h
| S elements' => g_value elements' (change h l)
end
end.
Theorem no_elements : forall (m n z :nat)(l:list nat),
m=?0=false -> greatest(g_value (length (n :: l)) (n :: l) + m) (n :: l) = (S z).
Proof. Admitted.
Goal False.
pose proof (no_elements 1 0 1 [] eq_refl).
simpl in H.
discriminate.
Qed.
@我很抱歉,我仍然无法理解你想做什么。你能写一个我可以直接在Coq中运行的自我包含的、更正的更大的声明,并把它放在原始问题中吗?我无法运行m_greater or greater_f2,因为您没有包含f1或f2的定义。@rosijavi change_greater or greater_元素的定义很有用,但它们仍然不够:我无法将它们与您在上面写的有关f1和m的解释联系起来。您需要编辑原始问题,并包含诊断问题的所有相关代码。应该可以从您的问题中复制代码,将其粘贴到Coq文件中并运行,直到遇到问题为止。@rosijavi感谢您的更新。不幸的是,你在那里写的声明是矛盾的。我用一个反例更新了答案。在上述函数的帮助下,我证明了以下两个引理,但在证明中遇到了问题。还是可以证明?定理g_值_len1:对于所有n a:natl:list nat,g_值长度a::l更改n a::l
Require Import Coq.Arith.Arith.
Require Import Coq.Lists.List.
Import ListNotations.
Fixpoint lt_numb (n: nat) (l: list nat) : nat :=
match l with
| nil => 0
| h::tl =>
if h <? n then S (lt_numb n tl) else lt_numb n tl
end.
Fixpoint greatest (large: nat) (l: list nat) : nat :=
match large with
| O => 0
| S m' => (lt_numb large l) + (greatest m' l)
end.
Definition change (n: nat) (l: list nat) : list nat :=
match l with
| nil => l
| h::tl => if n <? h then l else n::tl
end.
Fixpoint g_value (elements: nat) (l: list nat) : nat :=
match l with
| nil => 0
| [n] => n
| h :: l =>
match elements with
| O => h
| S elements' => g_value elements' (change h l)
end
end.
Theorem no_elements : forall (m n z :nat)(l:list nat),
m=?0=false -> greatest(g_value (length (n :: l)) (n :: l) + m) (n :: l) = (S z).
Proof. Admitted.
Goal False.
pose proof (no_elements 1 0 1 [] eq_refl).
simpl in H.
discriminate.
Qed.