re-organized some hyperreal and real lemmas
authorpaulson
Thu Dec 25 22:48:32 2003 +0100 (2003-12-25)
changeset 14329ff3210fe968f
parent 14328 fd063037fdf5
child 14330 eb8b8241ef5b
re-organized some hyperreal and real lemmas
src/HOL/Hyperreal/HyperArith.thy
src/HOL/Hyperreal/HyperBin.ML
src/HOL/Hyperreal/HyperDef.thy
src/HOL/Hyperreal/HyperOrd.thy
src/HOL/Hyperreal/Integration.ML
src/HOL/Hyperreal/NSA.ML
src/HOL/Hyperreal/SEQ.ML
src/HOL/Integ/int_arith1.ML
src/HOL/Real/HahnBanach/Subspace.thy
src/HOL/Real/RealArith.thy
src/HOL/Real/RealBin.ML
src/HOL/Real/RealDef.thy
src/HOL/Real/RealOrd.thy
src/HOL/Real/real_arith0.ML
     1.1 --- a/src/HOL/Hyperreal/HyperArith.thy	Wed Dec 24 08:54:30 2003 +0100
     1.2 +++ b/src/HOL/Hyperreal/HyperArith.thy	Thu Dec 25 22:48:32 2003 +0100
     1.3 @@ -4,6 +4,16 @@
     1.4  
     1.5  setup hypreal_arith_setup
     1.6  
     1.7 +text{*Used once in NSA*}
     1.8 +lemma hypreal_add_minus_eq_minus: "x + y = (0::hypreal) ==> x = -y"
     1.9 +apply arith
    1.10 +done
    1.11 +
    1.12 +ML
    1.13 +{*
    1.14 +val hypreal_add_minus_eq_minus = thm "hypreal_add_minus_eq_minus";
    1.15 +*}
    1.16 +
    1.17  subsubsection{*Division By @{term 1} and @{term "-1"}*}
    1.18  
    1.19  lemma hypreal_divide_minus1 [simp]: "x/-1 = -(x::hypreal)"
     2.1 --- a/src/HOL/Hyperreal/HyperBin.ML	Wed Dec 24 08:54:30 2003 +0100
     2.2 +++ b/src/HOL/Hyperreal/HyperBin.ML	Thu Dec 25 22:48:32 2003 +0100
     2.3 @@ -148,21 +148,6 @@
     2.4  
     2.5  (**** Simprocs for numeric literals ****)
     2.6  
     2.7 -(** Combining of literal coefficients in sums of products **)
     2.8 -
     2.9 -Goal "(x < y) = (x-y < (0::hypreal))";
    2.10 -by (simp_tac (simpset() addsimps [hypreal_diff_less_eq]) 1);
    2.11 -qed "hypreal_less_iff_diff_less_0";
    2.12 -
    2.13 -Goal "(x = y) = (x-y = (0::hypreal))";
    2.14 -by (simp_tac (simpset() addsimps [hypreal_diff_eq_eq]) 1);
    2.15 -qed "hypreal_eq_iff_diff_eq_0";
    2.16 -
    2.17 -Goal "(x <= y) = (x-y <= (0::hypreal))";
    2.18 -by (simp_tac (simpset() addsimps [hypreal_diff_le_eq]) 1);
    2.19 -qed "hypreal_le_iff_diff_le_0";
    2.20 -
    2.21 -
    2.22  (** For combine_numerals **)
    2.23  
    2.24  Goal "i*u + (j*u + k) = (i+j)*u + (k::hypreal)";
    2.25 @@ -173,12 +158,12 @@
    2.26  (** For cancel_numerals **)
    2.27  
    2.28  val rel_iff_rel_0_rls =
    2.29 -    map (inst "y" "?u+?v")
    2.30 -      [hypreal_less_iff_diff_less_0, hypreal_eq_iff_diff_eq_0,
    2.31 -       hypreal_le_iff_diff_le_0] @
    2.32 -    map (inst "y" "n")
    2.33 -      [hypreal_less_iff_diff_less_0, hypreal_eq_iff_diff_eq_0,
    2.34 -       hypreal_le_iff_diff_le_0];
    2.35 +    map (inst "b" "?u+?v")
    2.36 +      [less_iff_diff_less_0, eq_iff_diff_eq_0,
    2.37 +       le_iff_diff_le_0] @
    2.38 +    map (inst "b" "n")
    2.39 +      [less_iff_diff_less_0, eq_iff_diff_eq_0,
    2.40 +       le_iff_diff_le_0];
    2.41  
    2.42  Goal "!!i::hypreal. (i*u + m = j*u + n) = ((i-j)*u + m = n)";
    2.43  by (asm_simp_tac
    2.44 @@ -582,9 +567,9 @@
    2.45  Addsimprocs [Hyperreal_Times_Assoc.conv];
    2.46  
    2.47  (*Simplification of  x-y < 0, etc.*)
    2.48 -AddIffs [hypreal_less_iff_diff_less_0 RS sym];
    2.49 -AddIffs [hypreal_eq_iff_diff_eq_0 RS sym];
    2.50 -AddIffs [hypreal_le_iff_diff_le_0 RS sym];
    2.51 +AddIffs [less_iff_diff_less_0 RS sym];
    2.52 +AddIffs [eq_iff_diff_eq_0 RS sym];
    2.53 +AddIffs [le_iff_diff_le_0 RS sym];
    2.54  
    2.55  
    2.56  (** number_of related to hypreal_of_real **)
     3.1 --- a/src/HOL/Hyperreal/HyperDef.thy	Wed Dec 24 08:54:30 2003 +0100
     3.2 +++ b/src/HOL/Hyperreal/HyperDef.thy	Thu Dec 25 22:48:32 2003 +0100
     3.3 @@ -84,12 +84,14 @@
     3.4    hypreal_le_def:
     3.5    "P <= (Q::hypreal) == ~(Q < P)"
     3.6  
     3.7 -(*------------------------------------------------------------------------
     3.8 -             Proof that the set of naturals is not finite
     3.9 - ------------------------------------------------------------------------*)
    3.10 +  hrabs_def:  "abs (r::hypreal) == (if 0 \<le> r then r else -r)"
    3.11 +
    3.12 +
    3.13 +subsection{*The Set of Naturals is not Finite*}
    3.14  
    3.15  (*** based on James' proof that the set of naturals is not finite ***)
    3.16 -lemma finite_exhausts [rule_format (no_asm)]: "finite (A::nat set) --> (\<exists>n. \<forall>m. Suc (n + m) \<notin> A)"
    3.17 +lemma finite_exhausts [rule_format]:
    3.18 +     "finite (A::nat set) --> (\<exists>n. \<forall>m. Suc (n + m) \<notin> A)"
    3.19  apply (rule impI)
    3.20  apply (erule_tac F = A in finite_induct)
    3.21  apply (blast, erule exE)
    3.22 @@ -98,16 +100,18 @@
    3.23  apply (auto simp add: add_ac)
    3.24  done
    3.25  
    3.26 -lemma finite_not_covers [rule_format (no_asm)]: "finite (A :: nat set) --> (\<exists>n. n \<notin>A)"
    3.27 +lemma finite_not_covers [rule_format (no_asm)]:
    3.28 +     "finite (A :: nat set) --> (\<exists>n. n \<notin>A)"
    3.29  by (rule impI, drule finite_exhausts, blast)
    3.30  
    3.31  lemma not_finite_nat: "~ finite(UNIV:: nat set)"
    3.32  by (fast dest!: finite_exhausts)
    3.33  
    3.34 -(*------------------------------------------------------------------------
    3.35 -   Existence of free ultrafilter over the naturals and proof of various 
    3.36 -   properties of the FreeUltrafilterNat- an arbitrary free ultrafilter
    3.37 - ------------------------------------------------------------------------*)
    3.38 +
    3.39 +subsection{*Existence of Free Ultrafilter over the Naturals*}
    3.40 +
    3.41 +text{*Also, proof of various properties of @{term FreeUltrafilterNat}: 
    3.42 +an arbitrary free ultrafilter*}
    3.43  
    3.44  lemma FreeUltrafilterNat_Ex: "\<exists>U. U: FreeUltrafilter (UNIV::nat set)"
    3.45  by (rule not_finite_nat [THEN FreeUltrafilter_Ex])
    3.46 @@ -137,33 +141,39 @@
    3.47                     Filter_empty_not_mem)
    3.48  done
    3.49  
    3.50 -lemma FreeUltrafilterNat_Int: "[| X: FreeUltrafilterNat;  Y: FreeUltrafilterNat |]   
    3.51 +lemma FreeUltrafilterNat_Int:
    3.52 +     "[| X: FreeUltrafilterNat;  Y: FreeUltrafilterNat |]   
    3.53        ==> X Int Y \<in> FreeUltrafilterNat"
    3.54  apply (cut_tac FreeUltrafilterNat_mem)
    3.55  apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter mem_FiltersetD1)
    3.56  done
    3.57  
    3.58 -lemma FreeUltrafilterNat_subset: "[| X: FreeUltrafilterNat;  X <= Y |]  
    3.59 +lemma FreeUltrafilterNat_subset:
    3.60 +     "[| X: FreeUltrafilterNat;  X <= Y |]  
    3.61        ==> Y \<in> FreeUltrafilterNat"
    3.62  apply (cut_tac FreeUltrafilterNat_mem)
    3.63  apply (blast dest: FreeUltrafilter_Ultrafilter Ultrafilter_Filter mem_FiltersetD2)
    3.64  done
    3.65  
    3.66 -lemma FreeUltrafilterNat_Compl: "X: FreeUltrafilterNat ==> -X \<notin> FreeUltrafilterNat"
    3.67 +lemma FreeUltrafilterNat_Compl:
    3.68 +     "X: FreeUltrafilterNat ==> -X \<notin> FreeUltrafilterNat"
    3.69  apply safe
    3.70  apply (drule FreeUltrafilterNat_Int, assumption, auto)
    3.71  done
    3.72  
    3.73 -lemma FreeUltrafilterNat_Compl_mem: "X\<notin> FreeUltrafilterNat ==> -X \<in> FreeUltrafilterNat"
    3.74 +lemma FreeUltrafilterNat_Compl_mem:
    3.75 +     "X\<notin> FreeUltrafilterNat ==> -X \<in> FreeUltrafilterNat"
    3.76  apply (cut_tac FreeUltrafilterNat_mem [THEN FreeUltrafilter_iff [THEN iffD1]])
    3.77  apply (safe, drule_tac x = X in bspec)
    3.78  apply (auto simp add: UNIV_diff_Compl)
    3.79  done
    3.80  
    3.81 -lemma FreeUltrafilterNat_Compl_iff1: "(X \<notin> FreeUltrafilterNat) = (-X: FreeUltrafilterNat)"
    3.82 +lemma FreeUltrafilterNat_Compl_iff1:
    3.83 +     "(X \<notin> FreeUltrafilterNat) = (-X: FreeUltrafilterNat)"
    3.84  by (blast dest: FreeUltrafilterNat_Compl FreeUltrafilterNat_Compl_mem)
    3.85  
    3.86 -lemma FreeUltrafilterNat_Compl_iff2: "(X: FreeUltrafilterNat) = (-X \<notin> FreeUltrafilterNat)"
    3.87 +lemma FreeUltrafilterNat_Compl_iff2:
    3.88 +     "(X: FreeUltrafilterNat) = (-X \<notin> FreeUltrafilterNat)"
    3.89  by (auto simp add: FreeUltrafilterNat_Compl_iff1 [symmetric])
    3.90  
    3.91  lemma FreeUltrafilterNat_UNIV [simp]: "(UNIV::nat set) \<in> FreeUltrafilterNat"
    3.92 @@ -172,7 +182,8 @@
    3.93  lemma FreeUltrafilterNat_Nat_set [simp]: "UNIV \<in> FreeUltrafilterNat"
    3.94  by auto
    3.95  
    3.96 -lemma FreeUltrafilterNat_Nat_set_refl [intro]: "{n. P(n) = P(n)} \<in> FreeUltrafilterNat"
    3.97 +lemma FreeUltrafilterNat_Nat_set_refl [intro]:
    3.98 +     "{n. P(n) = P(n)} \<in> FreeUltrafilterNat"
    3.99  by simp
   3.100  
   3.101  lemma FreeUltrafilterNat_P: "{n::nat. P} \<in> FreeUltrafilterNat ==> P"
   3.102 @@ -184,9 +195,8 @@
   3.103  lemma FreeUltrafilterNat_all: "\<forall>n. P(n) ==> {n. P(n)} \<in> FreeUltrafilterNat"
   3.104  by (auto intro: FreeUltrafilterNat_Nat_set)
   3.105  
   3.106 -(*-------------------------------------------------------
   3.107 -     Define and use Ultrafilter tactics
   3.108 - -------------------------------------------------------*)
   3.109 +
   3.110 +text{*Define and use Ultrafilter tactics*}
   3.111  use "fuf.ML"
   3.112  
   3.113  method_setup fuf = {*
   3.114 @@ -204,21 +214,18 @@
   3.115      "ultrafilter tactic"
   3.116  
   3.117  
   3.118 -(*-------------------------------------------------------
   3.119 -  Now prove one further property of our free ultrafilter
   3.120 - -------------------------------------------------------*)
   3.121 -lemma FreeUltrafilterNat_Un: "X Un Y: FreeUltrafilterNat  
   3.122 +text{*One further property of our free ultrafilter*}
   3.123 +lemma FreeUltrafilterNat_Un:
   3.124 +     "X Un Y: FreeUltrafilterNat  
   3.125        ==> X: FreeUltrafilterNat | Y: FreeUltrafilterNat"
   3.126  apply auto
   3.127  apply ultra
   3.128  done
   3.129  
   3.130 -(*-------------------------------------------------------
   3.131 -   Properties of hyprel
   3.132 - -------------------------------------------------------*)
   3.133  
   3.134 -(** Proving that hyprel is an equivalence relation **)
   3.135 -(** Natural deduction for hyprel **)
   3.136 +subsection{*Properties of @{term hyprel}*}
   3.137 +
   3.138 +text{*Proving that @{term hyprel} is an equivalence relation*}
   3.139  
   3.140  lemma hyprel_iff: "((X,Y): hyprel) = ({n. X n = Y n}: FreeUltrafilterNat)"
   3.141  by (unfold hyprel_def, fast)
   3.142 @@ -281,9 +288,8 @@
   3.143  by (cut_tac x = x in Rep_hypreal, auto)
   3.144  
   3.145  
   3.146 -(*------------------------------------------------------------------------
   3.147 -   hypreal_of_real: the injection from real to hypreal
   3.148 - ------------------------------------------------------------------------*)
   3.149 +subsection{*@{term hypreal_of_real}: 
   3.150 +            the Injection from @{typ real} to @{typ hypreal}*}
   3.151  
   3.152  lemma inj_hypreal_of_real: "inj(hypreal_of_real)"
   3.153  apply (rule inj_onI)
   3.154 @@ -302,7 +308,61 @@
   3.155  apply (force simp add: Rep_hypreal_inverse)
   3.156  done
   3.157  
   3.158 -(**** hypreal_minus: additive inverse on hypreal ****)
   3.159 +
   3.160 +subsection{*Hyperreal Addition*}
   3.161 +
   3.162 +lemma hypreal_add_congruent2: 
   3.163 +    "congruent2 hyprel (%X Y. hyprel``{%n. X n + Y n})"
   3.164 +apply (unfold congruent2_def, auto, ultra)
   3.165 +done
   3.166 +
   3.167 +lemma hypreal_add: 
   3.168 +  "Abs_hypreal(hyprel``{%n. X n}) + Abs_hypreal(hyprel``{%n. Y n}) =  
   3.169 +   Abs_hypreal(hyprel``{%n. X n + Y n})"
   3.170 +apply (unfold hypreal_add_def)
   3.171 +apply (simp add: UN_equiv_class2 [OF equiv_hyprel hypreal_add_congruent2])
   3.172 +done
   3.173 +
   3.174 +lemma hypreal_add_commute: "(z::hypreal) + w = w + z"
   3.175 +apply (rule_tac z = z in eq_Abs_hypreal)
   3.176 +apply (rule_tac z = w in eq_Abs_hypreal)
   3.177 +apply (simp add: real_add_ac hypreal_add)
   3.178 +done
   3.179 +
   3.180 +lemma hypreal_add_assoc: "((z1::hypreal) + z2) + z3 = z1 + (z2 + z3)"
   3.181 +apply (rule_tac z = z1 in eq_Abs_hypreal)
   3.182 +apply (rule_tac z = z2 in eq_Abs_hypreal)
   3.183 +apply (rule_tac z = z3 in eq_Abs_hypreal)
   3.184 +apply (simp add: hypreal_add real_add_assoc)
   3.185 +done
   3.186 +
   3.187 +(*For AC rewriting*)
   3.188 +lemma hypreal_add_left_commute: "(x::hypreal)+(y+z)=y+(x+z)"
   3.189 +  apply (rule mk_left_commute [of "op +"])
   3.190 +  apply (rule hypreal_add_assoc)
   3.191 +  apply (rule hypreal_add_commute)
   3.192 +  done
   3.193 +
   3.194 +(* hypreal addition is an AC operator *)
   3.195 +lemmas hypreal_add_ac =
   3.196 +       hypreal_add_assoc hypreal_add_commute hypreal_add_left_commute
   3.197 +
   3.198 +lemma hypreal_add_zero_left [simp]: "(0::hypreal) + z = z"
   3.199 +apply (unfold hypreal_zero_def)
   3.200 +apply (rule_tac z = z in eq_Abs_hypreal)
   3.201 +apply (simp add: hypreal_add)
   3.202 +done
   3.203 +
   3.204 +instance hypreal :: plus_ac0
   3.205 +  by (intro_classes,
   3.206 +      (assumption | 
   3.207 +       rule hypreal_add_commute hypreal_add_assoc hypreal_add_zero_left)+)
   3.208 +
   3.209 +lemma hypreal_add_zero_right [simp]: "z + (0::hypreal) = z"
   3.210 +by (simp add: hypreal_add_zero_left hypreal_add_commute)
   3.211 +
   3.212 +
   3.213 +subsection{*Additive inverse on @{typ hypreal}*}
   3.214  
   3.215  lemma hypreal_minus_congruent: 
   3.216    "congruent hyprel (%X. hyprel``{%n. - (X n)})"
   3.217 @@ -337,59 +397,12 @@
   3.218  apply (auto simp add: hypreal_zero_def hypreal_minus)
   3.219  done
   3.220  
   3.221 -
   3.222 -(**** hyperreal addition: hypreal_add  ****)
   3.223 -
   3.224 -lemma hypreal_add_congruent2: 
   3.225 -    "congruent2 hyprel (%X Y. hyprel``{%n. X n + Y n})"
   3.226 -apply (unfold congruent2_def, auto, ultra)
   3.227 -done
   3.228 -
   3.229 -lemma hypreal_add: 
   3.230 -  "Abs_hypreal(hyprel``{%n. X n}) + Abs_hypreal(hyprel``{%n. Y n}) =  
   3.231 -   Abs_hypreal(hyprel``{%n. X n + Y n})"
   3.232 -apply (unfold hypreal_add_def)
   3.233 -apply (simp add: UN_equiv_class2 [OF equiv_hyprel hypreal_add_congruent2])
   3.234 -done
   3.235 -
   3.236 -lemma hypreal_diff: "Abs_hypreal(hyprel``{%n. X n}) - Abs_hypreal(hyprel``{%n. Y n}) =  
   3.237 +lemma hypreal_diff:
   3.238 +     "Abs_hypreal(hyprel``{%n. X n}) - Abs_hypreal(hyprel``{%n. Y n}) =  
   3.239        Abs_hypreal(hyprel``{%n. X n - Y n})"
   3.240  apply (simp add: hypreal_diff_def hypreal_minus hypreal_add)
   3.241  done
   3.242  
   3.243 -lemma hypreal_add_commute: "(z::hypreal) + w = w + z"
   3.244 -apply (rule_tac z = z in eq_Abs_hypreal)
   3.245 -apply (rule_tac z = w in eq_Abs_hypreal)
   3.246 -apply (simp add: real_add_ac hypreal_add)
   3.247 -done
   3.248 -
   3.249 -lemma hypreal_add_assoc: "((z1::hypreal) + z2) + z3 = z1 + (z2 + z3)"
   3.250 -apply (rule_tac z = z1 in eq_Abs_hypreal)
   3.251 -apply (rule_tac z = z2 in eq_Abs_hypreal)
   3.252 -apply (rule_tac z = z3 in eq_Abs_hypreal)
   3.253 -apply (simp add: hypreal_add real_add_assoc)
   3.254 -done
   3.255 -
   3.256 -(*For AC rewriting*)
   3.257 -lemma hypreal_add_left_commute: "(x::hypreal)+(y+z)=y+(x+z)"
   3.258 -  apply (rule mk_left_commute [of "op +"])
   3.259 -  apply (rule hypreal_add_assoc)
   3.260 -  apply (rule hypreal_add_commute)
   3.261 -  done
   3.262 -
   3.263 -(* hypreal addition is an AC operator *)
   3.264 -lemmas hypreal_add_ac =
   3.265 -       hypreal_add_assoc hypreal_add_commute hypreal_add_left_commute
   3.266 -
   3.267 -lemma hypreal_add_zero_left [simp]: "(0::hypreal) + z = z"
   3.268 -apply (unfold hypreal_zero_def)
   3.269 -apply (rule_tac z = z in eq_Abs_hypreal)
   3.270 -apply (simp add: hypreal_add)
   3.271 -done
   3.272 -
   3.273 -lemma hypreal_add_zero_right [simp]: "z + (0::hypreal) = z"
   3.274 -by (simp add: hypreal_add_zero_left hypreal_add_commute)
   3.275 -
   3.276  lemma hypreal_add_minus [simp]: "z + -z = (0::hypreal)"
   3.277  apply (unfold hypreal_zero_def)
   3.278  apply (rule_tac z = z in eq_Abs_hypreal)
   3.279 @@ -399,42 +412,6 @@
   3.280  lemma hypreal_add_minus_left [simp]: "-z + z = (0::hypreal)"
   3.281  by (simp add: hypreal_add_commute hypreal_add_minus)
   3.282  
   3.283 -lemma hypreal_minus_ex: "\<exists>y. (x::hypreal) + y = 0"
   3.284 -by (fast intro: hypreal_add_minus)
   3.285 -
   3.286 -lemma hypreal_minus_ex1: "EX! y. (x::hypreal) + y = 0"
   3.287 -apply (auto intro: hypreal_add_minus)
   3.288 -apply (drule_tac f = "%x. ya+x" in arg_cong)
   3.289 -apply (simp add: hypreal_add_assoc [symmetric])
   3.290 -apply (simp add: hypreal_add_commute)
   3.291 -done
   3.292 -
   3.293 -lemma hypreal_minus_left_ex1: "EX! y. y + (x::hypreal) = 0"
   3.294 -apply (auto intro: hypreal_add_minus_left)
   3.295 -apply (drule_tac f = "%x. x+ya" in arg_cong)
   3.296 -apply (simp add: hypreal_add_assoc)
   3.297 -apply (simp add: hypreal_add_commute)
   3.298 -done
   3.299 -
   3.300 -lemma hypreal_add_minus_eq_minus: "x + y = (0::hypreal) ==> x = -y"
   3.301 -apply (cut_tac z = y in hypreal_add_minus_left)
   3.302 -apply (rule_tac x1 = y in hypreal_minus_left_ex1 [THEN ex1E], blast)
   3.303 -done
   3.304 -
   3.305 -lemma hypreal_as_add_inverse_ex: "\<exists>y::hypreal. x = -y"
   3.306 -apply (cut_tac x = x in hypreal_minus_ex)
   3.307 -apply (erule exE, drule hypreal_add_minus_eq_minus, fast)
   3.308 -done
   3.309 -
   3.310 -lemma hypreal_minus_add_distrib [simp]: "-(x + (y::hypreal)) = -x + -y"
   3.311 -apply (rule_tac z = x in eq_Abs_hypreal)
   3.312 -apply (rule_tac z = y in eq_Abs_hypreal)
   3.313 -apply (auto simp add: hypreal_minus hypreal_add real_minus_add_distrib)
   3.314 -done
   3.315 -
   3.316 -lemma hypreal_minus_distrib1: "-(y + -(x::hypreal)) = x + -y"
   3.317 -by (simp add: hypreal_add_commute)
   3.318 -
   3.319  lemma hypreal_add_left_cancel: "((x::hypreal) + y = x + z) = (y = z)"
   3.320  apply safe
   3.321  apply (drule_tac f = "%t.-x + t" in arg_cong)
   3.322 @@ -450,7 +427,8 @@
   3.323  lemma hypreal_minus_add_cancelA [simp]: "(-z) + (z + w) = (w::hypreal)"
   3.324  by (simp add: hypreal_add_assoc [symmetric])
   3.325  
   3.326 -(**** hyperreal multiplication: hypreal_mult  ****)
   3.327 +
   3.328 +subsection{*Hyperreal Multiplication*}
   3.329  
   3.330  lemma hypreal_mult_congruent2: 
   3.331      "congruent2 hyprel (%X Y. hyprel``{%n. X n * Y n})"
   3.332 @@ -530,30 +508,30 @@
   3.333  lemma hypreal_minus_mult_commute: "(-x) * y = (x::hypreal) * -y"
   3.334  by auto
   3.335  
   3.336 -(*-----------------------------------------------------------------------------
   3.337 -    A few more theorems
   3.338 - ----------------------------------------------------------------------------*)
   3.339 -lemma hypreal_add_assoc_cong: "(z::hypreal) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
   3.340 -by (simp add: hypreal_add_assoc [symmetric])
   3.341 +subsection{*A few more theorems *}
   3.342  
   3.343 -lemma hypreal_add_mult_distrib: "((z1::hypreal) + z2) * w = (z1 * w) + (z2 * w)"
   3.344 +lemma hypreal_add_mult_distrib:
   3.345 +     "((z1::hypreal) + z2) * w = (z1 * w) + (z2 * w)"
   3.346  apply (rule_tac z = z1 in eq_Abs_hypreal)
   3.347  apply (rule_tac z = z2 in eq_Abs_hypreal)
   3.348  apply (rule_tac z = w in eq_Abs_hypreal)
   3.349  apply (simp add: hypreal_mult hypreal_add real_add_mult_distrib)
   3.350  done
   3.351  
   3.352 -lemma hypreal_add_mult_distrib2: "(w::hypreal) * (z1 + z2) = (w * z1) + (w * z2)"
   3.353 +lemma hypreal_add_mult_distrib2:
   3.354 +     "(w::hypreal) * (z1 + z2) = (w * z1) + (w * z2)"
   3.355  by (simp add: hypreal_mult_commute [of w] hypreal_add_mult_distrib)
   3.356  
   3.357  
   3.358 -lemma hypreal_diff_mult_distrib: "((z1::hypreal) - z2) * w = (z1 * w) - (z2 * w)"
   3.359 +lemma hypreal_diff_mult_distrib:
   3.360 +     "((z1::hypreal) - z2) * w = (z1 * w) - (z2 * w)"
   3.361  
   3.362  apply (unfold hypreal_diff_def)
   3.363  apply (simp add: hypreal_add_mult_distrib)
   3.364  done
   3.365  
   3.366 -lemma hypreal_diff_mult_distrib2: "(w::hypreal) * (z1 - z2) = (w * z1) - (w * z2)"
   3.367 +lemma hypreal_diff_mult_distrib2:
   3.368 +     "(w::hypreal) * (z1 - z2) = (w * z1) - (w * z2)"
   3.369  by (simp add: hypreal_mult_commute [of w] hypreal_diff_mult_distrib)
   3.370  
   3.371  (*** one and zero are distinct ***)
   3.372 @@ -563,7 +541,7 @@
   3.373  done
   3.374  
   3.375  
   3.376 -(**** multiplicative inverse on hypreal ****)
   3.377 +subsection{*Multiplicative Inverse on @{typ hypreal} *}
   3.378  
   3.379  lemma hypreal_inverse_congruent: 
   3.380    "congruent hyprel (%X. hyprel``{%n. if X n = 0 then 0 else inverse(X n)})"
   3.381 @@ -586,19 +564,15 @@
   3.382  lemma HYPREAL_DIVISION_BY_ZERO: "a / (0::hypreal) = 0"
   3.383  by (simp add: hypreal_divide_def HYPREAL_INVERSE_ZERO)
   3.384  
   3.385 -lemma hypreal_inverse_inverse [simp]: "inverse (inverse (z::hypreal)) = z"
   3.386 -apply (case_tac "z=0", simp add: HYPREAL_INVERSE_ZERO)
   3.387 -apply (rule_tac z = z in eq_Abs_hypreal)
   3.388 -apply (simp add: hypreal_inverse hypreal_zero_def)
   3.389 -done
   3.390 -
   3.391 -lemma hypreal_inverse_1 [simp]: "inverse((1::hypreal)) = (1::hypreal)"
   3.392 -apply (unfold hypreal_one_def)
   3.393 -apply (simp add: hypreal_inverse real_zero_not_eq_one [THEN not_sym])
   3.394 -done
   3.395 +instance hypreal :: division_by_zero
   3.396 +proof
   3.397 +  fix x :: hypreal
   3.398 +  show "inverse 0 = (0::hypreal)" by (rule HYPREAL_INVERSE_ZERO)
   3.399 +  show "x/0 = 0" by (rule HYPREAL_DIVISION_BY_ZERO) 
   3.400 +qed
   3.401  
   3.402  
   3.403 -(*** existence of inverse ***)
   3.404 +subsection{*Existence of Inverse*}
   3.405  
   3.406  lemma hypreal_mult_inverse [simp]: 
   3.407       "x \<noteq> 0 ==> x*inverse(x) = (1::hypreal)"
   3.408 @@ -609,99 +583,33 @@
   3.409  apply (blast intro!: real_mult_inv_right FreeUltrafilterNat_subset)
   3.410  done
   3.411  
   3.412 -lemma hypreal_mult_inverse_left [simp]: "x \<noteq> 0 ==> inverse(x)*x = (1::hypreal)"
   3.413 +lemma hypreal_mult_inverse_left [simp]:
   3.414 +     "x \<noteq> 0 ==> inverse(x)*x = (1::hypreal)"
   3.415  by (simp add: hypreal_mult_inverse hypreal_mult_commute)
   3.416  
   3.417 -lemma hypreal_mult_left_cancel: "(c::hypreal) \<noteq> 0 ==> (c*a=c*b) = (a=b)"
   3.418 -apply auto
   3.419 -apply (drule_tac f = "%x. x*inverse c" in arg_cong)
   3.420 -apply (simp add: hypreal_mult_inverse hypreal_mult_ac)
   3.421 -done
   3.422 -    
   3.423 -lemma hypreal_mult_right_cancel: "(c::hypreal) \<noteq> 0 ==> (a*c=b*c) = (a=b)"
   3.424 -apply safe
   3.425 -apply (drule_tac f = "%x. x*inverse c" in arg_cong)
   3.426 -apply (simp add: hypreal_mult_inverse hypreal_mult_ac)
   3.427 -done
   3.428 +
   3.429 +subsection{*Theorems for Ordering*}
   3.430 +
   3.431 +text{*TODO: define @{text "\<le>"} as the primitive concept and quickly 
   3.432 +establish membership in class @{text linorder}. Then proofs could be
   3.433 +simplified, since properties of @{text "<"} would be generic.*}
   3.434  
   3.435 -lemma hypreal_inverse_not_zero: "x \<noteq> 0 ==> inverse (x::hypreal) \<noteq> 0"
   3.436 -apply (unfold hypreal_zero_def)
   3.437 -apply (rule_tac z = x in eq_Abs_hypreal)
   3.438 -apply (simp add: hypreal_inverse hypreal_mult)
   3.439 -done
   3.440 -
   3.441 -
   3.442 -lemma hypreal_mult_not_0: "[| x \<noteq> 0; y \<noteq> 0 |] ==> x * y \<noteq> (0::hypreal)"
   3.443 -apply safe
   3.444 -apply (drule_tac f = "%z. inverse x*z" in arg_cong)
   3.445 -apply (simp add: hypreal_mult_assoc [symmetric])
   3.446 -done
   3.447 -
   3.448 -lemma hypreal_mult_zero_disj: "x*y = (0::hypreal) ==> x = 0 | y = 0"
   3.449 -by (auto intro: ccontr dest: hypreal_mult_not_0)
   3.450 -
   3.451 -lemma hypreal_minus_inverse: "inverse(-x) = -inverse(x::hypreal)"
   3.452 -apply (case_tac "x=0", simp add: HYPREAL_INVERSE_ZERO)
   3.453 -apply (rule hypreal_mult_right_cancel [of "-x", THEN iffD1], simp) 
   3.454 -apply (subst hypreal_mult_inverse_left, auto)
   3.455 +text{*TODO: The following theorem should be used througout the proofs
   3.456 +  as it probably makes many of them more straightforward.*}
   3.457 +lemma hypreal_less: 
   3.458 +      "(Abs_hypreal(hyprel``{%n. X n}) < Abs_hypreal(hyprel``{%n. Y n})) =  
   3.459 +       ({n. X n < Y n} \<in> FreeUltrafilterNat)"
   3.460 +apply (unfold hypreal_less_def)
   3.461 +apply (auto intro!: lemma_hyprel_refl, ultra)
   3.462  done
   3.463  
   3.464 -lemma hypreal_inverse_distrib: "inverse(x*y) = inverse(x)*inverse(y::hypreal)"
   3.465 -apply (case_tac "x=0", simp add: HYPREAL_INVERSE_ZERO)
   3.466 -apply (case_tac "y=0", simp add: HYPREAL_INVERSE_ZERO)
   3.467 -apply (frule_tac y = y in hypreal_mult_not_0, assumption)
   3.468 -apply (rule_tac c1 = x in hypreal_mult_left_cancel [THEN iffD1])
   3.469 -apply (auto simp add: hypreal_mult_assoc [symmetric])
   3.470 -apply (rule_tac c1 = y in hypreal_mult_left_cancel [THEN iffD1])
   3.471 -apply (auto simp add: hypreal_mult_left_commute)
   3.472 -apply (simp add: hypreal_mult_assoc [symmetric])
   3.473 -done
   3.474 -
   3.475 -(*------------------------------------------------------------------
   3.476 -                   Theorems for ordering 
   3.477 - ------------------------------------------------------------------*)
   3.478 -
   3.479  (* prove introduction and elimination rules for hypreal_less *)
   3.480  
   3.481 -lemma hypreal_less_iff: 
   3.482 - "(P < (Q::hypreal)) = (\<exists>X Y. X \<in> Rep_hypreal(P) &  
   3.483 -                              Y \<in> Rep_hypreal(Q) &  
   3.484 -                              {n. X n < Y n} \<in> FreeUltrafilterNat)"
   3.485 -
   3.486 -apply (unfold hypreal_less_def, fast)
   3.487 -done
   3.488 -
   3.489 -lemma hypreal_lessI: 
   3.490 - "[| {n. X n < Y n} \<in> FreeUltrafilterNat;  
   3.491 -          X \<in> Rep_hypreal(P);  
   3.492 -          Y \<in> Rep_hypreal(Q) |] ==> P < (Q::hypreal)"
   3.493 -apply (unfold hypreal_less_def, fast)
   3.494 -done
   3.495 -
   3.496 -
   3.497 -lemma hypreal_lessE: 
   3.498 -     "!! R1. [| R1 < (R2::hypreal);  
   3.499 -          !!X Y. {n. X n < Y n} \<in> FreeUltrafilterNat ==> P;  
   3.500 -          !!X. X \<in> Rep_hypreal(R1) ==> P;   
   3.501 -          !!Y. Y \<in> Rep_hypreal(R2) ==> P |]  
   3.502 -      ==> P"
   3.503 -
   3.504 -apply (unfold hypreal_less_def, auto)
   3.505 -done
   3.506 -
   3.507 -lemma hypreal_lessD: 
   3.508 - "R1 < (R2::hypreal) ==> (\<exists>X Y. {n. X n < Y n} \<in> FreeUltrafilterNat &  
   3.509 -                                   X \<in> Rep_hypreal(R1) &  
   3.510 -                                   Y \<in> Rep_hypreal(R2))"
   3.511 -apply (unfold hypreal_less_def, fast)
   3.512 -done
   3.513 -
   3.514  lemma hypreal_less_not_refl: "~ (R::hypreal) < R"
   3.515  apply (rule_tac z = R in eq_Abs_hypreal)
   3.516  apply (auto simp add: hypreal_less_def, ultra)
   3.517  done
   3.518  
   3.519 -(*** y < y ==> P ***)
   3.520  lemmas hypreal_less_irrefl = hypreal_less_not_refl [THEN notE, standard]
   3.521  declare hypreal_less_irrefl [elim!]
   3.522  
   3.523 @@ -720,25 +628,10 @@
   3.524  apply (simp add: hypreal_less_not_refl)
   3.525  done
   3.526  
   3.527 -(*-------------------------------------------------------
   3.528 -  TODO: The following theorem should have been proved 
   3.529 -  first and then used througout the proofs as it probably 
   3.530 -  makes many of them more straightforward. 
   3.531 - -------------------------------------------------------*)
   3.532 -lemma hypreal_less: 
   3.533 -      "(Abs_hypreal(hyprel``{%n. X n}) <  
   3.534 -            Abs_hypreal(hyprel``{%n. Y n})) =  
   3.535 -       ({n. X n < Y n} \<in> FreeUltrafilterNat)"
   3.536 -apply (unfold hypreal_less_def)
   3.537 -apply (auto intro!: lemma_hyprel_refl, ultra)
   3.538 -done
   3.539  
   3.540 -(*----------------------------------------------------------------------------
   3.541 -		 Trichotomy: the hyperreals are linearly ordered
   3.542 -  ---------------------------------------------------------------------------*)
   3.543 +subsection{*Trichotomy: the hyperreals are Linearly Ordered*}
   3.544  
   3.545  lemma lemma_hyprel_0_mem: "\<exists>x. x: hyprel `` {%n. 0}"
   3.546 -
   3.547  apply (unfold hyprel_def)
   3.548  apply (rule_tac x = "%n. 0" in exI, safe)
   3.549  apply (auto intro!: FreeUltrafilterNat_Nat_set)
   3.550 @@ -763,9 +656,7 @@
   3.551  apply (insert hypreal_trichotomy [of x], blast) 
   3.552  done
   3.553  
   3.554 -(*----------------------------------------------------------------------------
   3.555 -            More properties of <
   3.556 - ----------------------------------------------------------------------------*)
   3.557 +subsection{*More properties of Less Than*}
   3.558  
   3.559  lemma hypreal_less_minus_iff: "((x::hypreal) < y) = (0 < y + -x)"
   3.560  apply (rule_tac z = x in eq_Abs_hypreal)
   3.561 @@ -789,24 +680,8 @@
   3.562  apply (rule_tac x1 = "-x" in hypreal_add_right_cancel [THEN iffD1], auto)
   3.563  done
   3.564  
   3.565 -(* 07/00 *)
   3.566 -lemma hypreal_diff_zero [simp]: "(0::hypreal) - x = -x"
   3.567 -by (simp add: hypreal_diff_def)
   3.568  
   3.569 -lemma hypreal_diff_zero_right [simp]: "x - (0::hypreal) = x"
   3.570 -by (simp add: hypreal_diff_def)
   3.571 -
   3.572 -lemma hypreal_diff_self [simp]: "x - x = (0::hypreal)"
   3.573 -by (simp add: hypreal_diff_def)
   3.574 -
   3.575 -lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))"
   3.576 -by (auto simp add: hypreal_add_assoc)
   3.577 -
   3.578 -lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x + -a \<noteq> (0::hypreal))"
   3.579 -by (auto dest: hypreal_eq_minus_iff [THEN iffD2])
   3.580 -
   3.581 -
   3.582 -(*** linearity ***)
   3.583 +subsection{*Linearity*}
   3.584  
   3.585  lemma hypreal_linear: "(x::hypreal) < y | x = y | y < x"
   3.586  apply (subst hypreal_eq_minus_iff2)
   3.587 @@ -823,10 +698,8 @@
   3.588  apply (cut_tac x = x and y = y in hypreal_linear, auto)
   3.589  done
   3.590  
   3.591 -(*------------------------------------------------------------------------------
   3.592 -                            Properties of <=
   3.593 - ------------------------------------------------------------------------------*)
   3.594 -(*------ hypreal le iff reals le a.e ------*)
   3.595 +
   3.596 +subsection{*Properties of The @{text "\<le>"} Relation*}
   3.597  
   3.598  lemma hypreal_le: 
   3.599        "(Abs_hypreal(hyprel``{%n. X n}) <=  
   3.600 @@ -837,8 +710,6 @@
   3.601  apply (ultra+)
   3.602  done
   3.603  
   3.604 -(*---------------------------------------------------------*)
   3.605 -(*---------------------------------------------------------*)
   3.606  lemma hypreal_leI: 
   3.607       "~(w < z) ==> z <= (w::hypreal)"
   3.608  apply (unfold hypreal_le_def, assumption)
   3.609 @@ -894,17 +765,21 @@
   3.610  apply (fast elim: hypreal_less_irrefl hypreal_less_asym)
   3.611  done
   3.612  
   3.613 -lemma not_less_not_eq_hypreal_less: "[| ~ y < x; y \<noteq> x |] ==> x < (y::hypreal)"
   3.614 -apply (rule not_hypreal_leE)
   3.615 -apply (fast dest: hypreal_le_imp_less_or_eq)
   3.616 -done
   3.617 -
   3.618  (* Axiom 'order_less_le' of class 'order': *)
   3.619  lemma hypreal_less_le: "((w::hypreal) < z) = (w <= z & w \<noteq> z)"
   3.620  apply (simp add: hypreal_le_def hypreal_neq_iff)
   3.621  apply (blast intro: hypreal_less_asym)
   3.622  done
   3.623  
   3.624 +instance hypreal :: order
   3.625 +  by (intro_classes,
   3.626 +      (assumption | 
   3.627 +       rule hypreal_le_refl hypreal_le_trans hypreal_le_anti_sym
   3.628 +            hypreal_less_le)+)
   3.629 +
   3.630 +instance hypreal :: linorder 
   3.631 +  by (intro_classes, rule hypreal_le_linear)
   3.632 +
   3.633  lemma hypreal_minus_zero_less_iff [simp]: "(0 < -R) = (R < (0::hypreal))"
   3.634  apply (rule_tac z = R in eq_Abs_hypreal)
   3.635  apply (auto simp add: hypreal_zero_def hypreal_less hypreal_minus)
   3.636 @@ -925,9 +800,141 @@
   3.637  apply (simp add: hypreal_minus_zero_less_iff2)
   3.638  done
   3.639  
   3.640 -(*----------------------------------------------------------
   3.641 -  hypreal_of_real preserves field and order properties
   3.642 - -----------------------------------------------------------*)
   3.643 +
   3.644 +lemma hypreal_self_eq_minus_self_zero: "x = -x ==> x = (0::hypreal)"
   3.645 +apply (rule_tac z = x in eq_Abs_hypreal)
   3.646 +apply (auto simp add: hypreal_minus hypreal_zero_def, ultra)
   3.647 +done
   3.648 +
   3.649 +lemma hypreal_add_self_zero_cancel [simp]: "(x + x = 0) = (x = (0::hypreal))"
   3.650 +apply (rule_tac z = x in eq_Abs_hypreal)
   3.651 +apply (auto simp add: hypreal_add hypreal_zero_def)
   3.652 +done
   3.653 +
   3.654 +lemma hypreal_add_self_zero_cancel2 [simp]:
   3.655 +     "(x + x + y = y) = (x = (0::hypreal))"
   3.656 +apply auto
   3.657 +apply (drule hypreal_eq_minus_iff [THEN iffD1])
   3.658 +apply (auto simp add: hypreal_add_assoc hypreal_self_eq_minus_self_zero)
   3.659 +done
   3.660 +
   3.661 +lemma hypreal_minus_eq_swap: "(b = -a) = (-b = (a::hypreal))"
   3.662 +by auto
   3.663 +
   3.664 +lemma hypreal_minus_eq_cancel [simp]: "(-b = -a) = (b = (a::hypreal))"
   3.665 +by (simp add: hypreal_minus_eq_swap)
   3.666 +
   3.667 +lemma hypreal_add_less_mono1: "(A::hypreal) < B ==> A + C < B + C"
   3.668 +apply (rule_tac z = A in eq_Abs_hypreal)
   3.669 +apply (rule_tac z = B in eq_Abs_hypreal)
   3.670 +apply (rule_tac z = C in eq_Abs_hypreal)
   3.671 +apply (auto intro!: exI simp add: hypreal_less_def hypreal_add, ultra)
   3.672 +done
   3.673 +
   3.674 +lemma hypreal_mult_order: "[| 0 < x; 0 < y |] ==> (0::hypreal) < x * y"
   3.675 +apply (unfold hypreal_zero_def)
   3.676 +apply (rule_tac z = x in eq_Abs_hypreal)
   3.677 +apply (rule_tac z = y in eq_Abs_hypreal)
   3.678 +apply (auto intro!: exI simp add: hypreal_less_def hypreal_mult, ultra)
   3.679 +apply (auto intro: real_mult_order)
   3.680 +done
   3.681 +
   3.682 +lemma hypreal_add_left_le_mono1: "(q1::hypreal) \<le> q2  ==> x + q1 \<le> x + q2"
   3.683 +apply (drule order_le_imp_less_or_eq)
   3.684 +apply (auto intro: order_less_imp_le hypreal_add_less_mono1 simp add: hypreal_add_commute)
   3.685 +done
   3.686 +
   3.687 +lemma hypreal_mult_less_mono1: "[| (0::hypreal) < z; x < y |] ==> x*z < y*z"
   3.688 +apply (rotate_tac 1)
   3.689 +apply (drule hypreal_less_minus_iff [THEN iffD1])
   3.690 +apply (rule hypreal_less_minus_iff [THEN iffD2])
   3.691 +apply (drule hypreal_mult_order, assumption)
   3.692 +apply (simp add: hypreal_add_mult_distrib2 hypreal_mult_commute)
   3.693 +done
   3.694 +
   3.695 +lemma hypreal_mult_less_mono2: "[| (0::hypreal)<z; x<y |] ==> z*x<z*y"
   3.696 +apply (simp (no_asm_simp) add: hypreal_mult_commute hypreal_mult_less_mono1)
   3.697 +done
   3.698 +
   3.699 +subsection{*The Hyperreals Form an Ordered Field*}
   3.700 +
   3.701 +instance hypreal :: inverse ..
   3.702 +
   3.703 +instance hypreal :: ordered_field
   3.704 +proof
   3.705 +  fix x y z :: hypreal
   3.706 +  show "(x + y) + z = x + (y + z)" by (rule hypreal_add_assoc)
   3.707 +  show "x + y = y + x" by (rule hypreal_add_commute)
   3.708 +  show "0 + x = x" by simp
   3.709 +  show "- x + x = 0" by simp
   3.710 +  show "x - y = x + (-y)" by (simp add: hypreal_diff_def)
   3.711 +  show "(x * y) * z = x * (y * z)" by (rule hypreal_mult_assoc)
   3.712 +  show "x * y = y * x" by (rule hypreal_mult_commute)
   3.713 +  show "1 * x = x" by simp
   3.714 +  show "(x + y) * z = x * z + y * z" by (simp add: hypreal_add_mult_distrib)
   3.715 +  show "0 \<noteq> (1::hypreal)" by (rule hypreal_zero_not_eq_one)
   3.716 +  show "x \<le> y ==> z + x \<le> z + y" by (rule hypreal_add_left_le_mono1)
   3.717 +  show "x < y ==> 0 < z ==> z * x < z * y" by (simp add: hypreal_mult_less_mono2)
   3.718 +  show "\<bar>x\<bar> = (if x < 0 then -x else x)"
   3.719 +    by (auto dest: order_le_less_trans simp add: hrabs_def linorder_not_le)
   3.720 +  show "x \<noteq> 0 ==> inverse x * x = 1" by simp
   3.721 +  show "y \<noteq> 0 ==> x / y = x * inverse y" by (simp add: hypreal_divide_def)
   3.722 +qed
   3.723 +
   3.724 +lemma hypreal_minus_add_distrib [simp]: "-(x + (y::hypreal)) = -x + -y"
   3.725 +  by (rule Ring_and_Field.minus_add_distrib)
   3.726 +
   3.727 +(*Used ONCE: in NSA.ML*)
   3.728 +lemma hypreal_minus_distrib1: "-(y + -(x::hypreal)) = x + -y"
   3.729 +by (simp add: hypreal_add_commute)
   3.730 +
   3.731 +(*Used ONCE: in Lim.ML*)
   3.732 +lemma hypreal_eq_minus_iff3: "(x = y + z) = (x + -z = (y::hypreal))"
   3.733 +by (auto simp add: hypreal_add_assoc)
   3.734 +
   3.735 +lemma hypreal_not_eq_minus_iff: "(x \<noteq> a) = (x + -a \<noteq> (0::hypreal))"
   3.736 +by (auto dest: hypreal_eq_minus_iff [THEN iffD2])
   3.737 +
   3.738 +lemma hypreal_mult_left_cancel: "(c::hypreal) \<noteq> 0 ==> (c*a=c*b) = (a=b)"
   3.739 +apply auto
   3.740 +done
   3.741 +    
   3.742 +lemma hypreal_mult_right_cancel: "(c::hypreal) \<noteq> 0 ==> (a*c=b*c) = (a=b)"
   3.743 +apply auto
   3.744 +done
   3.745 +
   3.746 +lemma hypreal_inverse_not_zero: "x \<noteq> 0 ==> inverse (x::hypreal) \<noteq> 0"
   3.747 +  by (rule Ring_and_Field.nonzero_imp_inverse_nonzero)
   3.748 +
   3.749 +lemma hypreal_mult_not_0: "[| x \<noteq> 0; y \<noteq> 0 |] ==> x * y \<noteq> (0::hypreal)"
   3.750 +by simp
   3.751 +
   3.752 +lemma hypreal_minus_inverse: "inverse(-x) = -inverse(x::hypreal)"
   3.753 +  by (rule Ring_and_Field.inverse_minus_eq)
   3.754 +
   3.755 +lemma hypreal_inverse_distrib: "inverse(x*y) = inverse(x)*inverse(y::hypreal)"
   3.756 +  by (rule Ring_and_Field.inverse_mult_distrib)
   3.757 +
   3.758 +
   3.759 +subsection{* Division lemmas *}
   3.760 +
   3.761 +lemma hypreal_divide_one: "x/(1::hypreal) = x"
   3.762 +by (simp add: hypreal_divide_def)
   3.763 +
   3.764 +
   3.765 +(** As with multiplication, pull minus signs OUT of the / operator **)
   3.766 +
   3.767 +lemma hypreal_add_divide_distrib: "(x+y)/(z::hypreal) = x/z + y/z"
   3.768 +  by (rule Ring_and_Field.add_divide_distrib)
   3.769 +
   3.770 +lemma hypreal_inverse_add:
   3.771 +     "[|(x::hypreal) \<noteq> 0;  y \<noteq> 0 |]   
   3.772 +      ==> inverse(x) + inverse(y) = (x + y)*inverse(x*y)"
   3.773 +by (simp add: Ring_and_Field.inverse_add mult_assoc)
   3.774 +
   3.775 +
   3.776 +subsection{*@{term hypreal_of_real} Preserves Field and Order Properties*}
   3.777 +
   3.778  lemma hypreal_of_real_add [simp]: 
   3.779       "hypreal_of_real (z1 + z2) = hypreal_of_real z1 + hypreal_of_real z2"
   3.780  apply (unfold hypreal_of_real_def)
   3.781 @@ -953,10 +960,12 @@
   3.782  apply (unfold hypreal_le_def real_le_def, auto)
   3.783  done
   3.784  
   3.785 -lemma hypreal_of_real_eq_iff [simp]: "(hypreal_of_real z1 = hypreal_of_real z2) = (z1 = z2)"
   3.786 +lemma hypreal_of_real_eq_iff [simp]:
   3.787 +     "(hypreal_of_real z1 = hypreal_of_real z2) = (z1 = z2)"
   3.788  by (force intro: order_antisym hypreal_of_real_le_iff [THEN iffD1])
   3.789  
   3.790 -lemma hypreal_of_real_minus [simp]: "hypreal_of_real (-r) = - hypreal_of_real  r"
   3.791 +lemma hypreal_of_real_minus [simp]:
   3.792 +     "hypreal_of_real (-r) = - hypreal_of_real  r"
   3.793  apply (unfold hypreal_of_real_def)
   3.794  apply (auto simp add: hypreal_minus)
   3.795  done
   3.796 @@ -970,146 +979,20 @@
   3.797  lemma hypreal_of_real_zero_iff: "(hypreal_of_real r = 0) = (r = 0)"
   3.798  by (auto intro: FreeUltrafilterNat_P simp add: hypreal_of_real_def hypreal_zero_def FreeUltrafilterNat_Nat_set)
   3.799  
   3.800 -lemma hypreal_of_real_inverse [simp]: "hypreal_of_real (inverse r) = inverse (hypreal_of_real r)"
   3.801 +lemma hypreal_of_real_inverse [simp]:
   3.802 +     "hypreal_of_real (inverse r) = inverse (hypreal_of_real r)"
   3.803  apply (case_tac "r=0")
   3.804  apply (simp add: DIVISION_BY_ZERO INVERSE_ZERO HYPREAL_INVERSE_ZERO)
   3.805  apply (rule_tac c1 = "hypreal_of_real r" in hypreal_mult_left_cancel [THEN iffD1])
   3.806  apply (auto simp add: hypreal_of_real_zero_iff hypreal_of_real_mult [symmetric])
   3.807  done
   3.808  
   3.809 -lemma hypreal_of_real_divide [simp]: "hypreal_of_real (z1 / z2) = hypreal_of_real z1 / hypreal_of_real z2"
   3.810 +lemma hypreal_of_real_divide [simp]:
   3.811 +     "hypreal_of_real (z1 / z2) = hypreal_of_real z1 / hypreal_of_real z2"
   3.812  by (simp add: hypreal_divide_def real_divide_def)
   3.813  
   3.814  
   3.815 -(*** Division lemmas ***)
   3.816 -
   3.817 -lemma hypreal_zero_divide: "(0::hypreal)/x = 0"
   3.818 -by (simp add: hypreal_divide_def)
   3.819 -
   3.820 -lemma hypreal_divide_one: "x/(1::hypreal) = x"
   3.821 -by (simp add: hypreal_divide_def)
   3.822 -declare hypreal_zero_divide [simp] hypreal_divide_one [simp]
   3.823 -
   3.824 -lemma hypreal_divide_divide1_eq [simp]: "(x::hypreal) / (y/z) = (x*z)/y"
   3.825 -by (simp add: hypreal_divide_def hypreal_inverse_distrib hypreal_mult_ac)
   3.826 -
   3.827 -lemma hypreal_divide_divide2_eq [simp]: "((x::hypreal) / y) / z = x/(y*z)"
   3.828 -by (simp add: hypreal_divide_def hypreal_inverse_distrib hypreal_mult_assoc)
   3.829 -
   3.830 -
   3.831 -(** As with multiplication, pull minus signs OUT of the / operator **)
   3.832 -
   3.833 -lemma hypreal_minus_divide_eq [simp]: "(-x) / (y::hypreal) = - (x/y)"
   3.834 -by (simp add: hypreal_divide_def)
   3.835 -
   3.836 -lemma hypreal_divide_minus_eq [simp]: "(x / -(y::hypreal)) = - (x/y)"
   3.837 -by (simp add: hypreal_divide_def hypreal_minus_inverse)
   3.838 -
   3.839 -lemma hypreal_add_divide_distrib: "(x+y)/(z::hypreal) = x/z + y/z"
   3.840 -by (simp add: hypreal_divide_def hypreal_add_mult_distrib)
   3.841 -
   3.842 -lemma hypreal_inverse_add: "[|(x::hypreal) \<noteq> 0;  y \<noteq> 0 |]   
   3.843 -      ==> inverse(x) + inverse(y) = (x + y)*inverse(x*y)"
   3.844 -apply (simp add: hypreal_inverse_distrib hypreal_add_mult_distrib hypreal_mult_assoc [symmetric])
   3.845 -apply (subst hypreal_mult_assoc)
   3.846 -apply (rule hypreal_mult_left_commute [THEN subst])
   3.847 -apply (simp add: hypreal_add_commute)
   3.848 -done
   3.849 -
   3.850 -lemma hypreal_self_eq_minus_self_zero: "x = -x ==> x = (0::hypreal)"
   3.851 -apply (rule_tac z = x in eq_Abs_hypreal)
   3.852 -apply (auto simp add: hypreal_minus hypreal_zero_def, ultra)
   3.853 -done
   3.854 -
   3.855 -lemma hypreal_add_self_zero_cancel [simp]: "(x + x = 0) = (x = (0::hypreal))"
   3.856 -apply (rule_tac z = x in eq_Abs_hypreal)
   3.857 -apply (auto simp add: hypreal_add hypreal_zero_def)
   3.858 -done
   3.859 -
   3.860 -lemma hypreal_add_self_zero_cancel2 [simp]: "(x + x + y = y) = (x = (0::hypreal))"
   3.861 -apply auto
   3.862 -apply (drule hypreal_eq_minus_iff [THEN iffD1])
   3.863 -apply (auto simp add: hypreal_add_assoc hypreal_self_eq_minus_self_zero)
   3.864 -done
   3.865 -
   3.866 -lemma hypreal_add_self_zero_cancel2a [simp]: "(x + (x + y) = y) = (x = (0::hypreal))"
   3.867 -by (simp add: hypreal_add_assoc [symmetric])
   3.868 -
   3.869 -lemma hypreal_minus_eq_swap: "(b = -a) = (-b = (a::hypreal))"
   3.870 -by auto
   3.871 -
   3.872 -lemma hypreal_minus_eq_cancel [simp]: "(-b = -a) = (b = (a::hypreal))"
   3.873 -by (simp add: hypreal_minus_eq_swap)
   3.874 -
   3.875 -lemma hypreal_less_eq_diff: "(x<y) = (x-y < (0::hypreal))"
   3.876 -apply (unfold hypreal_diff_def)
   3.877 -apply (rule hypreal_less_minus_iff2)
   3.878 -done
   3.879 -
   3.880 -(*** Subtraction laws ***)
   3.881 -
   3.882 -lemma hypreal_add_diff_eq: "x + (y - z) = (x + y) - (z::hypreal)"
   3.883 -by (simp add: hypreal_diff_def hypreal_add_ac)
   3.884 -
   3.885 -lemma hypreal_diff_add_eq: "(x - y) + z = (x + z) - (y::hypreal)"
   3.886 -by (simp add: hypreal_diff_def hypreal_add_ac)
   3.887 -
   3.888 -lemma hypreal_diff_diff_eq: "(x - y) - z = x - (y + (z::hypreal))"
   3.889 -by (simp add: hypreal_diff_def hypreal_add_ac)
   3.890 -
   3.891 -lemma hypreal_diff_diff_eq2: "x - (y - z) = (x + z) - (y::hypreal)"
   3.892 -by (simp add: hypreal_diff_def hypreal_add_ac)
   3.893 -
   3.894 -lemma hypreal_diff_less_eq: "(x-y < z) = (x < z + (y::hypreal))"
   3.895 -apply (subst hypreal_less_eq_diff)
   3.896 -apply (rule_tac y1 = z in hypreal_less_eq_diff [THEN ssubst])
   3.897 -apply (simp add: hypreal_diff_def hypreal_add_ac)
   3.898 -done
   3.899 -
   3.900 -lemma hypreal_less_diff_eq: "(x < z-y) = (x + (y::hypreal) < z)"
   3.901 -apply (subst hypreal_less_eq_diff)
   3.902 -apply (rule_tac y1 = "z-y" in hypreal_less_eq_diff [THEN ssubst])
   3.903 -apply (simp add: hypreal_diff_def hypreal_add_ac)
   3.904 -done
   3.905 -
   3.906 -lemma hypreal_diff_le_eq: "(x-y <= z) = (x <= z + (y::hypreal))"
   3.907 -apply (unfold hypreal_le_def)
   3.908 -apply (simp add: hypreal_less_diff_eq)
   3.909 -done
   3.910 -
   3.911 -lemma hypreal_le_diff_eq: "(x <= z-y) = (x + (y::hypreal) <= z)"
   3.912 -apply (unfold hypreal_le_def)
   3.913 -apply (simp add: hypreal_diff_less_eq)
   3.914 -done
   3.915 -
   3.916 -lemma hypreal_diff_eq_eq: "(x-y = z) = (x = z + (y::hypreal))"
   3.917 -apply (unfold hypreal_diff_def)
   3.918 -apply (auto simp add: hypreal_add_assoc)
   3.919 -done
   3.920 -
   3.921 -lemma hypreal_eq_diff_eq: "(x = z-y) = (x + (y::hypreal) = z)"
   3.922 -apply (unfold hypreal_diff_def)
   3.923 -apply (auto simp add: hypreal_add_assoc)
   3.924 -done
   3.925 -
   3.926 -
   3.927 -(** For the cancellation simproc.
   3.928 -    The idea is to cancel like terms on opposite sides by subtraction **)
   3.929 -
   3.930 -lemma hypreal_less_eqI: "(x::hypreal) - y = x' - y' ==> (x<y) = (x'<y')"
   3.931 -apply (subst hypreal_less_eq_diff)
   3.932 -apply (rule_tac y1 = y in hypreal_less_eq_diff [THEN ssubst], simp)
   3.933 -done
   3.934 -
   3.935 -lemma hypreal_le_eqI: "(x::hypreal) - y = x' - y' ==> (y<=x) = (y'<=x')"
   3.936 -apply (drule hypreal_less_eqI)
   3.937 -apply (simp add: hypreal_le_def)
   3.938 -done
   3.939 -
   3.940 -lemma hypreal_eq_eqI: "(x::hypreal) - y = x' - y' ==> (x=y) = (x'=y')"
   3.941 -apply safe
   3.942 -apply (simp_all add: hypreal_eq_diff_eq hypreal_diff_eq_eq)
   3.943 -done
   3.944 +subsection{*Misc Others*}
   3.945  
   3.946  lemma hypreal_zero_num: "0 = Abs_hypreal (hyprel `` {%n. 0})"
   3.947  by (simp add: hypreal_zero_def [THEN meta_eq_to_obj_eq, symmetric])
   3.948 @@ -1122,8 +1005,19 @@
   3.949  apply (auto simp add: hypreal_less hypreal_zero_num)
   3.950  done
   3.951  
   3.952 +
   3.953 +lemma hypreal_hrabs:
   3.954 +     "abs (Abs_hypreal (hyprel `` {X})) = 
   3.955 +      Abs_hypreal(hyprel `` {%n. abs (X n)})"
   3.956 +apply (auto simp add: hrabs_def hypreal_zero_def hypreal_le hypreal_minus)
   3.957 +apply (ultra, arith)+
   3.958 +done
   3.959 +
   3.960  ML
   3.961  {*
   3.962 +val hrabs_def = thm "hrabs_def";
   3.963 +val hypreal_hrabs = thm "hypreal_hrabs";
   3.964 +
   3.965  val hypreal_zero_def = thm "hypreal_zero_def";
   3.966  val hypreal_one_def = thm "hypreal_one_def";
   3.967  val hypreal_minus_def = thm "hypreal_minus_def";
   3.968 @@ -1189,11 +1083,6 @@
   3.969  val hypreal_add_zero_right = thm "hypreal_add_zero_right";
   3.970  val hypreal_add_minus = thm "hypreal_add_minus";
   3.971  val hypreal_add_minus_left = thm "hypreal_add_minus_left";
   3.972 -val hypreal_minus_ex = thm "hypreal_minus_ex";
   3.973 -val hypreal_minus_ex1 = thm "hypreal_minus_ex1";
   3.974 -val hypreal_minus_left_ex1 = thm "hypreal_minus_left_ex1";
   3.975 -val hypreal_add_minus_eq_minus = thm "hypreal_add_minus_eq_minus";
   3.976 -val hypreal_as_add_inverse_ex = thm "hypreal_as_add_inverse_ex";
   3.977  val hypreal_minus_add_distrib = thm "hypreal_minus_add_distrib";
   3.978  val hypreal_minus_distrib1 = thm "hypreal_minus_distrib1";
   3.979  val hypreal_add_left_cancel = thm "hypreal_add_left_cancel";
   3.980 @@ -1214,7 +1103,6 @@
   3.981  val hypreal_mult_minus_1 = thm "hypreal_mult_minus_1";
   3.982  val hypreal_mult_minus_1_right = thm "hypreal_mult_minus_1_right";
   3.983  val hypreal_minus_mult_commute = thm "hypreal_minus_mult_commute";
   3.984 -val hypreal_add_assoc_cong = thm "hypreal_add_assoc_cong";
   3.985  val hypreal_add_mult_distrib = thm "hypreal_add_mult_distrib";
   3.986  val hypreal_add_mult_distrib2 = thm "hypreal_add_mult_distrib2";
   3.987  val hypreal_diff_mult_distrib = thm "hypreal_diff_mult_distrib";
   3.988 @@ -1224,35 +1112,24 @@
   3.989  val hypreal_inverse = thm "hypreal_inverse";
   3.990  val HYPREAL_INVERSE_ZERO = thm "HYPREAL_INVERSE_ZERO";
   3.991  val HYPREAL_DIVISION_BY_ZERO = thm "HYPREAL_DIVISION_BY_ZERO";
   3.992 -val hypreal_inverse_inverse = thm "hypreal_inverse_inverse";
   3.993 -val hypreal_inverse_1 = thm "hypreal_inverse_1";
   3.994  val hypreal_mult_inverse = thm "hypreal_mult_inverse";
   3.995  val hypreal_mult_inverse_left = thm "hypreal_mult_inverse_left";
   3.996  val hypreal_mult_left_cancel = thm "hypreal_mult_left_cancel";
   3.997  val hypreal_mult_right_cancel = thm "hypreal_mult_right_cancel";
   3.998  val hypreal_inverse_not_zero = thm "hypreal_inverse_not_zero";
   3.999  val hypreal_mult_not_0 = thm "hypreal_mult_not_0";
  3.1000 -val hypreal_mult_zero_disj = thm "hypreal_mult_zero_disj";
  3.1001  val hypreal_minus_inverse = thm "hypreal_minus_inverse";
  3.1002  val hypreal_inverse_distrib = thm "hypreal_inverse_distrib";
  3.1003 -val hypreal_less_iff = thm "hypreal_less_iff";
  3.1004 -val hypreal_lessI = thm "hypreal_lessI";
  3.1005 -val hypreal_lessE = thm "hypreal_lessE";
  3.1006 -val hypreal_lessD = thm "hypreal_lessD";
  3.1007  val hypreal_less_not_refl = thm "hypreal_less_not_refl";
  3.1008  val hypreal_not_refl2 = thm "hypreal_not_refl2";
  3.1009  val hypreal_less_trans = thm "hypreal_less_trans";
  3.1010  val hypreal_less_asym = thm "hypreal_less_asym";
  3.1011  val hypreal_less = thm "hypreal_less";
  3.1012  val hypreal_trichotomy = thm "hypreal_trichotomy";
  3.1013 -val hypreal_trichotomyE = thm "hypreal_trichotomyE";
  3.1014  val hypreal_less_minus_iff = thm "hypreal_less_minus_iff";
  3.1015  val hypreal_less_minus_iff2 = thm "hypreal_less_minus_iff2";
  3.1016  val hypreal_eq_minus_iff = thm "hypreal_eq_minus_iff";
  3.1017  val hypreal_eq_minus_iff2 = thm "hypreal_eq_minus_iff2";
  3.1018 -val hypreal_diff_zero = thm "hypreal_diff_zero";
  3.1019 -val hypreal_diff_zero_right = thm "hypreal_diff_zero_right";
  3.1020 -val hypreal_diff_self = thm "hypreal_diff_self";
  3.1021  val hypreal_eq_minus_iff3 = thm "hypreal_eq_minus_iff3";
  3.1022  val hypreal_not_eq_minus_iff = thm "hypreal_not_eq_minus_iff";
  3.1023  val hypreal_linear = thm "hypreal_linear";
  3.1024 @@ -1270,7 +1147,6 @@
  3.1025  val hypreal_le_linear = thm "hypreal_le_linear";
  3.1026  val hypreal_le_trans = thm "hypreal_le_trans";
  3.1027  val hypreal_le_anti_sym = thm "hypreal_le_anti_sym";
  3.1028 -val not_less_not_eq_hypreal_less = thm "not_less_not_eq_hypreal_less";
  3.1029  val hypreal_less_le = thm "hypreal_less_le";
  3.1030  val hypreal_minus_zero_less_iff = thm "hypreal_minus_zero_less_iff";
  3.1031  val hypreal_minus_zero_less_iff2 = thm "hypreal_minus_zero_less_iff2";
  3.1032 @@ -1287,34 +1163,14 @@
  3.1033  val hypreal_of_real_zero_iff = thm "hypreal_of_real_zero_iff";
  3.1034  val hypreal_of_real_inverse = thm "hypreal_of_real_inverse";
  3.1035  val hypreal_of_real_divide = thm "hypreal_of_real_divide";
  3.1036 -val hypreal_zero_divide = thm "hypreal_zero_divide";
  3.1037  val hypreal_divide_one = thm "hypreal_divide_one";
  3.1038 -val hypreal_divide_divide1_eq = thm "hypreal_divide_divide1_eq";
  3.1039 -val hypreal_divide_divide2_eq = thm "hypreal_divide_divide2_eq";
  3.1040 -val hypreal_minus_divide_eq = thm "hypreal_minus_divide_eq";
  3.1041 -val hypreal_divide_minus_eq = thm "hypreal_divide_minus_eq";
  3.1042  val hypreal_add_divide_distrib = thm "hypreal_add_divide_distrib";
  3.1043  val hypreal_inverse_add = thm "hypreal_inverse_add";
  3.1044  val hypreal_self_eq_minus_self_zero = thm "hypreal_self_eq_minus_self_zero";
  3.1045  val hypreal_add_self_zero_cancel = thm "hypreal_add_self_zero_cancel";
  3.1046  val hypreal_add_self_zero_cancel2 = thm "hypreal_add_self_zero_cancel2";
  3.1047 -val hypreal_add_self_zero_cancel2a = thm "hypreal_add_self_zero_cancel2a";
  3.1048  val hypreal_minus_eq_swap = thm "hypreal_minus_eq_swap";
  3.1049  val hypreal_minus_eq_cancel = thm "hypreal_minus_eq_cancel";
  3.1050 -val hypreal_less_eq_diff = thm "hypreal_less_eq_diff";
  3.1051 -val hypreal_add_diff_eq = thm "hypreal_add_diff_eq";
  3.1052 -val hypreal_diff_add_eq = thm "hypreal_diff_add_eq";
  3.1053 -val hypreal_diff_diff_eq = thm "hypreal_diff_diff_eq";
  3.1054 -val hypreal_diff_diff_eq2 = thm "hypreal_diff_diff_eq2";
  3.1055 -val hypreal_diff_less_eq = thm "hypreal_diff_less_eq";
  3.1056 -val hypreal_less_diff_eq = thm "hypreal_less_diff_eq";
  3.1057 -val hypreal_diff_le_eq = thm "hypreal_diff_le_eq";
  3.1058 -val hypreal_le_diff_eq = thm "hypreal_le_diff_eq";
  3.1059 -val hypreal_diff_eq_eq = thm "hypreal_diff_eq_eq";
  3.1060 -val hypreal_eq_diff_eq = thm "hypreal_eq_diff_eq";
  3.1061 -val hypreal_less_eqI = thm "hypreal_less_eqI";
  3.1062 -val hypreal_le_eqI = thm "hypreal_le_eqI";
  3.1063 -val hypreal_eq_eqI = thm "hypreal_eq_eqI";
  3.1064  val hypreal_zero_num = thm "hypreal_zero_num";
  3.1065  val hypreal_one_num = thm "hypreal_one_num";
  3.1066  val hypreal_omega_gt_zero = thm "hypreal_omega_gt_zero";
     4.1 --- a/src/HOL/Hyperreal/HyperOrd.thy	Wed Dec 24 08:54:30 2003 +0100
     4.2 +++ b/src/HOL/Hyperreal/HyperOrd.thy	Thu Dec 25 22:48:32 2003 +0100
     4.3 @@ -7,95 +7,6 @@
     4.4  
     4.5  theory HyperOrd = HyperDef:
     4.6  
     4.7 -instance hypreal :: division_by_zero
     4.8 -proof
     4.9 -  fix x :: hypreal
    4.10 -  show "inverse 0 = (0::hypreal)" by (rule HYPREAL_INVERSE_ZERO)
    4.11 -  show "x/0 = 0" by (rule HYPREAL_DIVISION_BY_ZERO) 
    4.12 -qed
    4.13 -
    4.14 -
    4.15 -defs (overloaded)
    4.16 -  hrabs_def:  "abs (r::hypreal) == (if 0 \<le> r then r else -r)"
    4.17 -
    4.18 -
    4.19 -lemma hypreal_hrabs:
    4.20 -     "abs (Abs_hypreal (hyprel `` {X})) = 
    4.21 -      Abs_hypreal(hyprel `` {%n. abs (X n)})"
    4.22 -apply (auto simp add: hrabs_def hypreal_zero_def hypreal_le hypreal_minus)
    4.23 -apply (ultra, arith)+
    4.24 -done
    4.25 -
    4.26 -instance hypreal :: order
    4.27 -  by (intro_classes,
    4.28 -      (assumption | 
    4.29 -       rule hypreal_le_refl hypreal_le_trans hypreal_le_anti_sym
    4.30 -            hypreal_less_le)+)
    4.31 -
    4.32 -instance hypreal :: linorder 
    4.33 -  by (intro_classes, rule hypreal_le_linear)
    4.34 -
    4.35 -instance hypreal :: plus_ac0
    4.36 -  by (intro_classes,
    4.37 -      (assumption | 
    4.38 -       rule hypreal_add_commute hypreal_add_assoc hypreal_add_zero_left)+)
    4.39 -
    4.40 -lemma hypreal_add_less_mono1: "(A::hypreal) < B ==> A + C < B + C"
    4.41 -apply (rule_tac z = A in eq_Abs_hypreal)
    4.42 -apply (rule_tac z = B in eq_Abs_hypreal)
    4.43 -apply (rule_tac z = C in eq_Abs_hypreal)
    4.44 -apply (auto intro!: exI simp add: hypreal_less_def hypreal_add, ultra)
    4.45 -done
    4.46 -
    4.47 -lemma hypreal_mult_order: "[| 0 < x; 0 < y |] ==> (0::hypreal) < x * y"
    4.48 -apply (unfold hypreal_zero_def)
    4.49 -apply (rule_tac z = x in eq_Abs_hypreal)
    4.50 -apply (rule_tac z = y in eq_Abs_hypreal)
    4.51 -apply (auto intro!: exI simp add: hypreal_less_def hypreal_mult, ultra)
    4.52 -apply (auto intro: real_mult_order)
    4.53 -done
    4.54 -
    4.55 -lemma hypreal_add_left_le_mono1: "(q1::hypreal) \<le> q2  ==> x + q1 \<le> x + q2"
    4.56 -apply (drule order_le_imp_less_or_eq)
    4.57 -apply (auto intro: order_less_imp_le hypreal_add_less_mono1 simp add: hypreal_add_commute)
    4.58 -done
    4.59 -
    4.60 -lemma hypreal_mult_less_mono1: "[| (0::hypreal) < z; x < y |] ==> x*z < y*z"
    4.61 -apply (rotate_tac 1)
    4.62 -apply (drule hypreal_less_minus_iff [THEN iffD1])
    4.63 -apply (rule hypreal_less_minus_iff [THEN iffD2])
    4.64 -apply (drule hypreal_mult_order, assumption)
    4.65 -apply (simp add: hypreal_add_mult_distrib2 hypreal_mult_commute)
    4.66 -done
    4.67 -
    4.68 -lemma hypreal_mult_less_mono2: "[| (0::hypreal)<z; x<y |] ==> z*x<z*y"
    4.69 -apply (simp (no_asm_simp) add: hypreal_mult_commute hypreal_mult_less_mono1)
    4.70 -done
    4.71 -
    4.72 -subsection{*The Hyperreals Form an Ordered Field*}
    4.73 -
    4.74 -instance hypreal :: inverse ..
    4.75 -
    4.76 -instance hypreal :: ordered_field
    4.77 -proof
    4.78 -  fix x y z :: hypreal
    4.79 -  show "(x + y) + z = x + (y + z)" by (rule hypreal_add_assoc)
    4.80 -  show "x + y = y + x" by (rule hypreal_add_commute)
    4.81 -  show "0 + x = x" by simp
    4.82 -  show "- x + x = 0" by simp
    4.83 -  show "x - y = x + (-y)" by (simp add: hypreal_diff_def)
    4.84 -  show "(x * y) * z = x * (y * z)" by (rule hypreal_mult_assoc)
    4.85 -  show "x * y = y * x" by (rule hypreal_mult_commute)
    4.86 -  show "1 * x = x" by simp
    4.87 -  show "(x + y) * z = x * z + y * z" by (simp add: hypreal_add_mult_distrib)
    4.88 -  show "0 \<noteq> (1::hypreal)" by (rule hypreal_zero_not_eq_one)
    4.89 -  show "x \<le> y ==> z + x \<le> z + y" by (rule hypreal_add_left_le_mono1)
    4.90 -  show "x < y ==> 0 < z ==> z * x < z * y" by (simp add: hypreal_mult_less_mono2)
    4.91 -  show "\<bar>x\<bar> = (if x < 0 then -x else x)"
    4.92 -    by (auto dest: order_le_less_trans simp add: hrabs_def linorder_not_le)
    4.93 -  show "x \<noteq> 0 ==> inverse x * x = 1" by simp
    4.94 -  show "y \<noteq> 0 ==> x / y = x * inverse y" by (simp add: hypreal_divide_def)
    4.95 -qed
    4.96  
    4.97  (*** Monotonicity results ***)
    4.98  
    4.99 @@ -277,9 +188,6 @@
   4.100  
   4.101  ML
   4.102  {*
   4.103 -val hrabs_def = thm "hrabs_def";
   4.104 -val hypreal_hrabs = thm "hypreal_hrabs";
   4.105 -
   4.106  val hypreal_add_less_mono1 = thm"hypreal_add_less_mono1";
   4.107  val hypreal_add_less_mono2 = thm"hypreal_add_less_mono2";
   4.108  val hypreal_mult_order = thm"hypreal_mult_order";
     5.1 --- a/src/HOL/Hyperreal/Integration.ML	Wed Dec 24 08:54:30 2003 +0100
     5.2 +++ b/src/HOL/Hyperreal/Integration.ML	Thu Dec 25 22:48:32 2003 +0100
     5.3 @@ -183,7 +183,7 @@
     5.4  by (dres_inst_tac [("x","psize D - Suc n")] spec 2);
     5.5  by (thin_tac "ALL n. psize D <= n --> D n = b" 2);
     5.6  by (Asm_full_simp_tac 2);
     5.7 -by (Blast_tac 1);
     5.8 +by (arith_tac 1);
     5.9  qed "partition_ub";
    5.10  
    5.11  Goal "[| partition(a,b) D; n < psize D |] ==> D(n) < b"; 
     6.1 --- a/src/HOL/Hyperreal/NSA.ML	Wed Dec 24 08:54:30 2003 +0100
     6.2 +++ b/src/HOL/Hyperreal/NSA.ML	Thu Dec 25 22:48:32 2003 +0100
     6.3 @@ -350,7 +350,7 @@
     6.4  by (forw_inst_tac [("x1","r"),("z","abs x")]
     6.5      (hypreal_inverse_gt_0 RS order_less_trans) 1);
     6.6  by (assume_tac 1);
     6.7 -by (dtac ((hypreal_inverse_inverse RS sym) RS subst) 1);
     6.8 +by (dtac ((inverse_inverse_eq RS sym) RS subst) 1);
     6.9  by (rtac (hypreal_inverse_less_iff RS iffD1) 1);
    6.10  by (auto_tac (claset(), simpset() addsimps [SReal_inverse]));
    6.11  qed "HInfinite_inverse_Infinitesimal";
    6.12 @@ -2244,7 +2244,7 @@
    6.13  
    6.14  Goal "(u = inverse (real(Suc n))) = (real(Suc n) = inverse u)";
    6.15  by (auto_tac (claset(),
    6.16 -      simpset() addsimps [real_inverse_inverse, real_of_nat_Suc_gt_zero,
    6.17 +      simpset() addsimps [inverse_inverse_eq, real_of_nat_Suc_gt_zero,
    6.18                            real_not_refl2 RS not_sym]));
    6.19  qed "real_of_nat_inverse_eq_iff";
    6.20  
     7.1 --- a/src/HOL/Hyperreal/SEQ.ML	Wed Dec 24 08:54:30 2003 +0100
     7.2 +++ b/src/HOL/Hyperreal/SEQ.ML	Thu Dec 25 22:48:32 2003 +0100
     7.3 @@ -1130,9 +1130,9 @@
     7.4  by (ftac order_less_trans 1 THEN assume_tac 1);
     7.5  by (forw_inst_tac [("x","f n")] real_inverse_gt_0 1);
     7.6  by (asm_simp_tac (simpset() addsimps [abs_eqI2]) 1);
     7.7 -by (res_inst_tac [("t","r")] (real_inverse_inverse RS subst) 1);
     7.8 +by (res_inst_tac [("t","r")] (inverse_inverse_eq RS subst) 1);
     7.9  by (auto_tac (claset() addIs [inverse_less_iff_less RS iffD2], 
    7.10 -            simpset() delsimps [thm"Ring_and_Field.inverse_inverse_eq"]));
    7.11 +            simpset() delsimps [inverse_inverse_eq]));
    7.12  qed "LIMSEQ_inverse_zero";
    7.13  
    7.14  Goal "ALL y. EX N. ALL n. N <= n --> y < f(n) \
     8.1 --- a/src/HOL/Integ/int_arith1.ML	Wed Dec 24 08:54:30 2003 +0100
     8.2 +++ b/src/HOL/Integ/int_arith1.ML	Thu Dec 25 22:48:32 2003 +0100
     8.3 @@ -5,6 +5,43 @@
     8.4  Simprocs and decision procedure for linear arithmetic.
     8.5  *)
     8.6  
     8.7 +(** Misc ML bindings **)
     8.8 +
     8.9 +val left_inverse = thm "left_inverse";
    8.10 +val right_inverse = thm "right_inverse";
    8.11 +val inverse_less_iff_less = thm"Ring_and_Field.inverse_less_iff_less";
    8.12 +val inverse_eq_divide = thm"Ring_and_Field.inverse_eq_divide";
    8.13 +val inverse_minus_eq = thm "inverse_minus_eq";
    8.14 +val inverse_mult_distrib = thm "inverse_mult_distrib";
    8.15 +val inverse_add = thm "inverse_add";
    8.16 +val inverse_inverse_eq = thm "inverse_inverse_eq";
    8.17 +
    8.18 +val add_right_mono = thm"Ring_and_Field.add_right_mono";
    8.19 +val times_divide_eq_left = thm "times_divide_eq_left";
    8.20 +val times_divide_eq_right = thm "times_divide_eq_right";
    8.21 +val minus_minus = thm "minus_minus";
    8.22 +val minus_mult_left = thm "minus_mult_left";
    8.23 +val minus_mult_right = thm "minus_mult_right";
    8.24 +
    8.25 +val pos_real_less_divide_eq = thm"pos_less_divide_eq";
    8.26 +val pos_real_divide_less_eq = thm"pos_divide_less_eq";
    8.27 +val pos_real_le_divide_eq = thm"pos_le_divide_eq";
    8.28 +val pos_real_divide_le_eq = thm"pos_divide_le_eq";
    8.29 +
    8.30 +val mult_less_cancel_left = thm"Ring_and_Field.mult_less_cancel_left";
    8.31 +val mult_le_cancel_left = thm"Ring_and_Field.mult_le_cancel_left";
    8.32 +val mult_less_cancel_right = thm"Ring_and_Field.mult_less_cancel_right";
    8.33 +val mult_le_cancel_right = thm"Ring_and_Field.mult_le_cancel_right";
    8.34 +val mult_cancel_left = thm"Ring_and_Field.mult_cancel_left";
    8.35 +val mult_cancel_right = thm"Ring_and_Field.mult_cancel_right";
    8.36 +
    8.37 +val field_mult_cancel_left = thm "field_mult_cancel_left";
    8.38 +val field_mult_cancel_right = thm "field_mult_cancel_right";
    8.39 +
    8.40 +val mult_divide_cancel_left = thm"Ring_and_Field.mult_divide_cancel_left";
    8.41 +val mult_divide_cancel_right = thm "Ring_and_Field.mult_divide_cancel_right";
    8.42 +val mult_divide_cancel_eq_if = thm"Ring_and_Field.mult_divide_cancel_eq_if";
    8.43 +
    8.44  val NCons_Pls = thm"NCons_Pls";
    8.45  val NCons_Min = thm"NCons_Min";
    8.46  val NCons_BIT = thm"NCons_BIT";
     9.1 --- a/src/HOL/Real/HahnBanach/Subspace.thy	Wed Dec 24 08:54:30 2003 +0100
     9.2 +++ b/src/HOL/Real/HahnBanach/Subspace.thy	Thu Dec 25 22:48:32 2003 +0100
     9.3 @@ -329,13 +329,13 @@
     9.4    proof (rule add_minus_eq)
     9.5      show "u1 \<in> E" ..
     9.6      show "u2 \<in> E" ..
     9.7 -    from u u' and direct show "u1 - u2 = 0" by blast
     9.8 +    from u u' and direct show "u1 - u2 = 0" by force
     9.9    qed
    9.10    show "v1 = v2"
    9.11    proof (rule add_minus_eq [symmetric])
    9.12      show "v1 \<in> E" ..
    9.13      show "v2 \<in> E" ..
    9.14 -    from v v' and direct show "v2 - v1 = 0" by blast
    9.15 +    from v v' and direct show "v2 - v1 = 0" by force
    9.16    qed
    9.17  qed
    9.18  
    10.1 --- a/src/HOL/Real/RealArith.thy	Wed Dec 24 08:54:30 2003 +0100
    10.2 +++ b/src/HOL/Real/RealArith.thy	Thu Dec 25 22:48:32 2003 +0100
    10.3 @@ -31,9 +31,7 @@
    10.4  by auto
    10.5  
    10.6  
    10.7 -(** Simprules combining x-y and 0; see also real_less_iff_diff_less_0, etc.,
    10.8 -    in RealBin
    10.9 -**)
   10.10 +(** Simprules combining x-y and 0 (needed??) **)
   10.11  
   10.12  lemma real_0_less_diff_iff [iff]: "((0::real) < x-y) = (y < x)"
   10.13  by auto
    11.1 --- a/src/HOL/Real/RealBin.ML	Wed Dec 24 08:54:30 2003 +0100
    11.2 +++ b/src/HOL/Real/RealBin.ML	Thu Dec 25 22:48:32 2003 +0100
    11.3 @@ -192,17 +192,6 @@
    11.4  
    11.5  (**** Simprocs for numeric literals ****)
    11.6  
    11.7 -(** Combining of literal coefficients in sums of products **)
    11.8 -
    11.9 -Goal "(x = y) = (x-y = (0::real))";
   11.10 -by (simp_tac (simpset() addsimps compare_rls) 1);
   11.11 -qed "real_eq_iff_diff_eq_0";
   11.12 -
   11.13 -Goal "(x <= y) = (x-y <= (0::real))";
   11.14 -by (simp_tac (simpset() addsimps compare_rls) 1);
   11.15 -qed "real_le_iff_diff_le_0";
   11.16 -
   11.17 -
   11.18  (** For combine_numerals **)
   11.19  
   11.20  Goal "i*u + (j*u + k) = (i+j)*u + (k::real)";
   11.21 @@ -212,12 +201,10 @@
   11.22  
   11.23  (** For cancel_numerals **)
   11.24  
   11.25 -val rel_iff_rel_0_rls = map (inst "y" "?u+?v")
   11.26 -                          [real_less_eq_diff, real_eq_iff_diff_eq_0,
   11.27 -                           real_le_iff_diff_le_0] @
   11.28 -                        map (inst "y" "n")
   11.29 -                          [real_less_eq_diff, real_eq_iff_diff_eq_0,
   11.30 -                           real_le_iff_diff_le_0];
   11.31 +val rel_iff_rel_0_rls = map (inst "b" "?u+?v")
   11.32 +                   [less_iff_diff_less_0, eq_iff_diff_eq_0, le_iff_diff_le_0] @
   11.33 +                 map (inst "b" "n")
   11.34 +                   [less_iff_diff_less_0, eq_iff_diff_eq_0, le_iff_diff_le_0];
   11.35  
   11.36  Goal "!!i::real. (i*u + m = j*u + n) = ((i-j)*u + m = n)";
   11.37  by (asm_simp_tac (simpset() addsimps [real_diff_def, real_add_mult_distrib]@
   11.38 @@ -603,9 +590,9 @@
   11.39  Addsimprocs [Real_Times_Assoc.conv];
   11.40  
   11.41  (*Simplification of  x-y < 0, etc.*)
   11.42 -AddIffs [real_less_eq_diff RS sym];
   11.43 -AddIffs [real_eq_iff_diff_eq_0 RS sym];
   11.44 -AddIffs [real_le_iff_diff_le_0 RS sym];
   11.45 +AddIffs [less_iff_diff_less_0 RS sym];
   11.46 +AddIffs [eq_iff_diff_eq_0 RS sym];
   11.47 +AddIffs [le_iff_diff_le_0 RS sym];
   11.48  
   11.49  (** <= monotonicity results: needed for arithmetic **)
   11.50  
    12.1 --- a/src/HOL/Real/RealDef.thy	Wed Dec 24 08:54:30 2003 +0100
    12.2 +++ b/src/HOL/Real/RealDef.thy	Thu Dec 25 22:48:32 2003 +0100
    12.3 @@ -93,17 +93,17 @@
    12.4    real_of_nat_def:   "real n == real_of_posnat n + (- 1)"
    12.5  
    12.6    real_add_def:
    12.7 -  "P+Q == Abs_REAL(UN p1:Rep_REAL(P). UN p2:Rep_REAL(Q).
    12.8 +  "P+Q == Abs_REAL(\<Union>p1\<in>Rep_REAL(P). \<Union>p2\<in>Rep_REAL(Q).
    12.9                     (%(x1,y1). (%(x2,y2). realrel``{(x1+x2, y1+y2)}) p2) p1)"
   12.10  
   12.11    real_mult_def:
   12.12 -  "P*Q == Abs_REAL(UN p1:Rep_REAL(P). UN p2:Rep_REAL(Q).
   12.13 +  "P*Q == Abs_REAL(\<Union>p1\<in>Rep_REAL(P). \<Union>p2\<in>Rep_REAL(Q).
   12.14                     (%(x1,y1). (%(x2,y2). realrel``{(x1*x2+y1*y2,x1*y2+x2*y1)})
   12.15  		   p2) p1)"
   12.16  
   12.17    real_less_def:
   12.18    "P<Q == \<exists>x1 y1 x2 y2. x1 + y2 < x2 + y1 &
   12.19 -                            (x1,y1):Rep_REAL(P) & (x2,y2):Rep_REAL(Q)"
   12.20 +                            (x1,y1)\<in>Rep_REAL(P) & (x2,y2)\<in>Rep_REAL(Q)"
   12.21    real_le_def:
   12.22    "P \<le> (Q::real) == ~(Q < P)"
   12.23  
   12.24 @@ -112,7 +112,7 @@
   12.25    Nats      :: "'a set"                   ("\<nat>")
   12.26  
   12.27  
   12.28 -(*** Proving that realrel is an equivalence relation ***)
   12.29 +subsection{*Proving that realrel is an equivalence relation*}
   12.30  
   12.31  lemma preal_trans_lemma:
   12.32       "[| (x1::preal) + y2 = x2 + y1; x2 + y3 = x3 + y2 |]
   12.33 @@ -225,7 +225,7 @@
   12.34  
   12.35  declare real_minus_zero_iff [simp]
   12.36  
   12.37 -(*** Congruence property for addition ***)
   12.38 +subsection{*Congruence property for addition*}
   12.39  
   12.40  lemma real_add_congruent2_lemma:
   12.41       "[|a + ba = aa + b; ab + bc = ac + bb|]
   12.42 @@ -298,9 +298,10 @@
   12.43  declare real_add_minus_left [simp]
   12.44  
   12.45  
   12.46 -(*** Congruence property for multiplication ***)
   12.47 +subsection{*Congruence property for multiplication*}
   12.48  
   12.49 -lemma real_mult_congruent2_lemma: "!!(x1::preal). [| x1 + y2 = x2 + y1 |] ==>
   12.50 +lemma real_mult_congruent2_lemma:
   12.51 +     "!!(x1::preal). [| x1 + y2 = x2 + y1 |] ==>
   12.52            x * x1 + y * y1 + (x * y2 + x2 * y) =
   12.53            x * x2 + y * y2 + (x * y1 + x1 * y)"
   12.54  apply (simp add: preal_add_left_commute preal_add_assoc [symmetric] preal_add_mult_distrib2 [symmetric])
   12.55 @@ -407,7 +408,8 @@
   12.56  
   12.57  (** Lemmas **)
   12.58  
   12.59 -lemma real_add_assoc_cong: "(z::real) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
   12.60 +lemma real_add_assoc_cong:
   12.61 +     "(z::real) + v = z' + v' ==> z + (v + w) = z' + (v' + w)"
   12.62  by (simp add: real_add_assoc [symmetric])
   12.63  
   12.64  lemma real_add_mult_distrib: "((z1::real) + z2) * w = (z1 * w) + (z2 * w)"
   12.65 @@ -428,13 +430,13 @@
   12.66  lemma real_diff_mult_distrib2: "(w::real) * (z1 - z2) = (w * z1) - (w * z2)"
   12.67  by (simp add: real_mult_commute [of w] real_diff_mult_distrib)
   12.68  
   12.69 -(*** one and zero are distinct ***)
   12.70 +text{*one and zero are distinct*}
   12.71  lemma real_zero_not_eq_one: "0 ~= (1::real)"
   12.72  apply (unfold real_zero_def real_one_def)
   12.73  apply (auto simp add: preal_self_less_add_left [THEN preal_not_refl2])
   12.74  done
   12.75  
   12.76 -(*** existence of inverse ***)
   12.77 +subsection{*existence of inverse*}
   12.78  (** lemma -- alternative definition of 0 **)
   12.79  lemma real_zero_iff: "0 = Abs_REAL (realrel `` {(x, x)})"
   12.80  apply (unfold real_zero_def)
   12.81 @@ -449,7 +451,9 @@
   12.82  apply (auto dest!: preal_less_add_left_Ex simp add: real_zero_iff [symmetric])
   12.83  apply (rule_tac x = "Abs_REAL (realrel `` { (preal_of_prat (prat_of_pnat 1), pinv (D) + preal_of_prat (prat_of_pnat 1))}) " in exI)
   12.84  apply (rule_tac [2] x = "Abs_REAL (realrel `` { (pinv (D) + preal_of_prat (prat_of_pnat 1), preal_of_prat (prat_of_pnat 1))}) " in exI)
   12.85 -apply (auto simp add: real_mult pnat_one_def preal_mult_1_right preal_add_mult_distrib2 preal_add_mult_distrib preal_mult_1 preal_mult_inv_right preal_add_ac preal_mult_ac)
   12.86 +apply (auto simp add: real_mult pnat_one_def preal_mult_1_right
   12.87 +              preal_add_mult_distrib2 preal_add_mult_distrib preal_mult_1
   12.88 +              preal_mult_inv_right preal_add_ac preal_mult_ac)
   12.89  done
   12.90  
   12.91  lemma real_mult_inv_left_ex: "x ~= 0 ==> \<exists>y. y*x = (1::real)"
   12.92 @@ -471,21 +475,21 @@
   12.93  declare real_mult_inv_right [simp]
   12.94  
   12.95  
   12.96 -(*---------------------------------------------------------
   12.97 -     Theorems for ordering
   12.98 - --------------------------------------------------------*)
   12.99 -(* prove introduction and elimination rules for real_less *)
  12.100 +subsection{*Theorems for Ordering*}
  12.101 +
  12.102 +(* real_less is a strict order: irreflexive *)
  12.103  
  12.104 -(* real_less is a strong order i.e. nonreflexive and transitive *)
  12.105 -
  12.106 -(*** lemmas ***)
  12.107 -lemma preal_lemma_eq_rev_sum: "!!(x::preal). [| x = y; x1 = y1 |] ==> x + y1 = x1 + y"
  12.108 +text{*lemmas*}
  12.109 +lemma preal_lemma_eq_rev_sum:
  12.110 +     "!!(x::preal). [| x = y; x1 = y1 |] ==> x + y1 = x1 + y"
  12.111  by (simp add: preal_add_commute)
  12.112  
  12.113 -lemma preal_add_left_commute_cancel: "!!(b::preal). x + (b + y) = x1 + (b + y1) ==> x + y = x1 + y1"
  12.114 +lemma preal_add_left_commute_cancel:
  12.115 +     "!!(b::preal). x + (b + y) = x1 + (b + y1) ==> x + y = x1 + y1"
  12.116  by (simp add: preal_add_ac)
  12.117  
  12.118 -lemma preal_lemma_for_not_refl: "!!(x::preal). [| x + y2a = x2a + y;
  12.119 +lemma preal_lemma_for_not_refl:
  12.120 +     "!!(x::preal). [| x + y2a = x2a + y;
  12.121                         x + y2b = x2b + y |]
  12.122                      ==> x2a + y2b = x2b + y2a"
  12.123  apply (drule preal_lemma_eq_rev_sum, assumption)
  12.124 @@ -569,10 +573,11 @@
  12.125  apply (simp add: preal_add_assoc [symmetric] preal_self_less_add_left)
  12.126  done
  12.127  
  12.128 -lemma real_of_preal_iff: "(\<exists>m. Abs_REAL (realrel `` {(x,y)}) = real_of_preal m) = (y < x)"
  12.129 +lemma real_of_preal_iff:
  12.130 +     "(\<exists>m. Abs_REAL (realrel `` {(x,y)}) = real_of_preal m) = (y < x)"
  12.131  by (blast intro!: real_of_preal_ExI real_of_preal_ExD)
  12.132  
  12.133 -(*** Gleason prop 9-4.4 p 127 ***)
  12.134 +text{*Gleason prop 9-4.4 p 127*}
  12.135  lemma real_of_preal_trichotomy:
  12.136        "\<exists>m. (x::real) = real_of_preal m | x = 0 | x = -(real_of_preal m)"
  12.137  apply (unfold real_of_preal_def real_zero_def)
  12.138 @@ -583,7 +588,8 @@
  12.139  apply (auto simp add: preal_add_commute)
  12.140  done
  12.141  
  12.142 -lemma real_of_preal_trichotomyE: "!!P. [| !!m. x = real_of_preal m ==> P;
  12.143 +lemma real_of_preal_trichotomyE:
  12.144 +     "!!P. [| !!m. x = real_of_preal m ==> P;
  12.145                x = 0 ==> P;
  12.146                !!m. x = -(real_of_preal m) ==> P |] ==> P"
  12.147  apply (cut_tac x = x in real_of_preal_trichotomy, auto)
  12.148 @@ -606,7 +612,8 @@
  12.149  apply (simp add: preal_self_less_add_left del: preal_add_less_iff2)
  12.150  done
  12.151  
  12.152 -lemma real_of_preal_less_iff1: "(real_of_preal m1 < real_of_preal m2) = (m1 < m2)"
  12.153 +lemma real_of_preal_less_iff1:
  12.154 +     "(real_of_preal m1 < real_of_preal m2) = (m1 < m2)"
  12.155  by (blast intro: real_of_preal_lessI real_of_preal_lessD)
  12.156  
  12.157  declare real_of_preal_less_iff1 [simp]
  12.158 @@ -677,7 +684,8 @@
  12.159  apply (blast dest: real_less_trans elim: real_less_irrefl)
  12.160  done
  12.161  
  12.162 -lemma real_of_preal_minus_less_rev1: "- real_of_preal m1 < - real_of_preal m2
  12.163 +lemma real_of_preal_minus_less_rev1:
  12.164 +     "- real_of_preal m1 < - real_of_preal m2
  12.165        ==> real_of_preal m2 < real_of_preal m1"
  12.166  apply (auto simp add: real_of_preal_def real_less_def real_minus)
  12.167  apply (rule exI)+
  12.168 @@ -688,7 +696,8 @@
  12.169  apply (auto simp add: preal_add_ac)
  12.170  done
  12.171  
  12.172 -lemma real_of_preal_minus_less_rev2: "real_of_preal m1 < real_of_preal m2
  12.173 +lemma real_of_preal_minus_less_rev2:
  12.174 +     "real_of_preal m1 < real_of_preal m2
  12.175        ==> - real_of_preal m2 < - real_of_preal m1"
  12.176  apply (auto simp add: real_of_preal_def real_less_def real_minus)
  12.177  apply (rule exI)+
  12.178 @@ -699,7 +708,8 @@
  12.179  apply (auto simp add: preal_add_ac)
  12.180  done
  12.181  
  12.182 -lemma real_of_preal_minus_less_rev_iff: "(- real_of_preal m1 < - real_of_preal m2) =
  12.183 +lemma real_of_preal_minus_less_rev_iff:
  12.184 +     "(- real_of_preal m1 < - real_of_preal m2) =
  12.185        (real_of_preal m2 < real_of_preal m1)"
  12.186  apply (blast intro!: real_of_preal_minus_less_rev1 real_of_preal_minus_less_rev2)
  12.187  done
  12.188 @@ -721,7 +731,8 @@
  12.189  by (cut_tac real_linear, blast)
  12.190  
  12.191  
  12.192 -lemma real_linear_less2: "!!(R1::real). [| R1 < R2 ==> P;  R1 = R2 ==> P;
  12.193 +lemma real_linear_less2:
  12.194 +     "!!(R1::real). [| R1 < R2 ==> P;  R1 = R2 ==> P;
  12.195                         R2 < R1 ==> P |] ==> P"
  12.196  apply (cut_tac x = R1 and y = R2 in real_linear, auto)
  12.197  done
    13.1 --- a/src/HOL/Real/RealOrd.thy	Wed Dec 24 08:54:30 2003 +0100
    13.2 +++ b/src/HOL/Real/RealOrd.thy	Thu Dec 25 22:48:32 2003 +0100
    13.3 @@ -56,7 +56,7 @@
    13.4  done
    13.5  
    13.6  (* Axiom 'order_less_le' of class 'order': *)
    13.7 -lemma real_less_le: "((w::real) < z) = (w \<le> z & w ~= z)"
    13.8 +lemma real_less_le: "((w::real) < z) = (w \<le> z & w \<noteq> z)"
    13.9  apply (simp add: real_le_def real_neq_iff)
   13.10  apply (blast elim!: real_less_asym)
   13.11  done
   13.12 @@ -84,11 +84,13 @@
   13.13  apply (blast elim!: real_less_irrefl real_of_preal_not_minus_gt_zero [THEN notE])
   13.14  done
   13.15  
   13.16 -lemma real_gt_preal_preal_Ex: "real_of_preal z < x ==> \<exists>y. x = real_of_preal y"
   13.17 +lemma real_gt_preal_preal_Ex:
   13.18 +     "real_of_preal z < x ==> \<exists>y. x = real_of_preal y"
   13.19  by (blast dest!: real_of_preal_zero_less [THEN real_less_trans]
   13.20               intro: real_gt_zero_preal_Ex [THEN iffD1])
   13.21  
   13.22 -lemma real_ge_preal_preal_Ex: "real_of_preal z \<le> x ==> \<exists>y. x = real_of_preal y"
   13.23 +lemma real_ge_preal_preal_Ex:
   13.24 +     "real_of_preal z \<le> x ==> \<exists>y. x = real_of_preal y"
   13.25  by (blast dest: order_le_imp_less_or_eq real_gt_preal_preal_Ex)
   13.26  
   13.27  lemma real_less_all_preal: "y \<le> 0 ==> \<forall>x. y < real_of_preal x"
   13.28 @@ -99,7 +101,8 @@
   13.29  lemma real_less_all_real2: "~ 0 < y ==> \<forall>x. y < real_of_preal x"
   13.30  by (blast intro!: real_less_all_preal real_leI)
   13.31  
   13.32 -lemma real_of_preal_le_iff: "(real_of_preal m1 \<le> real_of_preal m2) = (m1 \<le> m2)"
   13.33 +lemma real_of_preal_le_iff:
   13.34 +     "(real_of_preal m1 \<le> real_of_preal m2) = (m1 \<le> m2)"
   13.35  apply (auto intro!: preal_leI simp add: linorder_not_less [symmetric])
   13.36  done
   13.37  
   13.38 @@ -241,7 +244,7 @@
   13.39  apply (auto simp add: real_zero_not_eq_one)
   13.40  done
   13.41  
   13.42 -lemma DIVISION_BY_ZERO [simp]: "a / (0::real) = 0"
   13.43 +lemma DIVISION_BY_ZERO: "a / (0::real) = 0"
   13.44    by (simp add: real_divide_def INVERSE_ZERO)
   13.45  
   13.46  instance real :: division_by_zero
   13.47 @@ -251,27 +254,24 @@
   13.48    show "x/0 = 0" by (rule DIVISION_BY_ZERO) 
   13.49  qed
   13.50  
   13.51 -lemma real_mult_left_cancel: "(c::real) ~= 0 ==> (c*a=c*b) = (a=b)"
   13.52 +lemma real_mult_left_cancel: "(c::real) \<noteq> 0 ==> (c*a=c*b) = (a=b)"
   13.53  by auto
   13.54  
   13.55 -lemma real_mult_right_cancel: "(c::real) ~= 0 ==> (a*c=b*c) = (a=b)"
   13.56 +lemma real_mult_right_cancel: "(c::real) \<noteq> 0 ==> (a*c=b*c) = (a=b)"
   13.57  by auto
   13.58  
   13.59 -lemma real_mult_left_cancel_ccontr: "c*a ~= c*b ==> a ~= b"
   13.60 +lemma real_mult_left_cancel_ccontr: "c*a \<noteq> c*b ==> a \<noteq> b"
   13.61  by auto
   13.62  
   13.63 -lemma real_mult_right_cancel_ccontr: "a*c ~= b*c ==> a ~= b"
   13.64 +lemma real_mult_right_cancel_ccontr: "a*c \<noteq> b*c ==> a \<noteq> b"
   13.65  by auto
   13.66  
   13.67 -lemma real_inverse_not_zero: "x ~= 0 ==> inverse(x::real) ~= 0"
   13.68 +lemma real_inverse_not_zero: "x \<noteq> 0 ==> inverse(x::real) \<noteq> 0"
   13.69    by (rule Ring_and_Field.nonzero_imp_inverse_nonzero)
   13.70  
   13.71 -lemma real_mult_not_zero: "[| x ~= 0; y ~= 0 |] ==> x * y ~= (0::real)"
   13.72 +lemma real_mult_not_zero: "[| x \<noteq> 0; y \<noteq> 0 |] ==> x * y \<noteq> (0::real)"
   13.73  by simp
   13.74  
   13.75 -lemma real_inverse_inverse: "inverse(inverse (x::real)) = x"
   13.76 -  by (rule Ring_and_Field.inverse_inverse_eq)
   13.77 -
   13.78  lemma real_inverse_1: "inverse((1::real)) = (1::real)"
   13.79    by (rule Ring_and_Field.inverse_1)
   13.80  
   13.81 @@ -301,7 +301,8 @@
   13.82  apply (erule add_left_mono) 
   13.83  done
   13.84  
   13.85 -lemma real_add_le_less_mono: "!!z z'::real. [| w'\<le>w; z'<z |] ==> w' + z' < w + z"
   13.86 +lemma real_add_le_less_mono:
   13.87 +     "!!z z'::real. [| w'\<le>w; z'<z |] ==> w' + z' < w + z"
   13.88  apply (erule add_right_mono [THEN order_le_less_trans])
   13.89  apply (erule add_strict_left_mono) 
   13.90  done
   13.91 @@ -371,7 +372,8 @@
   13.92  lemma real_mult_is_0 [iff]: "(x*y = 0) = (x = 0 | y = (0::real))"
   13.93  by (rule Ring_and_Field.mult_eq_0_iff)
   13.94  
   13.95 -lemma real_inverse_add: "[| x \<noteq> 0; y \<noteq> 0 |]  
   13.96 +lemma real_inverse_add:
   13.97 +     "[| x \<noteq> 0; y \<noteq> 0 |]  
   13.98        ==> inverse x + inverse y = (x + y) * inverse (x * (y::real))"
   13.99  by (simp add: Ring_and_Field.inverse_add mult_assoc)
  13.100  
  13.101 @@ -436,13 +438,15 @@
  13.102  apply (simp (no_asm_use) add: real_of_posnat_one [symmetric] real_of_posnat_def real_of_preal_add [symmetric] preal_of_prat_add [symmetric] prat_of_pnat_add [symmetric] pnat_of_nat_add)
  13.103  done
  13.104  
  13.105 -lemma real_of_posnat_add_one: "real_of_posnat (n + 1) = real_of_posnat n + (1::real)"
  13.106 +lemma real_of_posnat_add_one:
  13.107 +     "real_of_posnat (n + 1) = real_of_posnat n + (1::real)"
  13.108  apply (rule_tac x1 = " (1::real) " in real_add_right_cancel [THEN iffD1])
  13.109  apply (rule real_of_posnat_add [THEN subst])
  13.110  apply (simp (no_asm_use) add: real_of_posnat_two real_add_assoc)
  13.111  done
  13.112  
  13.113 -lemma real_of_posnat_Suc: "real_of_posnat (Suc n) = real_of_posnat n + (1::real)"
  13.114 +lemma real_of_posnat_Suc:
  13.115 +     "real_of_posnat (Suc n) = real_of_posnat n + (1::real)"
  13.116  by (subst real_of_posnat_add_one [symmetric], simp)
  13.117  
  13.118  lemma inj_real_of_posnat: "inj(real_of_posnat)"
  13.119 @@ -535,7 +539,7 @@
  13.120  done
  13.121  
  13.122  lemma real_inverse_unique: "x*y = (1::real) ==> y = inverse x"
  13.123 -apply (case_tac "x ~= 0")
  13.124 +apply (case_tac "x \<noteq> 0")
  13.125  apply (rule_tac c1 = x in real_mult_left_cancel [THEN iffD1], auto)
  13.126  done
  13.127  
  13.128 @@ -564,7 +568,8 @@
  13.129  done
  13.130  declare real_of_nat_ge_zero_cancel_iff [simp]
  13.131  
  13.132 -lemma real_of_nat_num_if: "real n = (if n=0 then 0 else 1 + real ((n::nat) - 1))"
  13.133 +lemma real_of_nat_num_if:
  13.134 +     "real n = (if n=0 then 0 else 1 + real ((n::nat) - 1))"
  13.135  apply (case_tac "n", simp) 
  13.136  apply (simp add: real_of_nat_Suc add_commute)
  13.137  done
  13.138 @@ -721,7 +726,6 @@
  13.139  val real_mult_right_cancel_ccontr = thm"real_mult_right_cancel_ccontr";
  13.140  val real_inverse_not_zero = thm"real_inverse_not_zero";
  13.141  val real_mult_not_zero = thm"real_mult_not_zero";
  13.142 -val real_inverse_inverse = thm"real_inverse_inverse";
  13.143  val real_inverse_1 = thm"real_inverse_1";
  13.144  val real_minus_inverse = thm"real_minus_inverse";
  13.145  val real_inverse_distrib = thm"real_inverse_distrib";
    14.1 --- a/src/HOL/Real/real_arith0.ML	Wed Dec 24 08:54:30 2003 +0100
    14.2 +++ b/src/HOL/Real/real_arith0.ML	Thu Dec 25 22:48:32 2003 +0100
    14.3 @@ -6,43 +6,6 @@
    14.4  Instantiation of the generic linear arithmetic package for type real.
    14.5  *)
    14.6  
    14.7 -(** Misc ML bindings **)
    14.8 -(*FIXME: move to Integ or earlier*)
    14.9 -
   14.10 -val left_inverse = thm "left_inverse";
   14.11 -val right_inverse = thm "right_inverse";
   14.12 -val inverse_less_iff_less = thm"Ring_and_Field.inverse_less_iff_less";
   14.13 -val inverse_eq_divide = thm"Ring_and_Field.inverse_eq_divide";
   14.14 -val inverse_minus_eq = thm "inverse_minus_eq";
   14.15 -val inverse_mult_distrib = thm "inverse_mult_distrib";
   14.16 -val inverse_add = thm "inverse_add";
   14.17 -
   14.18 -val add_right_mono = thm"Ring_and_Field.add_right_mono";
   14.19 -val times_divide_eq_left = thm "times_divide_eq_left";
   14.20 -val times_divide_eq_right = thm "times_divide_eq_right";
   14.21 -val minus_minus = thm "minus_minus";
   14.22 -val minus_mult_left = thm "minus_mult_left";
   14.23 -val minus_mult_right = thm "minus_mult_right";
   14.24 -
   14.25 -val pos_real_less_divide_eq = thm"pos_less_divide_eq";
   14.26 -val pos_real_divide_less_eq = thm"pos_divide_less_eq";
   14.27 -val pos_real_le_divide_eq = thm"pos_le_divide_eq";
   14.28 -val pos_real_divide_le_eq = thm"pos_divide_le_eq";
   14.29 -
   14.30 -val mult_less_cancel_left = thm"Ring_and_Field.mult_less_cancel_left";
   14.31 -val mult_le_cancel_left = thm"Ring_and_Field.mult_le_cancel_left";
   14.32 -val mult_less_cancel_right = thm"Ring_and_Field.mult_less_cancel_right";
   14.33 -val mult_le_cancel_right = thm"Ring_and_Field.mult_le_cancel_right";
   14.34 -val mult_cancel_left = thm"Ring_and_Field.mult_cancel_left";
   14.35 -val mult_cancel_right = thm"Ring_and_Field.mult_cancel_right";
   14.36 -
   14.37 -val field_mult_cancel_left = thm "field_mult_cancel_left";
   14.38 -val field_mult_cancel_right = thm "field_mult_cancel_right";
   14.39 -
   14.40 -val mult_divide_cancel_left = thm"Ring_and_Field.mult_divide_cancel_left";
   14.41 -val mult_divide_cancel_right = thm "Ring_and_Field.mult_divide_cancel_right";
   14.42 -val mult_divide_cancel_eq_if = thm"Ring_and_Field.mult_divide_cancel_eq_if";
   14.43 -
   14.44  
   14.45  
   14.46  local