author | avigad |
Tue, 12 Jul 2005 17:56:03 +0200 | |
changeset 16775 | c1b87ef4a1c3 |
parent 15543 | 0024472afce7 |
child 17298 | ad73fb6144cf |
permissions | -rw-r--r-- |
10751 | 1 |
(* Title : HSeries.thy |
2 |
Author : Jacques D. Fleuriot |
|
3 |
Copyright : 1998 University of Cambridge |
|
14413 | 4 |
|
5 |
Converted to Isar and polished by lcp |
|
10751 | 6 |
*) |
7 |
||
14413 | 8 |
header{*Finite Summation and Infinite Series for Hyperreals*} |
10751 | 9 |
|
15131 | 10 |
theory HSeries |
15140 | 11 |
imports Series |
15131 | 12 |
begin |
10751 | 13 |
|
14413 | 14 |
constdefs |
15 |
sumhr :: "(hypnat * hypnat * (nat=>real)) => hypreal" |
|
16 |
"sumhr p == |
|
17 |
(%(M,N,f). Abs_hypreal(\<Union>X \<in> Rep_hypnat(M). \<Union>Y \<in> Rep_hypnat(N). |
|
15539 | 18 |
hyprel ``{%n::nat. setsum f {X n..<Y n}})) p" |
10751 | 19 |
|
14413 | 20 |
NSsums :: "[nat=>real,real] => bool" (infixr "NSsums" 80) |
15539 | 21 |
"f NSsums s == (%n. setsum f {0..<n}) ----NS> s" |
10751 | 22 |
|
14413 | 23 |
NSsummable :: "(nat=>real) => bool" |
24 |
"NSsummable f == (\<exists>s. f NSsums s)" |
|
10751 | 25 |
|
14413 | 26 |
NSsuminf :: "(nat=>real) => real" |
10751 | 27 |
"NSsuminf f == (@s. f NSsums s)" |
28 |
||
14413 | 29 |
|
30 |
lemma sumhr: |
|
31 |
"sumhr(Abs_hypnat(hypnatrel``{%n. M n}), |
|
32 |
Abs_hypnat(hypnatrel``{%n. N n}), f) = |
|
15539 | 33 |
Abs_hypreal(hyprel `` {%n. setsum f {M n..<N n}})" |
14413 | 34 |
apply (simp add: sumhr_def) |
15539 | 35 |
apply (rule arg_cong [where f = Abs_hypreal]) |
14413 | 36 |
apply (auto, ultra) |
37 |
done |
|
38 |
||
39 |
text{*Base case in definition of @{term sumr}*} |
|
40 |
lemma sumhr_zero [simp]: "sumhr (m,0,f) = 0" |
|
14468 | 41 |
apply (cases m) |
14413 | 42 |
apply (simp add: hypnat_zero_def sumhr symmetric hypreal_zero_def) |
43 |
done |
|
44 |
||
45 |
text{*Recursive case in definition of @{term sumr}*} |
|
46 |
lemma sumhr_if: |
|
47 |
"sumhr(m,n+1,f) = |
|
48 |
(if n + 1 \<le> m then 0 else sumhr(m,n,f) + ( *fNat* f) n)" |
|
14468 | 49 |
apply (cases m, cases n) |
14413 | 50 |
apply (auto simp add: hypnat_one_def sumhr hypnat_add hypnat_le starfunNat |
51 |
hypreal_add hypreal_zero_def, ultra+) |
|
52 |
done |
|
53 |
||
54 |
lemma sumhr_Suc_zero [simp]: "sumhr (n + 1, n, f) = 0" |
|
14468 | 55 |
apply (cases n) |
14413 | 56 |
apply (simp add: hypnat_one_def sumhr hypnat_add hypreal_zero_def) |
57 |
done |
|
58 |
||
59 |
lemma sumhr_eq_bounds [simp]: "sumhr (n,n,f) = 0" |
|
14468 | 60 |
apply (cases n) |
14413 | 61 |
apply (simp add: sumhr hypreal_zero_def) |
62 |
done |
|
63 |
||
64 |
lemma sumhr_Suc [simp]: "sumhr (m,m + 1,f) = ( *fNat* f) m" |
|
14468 | 65 |
apply (cases m) |
14413 | 66 |
apply (simp add: sumhr hypnat_one_def hypnat_add starfunNat) |
67 |
done |
|
68 |
||
69 |
lemma sumhr_add_lbound_zero [simp]: "sumhr(m+k,k,f) = 0" |
|
14468 | 70 |
apply (cases m, cases k) |
14413 | 71 |
apply (simp add: sumhr hypnat_add hypreal_zero_def) |
72 |
done |
|
73 |
||
74 |
lemma sumhr_add: "sumhr (m,n,f) + sumhr(m,n,g) = sumhr(m,n,%i. f i + g i)" |
|
14468 | 75 |
apply (cases m, cases n) |
15536 | 76 |
apply (simp add: sumhr hypreal_add setsum_addf) |
14413 | 77 |
done |
78 |
||
79 |
lemma sumhr_mult: "hypreal_of_real r * sumhr(m,n,f) = sumhr(m,n,%n. r * f n)" |
|
14468 | 80 |
apply (cases m, cases n) |
15536 | 81 |
apply (simp add: sumhr hypreal_of_real_def hypreal_mult setsum_mult) |
14413 | 82 |
done |
83 |
||
84 |
lemma sumhr_split_add: "n < p ==> sumhr(0,n,f) + sumhr(n,p,f) = sumhr(0,p,f)" |
|
14468 | 85 |
apply (cases n, cases p) |
14413 | 86 |
apply (auto elim!: FreeUltrafilterNat_subset simp |
15539 | 87 |
add: hypnat_zero_def sumhr hypreal_add hypnat_less setsum_add_nat_ivl) |
14413 | 88 |
done |
89 |
||
90 |
lemma sumhr_split_diff: "n<p ==> sumhr(0,p,f) - sumhr(0,n,f) = sumhr(n,p,f)" |
|
91 |
by (drule_tac f1 = f in sumhr_split_add [symmetric], simp) |
|
92 |
||
93 |
lemma sumhr_hrabs: "abs(sumhr(m,n,f)) \<le> sumhr(m,n,%i. abs(f i))" |
|
14468 | 94 |
apply (cases n, cases m) |
15536 | 95 |
apply (simp add: sumhr hypreal_le hypreal_hrabs setsum_abs) |
14413 | 96 |
done |
97 |
||
98 |
text{* other general version also needed *} |
|
99 |
lemma sumhr_fun_hypnat_eq: |
|
100 |
"(\<forall>r. m \<le> r & r < n --> f r = g r) --> |
|
101 |
sumhr(hypnat_of_nat m, hypnat_of_nat n, f) = |
|
102 |
sumhr(hypnat_of_nat m, hypnat_of_nat n, g)" |
|
15536 | 103 |
by (fastsimp simp add: sumhr hypnat_of_nat_eq intro:setsum_cong) |
104 |
||
14413 | 105 |
|
15047 | 106 |
lemma sumhr_const: |
107 |
"sumhr(0, n, %i. r) = hypreal_of_hypnat n * hypreal_of_real r" |
|
14468 | 108 |
apply (cases n) |
14413 | 109 |
apply (simp add: sumhr hypnat_zero_def hypreal_of_real_def hypreal_of_hypnat |
15047 | 110 |
hypreal_mult real_of_nat_def) |
14413 | 111 |
done |
112 |
||
113 |
lemma sumhr_less_bounds_zero [simp]: "n < m ==> sumhr(m,n,f) = 0" |
|
14468 | 114 |
apply (cases m, cases n) |
14413 | 115 |
apply (auto elim: FreeUltrafilterNat_subset |
116 |
simp add: sumhr hypnat_less hypreal_zero_def) |
|
117 |
done |
|
118 |
||
119 |
lemma sumhr_minus: "sumhr(m, n, %i. - f i) = - sumhr(m, n, f)" |
|
14468 | 120 |
apply (cases m, cases n) |
15536 | 121 |
apply (simp add: sumhr hypreal_minus setsum_negf) |
14413 | 122 |
done |
123 |
||
124 |
lemma sumhr_shift_bounds: |
|
125 |
"sumhr(m+hypnat_of_nat k,n+hypnat_of_nat k,f) = sumhr(m,n,%i. f(i + k))" |
|
14468 | 126 |
apply (cases m, cases n) |
15539 | 127 |
apply (simp add: sumhr hypnat_add setsum_shift_bounds_nat_ivl hypnat_of_nat_eq) |
14413 | 128 |
done |
129 |
||
130 |
||
131 |
subsection{*Nonstandard Sums*} |
|
132 |
||
133 |
text{*Infinite sums are obtained by summing to some infinite hypernatural |
|
134 |
(such as @{term whn})*} |
|
135 |
lemma sumhr_hypreal_of_hypnat_omega: |
|
136 |
"sumhr(0,whn,%i. 1) = hypreal_of_hypnat whn" |
|
15047 | 137 |
by (simp add: hypnat_omega_def hypnat_zero_def sumhr hypreal_of_hypnat |
138 |
real_of_nat_def) |
|
14413 | 139 |
|
140 |
lemma sumhr_hypreal_omega_minus_one: "sumhr(0, whn, %i. 1) = omega - 1" |
|
141 |
by (simp add: hypnat_omega_def hypnat_zero_def omega_def hypreal_one_def |
|
15047 | 142 |
sumhr hypreal_diff real_of_nat_def) |
14413 | 143 |
|
144 |
lemma sumhr_minus_one_realpow_zero [simp]: |
|
145 |
"sumhr(0, whn + whn, %i. (-1) ^ (i+1)) = 0" |
|
146 |
by (simp del: realpow_Suc |
|
14435
9e22eeccf129
Conversion of Poly to Isar script, and other tidying of HOL/Hyperreal
paulson
parents:
14413
diff
changeset
|
147 |
add: sumhr hypnat_add nat_mult_2 [symmetric] hypreal_zero_def |
14413 | 148 |
hypnat_zero_def hypnat_omega_def) |
149 |
||
150 |
lemma sumhr_interval_const: |
|
151 |
"(\<forall>n. m \<le> Suc n --> f n = r) & m \<le> na |
|
152 |
==> sumhr(hypnat_of_nat m,hypnat_of_nat na,f) = |
|
153 |
(hypreal_of_nat (na - m) * hypreal_of_real r)" |
|
15539 | 154 |
by(simp add: sumhr hypreal_of_nat_eq hypnat_of_nat_eq hypreal_of_real_def |
155 |
real_of_nat_def hypreal_mult cong: setsum_ivl_cong) |
|
14413 | 156 |
|
15539 | 157 |
lemma starfunNat_sumr: "( *fNat* (%n. setsum f {0..<n})) N = sumhr(0,N,f)" |
14468 | 158 |
apply (cases N) |
14413 | 159 |
apply (simp add: hypnat_zero_def starfunNat sumhr) |
160 |
done |
|
161 |
||
162 |
lemma sumhr_hrabs_approx [simp]: "sumhr(0, M, f) @= sumhr(0, N, f) |
|
163 |
==> abs (sumhr(M, N, f)) @= 0" |
|
164 |
apply (cut_tac x = M and y = N in linorder_less_linear) |
|
165 |
apply (auto simp add: approx_refl) |
|
166 |
apply (drule approx_sym [THEN approx_minus_iff [THEN iffD1]]) |
|
167 |
apply (auto dest: approx_hrabs |
|
168 |
simp add: sumhr_split_diff diff_minus [symmetric]) |
|
169 |
done |
|
170 |
||
171 |
(*---------------------------------------------------------------- |
|
172 |
infinite sums: Standard and NS theorems |
|
173 |
----------------------------------------------------------------*) |
|
174 |
lemma sums_NSsums_iff: "(f sums l) = (f NSsums l)" |
|
175 |
by (simp add: sums_def NSsums_def LIMSEQ_NSLIMSEQ_iff) |
|
176 |
||
177 |
lemma summable_NSsummable_iff: "(summable f) = (NSsummable f)" |
|
178 |
by (simp add: summable_def NSsummable_def sums_NSsums_iff) |
|
179 |
||
180 |
lemma suminf_NSsuminf_iff: "(suminf f) = (NSsuminf f)" |
|
181 |
by (simp add: suminf_def NSsuminf_def sums_NSsums_iff) |
|
182 |
||
183 |
lemma NSsums_NSsummable: "f NSsums l ==> NSsummable f" |
|
184 |
by (simp add: NSsums_def NSsummable_def, blast) |
|
185 |
||
186 |
lemma NSsummable_NSsums: "NSsummable f ==> f NSsums (NSsuminf f)" |
|
187 |
apply (simp add: NSsummable_def NSsuminf_def) |
|
188 |
apply (blast intro: someI2) |
|
189 |
done |
|
190 |
||
191 |
lemma NSsums_unique: "f NSsums s ==> (s = NSsuminf f)" |
|
192 |
by (simp add: suminf_NSsuminf_iff [symmetric] sums_NSsums_iff sums_unique) |
|
193 |
||
15539 | 194 |
lemma NSseries_zero: |
195 |
"\<forall>m. n \<le> Suc m --> f(m) = 0 ==> f NSsums (setsum f {0..<n})" |
|
14413 | 196 |
by (simp add: sums_NSsums_iff [symmetric] series_zero) |
197 |
||
198 |
lemma NSsummable_NSCauchy: |
|
199 |
"NSsummable f = |
|
200 |
(\<forall>M \<in> HNatInfinite. \<forall>N \<in> HNatInfinite. abs (sumhr(M,N,f)) @= 0)" |
|
201 |
apply (auto simp add: summable_NSsummable_iff [symmetric] |
|
202 |
summable_convergent_sumr_iff convergent_NSconvergent_iff |
|
203 |
NSCauchy_NSconvergent_iff [symmetric] NSCauchy_def starfunNat_sumr) |
|
204 |
apply (cut_tac x = M and y = N in linorder_less_linear) |
|
205 |
apply (auto simp add: approx_refl) |
|
206 |
apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym]) |
|
207 |
apply (rule_tac [2] approx_minus_iff [THEN iffD2]) |
|
208 |
apply (auto dest: approx_hrabs_zero_cancel |
|
209 |
simp add: sumhr_split_diff diff_minus [symmetric]) |
|
210 |
done |
|
211 |
||
212 |
||
213 |
text{*Terms of a convergent series tend to zero*} |
|
214 |
lemma NSsummable_NSLIMSEQ_zero: "NSsummable f ==> f ----NS> 0" |
|
215 |
apply (auto simp add: NSLIMSEQ_def NSsummable_NSCauchy) |
|
216 |
apply (drule bspec, auto) |
|
217 |
apply (drule_tac x = "N + 1 " in bspec) |
|
218 |
apply (auto intro: HNatInfinite_add_one approx_hrabs_zero_cancel) |
|
219 |
done |
|
220 |
||
221 |
text{* Easy to prove stsandard case now *} |
|
222 |
lemma summable_LIMSEQ_zero: "summable f ==> f ----> 0" |
|
223 |
by (simp add: summable_NSsummable_iff LIMSEQ_NSLIMSEQ_iff NSsummable_NSLIMSEQ_zero) |
|
224 |
||
225 |
text{*Nonstandard comparison test*} |
|
226 |
lemma NSsummable_comparison_test: |
|
227 |
"[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] ==> NSsummable f" |
|
228 |
by (auto intro: summable_comparison_test |
|
229 |
simp add: summable_NSsummable_iff [symmetric]) |
|
230 |
||
231 |
lemma NSsummable_rabs_comparison_test: |
|
232 |
"[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] |
|
233 |
==> NSsummable (%k. abs (f k))" |
|
234 |
apply (rule NSsummable_comparison_test) |
|
15543 | 235 |
apply (auto) |
14413 | 236 |
done |
237 |
||
238 |
ML |
|
239 |
{* |
|
240 |
val sumhr = thm "sumhr"; |
|
241 |
val sumhr_zero = thm "sumhr_zero"; |
|
242 |
val sumhr_if = thm "sumhr_if"; |
|
243 |
val sumhr_Suc_zero = thm "sumhr_Suc_zero"; |
|
244 |
val sumhr_eq_bounds = thm "sumhr_eq_bounds"; |
|
245 |
val sumhr_Suc = thm "sumhr_Suc"; |
|
246 |
val sumhr_add_lbound_zero = thm "sumhr_add_lbound_zero"; |
|
247 |
val sumhr_add = thm "sumhr_add"; |
|
248 |
val sumhr_mult = thm "sumhr_mult"; |
|
249 |
val sumhr_split_add = thm "sumhr_split_add"; |
|
250 |
val sumhr_split_diff = thm "sumhr_split_diff"; |
|
251 |
val sumhr_hrabs = thm "sumhr_hrabs"; |
|
252 |
val sumhr_fun_hypnat_eq = thm "sumhr_fun_hypnat_eq"; |
|
253 |
val sumhr_less_bounds_zero = thm "sumhr_less_bounds_zero"; |
|
254 |
val sumhr_minus = thm "sumhr_minus"; |
|
255 |
val sumhr_shift_bounds = thm "sumhr_shift_bounds"; |
|
256 |
val sumhr_hypreal_of_hypnat_omega = thm "sumhr_hypreal_of_hypnat_omega"; |
|
257 |
val sumhr_hypreal_omega_minus_one = thm "sumhr_hypreal_omega_minus_one"; |
|
258 |
val sumhr_minus_one_realpow_zero = thm "sumhr_minus_one_realpow_zero"; |
|
259 |
val sumhr_interval_const = thm "sumhr_interval_const"; |
|
260 |
val starfunNat_sumr = thm "starfunNat_sumr"; |
|
261 |
val sumhr_hrabs_approx = thm "sumhr_hrabs_approx"; |
|
262 |
val sums_NSsums_iff = thm "sums_NSsums_iff"; |
|
263 |
val summable_NSsummable_iff = thm "summable_NSsummable_iff"; |
|
264 |
val suminf_NSsuminf_iff = thm "suminf_NSsuminf_iff"; |
|
265 |
val NSsums_NSsummable = thm "NSsums_NSsummable"; |
|
266 |
val NSsummable_NSsums = thm "NSsummable_NSsums"; |
|
267 |
val NSsums_unique = thm "NSsums_unique"; |
|
268 |
val NSseries_zero = thm "NSseries_zero"; |
|
269 |
val NSsummable_NSCauchy = thm "NSsummable_NSCauchy"; |
|
270 |
val NSsummable_NSLIMSEQ_zero = thm "NSsummable_NSLIMSEQ_zero"; |
|
271 |
val summable_LIMSEQ_zero = thm "summable_LIMSEQ_zero"; |
|
272 |
val NSsummable_comparison_test = thm "NSsummable_comparison_test"; |
|
273 |
val NSsummable_rabs_comparison_test = thm "NSsummable_rabs_comparison_test"; |
|
274 |
*} |
|
275 |
||
10751 | 276 |
end |