获得coq中最小集合的函数

时间:2018-06-08 09:23:41

标签: coq

我们知道nat的每个子集都有一个最小数量。 我可以证明这样的事情:

Variable P : nat -> Prop.
Hypothesis H : (exists n : nat , P n).

Theorem well_ordering : exists m : nat , P m /\ forall x : nat , x<m -> ~ P x.

但我如何定义像min_point这样的函数?

Variable P : nat -> Prop.
Hypothesis H : (exists n : nat , P n).

Definition min_point : nat.

Theorem min_point_def : P min_point /\ forall x : nat , x<min_point -> ~ P x. 

2 个答案:

答案 0 :(得分:4)

Li-yao是正确的,因为可计算性问题通常不可能。但是,在命题P可判定的情况下,可以找到这个最小值。 Mathematical Components图书馆在ssrnat ex_minn中有证据证明这一事实; Require Import Omega. Section Minimum. Variable P : nat -> bool. Hypothesis exP : exists n, P n = true. Inductive acc_nat i : Prop := | AccNat0 : P i = true -> acc_nat i | AccNatS : acc_nat (S i) -> acc_nat i. Lemma find_ex_minn : {m | P m = true & forall n, P n = true -> n >= m}. Proof. assert (H1 : forall n, P n = true -> n >= 0). { intros n. omega. } assert (H2 : acc_nat 0). { destruct exP as [n Hn]. rewrite <- (Nat.add_0_r n) in Hn. revert Hn. generalize 0. induction n as [|n IHn]. - intros j Hj. now constructor. - intros j. rewrite Nat.add_succ_l, <- Nat.add_succ_r; right. now apply IHn. } revert H2 H1. generalize 0. fix find_ex_minn 2. intros m IHm m_lb. destruct (P m) eqn:Pm. - now exists m. - apply (find_ex_minn (S m)). + destruct IHm; trivial. now rewrite H in Pm. + intros n Pn. specialize (m_lb n Pn). assert (H : n >= S m \/ n = m) by omega. destruct H as [? | H]; trivial. congruence. Qed. Definition ex_minn := let (m, _, _) := find_ex_minn in m. Lemma ex_minnP : P ex_minn = true /\ forall n, P n = true -> n >= ex_minn. Proof. unfold ex_minn. destruct find_ex_minn as [m H1 H2]. auto. Qed. End Minimum. 我在纯Coq中包含了一个翻译,供参考。

val input:List[Item]=List(FRDVE,12
SDED,13
prog-d,11
PROG-D,15
a-prog-d,17)

答案 1 :(得分:2)

这是不可能的。如果我们可以定义min_point,那么我们可以通过将Q : Prop定义为P来确定任何属性P n := if n = 0 then Q else True,并将H保留为n := 1。然后我们得到Q的证明,当且仅当min_point = 0时,我们得到~Q