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 =
57 (cic:/matita/dama/supremum/upper_bound.con _ s x).
58 interpretation "Ordered set lower bound" 'lower_bound s x =
59 (cic:/matita/dama/supremum/lower_bound.con _ s x).
60 interpretation "Ordered set increasing" 'increasing s =
61 (cic:/matita/dama/supremum/increasing.con _ s).
62 interpretation "Ordered set decreasing" 'decreasing s =
63 (cic:/matita/dama/supremum/decreasing.con _ s).
64 interpretation "Ordered set strong sup" 'supremum s x =
65 (cic:/matita/dama/supremum/supremum.con _ s x).
66 interpretation "Ordered set strong inf" 'infimum s x =
67 (cic:/matita/dama/supremum/infimum.con _ s x).
69 include "bishop_set.ma".
72 ∀O:ordered_set.∀s:sequence O.∀t1,t2:O.
73 t1 is_supremum s → t2 is_supremum s → t1 ≈ t2.
74 intros (O s t1 t2 Ht1 Ht2); cases Ht1 (U1 H1); cases Ht2 (U2 H2);
75 apply le_le_eq; intro X;
76 [1: cases (H1 ? X); apply (U2 w); assumption
77 |2: cases (H2 ? X); apply (U1 w); assumption]
81 lemma supremum_is_upper_bound:
82 ∀C:ordered_set.∀a:sequence C.∀u:C.
83 u is_supremum a → ∀v.v is_upper_bound a → u ≤ v.
84 intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
85 cases (H1 ? H) (w Hw); apply Hv; assumption;
89 definition strictly_increasing ≝
90 λC:ordered_set.λa:sequence C.∀n:nat.a (S n) ≰ a n.
91 definition strictly_decreasing ≝
92 λC:ordered_set.λa:sequence C.∀n:nat.a n ≰ a (S n).
95 notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 50
96 for @{'strictly_increasing $s}.
97 notation > "s 'is_strictly_increasing'" non associative with precedence 50
98 for @{'strictly_increasing $s}.
99 interpretation "Ordered set strict increasing" 'strictly_increasing s =
100 (cic:/matita/dama/supremum/strictly_increasing.con _ s).
101 notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 50
102 for @{'strictly_decreasing $s}.
103 notation > "s 'is_strictly_decreasing'" non associative with precedence 50
104 for @{'strictly_decreasing $s}.
105 interpretation "Ordered set strict decreasing" 'strictly_decreasing s =
106 (cic:/matita/dama/supremum/strictly_decreasing.con _ s).
108 notation "a \uparrow u" non associative with precedence 50 for @{'sup_inc $a $u}.
109 interpretation "Ordered set supremum of increasing" 'sup_inc s u =
110 (cic:/matita/dama/cprop_connectives/And.ind#xpointer(1/1)
111 (cic:/matita/dama/supremum/increasing.con _ s)
112 (cic:/matita/dama/supremum/supremum.con _ s u)).
113 notation "a \downarrow u" non associative with precedence 50 for @{'inf_dec $a $u}.
114 interpretation "Ordered set supremum of increasing" 'inf_dec s u =
115 (cic:/matita/dama/cprop_connectives/And.ind#xpointer(1/1)
116 (cic:/matita/dama/supremum/decreasing.con _ s)
117 (cic:/matita/dama/supremum/infimum.con _ s u)).
119 include "nat/plus.ma".
120 include "nat_ordered_set.ma".
122 alias symbol "nleq" = "Ordered set excess".
123 alias symbol "leq" = "Ordered set less or equal than".
124 lemma trans_increasing:
125 ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
126 intros 5 (C a Hs n m); elim m; [
127 rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
128 intro X; cases (os_coreflexive ?? X);]
129 cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
130 [2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
131 |1: apply (le_transitive ???? (H ?) (Hs ?));
132 intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
135 lemma trans_increasing_exc:
136 ∀C:ordered_set.∀a:sequence C.a is_increasing → ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
137 intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
139 [1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *)
140 change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
141 cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
142 cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)
143 |2: cases (os_cotransitive ??? (a n1) H2); [assumption]
144 cases (Hs n1); assumption;]
147 lemma strictly_increasing_reaches:
148 ∀C:ordered_set.∀m:sequence nat_ordered_set.
149 m is_strictly_increasing → ∀w.∃t.m t ≰ w.
151 [1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
152 cases H1; [exists [apply O] apply H2;]
153 exists [apply (S O)] lapply (H O) as H3; rewrite < H2 in H3; assumption
154 |2: cases H1 (p Hp); cases (nat_discriminable (S n) (m p));
155 [1: cases H2; clear H2;
156 [1: exists [apply p]; assumption;
157 |2: exists [apply (S p)]; rewrite > H3; apply H;]
158 |2: cases (?:False); change in Hp with (n<m p);
159 apply (not_le_Sn_n (m p));
160 apply (transitive_le ??? H2 Hp);]]
164 ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
165 ∀a:sequence C.∀u.a ↑ u → (λx.a (m x)) ↑ u.
166 intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split;
167 [1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
168 |2: intro n; simplify; apply Uu;
169 |3: intros (y Hy); simplify; cases (Hu ? Hy);
170 cases (strictly_increasing_reaches C ? Hm w);
171 exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]
172 cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
176 alias symbol "exists" = "CProp exists".
177 alias symbol "and" = "constructive and".
178 definition order_converge ≝
179 λO:ordered_set.λa:sequence O.λx:O.
180 ∃l:sequence O.∃u:sequence O.
181 l is_increasing ∧ u is_decreasing ∧ l ↑ x ∧ u ↓ x ∧
182 ∀i:nat. (l i) is_infimum (λw.a (w+i)) ∧ (u i) is_supremum (λw.a (w+i)).
184 notation < "a \nbsp (\circ \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 50
185 for @{'order_converge $a $x}.
186 notation > "a 'order_converges' x" non associative with precedence 50
187 for @{'order_converge $a $x}.
188 interpretation "Order convergence" 'order_converge s u =
189 (cic:/matita/dama/supremum/order_converge.con _ s u).
193 definition segment ≝ λO:ordered_set.λa,b:O.λx:O.
194 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (x ≤ b) (a ≤ x)).
196 notation "[a,b]" non associative with precedence 50
197 for @{'segment $a $b}.
198 interpretation "Ordered set sergment" 'segment a b =
199 (cic:/matita/dama/supremum/segment.con _ a b).
201 notation "hvbox(x \in break [a,b])" non associative with precedence 50
202 for @{'segment2 $a $b $x}.
203 interpretation "Ordered set sergment in" 'segment2 a b x=
204 (cic:/matita/dama/supremum/segment.con _ a b x).
206 coinductive sigma (A:Type) (P:A→Prop) : Type ≝ sig_in : ∀x.P x → sigma A P.
208 definition pi1 : ∀A.∀P.sigma A P → A ≝ λA,P,s.match s with [sig_in x _ ⇒ x].
210 notation < "'fst' \nbsp x" non associative with precedence 50 for @{'pi1 $x}.
211 notation < "'snd' \nbsp x" non associative with precedence 50 for @{'pi2 $x}.
212 notation > "'fst' x" non associative with precedence 50 for @{'pi1 $x}.
213 notation > "'snd' x" non associative with precedence 50 for @{'pi2 $x}.
214 interpretation "sigma pi1" 'pi1 x =
215 (cic:/matita/dama/supremum/pi1.con _ _ x).
217 interpretation "Type exists" 'exists \eta.x =
218 (cic:/matita/dama/supremum/sigma.ind#xpointer(1/1) _ x).
220 lemma segment_ordered_set:
221 ∀O:ordered_set.∀u,v:O.ordered_set.
222 intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
223 [1: intros (x y); apply (fst x ≰ fst y);
224 |2: intro x; cases x; simplify; apply os_coreflexive;
225 |3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
228 notation "hvbox({[a, break b]})" non associative with precedence 90
229 for @{'segment_set $a $b}.
230 interpretation "Ordered set segment" 'segment_set a b =
231 (cic:/matita/dama/supremum/segment_ordered_set.con _ a b).
234 lemma segment_preserves_supremum:
235 ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}.
236 (λn.fst (a n)) is_increasing ∧
237 (fst x) is_supremum (λn.fst (a n)) → a ↑ x.
238 intros; split; cases H; clear H;
240 |2: cases H2; split; clear H2;
242 |2: clear H; intro y0; apply (H3 (fst y0));]]
245 (* Definition 2.10 *)
246 coinductive pair (A,B:Type) : Type ≝ prod : ∀a:A.∀b:B.pair A B.
247 definition first : ∀A.∀P.pair A P → A ≝ λA,P,s.match s with [prod x _ ⇒ x].
248 definition second : ∀A.∀P.pair A P → P ≝ λA,P,s.match s with [prod _ y ⇒ y].
250 interpretation "pair pi1" 'pi1 x =
251 (cic:/matita/dama/supremum/first.con _ _ x).
252 interpretation "pair pi2" 'pi2 x =
253 (cic:/matita/dama/supremum/second.con _ _ x).
255 notation "hvbox(\langle a, break b\rangle)" non associative with precedence 91 for @{ 'pair $a $b}.
256 interpretation "pair" 'pair a b =
257 (cic:/matita/dama/supremum/pair.ind#xpointer(1/1/1) _ _ a b).
259 notation "a \times b" left associative with precedence 60 for @{'prod $a $b}.
260 interpretation "prod" 'prod a b =
261 (cic:/matita/dama/supremum/pair.ind#xpointer(1/1) a b).
263 lemma square_ordered_set: ordered_set → ordered_set.
264 intro O; apply (mk_ordered_set (O × O));
265 [1: intros (x y); apply (fst x ≰ fst y ∨ snd x ≰ snd y);
266 |2: intro x0; cases x0 (x y); clear x0; simplify; intro H;
267 cases H (X X); apply (os_coreflexive ?? X);
268 |3: intros 3 (x0 y0 z0); cases x0 (x1 x2); cases y0 (y1 y2) ; cases z0 (z1 z2);
269 clear x0 y0 z0; simplify; intro H; cases H (H1 H1); clear H;
270 [1: cases (os_cotransitive ??? z1 H1); [left; left|right;left]assumption;
271 |2: cases (os_cotransitive ??? z2 H1); [left;right|right;right]assumption]]
274 notation < "s 2 \atop \nleq" non associative with precedence 90
276 notation > "s 'square'" non associative with precedence 90
278 interpretation "ordered set square" 'square s =
279 (cic:/matita/dama/supremum/square_ordered_set.con s).
281 definition square_segment ≝
282 λO:ordered_set.λa,b:O.λx:square_ordered_set O.
283 (cic:/matita/logic/connectives/And.ind#xpointer(1/1)
284 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (fst x ≤ b) (a ≤ fst x))
285 (cic:/matita/logic/connectives/And.ind#xpointer(1/1) (snd x ≤ b) (a ≤ snd x))).
288 λO:ordered_set.λU:O square → Prop.
289 ∀p.U p → fst p ≤ snd p → ∀y. square_segment ? (fst p) (snd p) y → U y.
291 (* Definition 2.11 *)
292 definition upper_located ≝
293 λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x →
294 (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
296 definition lower_located ≝
297 λO:ordered_set.λa:sequence O.∀x,y:O. x ≰ y →
298 (∃i:nat.x ≰ a i) ∨ (∃b:O.b≰y ∧ ∀i:nat.b ≤ a i).
300 notation < "s \nbsp 'is_upper_located'" non associative with precedence 50
301 for @{'upper_located $s}.
302 notation > "s 'is_upper_located'" non associative with precedence 50
303 for @{'upper_located $s}.
304 interpretation "Ordered set upper locatedness" 'upper_located s =
305 (cic:/matita/dama/supremum/upper_located.con _ s).
307 notation < "s \nbsp 'is_lower_located'" non associative with precedence 50
308 for @{'lower_located $s}.
309 notation > "s 'is_lower_located'" non associative with precedence 50
310 for @{'lower_located $s}.
311 interpretation "Ordered set lower locatedness" 'lower_located s =
312 (cic:/matita/dama/supremum/lower_located.con _ s).
315 lemma uparrow_upperlocated:
316 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → a is_upper_located.
317 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
318 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
319 [2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
320 |1: right; exists [apply u]; split; [apply W|apply H4]]
323 lemma downarrow_lowerlocated:
324 ∀C:ordered_set.∀a:sequence C.∀u:C.a ↓ u → a is_lower_located.
325 intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
326 cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
327 [1: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
328 |2: right; exists [apply u]; split; [apply W|apply H4]]