]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/dama/dama/models/nat_dedekind_sigma_complete.ma
- notation fixed according to the new stricter semantics
[helm.git] / helm / software / matita / contribs / dama / dama / models / nat_dedekind_sigma_complete.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 "models/nat_uniform.ma".
16 include "supremum.ma".
17 include "nat/le_arith.ma".
18 include "russell_support.ma".
19
20 inductive cmp_cases (n,m:nat) : CProp ≝
21   | cmp_lt : n < m → cmp_cases n m
22   | cmp_eq : n = m → cmp_cases n m
23   | cmp_gt : m < n → cmp_cases n m.
24   
25 lemma cmp_nat: ∀n,m.cmp_cases n m.
26 intros; generalize in match (nat_compare_to_Prop n m);
27 cases (nat_compare n m); intros;
28 [constructor 1|constructor 2|constructor 3] assumption;
29 qed.
30
31 alias symbol "pi1" = "exT fst".
32 alias symbol "leq" = "natural 'less or equal to'".
33 lemma nat_dedekind_sigma_complete:
34   ∀l,u:ℕ.∀a:sequence {[l,u]}.a is_increasing → 
35     ∀x.x is_supremum a → ∃i.∀j.i ≤ j → fst x = fst (a j).
36 intros 5; cases x (s Hs); clear x; letin X ≝ (〈s,Hs〉); 
37 fold normalize X; intros; cases H1; 
38 letin spec ≝ (λi,j:ℕ.(u≤i ∧ s = fst (a j)) ∨ (i < u ∧ s+i ≤ u + fst (a j))); (* s - aj <= max 0 (u - i) *)  
39 letin m ≝ (hide ? (
40   let rec aux i ≝
41     match i with
42     [ O ⇒ O
43     | S m ⇒ 
44         let pred ≝ aux m in
45         let apred ≝ a pred in 
46         match cmp_nat (fst apred) s with
47         [ cmp_eq _ ⇒ pred
48         | cmp_gt nP ⇒ match ? in False return λ_.nat with []
49         | cmp_lt nP ⇒ fst (H3 apred nP)]]
50   in aux 
51    :
52    ∀i:nat.∃j:nat.spec i j));unfold spec in aux ⊢ %;
53 [1: apply (H2 pred nP);
54 |4: unfold X in H2; clear H4 n aux spec H3 H1 H X;
55     cases u in H2 Hs a ⊢ %; intros (a Hs H);
56     [1: left; split; [apply le_n]
57         generalize in match H;
58         generalize in match Hs;
59         rewrite > (?:s = O); 
60         [2: cases Hs; lapply (os_le_to_nat_le ?? H1);
61             apply (symmetric_eq nat O s ?).apply (le_n_O_to_eq s ?).apply (Hletin).
62         |1: intros; lapply (os_le_to_nat_le (fst (a O)) O (H2 O));
63             lapply (le_n_O_to_eq ? Hletin); assumption;]
64     |2: right; cases Hs; rewrite > (sym_plus s O); split; [apply le_S_S; apply le_O_n];
65         apply (trans_le ??? (os_le_to_nat_le ?? H1));
66         apply le_plus_n_r;] 
67 |2,3: clear H6;
68     cases (aux n1) in H5 ⊢ %; intros;
69     change in match (a 〈w,H5〉) in H6 ⊢ % with (a w);
70     cases H5; clear H5; cases H7; clear H7;
71     [1: left; split; [ apply (le_S ?? H5); | assumption]
72     |3: cases (?:False); rewrite < H8 in H6; apply (not_le_Sn_n ? H6);
73     |*: cut (u ≤ S n1 ∨ S n1 < u);
74         [2,4: cases (cmp_nat u (S n1));
75             [1,4: left; apply lt_to_le; assumption
76             |2,5: rewrite > H7; left; apply le_n
77             |3,6: right; assumption ]
78         |*: cases Hcut; clear Hcut
79             [1,3: left; split; [1,3: assumption |2: symmetry; assumption]
80                 cut (u = S n1); [2: apply le_to_le_to_eq; assumption ]
81                 clear H7 H5 H4;rewrite > Hcut in H8:(? ? (? % ?)); clear Hcut;
82                 cut (s = S (fst (a w)));
83                 [2: apply le_to_le_to_eq; [2: assumption]
84                     change in H8 with (s + n1 ≤ S (n1 + fst (a w)));
85                     rewrite > plus_n_Sm in H8; rewrite > sym_plus in H8;
86                     apply (le_plus_to_le ??? H8);]
87                 cases (H3 (a w) H6);
88                 change with (s = fst (a w1));
89                 change in H4 with (fst (a w) < fst (a w1));
90                 apply le_to_le_to_eq; [ rewrite > Hcut; assumption ]
91                 apply (os_le_to_nat_le (fst (a w1)) s (H2 w1));
92             |*: right; split; try assumption;
93                 [1: rewrite > sym_plus in ⊢ (? ? %);
94                     rewrite < H6; apply le_plus_r; assumption;
95                 |2: cases (H3 (a w) H6);
96                     change with (s + S n1 ≤ u + fst (a w1));rewrite < plus_n_Sm;
97                     apply (trans_le ??? (le_S_S ?? H8)); rewrite > plus_n_Sm;
98                     apply (le_plus ???? (le_n ?) H9);]]]]]
99 clearbody m; unfold spec in m; clear spec;
100 letin find ≝ (
101  let rec find i u on u : nat ≝
102   match u with
103   [ O ⇒ (m i:nat)
104   | S w ⇒ match eqb (fst (a (m i))) s with
105           [ true ⇒ (m i:nat)
106           | false ⇒ find (S i) w]]
107  in find
108  :
109   ∀i,bound.∃j.i + bound = u → s = fst (a j));
110 [1: cases (find (S n) n2); intro; change with (s = fst (a w));
111     apply H6; rewrite < H7; simplify; apply plus_n_Sm;
112 |2: intros; rewrite > (eqb_true_to_eq ?? H5); reflexivity
113 |3: intros; rewrite > sym_plus in H5; rewrite > H5; clear H5 H4 n n1;
114     cases (m u); cases H4; clear H4; cases H5; clear H5; [assumption]
115     cases (not_le_Sn_n ? H4)]
116 clearbody find; cases (find O u);
117 exists [apply w]; intros; change with (s = fst (a j));
118 rewrite > (H4 ?); [2: reflexivity]
119 apply le_to_le_to_eq;
120 [1: apply os_le_to_nat_le;
121     apply (trans_increasing ?? H ? ? (nat_le_to_os_le ?? H5));
122 |2: apply (trans_le ? s ?);[apply os_le_to_nat_le; apply (H2 j);]
123     rewrite < (H4 ?); [2: reflexivity] apply le_n;]
124 qed.
125
126 alias symbol "pi1" = "exT fst".
127 alias symbol "leq" = "natural 'less or equal to'".
128 axiom nat_dedekind_sigma_complete_r:
129   ∀l,u:ℕ.∀a:sequence {[l,u]}.a is_decreasing → 
130     ∀x.x is_infimum a → ∃i.∀j.i ≤ j → fst x = fst (a j).