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".
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.
23 λO:ordered_set.λs:sequence O.λx.upper_bound ? s x ∧ (∀y:O.x ≰ y → ∃n.s n ≰ y).
25 λO:ordered_set.λs:sequence O.λx.lower_bound ? s x ∧ (∀y:O.y ≰ x → ∃n.y ≰ s n).
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.
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}.
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}.
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).
63 include "bishop_set.ma".
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]
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;
83 definition strictly_increasing ≝
84 λC:ordered_set.λa:sequence C.∀n:nat.a (S n) ≰ a n.
85 definition strictly_decreasing ≝
86 λC:ordered_set.λa:sequence C.∀n:nat.a n ≰ a (S n).
89 notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 50
90 for @{'strictly_increasing $s}.
91 notation > "s 'is_strictly_increasing'" non associative with precedence 50
92 for @{'strictly_increasing $s}.
93 interpretation "Ordered set strict increasing" 'strictly_increasing s =
94 (strictly_increasing _ s).
95 notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 50
96 for @{'strictly_decreasing $s}.
97 notation > "s 'is_strictly_decreasing'" non associative with precedence 50
98 for @{'strictly_decreasing $s}.
99 interpretation "Ordered set strict decreasing" 'strictly_decreasing s =
100 (strictly_decreasing _ s).
102 notation "a \uparrow u" non associative with precedence 50 for @{'sup_inc $a $u}.
103 interpretation "Ordered set supremum of increasing" 'sup_inc s u =
104 (cic:/matita/dama/cprop_connectives/And.ind#xpointer(1/1)
107 notation "a \downarrow u" non associative with precedence 50 for @{'inf_dec $a $u}.
108 interpretation "Ordered set supremum of increasing" 'inf_dec s u =
109 (cic:/matita/dama/cprop_connectives/And.ind#xpointer(1/1)
113 include "nat/plus.ma".
114 include "nat_ordered_set.ma".
116 alias symbol "nleq" = "Ordered set excess".
117 alias symbol "leq" = "Ordered set less or equal than".
118 lemma trans_increasing:
119 ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
120 intros 5 (C a Hs n m); elim m; [
121 rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
122 intro X; cases (os_coreflexive ?? X);]
123 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
124 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
125 |1: apply (le_transitive ???? (H ?) (Hs ?));
126 intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
129 lemma trans_increasing_exc:
130 ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
131 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
133 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *)
134 change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
135 cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
136 cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)
137 |2: cases (os_cotransitive ??? (a n1) H2); [assumption]
138 cases (Hs n1); assumption;]
141 lemma strictly_increasing_reaches:
142 ∀C:ordered_set.∀m:sequence nat_ordered_set.
143 m is_strictly_increasing → ∀w.∃t.m t ≰ w.
145 [1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
146 cases H1; [exists [apply O] apply H2;]
147 exists [apply (S O)] lapply (H O) as H3; rewrite < H2 in H3; assumption
148 |2: cases H1 (p Hp); cases (nat_discriminable (S n) (m p));
149 [1: cases H2; clear H2;
150 [1: exists [apply p]; assumption;
151 |2: exists [apply (S p)]; rewrite > H3; apply H;]
152 |2: cases (?:False); change in Hp with (n<m p);
153 apply (not_le_Sn_n (m p));
154 apply (transitive_le ??? H2 Hp);]]
158 ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
159 ∀a:sequence C.∀u.a ↑ u → (λx.a (m x)) ↑ u.
160 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
161 [1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
162 |2: intro n; simplify; apply Uu;
163 |3: intros (y Hy); simplify; cases (Hu ? Hy);
164 cases (strictly_increasing_reaches C ? Hm w);
165 exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]
166 cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
170 alias symbol "exists" = "CProp exists".
171 alias symbol "and" = "constructive and".
172 definition order_converge ≝
173 λO:ordered_set.λa:sequence O.λx:O.
174 ∃l:sequence O.∃u:sequence O.
175 (*l is_increasing ∧ u is_decreasing ∧*) l ↑ x ∧ u ↓ x ∧
176 ∀i:nat. (l i) is_infimum (λw.a (w+i)) ∧ (u i) is_supremum (λw.a (w+i)).
178 notation < "a \nbsp (\circ \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 50
179 for @{'order_converge $a $x}.
180 notation > "a 'order_converges' x" non associative with precedence 50
181 for @{'order_converge $a $x}.
182 interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).
186 definition segment ≝ λO:ordered_set.λa,b:O.λx:O.
187 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (x ≤ b) (a ≤ x)).
189 notation "[a,b]" non associative with precedence 50
190 for @{'segment $a $b}.
191 interpretation "Ordered set sergment" 'segment a b = (segment _ a b).
193 notation "hvbox(x \in break [a,b])" non associative with precedence 50
194 for @{'segment2 $a $b $x}.
195 interpretation "Ordered set sergment in" 'segment2 a b x= (segment _ a b x).
197 coinductive sigma (A:Type) (P:A→Prop) : Type ≝ sig_in : ∀x.P x → sigma A P.
199 definition pi1 : ∀A.∀P.sigma A P → A ≝ λA,P,s.match s with [sig_in x _ ⇒ x].
201 notation < "'fst' \nbsp x" non associative with precedence 50 for @{'pi1 $x}.
202 notation < "'snd' \nbsp x" non associative with precedence 50 for @{'pi2 $x}.
203 notation > "'fst' x" non associative with precedence 50 for @{'pi1 $x}.
204 notation > "'snd' x" non associative with precedence 50 for @{'pi2 $x}.
205 interpretation "sigma pi1" 'pi1 x = (pi1 _ _ x).
207 interpretation "Type exists" 'exists \eta.x =
208 (cic:/matita/dama/supremum/sigma.ind#xpointer(1/1) _ x).
210 lemma segment_ordered_set:
211 ∀O:ordered_set.∀u,v:O.ordered_set.
212 intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
213 [1: intros (x y); apply (fst x ≰ fst y);
214 |2: intro x; cases x; simplify; apply os_coreflexive;
215 |3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
218 notation "hvbox({[a, break b]})" non associative with precedence 90
219 for @{'segment_set $a $b}.
220 interpretation "Ordered set segment" 'segment_set a b =
221 (segment_ordered_set _ a b).
224 lemma segment_preserves_supremum:
225 ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}.
226 (λn.fst (a n)) is_increasing ∧
227 (fst x) is_supremum (λn.fst (a n)) → a ↑ x.
228 intros; split; cases H; clear H;
230 |2: cases H2; split; clear H2;
232 |2: clear H; intro y0; apply (H3 (fst y0));]]
235 (* Definition 2.10 *)
236 coinductive pair (A,B:Type) : Type ≝ prod : ∀a:A.∀b:B.pair A B.
237 definition first : ∀A.∀P.pair A P → A ≝ λA,P,s.match s with [prod x _ ⇒ x].
238 definition second : ∀A.∀P.pair A P → P ≝ λA,P,s.match s with [prod _ y ⇒ y].
240 interpretation "pair pi1" 'pi1 x = (first _ _ x).
241 interpretation "pair pi2" 'pi2 x = (second _ _ x).
243 notation "hvbox(\langle a, break b\rangle)" non associative with precedence 91 for @{ 'pair $a $b}.
244 interpretation "pair" 'pair a b = (prod _ _ a b).
246 notation "a \times b" left associative with precedence 60 for @{'prod $a $b}.
247 interpretation "prod" 'prod a b = (pair a b).
249 lemma square_ordered_set: ordered_set → ordered_set.
250 intro O; apply (mk_ordered_set (O × O));
251 [1: intros (x y); apply (fst x ≰ fst y ∨ snd x ≰ snd y);
252 |2: intro x0; cases x0 (x y); clear x0; simplify; intro H;
253 cases H (X X); apply (os_coreflexive ?? X);
254 |3: intros 3 (x0 y0 z0); cases x0 (x1 x2); cases y0 (y1 y2) ; cases z0 (z1 z2);
255 clear x0 y0 z0; simplify; intro H; cases H (H1 H1); clear H;
256 [1: cases (os_cotransitive ??? z1 H1); [left; left|right;left]assumption;
257 |2: cases (os_cotransitive ??? z2 H1); [left;right|right;right]assumption]]
260 notation < "s 2 \atop \nleq" non associative with precedence 90
262 notation > "s 'square'" non associative with precedence 90
264 interpretation "ordered set square" 'square s = (square_ordered_set s).
266 definition square_segment ≝
267 λO:ordered_set.λa,b:O.λx:square_ordered_set O.
268 (cic:/matita/logic/connectives/And.ind#xpointer(1/1)
269 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (fst x ≤ b) (a ≤ fst x))
270 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (snd x ≤ b) (a ≤ snd x))).
273 λO:ordered_set.λU:O square → Prop.
274 ∀p.U p → fst p ≤ snd p → ∀y. square_segment ? (fst p) (snd p) y → U y.
276 (* Definition 2.11 *)
277 definition upper_located ≝
278 λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x →
279 (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
281 definition lower_located ≝
282 λO:ordered_set.λa:sequence O.∀x,y:O. x ≰ y →
283 (∃i:nat.x ≰ a i) ∨ (∃b:O.b≰y ∧ ∀i:nat.b ≤ a i).
285 notation < "s \nbsp 'is_upper_located'" non associative with precedence 50
286 for @{'upper_located $s}.
287 notation > "s 'is_upper_located'" non associative with precedence 50
288 for @{'upper_located $s}.
289 interpretation "Ordered set upper locatedness" 'upper_located s =
292 notation < "s \nbsp 'is_lower_located'" non associative with precedence 50
293 for @{'lower_located $s}.
294 notation > "s 'is_lower_located'" non associative with precedence 50
295 for @{'lower_located $s}.
296 interpretation "Ordered set lower locatedness" 'lower_located s =
300 lemma uparrow_upperlocated:
301 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → a is_upper_located.
302 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
303 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
304 [2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
305 |1: right; exists [apply u]; split; [apply W|apply H4]]
308 lemma downarrow_lowerlocated:
309 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↓ u → a is_lower_located.
310 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
311 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
312 [1: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
313 |2: right; exists [apply u]; split; [apply W|apply H4]]