有了以下定义,我想证明引理 without_P
Variable n : nat.
Definition mnnat := {m : nat | m < n}.
Variable f : mnnat -> nat.
Lemma without_P : (exists x : mnnat, True) -> (exists x, forall y, f x <= f y).
Run Code Online (Sandbox Code Playgroud)
引理without_P
意味着:如果你知道(有限)集合mnnat
不是空的,那么mnnat
在映射f
到之后必须存在一个元素,即所有元素中最小的元素mnnat
.
我们知道mnnat
是有限的,因为它有n-1
数字,并且在证据的背景下,without_P
我们也知道mnnat
不是空的,因为前提(exists x : mnnat, True)
.
现在mnnat
非空和有限的"自然/直觉"具有一些最小元素(在应用f
其所有元素之后).
目前我被困在下面的那个地方,我想在那里进行归纳n
,这是不允许的.
1 subgoal
n : nat
f : mnnat -> nat
x : nat
H' : x < n
______________________________________(1/1)
exists (y : nat) (H0 : y < n),
forall (y0 : nat) (H1 : y0 < n),
f (exist (fun m : nat => m < n) y H0) <= f (exist (fun m : nat => m < n) y0 H1)
Run Code Online (Sandbox Code Playgroud)
我唯一的想法是断言这样一个函数的存在f' : nat -> nat
:exists (f' : nat -> nat), forall (x : nat) (H0: x < n), f' (exist (fun m : nat => m < n) x H0) = f x
在解决了这个断言后,我已经通过归纳证明了这个引理n
.我怎样才能证明这个断言?
有没有办法证明"非空的,有限集合(在应用于f
每个元素之后)具有最小"更直接?我现在的路径对于我的Coq技能来说似乎太难了.
我通过用引理(exists (f' : nat -> nat), forall (x : nat) (H0: x < n), f (exist (fun m : nat => m < n) x H0) = f' x).
证明类似的断言找到了我的断言的证据。接下来的第一个断言几乎是微不足道的。
在我证明了这个断言之后,我可以向用户 larsr 做一个类似的证明,以证明 Lemma 。 (exists (f' : nat -> nat), forall x : mnnat, f x = f' (proj1_sig x)).
f'exists
without_P
除了 的基本情况之外,我使用mod
-Function 将 any 转换nat
为nat
更小的 then 。n
n = 0
Lemma mod_mnnat : forall m,
n > 0 -> m mod n < n.
Proof.
intros.
apply PeanoNat.Nat.mod_upper_bound.
intuition.
Qed.
Lemma mod_mnnat' : forall m,
m < n -> m mod n = m.
Proof.
intros.
apply PeanoNat.Nat.mod_small.
auto.
Qed.
Lemma f_proj1_sig : forall x y,
proj1_sig x = proj1_sig y -> f x = f y.
Proof.
intros.
rewrite (sig_eta x).
rewrite (sig_eta y).
destruct x. destruct y as [y H0].
simpl in *.
subst.
assert (l = H0).
apply proof_irrelevance. (* This was tricky to find.
It means two proofs of the same thing are equal themselves.
This makes (exist a b c) (exist a b d) equal,
if c and d prove the same thing. *)
subst.
intuition.
Qed.
(* Main Lemma *)
Lemma f'exists :
exists (ff : nat -> nat), forall x : mnnat, f x = ff (proj1_sig x).
Proof.
assert (n = 0 \/ n > 0).
induction n.
auto.
intuition.
destruct H.
exists (fun m : nat => m).
intuition. destruct x. assert (l' := l). rewrite H in l'. inversion l'.
unfold mnnat in *.
(* I am using the mod-function to map (m : nat) -> {m | m < n} *)
exists (fun m : nat => f (exist (ltn n) (m mod n) (mod_mnnat m H))).
intros.
destruct x.
simpl.
unfold ltn.
assert (l' := l).
apply mod_mnnat' in l'.
assert (proj1_sig (exist (fun m : nat => m < n) x l) = proj1_sig (exist (fun m : nat => m < n) (x mod n) (mod_mnnat x H))).
simpl. rewrite l'.
auto.
apply f_proj1_sig in H0.
auto.
Qed.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
165 次 |
最近记录: |