]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/contribs/dama/dama/supremum.ma
bla bla bla
[helm.git] / helm / software / matita / contribs / dama / dama / supremum.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 "sequence.ma".
16 include "ordered_set.ma".
17
18 (* Definition 2.4 *)
19 definition upper_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.a n ≤ u.
20 definition lower_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.u ≤ a n.
21
22 definition supremum ≝
23   λO:ordered_set.λs:sequence O.λx.upper_bound ? s x ∧ (∀y:O.x ≰ y → ∃n.s n ≰ y).
24 definition infimum ≝
25   λO:ordered_set.λs:sequence O.λx.lower_bound ? s x ∧ (∀y:O.y ≰ x → ∃n.y ≰ s n).
26
27 definition increasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a n ≤ a (S n).
28 definition decreasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a (S n) ≤ a n.
29
30 notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 50 
31   for @{'upper_bound $s $x}.
32 notation < "x \nbsp 'is_lower_bound' \nbsp s" non associative with precedence 50 
33   for @{'lower_bound $s $x}.
34 notation < "s \nbsp 'is_increasing'" non associative with precedence 50 
35   for @{'increasing $s}.
36 notation < "s \nbsp 'is_decreasing'" non associative with precedence 50 
37   for @{'decreasing $s}.
38 notation < "x \nbsp 'is_supremum' \nbsp s" non associative with precedence 50 
39   for @{'supremum $s $x}.
40 notation < "x \nbsp 'is_infimum' \nbsp s" non associative with precedence 50 
41   for @{'infimum $s $x}.
42
43 notation > "x 'is_upper_bound' s" non associative with precedence 50 
44   for @{'upper_bound $s $x}.
45 notation > "x 'is_lower_bound' s" non associative with precedence 50 
46   for @{'lower_bound $s $x}.
47 notation > "s 'is_increasing'"    non associative with precedence 50 
48   for @{'increasing $s}.
49 notation > "s 'is_decreasing'"    non associative with precedence 50 
50   for @{'decreasing $s}.
51 notation > "x 'is_supremum' s"  non associative with precedence 50 
52   for @{'supremum $s $x}.
53 notation > "x 'is_infimum' s"  non associative with precedence 50 
54   for @{'infimum $s $x}.
55
56 interpretation "Ordered set upper bound" 'upper_bound s x = (upper_bound _ s x).
57 interpretation "Ordered set lower bound" 'lower_bound s x = (lower_bound _ s x).
58 interpretation "Ordered set increasing"  'increasing s    = (increasing _ s).
59 interpretation "Ordered set decreasing"  'decreasing s    = (decreasing _ s).
60 interpretation "Ordered set strong sup"  'supremum s x  = (supremum _ s x).
61 interpretation "Ordered set strong inf"  'infimum s x  = (infimum _ s x).
62   
63 include "bishop_set.ma".
64   
65 lemma uniq_supremum: 
66   ∀O:ordered_set.∀s:sequence O.∀t1,t2:O.
67     t1 is_supremum s → t2 is_supremum s → t1 ≈ t2.
68 intros (O s t1 t2 Ht1 Ht2); cases Ht1 (U1 H1); cases Ht2 (U2 H2); 
69 apply le_le_eq; intro X;
70 [1: cases (H1 ? X); apply (U2 w); assumption
71 |2: cases (H2 ? X); apply (U1 w); assumption]
72 qed.
73
74 (* Fact 2.5 *)
75 lemma supremum_is_upper_bound: 
76   ∀C:ordered_set.∀a:sequence C.∀u:C.
77    u is_supremum a → ∀v.v is_upper_bound a → u ≤ v.
78 intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
79 cases (H1 ? H) (w Hw); apply Hv; assumption;
80 qed.
81
82 lemma infimum_is_lower_bound: 
83   ∀C:ordered_set.∀a:sequence C.∀u:C.
84    u is_infimum a → ∀v.v is_lower_bound a → v ≤ u.
85 intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
86 cases (H1 ? H) (w Hw); apply Hv; assumption;
87 qed.
88
89
90 (* Lemma 2.6 *)
91 definition strictly_increasing ≝ 
92   λC:ordered_set.λa:sequence C.∀n:nat.a (S n) ≰ a n.
93 definition strictly_decreasing ≝ 
94   λC:ordered_set.λa:sequence C.∀n:nat.a n ≰ a (S n).
95
96  
97 notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 50 
98   for @{'strictly_increasing $s}.
99 notation > "s 'is_strictly_increasing'" non associative with precedence 50 
100   for @{'strictly_increasing $s}.
101 interpretation "Ordered set strict increasing"  'strictly_increasing s    = 
102   (strictly_increasing _ s).
103 notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 50 
104   for @{'strictly_decreasing $s}.
105 notation > "s 'is_strictly_decreasing'" non associative with precedence 50 
106   for @{'strictly_decreasing $s}.
107 interpretation "Ordered set strict decreasing"  'strictly_decreasing s    = 
108   (strictly_decreasing _ s).
109
110 definition uparrow ≝
111   λC:ordered_set.λs:sequence C.λu:C.
112    s is_increasing ∧ u is_supremum s.
113    
114 definition downarrow ≝
115   λC:ordered_set.λs:sequence C.λu:C.
116    s is_decreasing ∧ u is_infimum s.
117      
118 notation < "a \uparrow \nbsp u" non associative with precedence 50 for @{'sup_inc $a $u}.
119 notation > "a \uparrow u" non associative with precedence 50 for @{'sup_inc $a $u}.
120 interpretation "Ordered set uparrow" 'sup_inc s u = (uparrow _ s u).
121
122 notation < "a \downarrow \nbsp u" non associative with precedence 50 for @{'inf_dec $a $u}.
123 notation > "a \downarrow u" non associative with precedence 50 for @{'inf_dec $a $u}.
124 interpretation "Ordered set downarrow" 'inf_dec s u = (downarrow _ s u).
125
126 include "nat/plus.ma".
127 include "nat_ordered_set.ma".
128   
129 alias symbol "nleq" = "Ordered set excess".
130 alias symbol "leq" = "Ordered set less or equal than".
131 lemma trans_increasing: 
132   ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
133 intros 5 (C a Hs n m); elim m; [
134   rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
135   intro X; cases (os_coreflexive ?? X);]
136 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
137 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
138 |1: apply (le_transitive ???? (H ?) (Hs ?));
139     intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
140 qed.
141
142 lemma trans_decreasing: 
143   ∀C:ordered_set.∀a:sequence C.a is_decreasing → ∀n,m:nat_ordered_set. n ≤ m → a m ≤ a n.
144 intros 5 (C a Hs n m); elim m; [
145   rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
146   intro X; cases (os_coreflexive ?? X);]
147 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
148 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
149 |1: apply (le_transitive ???? (Hs ?) (H ?));
150     intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
151 qed.
152
153 lemma trans_increasing_exc: 
154   ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
155 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
156 intro; apply H; 
157 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *) 
158     change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
159     cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
160     cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)    
161 |2: cases (os_cotransitive ??? (a n1) H2); [assumption]
162     cases (Hs n1); assumption;]
163 qed.
164
165 lemma trans_decreasing_exc: 
166   ∀C:ordered_set.∀a:sequence C.a is_decreasing → ∀n,m:nat_ordered_set. m ≰ n → a m ≤ a n .
167 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
168 intro; apply H; 
169 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *) 
170     change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
171     cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
172     cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)    
173 |2: cases (os_cotransitive ??? (a n1) H2); [2:assumption]
174     cases (Hs n1); assumption;]
175 qed.
176
177 lemma strictly_increasing_reaches: 
178   ∀C:ordered_set.∀m:sequence nat_ordered_set.
179    m is_strictly_increasing → ∀w.∃t.m t ≰ w.
180 intros; elim w;
181 [1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
182     cases H1; [exists [apply O] apply H2;]
183     exists [apply (S O)] lapply (H O) as H3; rewrite < H2 in H3; assumption
184 |2: cases H1 (p Hp); cases (nat_discriminable (S n) (m p)); 
185     [1: cases H2; clear H2;
186         [1: exists [apply p]; assumption;
187         |2: exists [apply (S p)]; rewrite > H3; apply H;]
188     |2: cases (?:False); change in Hp with (n<m p);
189         apply (not_le_Sn_n (m p));
190         apply (transitive_le ??? H2 Hp);]]
191 qed.
192      
193 lemma selection_uparrow: 
194   ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
195     ∀a:sequence C.∀u.a ↑ u → (λx.a (m x)) ↑ u.
196 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split; 
197 [1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
198 |2: intro n; simplify; apply Uu;
199 |3: intros (y Hy); simplify; cases (Hu ? Hy);
200     cases (strictly_increasing_reaches C ? Hm w); 
201     exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]  
202     cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
203 qed.     
204
205 lemma selection_downarrow: 
206   ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
207     ∀a:sequence C.∀u.a ↓ u → (λx.a (m x)) ↓ u.
208 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split; 
209 [1: intro n; simplify; apply trans_decreasing_exc; [assumption] apply (Hm n);
210 |2: intro n; simplify; apply Uu;
211 |3: intros (y Hy); simplify; cases (Hu ? Hy);
212     cases (strictly_increasing_reaches C ? Hm w); 
213     exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [assumption]  
214     cases (trans_decreasing_exc C ? Ia ?? H1); assumption;]
215 qed.     
216
217 (* Definition 2.7 *)
218 alias id "ExT23" = "cic:/matita/dama/cprop_connectives/exT23.ind#xpointer(1/1)".
219 definition order_converge ≝
220   λO:ordered_set.λa:sequence O.λx:O.
221    ExT23 (sequence O) (λl.l ↑ x) (λu.u ↓ x)
222      (λl,u.∀i:nat. (l i) is_infimum (λw.a (w+i)) ∧ (u i) is_supremum (λw.a (w+i))).
223     
224 notation < "a \nbsp (\circ \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 50 
225   for @{'order_converge $a $x}.
226 notation > "a 'order_converges' x" non associative with precedence 50 
227   for @{'order_converge $a $x}.
228 interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).   
229     
230 (* Definition 2.8 *)
231
232 definition segment ≝ λO:ordered_set.λa,b:O.λx:O.
233   (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (x ≤ b) (a ≤ x)).
234
235 notation "[a,b]" non associative with precedence 50 
236   for @{'segment $a $b}.
237 interpretation "Ordered set sergment" 'segment a b = (segment _ a b).
238
239 notation "hvbox(x \in break [a,b])" non associative with precedence 50 
240   for @{'segment2 $a $b $x}.
241 interpretation "Ordered set sergment in" 'segment2 a b x= (segment _ a b x).
242
243 coinductive sigma (A:Type) (P:A→Prop) : Type ≝ sig_in : ∀x.P x → sigma A P.
244
245 definition pi1 : ∀A.∀P.sigma A P → A ≝ λA,P,s.match s with [sig_in x _ ⇒ x].  
246
247 interpretation "sigma pi1" 'pi1 x = (pi1 _ _ x).
248  
249 interpretation "Type exists" 'exists \eta.x =
250   (cic:/matita/dama/supremum/sigma.ind#xpointer(1/1) _ x).
251
252 lemma segment_ordered_set: 
253   ∀O:ordered_set.∀u,v:O.ordered_set.
254 intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
255 [1: intros (x y); apply (fst x ≰ fst y);
256 |2: intro x; cases x; simplify; apply os_coreflexive;
257 |3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
258 qed.
259
260 notation "hvbox({[a, break b]})" non associative with precedence 90 
261   for @{'segment_set $a $b}.
262 interpretation "Ordered set segment" 'segment_set a b = 
263  (segment_ordered_set _ a b).
264
265 (* Lemma 2.9 *)
266 lemma segment_preserves_supremum:
267   ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}. 
268     (λn.fst (a n)) is_increasing ∧ 
269     (fst x) is_supremum (λn.fst (a n)) → a ↑ x.
270 intros; split; cases H; clear H; 
271 [1: apply H1;
272 |2: cases H2; split; clear H2;
273     [1: apply H;
274     |2: clear H; intro y0; apply (H3 (fst y0));]]
275 qed.
276
277 lemma segment_preserves_infimum:
278   ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}. 
279     (λn.fst (a n)) is_decreasing ∧ 
280     (fst x) is_infimum (λn.fst (a n)) → a ↓ x.
281 intros; split; cases H; clear H; 
282 [1: apply H1;
283 |2: cases H2; split; clear H2;
284     [1: apply H;
285     |2: clear H; intro y0; apply (H3 (fst y0));]]
286 qed.
287
288
289 (* Definition 2.10 *)
290 coinductive pair (A,B:Type) : Type ≝ prod : ∀a:A.∀b:B.pair A B. 
291 definition first : ∀A.∀P.pair A P → A ≝ λA,P,s.match s with [prod x _ ⇒ x].
292 definition second : ∀A.∀P.pair A P → P ≝ λA,P,s.match s with [prod _ y ⇒ y].
293   
294 interpretation "pair pi1" 'pi1 x = (first _ _ x).
295 interpretation "pair pi2" 'pi2 x = (second _ _ x).
296
297 notation "hvbox(\langle a, break b\rangle)" non associative with precedence 91 for @{ 'pair $a $b}.
298 interpretation "pair" 'pair a b = (prod _ _ a b).
299  
300 notation "a \times b" left associative with precedence 60 for @{'prod $a $b}.
301 interpretation "prod" 'prod a b = (pair a b).
302  
303 lemma square_ordered_set: ordered_set → ordered_set.
304 intro O; apply (mk_ordered_set (O × O));
305 [1: intros (x y); apply (fst x ≰ fst y ∨ snd x ≰ snd y);
306 |2: intro x0; cases x0 (x y); clear x0; simplify; intro H;
307     cases H (X X); apply (os_coreflexive ?? X);
308 |3: intros 3 (x0 y0 z0); cases x0 (x1 x2); cases y0 (y1 y2) ; cases z0 (z1 z2); 
309     clear x0 y0 z0; simplify; intro H; cases H (H1 H1); clear H;
310     [1: cases (os_cotransitive ??? z1 H1); [left; left|right;left]assumption;
311     |2: cases (os_cotransitive ??? z2 H1); [left;right|right;right]assumption]]
312 qed.
313
314 notation < "s  2 \atop \nleq" non associative with precedence 90
315   for @{ 'square $s }.
316 notation > "s 'square'" non associative with precedence 90
317   for @{ 'square $s }.
318 interpretation "ordered set square" 'square s = (square_ordered_set s).
319  
320 definition square_segment ≝ 
321   λO:ordered_set.λa,b:O.λx:square_ordered_set O.
322   (cic:/matita/logic/connectives/And.ind#xpointer(1/1)
323    (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (fst x ≤ b) (a ≤ fst x))
324    (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (snd x ≤ b) (a ≤ snd x))).
325  
326 definition convex ≝
327   λO:ordered_set.λU:O square → Prop.
328   ∀p.U p → fst p ≤ snd p → ∀y. square_segment ? (fst p) (snd p) y → U y.
329   
330 (* Definition 2.11 *)  
331 definition upper_located ≝
332   λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x → 
333     (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
334
335 definition lower_located ≝
336   λO:ordered_set.λa:sequence O.∀x,y:O. x ≰ y → 
337     (∃i:nat.x ≰ a i) ∨ (∃b:O.b≰y ∧ ∀i:nat.b ≤ a i).
338
339 notation < "s \nbsp 'is_upper_located'" non associative with precedence 50 
340   for @{'upper_located $s}.
341 notation > "s 'is_upper_located'" non associative with precedence 50 
342   for @{'upper_located $s}.
343 interpretation "Ordered set upper locatedness" 'upper_located s    = 
344   (upper_located _ s).
345
346 notation < "s \nbsp 'is_lower_located'" non associative with precedence 50 
347   for @{'lower_located $s}.
348 notation > "s 'is_lower_located'" non associative with precedence 50 
349   for @{'lower_located $s}.
350 interpretation "Ordered set lower locatedness" 'lower_located s    = 
351   (lower_located _ s).
352     
353 (* Lemma 2.12 *)    
354 lemma uparrow_upperlocated:
355   ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → a is_upper_located.
356 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
357 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
358 [2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
359 |1: right; exists [apply u]; split; [apply W|apply H4]]
360 qed. 
361
362 lemma downarrow_lowerlocated:
363   ∀C:ordered_set.∀a:sequence C.∀u:C.a ↓ u → a is_lower_located.
364 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
365 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
366 [1: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
367 |2: right; exists [apply u]; split; [apply W|apply H4]]
368 qed.