]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/contribs/dama/dama/supremum.ma
simplified coercDb implementation with additional info about the position of
[helm.git] / helm / software / matita / contribs / dama / dama / supremum.ma
index 715fb5bdbcd5f50f87afaef34b4d27ce48a4222c..a492c8f3299e8255c0b86be2605972da857b3310 100644 (file)
 (*                                                                        *)
 (**************************************************************************)
 
+
+include "datatypes/constructors.ma".
+include "nat/plus.ma".
+include "nat_ordered_set.ma".
 include "sequence.ma".
-include "ordered_set.ma".
 
 (* Definition 2.4 *)
 definition upper_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.a n ≤ u.
+definition lower_bound ≝ λO:ordered_set.λa:sequence O.λu:O.∀n:nat.u ≤ a n.
 
-definition strong_sup ≝
+definition supremum ≝
   λO:ordered_set.λs:sequence O.λx.upper_bound ? s x ∧ (∀y:O.x ≰ y → ∃n.s n ≰ y).
+definition infimum ≝
+  λO:ordered_set.λs:sequence O.λx.lower_bound ? s x ∧ (∀y:O.y ≰ x → ∃n.y ≰ s n).
 
 definition increasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a n ≤ a (S n).
+definition decreasing ≝ λO:ordered_set.λa:sequence O.∀n:nat.a (S n) ≤ a n.
 
-notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 50 
+notation < "x \nbsp 'is_upper_bound' \nbsp s" non associative with precedence 45 
   for @{'upper_bound $s $x}.
-notation < "s \nbsp 'is_increasing'"          non associative with precedence 50 
+notation < "x \nbsp 'is_lower_bound' \nbsp s" non associative with precedence 45 
+  for @{'lower_bound $s $x}.
+notation < "s \nbsp 'is_increasing'" non associative with precedence 45 
   for @{'increasing $s}.
-notation < "x \nbsp 'is_strong_sup' \nbsp s"  non associative with precedence 50 
-  for @{'strong_sup $s $x}.
+notation < "s \nbsp 'is_decreasing'" non associative with precedence 45 
+  for @{'decreasing $s}.
+notation < "x \nbsp 'is_supremum' \nbsp s" non associative with precedence 45 
+  for @{'supremum $s $x}.
+notation < "x \nbsp 'is_infimum' \nbsp s" non associative with precedence 45 
+  for @{'infimum $s $x}.
 
-notation > "x 'is_upper_bound' s" non associative with precedence 50 
+notation > "x 'is_upper_bound' s" non associative with precedence 45 
   for @{'upper_bound $s $x}.
-notation > "s 'is_increasing'"    non associative with precedence 50 
+notation > "x 'is_lower_bound' s" non associative with precedence 45 
+  for @{'lower_bound $s $x}.
+notation > "s 'is_increasing'"    non associative with precedence 45 
   for @{'increasing $s}.
-notation > "x 'is_strong_sup' s"  non associative with precedence 50 
-  for @{'strong_sup $s $x}.
-
-interpretation "Ordered set upper bound" 'upper_bound s x = 
-  (cic:/matita/dama/supremum/upper_bound.con _ s x).
-interpretation "Ordered set increasing"  'increasing s    = 
-  (cic:/matita/dama/supremum/increasing.con _ s).
-interpretation "Ordered set strong sup"  'strong_sup s x  = 
-  (cic:/matita/dama/supremum/strong_sup.con _ s x).
+notation > "s 'is_decreasing'"    non associative with precedence 45 
+  for @{'decreasing $s}.
+notation > "x 'is_supremum' s"  non associative with precedence 45 
+  for @{'supremum $s $x}.
+notation > "x 'is_infimum' s"  non associative with precedence 45 
+  for @{'infimum $s $x}.
 
-include "bishop_set.ma".  
+interpretation "Ordered set upper bound" 'upper_bound s x = (upper_bound _ s x).
+interpretation "Ordered set lower bound" 'lower_bound s x = (lower_bound _ s x).
+interpretation "Ordered set increasing"  'increasing s = (increasing _ s).
+interpretation "Ordered set decreasing"  'decreasing s = (decreasing _ s).
+interpretation "Ordered set strong sup"  'supremum s x = (supremum _ s x).
+interpretation "Ordered set strong inf"  'infimum s x = (infimum _ s x).
   
 lemma uniq_supremum: 
   ∀O:ordered_set.∀s:sequence O.∀t1,t2:O.
-    t1 is_strong_sup s → t2 is_strong_sup s → t1 ≈ t2.
+    t1 is_supremum s → t2 is_supremum s → t1 ≈ t2.
 intros (O s t1 t2 Ht1 Ht2); cases Ht1 (U1 H1); cases Ht2 (U2 H2); 
 apply le_le_eq; intro X;
 [1: cases (H1 ? X); apply (U2 w); assumption
 |2: cases (H2 ? X); apply (U1 w); assumption]
 qed.
 
+(* Fact 2.5 *)
+lemma supremum_is_upper_bound: 
+  ∀C:ordered_set.∀a:sequence C.∀u:C.
+   u is_supremum a → ∀v.v is_upper_bound a → u ≤ v.
+intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
+cases (H1 ? H) (w Hw); apply Hv; assumption;
+qed.
+
+lemma infimum_is_lower_bound: 
+  ∀C:ordered_set.∀a:sequence C.∀u:C.
+   u is_infimum a → ∀v.v is_lower_bound a → v ≤ u.
+intros 7 (C s u Hu v Hv H); cases Hu (_ H1); clear Hu;
+cases (H1 ? H) (w Hw); apply Hv; assumption;
+qed.
+
+(* Lemma 2.6 *)
+definition strictly_increasing ≝ 
+  λC:ordered_set.λa:sequence C.∀n:nat.a (S n) ≰ a n.
+definition strictly_decreasing ≝ 
+  λC:ordered_set.λa:sequence C.∀n:nat.a n ≰ a (S n).
+
+notation < "s \nbsp 'is_strictly_increasing'" non associative with precedence 50 
+  for @{'strictly_increasing $s}.
+notation > "s 'is_strictly_increasing'" non associative with precedence 50 
+  for @{'strictly_increasing $s}.
+interpretation "Ordered set strict increasing"  'strictly_increasing s    = 
+  (strictly_increasing _ s).
+notation < "s \nbsp 'is_strictly_decreasing'" non associative with precedence 50 
+  for @{'strictly_decreasing $s}.
+notation > "s 'is_strictly_decreasing'" non associative with precedence 50 
+  for @{'strictly_decreasing $s}.
+interpretation "Ordered set strict decreasing"  'strictly_decreasing s    = 
+  (strictly_decreasing _ s).
+
+definition uparrow ≝
+  λC:ordered_set.λs:sequence C.λu:C.
+   s is_increasing ∧ u is_supremum s.
+   
+definition downarrow ≝
+  λC:ordered_set.λs:sequence C.λu:C.
+   s is_decreasing ∧ u is_infimum s.
+     
+notation < "a \uparrow \nbsp u" non associative with precedence 45 for @{'sup_inc $a $u}.
+notation > "a \uparrow u" non associative with precedence 45 for @{'sup_inc $a $u}.
+interpretation "Ordered set uparrow" 'sup_inc s u = (uparrow _ s u).
+
+notation < "a \downarrow \nbsp u" non associative with precedence 45 for @{'inf_dec $a $u}.
+notation > "a \downarrow u" non associative with precedence 45 for @{'inf_dec $a $u}.
+interpretation "Ordered set downarrow" 'inf_dec s u = (downarrow _ s u).
+
+lemma trans_increasing: 
+  ∀C:ordered_set.∀a:sequence C.a is_increasing → 
+   ∀n,m:nat_ordered_set. n ≤ m → a n ≤ a m.
+intros 5 (C a Hs n m); elim m; [
+  rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
+  intro X; cases (os_coreflexive ?? X);]
+cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
+[2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
+|1: apply (le_transitive ???? (H ?) (Hs ?));
+    intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
+qed.
+
+lemma trans_decreasing: 
+  ∀C:ordered_set.∀a:sequence C.a is_decreasing → 
+   ∀n,m:nat_ordered_set. n ≤ m → a m ≤ a n.
+intros 5 (C a Hs n m); elim m; [
+  rewrite > (le_n_O_to_eq n (not_lt_to_le O n H));
+  intro X; cases (os_coreflexive ?? X);]
+cases (le_to_or_lt_eq ?? (not_lt_to_le (S n1) n H1)); clear H1;
+[2: rewrite > H2; intro; cases (os_coreflexive ?? H1);
+|1: apply (le_transitive ???? (Hs ?) (H ?));
+    intro; whd in H1; apply (not_le_Sn_n n); apply (transitive_le ??? H2 H1);]
+qed.
+
+lemma trans_increasing_exc: 
+  ∀C:ordered_set.∀a:sequence C.a is_increasing → 
+   ∀n,m:nat_ordered_set. m ≰ n → a n ≤ a m.
+intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
+intro; apply H; 
+[1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *) 
+    change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
+    cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
+    cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)    
+|2: cases (os_cotransitive ??? (a n1) H2); [assumption]
+    cases (Hs n1); assumption;]
+qed.
+
+lemma trans_decreasing_exc: 
+  ∀C:ordered_set.∀a:sequence C.a is_decreasing →
+   ∀n,m:nat_ordered_set. m ≰ n → a m ≤ a n .
+intros 5 (C a Hs n m); elim m; [cases (not_le_Sn_O n H);]
+intro; apply H; 
+[1: change in n1 with (os_carr nat_ordered_set); (* canonical structures *) 
+    change with (n<n1); (* is sort elimination not allowed preserved by delta? *)
+    cases (le_to_or_lt_eq ?? H1); [apply le_S_S_to_le;assumption]
+    cases (Hs n); rewrite < H3 in H2; assumption (* ogni goal di tipo Prop non è anche di tipo CProp *)    
+|2: cases (os_cotransitive ??? (a n1) H2); [2:assumption]
+    cases (Hs n1); assumption;]
+qed.
+
+alias symbol "exists" = "CProp exists".
+lemma strictly_increasing_reaches: 
+  ∀C:ordered_set.∀m:sequence nat_ordered_set.
+   m is_strictly_increasing → ∀w.∃t.m t ≰ w.
+intros; elim w;
+[1: cases (nat_discriminable O (m O)); [2: cases (not_le_Sn_n O (ltn_to_ltO ?? H1))]
+    cases H1; [exists [apply O] apply H2;]
+    exists [apply (S O)] lapply (H O) as H3; rewrite < H2 in H3; assumption
+|2: cases H1 (p Hp); cases (nat_discriminable (S n) (m p)); 
+    [1: cases H2; clear H2;
+        [1: exists [apply p]; assumption;
+        |2: exists [apply (S p)]; rewrite > H3; apply H;]
+    |2: cases (?:False); change in Hp with (n<m p);
+        apply (not_le_Sn_n (m p));
+        apply (transitive_le ??? H2 Hp);]]
+qed.
+     
+lemma selection_uparrow: 
+  ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
+    ∀a:sequence C.∀u.a ↑ u → ⌊x,a (m x)⌋ ↑ u.
+intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split; 
+[1: intro n; simplify; apply trans_increasing_exc; [assumption] apply (Hm n);
+|2: intro n; simplify; apply Uu;
+|3: intros (y Hy); simplify; cases (Hu ? Hy);
+    cases (strictly_increasing_reaches C ? Hm w); 
+    exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [2:assumption]  
+    cases (trans_increasing_exc C ? Ia ?? H1); assumption;]
+qed.     
+
+lemma selection_downarrow: 
+  ∀C:ordered_set.∀m:sequence nat_ordered_set.m is_strictly_increasing →
+    ∀a:sequence C.∀u.a ↓ u → ⌊x,a (m x)⌋ ↓ u.
+intros (C m Hm a u Ha); cases Ha (Ia Su); cases Su (Uu Hu); repeat split; 
+[1: intro n; simplify; apply trans_decreasing_exc; [assumption] apply (Hm n);
+|2: intro n; simplify; apply Uu;
+|3: intros (y Hy); simplify; cases (Hu ? Hy);
+    cases (strictly_increasing_reaches C ? Hm w); 
+    exists [apply w1]; cases (os_cotransitive ??? (a (m w1)) H); [assumption]  
+    cases (trans_decreasing_exc C ? Ia ?? H1); assumption;]
+qed.
 
+(* Definition 2.7 *)
+definition order_converge ≝
+  λO:ordered_set.λa:sequence O.λx:O.
+   exT23 (sequence O) (λl.l ↑ x) (λu.u ↓ x)
+     (λl,u:sequence O.∀i:nat. (l i) is_infimum ⌊w,a (w+i)⌋ ∧ 
+                   (u i) is_supremum ⌊w,a (w+i)⌋).
+    
+notation < "a \nbsp (\cir \atop (\horbar\triangleright)) \nbsp x" non associative with precedence 45 
+  for @{'order_converge $a $x}.
+notation > "a 'order_converges' x" non associative with precedence 45 
+  for @{'order_converge $a $x}.
+interpretation "Order convergence" 'order_converge s u = (order_converge _ s u).   
     
+(* Definition 2.8 *)
+alias symbol "and" = "constructive and".
+definition segment ≝ λO:ordered_set.λa,b:O.λx:O.(x ≤ b) ∧ (a ≤ x).
+
+notation "[a,b]" left associative with precedence 70 for @{'segment $a $b}.
+interpretation "Ordered set sergment" 'segment a b = (segment _ a b).
+
+notation "hvbox(x \in break [a,b])" non associative with precedence 45 
+  for @{'segment_in $a $b $x}.
+interpretation "Ordered set sergment in" 'segment_in a b x= (segment _ a b x).
+
+lemma segment_ordered_set: 
+  ∀O:ordered_set.∀u,v:O.ordered_set.
+intros (O u v); apply (mk_ordered_set (∃x.x ∈ [u,v]));
+[1: intros (x y); apply (\fst x ≰ \fst y);
+|2: intro x; cases x; simplify; apply os_coreflexive;
+|3: intros 3 (x y z); cases x; cases y ; cases z; simplify; apply os_cotransitive]
+qed.
+
+notation "hvbox({[a, break b]})" non associative with precedence 90 
+  for @{'segment_set $a $b}.
+interpretation "Ordered set segment" 'segment_set a b = 
+  (segment_ordered_set _ a b).
+
+(* Lemma 2.9 *)
+lemma segment_preserves_supremum:
+  ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}. 
+    ⌊n,\fst (a n)⌋ is_increasing ∧ 
+    (\fst x) is_supremum ⌊n,\fst (a n)⌋ → a ↑ x.
+intros; split; cases H; clear H; 
+[1: apply H1;
+|2: cases H2; split; clear H2;
+    [1: apply H;
+    |2: clear H; intro y0; apply (H3 (\fst y0));]]
+qed.
+
+lemma segment_preserves_infimum:
+  ∀O:ordered_set.∀l,u:O.∀a:sequence {[l,u]}.∀x:{[l,u]}. 
+    ⌊n,\fst (a n)⌋ is_decreasing ∧ 
+    (\fst x) is_infimum ⌊n,\fst (a n)⌋ → a ↓ x.
+intros; split; cases H; clear H; 
+[1: apply H1;
+|2: cases H2; split; clear H2;
+    [1: apply H;
+    |2: clear H; intro y0; apply (H3 (\fst y0));]]
+qed.
+
+(* Definition 2.10 *)
+alias symbol "square" = "ordered set square".
+alias symbol "pi2" = "pair pi2".
+alias symbol "pi1" = "pair pi1".
+definition square_segment ≝ 
+  λO:ordered_set.λa,b:O.λx:O square.
+    And4 (\fst x ≤ b) (a ≤ \fst x) (\snd x ≤ b) (a ≤ \snd x).
+definition convex ≝
+  λO:ordered_set.λU:O square → Prop.
+    ∀p.U p → \fst p ≤ \snd p → ∀y. square_segment ? (\fst p) (\snd p) y → U y.
+  
+(* Definition 2.11 *)  
+definition upper_located ≝
+  λO:ordered_set.λa:sequence O.∀x,y:O. y ≰ x → 
+    (∃i:nat.a i ≰ x) ∨ (∃b:O.y≰b ∧ ∀i:nat.a i ≤ b).
+
+definition lower_located ≝
+  λO:ordered_set.λa:sequence O.∀x,y:O. x ≰ y → 
+    (∃i:nat.x ≰ a i) ∨ (∃b:O.b≰y ∧ ∀i:nat.b ≤ a i).
+
+notation < "s \nbsp 'is_upper_located'" non associative with precedence 45 
+  for @{'upper_located $s}.
+notation > "s 'is_upper_located'" non associative with precedence 45 
+  for @{'upper_located $s}.
+interpretation "Ordered set upper locatedness" 'upper_located s = 
+  (upper_located _ s).
+
+notation < "s \nbsp 'is_lower_located'" non associative with precedence 45 
+  for @{'lower_located $s}.
+notation > "s 'is_lower_located'" non associative with precedence 45
+  for @{'lower_located $s}.
+interpretation "Ordered set lower locatedness" 'lower_located s = 
+  (lower_located _ s).
+    
+(* Lemma 2.12 *)    
+lemma uparrow_upperlocated:
+  ∀C:ordered_set.∀a:sequence C.∀u:C.a ↑ u → a is_upper_located.
+intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
+cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
+[2: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
+|1: right; exists [apply u]; split; [apply W|apply H4]]
+qed. 
+
+lemma downarrow_lowerlocated:
+  ∀C:ordered_set.∀a:sequence C.∀u:C.a ↓ u → a is_lower_located.
+intros (C a u H); cases H (H2 H3); clear H; intros 3 (x y Hxy);
+cases H3 (H4 H5); clear H3; cases (os_cotransitive ??? u Hxy) (W W);
+[1: cases (H5 ? W) (w Hw); left; exists [apply w] assumption;
+|2: right; exists [apply u]; split; [apply W|apply H4]]
+qed.