author | wenzelm |
Fri, 02 Jun 2006 23:22:29 +0200 | |
changeset 19765 | dfe940911617 |
parent 19279 | 48b527d0331b |
child 20688 | 690d866a165d |
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 |
|
19765 | 14 |
definition |
14413 | 15 |
sumhr :: "(hypnat * hypnat * (nat=>real)) => hypreal" |
19765 | 16 |
"sumhr = |
17 |
(%(M,N,f). starfun2 (%m n. setsum f {m..<n}) M N)" |
|
10751 | 18 |
|
14413 | 19 |
NSsums :: "[nat=>real,real] => bool" (infixr "NSsums" 80) |
19765 | 20 |
"f NSsums s = (%n. setsum f {0..<n}) ----NS> s" |
10751 | 21 |
|
14413 | 22 |
NSsummable :: "(nat=>real) => bool" |
19765 | 23 |
"NSsummable f = (\<exists>s. f NSsums s)" |
10751 | 24 |
|
14413 | 25 |
NSsuminf :: "(nat=>real) => real" |
19765 | 26 |
"NSsuminf f = (SOME s. f NSsums s)" |
10751 | 27 |
|
14413 | 28 |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
29 |
lemma sumhr: |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
30 |
"sumhr(star_n M, star_n N, f) = |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
31 |
star_n (%n. setsum f {M n..<N n})" |
17429
e8d6ed3aacfe
merged Transfer.thy and StarType.thy into StarDef.thy; renamed Ifun2_of to starfun2; cleaned up
huffman
parents:
17318
diff
changeset
|
32 |
by (simp add: sumhr_def starfun2_star_n) |
14413 | 33 |
|
34 |
text{*Base case in definition of @{term sumr}*} |
|
35 |
lemma sumhr_zero [simp]: "sumhr (m,0,f) = 0" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
36 |
apply (cases m) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
37 |
apply (simp add: star_n_zero_num sumhr symmetric) |
14413 | 38 |
done |
39 |
||
40 |
text{*Recursive case in definition of @{term sumr}*} |
|
41 |
lemma sumhr_if: |
|
42 |
"sumhr(m,n+1,f) = |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
43 |
(if n + 1 \<le> m then 0 else sumhr(m,n,f) + ( *f* f) n)" |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
44 |
apply (cases m, cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
45 |
apply (auto simp add: star_n_one_num sumhr star_n_add star_n_le starfun |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
46 |
star_n_zero_num star_n_eq_iff, ultra+) |
14413 | 47 |
done |
48 |
||
49 |
lemma sumhr_Suc_zero [simp]: "sumhr (n + 1, n, f) = 0" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
50 |
apply (cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
51 |
apply (simp add: star_n_one_num sumhr star_n_add star_n_zero_num) |
14413 | 52 |
done |
53 |
||
54 |
lemma sumhr_eq_bounds [simp]: "sumhr (n,n,f) = 0" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
55 |
apply (cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
56 |
apply (simp add: sumhr star_n_zero_num) |
14413 | 57 |
done |
58 |
||
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
59 |
lemma sumhr_Suc [simp]: "sumhr (m,m + 1,f) = ( *f* f) m" |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
60 |
apply (cases m) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
61 |
apply (simp add: sumhr star_n_one_num star_n_add starfun) |
14413 | 62 |
done |
63 |
||
64 |
lemma sumhr_add_lbound_zero [simp]: "sumhr(m+k,k,f) = 0" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
65 |
apply (cases m, cases k) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
66 |
apply (simp add: sumhr star_n_add star_n_zero_num) |
14413 | 67 |
done |
68 |
||
69 |
lemma sumhr_add: "sumhr (m,n,f) + sumhr(m,n,g) = sumhr(m,n,%i. f i + g i)" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
70 |
apply (cases m, cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
71 |
apply (simp add: sumhr star_n_add setsum_addf) |
14413 | 72 |
done |
73 |
||
74 |
lemma sumhr_mult: "hypreal_of_real r * sumhr(m,n,f) = sumhr(m,n,%n. r * f n)" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
75 |
apply (cases m, cases n) |
19279 | 76 |
apply (simp add: sumhr star_of_def star_n_mult setsum_right_distrib) |
14413 | 77 |
done |
78 |
||
79 |
lemma sumhr_split_add: "n < p ==> sumhr(0,n,f) + sumhr(n,p,f) = sumhr(0,p,f)" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
80 |
apply (cases n, cases p) |
14413 | 81 |
apply (auto elim!: FreeUltrafilterNat_subset simp |
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
82 |
add: star_n_zero_num sumhr star_n_add star_n_less setsum_add_nat_ivl star_n_eq_iff) |
14413 | 83 |
done |
84 |
||
85 |
lemma sumhr_split_diff: "n<p ==> sumhr(0,p,f) - sumhr(0,n,f) = sumhr(n,p,f)" |
|
86 |
by (drule_tac f1 = f in sumhr_split_add [symmetric], simp) |
|
87 |
||
88 |
lemma sumhr_hrabs: "abs(sumhr(m,n,f)) \<le> sumhr(m,n,%i. abs(f i))" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
89 |
apply (cases n, cases m) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
90 |
apply (simp add: sumhr star_n_le star_n_abs setsum_abs) |
14413 | 91 |
done |
92 |
||
93 |
text{* other general version also needed *} |
|
94 |
lemma sumhr_fun_hypnat_eq: |
|
95 |
"(\<forall>r. m \<le> r & r < n --> f r = g r) --> |
|
96 |
sumhr(hypnat_of_nat m, hypnat_of_nat n, f) = |
|
97 |
sumhr(hypnat_of_nat m, hypnat_of_nat n, g)" |
|
15536 | 98 |
by (fastsimp simp add: sumhr hypnat_of_nat_eq intro:setsum_cong) |
99 |
||
14413 | 100 |
|
15047 | 101 |
lemma sumhr_const: |
102 |
"sumhr(0, n, %i. r) = hypreal_of_hypnat n * hypreal_of_real r" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
103 |
apply (cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
104 |
apply (simp add: sumhr star_n_zero_num hypreal_of_hypnat |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
105 |
star_of_def star_n_mult real_of_nat_def) |
14413 | 106 |
done |
107 |
||
108 |
lemma sumhr_less_bounds_zero [simp]: "n < m ==> sumhr(m,n,f) = 0" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
109 |
apply (cases m, cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
110 |
apply (auto elim: FreeUltrafilterNat_subset |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
111 |
simp add: sumhr star_n_less star_n_zero_num star_n_eq_iff) |
14413 | 112 |
done |
113 |
||
114 |
lemma sumhr_minus: "sumhr(m, n, %i. - f i) = - sumhr(m, n, f)" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
115 |
apply (cases m, cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
116 |
apply (simp add: sumhr star_n_minus setsum_negf) |
14413 | 117 |
done |
118 |
||
119 |
lemma sumhr_shift_bounds: |
|
120 |
"sumhr(m+hypnat_of_nat k,n+hypnat_of_nat k,f) = sumhr(m,n,%i. f(i + k))" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
121 |
apply (cases m, cases n) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
122 |
apply (simp add: sumhr star_n_add setsum_shift_bounds_nat_ivl hypnat_of_nat_eq) |
14413 | 123 |
done |
124 |
||
125 |
||
126 |
subsection{*Nonstandard Sums*} |
|
127 |
||
128 |
text{*Infinite sums are obtained by summing to some infinite hypernatural |
|
129 |
(such as @{term whn})*} |
|
130 |
lemma sumhr_hypreal_of_hypnat_omega: |
|
131 |
"sumhr(0,whn,%i. 1) = hypreal_of_hypnat whn" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
132 |
by (simp add: hypnat_omega_def star_n_zero_num sumhr hypreal_of_hypnat |
15047 | 133 |
real_of_nat_def) |
14413 | 134 |
|
135 |
lemma sumhr_hypreal_omega_minus_one: "sumhr(0, whn, %i. 1) = omega - 1" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
136 |
by (simp add: hypnat_omega_def star_n_zero_num omega_def star_n_one_num |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
137 |
sumhr star_n_diff real_of_nat_def) |
14413 | 138 |
|
139 |
lemma sumhr_minus_one_realpow_zero [simp]: |
|
140 |
"sumhr(0, whn + whn, %i. (-1) ^ (i+1)) = 0" |
|
141 |
by (simp del: realpow_Suc |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
142 |
add: sumhr star_n_add nat_mult_2 [symmetric] star_n_zero_num |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
143 |
star_n_zero_num hypnat_omega_def) |
14413 | 144 |
|
145 |
lemma sumhr_interval_const: |
|
146 |
"(\<forall>n. m \<le> Suc n --> f n = r) & m \<le> na |
|
147 |
==> sumhr(hypnat_of_nat m,hypnat_of_nat na,f) = |
|
148 |
(hypreal_of_nat (na - m) * hypreal_of_real r)" |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
149 |
by(simp add: sumhr hypreal_of_nat_eq hypnat_of_nat_eq |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
150 |
real_of_nat_def star_of_def star_n_mult cong: setsum_ivl_cong) |
14413 | 151 |
|
17318
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
152 |
lemma starfunNat_sumr: "( *f* (%n. setsum f {0..<n})) N = sumhr(0,N,f)" |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
153 |
apply (cases N) |
bc1c75855f3d
starfun, starset, and other functions on NS types are now polymorphic;
huffman
parents:
17299
diff
changeset
|
154 |
apply (simp add: star_n_zero_num starfun sumhr) |
14413 | 155 |
done |
156 |
||
157 |
lemma sumhr_hrabs_approx [simp]: "sumhr(0, M, f) @= sumhr(0, N, f) |
|
158 |
==> abs (sumhr(M, N, f)) @= 0" |
|
159 |
apply (cut_tac x = M and y = N in linorder_less_linear) |
|
160 |
apply (auto simp add: approx_refl) |
|
161 |
apply (drule approx_sym [THEN approx_minus_iff [THEN iffD1]]) |
|
162 |
apply (auto dest: approx_hrabs |
|
163 |
simp add: sumhr_split_diff diff_minus [symmetric]) |
|
164 |
done |
|
165 |
||
166 |
(*---------------------------------------------------------------- |
|
167 |
infinite sums: Standard and NS theorems |
|
168 |
----------------------------------------------------------------*) |
|
169 |
lemma sums_NSsums_iff: "(f sums l) = (f NSsums l)" |
|
170 |
by (simp add: sums_def NSsums_def LIMSEQ_NSLIMSEQ_iff) |
|
171 |
||
172 |
lemma summable_NSsummable_iff: "(summable f) = (NSsummable f)" |
|
173 |
by (simp add: summable_def NSsummable_def sums_NSsums_iff) |
|
174 |
||
175 |
lemma suminf_NSsuminf_iff: "(suminf f) = (NSsuminf f)" |
|
176 |
by (simp add: suminf_def NSsuminf_def sums_NSsums_iff) |
|
177 |
||
178 |
lemma NSsums_NSsummable: "f NSsums l ==> NSsummable f" |
|
179 |
by (simp add: NSsums_def NSsummable_def, blast) |
|
180 |
||
181 |
lemma NSsummable_NSsums: "NSsummable f ==> f NSsums (NSsuminf f)" |
|
182 |
apply (simp add: NSsummable_def NSsuminf_def) |
|
183 |
apply (blast intro: someI2) |
|
184 |
done |
|
185 |
||
186 |
lemma NSsums_unique: "f NSsums s ==> (s = NSsuminf f)" |
|
187 |
by (simp add: suminf_NSsuminf_iff [symmetric] sums_NSsums_iff sums_unique) |
|
188 |
||
15539 | 189 |
lemma NSseries_zero: |
190 |
"\<forall>m. n \<le> Suc m --> f(m) = 0 ==> f NSsums (setsum f {0..<n})" |
|
14413 | 191 |
by (simp add: sums_NSsums_iff [symmetric] series_zero) |
192 |
||
193 |
lemma NSsummable_NSCauchy: |
|
194 |
"NSsummable f = |
|
195 |
(\<forall>M \<in> HNatInfinite. \<forall>N \<in> HNatInfinite. abs (sumhr(M,N,f)) @= 0)" |
|
196 |
apply (auto simp add: summable_NSsummable_iff [symmetric] |
|
197 |
summable_convergent_sumr_iff convergent_NSconvergent_iff |
|
198 |
NSCauchy_NSconvergent_iff [symmetric] NSCauchy_def starfunNat_sumr) |
|
199 |
apply (cut_tac x = M and y = N in linorder_less_linear) |
|
200 |
apply (auto simp add: approx_refl) |
|
201 |
apply (rule approx_minus_iff [THEN iffD2, THEN approx_sym]) |
|
202 |
apply (rule_tac [2] approx_minus_iff [THEN iffD2]) |
|
203 |
apply (auto dest: approx_hrabs_zero_cancel |
|
204 |
simp add: sumhr_split_diff diff_minus [symmetric]) |
|
205 |
done |
|
206 |
||
207 |
||
208 |
text{*Terms of a convergent series tend to zero*} |
|
209 |
lemma NSsummable_NSLIMSEQ_zero: "NSsummable f ==> f ----NS> 0" |
|
210 |
apply (auto simp add: NSLIMSEQ_def NSsummable_NSCauchy) |
|
211 |
apply (drule bspec, auto) |
|
212 |
apply (drule_tac x = "N + 1 " in bspec) |
|
213 |
apply (auto intro: HNatInfinite_add_one approx_hrabs_zero_cancel) |
|
214 |
done |
|
215 |
||
216 |
text{* Easy to prove stsandard case now *} |
|
217 |
lemma summable_LIMSEQ_zero: "summable f ==> f ----> 0" |
|
218 |
by (simp add: summable_NSsummable_iff LIMSEQ_NSLIMSEQ_iff NSsummable_NSLIMSEQ_zero) |
|
219 |
||
220 |
text{*Nonstandard comparison test*} |
|
221 |
lemma NSsummable_comparison_test: |
|
222 |
"[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] ==> NSsummable f" |
|
223 |
by (auto intro: summable_comparison_test |
|
224 |
simp add: summable_NSsummable_iff [symmetric]) |
|
225 |
||
226 |
lemma NSsummable_rabs_comparison_test: |
|
227 |
"[| \<exists>N. \<forall>n. N \<le> n --> abs(f n) \<le> g n; NSsummable g |] |
|
228 |
==> NSsummable (%k. abs (f k))" |
|
229 |
apply (rule NSsummable_comparison_test) |
|
15543 | 230 |
apply (auto) |
14413 | 231 |
done |
232 |
||
10751 | 233 |
end |