author | nipkow |
Mon, 21 Feb 2005 15:04:10 +0100 | |
changeset 15539 | 333a88244569 |
parent 15536 | 3ce1cb7a24f0 |
child 15542 | ee6cd48cf840 |
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 |
||
15539 | 150 |
(* FIXME move *) |
151 |
lemma setsum_ivl_cong: |
|
152 |
"i = m \<Longrightarrow> j = n \<Longrightarrow> (!!x. m <= x \<Longrightarrow> x < n \<Longrightarrow> f x = g x) \<Longrightarrow> |
|
153 |
setsum f {i..<j} = setsum g {m..<n}" |
|
154 |
by(rule setsum_cong, simp_all) |
|
155 |
||
14413 | 156 |
lemma sumhr_interval_const: |
157 |
"(\<forall>n. m \<le> Suc n --> f n = r) & m \<le> na |
|
158 |
==> sumhr(hypnat_of_nat m,hypnat_of_nat na,f) = |
|
159 |
(hypreal_of_nat (na - m) * hypreal_of_real r)" |
|
15539 | 160 |
by(simp add: sumhr hypreal_of_nat_eq hypnat_of_nat_eq hypreal_of_real_def |
161 |
real_of_nat_def hypreal_mult cong: setsum_ivl_cong) |
|
14413 | 162 |
|
15539 | 163 |
lemma starfunNat_sumr: "( *fNat* (%n. setsum f {0..<n})) N = sumhr(0,N,f)" |
14468 | 164 |
apply (cases N) |
14413 | 165 |
apply (simp add: hypnat_zero_def starfunNat sumhr) |
166 |
done |
|
167 |
||
168 |
lemma sumhr_hrabs_approx [simp]: "sumhr(0, M, f) @= sumhr(0, N, f) |
|
169 |
==> abs (sumhr(M, N, f)) @= 0" |
|
170 |
apply (cut_tac x = M and y = N in linorder_less_linear) |
|
171 |
apply (auto simp add: approx_refl) |
|
172 |
apply (drule approx_sym [THEN approx_minus_iff [THEN iffD1]]) |
|
173 |
apply (auto dest: approx_hrabs |
|
174 |
simp add: sumhr_split_diff diff_minus [symmetric]) |
|
175 |
done |
|
176 |
||
177 |
(*---------------------------------------------------------------- |
|
178 |
infinite sums: Standard and NS theorems |
|
179 |
----------------------------------------------------------------*) |
|
180 |
lemma sums_NSsums_iff: "(f sums l) = (f NSsums l)" |
|
181 |
by (simp add: sums_def NSsums_def LIMSEQ_NSLIMSEQ_iff) |
|
182 |
||
183 |
lemma summable_NSsummable_iff: "(summable f) = (NSsummable f)" |
|
184 |
by (simp add: summable_def NSsummable_def sums_NSsums_iff) |
|
185 |
||
186 |
lemma suminf_NSsuminf_iff: "(suminf f) = (NSsuminf f)" |
|
187 |
by (simp add: suminf_def NSsuminf_def sums_NSsums_iff) |
|
188 |
||
189 |
lemma NSsums_NSsummable: "f NSsums l ==> NSsummable f" |
|
190 |
by (simp add: NSsums_def NSsummable_def, blast) |
|
191 |
||
192 |
lemma NSsummable_NSsums: "NSsummable f ==> f NSsums (NSsuminf f)" |
|
193 |
apply (simp add: NSsummable_def NSsuminf_def) |
|
194 |
apply (blast intro: someI2) |
|
195 |
done |
|
196 |
||
197 |
lemma NSsums_unique: "f NSsums s ==> (s = NSsuminf f)" |
|
198 |
by (simp add: suminf_NSsuminf_iff [symmetric] sums_NSsums_iff sums_unique) |
|
199 |
||
15539 | 200 |
lemma NSseries_zero: |
201 |
"\<forall>m. n \<le> Suc m --> f(m) = 0 ==> f NSsums (setsum f {0..<n})" |
|
14413 | 202 |
by (simp add: sums_NSsums_iff [symmetric] series_zero) |
203 |
||
204 |
lemma NSsummable_NSCauchy: |
|
205 |
"NSsummable f = |
|
206 |
(\<forall>M \<in> HNatInfinite. \<forall>N \<in> HNatInfinite. abs (sumhr(M,N,f)) @= 0)" |
|
207 |
apply (auto simp add: summable_NSsummable_iff [symmetric] |
|
208 |
summable_convergent_sumr_iff convergent_NSconvergent_iff |
|
209 |
NSCauchy_NSconvergent_iff [symmetric] NSCauchy_def starfunNat_sumr) |
|
210 |
apply (cut_tac x = M and y = N in linorder_less_linear) |
|
211 |
apply (auto simp add: approx_refl) |
|
212 |
apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym]) |
|
213 |
apply (rule_tac [2] approx_minus_iff [THEN iffD2]) |
|
214 |
apply (auto dest: approx_hrabs_zero_cancel |
|
215 |
simp add: sumhr_split_diff diff_minus [symmetric]) |
|
216 |
done |
|
217 |
||
218 |
||
219 |
text{*Terms of a convergent series tend to zero*} |
|
220 |
lemma NSsummable_NSLIMSEQ_zero: "NSsummable f ==> f ----NS> 0" |
|
221 |
apply (auto simp add: NSLIMSEQ_def NSsummable_NSCauchy) |
|
222 |
apply (drule bspec, auto) |
|
223 |
apply (drule_tac x = "N + 1 " in bspec) |
|
224 |
apply (auto intro: HNatInfinite_add_one approx_hrabs_zero_cancel) |
|
225 |
done |
|
226 |
||
227 |
text{* Easy to prove stsandard case now *} |
|
228 |
lemma summable_LIMSEQ_zero: "summable f ==> f ----> 0" |
|
229 |
by (simp add: summable_NSsummable_iff LIMSEQ_NSLIMSEQ_iff NSsummable_NSLIMSEQ_zero) |
|
230 |
||
231 |
text{*Nonstandard comparison test*} |
|
232 |
lemma NSsummable_comparison_test: |
|
233 |
"[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] ==> NSsummable f" |
|
234 |
by (auto intro: summable_comparison_test |
|
235 |
simp add: summable_NSsummable_iff [symmetric]) |
|
236 |
||
237 |
lemma NSsummable_rabs_comparison_test: |
|
238 |
"[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] |
|
239 |
==> NSsummable (%k. abs (f k))" |
|
240 |
apply (rule NSsummable_comparison_test) |
|
241 |
apply (auto simp add: abs_idempotent) |
|
242 |
done |
|
243 |
||
244 |
ML |
|
245 |
{* |
|
246 |
val sumhr = thm "sumhr"; |
|
247 |
val sumhr_zero = thm "sumhr_zero"; |
|
248 |
val sumhr_if = thm "sumhr_if"; |
|
249 |
val sumhr_Suc_zero = thm "sumhr_Suc_zero"; |
|
250 |
val sumhr_eq_bounds = thm "sumhr_eq_bounds"; |
|
251 |
val sumhr_Suc = thm "sumhr_Suc"; |
|
252 |
val sumhr_add_lbound_zero = thm "sumhr_add_lbound_zero"; |
|
253 |
val sumhr_add = thm "sumhr_add"; |
|
254 |
val sumhr_mult = thm "sumhr_mult"; |
|
255 |
val sumhr_split_add = thm "sumhr_split_add"; |
|
256 |
val sumhr_split_diff = thm "sumhr_split_diff"; |
|
257 |
val sumhr_hrabs = thm "sumhr_hrabs"; |
|
258 |
val sumhr_fun_hypnat_eq = thm "sumhr_fun_hypnat_eq"; |
|
259 |
val sumhr_less_bounds_zero = thm "sumhr_less_bounds_zero"; |
|
260 |
val sumhr_minus = thm "sumhr_minus"; |
|
261 |
val sumhr_shift_bounds = thm "sumhr_shift_bounds"; |
|
262 |
val sumhr_hypreal_of_hypnat_omega = thm "sumhr_hypreal_of_hypnat_omega"; |
|
263 |
val sumhr_hypreal_omega_minus_one = thm "sumhr_hypreal_omega_minus_one"; |
|
264 |
val sumhr_minus_one_realpow_zero = thm "sumhr_minus_one_realpow_zero"; |
|
265 |
val sumhr_interval_const = thm "sumhr_interval_const"; |
|
266 |
val starfunNat_sumr = thm "starfunNat_sumr"; |
|
267 |
val sumhr_hrabs_approx = thm "sumhr_hrabs_approx"; |
|
268 |
val sums_NSsums_iff = thm "sums_NSsums_iff"; |
|
269 |
val summable_NSsummable_iff = thm "summable_NSsummable_iff"; |
|
270 |
val suminf_NSsuminf_iff = thm "suminf_NSsuminf_iff"; |
|
271 |
val NSsums_NSsummable = thm "NSsums_NSsummable"; |
|
272 |
val NSsummable_NSsums = thm "NSsummable_NSsums"; |
|
273 |
val NSsums_unique = thm "NSsums_unique"; |
|
274 |
val NSseries_zero = thm "NSseries_zero"; |
|
275 |
val NSsummable_NSCauchy = thm "NSsummable_NSCauchy"; |
|
276 |
val NSsummable_NSLIMSEQ_zero = thm "NSsummable_NSLIMSEQ_zero"; |
|
277 |
val summable_LIMSEQ_zero = thm "summable_LIMSEQ_zero"; |
|
278 |
val NSsummable_comparison_test = thm "NSsummable_comparison_test"; |
|
279 |
val NSsummable_rabs_comparison_test = thm "NSsummable_rabs_comparison_test"; |
|
280 |
*} |
|
281 |
||
10751 | 282 |
end |