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