Coq将不存在转换为forall语句
我是Coq的新手。这是我的问题。 我有一份声明说:Coq将不存在转换为forall语句,coq,forall,Coq,Forall,我是Coq的新手。这是我的问题。 我有一份声明说: H : forall x : term, ~ (exists y : term, P x y /\ ~ P y x) 我想这相当于: forall x y : term, (P x y /\ ~ P y x) -> false 但是,我可以使用哪种策略来转换该假设?您可以使用在H中展开非1~P只是非P的符号,根据定义非P=(P->False)。第1部分的意味着你只想展开第一次出现的不,而第H部分的意味着你只想展开假设H我不知道有什么策
H : forall x : term, ~ (exists y : term, P x y /\ ~ P y x)
我想这相当于:
forall x y : term, (P x y /\ ~ P y x) -> false
但是,我可以使用哪种策略来转换该假设?您可以使用
在H中展开非1
~P
只是非P
的符号,根据定义非P=(P->False)
。第1部分的意味着你只想展开第一次出现的不,而第H部分的意味着你只想展开假设H
我不知道有什么策略可以把不存在变成不存在,但你总是可以断言它并证明它。(如果你反复需要它,你可以把它打包成一个或一个简单的定理[1]。)
这里有三种方法来证明这一点。(您应该能够将此成绩单复制/粘贴到CoqIDE或Emacs/ProofGeneral中,并逐步完成代码。)
[1] 库中存在一个引理not_exu_all_not
,但加载将引入经典逻辑的公理(这里甚至不需要)
(*
这是一个长版本,有一些解释:*)
(*
您也可以在一条语句中完成:*)
(*
像这样简单的东西也可以手工编写:*)
(*
现在您有了正确类型的H;可以选择摆脱旧的H:*)
实际上,您可以使用coq的库来直接证明它。只需使用Coq要求导出初始逻辑的
(* dummy context to set up H of the correct type, for testing it out *)
Lemma SomeName (term : Type) (P : term -> term -> Prop) :
(forall x : term, ~ (exists (y : term), P x y /\ ~ P y x)) ->
True. (* dummy goal *)
Proof.
intro H.
(* end dummy context *)
(* this states the goal, result will be put into the context as H' *)
assert (forall (x y : term), (P x y /\ ~ P y x) -> False) as H'.
(* get rid of unneeded variables in context, get new args *)
clear - H; intros x y Pxy.
(* unfolding the not shows the computational structure of this *)
unfold not at 1 in H.
(* yay... (x, y, Pxy) will produce False via H *)
(* specialize to x and apply... *)
apply (H x).
(* ...and provide the witness. *)
exists y. exact Pxy.
(* done. *)
(* let's do it again... *)
clear H'.
assert (forall x y, (P x y /\ ~ P y x) -> False) as H'
by (clear -H; intros x y Pxy; apply (H x (ex_intro _ y Pxy))).
(* and again... *)
clear H'.
pose proof (fun x y Pxy => H x (ex_intro _ y Pxy)) as H'; simpl in H'.
clear H; rename H' into H.