]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/dama/dama/nat_ordered_set.ma
more work on supremum
[helm.git] / helm / software / matita / contribs / dama / dama / nat_ordered_set.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ordered_set.ma".
16
17 include "nat/compare.ma".
18 include "cprop_connectives.ma".
19
20 definition nat_excess : nat → nat → CProp ≝ λn,m. m<n.
21
22 lemma nat_elim2: 
23   ∀R:nat → nat → CProp.
24   (∀ n:nat. R O n) → (∀n:nat. R (S n) O) → (∀n,m:nat. R n m → R (S n) (S m)) →
25     ∀n,m:nat. R n m.
26 intros 5;elim n; [apply H]
27 cases m;[ apply H1| apply H2; apply H3 ]
28 qed.
29
30 lemma nat_discriminable: ∀x,y:nat.x < y ∨ x = y ∨ y < x.
31 intros (x y); apply (nat_elim2 ???? x y); 
32 [1: intro;left;cases n; [right;reflexivity] left; apply lt_O_S;
33 |2: intro;right;apply lt_O_S;
34 |3: intros; cases H; 
35     [1: cases H1; [left; left; apply le_S_S; assumption]
36         left;right;rewrite > H2; reflexivity;
37     |2: right;apply le_S_S; assumption]]
38 qed.
39         
40 lemma nat_excess_cotransitive: cotransitive ? nat_excess.
41 intros 3 (x y z); unfold nat_excess; simplify; intros;
42 cases (nat_discriminable x z); [2: left; assumption] cases H1; clear H1;
43 [1: right; apply (trans_lt ??? H H2);
44 |2: right; rewrite < H2; assumption;]
45 qed.
46   
47 lemma nat_ordered_set : ordered_set.
48 apply (mk_ordered_set ? nat_excess);
49 [1: intro x; intro; apply (not_le_Sn_n ? H);
50 |2: apply nat_excess_cotransitive]
51 qed.