]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/dama/sequence.ma
8d3ba44df84a9cebb15bf529d6f27f38db28eb84
[helm.git] / helm / software / matita / dama / sequence.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 set "baseuri" "cic:/matita/sequence/".
16
17 include "ordered_set.ma".
18
19 definition is_increasing ≝ λO:pordered_set.λa:nat→O.∀n:nat.a n ≤ a (S n).
20 definition is_decreasing ≝ λO:pordered_set.λa:nat→O.∀n:nat.a (S n) ≤ a n.
21
22 definition is_upper_bound ≝ λO:pordered_set.λa:nat→O.λu:O.∀n:nat.a n ≤ u.
23 definition is_lower_bound ≝ λO:pordered_set.λa:nat→O.λu:O.∀n:nat.u ≤ a n.
24
25 record is_sup (O:pordered_set) (a:nat→O) (u:O) : Prop ≝
26  { sup_upper_bound: is_upper_bound O a u; 
27    sup_least_upper_bound: ∀v:O. is_upper_bound O a v → u≤v
28  }.
29
30 record is_inf (O:pordered_set) (a:nat→O) (u:O) : Prop ≝
31  { inf_lower_bound: is_lower_bound O a u; 
32    inf_greatest_lower_bound: ∀v:O. is_lower_bound O a v → v≤u
33  }.
34
35 record is_bounded_below (O:pordered_set) (a:nat→O) : Type ≝
36  { ib_lower_bound: O;
37    ib_lower_bound_is_lower_bound: is_lower_bound ? a ib_lower_bound
38  }.
39
40 record is_bounded_above (O:pordered_set) (a:nat→O) : Type ≝
41  { ib_upper_bound: O;
42    ib_upper_bound_is_upper_bound: is_upper_bound ? a ib_upper_bound
43  }.
44
45 record is_bounded (O:pordered_set) (a:nat→O) : Type ≝
46  { ib_bounded_below:> is_bounded_below ? a;
47    ib_bounded_above:> is_bounded_above ? a
48  }.
49
50 record bounded_below_sequence (O:pordered_set) : Type ≝
51  { bbs_seq:1> nat→O;
52    bbs_is_bounded_below:> is_bounded_below ? bbs_seq
53  }.
54
55 record bounded_above_sequence (O:pordered_set) : Type ≝
56  { bas_seq:1> nat→O;
57    bas_is_bounded_above:> is_bounded_above ? bas_seq
58  }.
59
60 record bounded_sequence (O:pordered_set) : Type ≝
61  { bs_seq:1> nat → O;
62    bs_is_bounded_below: is_bounded_below ? bs_seq;
63    bs_is_bounded_above: is_bounded_above ? bs_seq
64  }.
65
66 definition bounded_below_sequence_of_bounded_sequence ≝
67  λO:pordered_set.λb:bounded_sequence O.
68   mk_bounded_below_sequence ? b (bs_is_bounded_below ? b).
69
70 coercion cic:/matita/sequence/bounded_below_sequence_of_bounded_sequence.con.
71
72 definition bounded_above_sequence_of_bounded_sequence ≝
73  λO:pordered_set.λb:bounded_sequence O.
74   mk_bounded_above_sequence ? b (bs_is_bounded_above ? b).
75
76 coercion cic:/matita/sequence/bounded_above_sequence_of_bounded_sequence.con.
77
78 definition lower_bound ≝
79  λO:pordered_set.λb:bounded_below_sequence O.
80   ib_lower_bound ? b (bbs_is_bounded_below ? b).
81
82 lemma lower_bound_is_lower_bound:
83  ∀O:pordered_set.∀b:bounded_below_sequence O.
84   is_lower_bound ? b (lower_bound ? b).
85 intros; unfold lower_bound; apply ib_lower_bound_is_lower_bound.
86 qed.
87
88 definition upper_bound ≝
89  λO:pordered_set.λb:bounded_above_sequence O.
90   ib_upper_bound ? b (bas_is_bounded_above ? b).
91
92 lemma upper_bound_is_upper_bound:
93  ∀O:pordered_set.∀b:bounded_above_sequence O.
94   is_upper_bound ? b (upper_bound ? b).
95 intros; unfold upper_bound; apply ib_upper_bound_is_upper_bound.
96 qed.
97
98 definition reverse_excedence: excedence → excedence.
99 intros (E); apply (mk_excedence E); [apply (λx,y.exc_relation E y x)] 
100 cases E (T f cRf cTf); simplify; 
101 [1: unfold Not; intros (x H); apply (cRf x); assumption
102 |2: intros (x y z); apply Or_symmetric; apply cTf; assumption;]
103 qed. 
104
105 definition reverse_pordered_set: pordered_set → pordered_set.
106 intros (p); apply (mk_pordered_set (reverse_excedence p));
107 generalize in match (reverse_excedence p); intros (E);
108 apply mk_is_porder_relation;
109 [apply le_reflexive|apply le_transitive|apply le_antisymmetric]
110 qed. 
111  
112 lemma is_lower_bound_reverse_is_upper_bound:
113  ∀O:pordered_set.∀a:nat→O.∀l:O.
114   is_lower_bound O a l → is_upper_bound (reverse_pordered_set O) a l.
115 intros (O a l H); unfold; intros (n); unfold reverse_pordered_set;
116 unfold reverse_excedence; simplify; fold unfold le (le ? l (a n)); apply H;    
117 qed.
118
119 lemma is_upper_bound_reverse_is_lower_bound:
120  ∀O:pordered_set.∀a:nat→O.∀l:O.
121   is_upper_bound O a l → is_lower_bound (reverse_pordered_set O) a l.
122 intros (O a l H); unfold; intros (n); unfold reverse_pordered_set;
123 unfold reverse_excedence; simplify; fold unfold le (le ? (a n) l); apply H;    
124 qed.
125
126 lemma reverse_is_lower_bound_is_upper_bound:
127  ∀O:pordered_set.∀a:nat→O.∀l:O.
128   is_lower_bound (reverse_pordered_set O) a l → is_upper_bound O a l.
129 intros (O a l H); unfold; intros (n); unfold reverse_pordered_set in H;
130 unfold reverse_excedence in H; simplify in H; apply H;    
131 qed.
132
133 lemma reverse_is_upper_bound_is_lower_bound:
134  ∀O:pordered_set.∀a:nat→O.∀l:O.
135   is_upper_bound (reverse_pordered_set O) a l → is_lower_bound O a l.
136 intros (O a l H); unfold; intros (n); unfold reverse_pordered_set in H;
137 unfold reverse_excedence in H; simplify in H; apply H;    
138 qed.
139
140 lemma is_inf_to_reverse_is_sup:
141  ∀O:pordered_set.∀a:bounded_below_sequence O.∀l:O.
142   is_inf O a l → is_sup (reverse_pordered_set O) a l.
143 intros (O a l H); apply (mk_is_sup (reverse_pordered_set O));
144 [1: apply is_lower_bound_reverse_is_upper_bound; apply inf_lower_bound; assumption
145 |2: unfold reverse_pordered_set; simplify; unfold reverse_excedence; simplify; 
146     intros (m H1); apply (inf_greatest_lower_bound ? ? ? H); apply H1;]
147 qed.
148
149 lemma is_sup_to_reverse_is_inf:
150  ∀O:pordered_set.∀a:bounded_above_sequence O.∀l:O.
151   is_sup O a l → is_inf (reverse_pordered_set O) a l.
152 intros (O a l H); apply (mk_is_inf (reverse_pordered_set O));
153 [1: apply is_upper_bound_reverse_is_lower_bound; apply sup_upper_bound; assumption
154 |2: unfold reverse_pordered_set; simplify; unfold reverse_excedence; simplify; 
155     intros (m H1); apply (sup_least_upper_bound ? ? ? H); apply H1;]
156 qed.
157
158 lemma reverse_is_sup_to_is_inf:
159  ∀O:pordered_set.∀a:bounded_above_sequence O.∀l:O.
160   is_sup (reverse_pordered_set O) a l → is_inf O a l.
161 intros (O a l H); apply mk_is_inf;
162 [1: apply reverse_is_upper_bound_is_lower_bound; 
163     apply (sup_upper_bound (reverse_pordered_set O)); assumption
164 |2: intros (v H1); apply (sup_least_upper_bound (reverse_pordered_set O) a l H v);
165     apply is_lower_bound_reverse_is_upper_bound; assumption;]
166 qed.
167
168 lemma reverse_is_inf_to_is_sup:
169  ∀O:pordered_set.∀a:bounded_above_sequence O.∀l:O.
170   is_inf (reverse_pordered_set O) a l → is_sup O a l.
171 intros (O a l H); apply mk_is_sup;
172 [1: apply reverse_is_lower_bound_is_upper_bound; 
173     apply (inf_lower_bound (reverse_pordered_set O)); assumption
174 |2: intros (v H1); apply (inf_greatest_lower_bound (reverse_pordered_set O) a l H v);
175     apply is_upper_bound_reverse_is_lower_bound; assumption;]
176 qed.