27468
|
1 |
(* Title : HOL/Hyperreal/StarDef.thy
|
|
2 |
ID : $Id$
|
|
3 |
Author : Jacques D. Fleuriot and Brian Huffman
|
|
4 |
*)
|
|
5 |
|
|
6 |
header {* Construction of Star Types Using Ultrafilters *}
|
|
7 |
|
|
8 |
theory StarDef
|
|
9 |
imports Filter
|
|
10 |
uses ("transfer.ML")
|
|
11 |
begin
|
|
12 |
|
|
13 |
subsection {* A Free Ultrafilter over the Naturals *}
|
|
14 |
|
|
15 |
definition
|
|
16 |
FreeUltrafilterNat :: "nat set set" ("\<U>") where
|
|
17 |
"\<U> = (SOME U. freeultrafilter U)"
|
|
18 |
|
|
19 |
lemma freeultrafilter_FreeUltrafilterNat: "freeultrafilter \<U>"
|
|
20 |
apply (unfold FreeUltrafilterNat_def)
|
|
21 |
apply (rule someI_ex [where P=freeultrafilter])
|
|
22 |
apply (rule freeultrafilter_Ex)
|
|
23 |
apply (rule nat_infinite)
|
|
24 |
done
|
|
25 |
|
|
26 |
interpretation FreeUltrafilterNat: freeultrafilter [FreeUltrafilterNat]
|
|
27 |
by (rule freeultrafilter_FreeUltrafilterNat)
|
|
28 |
|
|
29 |
text {* This rule takes the place of the old ultra tactic *}
|
|
30 |
|
|
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>"
|
|
33 |
by (simp add: Collect_imp_eq
|
|
34 |
FreeUltrafilterNat.Un_iff FreeUltrafilterNat.Compl_iff)
|
|
35 |
|
|
36 |
|
|
37 |
subsection {* Definition of @{text star} type constructor *}
|
|
38 |
|
|
39 |
definition
|
|
40 |
starrel :: "((nat \<Rightarrow> 'a) \<times> (nat \<Rightarrow> 'a)) set" where
|
|
41 |
"starrel = {(X,Y). {n. X n = Y n} \<in> \<U>}"
|
|
42 |
|
|
43 |
typedef 'a star = "(UNIV :: (nat \<Rightarrow> 'a) set) // starrel"
|
|
44 |
by (auto intro: quotientI)
|
|
45 |
|
|
46 |
definition
|
|
47 |
star_n :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a star" where
|
|
48 |
"star_n X = Abs_star (starrel `` {X})"
|
|
49 |
|
|
50 |
theorem star_cases [case_names star_n, cases type: star]:
|
|
51 |
"(\<And>X. x = star_n X \<Longrightarrow> P) \<Longrightarrow> P"
|
|
52 |
by (cases x, unfold star_n_def star_def, erule quotientE, fast)
|
|
53 |
|
|
54 |
lemma all_star_eq: "(\<forall>x. P x) = (\<forall>X. P (star_n X))"
|
|
55 |
by (auto, rule_tac x=x in star_cases, simp)
|
|
56 |
|
|
57 |
lemma ex_star_eq: "(\<exists>x. P x) = (\<exists>X. P (star_n X))"
|
|
58 |
by (auto, rule_tac x=x in star_cases, auto)
|
|
59 |
|
|
60 |
text {* Proving that @{term starrel} is an equivalence relation *}
|
|
61 |
|
|
62 |
lemma starrel_iff [iff]: "((X,Y) \<in> starrel) = ({n. X n = Y n} \<in> \<U>)"
|
|
63 |
by (simp add: starrel_def)
|
|
64 |
|
|
65 |
lemma equiv_starrel: "equiv UNIV starrel"
|
|
66 |
proof (rule equiv.intro)
|
|
67 |
show "reflexive starrel" by (simp add: refl_def)
|
|
68 |
show "sym starrel" by (simp add: sym_def eq_commute)
|
|
69 |
show "trans starrel" by (auto intro: transI elim!: ultra)
|
|
70 |
qed
|
|
71 |
|
|
72 |
lemmas equiv_starrel_iff =
|
|
73 |
eq_equiv_class_iff [OF equiv_starrel UNIV_I UNIV_I]
|
|
74 |
|
|
75 |
lemma starrel_in_star: "starrel``{x} \<in> star"
|
|
76 |
by (simp add: star_def quotientI)
|
|
77 |
|
|
78 |
lemma star_n_eq_iff: "(star_n X = star_n Y) = ({n. X n = Y n} \<in> \<U>)"
|
|
79 |
by (simp add: star_n_def Abs_star_inject starrel_in_star equiv_starrel_iff)
|
|
80 |
|
|
81 |
|
|
82 |
subsection {* Transfer principle *}
|
|
83 |
|
|
84 |
text {* This introduction rule starts each transfer proof. *}
|
|
85 |
lemma transfer_start:
|
|
86 |
"P \<equiv> {n. Q} \<in> \<U> \<Longrightarrow> Trueprop P \<equiv> Trueprop Q"
|
|
87 |
by (subgoal_tac "P \<equiv> Q", simp, simp add: atomize_eq)
|
|
88 |
|
|
89 |
text {*Initialize transfer tactic.*}
|
|
90 |
use "transfer.ML"
|
|
91 |
setup Transfer.setup
|
|
92 |
|
|
93 |
text {* Transfer introduction rules. *}
|
|
94 |
|
|
95 |
lemma transfer_ex [transfer_intro]:
|
|
96 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk>
|
|
97 |
\<Longrightarrow> \<exists>x::'a star. p x \<equiv> {n. \<exists>x. P n x} \<in> \<U>"
|
|
98 |
by (simp only: ex_star_eq FreeUltrafilterNat.Collect_ex)
|
|
99 |
|
|
100 |
lemma transfer_all [transfer_intro]:
|
|
101 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk>
|
|
102 |
\<Longrightarrow> \<forall>x::'a star. p x \<equiv> {n. \<forall>x. P n x} \<in> \<U>"
|
|
103 |
by (simp only: all_star_eq FreeUltrafilterNat.Collect_all)
|
|
104 |
|
|
105 |
lemma transfer_not [transfer_intro]:
|
|
106 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>\<rbrakk> \<Longrightarrow> \<not> p \<equiv> {n. \<not> P n} \<in> \<U>"
|
|
107 |
by (simp only: FreeUltrafilterNat.Collect_not)
|
|
108 |
|
|
109 |
lemma transfer_conj [transfer_intro]:
|
|
110 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk>
|
|
111 |
\<Longrightarrow> p \<and> q \<equiv> {n. P n \<and> Q n} \<in> \<U>"
|
|
112 |
by (simp only: FreeUltrafilterNat.Collect_conj)
|
|
113 |
|
|
114 |
lemma transfer_disj [transfer_intro]:
|
|
115 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk>
|
|
116 |
\<Longrightarrow> p \<or> q \<equiv> {n. P n \<or> Q n} \<in> \<U>"
|
|
117 |
by (simp only: FreeUltrafilterNat.Collect_disj)
|
|
118 |
|
|
119 |
lemma transfer_imp [transfer_intro]:
|
|
120 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk>
|
|
121 |
\<Longrightarrow> p \<longrightarrow> q \<equiv> {n. P n \<longrightarrow> Q n} \<in> \<U>"
|
|
122 |
by (simp only: imp_conv_disj transfer_disj transfer_not)
|
|
123 |
|
|
124 |
lemma transfer_iff [transfer_intro]:
|
|
125 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; q \<equiv> {n. Q n} \<in> \<U>\<rbrakk>
|
|
126 |
\<Longrightarrow> p = q \<equiv> {n. P n = Q n} \<in> \<U>"
|
|
127 |
by (simp only: iff_conv_conj_imp transfer_conj transfer_imp)
|
|
128 |
|
|
129 |
lemma transfer_if_bool [transfer_intro]:
|
|
130 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; x \<equiv> {n. X n} \<in> \<U>; y \<equiv> {n. Y n} \<in> \<U>\<rbrakk>
|
|
131 |
\<Longrightarrow> (if p then x else y) \<equiv> {n. if P n then X n else Y n} \<in> \<U>"
|
|
132 |
by (simp only: if_bool_eq_conj transfer_conj transfer_imp transfer_not)
|
|
133 |
|
|
134 |
lemma transfer_eq [transfer_intro]:
|
|
135 |
"\<lbrakk>x \<equiv> star_n X; y \<equiv> star_n Y\<rbrakk> \<Longrightarrow> x = y \<equiv> {n. X n = Y n} \<in> \<U>"
|
|
136 |
by (simp only: star_n_eq_iff)
|
|
137 |
|
|
138 |
lemma transfer_if [transfer_intro]:
|
|
139 |
"\<lbrakk>p \<equiv> {n. P n} \<in> \<U>; x \<equiv> star_n X; y \<equiv> star_n Y\<rbrakk>
|
|
140 |
\<Longrightarrow> (if p then x else y) \<equiv> star_n (\<lambda>n. if P n then X n else Y n)"
|
|
141 |
apply (rule eq_reflection)
|
|
142 |
apply (auto simp add: star_n_eq_iff transfer_not elim!: ultra)
|
|
143 |
done
|
|
144 |
|
|
145 |
lemma transfer_fun_eq [transfer_intro]:
|
|
146 |
"\<lbrakk>\<And>X. f (star_n X) = g (star_n X)
|
|
147 |
\<equiv> {n. F n (X n) = G n (X n)} \<in> \<U>\<rbrakk>
|
|
148 |
\<Longrightarrow> f = g \<equiv> {n. F n = G n} \<in> \<U>"
|
|
149 |
by (simp only: expand_fun_eq transfer_all)
|
|
150 |
|
|
151 |
lemma transfer_star_n [transfer_intro]: "star_n X \<equiv> star_n (\<lambda>n. X n)"
|
|
152 |
by (rule reflexive)
|
|
153 |
|
|
154 |
lemma transfer_bool [transfer_intro]: "p \<equiv> {n. p} \<in> \<U>"
|
|
155 |
by (simp add: atomize_eq)
|
|
156 |
|
|
157 |
|
|
158 |
subsection {* Standard elements *}
|
|
159 |
|
|
160 |
definition
|
|
161 |
star_of :: "'a \<Rightarrow> 'a star" where
|
|
162 |
"star_of x == star_n (\<lambda>n. x)"
|
|
163 |
|
|
164 |
definition
|
|
165 |
Standard :: "'a star set" where
|
|
166 |
"Standard = range star_of"
|
|
167 |
|
|
168 |
text {* Transfer tactic should remove occurrences of @{term star_of} *}
|
|
169 |
setup {* Transfer.add_const "StarDef.star_of" *}
|
|
170 |
|
|
171 |
declare star_of_def [transfer_intro]
|
|
172 |
|
|
173 |
lemma star_of_inject: "(star_of x = star_of y) = (x = y)"
|
|
174 |
by (transfer, rule refl)
|
|
175 |
|
|
176 |
lemma Standard_star_of [simp]: "star_of x \<in> Standard"
|
|
177 |
by (simp add: Standard_def)
|
|
178 |
|
|
179 |
|
|
180 |
subsection {* Internal functions *}
|
|
181 |
|
|
182 |
definition
|
|
183 |
Ifun :: "('a \<Rightarrow> 'b) star \<Rightarrow> 'a star \<Rightarrow> 'b star" ("_ \<star> _" [300,301] 300) where
|
|
184 |
"Ifun f \<equiv> \<lambda>x. Abs_star
|
|
185 |
(\<Union>F\<in>Rep_star f. \<Union>X\<in>Rep_star x. starrel``{\<lambda>n. F n (X n)})"
|
|
186 |
|
|
187 |
lemma Ifun_congruent2:
|
|
188 |
"congruent2 starrel starrel (\<lambda>F X. starrel``{\<lambda>n. F n (X n)})"
|
|
189 |
by (auto simp add: congruent2_def equiv_starrel_iff elim!: ultra)
|
|
190 |
|
|
191 |
lemma Ifun_star_n: "star_n F \<star> star_n X = star_n (\<lambda>n. F n (X n))"
|
|
192 |
by (simp add: Ifun_def star_n_def Abs_star_inverse starrel_in_star
|
|
193 |
UN_equiv_class2 [OF equiv_starrel equiv_starrel Ifun_congruent2])
|
|
194 |
|
|
195 |
text {* Transfer tactic should remove occurrences of @{term Ifun} *}
|
|
196 |
setup {* Transfer.add_const "StarDef.Ifun" *}
|
|
197 |
|
|
198 |
lemma transfer_Ifun [transfer_intro]:
|
|
199 |
"\<lbrakk>f \<equiv> star_n F; x \<equiv> star_n X\<rbrakk> \<Longrightarrow> f \<star> x \<equiv> star_n (\<lambda>n. F n (X n))"
|
|
200 |
by (simp only: Ifun_star_n)
|
|
201 |
|
|
202 |
lemma Ifun_star_of [simp]: "star_of f \<star> star_of x = star_of (f x)"
|
|
203 |
by (transfer, rule refl)
|
|
204 |
|
|
205 |
lemma Standard_Ifun [simp]:
|
|
206 |
"\<lbrakk>f \<in> Standard; x \<in> Standard\<rbrakk> \<Longrightarrow> f \<star> x \<in> Standard"
|
|
207 |
by (auto simp add: Standard_def)
|
|
208 |
|
|
209 |
text {* Nonstandard extensions of functions *}
|
|
210 |
|
|
211 |
definition
|
|
212 |
starfun :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a star \<Rightarrow> 'b star)" ("*f* _" [80] 80) where
|
|
213 |
"starfun f == \<lambda>x. star_of f \<star> x"
|
|
214 |
|
|
215 |
definition
|
|
216 |
starfun2 :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> ('a star \<Rightarrow> 'b star \<Rightarrow> 'c star)"
|
|
217 |
("*f2* _" [80] 80) where
|
|
218 |
"starfun2 f == \<lambda>x y. star_of f \<star> x \<star> y"
|
|
219 |
|
|
220 |
declare starfun_def [transfer_unfold]
|
|
221 |
declare starfun2_def [transfer_unfold]
|
|
222 |
|
|
223 |
lemma starfun_star_n: "( *f* f) (star_n X) = star_n (\<lambda>n. f (X n))"
|
|
224 |
by (simp only: starfun_def star_of_def Ifun_star_n)
|
|
225 |
|
|
226 |
lemma starfun2_star_n:
|
|
227 |
"( *f2* f) (star_n X) (star_n Y) = star_n (\<lambda>n. f (X n) (Y n))"
|
|
228 |
by (simp only: starfun2_def star_of_def Ifun_star_n)
|
|
229 |
|
|
230 |
lemma starfun_star_of [simp]: "( *f* f) (star_of x) = star_of (f x)"
|
|
231 |
by (transfer, rule refl)
|
|
232 |
|
|
233 |
lemma starfun2_star_of [simp]: "( *f2* f) (star_of x) = *f* f x"
|
|
234 |
by (transfer, rule refl)
|
|
235 |
|
|
236 |
lemma Standard_starfun [simp]: "x \<in> Standard \<Longrightarrow> starfun f x \<in> Standard"
|
|
237 |
by (simp add: starfun_def)
|
|
238 |
|
|
239 |
lemma Standard_starfun2 [simp]:
|
|
240 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> starfun2 f x y \<in> Standard"
|
|
241 |
by (simp add: starfun2_def)
|
|
242 |
|
|
243 |
lemma Standard_starfun_iff:
|
|
244 |
assumes inj: "\<And>x y. f x = f y \<Longrightarrow> x = y"
|
|
245 |
shows "(starfun f x \<in> Standard) = (x \<in> Standard)"
|
|
246 |
proof
|
|
247 |
assume "x \<in> Standard"
|
|
248 |
thus "starfun f x \<in> Standard" by simp
|
|
249 |
next
|
|
250 |
have inj': "\<And>x y. starfun f x = starfun f y \<Longrightarrow> x = y"
|
|
251 |
using inj by transfer
|
|
252 |
assume "starfun f x \<in> Standard"
|
|
253 |
then obtain b where b: "starfun f x = star_of b"
|
|
254 |
unfolding Standard_def ..
|
|
255 |
hence "\<exists>x. starfun f x = star_of b" ..
|
|
256 |
hence "\<exists>a. f a = b" by transfer
|
|
257 |
then obtain a where "f a = b" ..
|
|
258 |
hence "starfun f (star_of a) = star_of b" by transfer
|
|
259 |
with b have "starfun f x = starfun f (star_of a)" by simp
|
|
260 |
hence "x = star_of a" by (rule inj')
|
|
261 |
thus "x \<in> Standard"
|
|
262 |
unfolding Standard_def by auto
|
|
263 |
qed
|
|
264 |
|
|
265 |
lemma Standard_starfun2_iff:
|
|
266 |
assumes inj: "\<And>a b a' b'. f a b = f a' b' \<Longrightarrow> a = a' \<and> b = b'"
|
|
267 |
shows "(starfun2 f x y \<in> Standard) = (x \<in> Standard \<and> y \<in> Standard)"
|
|
268 |
proof
|
|
269 |
assume "x \<in> Standard \<and> y \<in> Standard"
|
|
270 |
thus "starfun2 f x y \<in> Standard" by simp
|
|
271 |
next
|
|
272 |
have inj': "\<And>x y z w. starfun2 f x y = starfun2 f z w \<Longrightarrow> x = z \<and> y = w"
|
|
273 |
using inj by transfer
|
|
274 |
assume "starfun2 f x y \<in> Standard"
|
|
275 |
then obtain c where c: "starfun2 f x y = star_of c"
|
|
276 |
unfolding Standard_def ..
|
|
277 |
hence "\<exists>x y. starfun2 f x y = star_of c" by auto
|
|
278 |
hence "\<exists>a b. f a b = c" by transfer
|
|
279 |
then obtain a b where "f a b = c" by auto
|
|
280 |
hence "starfun2 f (star_of a) (star_of b) = star_of c"
|
|
281 |
by transfer
|
|
282 |
with c have "starfun2 f x y = starfun2 f (star_of a) (star_of b)"
|
|
283 |
by simp
|
|
284 |
hence "x = star_of a \<and> y = star_of b"
|
|
285 |
by (rule inj')
|
|
286 |
thus "x \<in> Standard \<and> y \<in> Standard"
|
|
287 |
unfolding Standard_def by auto
|
|
288 |
qed
|
|
289 |
|
|
290 |
|
|
291 |
subsection {* Internal predicates *}
|
|
292 |
|
|
293 |
definition unstar :: "bool star \<Rightarrow> bool" where
|
|
294 |
[code func del]: "unstar b \<longleftrightarrow> b = star_of True"
|
|
295 |
|
|
296 |
lemma unstar_star_n: "unstar (star_n P) = ({n. P n} \<in> \<U>)"
|
|
297 |
by (simp add: unstar_def star_of_def star_n_eq_iff)
|
|
298 |
|
|
299 |
lemma unstar_star_of [simp]: "unstar (star_of p) = p"
|
|
300 |
by (simp add: unstar_def star_of_inject)
|
|
301 |
|
|
302 |
text {* Transfer tactic should remove occurrences of @{term unstar} *}
|
|
303 |
setup {* Transfer.add_const "StarDef.unstar" *}
|
|
304 |
|
|
305 |
lemma transfer_unstar [transfer_intro]:
|
|
306 |
"p \<equiv> star_n P \<Longrightarrow> unstar p \<equiv> {n. P n} \<in> \<U>"
|
|
307 |
by (simp only: unstar_star_n)
|
|
308 |
|
|
309 |
definition
|
|
310 |
starP :: "('a \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> bool" ("*p* _" [80] 80) where
|
|
311 |
"*p* P = (\<lambda>x. unstar (star_of P \<star> x))"
|
|
312 |
|
|
313 |
definition
|
|
314 |
starP2 :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> 'b star \<Rightarrow> bool" ("*p2* _" [80] 80) where
|
|
315 |
"*p2* P = (\<lambda>x y. unstar (star_of P \<star> x \<star> y))"
|
|
316 |
|
|
317 |
declare starP_def [transfer_unfold]
|
|
318 |
declare starP2_def [transfer_unfold]
|
|
319 |
|
|
320 |
lemma starP_star_n: "( *p* P) (star_n X) = ({n. P (X n)} \<in> \<U>)"
|
|
321 |
by (simp only: starP_def star_of_def Ifun_star_n unstar_star_n)
|
|
322 |
|
|
323 |
lemma starP2_star_n:
|
|
324 |
"( *p2* P) (star_n X) (star_n Y) = ({n. P (X n) (Y n)} \<in> \<U>)"
|
|
325 |
by (simp only: starP2_def star_of_def Ifun_star_n unstar_star_n)
|
|
326 |
|
|
327 |
lemma starP_star_of [simp]: "( *p* P) (star_of x) = P x"
|
|
328 |
by (transfer, rule refl)
|
|
329 |
|
|
330 |
lemma starP2_star_of [simp]: "( *p2* P) (star_of x) = *p* P x"
|
|
331 |
by (transfer, rule refl)
|
|
332 |
|
|
333 |
|
|
334 |
subsection {* Internal sets *}
|
|
335 |
|
|
336 |
definition
|
|
337 |
Iset :: "'a set star \<Rightarrow> 'a star set" where
|
|
338 |
"Iset A = {x. ( *p2* op \<in>) x A}"
|
|
339 |
|
|
340 |
lemma Iset_star_n:
|
|
341 |
"(star_n X \<in> Iset (star_n A)) = ({n. X n \<in> A n} \<in> \<U>)"
|
|
342 |
by (simp add: Iset_def starP2_star_n)
|
|
343 |
|
|
344 |
text {* Transfer tactic should remove occurrences of @{term Iset} *}
|
|
345 |
setup {* Transfer.add_const "StarDef.Iset" *}
|
|
346 |
|
|
347 |
lemma transfer_mem [transfer_intro]:
|
|
348 |
"\<lbrakk>x \<equiv> star_n X; a \<equiv> Iset (star_n A)\<rbrakk>
|
|
349 |
\<Longrightarrow> x \<in> a \<equiv> {n. X n \<in> A n} \<in> \<U>"
|
|
350 |
by (simp only: Iset_star_n)
|
|
351 |
|
|
352 |
lemma transfer_Collect [transfer_intro]:
|
|
353 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk>
|
|
354 |
\<Longrightarrow> Collect p \<equiv> Iset (star_n (\<lambda>n. Collect (P n)))"
|
|
355 |
by (simp add: atomize_eq expand_set_eq all_star_eq Iset_star_n)
|
|
356 |
|
|
357 |
lemma transfer_set_eq [transfer_intro]:
|
|
358 |
"\<lbrakk>a \<equiv> Iset (star_n A); b \<equiv> Iset (star_n B)\<rbrakk>
|
|
359 |
\<Longrightarrow> a = b \<equiv> {n. A n = B n} \<in> \<U>"
|
|
360 |
by (simp only: expand_set_eq transfer_all transfer_iff transfer_mem)
|
|
361 |
|
|
362 |
lemma transfer_ball [transfer_intro]:
|
|
363 |
"\<lbrakk>a \<equiv> Iset (star_n A); \<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk>
|
|
364 |
\<Longrightarrow> \<forall>x\<in>a. p x \<equiv> {n. \<forall>x\<in>A n. P n x} \<in> \<U>"
|
|
365 |
by (simp only: Ball_def transfer_all transfer_imp transfer_mem)
|
|
366 |
|
|
367 |
lemma transfer_bex [transfer_intro]:
|
|
368 |
"\<lbrakk>a \<equiv> Iset (star_n A); \<And>X. p (star_n X) \<equiv> {n. P n (X n)} \<in> \<U>\<rbrakk>
|
|
369 |
\<Longrightarrow> \<exists>x\<in>a. p x \<equiv> {n. \<exists>x\<in>A n. P n x} \<in> \<U>"
|
|
370 |
by (simp only: Bex_def transfer_ex transfer_conj transfer_mem)
|
|
371 |
|
|
372 |
lemma transfer_Iset [transfer_intro]:
|
|
373 |
"\<lbrakk>a \<equiv> star_n A\<rbrakk> \<Longrightarrow> Iset a \<equiv> Iset (star_n (\<lambda>n. A n))"
|
|
374 |
by simp
|
|
375 |
|
|
376 |
text {* Nonstandard extensions of sets. *}
|
|
377 |
|
|
378 |
definition
|
|
379 |
starset :: "'a set \<Rightarrow> 'a star set" ("*s* _" [80] 80) where
|
|
380 |
"starset A = Iset (star_of A)"
|
|
381 |
|
|
382 |
declare starset_def [transfer_unfold]
|
|
383 |
|
|
384 |
lemma starset_mem: "(star_of x \<in> *s* A) = (x \<in> A)"
|
|
385 |
by (transfer, rule refl)
|
|
386 |
|
|
387 |
lemma starset_UNIV: "*s* (UNIV::'a set) = (UNIV::'a star set)"
|
|
388 |
by (transfer UNIV_def, rule refl)
|
|
389 |
|
|
390 |
lemma starset_empty: "*s* {} = {}"
|
|
391 |
by (transfer empty_def, rule refl)
|
|
392 |
|
|
393 |
lemma starset_insert: "*s* (insert x A) = insert (star_of x) ( *s* A)"
|
|
394 |
by (transfer insert_def Un_def, rule refl)
|
|
395 |
|
|
396 |
lemma starset_Un: "*s* (A \<union> B) = *s* A \<union> *s* B"
|
|
397 |
by (transfer Un_def, rule refl)
|
|
398 |
|
|
399 |
lemma starset_Int: "*s* (A \<inter> B) = *s* A \<inter> *s* B"
|
|
400 |
by (transfer Int_def, rule refl)
|
|
401 |
|
|
402 |
lemma starset_Compl: "*s* -A = -( *s* A)"
|
|
403 |
by (transfer Compl_eq, rule refl)
|
|
404 |
|
|
405 |
lemma starset_diff: "*s* (A - B) = *s* A - *s* B"
|
|
406 |
by (transfer set_diff_eq, rule refl)
|
|
407 |
|
|
408 |
lemma starset_image: "*s* (f ` A) = ( *f* f) ` ( *s* A)"
|
|
409 |
by (transfer image_def, rule refl)
|
|
410 |
|
|
411 |
lemma starset_vimage: "*s* (f -` A) = ( *f* f) -` ( *s* A)"
|
|
412 |
by (transfer vimage_def, rule refl)
|
|
413 |
|
|
414 |
lemma starset_subset: "( *s* A \<subseteq> *s* B) = (A \<subseteq> B)"
|
|
415 |
by (transfer subset_eq, rule refl)
|
|
416 |
|
|
417 |
lemma starset_eq: "( *s* A = *s* B) = (A = B)"
|
|
418 |
by (transfer, rule refl)
|
|
419 |
|
|
420 |
lemmas starset_simps [simp] =
|
|
421 |
starset_mem starset_UNIV
|
|
422 |
starset_empty starset_insert
|
|
423 |
starset_Un starset_Int
|
|
424 |
starset_Compl starset_diff
|
|
425 |
starset_image starset_vimage
|
|
426 |
starset_subset starset_eq
|
|
427 |
|
|
428 |
|
|
429 |
subsection {* Syntactic classes *}
|
|
430 |
|
|
431 |
instantiation star :: (zero) zero
|
|
432 |
begin
|
|
433 |
|
|
434 |
definition
|
|
435 |
star_zero_def [code func del]: "0 \<equiv> star_of 0"
|
|
436 |
|
|
437 |
instance ..
|
|
438 |
|
|
439 |
end
|
|
440 |
|
|
441 |
instantiation star :: (one) one
|
|
442 |
begin
|
|
443 |
|
|
444 |
definition
|
|
445 |
star_one_def [code func del]: "1 \<equiv> star_of 1"
|
|
446 |
|
|
447 |
instance ..
|
|
448 |
|
|
449 |
end
|
|
450 |
|
|
451 |
instantiation star :: (plus) plus
|
|
452 |
begin
|
|
453 |
|
|
454 |
definition
|
|
455 |
star_add_def [code func del]: "(op +) \<equiv> *f2* (op +)"
|
|
456 |
|
|
457 |
instance ..
|
|
458 |
|
|
459 |
end
|
|
460 |
|
|
461 |
instantiation star :: (times) times
|
|
462 |
begin
|
|
463 |
|
|
464 |
definition
|
|
465 |
star_mult_def [code func del]: "(op *) \<equiv> *f2* (op *)"
|
|
466 |
|
|
467 |
instance ..
|
|
468 |
|
|
469 |
end
|
|
470 |
|
|
471 |
instantiation star :: (uminus) uminus
|
|
472 |
begin
|
|
473 |
|
|
474 |
definition
|
|
475 |
star_minus_def [code func del]: "uminus \<equiv> *f* uminus"
|
|
476 |
|
|
477 |
instance ..
|
|
478 |
|
|
479 |
end
|
|
480 |
|
|
481 |
instantiation star :: (minus) minus
|
|
482 |
begin
|
|
483 |
|
|
484 |
definition
|
|
485 |
star_diff_def [code func del]: "(op -) \<equiv> *f2* (op -)"
|
|
486 |
|
|
487 |
instance ..
|
|
488 |
|
|
489 |
end
|
|
490 |
|
|
491 |
instantiation star :: (abs) abs
|
|
492 |
begin
|
|
493 |
|
|
494 |
definition
|
|
495 |
star_abs_def: "abs \<equiv> *f* abs"
|
|
496 |
|
|
497 |
instance ..
|
|
498 |
|
|
499 |
end
|
|
500 |
|
|
501 |
instantiation star :: (sgn) sgn
|
|
502 |
begin
|
|
503 |
|
|
504 |
definition
|
|
505 |
star_sgn_def: "sgn \<equiv> *f* sgn"
|
|
506 |
|
|
507 |
instance ..
|
|
508 |
|
|
509 |
end
|
|
510 |
|
|
511 |
instantiation star :: (inverse) inverse
|
|
512 |
begin
|
|
513 |
|
|
514 |
definition
|
|
515 |
star_divide_def: "(op /) \<equiv> *f2* (op /)"
|
|
516 |
|
|
517 |
definition
|
|
518 |
star_inverse_def: "inverse \<equiv> *f* inverse"
|
|
519 |
|
|
520 |
instance ..
|
|
521 |
|
|
522 |
end
|
|
523 |
|
|
524 |
instantiation star :: (number) number
|
|
525 |
begin
|
|
526 |
|
|
527 |
definition
|
|
528 |
star_number_def: "number_of b \<equiv> star_of (number_of b)"
|
|
529 |
|
|
530 |
instance ..
|
|
531 |
|
|
532 |
end
|
|
533 |
|
|
534 |
instantiation star :: (Divides.div) Divides.div
|
|
535 |
begin
|
|
536 |
|
|
537 |
definition
|
|
538 |
star_div_def: "(op div) \<equiv> *f2* (op div)"
|
|
539 |
|
|
540 |
definition
|
|
541 |
star_mod_def: "(op mod) \<equiv> *f2* (op mod)"
|
|
542 |
|
|
543 |
instance ..
|
|
544 |
|
|
545 |
end
|
|
546 |
|
|
547 |
instantiation star :: (power) power
|
|
548 |
begin
|
|
549 |
|
|
550 |
definition
|
|
551 |
star_power_def: "(op ^) \<equiv> \<lambda>x n. ( *f* (\<lambda>x. x ^ n)) x"
|
|
552 |
|
|
553 |
instance ..
|
|
554 |
|
|
555 |
end
|
|
556 |
|
|
557 |
instantiation star :: (ord) ord
|
|
558 |
begin
|
|
559 |
|
|
560 |
definition
|
|
561 |
star_le_def: "(op \<le>) \<equiv> *p2* (op \<le>)"
|
|
562 |
|
|
563 |
definition
|
|
564 |
star_less_def: "(op <) \<equiv> *p2* (op <)"
|
|
565 |
|
|
566 |
instance ..
|
|
567 |
|
|
568 |
end
|
|
569 |
|
|
570 |
lemmas star_class_defs [transfer_unfold] =
|
|
571 |
star_zero_def star_one_def star_number_def
|
|
572 |
star_add_def star_diff_def star_minus_def
|
|
573 |
star_mult_def star_divide_def star_inverse_def
|
|
574 |
star_le_def star_less_def star_abs_def star_sgn_def
|
|
575 |
star_div_def star_mod_def star_power_def
|
|
576 |
|
|
577 |
text {* Class operations preserve standard elements *}
|
|
578 |
|
|
579 |
lemma Standard_zero: "0 \<in> Standard"
|
|
580 |
by (simp add: star_zero_def)
|
|
581 |
|
|
582 |
lemma Standard_one: "1 \<in> Standard"
|
|
583 |
by (simp add: star_one_def)
|
|
584 |
|
|
585 |
lemma Standard_number_of: "number_of b \<in> Standard"
|
|
586 |
by (simp add: star_number_def)
|
|
587 |
|
|
588 |
lemma Standard_add: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x + y \<in> Standard"
|
|
589 |
by (simp add: star_add_def)
|
|
590 |
|
|
591 |
lemma Standard_diff: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x - y \<in> Standard"
|
|
592 |
by (simp add: star_diff_def)
|
|
593 |
|
|
594 |
lemma Standard_minus: "x \<in> Standard \<Longrightarrow> - x \<in> Standard"
|
|
595 |
by (simp add: star_minus_def)
|
|
596 |
|
|
597 |
lemma Standard_mult: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x * y \<in> Standard"
|
|
598 |
by (simp add: star_mult_def)
|
|
599 |
|
|
600 |
lemma Standard_divide: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x / y \<in> Standard"
|
|
601 |
by (simp add: star_divide_def)
|
|
602 |
|
|
603 |
lemma Standard_inverse: "x \<in> Standard \<Longrightarrow> inverse x \<in> Standard"
|
|
604 |
by (simp add: star_inverse_def)
|
|
605 |
|
|
606 |
lemma Standard_abs: "x \<in> Standard \<Longrightarrow> abs x \<in> Standard"
|
|
607 |
by (simp add: star_abs_def)
|
|
608 |
|
|
609 |
lemma Standard_div: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x div y \<in> Standard"
|
|
610 |
by (simp add: star_div_def)
|
|
611 |
|
|
612 |
lemma Standard_mod: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x mod y \<in> Standard"
|
|
613 |
by (simp add: star_mod_def)
|
|
614 |
|
|
615 |
lemma Standard_power: "x \<in> Standard \<Longrightarrow> x ^ n \<in> Standard"
|
|
616 |
by (simp add: star_power_def)
|
|
617 |
|
|
618 |
lemmas Standard_simps [simp] =
|
|
619 |
Standard_zero Standard_one Standard_number_of
|
|
620 |
Standard_add Standard_diff Standard_minus
|
|
621 |
Standard_mult Standard_divide Standard_inverse
|
|
622 |
Standard_abs Standard_div Standard_mod
|
|
623 |
Standard_power
|
|
624 |
|
|
625 |
text {* @{term star_of} preserves class operations *}
|
|
626 |
|
|
627 |
lemma star_of_add: "star_of (x + y) = star_of x + star_of y"
|
|
628 |
by transfer (rule refl)
|
|
629 |
|
|
630 |
lemma star_of_diff: "star_of (x - y) = star_of x - star_of y"
|
|
631 |
by transfer (rule refl)
|
|
632 |
|
|
633 |
lemma star_of_minus: "star_of (-x) = - star_of x"
|
|
634 |
by transfer (rule refl)
|
|
635 |
|
|
636 |
lemma star_of_mult: "star_of (x * y) = star_of x * star_of y"
|
|
637 |
by transfer (rule refl)
|
|
638 |
|
|
639 |
lemma star_of_divide: "star_of (x / y) = star_of x / star_of y"
|
|
640 |
by transfer (rule refl)
|
|
641 |
|
|
642 |
lemma star_of_inverse: "star_of (inverse x) = inverse (star_of x)"
|
|
643 |
by transfer (rule refl)
|
|
644 |
|
|
645 |
lemma star_of_div: "star_of (x div y) = star_of x div star_of y"
|
|
646 |
by transfer (rule refl)
|
|
647 |
|
|
648 |
lemma star_of_mod: "star_of (x mod y) = star_of x mod star_of y"
|
|
649 |
by transfer (rule refl)
|
|
650 |
|
|
651 |
lemma star_of_power: "star_of (x ^ n) = star_of x ^ n"
|
|
652 |
by transfer (rule refl)
|
|
653 |
|
|
654 |
lemma star_of_abs: "star_of (abs x) = abs (star_of x)"
|
|
655 |
by transfer (rule refl)
|
|
656 |
|
|
657 |
text {* @{term star_of} preserves numerals *}
|
|
658 |
|
|
659 |
lemma star_of_zero: "star_of 0 = 0"
|
|
660 |
by transfer (rule refl)
|
|
661 |
|
|
662 |
lemma star_of_one: "star_of 1 = 1"
|
|
663 |
by transfer (rule refl)
|
|
664 |
|
|
665 |
lemma star_of_number_of: "star_of (number_of x) = number_of x"
|
|
666 |
by transfer (rule refl)
|
|
667 |
|
|
668 |
text {* @{term star_of} preserves orderings *}
|
|
669 |
|
|
670 |
lemma star_of_less: "(star_of x < star_of y) = (x < y)"
|
|
671 |
by transfer (rule refl)
|
|
672 |
|
|
673 |
lemma star_of_le: "(star_of x \<le> star_of y) = (x \<le> y)"
|
|
674 |
by transfer (rule refl)
|
|
675 |
|
|
676 |
lemma star_of_eq: "(star_of x = star_of y) = (x = y)"
|
|
677 |
by transfer (rule refl)
|
|
678 |
|
|
679 |
text{*As above, for 0*}
|
|
680 |
|
|
681 |
lemmas star_of_0_less = star_of_less [of 0, simplified star_of_zero]
|
|
682 |
lemmas star_of_0_le = star_of_le [of 0, simplified star_of_zero]
|
|
683 |
lemmas star_of_0_eq = star_of_eq [of 0, simplified star_of_zero]
|
|
684 |
|
|
685 |
lemmas star_of_less_0 = star_of_less [of _ 0, simplified star_of_zero]
|
|
686 |
lemmas star_of_le_0 = star_of_le [of _ 0, simplified star_of_zero]
|
|
687 |
lemmas star_of_eq_0 = star_of_eq [of _ 0, simplified star_of_zero]
|
|
688 |
|
|
689 |
text{*As above, for 1*}
|
|
690 |
|
|
691 |
lemmas star_of_1_less = star_of_less [of 1, simplified star_of_one]
|
|
692 |
lemmas star_of_1_le = star_of_le [of 1, simplified star_of_one]
|
|
693 |
lemmas star_of_1_eq = star_of_eq [of 1, simplified star_of_one]
|
|
694 |
|
|
695 |
lemmas star_of_less_1 = star_of_less [of _ 1, simplified star_of_one]
|
|
696 |
lemmas star_of_le_1 = star_of_le [of _ 1, simplified star_of_one]
|
|
697 |
lemmas star_of_eq_1 = star_of_eq [of _ 1, simplified star_of_one]
|
|
698 |
|
|
699 |
text{*As above, for numerals*}
|
|
700 |
|
|
701 |
lemmas star_of_number_less =
|
|
702 |
star_of_less [of "number_of w", standard, simplified star_of_number_of]
|
|
703 |
lemmas star_of_number_le =
|
|
704 |
star_of_le [of "number_of w", standard, simplified star_of_number_of]
|
|
705 |
lemmas star_of_number_eq =
|
|
706 |
star_of_eq [of "number_of w", standard, simplified star_of_number_of]
|
|
707 |
|
|
708 |
lemmas star_of_less_number =
|
|
709 |
star_of_less [of _ "number_of w", standard, simplified star_of_number_of]
|
|
710 |
lemmas star_of_le_number =
|
|
711 |
star_of_le [of _ "number_of w", standard, simplified star_of_number_of]
|
|
712 |
lemmas star_of_eq_number =
|
|
713 |
star_of_eq [of _ "number_of w", standard, simplified star_of_number_of]
|
|
714 |
|
|
715 |
lemmas star_of_simps [simp] =
|
|
716 |
star_of_add star_of_diff star_of_minus
|
|
717 |
star_of_mult star_of_divide star_of_inverse
|
|
718 |
star_of_div star_of_mod
|
|
719 |
star_of_power star_of_abs
|
|
720 |
star_of_zero star_of_one star_of_number_of
|
|
721 |
star_of_less star_of_le star_of_eq
|
|
722 |
star_of_0_less star_of_0_le star_of_0_eq
|
|
723 |
star_of_less_0 star_of_le_0 star_of_eq_0
|
|
724 |
star_of_1_less star_of_1_le star_of_1_eq
|
|
725 |
star_of_less_1 star_of_le_1 star_of_eq_1
|
|
726 |
star_of_number_less star_of_number_le star_of_number_eq
|
|
727 |
star_of_less_number star_of_le_number star_of_eq_number
|
|
728 |
|
|
729 |
subsection {* Ordering and lattice classes *}
|
|
730 |
|
|
731 |
instance star :: (order) order
|
|
732 |
apply (intro_classes)
|
|
733 |
apply (transfer, rule order_less_le)
|
|
734 |
apply (transfer, rule order_refl)
|
|
735 |
apply (transfer, erule (1) order_trans)
|
|
736 |
apply (transfer, erule (1) order_antisym)
|
|
737 |
done
|
|
738 |
|
|
739 |
instantiation star :: (lower_semilattice) lower_semilattice
|
|
740 |
begin
|
|
741 |
|
|
742 |
definition
|
|
743 |
star_inf_def [transfer_unfold]: "inf \<equiv> *f2* inf"
|
|
744 |
|
|
745 |
instance
|
|
746 |
by default (transfer star_inf_def, auto)+
|
|
747 |
|
|
748 |
end
|
|
749 |
|
|
750 |
instantiation star :: (upper_semilattice) upper_semilattice
|
|
751 |
begin
|
|
752 |
|
|
753 |
definition
|
|
754 |
star_sup_def [transfer_unfold]: "sup \<equiv> *f2* sup"
|
|
755 |
|
|
756 |
instance
|
|
757 |
by default (transfer star_sup_def, auto)+
|
|
758 |
|
|
759 |
end
|
|
760 |
|
|
761 |
instance star :: (lattice) lattice ..
|
|
762 |
|
|
763 |
instance star :: (distrib_lattice) distrib_lattice
|
|
764 |
by default (transfer, auto simp add: sup_inf_distrib1)
|
|
765 |
|
|
766 |
lemma Standard_inf [simp]:
|
|
767 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> inf x y \<in> Standard"
|
|
768 |
by (simp add: star_inf_def)
|
|
769 |
|
|
770 |
lemma Standard_sup [simp]:
|
|
771 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> sup x y \<in> Standard"
|
|
772 |
by (simp add: star_sup_def)
|
|
773 |
|
|
774 |
lemma star_of_inf [simp]: "star_of (inf x y) = inf (star_of x) (star_of y)"
|
|
775 |
by transfer (rule refl)
|
|
776 |
|
|
777 |
lemma star_of_sup [simp]: "star_of (sup x y) = sup (star_of x) (star_of y)"
|
|
778 |
by transfer (rule refl)
|
|
779 |
|
|
780 |
instance star :: (linorder) linorder
|
|
781 |
by (intro_classes, transfer, rule linorder_linear)
|
|
782 |
|
|
783 |
lemma star_max_def [transfer_unfold]: "max = *f2* max"
|
|
784 |
apply (rule ext, rule ext)
|
|
785 |
apply (unfold max_def, transfer, fold max_def)
|
|
786 |
apply (rule refl)
|
|
787 |
done
|
|
788 |
|
|
789 |
lemma star_min_def [transfer_unfold]: "min = *f2* min"
|
|
790 |
apply (rule ext, rule ext)
|
|
791 |
apply (unfold min_def, transfer, fold min_def)
|
|
792 |
apply (rule refl)
|
|
793 |
done
|
|
794 |
|
|
795 |
lemma Standard_max [simp]:
|
|
796 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> max x y \<in> Standard"
|
|
797 |
by (simp add: star_max_def)
|
|
798 |
|
|
799 |
lemma Standard_min [simp]:
|
|
800 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> min x y \<in> Standard"
|
|
801 |
by (simp add: star_min_def)
|
|
802 |
|
|
803 |
lemma star_of_max [simp]: "star_of (max x y) = max (star_of x) (star_of y)"
|
|
804 |
by transfer (rule refl)
|
|
805 |
|
|
806 |
lemma star_of_min [simp]: "star_of (min x y) = min (star_of x) (star_of y)"
|
|
807 |
by transfer (rule refl)
|
|
808 |
|
|
809 |
|
|
810 |
subsection {* Ordered group classes *}
|
|
811 |
|
|
812 |
instance star :: (semigroup_add) semigroup_add
|
|
813 |
by (intro_classes, transfer, rule add_assoc)
|
|
814 |
|
|
815 |
instance star :: (ab_semigroup_add) ab_semigroup_add
|
|
816 |
by (intro_classes, transfer, rule add_commute)
|
|
817 |
|
|
818 |
instance star :: (semigroup_mult) semigroup_mult
|
|
819 |
by (intro_classes, transfer, rule mult_assoc)
|
|
820 |
|
|
821 |
instance star :: (ab_semigroup_mult) ab_semigroup_mult
|
|
822 |
by (intro_classes, transfer, rule mult_commute)
|
|
823 |
|
|
824 |
instance star :: (comm_monoid_add) comm_monoid_add
|
|
825 |
by (intro_classes, transfer, rule comm_monoid_add_class.zero_plus.add_0)
|
|
826 |
|
|
827 |
instance star :: (monoid_mult) monoid_mult
|
|
828 |
apply (intro_classes)
|
|
829 |
apply (transfer, rule mult_1_left)
|
|
830 |
apply (transfer, rule mult_1_right)
|
|
831 |
done
|
|
832 |
|
|
833 |
instance star :: (comm_monoid_mult) comm_monoid_mult
|
|
834 |
by (intro_classes, transfer, rule mult_1)
|
|
835 |
|
|
836 |
instance star :: (cancel_semigroup_add) cancel_semigroup_add
|
|
837 |
apply (intro_classes)
|
|
838 |
apply (transfer, erule add_left_imp_eq)
|
|
839 |
apply (transfer, erule add_right_imp_eq)
|
|
840 |
done
|
|
841 |
|
|
842 |
instance star :: (cancel_ab_semigroup_add) cancel_ab_semigroup_add
|
|
843 |
by (intro_classes, transfer, rule add_imp_eq)
|
|
844 |
|
|
845 |
instance star :: (ab_group_add) ab_group_add
|
|
846 |
apply (intro_classes)
|
|
847 |
apply (transfer, rule left_minus)
|
|
848 |
apply (transfer, rule diff_minus)
|
|
849 |
done
|
|
850 |
|
|
851 |
instance star :: (pordered_ab_semigroup_add) pordered_ab_semigroup_add
|
|
852 |
by (intro_classes, transfer, rule add_left_mono)
|
|
853 |
|
|
854 |
instance star :: (pordered_cancel_ab_semigroup_add) pordered_cancel_ab_semigroup_add ..
|
|
855 |
|
|
856 |
instance star :: (pordered_ab_semigroup_add_imp_le) pordered_ab_semigroup_add_imp_le
|
|
857 |
by (intro_classes, transfer, rule add_le_imp_le_left)
|
|
858 |
|
|
859 |
instance star :: (pordered_comm_monoid_add) pordered_comm_monoid_add ..
|
|
860 |
instance star :: (pordered_ab_group_add) pordered_ab_group_add ..
|
|
861 |
|
|
862 |
instance star :: (pordered_ab_group_add_abs) pordered_ab_group_add_abs
|
|
863 |
by intro_classes (transfer,
|
|
864 |
simp add: abs_ge_self abs_leI abs_triangle_ineq)+
|
|
865 |
|
|
866 |
instance star :: (ordered_cancel_ab_semigroup_add) ordered_cancel_ab_semigroup_add ..
|
|
867 |
instance star :: (lordered_ab_group_add_meet) lordered_ab_group_add_meet ..
|
|
868 |
instance star :: (lordered_ab_group_add_meet) lordered_ab_group_add_meet ..
|
|
869 |
instance star :: (lordered_ab_group_add) lordered_ab_group_add ..
|
|
870 |
|
|
871 |
instance star :: (lordered_ab_group_add_abs) lordered_ab_group_add_abs
|
|
872 |
by (intro_classes, transfer, rule abs_lattice)
|
|
873 |
|
|
874 |
subsection {* Ring and field classes *}
|
|
875 |
|
|
876 |
instance star :: (semiring) semiring
|
|
877 |
apply (intro_classes)
|
|
878 |
apply (transfer, rule left_distrib)
|
|
879 |
apply (transfer, rule right_distrib)
|
|
880 |
done
|
|
881 |
|
|
882 |
instance star :: (semiring_0) semiring_0
|
|
883 |
by intro_classes (transfer, simp)+
|
|
884 |
|
|
885 |
instance star :: (semiring_0_cancel) semiring_0_cancel ..
|
|
886 |
|
|
887 |
instance star :: (comm_semiring) comm_semiring
|
|
888 |
by (intro_classes, transfer, rule left_distrib)
|
|
889 |
|
|
890 |
instance star :: (comm_semiring_0) comm_semiring_0 ..
|
|
891 |
instance star :: (comm_semiring_0_cancel) comm_semiring_0_cancel ..
|
|
892 |
|
|
893 |
instance star :: (zero_neq_one) zero_neq_one
|
|
894 |
by (intro_classes, transfer, rule zero_neq_one)
|
|
895 |
|
|
896 |
instance star :: (semiring_1) semiring_1 ..
|
|
897 |
instance star :: (comm_semiring_1) comm_semiring_1 ..
|
|
898 |
|
|
899 |
instance star :: (no_zero_divisors) no_zero_divisors
|
|
900 |
by (intro_classes, transfer, rule no_zero_divisors)
|
|
901 |
|
|
902 |
instance star :: (semiring_1_cancel) semiring_1_cancel ..
|
|
903 |
instance star :: (comm_semiring_1_cancel) comm_semiring_1_cancel ..
|
|
904 |
instance star :: (ring) ring ..
|
|
905 |
instance star :: (comm_ring) comm_ring ..
|
|
906 |
instance star :: (ring_1) ring_1 ..
|
|
907 |
instance star :: (comm_ring_1) comm_ring_1 ..
|
|
908 |
instance star :: (ring_no_zero_divisors) ring_no_zero_divisors ..
|
|
909 |
instance star :: (ring_1_no_zero_divisors) ring_1_no_zero_divisors ..
|
|
910 |
instance star :: (idom) idom ..
|
|
911 |
|
|
912 |
instance star :: (division_ring) division_ring
|
|
913 |
apply (intro_classes)
|
|
914 |
apply (transfer, erule left_inverse)
|
|
915 |
apply (transfer, erule right_inverse)
|
|
916 |
done
|
|
917 |
|
|
918 |
instance star :: (field) field
|
|
919 |
apply (intro_classes)
|
|
920 |
apply (transfer, erule left_inverse)
|
|
921 |
apply (transfer, rule divide_inverse)
|
|
922 |
done
|
|
923 |
|
|
924 |
instance star :: (division_by_zero) division_by_zero
|
|
925 |
by (intro_classes, transfer, rule inverse_zero)
|
|
926 |
|
|
927 |
instance star :: (pordered_semiring) pordered_semiring
|
|
928 |
apply (intro_classes)
|
|
929 |
apply (transfer, erule (1) mult_left_mono)
|
|
930 |
apply (transfer, erule (1) mult_right_mono)
|
|
931 |
done
|
|
932 |
|
|
933 |
instance star :: (pordered_cancel_semiring) pordered_cancel_semiring ..
|
|
934 |
|
|
935 |
instance star :: (ordered_semiring_strict) ordered_semiring_strict
|
|
936 |
apply (intro_classes)
|
|
937 |
apply (transfer, erule (1) mult_strict_left_mono)
|
|
938 |
apply (transfer, erule (1) mult_strict_right_mono)
|
|
939 |
done
|
|
940 |
|
|
941 |
instance star :: (pordered_comm_semiring) pordered_comm_semiring
|
|
942 |
by (intro_classes, transfer, rule mult_mono1_class.less_eq_less_times_zero.mult_mono1)
|
|
943 |
|
|
944 |
instance star :: (pordered_cancel_comm_semiring) pordered_cancel_comm_semiring ..
|
|
945 |
|
|
946 |
instance star :: (ordered_comm_semiring_strict) ordered_comm_semiring_strict
|
|
947 |
by (intro_classes, transfer, rule ordered_comm_semiring_strict_class.plus_less_eq_less_zero_times.mult_strict_left_mono_comm)
|
|
948 |
|
|
949 |
instance star :: (pordered_ring) pordered_ring ..
|
|
950 |
instance star :: (pordered_ring_abs) pordered_ring_abs
|
|
951 |
by intro_classes (transfer, rule abs_eq_mult)
|
|
952 |
instance star :: (lordered_ring) lordered_ring ..
|
|
953 |
|
|
954 |
instance star :: (abs_if) abs_if
|
|
955 |
by (intro_classes, transfer, rule abs_if)
|
|
956 |
|
|
957 |
instance star :: (sgn_if) sgn_if
|
|
958 |
by (intro_classes, transfer, rule sgn_if)
|
|
959 |
|
|
960 |
instance star :: (ordered_ring_strict) ordered_ring_strict ..
|
|
961 |
instance star :: (pordered_comm_ring) pordered_comm_ring ..
|
|
962 |
|
|
963 |
instance star :: (ordered_semidom) ordered_semidom
|
|
964 |
by (intro_classes, transfer, rule zero_less_one)
|
|
965 |
|
|
966 |
instance star :: (ordered_idom) ordered_idom ..
|
|
967 |
instance star :: (ordered_field) ordered_field ..
|
|
968 |
|
|
969 |
subsection {* Power classes *}
|
|
970 |
|
|
971 |
text {*
|
|
972 |
Proving the class axiom @{thm [source] power_Suc} for type
|
|
973 |
@{typ "'a star"} is a little tricky, because it quantifies
|
|
974 |
over values of type @{typ nat}. The transfer principle does
|
|
975 |
not handle quantification over non-star types in general,
|
|
976 |
but we can work around this by fixing an arbitrary @{typ nat}
|
|
977 |
value, and then applying the transfer principle.
|
|
978 |
*}
|
|
979 |
|
|
980 |
instance star :: (recpower) recpower
|
|
981 |
proof
|
|
982 |
show "\<And>a::'a star. a ^ 0 = 1"
|
|
983 |
by transfer (rule power_0)
|
|
984 |
next
|
|
985 |
fix n show "\<And>a::'a star. a ^ Suc n = a * a ^ n"
|
|
986 |
by transfer (rule power_Suc)
|
|
987 |
qed
|
|
988 |
|
|
989 |
subsection {* Number classes *}
|
|
990 |
|
|
991 |
lemma star_of_nat_def [transfer_unfold]: "of_nat n = star_of (of_nat n)"
|
|
992 |
by (induct n, simp_all)
|
|
993 |
|
|
994 |
lemma Standard_of_nat [simp]: "of_nat n \<in> Standard"
|
|
995 |
by (simp add: star_of_nat_def)
|
|
996 |
|
|
997 |
lemma star_of_of_nat [simp]: "star_of (of_nat n) = of_nat n"
|
|
998 |
by transfer (rule refl)
|
|
999 |
|
|
1000 |
lemma star_of_int_def [transfer_unfold]: "of_int z = star_of (of_int z)"
|
|
1001 |
by (rule_tac z=z in int_diff_cases, simp)
|
|
1002 |
|
|
1003 |
lemma Standard_of_int [simp]: "of_int z \<in> Standard"
|
|
1004 |
by (simp add: star_of_int_def)
|
|
1005 |
|
|
1006 |
lemma star_of_of_int [simp]: "star_of (of_int z) = of_int z"
|
|
1007 |
by transfer (rule refl)
|
|
1008 |
|
|
1009 |
instance star :: (semiring_char_0) semiring_char_0
|
|
1010 |
by intro_classes (simp only: star_of_nat_def star_of_eq of_nat_eq_iff)
|
|
1011 |
|
|
1012 |
instance star :: (ring_char_0) ring_char_0 ..
|
|
1013 |
|
|
1014 |
instance star :: (number_ring) number_ring
|
|
1015 |
by (intro_classes, simp only: star_number_def star_of_int_def number_of_eq)
|
|
1016 |
|
|
1017 |
subsection {* Finite class *}
|
|
1018 |
|
|
1019 |
lemma starset_finite: "finite A \<Longrightarrow> *s* A = star_of ` A"
|
|
1020 |
by (erule finite_induct, simp_all)
|
|
1021 |
|
|
1022 |
instance star :: (finite) finite
|
|
1023 |
apply (intro_classes)
|
|
1024 |
apply (subst starset_UNIV [symmetric])
|
|
1025 |
apply (subst starset_finite [OF finite])
|
|
1026 |
apply (rule finite_imageI [OF finite])
|
|
1027 |
done
|
|
1028 |
|
|
1029 |
end
|