10 uses ("transfer.ML") |
10 uses ("transfer.ML") |
11 begin |
11 begin |
12 |
12 |
13 subsection {* A Free Ultrafilter over the Naturals *} |
13 subsection {* A Free Ultrafilter over the Naturals *} |
14 |
14 |
15 constdefs |
15 definition |
16 FreeUltrafilterNat :: "nat set set" ("\<U>") |
16 FreeUltrafilterNat :: "nat set set" ("\<U>") |
17 "\<U> \<equiv> SOME U. freeultrafilter U" |
17 "\<U> = (SOME U. freeultrafilter U)" |
18 |
18 |
19 lemma freeultrafilter_FUFNat: "freeultrafilter \<U>" |
19 lemma freeultrafilter_FUFNat: "freeultrafilter \<U>" |
20 apply (unfold FreeUltrafilterNat_def) |
20 apply (unfold FreeUltrafilterNat_def) |
21 apply (rule someI_ex) |
21 apply (rule someI_ex) |
22 apply (rule freeultrafilter_Ex) |
22 apply (rule freeultrafilter_Ex) |
23 apply (rule nat_infinite) |
23 apply (rule nat_infinite) |
24 done |
24 done |
25 |
25 |
26 interpretation FUFNat: freeultrafilter [FreeUltrafilterNat] |
26 interpretation FUFNat: freeultrafilter [FreeUltrafilterNat] |
27 by (cut_tac [!] freeultrafilter_FUFNat, simp_all add: freeultrafilter_def) |
27 using freeultrafilter_FUFNat by (simp_all add: freeultrafilter_def) |
28 |
28 |
29 text {* This rule takes the place of the old ultra tactic *} |
29 text {* This rule takes the place of the old ultra tactic *} |
30 |
30 |
31 lemma ultra: |
31 lemma ultra: |
32 "\<lbrakk>{n. P n} \<in> \<U>; {n. P n \<longrightarrow> Q n} \<in> \<U>\<rbrakk> \<Longrightarrow> {n. Q n} \<in> \<U>" |
32 "\<lbrakk>{n. P n} \<in> \<U>; {n. P n \<longrightarrow> Q n} \<in> \<U>\<rbrakk> \<Longrightarrow> {n. Q n} \<in> \<U>" |
33 by (simp add: Collect_imp_eq FUFNat.F.Un_iff FUFNat.F.Compl_iff) |
33 by (simp add: Collect_imp_eq FUFNat.F.Un_iff FUFNat.F.Compl_iff) |
34 |
34 |
35 |
35 |
36 subsection {* Definition of @{text star} type constructor *} |
36 subsection {* Definition of @{text star} type constructor *} |
37 |
37 |
38 constdefs |
38 definition |
39 starrel :: "((nat \<Rightarrow> 'a) \<times> (nat \<Rightarrow> 'a)) set" |
39 starrel :: "((nat \<Rightarrow> 'a) \<times> (nat \<Rightarrow> 'a)) set" |
40 "starrel \<equiv> {(X,Y). {n. X n = Y n} \<in> \<U>}" |
40 "starrel = {(X,Y). {n. X n = Y n} \<in> \<U>}" |
41 |
41 |
42 typedef 'a star = "(UNIV :: (nat \<Rightarrow> 'a) set) // starrel" |
42 typedef 'a star = "(UNIV :: (nat \<Rightarrow> 'a) set) // starrel" |
43 by (auto intro: quotientI) |
43 by (auto intro: quotientI) |
44 |
44 |
45 constdefs |
45 definition |
46 star_n :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a star" |
46 star_n :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a star" |
47 "star_n X \<equiv> Abs_star (starrel `` {X})" |
47 "star_n X = Abs_star (starrel `` {X})" |
48 |
48 |
49 theorem star_cases [case_names star_n, cases type: star]: |
49 theorem star_cases [case_names star_n, cases type: star]: |
50 "(\<And>X. x = star_n X \<Longrightarrow> P) \<Longrightarrow> P" |
50 "(\<And>X. x = star_n X \<Longrightarrow> P) \<Longrightarrow> P" |
51 by (cases x, unfold star_n_def star_def, erule quotientE, fast) |
51 by (cases x, unfold star_n_def star_def, erule quotientE, fast) |
52 |
52 |
154 by (simp add: atomize_eq) |
154 by (simp add: atomize_eq) |
155 |
155 |
156 |
156 |
157 subsection {* Standard elements *} |
157 subsection {* Standard elements *} |
158 |
158 |
159 constdefs |
159 definition |
160 star_of :: "'a \<Rightarrow> 'a star" |
160 star_of :: "'a \<Rightarrow> 'a star" |
161 "star_of x \<equiv> star_n (\<lambda>n. x)" |
161 "star_of x == star_n (\<lambda>n. x)" |
162 |
162 |
163 text {* Transfer tactic should remove occurrences of @{term star_of} *} |
163 text {* Transfer tactic should remove occurrences of @{term star_of} *} |
164 setup {* Transfer.add_const "StarDef.star_of" *} |
164 setup {* Transfer.add_const "StarDef.star_of" *} |
165 declare star_of_def [transfer_intro] |
165 declare star_of_def [transfer_intro] |
166 |
166 |
168 by (transfer, rule refl) |
168 by (transfer, rule refl) |
169 |
169 |
170 |
170 |
171 subsection {* Internal functions *} |
171 subsection {* Internal functions *} |
172 |
172 |
173 constdefs |
173 definition |
174 Ifun :: "('a \<Rightarrow> 'b) star \<Rightarrow> 'a star \<Rightarrow> 'b star" ("_ \<star> _" [300,301] 300) |
174 Ifun :: "('a \<Rightarrow> 'b) star \<Rightarrow> 'a star \<Rightarrow> 'b star" ("_ \<star> _" [300,301] 300) |
175 "Ifun f \<equiv> \<lambda>x. Abs_star |
175 "Ifun f \<equiv> \<lambda>x. Abs_star |
176 (\<Union>F\<in>Rep_star f. \<Union>X\<in>Rep_star x. starrel``{\<lambda>n. F n (X n)})" |
176 (\<Union>F\<in>Rep_star f. \<Union>X\<in>Rep_star x. starrel``{\<lambda>n. F n (X n)})" |
177 |
177 |
178 lemma Ifun_congruent2: |
178 lemma Ifun_congruent2: |
193 lemma Ifun_star_of [simp]: "star_of f \<star> star_of x = star_of (f x)" |
193 lemma Ifun_star_of [simp]: "star_of f \<star> star_of x = star_of (f x)" |
194 by (transfer, rule refl) |
194 by (transfer, rule refl) |
195 |
195 |
196 text {* Nonstandard extensions of functions *} |
196 text {* Nonstandard extensions of functions *} |
197 |
197 |
198 constdefs |
198 definition |
199 starfun :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a star \<Rightarrow> 'b star)" |
199 starfun :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a star \<Rightarrow> 'b star)" |
200 ("*f* _" [80] 80) |
200 ("*f* _" [80] 80) |
201 "starfun f \<equiv> \<lambda>x. star_of f \<star> x" |
201 "starfun f == \<lambda>x. star_of f \<star> x" |
202 |
202 |
203 starfun2 :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> ('a star \<Rightarrow> 'b star \<Rightarrow> 'c star)" |
203 starfun2 :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> ('a star \<Rightarrow> 'b star \<Rightarrow> 'c star)" |
204 ("*f2* _" [80] 80) |
204 ("*f2* _" [80] 80) |
205 "starfun2 f \<equiv> \<lambda>x y. star_of f \<star> x \<star> y" |
205 "starfun2 f == \<lambda>x y. star_of f \<star> x \<star> y" |
206 |
206 |
207 declare starfun_def [transfer_unfold] |
207 declare starfun_def [transfer_unfold] |
208 declare starfun2_def [transfer_unfold] |
208 declare starfun2_def [transfer_unfold] |
209 |
209 |
210 lemma starfun_star_n: "( *f* f) (star_n X) = star_n (\<lambda>n. f (X n))" |
210 lemma starfun_star_n: "( *f* f) (star_n X) = star_n (\<lambda>n. f (X n))" |
221 by (transfer, rule refl) |
221 by (transfer, rule refl) |
222 |
222 |
223 |
223 |
224 subsection {* Internal predicates *} |
224 subsection {* Internal predicates *} |
225 |
225 |
226 constdefs |
226 definition |
227 unstar :: "bool star \<Rightarrow> bool" |
227 unstar :: "bool star \<Rightarrow> bool" |
228 "unstar b \<equiv> b = star_of True" |
228 "unstar b = (b = star_of True)" |
229 |
229 |
230 lemma unstar_star_n: "unstar (star_n P) = ({n. P n} \<in> \<U>)" |
230 lemma unstar_star_n: "unstar (star_n P) = ({n. P n} \<in> \<U>)" |
231 by (simp add: unstar_def star_of_def star_n_eq_iff) |
231 by (simp add: unstar_def star_of_def star_n_eq_iff) |
232 |
232 |
233 lemma unstar_star_of [simp]: "unstar (star_of p) = p" |
233 lemma unstar_star_of [simp]: "unstar (star_of p) = p" |
238 |
238 |
239 lemma transfer_unstar [transfer_intro]: |
239 lemma transfer_unstar [transfer_intro]: |
240 "p \<equiv> star_n P \<Longrightarrow> unstar p \<equiv> {n. P n} \<in> \<U>" |
240 "p \<equiv> star_n P \<Longrightarrow> unstar p \<equiv> {n. P n} \<in> \<U>" |
241 by (simp only: unstar_star_n) |
241 by (simp only: unstar_star_n) |
242 |
242 |
243 constdefs |
243 definition |
244 starP :: "('a \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> bool" |
244 starP :: "('a \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> bool" |
245 ("*p* _" [80] 80) |
245 ("*p* _" [80] 80) |
246 "*p* P \<equiv> \<lambda>x. unstar (star_of P \<star> x)" |
246 "*p* P = (\<lambda>x. unstar (star_of P \<star> x))" |
247 |
247 |
248 starP2 :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> 'b star \<Rightarrow> bool" |
248 starP2 :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> 'b star \<Rightarrow> bool" |
249 ("*p2* _" [80] 80) |
249 ("*p2* _" [80] 80) |
250 "*p2* P \<equiv> \<lambda>x y. unstar (star_of P \<star> x \<star> y)" |
250 "*p2* P = (\<lambda>x y. unstar (star_of P \<star> x \<star> y))" |
251 |
251 |
252 declare starP_def [transfer_unfold] |
252 declare starP_def [transfer_unfold] |
253 declare starP2_def [transfer_unfold] |
253 declare starP2_def [transfer_unfold] |
254 |
254 |
255 lemma starP_star_n: "( *p* P) (star_n X) = ({n. P (X n)} \<in> \<U>)" |
255 lemma starP_star_n: "( *p* P) (star_n X) = ({n. P (X n)} \<in> \<U>)" |
266 by (transfer, rule refl) |
266 by (transfer, rule refl) |
267 |
267 |
268 |
268 |
269 subsection {* Internal sets *} |
269 subsection {* Internal sets *} |
270 |
270 |
271 constdefs |
271 definition |
272 Iset :: "'a set star \<Rightarrow> 'a star set" |
272 Iset :: "'a set star \<Rightarrow> 'a star set" |
273 "Iset A \<equiv> {x. ( *p2* op \<in>) x A}" |
273 "Iset A = {x. ( *p2* op \<in>) x A}" |
274 |
274 |
275 lemma Iset_star_n: |
275 lemma Iset_star_n: |
276 "(star_n X \<in> Iset (star_n A)) = ({n. X n \<in> A n} \<in> \<U>)" |
276 "(star_n X \<in> Iset (star_n A)) = ({n. X n \<in> A n} \<in> \<U>)" |
277 by (simp add: Iset_def starP2_star_n) |
277 by (simp add: Iset_def starP2_star_n) |
278 |
278 |
307 lemma transfer_Iset [transfer_intro]: |
307 lemma transfer_Iset [transfer_intro]: |
308 "\<lbrakk>a \<equiv> star_n A\<rbrakk> \<Longrightarrow> Iset a \<equiv> Iset (star_n (\<lambda>n. A n))" |
308 "\<lbrakk>a \<equiv> star_n A\<rbrakk> \<Longrightarrow> Iset a \<equiv> Iset (star_n (\<lambda>n. A n))" |
309 by simp |
309 by simp |
310 |
310 |
311 text {* Nonstandard extensions of sets. *} |
311 text {* Nonstandard extensions of sets. *} |
312 constdefs |
312 |
|
313 definition |
313 starset :: "'a set \<Rightarrow> 'a star set" ("*s* _" [80] 80) |
314 starset :: "'a set \<Rightarrow> 'a star set" ("*s* _" [80] 80) |
314 "starset A \<equiv> Iset (star_of A)" |
315 "starset A = Iset (star_of A)" |
315 |
316 |
316 declare starset_def [transfer_unfold] |
317 declare starset_def [transfer_unfold] |
317 |
318 |
318 lemma starset_mem: "(star_of x \<in> *s* A) = (x \<in> A)" |
319 lemma starset_mem: "(star_of x \<in> *s* A) = (x \<in> A)" |
319 by (transfer, rule refl) |
320 by (transfer, rule refl) |