1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "sequence.ma".
16 include "ordered_set.ma".
17 include "datatypes/constructors.ma".
20 definition upper_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.a n ≤ u.
21 definition lower_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.u ≤ a n.
24 λO:ordered_set.λs:sequence O.λx.upper_bound ? s x ∧ (∀y:O.x ≰ y → ∃n.s n ≰ y).
26 λO:ordered_set.λs:sequence O.λx.lower_bound ? s x ∧ (∀y:O.y ≰ x → ∃n.y ≰ s n).
28 definition increasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a n ≤ a (S n).
29 definition decreasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a (S n) ≤ a n.
31 notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 50
32 for @{'upper_bound $s $x}.
33 notation < "x \nbsp 'is_lower_bound' \nbsp s" non associative with precedence 50
34 for @{'lower_bound $s $x}.
35 notation < "s \nbsp 'is_increasing'" non associative with precedence 50
36 for @{'increasing $s}.
37 notation < "s \nbsp 'is_decreasing'" non associative with precedence 50
38 for @{'decreasing $s}.
39 notation < "x \nbsp 'is_supremum' \nbsp s" non associative with precedence 50
40 for @{'supremum $s $x}.
41 notation < "x \nbsp 'is_infimum' \nbsp s" non associative with precedence 50
42 for @{'infimum $s $x}.
44 notation > "x 'is_upper_bound' s" non associative with precedence 50
45 for @{'upper_bound $s $x}.
46 notation > "x 'is_lower_bound' s" non associative with precedence 50
47 for @{'lower_bound $s $x}.
48 notation > "s 'is_increasing'" non associative with precedence 50
49 for @{'increasing $s}.
50 notation > "s 'is_decreasing'" non associative with precedence 50
51 for @{'decreasing $s}.
52 notation > "x 'is_supremum' s" non associative with precedence 50
53 for @{'supremum $s $x}.
54 notation > "x 'is_infimum' s" non associative with precedence 50
55 for @{'infimum $s $x}.
57 interpretation "Ordered set upper bound" 'upper_bound s x = (upper_bound _ s x).
58 interpretation "Ordered set lower bound" 'lower_bound s x = (lower_bound _ s x).
59 interpretation "Ordered set increasing" 'increasing s = (increasing _ s).
60 interpretation "Ordered set decreasing" 'decreasing s = (decreasing _ s).
61 interpretation "Ordered set strong sup" 'supremum s x = (supremum _ s x).
62 interpretation "Ordered set strong inf" 'infimum s x = (infimum _ s x).
64 include "bishop_set.ma".
67 ∀O:ordered_set.∀s:sequence O.∀t1,t2:O.
68 t1 is_supremum s → t2 is_supremum s → t1 ≈ t2.
69 intros (O s t1 t2 Ht1 Ht2); cases Ht1 (U1 H1); cases Ht2 (U2 H2);
70 apply le_le_eq; intro X;
71 [1: cases (H1 ? X); apply (U2 w); assumption
72 |2: cases (H2 ? X); apply (U1 w); assumption]
76 lemma supremum_is_upper_bound:
77 ∀C:ordered_set.∀a:sequence C.∀u:C.
78 u is_supremum a → ∀v.v is_upper_bound a → u ≤ v.
79 intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
80 cases (H1 ? H) (w Hw); apply Hv; assumption;
83 lemma infimum_is_lower_bound:
84 ∀C:ordered_set.∀a:sequence C.∀u:C.
85 u is_infimum a → ∀v.v is_lower_bound a → v ≤ u.
86 intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
87 cases (H1 ? H) (w Hw); apply Hv; assumption;
92 definition strictly_increasing ≝
93 λC:ordered_set.λa:sequence C.∀n:nat.a (S n) ≰ a n.
94 definition strictly_decreasing ≝
95 λC:ordered_set.λa:sequence C.∀n:nat.a n ≰ a (S n).
98 notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 50
99 for @{'strictly_increasing $s}.
100 notation > "s 'is_strictly_increasing'" non associative with precedence 50
101 for @{'strictly_increasing $s}.
102 interpretation "Ordered set strict increasing" 'strictly_increasing s =
103 (strictly_increasing _ s).
104 notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 50
105 for @{'strictly_decreasing $s}.
106 notation > "s 'is_strictly_decreasing'" non associative with precedence 50
107 for @{'strictly_decreasing $s}.
108 interpretation "Ordered set strict decreasing" 'strictly_decreasing s =
109 (strictly_decreasing _ s).
112 λC:ordered_set.λs:sequence C.λu:C.
113 s is_increasing ∧ u is_supremum s.
115 definition downarrow ≝
116 λC:ordered_set.λs:sequence C.λu:C.
117 s is_decreasing ∧ u is_infimum s.
119 notation < "a \uparrow \nbsp u" non associative with precedence 50 for @{'sup_inc $a $u}.
120 notation > "a \uparrow u" non associative with precedence 50 for @{'sup_inc $a $u}.
121 interpretation "Ordered set uparrow" 'sup_inc s u = (uparrow _ s u).
123 notation < "a \downarrow \nbsp u" non associative with precedence 50 for @{'inf_dec $a $u}.
124 notation > "a \downarrow u" non associative with precedence 50 for @{'inf_dec $a $u}.
125 interpretation "Ordered set downarrow" 'inf_dec s u = (downarrow _ s u).
127 include "nat/plus.ma".
128 include "nat_ordered_set.ma".
130 alias symbol "nleq" = "Ordered set excess".
131 alias symbol "leq" = "Ordered set less or equal than".
132 lemma trans_increasing:
133 ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
134 intros 5 (C a Hs n m); elim m; [
135 rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
136 intro X; cases (os_coreflexive ?? X);]
137 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
138 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
139 |1: apply (le_transitive ???? (H ?) (Hs ?));
140 intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
143 lemma trans_decreasing:
144 ∀C:ordered_set.∀a:sequence C.a is_decreasing → ∀n,m:nat_ordered_set. n ≤ m → a m ≤ a n.
145 intros 5 (C a Hs n m); elim m; [
146 rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
147 intro X; cases (os_coreflexive ?? X);]
148 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
149 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
150 |1: apply (le_transitive ???? (Hs ?) (H ?));
151 intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
154 lemma trans_increasing_exc:
155 ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
156 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
158 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *)
159 change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
160 cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
161 cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)
162 |2: cases (os_cotransitive ??? (a n1) H2); [assumption]
163 cases (Hs n1); assumption;]
166 lemma trans_decreasing_exc:
167 ∀C:ordered_set.∀a:sequence C.a is_decreasing → ∀n,m:nat_ordered_set. m ≰ n → a m ≤ a n .
168 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
170 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *)
171 change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
172 cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
173 cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)
174 |2: cases (os_cotransitive ??? (a n1) H2); [2:assumption]
175 cases (Hs n1); assumption;]
178 lemma strictly_increasing_reaches:
179 ∀C:ordered_set.∀m:sequence nat_ordered_set.
180 m is_strictly_increasing → ∀w.∃t.m t ≰ w.
182 [1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
183 cases H1; [exists [apply O] apply H2;]
184 exists [apply (S O)] lapply (H O) as H3; rewrite < H2 in H3; assumption
185 |2: cases H1 (p Hp); cases (nat_discriminable (S n) (m p));
186 [1: cases H2; clear H2;
187 [1: exists [apply p]; assumption;
188 |2: exists [apply (S p)]; rewrite > H3; apply H;]
189 |2: cases (?:False); change in Hp with (n<m p);
190 apply (not_le_Sn_n (m p));
191 apply (transitive_le ??? H2 Hp);]]
194 lemma selection_uparrow:
195 ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
196 ∀a:sequence C.∀u.a ↑ u → (λx.a (m x)) ↑ u.
197 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
198 [1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
199 |2: intro n; simplify; apply Uu;
200 |3: intros (y Hy); simplify; cases (Hu ? Hy);
201 cases (strictly_increasing_reaches C ? Hm w);
202 exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]
203 cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
206 lemma selection_downarrow:
207 ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
208 ∀a:sequence C.∀u.a ↓ u → (λx.a (m x)) ↓ u.
209 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
210 [1: intro n; simplify; apply trans_decreasing_exc; [assumption] apply (Hm n);
211 |2: intro n; simplify; apply Uu;
212 |3: intros (y Hy); simplify; cases (Hu ? Hy);
213 cases (strictly_increasing_reaches C ? Hm w);
214 exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [assumption]
215 cases (trans_decreasing_exc C ? Ia ?? H1); assumption;]
219 alias id "ExT23" = "cic:/matita/dama/cprop_connectives/exT23.ind#xpointer(1/1)".
220 definition order_converge ≝
221 λO:ordered_set.λa:sequence O.λx:O.
222 ExT23 (sequence O) (λl.l ↑ x) (λu.u ↓ x)
223 (λl,u.∀i:nat. (l i) is_infimum (λw.a (w+i)) ∧ (u i) is_supremum (λw.a (w+i))).
225 notation < "a \nbsp (\circ \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 50
226 for @{'order_converge $a $x}.
227 notation > "a 'order_converges' x" non associative with precedence 50
228 for @{'order_converge $a $x}.
229 interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).
233 definition segment ≝ λO:ordered_set.λa,b:O.λx:O.
234 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (x ≤ b) (a ≤ x)).
236 notation "[a,b]" non associative with precedence 50
237 for @{'segment $a $b}.
238 interpretation "Ordered set sergment" 'segment a b = (segment _ a b).
240 notation "hvbox(x \in break [a,b])" non associative with precedence 50
241 for @{'segment2 $a $b $x}.
242 interpretation "Ordered set sergment in" 'segment2 a b x= (segment _ a b x).
244 coinductive sigma (A:Type) (P:A→Prop) : Type ≝ sig_in : ∀x.P x → sigma A P.
246 definition pi1 : ∀A.∀P.sigma A P → A ≝ λA,P,s.match s with [sig_in x _ ⇒ x].
248 interpretation "sigma pi1" 'pi1 x = (pi1 _ _ x).
250 interpretation "Type exists" 'exists \eta.x =
251 (cic:/matita/dama/supremum/sigma.ind#xpointer(1/1) _ x).
253 lemma segment_ordered_set:
254 ∀O:ordered_set.∀u,v:O.ordered_set.
255 intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
256 [1: intros (x y); apply (fst x ≰ fst y);
257 |2: intro x; cases x; simplify; apply os_coreflexive;
258 |3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
261 notation "hvbox({[a, break b]})" non associative with precedence 80
262 for @{'segment_set $a $b}.
263 interpretation "Ordered set segment" 'segment_set a b =
264 (segment_ordered_set _ a b).
267 lemma segment_preserves_supremum:
268 ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}.
269 (λn.fst (a n)) is_increasing ∧
270 (fst x) is_supremum (λn.fst (a n)) → a ↑ x.
271 intros; split; cases H; clear H;
273 |2: cases H2; split; clear H2;
275 |2: clear H; intro y0; apply (H3 (fst y0));]]
278 lemma segment_preserves_infimum:
279 ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}.
280 (λn.fst (a n)) is_decreasing ∧
281 (fst x) is_infimum (λn.fst (a n)) → a ↓ x.
282 intros; split; cases H; clear H;
284 |2: cases H2; split; clear H2;
286 |2: clear H; intro y0; apply (H3 (fst y0));]]
290 (* Definition 2.10 *)
291 coinductive pair (A,B:Type) : Type ≝ prod : ∀a:A.∀b:B.pair A B.
292 definition first : ∀A.∀P.pair A P → A ≝ λA,P,s.match s with [prod x _ ⇒ x].
293 definition second : ∀A.∀P.pair A P → P ≝ λA,P,s.match s with [prod _ y ⇒ y].
295 interpretation "pair pi1" 'pi1 x = (first _ _ x).
296 interpretation "pair pi2" 'pi2 x = (second _ _ x).
298 notation "hvbox(\langle a, break b\rangle)" non associative with precedence 91 for @{ 'pair $a $b}.
299 interpretation "pair" 'pair a b = (prod _ _ a b).
301 interpretation "prod" 'product a b = (pair a b).
303 lemma square_ordered_set: ordered_set → ordered_set.
305 apply (mk_ordered_set (O × O));
306 [1: intros (x y); apply (fst x ≰ fst y ∨ snd x ≰ snd y);
307 |2: intro x0; cases x0 (x y); clear x0; simplify; intro H;
308 cases H (X X); apply (os_coreflexive ?? X);
309 |3: intros 3 (x0 y0 z0); cases x0 (x1 x2); cases y0 (y1 y2) ; cases z0 (z1 z2);
310 clear x0 y0 z0; simplify; intro H; cases H (H1 H1); clear H;
311 [1: cases (os_cotransitive ??? z1 H1); [left; left|right;left]assumption;
312 |2: cases (os_cotransitive ??? z2 H1); [left;right|right;right]assumption]]
315 notation < "s 2 \atop \nleq" non associative with precedence 90
317 notation > "s 'square'" non associative with precedence 90
319 interpretation "ordered set square" 'square s = (square_ordered_set s).
321 definition square_segment ≝
322 λO:ordered_set.λa,b:O.λx:square_ordered_set O.
323 (cic:/matita/logic/connectives/And.ind#xpointer(1/1)
324 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (fst x ≤ b) (a ≤ fst x))
325 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (snd x ≤ b) (a ≤ snd x))).
328 λO:ordered_set.λU:O square → Prop.
329 ∀p.U p → fst p ≤ snd p → ∀y. square_segment ? (fst p) (snd p) y → U y.
331 (* Definition 2.11 *)
332 definition upper_located ≝
333 λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x →
334 (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
336 definition lower_located ≝
337 λO:ordered_set.λa:sequence O.∀x,y:O. x ≰ y →
338 (∃i:nat.x ≰ a i) ∨ (∃b:O.b≰y ∧ ∀i:nat.b ≤ a i).
340 notation < "s \nbsp 'is_upper_located'" non associative with precedence 50
341 for @{'upper_located $s}.
342 notation > "s 'is_upper_located'" non associative with precedence 50
343 for @{'upper_located $s}.
344 interpretation "Ordered set upper locatedness" 'upper_located s =
347 notation < "s \nbsp 'is_lower_located'" non associative with precedence 50
348 for @{'lower_located $s}.
349 notation > "s 'is_lower_located'" non associative with precedence 50
350 for @{'lower_located $s}.
351 interpretation "Ordered set lower locatedness" 'lower_located s =
355 lemma uparrow_upperlocated:
356 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → a is_upper_located.
357 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
358 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
359 [2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
360 |1: right; exists [apply u]; split; [apply W|apply H4]]
363 lemma downarrow_lowerlocated:
364 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↓ u → a is_lower_located.
365 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
366 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
367 [1: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
368 |2: right; exists [apply u]; split; [apply W|apply H4]]