author | haftmann |
Sun, 16 Oct 2016 09:31:05 +0200 | |
changeset 64242 | 93c6f0da5c70 |
parent 63950 | cdc1e59aa513 |
child 64270 | bf474d719011 |
permissions | -rw-r--r-- |
62479 | 1 |
(* Title: HOL/Nonstandard_Analysis/StarDef.thy |
2 |
Author: Jacques D. Fleuriot and Brian Huffman |
|
27468 | 3 |
*) |
4 |
||
61975 | 5 |
section \<open>Construction of Star Types Using Ultrafilters\<close> |
27468 | 6 |
|
7 |
theory StarDef |
|
60036 | 8 |
imports Free_Ultrafilter |
27468 | 9 |
begin |
10 |
||
61975 | 11 |
subsection \<open>A Free Ultrafilter over the Naturals\<close> |
27468 | 12 |
|
13 |
definition |
|
60041 | 14 |
FreeUltrafilterNat :: "nat filter" ("\<U>") where |
27468 | 15 |
"\<U> = (SOME U. freeultrafilter U)" |
16 |
||
17 |
lemma freeultrafilter_FreeUltrafilterNat: "freeultrafilter \<U>" |
|
18 |
apply (unfold FreeUltrafilterNat_def) |
|
46008
c296c75f4cf4
reverted some changes for set->predicate transition, according to "hg log -u berghofe -r Isabelle2007:Isabelle2008";
wenzelm
parents:
45694
diff
changeset
|
19 |
apply (rule someI_ex) |
27468 | 20 |
apply (rule freeultrafilter_Ex) |
54580 | 21 |
apply (rule infinite_UNIV_nat) |
27468 | 22 |
done |
23 |
||
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
30198
diff
changeset
|
24 |
interpretation FreeUltrafilterNat: freeultrafilter FreeUltrafilterNat |
27468 | 25 |
by (rule freeultrafilter_FreeUltrafilterNat) |
26 |
||
61975 | 27 |
subsection \<open>Definition of \<open>star\<close> type constructor\<close> |
27468 | 28 |
|
29 |
definition |
|
30 |
starrel :: "((nat \<Rightarrow> 'a) \<times> (nat \<Rightarrow> 'a)) set" where |
|
60041 | 31 |
"starrel = {(X,Y). eventually (\<lambda>n. X n = Y n) \<U>}" |
27468 | 32 |
|
45694
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
45605
diff
changeset
|
33 |
definition "star = (UNIV :: (nat \<Rightarrow> 'a) set) // starrel" |
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
45605
diff
changeset
|
34 |
|
49834 | 35 |
typedef 'a star = "star :: (nat \<Rightarrow> 'a) set set" |
45694
4a8743618257
prefer typedef without extra definition and alternative name;
wenzelm
parents:
45605
diff
changeset
|
36 |
unfolding star_def by (auto intro: quotientI) |
27468 | 37 |
|
38 |
definition |
|
39 |
star_n :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a star" where |
|
40 |
"star_n X = Abs_star (starrel `` {X})" |
|
41 |
||
42 |
theorem star_cases [case_names star_n, cases type: star]: |
|
43 |
"(\<And>X. x = star_n X \<Longrightarrow> P) \<Longrightarrow> P" |
|
44 |
by (cases x, unfold star_n_def star_def, erule quotientE, fast) |
|
45 |
||
46 |
lemma all_star_eq: "(\<forall>x. P x) = (\<forall>X. P (star_n X))" |
|
47 |
by (auto, rule_tac x=x in star_cases, simp) |
|
48 |
||
49 |
lemma ex_star_eq: "(\<exists>x. P x) = (\<exists>X. P (star_n X))" |
|
50 |
by (auto, rule_tac x=x in star_cases, auto) |
|
51 |
||
61975 | 52 |
text \<open>Proving that @{term starrel} is an equivalence relation\<close> |
27468 | 53 |
|
60041 | 54 |
lemma starrel_iff [iff]: "((X,Y) \<in> starrel) = (eventually (\<lambda>n. X n = Y n) \<U>)" |
27468 | 55 |
by (simp add: starrel_def) |
56 |
||
57 |
lemma equiv_starrel: "equiv UNIV starrel" |
|
40815 | 58 |
proof (rule equivI) |
30198 | 59 |
show "refl starrel" by (simp add: refl_on_def) |
27468 | 60 |
show "sym starrel" by (simp add: sym_def eq_commute) |
60041 | 61 |
show "trans starrel" by (intro transI) (auto elim: eventually_elim2) |
27468 | 62 |
qed |
63 |
||
64 |
lemmas equiv_starrel_iff = |
|
65 |
eq_equiv_class_iff [OF equiv_starrel UNIV_I UNIV_I] |
|
66 |
||
67 |
lemma starrel_in_star: "starrel``{x} \<in> star" |
|
68 |
by (simp add: star_def quotientI) |
|
69 |
||
60041 | 70 |
lemma star_n_eq_iff: "(star_n X = star_n Y) = (eventually (\<lambda>n. X n = Y n) \<U>)" |
27468 | 71 |
by (simp add: star_n_def Abs_star_inject starrel_in_star equiv_starrel_iff) |
72 |
||
73 |
||
61975 | 74 |
subsection \<open>Transfer principle\<close> |
27468 | 75 |
|
61975 | 76 |
text \<open>This introduction rule starts each transfer proof.\<close> |
27468 | 77 |
lemma transfer_start: |
60041 | 78 |
"P \<equiv> eventually (\<lambda>n. Q) \<U> \<Longrightarrow> Trueprop P \<equiv> Trueprop Q" |
79 |
by (simp add: FreeUltrafilterNat.proper) |
|
27468 | 80 |
|
61975 | 81 |
text \<open>Initialize transfer tactic.\<close> |
48891 | 82 |
ML_file "transfer.ML" |
27468 | 83 |
|
61975 | 84 |
method_setup transfer = \<open> |
47432 | 85 |
Attrib.thms >> (fn ths => fn ctxt => |
86 |
SIMPLE_METHOD' (Transfer_Principle.transfer_tac ctxt ths)) |
|
61975 | 87 |
\<close> "transfer principle" |
47432 | 88 |
|
89 |
||
61975 | 90 |
text \<open>Transfer introduction rules.\<close> |
27468 | 91 |
|
92 |
lemma transfer_ex [transfer_intro]: |
|
60041 | 93 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> eventually (\<lambda>n. P n (X n)) \<U>\<rbrakk> |
94 |
\<Longrightarrow> \<exists>x::'a star. p x \<equiv> eventually (\<lambda>n. \<exists>x. P n x) \<U>" |
|
95 |
by (simp only: ex_star_eq eventually_ex) |
|
27468 | 96 |
|
97 |
lemma transfer_all [transfer_intro]: |
|
60041 | 98 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> eventually (\<lambda>n. P n (X n)) \<U>\<rbrakk> |
99 |
\<Longrightarrow> \<forall>x::'a star. p x \<equiv> eventually (\<lambda>n. \<forall>x. P n x) \<U>" |
|
100 |
by (simp only: all_star_eq FreeUltrafilterNat.eventually_all_iff) |
|
27468 | 101 |
|
102 |
lemma transfer_not [transfer_intro]: |
|
60041 | 103 |
"\<lbrakk>p \<equiv> eventually P \<U>\<rbrakk> \<Longrightarrow> \<not> p \<equiv> eventually (\<lambda>n. \<not> P n) \<U>" |
104 |
by (simp only: FreeUltrafilterNat.eventually_not_iff) |
|
27468 | 105 |
|
106 |
lemma transfer_conj [transfer_intro]: |
|
60041 | 107 |
"\<lbrakk>p \<equiv> eventually P \<U>; q \<equiv> eventually Q \<U>\<rbrakk> |
108 |
\<Longrightarrow> p \<and> q \<equiv> eventually (\<lambda>n. P n \<and> Q n) \<U>" |
|
109 |
by (simp only: eventually_conj_iff) |
|
27468 | 110 |
|
111 |
lemma transfer_disj [transfer_intro]: |
|
60041 | 112 |
"\<lbrakk>p \<equiv> eventually P \<U>; q \<equiv> eventually Q \<U>\<rbrakk> |
113 |
\<Longrightarrow> p \<or> q \<equiv> eventually (\<lambda>n. P n \<or> Q n) \<U>" |
|
114 |
by (simp only: FreeUltrafilterNat.eventually_disj_iff) |
|
27468 | 115 |
|
116 |
lemma transfer_imp [transfer_intro]: |
|
60041 | 117 |
"\<lbrakk>p \<equiv> eventually P \<U>; q \<equiv> eventually Q \<U>\<rbrakk> |
118 |
\<Longrightarrow> p \<longrightarrow> q \<equiv> eventually (\<lambda>n. P n \<longrightarrow> Q n) \<U>" |
|
119 |
by (simp only: FreeUltrafilterNat.eventually_imp_iff) |
|
27468 | 120 |
|
121 |
lemma transfer_iff [transfer_intro]: |
|
60041 | 122 |
"\<lbrakk>p \<equiv> eventually P \<U>; q \<equiv> eventually Q \<U>\<rbrakk> |
123 |
\<Longrightarrow> p = q \<equiv> eventually (\<lambda>n. P n = Q n) \<U>" |
|
124 |
by (simp only: FreeUltrafilterNat.eventually_iff_iff) |
|
27468 | 125 |
|
126 |
lemma transfer_if_bool [transfer_intro]: |
|
60041 | 127 |
"\<lbrakk>p \<equiv> eventually P \<U>; x \<equiv> eventually X \<U>; y \<equiv> eventually Y \<U>\<rbrakk> |
128 |
\<Longrightarrow> (if p then x else y) \<equiv> eventually (\<lambda>n. if P n then X n else Y n) \<U>" |
|
27468 | 129 |
by (simp only: if_bool_eq_conj transfer_conj transfer_imp transfer_not) |
130 |
||
131 |
lemma transfer_eq [transfer_intro]: |
|
60041 | 132 |
"\<lbrakk>x \<equiv> star_n X; y \<equiv> star_n Y\<rbrakk> \<Longrightarrow> x = y \<equiv> eventually (\<lambda>n. X n = Y n) \<U>" |
27468 | 133 |
by (simp only: star_n_eq_iff) |
134 |
||
135 |
lemma transfer_if [transfer_intro]: |
|
60041 | 136 |
"\<lbrakk>p \<equiv> eventually (\<lambda>n. P n) \<U>; x \<equiv> star_n X; y \<equiv> star_n Y\<rbrakk> |
27468 | 137 |
\<Longrightarrow> (if p then x else y) \<equiv> star_n (\<lambda>n. if P n then X n else Y n)" |
138 |
apply (rule eq_reflection) |
|
61810 | 139 |
apply (auto simp add: star_n_eq_iff transfer_not elim!: eventually_mono) |
27468 | 140 |
done |
141 |
||
142 |
lemma transfer_fun_eq [transfer_intro]: |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
143 |
"\<lbrakk>\<And>X. f (star_n X) = g (star_n X) |
60041 | 144 |
\<equiv> eventually (\<lambda>n. F n (X n) = G n (X n)) \<U>\<rbrakk> |
145 |
\<Longrightarrow> f = g \<equiv> eventually (\<lambda>n. F n = G n) \<U>" |
|
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
146 |
by (simp only: fun_eq_iff transfer_all) |
27468 | 147 |
|
148 |
lemma transfer_star_n [transfer_intro]: "star_n X \<equiv> star_n (\<lambda>n. X n)" |
|
149 |
by (rule reflexive) |
|
150 |
||
60041 | 151 |
lemma transfer_bool [transfer_intro]: "p \<equiv> eventually (\<lambda>n. p) \<U>" |
152 |
by (simp add: FreeUltrafilterNat.proper) |
|
27468 | 153 |
|
154 |
||
61975 | 155 |
subsection \<open>Standard elements\<close> |
27468 | 156 |
|
157 |
definition |
|
158 |
star_of :: "'a \<Rightarrow> 'a star" where |
|
159 |
"star_of x == star_n (\<lambda>n. x)" |
|
160 |
||
161 |
definition |
|
162 |
Standard :: "'a star set" where |
|
163 |
"Standard = range star_of" |
|
164 |
||
61975 | 165 |
text \<open>Transfer tactic should remove occurrences of @{term star_of}\<close> |
166 |
setup \<open>Transfer_Principle.add_const @{const_name star_of}\<close> |
|
27468 | 167 |
|
168 |
declare star_of_def [transfer_intro] |
|
169 |
||
170 |
lemma star_of_inject: "(star_of x = star_of y) = (x = y)" |
|
171 |
by (transfer, rule refl) |
|
172 |
||
173 |
lemma Standard_star_of [simp]: "star_of x \<in> Standard" |
|
174 |
by (simp add: Standard_def) |
|
175 |
||
176 |
||
61975 | 177 |
subsection \<open>Internal functions\<close> |
27468 | 178 |
|
179 |
definition |
|
180 |
Ifun :: "('a \<Rightarrow> 'b) star \<Rightarrow> 'a star \<Rightarrow> 'b star" ("_ \<star> _" [300,301] 300) where |
|
181 |
"Ifun f \<equiv> \<lambda>x. Abs_star |
|
182 |
(\<Union>F\<in>Rep_star f. \<Union>X\<in>Rep_star x. starrel``{\<lambda>n. F n (X n)})" |
|
183 |
||
184 |
lemma Ifun_congruent2: |
|
185 |
"congruent2 starrel starrel (\<lambda>F X. starrel``{\<lambda>n. F n (X n)})" |
|
60041 | 186 |
by (auto simp add: congruent2_def equiv_starrel_iff elim!: eventually_rev_mp) |
27468 | 187 |
|
188 |
lemma Ifun_star_n: "star_n F \<star> star_n X = star_n (\<lambda>n. F n (X n))" |
|
189 |
by (simp add: Ifun_def star_n_def Abs_star_inverse starrel_in_star |
|
190 |
UN_equiv_class2 [OF equiv_starrel equiv_starrel Ifun_congruent2]) |
|
191 |
||
61975 | 192 |
text \<open>Transfer tactic should remove occurrences of @{term Ifun}\<close> |
193 |
setup \<open>Transfer_Principle.add_const @{const_name Ifun}\<close> |
|
27468 | 194 |
|
195 |
lemma transfer_Ifun [transfer_intro]: |
|
196 |
"\<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))" |
|
197 |
by (simp only: Ifun_star_n) |
|
198 |
||
199 |
lemma Ifun_star_of [simp]: "star_of f \<star> star_of x = star_of (f x)" |
|
200 |
by (transfer, rule refl) |
|
201 |
||
202 |
lemma Standard_Ifun [simp]: |
|
203 |
"\<lbrakk>f \<in> Standard; x \<in> Standard\<rbrakk> \<Longrightarrow> f \<star> x \<in> Standard" |
|
204 |
by (auto simp add: Standard_def) |
|
205 |
||
61975 | 206 |
text \<open>Nonstandard extensions of functions\<close> |
27468 | 207 |
|
208 |
definition |
|
209 |
starfun :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a star \<Rightarrow> 'b star)" ("*f* _" [80] 80) where |
|
210 |
"starfun f == \<lambda>x. star_of f \<star> x" |
|
211 |
||
212 |
definition |
|
213 |
starfun2 :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> ('a star \<Rightarrow> 'b star \<Rightarrow> 'c star)" |
|
214 |
("*f2* _" [80] 80) where |
|
215 |
"starfun2 f == \<lambda>x y. star_of f \<star> x \<star> y" |
|
216 |
||
217 |
declare starfun_def [transfer_unfold] |
|
218 |
declare starfun2_def [transfer_unfold] |
|
219 |
||
220 |
lemma starfun_star_n: "( *f* f) (star_n X) = star_n (\<lambda>n. f (X n))" |
|
221 |
by (simp only: starfun_def star_of_def Ifun_star_n) |
|
222 |
||
223 |
lemma starfun2_star_n: |
|
224 |
"( *f2* f) (star_n X) (star_n Y) = star_n (\<lambda>n. f (X n) (Y n))" |
|
225 |
by (simp only: starfun2_def star_of_def Ifun_star_n) |
|
226 |
||
227 |
lemma starfun_star_of [simp]: "( *f* f) (star_of x) = star_of (f x)" |
|
228 |
by (transfer, rule refl) |
|
229 |
||
230 |
lemma starfun2_star_of [simp]: "( *f2* f) (star_of x) = *f* f x" |
|
231 |
by (transfer, rule refl) |
|
232 |
||
233 |
lemma Standard_starfun [simp]: "x \<in> Standard \<Longrightarrow> starfun f x \<in> Standard" |
|
234 |
by (simp add: starfun_def) |
|
235 |
||
236 |
lemma Standard_starfun2 [simp]: |
|
237 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> starfun2 f x y \<in> Standard" |
|
238 |
by (simp add: starfun2_def) |
|
239 |
||
240 |
lemma Standard_starfun_iff: |
|
241 |
assumes inj: "\<And>x y. f x = f y \<Longrightarrow> x = y" |
|
242 |
shows "(starfun f x \<in> Standard) = (x \<in> Standard)" |
|
243 |
proof |
|
244 |
assume "x \<in> Standard" |
|
245 |
thus "starfun f x \<in> Standard" by simp |
|
246 |
next |
|
247 |
have inj': "\<And>x y. starfun f x = starfun f y \<Longrightarrow> x = y" |
|
248 |
using inj by transfer |
|
249 |
assume "starfun f x \<in> Standard" |
|
250 |
then obtain b where b: "starfun f x = star_of b" |
|
251 |
unfolding Standard_def .. |
|
252 |
hence "\<exists>x. starfun f x = star_of b" .. |
|
253 |
hence "\<exists>a. f a = b" by transfer |
|
254 |
then obtain a where "f a = b" .. |
|
255 |
hence "starfun f (star_of a) = star_of b" by transfer |
|
256 |
with b have "starfun f x = starfun f (star_of a)" by simp |
|
257 |
hence "x = star_of a" by (rule inj') |
|
258 |
thus "x \<in> Standard" |
|
259 |
unfolding Standard_def by auto |
|
260 |
qed |
|
261 |
||
262 |
lemma Standard_starfun2_iff: |
|
263 |
assumes inj: "\<And>a b a' b'. f a b = f a' b' \<Longrightarrow> a = a' \<and> b = b'" |
|
264 |
shows "(starfun2 f x y \<in> Standard) = (x \<in> Standard \<and> y \<in> Standard)" |
|
265 |
proof |
|
266 |
assume "x \<in> Standard \<and> y \<in> Standard" |
|
267 |
thus "starfun2 f x y \<in> Standard" by simp |
|
268 |
next |
|
269 |
have inj': "\<And>x y z w. starfun2 f x y = starfun2 f z w \<Longrightarrow> x = z \<and> y = w" |
|
270 |
using inj by transfer |
|
271 |
assume "starfun2 f x y \<in> Standard" |
|
272 |
then obtain c where c: "starfun2 f x y = star_of c" |
|
273 |
unfolding Standard_def .. |
|
274 |
hence "\<exists>x y. starfun2 f x y = star_of c" by auto |
|
275 |
hence "\<exists>a b. f a b = c" by transfer |
|
276 |
then obtain a b where "f a b = c" by auto |
|
277 |
hence "starfun2 f (star_of a) (star_of b) = star_of c" |
|
278 |
by transfer |
|
279 |
with c have "starfun2 f x y = starfun2 f (star_of a) (star_of b)" |
|
280 |
by simp |
|
281 |
hence "x = star_of a \<and> y = star_of b" |
|
282 |
by (rule inj') |
|
283 |
thus "x \<in> Standard \<and> y \<in> Standard" |
|
284 |
unfolding Standard_def by auto |
|
285 |
qed |
|
286 |
||
287 |
||
61975 | 288 |
subsection \<open>Internal predicates\<close> |
27468 | 289 |
|
290 |
definition unstar :: "bool star \<Rightarrow> bool" where |
|
37765 | 291 |
"unstar b \<longleftrightarrow> b = star_of True" |
27468 | 292 |
|
60041 | 293 |
lemma unstar_star_n: "unstar (star_n P) = (eventually P \<U>)" |
27468 | 294 |
by (simp add: unstar_def star_of_def star_n_eq_iff) |
295 |
||
296 |
lemma unstar_star_of [simp]: "unstar (star_of p) = p" |
|
297 |
by (simp add: unstar_def star_of_inject) |
|
298 |
||
61975 | 299 |
text \<open>Transfer tactic should remove occurrences of @{term unstar}\<close> |
300 |
setup \<open>Transfer_Principle.add_const @{const_name unstar}\<close> |
|
27468 | 301 |
|
302 |
lemma transfer_unstar [transfer_intro]: |
|
60041 | 303 |
"p \<equiv> star_n P \<Longrightarrow> unstar p \<equiv> eventually P \<U>" |
27468 | 304 |
by (simp only: unstar_star_n) |
305 |
||
306 |
definition |
|
307 |
starP :: "('a \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> bool" ("*p* _" [80] 80) where |
|
308 |
"*p* P = (\<lambda>x. unstar (star_of P \<star> x))" |
|
309 |
||
310 |
definition |
|
311 |
starP2 :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a star \<Rightarrow> 'b star \<Rightarrow> bool" ("*p2* _" [80] 80) where |
|
312 |
"*p2* P = (\<lambda>x y. unstar (star_of P \<star> x \<star> y))" |
|
313 |
||
314 |
declare starP_def [transfer_unfold] |
|
315 |
declare starP2_def [transfer_unfold] |
|
316 |
||
60041 | 317 |
lemma starP_star_n: "( *p* P) (star_n X) = (eventually (\<lambda>n. P (X n)) \<U>)" |
27468 | 318 |
by (simp only: starP_def star_of_def Ifun_star_n unstar_star_n) |
319 |
||
320 |
lemma starP2_star_n: |
|
60041 | 321 |
"( *p2* P) (star_n X) (star_n Y) = (eventually (\<lambda>n. P (X n) (Y n)) \<U>)" |
27468 | 322 |
by (simp only: starP2_def star_of_def Ifun_star_n unstar_star_n) |
323 |
||
324 |
lemma starP_star_of [simp]: "( *p* P) (star_of x) = P x" |
|
325 |
by (transfer, rule refl) |
|
326 |
||
327 |
lemma starP2_star_of [simp]: "( *p2* P) (star_of x) = *p* P x" |
|
328 |
by (transfer, rule refl) |
|
329 |
||
330 |
||
61975 | 331 |
subsection \<open>Internal sets\<close> |
27468 | 332 |
|
333 |
definition |
|
334 |
Iset :: "'a set star \<Rightarrow> 'a star set" where |
|
335 |
"Iset A = {x. ( *p2* op \<in>) x A}" |
|
336 |
||
337 |
lemma Iset_star_n: |
|
60041 | 338 |
"(star_n X \<in> Iset (star_n A)) = (eventually (\<lambda>n. X n \<in> A n) \<U>)" |
27468 | 339 |
by (simp add: Iset_def starP2_star_n) |
340 |
||
61975 | 341 |
text \<open>Transfer tactic should remove occurrences of @{term Iset}\<close> |
342 |
setup \<open>Transfer_Principle.add_const @{const_name Iset}\<close> |
|
27468 | 343 |
|
344 |
lemma transfer_mem [transfer_intro]: |
|
345 |
"\<lbrakk>x \<equiv> star_n X; a \<equiv> Iset (star_n A)\<rbrakk> |
|
60041 | 346 |
\<Longrightarrow> x \<in> a \<equiv> eventually (\<lambda>n. X n \<in> A n) \<U>" |
27468 | 347 |
by (simp only: Iset_star_n) |
348 |
||
349 |
lemma transfer_Collect [transfer_intro]: |
|
60041 | 350 |
"\<lbrakk>\<And>X. p (star_n X) \<equiv> eventually (\<lambda>n. P n (X n)) \<U>\<rbrakk> |
27468 | 351 |
\<Longrightarrow> Collect p \<equiv> Iset (star_n (\<lambda>n. Collect (P n)))" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
352 |
by (simp add: atomize_eq set_eq_iff all_star_eq Iset_star_n) |
27468 | 353 |
|
354 |
lemma transfer_set_eq [transfer_intro]: |
|
355 |
"\<lbrakk>a \<equiv> Iset (star_n A); b \<equiv> Iset (star_n B)\<rbrakk> |
|
60041 | 356 |
\<Longrightarrow> a = b \<equiv> eventually (\<lambda>n. A n = B n) \<U>" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
357 |
by (simp only: set_eq_iff transfer_all transfer_iff transfer_mem) |
27468 | 358 |
|
359 |
lemma transfer_ball [transfer_intro]: |
|
60041 | 360 |
"\<lbrakk>a \<equiv> Iset (star_n A); \<And>X. p (star_n X) \<equiv> eventually (\<lambda>n. P n (X n)) \<U>\<rbrakk> |
361 |
\<Longrightarrow> \<forall>x\<in>a. p x \<equiv> eventually (\<lambda>n. \<forall>x\<in>A n. P n x) \<U>" |
|
27468 | 362 |
by (simp only: Ball_def transfer_all transfer_imp transfer_mem) |
363 |
||
364 |
lemma transfer_bex [transfer_intro]: |
|
60041 | 365 |
"\<lbrakk>a \<equiv> Iset (star_n A); \<And>X. p (star_n X) \<equiv> eventually (\<lambda>n. P n (X n)) \<U>\<rbrakk> |
366 |
\<Longrightarrow> \<exists>x\<in>a. p x \<equiv> eventually (\<lambda>n. \<exists>x\<in>A n. P n x) \<U>" |
|
27468 | 367 |
by (simp only: Bex_def transfer_ex transfer_conj transfer_mem) |
368 |
||
369 |
lemma transfer_Iset [transfer_intro]: |
|
370 |
"\<lbrakk>a \<equiv> star_n A\<rbrakk> \<Longrightarrow> Iset a \<equiv> Iset (star_n (\<lambda>n. A n))" |
|
371 |
by simp |
|
372 |
||
61975 | 373 |
text \<open>Nonstandard extensions of sets.\<close> |
27468 | 374 |
|
375 |
definition |
|
376 |
starset :: "'a set \<Rightarrow> 'a star set" ("*s* _" [80] 80) where |
|
377 |
"starset A = Iset (star_of A)" |
|
378 |
||
379 |
declare starset_def [transfer_unfold] |
|
380 |
||
381 |
lemma starset_mem: "(star_of x \<in> *s* A) = (x \<in> A)" |
|
382 |
by (transfer, rule refl) |
|
383 |
||
384 |
lemma starset_UNIV: "*s* (UNIV::'a set) = (UNIV::'a star set)" |
|
385 |
by (transfer UNIV_def, rule refl) |
|
386 |
||
387 |
lemma starset_empty: "*s* {} = {}" |
|
388 |
by (transfer empty_def, rule refl) |
|
389 |
||
390 |
lemma starset_insert: "*s* (insert x A) = insert (star_of x) ( *s* A)" |
|
391 |
by (transfer insert_def Un_def, rule refl) |
|
392 |
||
393 |
lemma starset_Un: "*s* (A \<union> B) = *s* A \<union> *s* B" |
|
394 |
by (transfer Un_def, rule refl) |
|
395 |
||
396 |
lemma starset_Int: "*s* (A \<inter> B) = *s* A \<inter> *s* B" |
|
397 |
by (transfer Int_def, rule refl) |
|
398 |
||
399 |
lemma starset_Compl: "*s* -A = -( *s* A)" |
|
400 |
by (transfer Compl_eq, rule refl) |
|
401 |
||
402 |
lemma starset_diff: "*s* (A - B) = *s* A - *s* B" |
|
403 |
by (transfer set_diff_eq, rule refl) |
|
404 |
||
405 |
lemma starset_image: "*s* (f ` A) = ( *f* f) ` ( *s* A)" |
|
406 |
by (transfer image_def, rule refl) |
|
407 |
||
408 |
lemma starset_vimage: "*s* (f -` A) = ( *f* f) -` ( *s* A)" |
|
409 |
by (transfer vimage_def, rule refl) |
|
410 |
||
411 |
lemma starset_subset: "( *s* A \<subseteq> *s* B) = (A \<subseteq> B)" |
|
412 |
by (transfer subset_eq, rule refl) |
|
413 |
||
414 |
lemma starset_eq: "( *s* A = *s* B) = (A = B)" |
|
415 |
by (transfer, rule refl) |
|
416 |
||
417 |
lemmas starset_simps [simp] = |
|
418 |
starset_mem starset_UNIV |
|
419 |
starset_empty starset_insert |
|
420 |
starset_Un starset_Int |
|
421 |
starset_Compl starset_diff |
|
422 |
starset_image starset_vimage |
|
423 |
starset_subset starset_eq |
|
424 |
||
425 |
||
61975 | 426 |
subsection \<open>Syntactic classes\<close> |
27468 | 427 |
|
428 |
instantiation star :: (zero) zero |
|
429 |
begin |
|
430 |
||
431 |
definition |
|
37765 | 432 |
star_zero_def: "0 \<equiv> star_of 0" |
27468 | 433 |
|
434 |
instance .. |
|
435 |
||
436 |
end |
|
437 |
||
438 |
instantiation star :: (one) one |
|
439 |
begin |
|
440 |
||
441 |
definition |
|
37765 | 442 |
star_one_def: "1 \<equiv> star_of 1" |
27468 | 443 |
|
444 |
instance .. |
|
445 |
||
446 |
end |
|
447 |
||
448 |
instantiation star :: (plus) plus |
|
449 |
begin |
|
450 |
||
451 |
definition |
|
37765 | 452 |
star_add_def: "(op +) \<equiv> *f2* (op +)" |
27468 | 453 |
|
454 |
instance .. |
|
455 |
||
456 |
end |
|
457 |
||
458 |
instantiation star :: (times) times |
|
459 |
begin |
|
460 |
||
461 |
definition |
|
37765 | 462 |
star_mult_def: "(op *) \<equiv> *f2* (op *)" |
27468 | 463 |
|
464 |
instance .. |
|
465 |
||
466 |
end |
|
467 |
||
468 |
instantiation star :: (uminus) uminus |
|
469 |
begin |
|
470 |
||
471 |
definition |
|
37765 | 472 |
star_minus_def: "uminus \<equiv> *f* uminus" |
27468 | 473 |
|
474 |
instance .. |
|
475 |
||
476 |
end |
|
477 |
||
478 |
instantiation star :: (minus) minus |
|
479 |
begin |
|
480 |
||
481 |
definition |
|
37765 | 482 |
star_diff_def: "(op -) \<equiv> *f2* (op -)" |
27468 | 483 |
|
484 |
instance .. |
|
485 |
||
486 |
end |
|
487 |
||
488 |
instantiation star :: (abs) abs |
|
489 |
begin |
|
490 |
||
491 |
definition |
|
492 |
star_abs_def: "abs \<equiv> *f* abs" |
|
493 |
||
494 |
instance .. |
|
495 |
||
496 |
end |
|
497 |
||
498 |
instantiation star :: (sgn) sgn |
|
499 |
begin |
|
500 |
||
501 |
definition |
|
502 |
star_sgn_def: "sgn \<equiv> *f* sgn" |
|
503 |
||
504 |
instance .. |
|
505 |
||
506 |
end |
|
507 |
||
60352
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
508 |
instantiation star :: (divide) divide |
27468 | 509 |
begin |
510 |
||
511 |
definition |
|
60352
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
512 |
star_divide_def: "divide \<equiv> *f2* divide" |
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
513 |
|
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
514 |
instance .. |
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
515 |
|
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
516 |
end |
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
517 |
|
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
518 |
instantiation star :: (inverse) inverse |
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
519 |
begin |
27468 | 520 |
|
521 |
definition |
|
522 |
star_inverse_def: "inverse \<equiv> *f* inverse" |
|
523 |
||
524 |
instance .. |
|
525 |
||
526 |
end |
|
527 |
||
35050
9f841f20dca6
renamed OrderedGroup to Groups; split theory Ring_and_Field into Rings Fields
haftmann
parents:
35043
diff
changeset
|
528 |
instance star :: (Rings.dvd) Rings.dvd .. |
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27468
diff
changeset
|
529 |
|
63950
cdc1e59aa513
syntactic type class for operation mod named after mod;
haftmann
parents:
63456
diff
changeset
|
530 |
instantiation star :: (modulo) modulo |
27468 | 531 |
begin |
532 |
||
533 |
definition |
|
534 |
star_mod_def: "(op mod) \<equiv> *f2* (op mod)" |
|
535 |
||
536 |
instance .. |
|
537 |
||
538 |
end |
|
539 |
||
540 |
instantiation star :: (ord) ord |
|
541 |
begin |
|
542 |
||
543 |
definition |
|
544 |
star_le_def: "(op \<le>) \<equiv> *p2* (op \<le>)" |
|
545 |
||
546 |
definition |
|
547 |
star_less_def: "(op <) \<equiv> *p2* (op <)" |
|
548 |
||
549 |
instance .. |
|
550 |
||
551 |
end |
|
552 |
||
553 |
lemmas star_class_defs [transfer_unfold] = |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
554 |
star_zero_def star_one_def |
27468 | 555 |
star_add_def star_diff_def star_minus_def |
556 |
star_mult_def star_divide_def star_inverse_def |
|
557 |
star_le_def star_less_def star_abs_def star_sgn_def |
|
60352
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
558 |
star_mod_def |
27468 | 559 |
|
61975 | 560 |
text \<open>Class operations preserve standard elements\<close> |
27468 | 561 |
|
562 |
lemma Standard_zero: "0 \<in> Standard" |
|
563 |
by (simp add: star_zero_def) |
|
564 |
||
565 |
lemma Standard_one: "1 \<in> Standard" |
|
566 |
by (simp add: star_one_def) |
|
567 |
||
568 |
lemma Standard_add: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x + y \<in> Standard" |
|
569 |
by (simp add: star_add_def) |
|
570 |
||
571 |
lemma Standard_diff: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x - y \<in> Standard" |
|
572 |
by (simp add: star_diff_def) |
|
573 |
||
574 |
lemma Standard_minus: "x \<in> Standard \<Longrightarrow> - x \<in> Standard" |
|
575 |
by (simp add: star_minus_def) |
|
576 |
||
577 |
lemma Standard_mult: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x * y \<in> Standard" |
|
578 |
by (simp add: star_mult_def) |
|
579 |
||
60429
d3d1e185cd63
uniform _ div _ as infix syntax for ring division
haftmann
parents:
60353
diff
changeset
|
580 |
lemma Standard_divide: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x / y \<in> Standard" |
27468 | 581 |
by (simp add: star_divide_def) |
582 |
||
583 |
lemma Standard_inverse: "x \<in> Standard \<Longrightarrow> inverse x \<in> Standard" |
|
584 |
by (simp add: star_inverse_def) |
|
585 |
||
61945 | 586 |
lemma Standard_abs: "x \<in> Standard \<Longrightarrow> \<bar>x\<bar> \<in> Standard" |
27468 | 587 |
by (simp add: star_abs_def) |
588 |
||
589 |
lemma Standard_mod: "\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> x mod y \<in> Standard" |
|
590 |
by (simp add: star_mod_def) |
|
591 |
||
592 |
lemmas Standard_simps [simp] = |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
593 |
Standard_zero Standard_one |
60352
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
594 |
Standard_add Standard_diff Standard_minus |
27468 | 595 |
Standard_mult Standard_divide Standard_inverse |
60352
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
596 |
Standard_abs Standard_mod |
27468 | 597 |
|
61975 | 598 |
text \<open>@{term star_of} preserves class operations\<close> |
27468 | 599 |
|
600 |
lemma star_of_add: "star_of (x + y) = star_of x + star_of y" |
|
601 |
by transfer (rule refl) |
|
602 |
||
603 |
lemma star_of_diff: "star_of (x - y) = star_of x - star_of y" |
|
604 |
by transfer (rule refl) |
|
605 |
||
606 |
lemma star_of_minus: "star_of (-x) = - star_of x" |
|
607 |
by transfer (rule refl) |
|
608 |
||
609 |
lemma star_of_mult: "star_of (x * y) = star_of x * star_of y" |
|
610 |
by transfer (rule refl) |
|
611 |
||
612 |
lemma star_of_divide: "star_of (x / y) = star_of x / star_of y" |
|
613 |
by transfer (rule refl) |
|
614 |
||
615 |
lemma star_of_inverse: "star_of (inverse x) = inverse (star_of x)" |
|
616 |
by transfer (rule refl) |
|
617 |
||
618 |
lemma star_of_mod: "star_of (x mod y) = star_of x mod star_of y" |
|
619 |
by transfer (rule refl) |
|
620 |
||
61945 | 621 |
lemma star_of_abs: "star_of \<bar>x\<bar> = \<bar>star_of x\<bar>" |
27468 | 622 |
by transfer (rule refl) |
623 |
||
61975 | 624 |
text \<open>@{term star_of} preserves numerals\<close> |
27468 | 625 |
|
626 |
lemma star_of_zero: "star_of 0 = 0" |
|
627 |
by transfer (rule refl) |
|
628 |
||
629 |
lemma star_of_one: "star_of 1 = 1" |
|
630 |
by transfer (rule refl) |
|
631 |
||
61975 | 632 |
text \<open>@{term star_of} preserves orderings\<close> |
27468 | 633 |
|
634 |
lemma star_of_less: "(star_of x < star_of y) = (x < y)" |
|
635 |
by transfer (rule refl) |
|
636 |
||
637 |
lemma star_of_le: "(star_of x \<le> star_of y) = (x \<le> y)" |
|
638 |
by transfer (rule refl) |
|
639 |
||
640 |
lemma star_of_eq: "(star_of x = star_of y) = (x = y)" |
|
641 |
by transfer (rule refl) |
|
642 |
||
61975 | 643 |
text\<open>As above, for 0\<close> |
27468 | 644 |
|
645 |
lemmas star_of_0_less = star_of_less [of 0, simplified star_of_zero] |
|
646 |
lemmas star_of_0_le = star_of_le [of 0, simplified star_of_zero] |
|
647 |
lemmas star_of_0_eq = star_of_eq [of 0, simplified star_of_zero] |
|
648 |
||
649 |
lemmas star_of_less_0 = star_of_less [of _ 0, simplified star_of_zero] |
|
650 |
lemmas star_of_le_0 = star_of_le [of _ 0, simplified star_of_zero] |
|
651 |
lemmas star_of_eq_0 = star_of_eq [of _ 0, simplified star_of_zero] |
|
652 |
||
61975 | 653 |
text\<open>As above, for 1\<close> |
27468 | 654 |
|
655 |
lemmas star_of_1_less = star_of_less [of 1, simplified star_of_one] |
|
656 |
lemmas star_of_1_le = star_of_le [of 1, simplified star_of_one] |
|
657 |
lemmas star_of_1_eq = star_of_eq [of 1, simplified star_of_one] |
|
658 |
||
659 |
lemmas star_of_less_1 = star_of_less [of _ 1, simplified star_of_one] |
|
660 |
lemmas star_of_le_1 = star_of_le [of _ 1, simplified star_of_one] |
|
661 |
lemmas star_of_eq_1 = star_of_eq [of _ 1, simplified star_of_one] |
|
662 |
||
663 |
lemmas star_of_simps [simp] = |
|
664 |
star_of_add star_of_diff star_of_minus |
|
665 |
star_of_mult star_of_divide star_of_inverse |
|
60352
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
haftmann
parents:
60041
diff
changeset
|
666 |
star_of_mod star_of_abs |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
667 |
star_of_zero star_of_one |
27468 | 668 |
star_of_less star_of_le star_of_eq |
669 |
star_of_0_less star_of_0_le star_of_0_eq |
|
670 |
star_of_less_0 star_of_le_0 star_of_eq_0 |
|
671 |
star_of_1_less star_of_1_le star_of_1_eq |
|
672 |
star_of_less_1 star_of_le_1 star_of_eq_1 |
|
673 |
||
61975 | 674 |
subsection \<open>Ordering and lattice classes\<close> |
27468 | 675 |
|
676 |
instance star :: (order) order |
|
677 |
apply (intro_classes) |
|
27682 | 678 |
apply (transfer, rule less_le_not_le) |
27468 | 679 |
apply (transfer, rule order_refl) |
680 |
apply (transfer, erule (1) order_trans) |
|
681 |
apply (transfer, erule (1) order_antisym) |
|
682 |
done |
|
683 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
684 |
instantiation star :: (semilattice_inf) semilattice_inf |
27468 | 685 |
begin |
686 |
||
687 |
definition |
|
688 |
star_inf_def [transfer_unfold]: "inf \<equiv> *f2* inf" |
|
689 |
||
690 |
instance |
|
60867 | 691 |
by (standard; transfer) auto |
27468 | 692 |
|
693 |
end |
|
694 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
695 |
instantiation star :: (semilattice_sup) semilattice_sup |
27468 | 696 |
begin |
697 |
||
698 |
definition |
|
699 |
star_sup_def [transfer_unfold]: "sup \<equiv> *f2* sup" |
|
700 |
||
701 |
instance |
|
60867 | 702 |
by (standard; transfer) auto |
27468 | 703 |
|
704 |
end |
|
705 |
||
706 |
instance star :: (lattice) lattice .. |
|
707 |
||
708 |
instance star :: (distrib_lattice) distrib_lattice |
|
60867 | 709 |
by (standard; transfer) (auto simp add: sup_inf_distrib1) |
27468 | 710 |
|
711 |
lemma Standard_inf [simp]: |
|
712 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> inf x y \<in> Standard" |
|
713 |
by (simp add: star_inf_def) |
|
714 |
||
715 |
lemma Standard_sup [simp]: |
|
716 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> sup x y \<in> Standard" |
|
717 |
by (simp add: star_sup_def) |
|
718 |
||
719 |
lemma star_of_inf [simp]: "star_of (inf x y) = inf (star_of x) (star_of y)" |
|
720 |
by transfer (rule refl) |
|
721 |
||
722 |
lemma star_of_sup [simp]: "star_of (sup x y) = sup (star_of x) (star_of y)" |
|
723 |
by transfer (rule refl) |
|
724 |
||
725 |
instance star :: (linorder) linorder |
|
726 |
by (intro_classes, transfer, rule linorder_linear) |
|
727 |
||
728 |
lemma star_max_def [transfer_unfold]: "max = *f2* max" |
|
729 |
apply (rule ext, rule ext) |
|
730 |
apply (unfold max_def, transfer, fold max_def) |
|
731 |
apply (rule refl) |
|
732 |
done |
|
733 |
||
734 |
lemma star_min_def [transfer_unfold]: "min = *f2* min" |
|
735 |
apply (rule ext, rule ext) |
|
736 |
apply (unfold min_def, transfer, fold min_def) |
|
737 |
apply (rule refl) |
|
738 |
done |
|
739 |
||
740 |
lemma Standard_max [simp]: |
|
741 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> max x y \<in> Standard" |
|
742 |
by (simp add: star_max_def) |
|
743 |
||
744 |
lemma Standard_min [simp]: |
|
745 |
"\<lbrakk>x \<in> Standard; y \<in> Standard\<rbrakk> \<Longrightarrow> min x y \<in> Standard" |
|
746 |
by (simp add: star_min_def) |
|
747 |
||
748 |
lemma star_of_max [simp]: "star_of (max x y) = max (star_of x) (star_of y)" |
|
749 |
by transfer (rule refl) |
|
750 |
||
751 |
lemma star_of_min [simp]: "star_of (min x y) = min (star_of x) (star_of y)" |
|
752 |
by transfer (rule refl) |
|
753 |
||
754 |
||
61975 | 755 |
subsection \<open>Ordered group classes\<close> |
27468 | 756 |
|
757 |
instance star :: (semigroup_add) semigroup_add |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56256
diff
changeset
|
758 |
by (intro_classes, transfer, rule add.assoc) |
27468 | 759 |
|
760 |
instance star :: (ab_semigroup_add) ab_semigroup_add |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56256
diff
changeset
|
761 |
by (intro_classes, transfer, rule add.commute) |
27468 | 762 |
|
763 |
instance star :: (semigroup_mult) semigroup_mult |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56256
diff
changeset
|
764 |
by (intro_classes, transfer, rule mult.assoc) |
27468 | 765 |
|
766 |
instance star :: (ab_semigroup_mult) ab_semigroup_mult |
|
57512
cc97b347b301
reduced name variants for assoc and commute on plus and mult
haftmann
parents:
56256
diff
changeset
|
767 |
by (intro_classes, transfer, rule mult.commute) |
27468 | 768 |
|
769 |
instance star :: (comm_monoid_add) comm_monoid_add |
|
28059 | 770 |
by (intro_classes, transfer, rule comm_monoid_add_class.add_0) |
27468 | 771 |
|
772 |
instance star :: (monoid_mult) monoid_mult |
|
773 |
apply (intro_classes) |
|
774 |
apply (transfer, rule mult_1_left) |
|
775 |
apply (transfer, rule mult_1_right) |
|
776 |
done |
|
777 |
||
60867 | 778 |
instance star :: (power) power .. |
779 |
||
27468 | 780 |
instance star :: (comm_monoid_mult) comm_monoid_mult |
781 |
by (intro_classes, transfer, rule mult_1) |
|
782 |
||
783 |
instance star :: (cancel_semigroup_add) cancel_semigroup_add |
|
784 |
apply (intro_classes) |
|
785 |
apply (transfer, erule add_left_imp_eq) |
|
786 |
apply (transfer, erule add_right_imp_eq) |
|
787 |
done |
|
788 |
||
789 |
instance star :: (cancel_ab_semigroup_add) cancel_ab_semigroup_add |
|
59815
cce82e360c2f
explicit commutative additive inverse operation;
haftmann
parents:
59680
diff
changeset
|
790 |
by intro_classes (transfer, simp add: diff_diff_eq)+ |
27468 | 791 |
|
29904 | 792 |
instance star :: (cancel_comm_monoid_add) cancel_comm_monoid_add .. |
793 |
||
27468 | 794 |
instance star :: (ab_group_add) ab_group_add |
795 |
apply (intro_classes) |
|
796 |
apply (transfer, rule left_minus) |
|
54230
b1d955791529
more simplification rules on unary and binary minus
haftmann
parents:
49962
diff
changeset
|
797 |
apply (transfer, rule diff_conv_add_uminus) |
27468 | 798 |
done |
799 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
800 |
instance star :: (ordered_ab_semigroup_add) ordered_ab_semigroup_add |
27468 | 801 |
by (intro_classes, transfer, rule add_left_mono) |
802 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
803 |
instance star :: (ordered_cancel_ab_semigroup_add) ordered_cancel_ab_semigroup_add .. |
27468 | 804 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
805 |
instance star :: (ordered_ab_semigroup_add_imp_le) ordered_ab_semigroup_add_imp_le |
27468 | 806 |
by (intro_classes, transfer, rule add_le_imp_le_left) |
807 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
808 |
instance star :: (ordered_comm_monoid_add) ordered_comm_monoid_add .. |
63456
3365c8ec67bd
sharing simp rules between ordered monoids and rings
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
62479
diff
changeset
|
809 |
instance star :: (ordered_ab_semigroup_monoid_add_imp_le) ordered_ab_semigroup_monoid_add_imp_le .. |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
810 |
instance star :: (ordered_cancel_comm_monoid_add) ordered_cancel_comm_monoid_add .. |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
811 |
instance star :: (ordered_ab_group_add) ordered_ab_group_add .. |
27468 | 812 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
813 |
instance star :: (ordered_ab_group_add_abs) ordered_ab_group_add_abs |
27468 | 814 |
by intro_classes (transfer, |
815 |
simp add: abs_ge_self abs_leI abs_triangle_ineq)+ |
|
816 |
||
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
817 |
instance star :: (linordered_cancel_ab_semigroup_add) linordered_cancel_ab_semigroup_add .. |
27468 | 818 |
|
819 |
||
61975 | 820 |
subsection \<open>Ring and field classes\<close> |
27468 | 821 |
|
822 |
instance star :: (semiring) semiring |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
823 |
by (intro_classes; transfer) (fact distrib_right distrib_left)+ |
27468 | 824 |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
825 |
instance star :: (semiring_0) semiring_0 |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
826 |
by (intro_classes; transfer) simp_all |
27468 | 827 |
|
828 |
instance star :: (semiring_0_cancel) semiring_0_cancel .. |
|
829 |
||
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
830 |
instance star :: (comm_semiring) comm_semiring |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
831 |
by (intro_classes; transfer) (fact distrib_right) |
27468 | 832 |
|
833 |
instance star :: (comm_semiring_0) comm_semiring_0 .. |
|
834 |
instance star :: (comm_semiring_0_cancel) comm_semiring_0_cancel .. |
|
835 |
||
836 |
instance star :: (zero_neq_one) zero_neq_one |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
837 |
by (intro_classes; transfer) (fact zero_neq_one) |
27468 | 838 |
|
839 |
instance star :: (semiring_1) semiring_1 .. |
|
840 |
instance star :: (comm_semiring_1) comm_semiring_1 .. |
|
841 |
||
59680 | 842 |
declare dvd_def [transfer_refold] |
59676 | 843 |
|
60562
24af00b010cf
Amalgamation of the class comm_semiring_1_diff_distrib into comm_semiring_1_cancel. Moving axiom le_add_diff_inverse2 from semiring_numeral_div to linordered_semidom.
paulson <lp15@cam.ac.uk>
parents:
60516
diff
changeset
|
844 |
instance star :: (comm_semiring_1_cancel) comm_semiring_1_cancel |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
845 |
by (intro_classes; transfer) (fact right_diff_distrib') |
59676 | 846 |
|
59833
ab828c2c5d67
clarified no_zero_devisors: makes only sense in a semiring;
haftmann
parents:
59816
diff
changeset
|
847 |
instance star :: (semiring_no_zero_divisors) semiring_no_zero_divisors |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
848 |
by (intro_classes; transfer) (fact no_zero_divisors) |
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
849 |
|
60867 | 850 |
instance star :: (semiring_1_no_zero_divisors) semiring_1_no_zero_divisors .. |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
851 |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
852 |
instance star :: (semiring_no_zero_divisors_cancel) semiring_no_zero_divisors_cancel |
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
853 |
by (intro_classes; transfer) simp_all |
27468 | 854 |
|
855 |
instance star :: (semiring_1_cancel) semiring_1_cancel .. |
|
856 |
instance star :: (ring) ring .. |
|
857 |
instance star :: (comm_ring) comm_ring .. |
|
858 |
instance star :: (ring_1) ring_1 .. |
|
859 |
instance star :: (comm_ring_1) comm_ring_1 .. |
|
59833
ab828c2c5d67
clarified no_zero_devisors: makes only sense in a semiring;
haftmann
parents:
59816
diff
changeset
|
860 |
instance star :: (semidom) semidom .. |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
861 |
|
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
60352
diff
changeset
|
862 |
instance star :: (semidom_divide) semidom_divide |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
863 |
by (intro_classes; transfer) simp_all |
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
864 |
|
59676 | 865 |
instance star :: (semiring_div) semiring_div |
64242
93c6f0da5c70
more standardized theorem names for facts involving the div and mod identity
haftmann
parents:
63950
diff
changeset
|
866 |
by (intro_classes; transfer) (simp_all add: div_mult_mod_eq) |
59676 | 867 |
|
27468 | 868 |
instance star :: (ring_no_zero_divisors) ring_no_zero_divisors .. |
869 |
instance star :: (ring_1_no_zero_divisors) ring_1_no_zero_divisors .. |
|
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
870 |
instance star :: (idom) idom .. |
60353
838025c6e278
implicit partial divison operation in integral domains
haftmann
parents:
60352
diff
changeset
|
871 |
instance star :: (idom_divide) idom_divide .. |
27468 | 872 |
|
873 |
instance star :: (division_ring) division_ring |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
874 |
by (intro_classes; transfer) (simp_all add: divide_inverse) |
27468 | 875 |
|
876 |
instance star :: (field) field |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
877 |
by (intro_classes; transfer) (simp_all add: divide_inverse) |
27468 | 878 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
879 |
instance star :: (ordered_semiring) ordered_semiring |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
880 |
by (intro_classes; transfer) (fact mult_left_mono mult_right_mono)+ |
27468 | 881 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
882 |
instance star :: (ordered_cancel_semiring) ordered_cancel_semiring .. |
27468 | 883 |
|
35043
07dbdf60d5ad
dropped accidental duplication of "lin" prefix from cs. 108662d50512
haftmann
parents:
35035
diff
changeset
|
884 |
instance star :: (linordered_semiring_strict) linordered_semiring_strict |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
885 |
by (intro_classes; transfer) (fact mult_strict_left_mono mult_strict_right_mono)+ |
27468 | 886 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
887 |
instance star :: (ordered_comm_semiring) ordered_comm_semiring |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
888 |
by (intro_classes; transfer) (fact mult_left_mono) |
27468 | 889 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
890 |
instance star :: (ordered_cancel_comm_semiring) ordered_cancel_comm_semiring .. |
27468 | 891 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
892 |
instance star :: (linordered_comm_semiring_strict) linordered_comm_semiring_strict |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
893 |
by (intro_classes; transfer) (fact mult_strict_left_mono) |
27468 | 894 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
895 |
instance star :: (ordered_ring) ordered_ring .. |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
896 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
897 |
instance star :: (ordered_ring_abs) ordered_ring_abs |
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
898 |
by (intro_classes; transfer) (fact abs_eq_mult) |
27468 | 899 |
|
900 |
instance star :: (abs_if) abs_if |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
901 |
by (intro_classes; transfer) (fact abs_if) |
27468 | 902 |
|
903 |
instance star :: (sgn_if) sgn_if |
|
60516
0826b7025d07
generalized some theorems about integral domains and moved to HOL theories
haftmann
parents:
60429
diff
changeset
|
904 |
by (intro_classes; transfer) (fact sgn_if) |
27468 | 905 |
|
35043
07dbdf60d5ad
dropped accidental duplication of "lin" prefix from cs. 108662d50512
haftmann
parents:
35035
diff
changeset
|
906 |
instance star :: (linordered_ring_strict) linordered_ring_strict .. |
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
907 |
instance star :: (ordered_comm_ring) ordered_comm_ring .. |
27468 | 908 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
909 |
instance star :: (linordered_semidom) linordered_semidom |
60562
24af00b010cf
Amalgamation of the class comm_semiring_1_diff_distrib into comm_semiring_1_cancel. Moving axiom le_add_diff_inverse2 from semiring_numeral_div to linordered_semidom.
paulson <lp15@cam.ac.uk>
parents:
60516
diff
changeset
|
910 |
apply intro_classes |
24af00b010cf
Amalgamation of the class comm_semiring_1_diff_distrib into comm_semiring_1_cancel. Moving axiom le_add_diff_inverse2 from semiring_numeral_div to linordered_semidom.
paulson <lp15@cam.ac.uk>
parents:
60516
diff
changeset
|
911 |
apply(transfer, fact zero_less_one) |
24af00b010cf
Amalgamation of the class comm_semiring_1_diff_distrib into comm_semiring_1_cancel. Moving axiom le_add_diff_inverse2 from semiring_numeral_div to linordered_semidom.
paulson <lp15@cam.ac.uk>
parents:
60516
diff
changeset
|
912 |
apply(transfer, fact le_add_diff_inverse2) |
24af00b010cf
Amalgamation of the class comm_semiring_1_diff_distrib into comm_semiring_1_cancel. Moving axiom le_add_diff_inverse2 from semiring_numeral_div to linordered_semidom.
paulson <lp15@cam.ac.uk>
parents:
60516
diff
changeset
|
913 |
done |
27468 | 914 |
|
35028
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
915 |
instance star :: (linordered_idom) linordered_idom .. |
108662d50512
more consistent naming of type classes involving orderings (and lattices) -- c.f. NEWS
haftmann
parents:
31021
diff
changeset
|
916 |
instance star :: (linordered_field) linordered_field .. |
27468 | 917 |
|
61975 | 918 |
subsection \<open>Power\<close> |
30968
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
919 |
|
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
920 |
lemma star_power_def [transfer_unfold]: |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
921 |
"(op ^) \<equiv> \<lambda>x n. ( *f* (\<lambda>x. x ^ n)) x" |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
922 |
proof (rule eq_reflection, rule ext, rule ext) |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
923 |
fix n :: nat |
62376
85f38d5f8807
Rename ordered_comm_monoid_add to ordered_cancel_comm_monoid_add. Introduce ordreed_comm_monoid_add, canonically_ordered_comm_monoid and dioid. Setup nat, entat and ennreal as dioids.
hoelzl
parents:
61975
diff
changeset
|
924 |
show "\<And>x::'a star. x ^ n = ( *f* (\<lambda>x. x ^ n)) x" |
30968
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
925 |
proof (induct n) |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
926 |
case 0 |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
927 |
have "\<And>x::'a star. ( *f* (\<lambda>x. 1)) x = 1" |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
928 |
by transfer simp |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
929 |
then show ?case by simp |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
930 |
next |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
931 |
case (Suc n) |
61076 | 932 |
have "\<And>x::'a star. x * ( *f* (\<lambda>x::'a. x ^ n)) x = ( *f* (\<lambda>x::'a. x * x ^ n)) x" |
30968
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
933 |
by transfer simp |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
934 |
with Suc show ?case by simp |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
935 |
qed |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
936 |
qed |
27468 | 937 |
|
30968
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
938 |
lemma Standard_power [simp]: "x \<in> Standard \<Longrightarrow> x ^ n \<in> Standard" |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
939 |
by (simp add: star_power_def) |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
940 |
|
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
941 |
lemma star_of_power [simp]: "star_of (x ^ n) = star_of x ^ n" |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
942 |
by transfer (rule refl) |
10fef94f40fc
adaptions due to rearrangment of power operation
haftmann
parents:
30729
diff
changeset
|
943 |
|
27468 | 944 |
|
61975 | 945 |
subsection \<open>Number classes\<close> |
27468 | 946 |
|
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
947 |
instance star :: (numeral) numeral .. |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
948 |
|
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
949 |
lemma star_numeral_def [transfer_unfold]: |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
950 |
"numeral k = star_of (numeral k)" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
951 |
by (induct k, simp_all only: numeral.simps star_of_one star_of_add) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
952 |
|
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
953 |
lemma Standard_numeral [simp]: "numeral k \<in> Standard" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
954 |
by (simp add: star_numeral_def) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
955 |
|
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
956 |
lemma star_of_numeral [simp]: "star_of (numeral k) = numeral k" |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
957 |
by transfer (rule refl) |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
958 |
|
27468 | 959 |
lemma star_of_nat_def [transfer_unfold]: "of_nat n = star_of (of_nat n)" |
960 |
by (induct n, simp_all) |
|
961 |
||
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
962 |
lemmas star_of_compare_numeral [simp] = |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
963 |
star_of_less [of "numeral k", simplified star_of_numeral] |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
964 |
star_of_le [of "numeral k", simplified star_of_numeral] |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
965 |
star_of_eq [of "numeral k", simplified star_of_numeral] |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
966 |
star_of_less [of _ "numeral k", simplified star_of_numeral] |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
967 |
star_of_le [of _ "numeral k", simplified star_of_numeral] |
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
968 |
star_of_eq [of _ "numeral k", simplified star_of_numeral] |
54489
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54230
diff
changeset
|
969 |
star_of_less [of "- numeral k", simplified star_of_numeral] |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54230
diff
changeset
|
970 |
star_of_le [of "- numeral k", simplified star_of_numeral] |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54230
diff
changeset
|
971 |
star_of_eq [of "- numeral k", simplified star_of_numeral] |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54230
diff
changeset
|
972 |
star_of_less [of _ "- numeral k", simplified star_of_numeral] |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54230
diff
changeset
|
973 |
star_of_le [of _ "- numeral k", simplified star_of_numeral] |
03ff4d1e6784
eliminiated neg_numeral in favour of - (numeral _)
haftmann
parents:
54230
diff
changeset
|
974 |
star_of_eq [of _ "- numeral k", simplified star_of_numeral] for k |
47108
2a1953f0d20d
merged fork with new numeral representation (see NEWS)
huffman
parents:
46008
diff
changeset
|
975 |
|
27468 | 976 |
lemma Standard_of_nat [simp]: "of_nat n \<in> Standard" |
977 |
by (simp add: star_of_nat_def) |
|
978 |
||
979 |
lemma star_of_of_nat [simp]: "star_of (of_nat n) = of_nat n" |
|
980 |
by transfer (rule refl) |
|
981 |
||
982 |
lemma star_of_int_def [transfer_unfold]: "of_int z = star_of (of_int z)" |
|
983 |
by (rule_tac z=z in int_diff_cases, simp) |
|
984 |
||
985 |
lemma Standard_of_int [simp]: "of_int z \<in> Standard" |
|
986 |
by (simp add: star_of_int_def) |
|
987 |
||
988 |
lemma star_of_of_int [simp]: "star_of (of_int z) = of_int z" |
|
989 |
by transfer (rule refl) |
|
990 |
||
62378
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62376
diff
changeset
|
991 |
instance star :: (semiring_char_0) semiring_char_0 |
85ed00c1fe7c
generalize more theorems to support enat and ennreal
hoelzl
parents:
62376
diff
changeset
|
992 |
proof |
38621
d6cb7e625d75
more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents:
37765
diff
changeset
|
993 |
have "inj (star_of :: 'a \<Rightarrow> 'a star)" by (rule injI) simp |
d6cb7e625d75
more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents:
37765
diff
changeset
|
994 |
then have "inj (star_of \<circ> of_nat :: nat \<Rightarrow> 'a star)" using inj_of_nat by (rule inj_comp) |
d6cb7e625d75
more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents:
37765
diff
changeset
|
995 |
then show "inj (of_nat :: nat \<Rightarrow> 'a star)" by (simp add: comp_def) |
d6cb7e625d75
more concise characterization of of_nat operation and class semiring_char_0
haftmann
parents:
37765
diff
changeset
|
996 |
qed |
27468 | 997 |
|
998 |
instance star :: (ring_char_0) ring_char_0 .. |
|
999 |
||
59676 | 1000 |
instance star :: (semiring_parity) semiring_parity |
1001 |
apply intro_classes |
|
1002 |
apply(transfer, rule odd_one) |
|
1003 |
apply(transfer, erule (1) odd_even_add) |
|
1004 |
apply(transfer, erule even_multD) |
|
1005 |
apply(transfer, erule odd_ex_decrement) |
|
1006 |
done |
|
1007 |
||
1008 |
instance star :: (semiring_div_parity) semiring_div_parity |
|
1009 |
apply intro_classes |
|
1010 |
apply(transfer, rule parity) |
|
1011 |
apply(transfer, rule one_mod_two_eq_one) |
|
1012 |
apply(transfer, rule zero_not_eq_two) |
|
1013 |
done |
|
1014 |
||
61275
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1015 |
instantiation star :: (semiring_numeral_div) semiring_numeral_div |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1016 |
begin |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1017 |
|
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1018 |
definition divmod_star :: "num \<Rightarrow> num \<Rightarrow> 'a star \<times> 'a star" |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1019 |
where |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1020 |
divmod_star_def: "divmod_star m n = (numeral m div numeral n, numeral m mod numeral n)" |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1021 |
|
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1022 |
definition divmod_step_star :: "num \<Rightarrow> 'a star \<times> 'a star \<Rightarrow> 'a star \<times> 'a star" |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1023 |
where |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1024 |
"divmod_step_star l qr = (let (q, r) = qr |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1025 |
in if r \<ge> numeral l then (2 * q + 1, r - numeral l) |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1026 |
else (2 * q, r))" |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1027 |
|
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1028 |
instance proof |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1029 |
show "divmod m n = (numeral m div numeral n :: 'a star, numeral m mod numeral n)" |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1030 |
for m n by (fact divmod_star_def) |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1031 |
show "divmod_step l qr = (let (q, r) = qr |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1032 |
in if r \<ge> numeral l then (2 * q + 1, r - numeral l) |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1033 |
else (2 * q, r))" for l and qr :: "'a star \<times> 'a star" |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1034 |
by (fact divmod_step_star_def) |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1035 |
qed (transfer, |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1036 |
fact |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1037 |
semiring_numeral_div_class.div_less |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1038 |
semiring_numeral_div_class.mod_less |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1039 |
semiring_numeral_div_class.div_positive |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1040 |
semiring_numeral_div_class.mod_less_eq_dividend |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1041 |
semiring_numeral_div_class.pos_mod_bound |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1042 |
semiring_numeral_div_class.pos_mod_sign |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1043 |
semiring_numeral_div_class.mod_mult2_eq |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1044 |
semiring_numeral_div_class.div_mult2_eq |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1045 |
semiring_numeral_div_class.discrete)+ |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1046 |
|
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1047 |
end |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1048 |
|
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1049 |
declare divmod_algorithm_code [where ?'a = "'a::semiring_numeral_div star", code] |
053ec04ea866
monomorphization of divmod wrt. code generation avoids costly dictionary unpacking at runtime
haftmann
parents:
61076
diff
changeset
|
1050 |
|
27468 | 1051 |
|
61975 | 1052 |
subsection \<open>Finite class\<close> |
27468 | 1053 |
|
1054 |
lemma starset_finite: "finite A \<Longrightarrow> *s* A = star_of ` A" |
|
1055 |
by (erule finite_induct, simp_all) |
|
1056 |
||
1057 |
instance star :: (finite) finite |
|
1058 |
apply (intro_classes) |
|
1059 |
apply (subst starset_UNIV [symmetric]) |
|
1060 |
apply (subst starset_finite [OF finite]) |
|
1061 |
apply (rule finite_imageI [OF finite]) |
|
1062 |
done |
|
1063 |
||
1064 |
end |