62479
|
1 |
(* Title: HOL/Nonstandard_Analysis/Star.thy
|
|
2 |
Author: Jacques D. Fleuriot
|
|
3 |
Copyright: 1998 University of Cambridge
|
27468
|
4 |
Conversion to Isar and new proofs by Lawrence C Paulson, 2003/4
|
|
5 |
*)
|
|
6 |
|
64435
|
7 |
section \<open>Star-Transforms in Non-Standard Analysis\<close>
|
27468
|
8 |
|
|
9 |
theory Star
|
64435
|
10 |
imports NSA
|
27468
|
11 |
begin
|
|
12 |
|
64435
|
13 |
definition \<comment> \<open>internal sets\<close>
|
|
14 |
starset_n :: "(nat \<Rightarrow> 'a set) \<Rightarrow> 'a star set" ("*sn* _" [80] 80)
|
|
15 |
where "*sn* As = Iset (star_n As)"
|
27468
|
16 |
|
64435
|
17 |
definition InternalSets :: "'a star set set"
|
|
18 |
where "InternalSets = {X. \<exists>As. X = *sn* As}"
|
27468
|
19 |
|
64435
|
20 |
definition \<comment> \<open>nonstandard extension of function\<close>
|
|
21 |
is_starext :: "('a star \<Rightarrow> 'a star) \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> bool"
|
|
22 |
where "is_starext F f \<longleftrightarrow>
|
|
23 |
(\<forall>x y. \<exists>X \<in> Rep_star x. \<exists>Y \<in> Rep_star y. y = F x \<longleftrightarrow> eventually (\<lambda>n. Y n = f(X n)) \<U>)"
|
27468
|
24 |
|
64435
|
25 |
definition \<comment> \<open>internal functions\<close>
|
|
26 |
starfun_n :: "(nat \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> 'a star \<Rightarrow> 'b star" ("*fn* _" [80] 80)
|
|
27 |
where "*fn* F = Ifun (star_n F)"
|
27468
|
28 |
|
64435
|
29 |
definition InternalFuns :: "('a star => 'b star) set"
|
|
30 |
where "InternalFuns = {X. \<exists>F. X = *fn* F}"
|
27468
|
31 |
|
|
32 |
|
64435
|
33 |
subsection \<open>Preamble - Pulling \<open>\<exists>\<close> over \<open>\<forall>\<close>\<close>
|
27468
|
34 |
|
64435
|
35 |
text \<open>This proof does not need AC and was suggested by the
|
|
36 |
referee for the JCM Paper: let \<open>f x\<close> be least \<open>y\<close> such
|
|
37 |
that \<open>Q x y\<close>.\<close>
|
|
38 |
lemma no_choice: "\<forall>x. \<exists>y. Q x y \<Longrightarrow> \<exists>f :: 'a \<Rightarrow> nat. \<forall>x. Q x (f x)"
|
|
39 |
by (rule exI [where x = "\<lambda>x. LEAST y. Q x y"]) (blast intro: LeastI)
|
27468
|
40 |
|
64435
|
41 |
|
|
42 |
subsection \<open>Properties of the Star-transform Applied to Sets of Reals\<close>
|
27468
|
43 |
|
64435
|
44 |
lemma STAR_star_of_image_subset: "star_of ` A \<subseteq> *s* A"
|
|
45 |
by auto
|
27468
|
46 |
|
64435
|
47 |
lemma STAR_hypreal_of_real_Int: "*s* X \<inter> \<real> = hypreal_of_real ` X"
|
|
48 |
by (auto simp add: SReal_def)
|
27468
|
49 |
|
64435
|
50 |
lemma STAR_star_of_Int: "*s* X \<inter> Standard = star_of ` X"
|
|
51 |
by (auto simp add: Standard_def)
|
27468
|
52 |
|
64435
|
53 |
lemma lemma_not_hyprealA: "x \<notin> hypreal_of_real ` A \<Longrightarrow> \<forall>y \<in> A. x \<noteq> hypreal_of_real y"
|
|
54 |
by auto
|
27468
|
55 |
|
64435
|
56 |
lemma lemma_not_starA: "x \<notin> star_of ` A \<Longrightarrow> \<forall>y \<in> A. x \<noteq> star_of y"
|
|
57 |
by auto
|
27468
|
58 |
|
64435
|
59 |
lemma STAR_real_seq_to_hypreal: "\<forall>n. (X n) \<notin> M \<Longrightarrow> star_n X \<notin> *s* M"
|
|
60 |
by (simp add: starset_def star_of_def Iset_star_n FreeUltrafilterNat.proper)
|
27468
|
61 |
|
|
62 |
lemma STAR_singleton: "*s* {x} = {star_of x}"
|
64435
|
63 |
by simp
|
27468
|
64 |
|
64435
|
65 |
lemma STAR_not_mem: "x \<notin> F \<Longrightarrow> star_of x \<notin> *s* F"
|
|
66 |
by transfer
|
27468
|
67 |
|
64435
|
68 |
lemma STAR_subset_closed: "x \<in> *s* A \<Longrightarrow> A \<subseteq> B \<Longrightarrow> x \<in> *s* B"
|
|
69 |
by (erule rev_subsetD) simp
|
27468
|
70 |
|
64435
|
71 |
text \<open>Nonstandard extension of a set (defined using a constant
|
|
72 |
sequence) as a special case of an internal set.\<close>
|
|
73 |
lemma starset_n_starset: "\<forall>n. As n = A \<Longrightarrow> *sn* As = *s* A"
|
|
74 |
by (drule fun_eq_iff [THEN iffD2]) (simp add: starset_n_def starset_def star_of_def)
|
27468
|
75 |
|
|
76 |
|
64435
|
77 |
subsection \<open>Theorems about nonstandard extensions of functions\<close>
|
27468
|
78 |
|
64435
|
79 |
text \<open>Nonstandard extension of a function (defined using a
|
|
80 |
constant sequence) as a special case of an internal function.\<close>
|
27468
|
81 |
|
70218
|
82 |
lemma starfun_n_starfun: "F = (\<lambda>n. f) \<Longrightarrow> *fn* F = *f* f"
|
|
83 |
by (simp add: starfun_n_def starfun_def star_of_def)
|
27468
|
84 |
|
64435
|
85 |
text \<open>Prove that \<open>abs\<close> for hypreal is a nonstandard extension of abs for real w/o
|
|
86 |
use of congruence property (proved after this for general
|
|
87 |
nonstandard extensions of real valued functions).
|
27468
|
88 |
|
64435
|
89 |
Proof now Uses the ultrafilter tactic!\<close>
|
27468
|
90 |
|
|
91 |
lemma hrabs_is_starext_rabs: "is_starext abs abs"
|
70218
|
92 |
proof -
|
|
93 |
have "\<exists>f\<in>Rep_star (star_n h). \<exists>g\<in>Rep_star (star_n k). (star_n k = \<bar>star_n h\<bar>) = (\<forall>\<^sub>F n in \<U>. (g n::'a) = \<bar>f n\<bar>)"
|
|
94 |
for x y :: "'a star" and h k
|
|
95 |
by (metis (full_types) Rep_star_star_n star_n_abs star_n_eq_iff)
|
|
96 |
then show ?thesis
|
|
97 |
unfolding is_starext_def by (metis star_cases)
|
|
98 |
qed
|
27468
|
99 |
|
|
100 |
|
64435
|
101 |
text \<open>Nonstandard extension of functions.\<close>
|
|
102 |
|
|
103 |
lemma starfun: "( *f* f) (star_n X) = star_n (\<lambda>n. f (X n))"
|
|
104 |
by (rule starfun_star_n)
|
27468
|
105 |
|
64435
|
106 |
lemma starfun_if_eq: "\<And>w. w \<noteq> star_of x \<Longrightarrow> ( *f* (\<lambda>z. if z = x then a else g z)) w = ( *f* g) w"
|
|
107 |
by transfer simp
|
27468
|
108 |
|
64435
|
109 |
text \<open>Multiplication: \<open>( *f) x ( *g) = *(f x g)\<close>\<close>
|
|
110 |
lemma starfun_mult: "\<And>x. ( *f* f) x * ( *f* g) x = ( *f* (\<lambda>x. f x * g x)) x"
|
|
111 |
by transfer (rule refl)
|
27468
|
112 |
declare starfun_mult [symmetric, simp]
|
|
113 |
|
64435
|
114 |
text \<open>Addition: \<open>( *f) + ( *g) = *(f + g)\<close>\<close>
|
|
115 |
lemma starfun_add: "\<And>x. ( *f* f) x + ( *f* g) x = ( *f* (\<lambda>x. f x + g x)) x"
|
|
116 |
by transfer (rule refl)
|
27468
|
117 |
declare starfun_add [symmetric, simp]
|
|
118 |
|
64435
|
119 |
text \<open>Subtraction: \<open>( *f) + -( *g) = *(f + -g)\<close>\<close>
|
|
120 |
lemma starfun_minus: "\<And>x. - ( *f* f) x = ( *f* (\<lambda>x. - f x)) x"
|
|
121 |
by transfer (rule refl)
|
27468
|
122 |
declare starfun_minus [symmetric, simp]
|
|
123 |
|
|
124 |
(*FIXME: delete*)
|
64435
|
125 |
lemma starfun_add_minus: "\<And>x. ( *f* f) x + -( *f* g) x = ( *f* (\<lambda>x. f x + -g x)) x"
|
|
126 |
by transfer (rule refl)
|
27468
|
127 |
declare starfun_add_minus [symmetric, simp]
|
|
128 |
|
64435
|
129 |
lemma starfun_diff: "\<And>x. ( *f* f) x - ( *f* g) x = ( *f* (\<lambda>x. f x - g x)) x"
|
|
130 |
by transfer (rule refl)
|
27468
|
131 |
declare starfun_diff [symmetric, simp]
|
|
132 |
|
64435
|
133 |
text \<open>Composition: \<open>( *f) \<circ> ( *g) = *(f \<circ> g)\<close>\<close>
|
|
134 |
lemma starfun_o2: "(\<lambda>x. ( *f* f) (( *f* g) x)) = *f* (\<lambda>x. f (g x))"
|
|
135 |
by transfer (rule refl)
|
27468
|
136 |
|
64435
|
137 |
lemma starfun_o: "( *f* f) \<circ> ( *f* g) = ( *f* (f \<circ> g))"
|
|
138 |
by (transfer o_def) (rule refl)
|
27468
|
139 |
|
64435
|
140 |
text \<open>NS extension of constant function.\<close>
|
|
141 |
lemma starfun_const_fun [simp]: "\<And>x. ( *f* (\<lambda>x. k)) x = star_of k"
|
|
142 |
by transfer (rule refl)
|
27468
|
143 |
|
64435
|
144 |
text \<open>The NS extension of the identity function.\<close>
|
|
145 |
lemma starfun_Id [simp]: "\<And>x. ( *f* (\<lambda>x. x)) x = x"
|
|
146 |
by transfer (rule refl)
|
27468
|
147 |
|
64435
|
148 |
text \<open>The Star-function is a (nonstandard) extension of the function.\<close>
|
27468
|
149 |
lemma is_starext_starfun: "is_starext ( *f* f) f"
|
70218
|
150 |
proof -
|
|
151 |
have "\<exists>X\<in>Rep_star x. \<exists>Y\<in>Rep_star y. (y = (*f* f) x) = (\<forall>\<^sub>F n in \<U>. Y n = f (X n))"
|
|
152 |
for x y
|
|
153 |
by (metis (mono_tags) Rep_star_star_n star_cases star_n_eq_iff starfun_star_n)
|
|
154 |
then show ?thesis
|
|
155 |
by (auto simp: is_starext_def)
|
|
156 |
qed
|
27468
|
157 |
|
64435
|
158 |
text \<open>Any nonstandard extension is in fact the Star-function.\<close>
|
70218
|
159 |
lemma is_starfun_starext:
|
|
160 |
assumes "is_starext F f"
|
|
161 |
shows "F = *f* f"
|
|
162 |
proof -
|
|
163 |
have "F x = (*f* f) x"
|
|
164 |
if "\<forall>x y. \<exists>X\<in>Rep_star x. \<exists>Y\<in>Rep_star y. (y = F x) = (\<forall>\<^sub>F n in \<U>. Y n = f (X n))" for x
|
|
165 |
by (metis that mem_Rep_star_iff star_n_eq_iff starfun_star_n)
|
|
166 |
with assms show ?thesis
|
|
167 |
by (force simp add: is_starext_def)
|
|
168 |
qed
|
27468
|
169 |
|
64435
|
170 |
lemma is_starext_starfun_iff: "is_starext F f \<longleftrightarrow> F = *f* f"
|
|
171 |
by (blast intro: is_starfun_starext is_starext_starfun)
|
27468
|
172 |
|
70218
|
173 |
text \<open>Extended function has same solution as its standard version
|
64435
|
174 |
for real arguments. i.e they are the same for all real arguments.\<close>
|
27468
|
175 |
lemma starfun_eq: "( *f* f) (star_of a) = star_of (f a)"
|
64435
|
176 |
by (rule starfun_star_of)
|
27468
|
177 |
|
61982
|
178 |
lemma starfun_approx: "( *f* f) (star_of a) \<approx> star_of (f a)"
|
64435
|
179 |
by simp
|
27468
|
180 |
|
64435
|
181 |
text \<open>Useful for NS definition of derivatives.\<close>
|
|
182 |
lemma starfun_lambda_cancel: "\<And>x'. ( *f* (\<lambda>h. f (x + h))) x' = ( *f* f) (star_of x + x')"
|
|
183 |
by transfer (rule refl)
|
27468
|
184 |
|
64435
|
185 |
lemma starfun_lambda_cancel2: "( *f* (\<lambda>h. f (g (x + h)))) x' = ( *f* (f \<circ> g)) (star_of x + x')"
|
|
186 |
unfolding o_def by (rule starfun_lambda_cancel)
|
27468
|
187 |
|
|
188 |
lemma starfun_mult_HFinite_approx:
|
64435
|
189 |
"( *f* f) x \<approx> l \<Longrightarrow> ( *f* g) x \<approx> m \<Longrightarrow> l \<in> HFinite \<Longrightarrow> m \<in> HFinite \<Longrightarrow>
|
|
190 |
( *f* (\<lambda>x. f x * g x)) x \<approx> l * m"
|
|
191 |
for l m :: "'a::real_normed_algebra star"
|
70218
|
192 |
using approx_mult_HFinite by auto
|
27468
|
193 |
|
64435
|
194 |
lemma starfun_add_approx: "( *f* f) x \<approx> l \<Longrightarrow> ( *f* g) x \<approx> m \<Longrightarrow> ( *f* (%x. f x + g x)) x \<approx> l + m"
|
|
195 |
by (auto intro: approx_add)
|
27468
|
196 |
|
64435
|
197 |
text \<open>Examples: \<open>hrabs\<close> is nonstandard extension of \<open>rabs\<close>,
|
|
198 |
\<open>inverse\<close> is nonstandard extension of \<open>inverse\<close>.\<close>
|
27468
|
199 |
|
64435
|
200 |
text \<open>Can be proved easily using theorem \<open>starfun\<close> and
|
|
201 |
properties of ultrafilter as for inverse below we
|
|
202 |
use the theorem we proved above instead.\<close>
|
27468
|
203 |
|
|
204 |
lemma starfun_rabs_hrabs: "*f* abs = abs"
|
64435
|
205 |
by (simp only: star_abs_def)
|
27468
|
206 |
|
64435
|
207 |
lemma starfun_inverse_inverse [simp]: "( *f* inverse) x = inverse x"
|
|
208 |
by (simp only: star_inverse_def)
|
27468
|
209 |
|
64435
|
210 |
lemma starfun_inverse: "\<And>x. inverse (( *f* f) x) = ( *f* (\<lambda>x. inverse (f x))) x"
|
|
211 |
by transfer (rule refl)
|
27468
|
212 |
declare starfun_inverse [symmetric, simp]
|
|
213 |
|
64435
|
214 |
lemma starfun_divide: "\<And>x. ( *f* f) x / ( *f* g) x = ( *f* (\<lambda>x. f x / g x)) x"
|
|
215 |
by transfer (rule refl)
|
27468
|
216 |
declare starfun_divide [symmetric, simp]
|
|
217 |
|
64435
|
218 |
lemma starfun_inverse2: "\<And>x. inverse (( *f* f) x) = ( *f* (\<lambda>x. inverse (f x))) x"
|
|
219 |
by transfer (rule refl)
|
27468
|
220 |
|
64435
|
221 |
text \<open>General lemma/theorem needed for proofs in elementary topology of the reals.\<close>
|
67613
|
222 |
lemma starfun_mem_starset: "\<And>x. ( *f* f) x \<in> *s* A \<Longrightarrow> x \<in> *s* {x. f x \<in> A}"
|
64435
|
223 |
by transfer simp
|
27468
|
224 |
|
64435
|
225 |
text \<open>Alternative definition for \<open>hrabs\<close> with \<open>rabs\<close> function applied
|
|
226 |
entrywise to equivalence class representative.
|
|
227 |
This is easily proved using @{thm [source] starfun} and ns extension thm.\<close>
|
|
228 |
lemma hypreal_hrabs: "\<bar>star_n X\<bar> = star_n (\<lambda>n. \<bar>X n\<bar>)"
|
|
229 |
by (simp only: starfun_rabs_hrabs [symmetric] starfun)
|
27468
|
230 |
|
64435
|
231 |
text \<open>Nonstandard extension of set through nonstandard extension
|
|
232 |
of \<open>rabs\<close> function i.e. \<open>hrabs\<close>. A more general result should be
|
|
233 |
where we replace \<open>rabs\<close> by some arbitrary function \<open>f\<close> and \<open>hrabs\<close>
|
61975
|
234 |
by its NS extenson. See second NS set extension below.\<close>
|
64435
|
235 |
lemma STAR_rabs_add_minus: "*s* {x. \<bar>x + - y\<bar> < r} = {x. \<bar>x + -star_of y\<bar> < star_of r}"
|
|
236 |
by transfer (rule refl)
|
27468
|
237 |
|
|
238 |
lemma STAR_starfun_rabs_add_minus:
|
64435
|
239 |
"*s* {x. \<bar>f x + - y\<bar> < r} = {x. \<bar>( *f* f) x + -star_of y\<bar> < star_of r}"
|
|
240 |
by transfer (rule refl)
|
27468
|
241 |
|
64435
|
242 |
text \<open>Another characterization of Infinitesimal and one of \<open>\<approx>\<close> relation.
|
|
243 |
In this theory since \<open>hypreal_hrabs\<close> proved here. Maybe move both theorems??\<close>
|
27468
|
244 |
lemma Infinitesimal_FreeUltrafilterNat_iff2:
|
64435
|
245 |
"star_n X \<in> Infinitesimal \<longleftrightarrow> (\<forall>m. eventually (\<lambda>n. norm (X n) < inverse (real (Suc m))) \<U>)"
|
|
246 |
by (simp add: Infinitesimal_hypreal_of_nat_iff star_of_def hnorm_def
|
|
247 |
star_of_nat_def starfun_star_n star_n_inverse star_n_less)
|
27468
|
248 |
|
|
249 |
lemma HNatInfinite_inverse_Infinitesimal [simp]:
|
70218
|
250 |
assumes "n \<in> HNatInfinite"
|
|
251 |
shows "inverse (hypreal_of_hypnat n) \<in> Infinitesimal"
|
|
252 |
proof (cases n)
|
|
253 |
case (star_n X)
|
|
254 |
then have *: "\<And>k. \<forall>\<^sub>F n in \<U>. k < X n"
|
|
255 |
using HNatInfinite_FreeUltrafilterNat assms by blast
|
|
256 |
have "\<forall>\<^sub>F n in \<U>. inverse (real (X n)) < inverse (1 + real m)" for m
|
|
257 |
using * [of "Suc m"] by (auto elim!: eventually_mono)
|
|
258 |
then show ?thesis
|
|
259 |
using star_n by (auto simp: of_hypnat_def starfun_star_n star_n_inverse Infinitesimal_FreeUltrafilterNat_iff2)
|
|
260 |
qed
|
27468
|
261 |
|
64435
|
262 |
lemma approx_FreeUltrafilterNat_iff:
|
|
263 |
"star_n X \<approx> star_n Y \<longleftrightarrow> (\<forall>r>0. eventually (\<lambda>n. norm (X n - Y n) < r) \<U>)"
|
70218
|
264 |
(is "?lhs = ?rhs")
|
|
265 |
proof -
|
|
266 |
have "?lhs = (star_n X - star_n Y \<approx> 0)"
|
|
267 |
using approx_minus_iff by blast
|
|
268 |
also have "... = ?rhs"
|
|
269 |
by (metis (full_types) Infinitesimal_FreeUltrafilterNat_iff mem_infmal_iff star_n_diff)
|
|
270 |
finally show ?thesis .
|
|
271 |
qed
|
27468
|
272 |
|
64435
|
273 |
lemma approx_FreeUltrafilterNat_iff2:
|
|
274 |
"star_n X \<approx> star_n Y \<longleftrightarrow> (\<forall>m. eventually (\<lambda>n. norm (X n - Y n) < inverse (real (Suc m))) \<U>)"
|
70218
|
275 |
(is "?lhs = ?rhs")
|
|
276 |
proof -
|
|
277 |
have "?lhs = (star_n X - star_n Y \<approx> 0)"
|
|
278 |
using approx_minus_iff by blast
|
|
279 |
also have "... = ?rhs"
|
|
280 |
by (metis (full_types) Infinitesimal_FreeUltrafilterNat_iff2 mem_infmal_iff star_n_diff)
|
|
281 |
finally show ?thesis .
|
|
282 |
qed
|
27468
|
283 |
|
|
284 |
lemma inj_starfun: "inj starfun"
|
70218
|
285 |
proof (rule inj_onI)
|
|
286 |
show "\<phi> = \<psi>" if eq: "*f* \<phi> = *f* \<psi>" for \<phi> \<psi> :: "'a \<Rightarrow> 'b"
|
|
287 |
proof (rule ext, rule ccontr)
|
|
288 |
show False
|
|
289 |
if "\<phi> x \<noteq> \<psi> x" for x
|
|
290 |
by (metis eq that star_of_inject starfun_eq)
|
|
291 |
qed
|
|
292 |
qed
|
27468
|
293 |
|
|
294 |
end
|