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 (**************************************************************************)
16 include "datatypes/constructors.ma".
17 include "nat/plus.ma".
18 include "nat_ordered_set.ma".
19 include "sequence.ma".
22 definition upper_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.a n ≤ u.
23 definition lower_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.u ≤ a n.
26 λO:ordered_set.λs:sequence O.λx.upper_bound ? s x ∧ (∀y:O.x ≰ y → ∃n.s n ≰ y).
28 λO:ordered_set.λs:sequence O.λx.lower_bound ? s x ∧ (∀y:O.y ≰ x → ∃n.y ≰ s n).
30 definition increasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a n ≤ a (S n).
31 definition decreasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a (S n) ≤ a n.
33 notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 45
34 for @{'upper_bound $s $x}.
35 notation < "x \nbsp 'is_lower_bound' \nbsp s" non associative with precedence 45
36 for @{'lower_bound $s $x}.
37 notation < "s \nbsp 'is_increasing'" non associative with precedence 45
38 for @{'increasing $s}.
39 notation < "s \nbsp 'is_decreasing'" non associative with precedence 45
40 for @{'decreasing $s}.
41 notation < "x \nbsp 'is_supremum' \nbsp s" non associative with precedence 45
42 for @{'supremum $s $x}.
43 notation < "x \nbsp 'is_infimum' \nbsp s" non associative with precedence 45
44 for @{'infimum $s $x}.
46 notation > "x 'is_upper_bound' s" non associative with precedence 45
47 for @{'upper_bound $s $x}.
48 notation > "x 'is_lower_bound' s" non associative with precedence 45
49 for @{'lower_bound $s $x}.
50 notation > "s 'is_increasing'" non associative with precedence 45
51 for @{'increasing $s}.
52 notation > "s 'is_decreasing'" non associative with precedence 45
53 for @{'decreasing $s}.
54 notation > "x 'is_supremum' s" non associative with precedence 45
55 for @{'supremum $s $x}.
56 notation > "x 'is_infimum' s" non associative with precedence 45
57 for @{'infimum $s $x}.
59 interpretation "Ordered set upper bound" 'upper_bound s x = (upper_bound _ s x).
60 interpretation "Ordered set lower bound" 'lower_bound s x = (lower_bound _ s x).
61 interpretation "Ordered set increasing" 'increasing s = (increasing _ s).
62 interpretation "Ordered set decreasing" 'decreasing s = (decreasing _ s).
63 interpretation "Ordered set strong sup" 'supremum s x = (supremum _ s x).
64 interpretation "Ordered set strong inf" 'infimum s x = (infimum _ s x).
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;
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).
96 notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 45
97 for @{'strictly_increasing $s}.
98 notation > "s 'is_strictly_increasing'" non associative with precedence 45
99 for @{'strictly_increasing $s}.
100 interpretation "Ordered set strict increasing" 'strictly_increasing s =
101 (strictly_increasing _ s).
102 notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 45
103 for @{'strictly_decreasing $s}.
104 notation > "s 'is_strictly_decreasing'" non associative with precedence 45
105 for @{'strictly_decreasing $s}.
106 interpretation "Ordered set strict decreasing" 'strictly_decreasing s =
107 (strictly_decreasing _ s).
110 λC:ordered_set.λs:sequence C.λu:C.
111 s is_increasing ∧ u is_supremum s.
113 definition downarrow ≝
114 λC:ordered_set.λs:sequence C.λu:C.
115 s is_decreasing ∧ u is_infimum s.
117 notation < "a \uparrow \nbsp u" non associative with precedence 45 for @{'sup_inc $a $u}.
118 notation > "a \uparrow u" non associative with precedence 45 for @{'sup_inc $a $u}.
119 interpretation "Ordered set uparrow" 'sup_inc s u = (uparrow _ s u).
121 notation < "a \downarrow \nbsp u" non associative with precedence 45 for @{'inf_dec $a $u}.
122 notation > "a \downarrow u" non associative with precedence 45 for @{'inf_dec $a $u}.
123 interpretation "Ordered set downarrow" 'inf_dec s u = (downarrow _ s u).
125 lemma trans_increasing:
126 ∀C:ordered_set.∀a:sequence C.a is_increasing →
127 ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
128 intros 5 (C a Hs n m); elim m; [
129 rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
130 intro X; cases (os_coreflexive ?? X);]
131 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
132 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
133 |1: apply (le_transitive ???? (H ?) (Hs ?));
134 intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
137 lemma trans_decreasing:
138 ∀C:ordered_set.∀a:sequence C.a is_decreasing →
139 ∀n,m:nat_ordered_set. n ≤ m → a m ≤ a n.
140 intros 5 (C a Hs n m); elim m; [
141 rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
142 intro X; cases (os_coreflexive ?? X);]
143 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
144 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
145 |1: apply (le_transitive ???? (Hs ?) (H ?));
146 intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
149 lemma trans_increasing_exc:
150 ∀C:ordered_set.∀a:sequence C.a is_increasing →
151 ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
152 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
154 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *)
155 change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
156 cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
157 cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)
158 |2: cases (os_cotransitive ??? (a n1) H2); [assumption]
159 cases (Hs n1); assumption;]
162 lemma trans_decreasing_exc:
163 ∀C:ordered_set.∀a:sequence C.a is_decreasing →
164 ∀n,m:nat_ordered_set. m ≰ n → a m ≤ a n .
165 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
167 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *)
168 change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
169 cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
170 cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)
171 |2: cases (os_cotransitive ??? (a n1) H2); [2:assumption]
172 cases (Hs n1); assumption;]
175 alias symbol "exists" = "CProp exists".
176 lemma strictly_increasing_reaches:
177 ∀C:ordered_set.∀m:sequence nat_ordered_set.
178 m is_strictly_increasing → ∀w.∃t.m t ≰ w.
180 [1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
181 cases H1; [exists [apply O] apply H2;]
182 exists [apply (S O)] lapply (H O) as H3; rewrite < H2 in H3; assumption
183 |2: cases H1 (p Hp); cases (nat_discriminable (S n) (m p));
184 [1: cases H2; clear H2;
185 [1: exists [apply p]; assumption;
186 |2: exists [apply (S p)]; rewrite > H3; apply H;]
187 |2: cases (?:False); change in Hp with (n<m p);
188 apply (not_le_Sn_n (m p));
189 apply (transitive_le ??? H2 Hp);]]
192 lemma selection_uparrow:
193 ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
194 ∀a:sequence C.∀u.a ↑ u → ⌊x,a (m x)⌋ ↑ u.
195 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
196 [1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
197 |2: intro n; simplify; apply Uu;
198 |3: intros (y Hy); simplify; cases (Hu ? Hy);
199 cases (strictly_increasing_reaches C ? Hm w);
200 exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]
201 cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
204 lemma selection_downarrow:
205 ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
206 ∀a:sequence C.∀u.a ↓ u → ⌊x,a (m x)⌋ ↓ u.
207 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
208 [1: intro n; simplify; apply trans_decreasing_exc; [assumption] apply (Hm n);
209 |2: intro n; simplify; apply Uu;
210 |3: intros (y Hy); simplify; cases (Hu ? Hy);
211 cases (strictly_increasing_reaches C ? Hm w);
212 exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [assumption]
213 cases (trans_decreasing_exc C ? Ia ?? H1); assumption;]
217 definition order_converge ≝
218 λO:ordered_set.λa:sequence O.λx:O.
219 exT23 (sequence O) (λl.l ↑ x) (λu.u ↓ x)
220 (λl,u:sequence O.∀i:nat. (l i) is_infimum ⌊w,a (w+i)⌋ ∧
221 (u i) is_supremum ⌊w,a (w+i)⌋).
223 notation < "a \nbsp (\cir \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 45
224 for @{'order_converge $a $x}.
225 notation > "a 'order_converges' x" non associative with precedence 45
226 for @{'order_converge $a $x}.
227 interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).
230 definition segment ≝ λO:ordered_set.λa,b:O.λx:O.(x ≤ b) ∧ (a ≤ x).
232 notation "[term 19 a,term 19 b]" non associative with precedence 90 for @{'segment $a $b}.
233 interpretation "Ordered set sergment" 'segment a b = (segment _ a b).
235 notation "hvbox(x \in break [term 19 a, term 19 b])" non associative with precedence 45
236 for @{'segment_in $a $b $x}.
237 interpretation "Ordered set sergment in" 'segment_in a b x= (segment _ a b x).
239 lemma segment_ordered_set:
240 ∀O:ordered_set.∀u,v:O.ordered_set.
241 intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
242 [1: intros (x y); apply (\fst x ≰ \fst y);
243 |2: intro x; cases x; simplify; apply os_coreflexive;
244 |3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
247 notation "hvbox({[a, break b]})" non associative with precedence 90
248 for @{'segment_set $a $b}.
249 interpretation "Ordered set segment" 'segment_set a b =
250 (segment_ordered_set _ a b).
253 lemma segment_preserves_supremum:
254 ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}.
255 ⌊n,\fst (a n)⌋ is_increasing ∧
256 (\fst x) is_supremum ⌊n,\fst (a n)⌋ → a ↑ x.
257 intros; split; cases H; clear H;
259 |2: cases H2; split; clear H2;
261 |2: clear H; intro y0; apply (H3 (\fst y0));]]
264 lemma segment_preserves_infimum:
265 ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}.
266 ⌊n,\fst (a n)⌋ is_decreasing ∧
267 (\fst x) is_infimum ⌊n,\fst (a n)⌋ → a ↓ x.
268 intros; split; cases H; clear H;
270 |2: cases H2; split; clear H2;
272 |2: clear H; intro y0; apply (H3 (\fst y0));]]
275 (* Definition 2.10 *)
276 alias symbol "square" = "ordered set square".
277 alias symbol "pi2" = "pair pi2".
278 alias symbol "pi1" = "pair pi1".
279 definition square_segment ≝
280 λO:ordered_set.λa,b:O.λx:O square.
281 And4 (\fst x ≤ b) (a ≤ \fst x) (\snd x ≤ b) (a ≤ \snd x).
284 λO:ordered_set.λU:O square → Prop.
285 ∀p.U p → \fst p ≤ \snd p → ∀y. square_segment ? (\fst p) (\snd p) y → U y.
287 (* Definition 2.11 *)
288 definition upper_located ≝
289 λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x →
290 (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
292 definition lower_located ≝
293 λO:ordered_set.λa:sequence O.∀x,y:O. x ≰ y →
294 (∃i:nat.x ≰ a i) ∨ (∃b:O.b≰y ∧ ∀i:nat.b ≤ a i).
296 notation < "s \nbsp 'is_upper_located'" non associative with precedence 45
297 for @{'upper_located $s}.
298 notation > "s 'is_upper_located'" non associative with precedence 45
299 for @{'upper_located $s}.
300 interpretation "Ordered set upper locatedness" 'upper_located s =
303 notation < "s \nbsp 'is_lower_located'" non associative with precedence 45
304 for @{'lower_located $s}.
305 notation > "s 'is_lower_located'" non associative with precedence 45
306 for @{'lower_located $s}.
307 interpretation "Ordered set lower locatedness" 'lower_located s =
311 lemma uparrow_upperlocated:
312 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → a is_upper_located.
313 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
314 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
315 [2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
316 |1: right; exists [apply u]; split; [apply W|apply H4]]
319 lemma downarrow_lowerlocated:
320 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↓ u → a is_lower_located.
321 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
322 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
323 [1: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
324 |2: right; exists [apply u]; split; [apply W|apply H4]]