src/HOL/Ring_and_Field.thy
author obua
Tue Apr 19 10:59:31 2005 +0200 (2005-04-19)
changeset 15769 38c8ea8521e7
parent 15580 900291ee0af8
child 15923 01d5d0c1c078
permissions -rw-r--r--
Removed mult_commute axiom from comm_semiring axclass.
     1 (*  Title:   HOL/Ring_and_Field.thy
     2     ID:      $Id$
     3     Author:  Gertrud Bauer, Steven Obua, Lawrence C Paulson and Markus Wenzel
     4 *)
     5 
     6 header {* (Ordered) Rings and Fields *}
     7 
     8 theory Ring_and_Field
     9 imports OrderedGroup
    10 begin
    11 
    12 text {*
    13   The theory of partially ordered rings is taken from the books:
    14   \begin{itemize}
    15   \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 
    16   \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
    17   \end{itemize}
    18   Most of the used notions can also be looked up in 
    19   \begin{itemize}
    20   \item \url{http://www.mathworld.com} by Eric Weisstein et. al.
    21   \item \emph{Algebra I} by van der Waerden, Springer.
    22   \end{itemize}
    23 *}
    24 
    25 axclass semiring \<subseteq> ab_semigroup_add, semigroup_mult
    26   left_distrib: "(a + b) * c = a * c + b * c"
    27   right_distrib: "a * (b + c) = a * b + a * c"
    28 
    29 axclass semiring_0 \<subseteq> semiring, comm_monoid_add
    30 
    31 axclass semiring_0_cancel \<subseteq> semiring_0, cancel_ab_semigroup_add
    32 
    33 axclass comm_semiring \<subseteq> ab_semigroup_add, ab_semigroup_mult  
    34   distrib: "(a + b) * c = a * c + b * c"
    35 
    36 instance comm_semiring \<subseteq> semiring
    37 proof
    38   fix a b c :: 'a
    39   show "(a + b) * c = a * c + b * c" by (simp add: distrib)
    40   have "a * (b + c) = (b + c) * a" by (simp add: mult_ac)
    41   also have "... = b * a + c * a" by (simp only: distrib)
    42   also have "... = a * b + a * c" by (simp add: mult_ac)
    43   finally show "a * (b + c) = a * b + a * c" by blast
    44 qed
    45 
    46 axclass comm_semiring_0 \<subseteq> comm_semiring, comm_monoid_add
    47 
    48 instance comm_semiring_0 \<subseteq> semiring_0 ..
    49 
    50 axclass comm_semiring_0_cancel \<subseteq> comm_semiring_0, cancel_ab_semigroup_add
    51 
    52 instance comm_semiring_0_cancel \<subseteq> semiring_0_cancel ..
    53 
    54 axclass axclass_0_neq_1 \<subseteq> zero, one
    55   zero_neq_one [simp]: "0 \<noteq> 1"
    56 
    57 axclass semiring_1 \<subseteq> axclass_0_neq_1, semiring_0, monoid_mult
    58 
    59 axclass comm_semiring_1 \<subseteq> axclass_0_neq_1, comm_semiring_0, comm_monoid_mult (* previously almost_semiring *)
    60 
    61 instance comm_semiring_1 \<subseteq> semiring_1 ..
    62 
    63 axclass axclass_no_zero_divisors \<subseteq> zero, times
    64   no_zero_divisors: "a \<noteq> 0 \<Longrightarrow> b \<noteq> 0 \<Longrightarrow> a * b \<noteq> 0"
    65 
    66 axclass semiring_1_cancel \<subseteq> semiring_1, cancel_ab_semigroup_add
    67 
    68 instance semiring_1_cancel \<subseteq> semiring_0_cancel ..
    69 
    70 axclass comm_semiring_1_cancel \<subseteq> comm_semiring_1, cancel_ab_semigroup_add (* previously semiring *)
    71 
    72 instance comm_semiring_1_cancel \<subseteq> semiring_1_cancel ..
    73 
    74 instance comm_semiring_1_cancel \<subseteq> comm_semiring_0_cancel ..
    75 
    76 axclass ring \<subseteq> semiring, ab_group_add
    77 
    78 instance ring \<subseteq> semiring_0_cancel ..
    79 
    80 axclass comm_ring \<subseteq> comm_semiring_0, ab_group_add
    81 
    82 instance comm_ring \<subseteq> ring ..
    83 
    84 instance comm_ring \<subseteq> comm_semiring_0_cancel ..
    85 
    86 axclass ring_1 \<subseteq> ring, semiring_1
    87 
    88 instance ring_1 \<subseteq> semiring_1_cancel ..
    89 
    90 axclass comm_ring_1 \<subseteq> comm_ring, comm_semiring_1 (* previously ring *)
    91 
    92 instance comm_ring_1 \<subseteq> ring_1 ..
    93 
    94 instance comm_ring_1 \<subseteq> comm_semiring_1_cancel ..
    95 
    96 axclass idom \<subseteq> comm_ring_1, axclass_no_zero_divisors
    97 
    98 axclass field \<subseteq> comm_ring_1, inverse
    99   left_inverse [simp]: "a \<noteq> 0 ==> inverse a * a = 1"
   100   divide_inverse:      "a / b = a * inverse b"
   101 
   102 lemma mult_zero_left [simp]: "0 * a = (0::'a::semiring_0_cancel)"
   103 proof -
   104   have "0*a + 0*a = 0*a + 0"
   105     by (simp add: left_distrib [symmetric])
   106   thus ?thesis 
   107     by (simp only: add_left_cancel)
   108 qed
   109 
   110 lemma mult_zero_right [simp]: "a * 0 = (0::'a::semiring_0_cancel)"
   111 proof -
   112   have "a*0 + a*0 = a*0 + 0"
   113     by (simp add: right_distrib [symmetric])
   114   thus ?thesis 
   115     by (simp only: add_left_cancel)
   116 qed
   117 
   118 lemma field_mult_eq_0_iff [simp]: "(a*b = (0::'a::field)) = (a = 0 | b = 0)"
   119 proof cases
   120   assume "a=0" thus ?thesis by simp
   121 next
   122   assume anz [simp]: "a\<noteq>0"
   123   { assume "a * b = 0"
   124     hence "inverse a * (a * b) = 0" by simp
   125     hence "b = 0"  by (simp (no_asm_use) add: mult_assoc [symmetric])}
   126   thus ?thesis by force
   127 qed
   128 
   129 instance field \<subseteq> idom
   130 by (intro_classes, simp)
   131   
   132 axclass division_by_zero \<subseteq> zero, inverse
   133   inverse_zero [simp]: "inverse 0 = 0"
   134 
   135 subsection {* Distribution rules *}
   136 
   137 theorems ring_distrib = right_distrib left_distrib
   138 
   139 text{*For the @{text combine_numerals} simproc*}
   140 lemma combine_common_factor:
   141      "a*e + (b*e + c) = (a+b)*e + (c::'a::semiring)"
   142 by (simp add: left_distrib add_ac)
   143 
   144 lemma minus_mult_left: "- (a * b) = (-a) * (b::'a::ring)"
   145 apply (rule equals_zero_I)
   146 apply (simp add: left_distrib [symmetric]) 
   147 done
   148 
   149 lemma minus_mult_right: "- (a * b) = a * -(b::'a::ring)"
   150 apply (rule equals_zero_I)
   151 apply (simp add: right_distrib [symmetric]) 
   152 done
   153 
   154 lemma minus_mult_minus [simp]: "(- a) * (- b) = a * (b::'a::ring)"
   155   by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric])
   156 
   157 lemma minus_mult_commute: "(- a) * b = a * (- b::'a::ring)"
   158   by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric])
   159 
   160 lemma right_diff_distrib: "a * (b - c) = a * b - a * (c::'a::ring)"
   161 by (simp add: right_distrib diff_minus 
   162               minus_mult_left [symmetric] minus_mult_right [symmetric]) 
   163 
   164 lemma left_diff_distrib: "(a - b) * c = a * c - b * (c::'a::ring)"
   165 by (simp add: left_distrib diff_minus 
   166               minus_mult_left [symmetric] minus_mult_right [symmetric]) 
   167 
   168 axclass pordered_semiring \<subseteq> semiring_0, pordered_ab_semigroup_add 
   169   mult_left_mono: "a <= b \<Longrightarrow> 0 <= c \<Longrightarrow> c * a <= c * b"
   170   mult_right_mono: "a <= b \<Longrightarrow> 0 <= c \<Longrightarrow> a * c <= b * c"
   171 
   172 axclass pordered_cancel_semiring \<subseteq> pordered_semiring, cancel_ab_semigroup_add
   173 
   174 instance pordered_cancel_semiring \<subseteq> semiring_0_cancel ..
   175 
   176 axclass ordered_semiring_strict \<subseteq> semiring_0, ordered_cancel_ab_semigroup_add
   177   mult_strict_left_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b"
   178   mult_strict_right_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> a * c < b * c"
   179 
   180 instance ordered_semiring_strict \<subseteq> semiring_0_cancel ..
   181 
   182 instance ordered_semiring_strict \<subseteq> pordered_cancel_semiring
   183 apply intro_classes
   184 apply (case_tac "a < b & 0 < c")
   185 apply (auto simp add: mult_strict_left_mono order_less_le)
   186 apply (auto simp add: mult_strict_left_mono order_le_less)
   187 apply (simp add: mult_strict_right_mono)
   188 done
   189 
   190 axclass pordered_comm_semiring \<subseteq> comm_semiring_0, pordered_ab_semigroup_add
   191   mult_mono: "a <= b \<Longrightarrow> 0 <= c \<Longrightarrow> c * a <= c * b"
   192 
   193 axclass pordered_cancel_comm_semiring \<subseteq> pordered_comm_semiring, cancel_ab_semigroup_add
   194 
   195 instance pordered_cancel_comm_semiring \<subseteq> pordered_comm_semiring ..
   196 
   197 axclass ordered_comm_semiring_strict \<subseteq> comm_semiring_0, ordered_cancel_ab_semigroup_add
   198   mult_strict_mono: "a < b \<Longrightarrow> 0 < c \<Longrightarrow> c * a < c * b"
   199 
   200 instance pordered_comm_semiring \<subseteq> pordered_semiring
   201 by (intro_classes, insert mult_mono, simp_all add: mult_commute, blast+)
   202 
   203 instance pordered_cancel_comm_semiring \<subseteq> pordered_cancel_semiring ..
   204 
   205 instance ordered_comm_semiring_strict \<subseteq> ordered_semiring_strict
   206 by (intro_classes, insert mult_strict_mono, simp_all add: mult_commute, blast+)
   207 
   208 instance ordered_comm_semiring_strict \<subseteq> pordered_cancel_comm_semiring
   209 apply (intro_classes)
   210 apply (case_tac "a < b & 0 < c")
   211 apply (auto simp add: mult_strict_left_mono order_less_le)
   212 apply (auto simp add: mult_strict_left_mono order_le_less)
   213 done
   214 
   215 axclass pordered_ring \<subseteq> ring, pordered_semiring 
   216 
   217 instance pordered_ring \<subseteq> pordered_ab_group_add ..
   218 
   219 instance pordered_ring \<subseteq> pordered_cancel_semiring ..
   220 
   221 axclass lordered_ring \<subseteq> pordered_ring, lordered_ab_group_abs
   222 
   223 instance lordered_ring \<subseteq> lordered_ab_group_meet ..
   224 
   225 instance lordered_ring \<subseteq> lordered_ab_group_join ..
   226 
   227 axclass axclass_abs_if \<subseteq> minus, ord, zero
   228   abs_if: "abs a = (if (a < 0) then (-a) else a)"
   229 
   230 axclass ordered_ring_strict \<subseteq> ring, ordered_semiring_strict, axclass_abs_if
   231 
   232 instance ordered_ring_strict \<subseteq> lordered_ab_group ..
   233 
   234 instance ordered_ring_strict \<subseteq> lordered_ring
   235 by (intro_classes, simp add: abs_if join_eq_if)
   236 
   237 axclass pordered_comm_ring \<subseteq> comm_ring, pordered_comm_semiring
   238 
   239 axclass ordered_semidom \<subseteq> comm_semiring_1_cancel, ordered_comm_semiring_strict (* previously ordered_semiring *)
   240   zero_less_one [simp]: "0 < 1"
   241 
   242 axclass ordered_idom \<subseteq> comm_ring_1, ordered_comm_semiring_strict, axclass_abs_if (* previously ordered_ring *)
   243 
   244 instance ordered_idom \<subseteq> ordered_ring_strict ..
   245 
   246 axclass ordered_field \<subseteq> field, ordered_idom
   247 
   248 lemma eq_add_iff1:
   249      "(a*e + c = b*e + d) = ((a-b)*e + c = (d::'a::ring))"
   250 apply (simp add: diff_minus left_distrib)
   251 apply (simp add: diff_minus left_distrib add_ac)
   252 apply (simp add: compare_rls minus_mult_left [symmetric])
   253 done
   254 
   255 lemma eq_add_iff2:
   256      "(a*e + c = b*e + d) = (c = (b-a)*e + (d::'a::ring))"
   257 apply (simp add: diff_minus left_distrib add_ac)
   258 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   259 done
   260 
   261 lemma less_add_iff1:
   262      "(a*e + c < b*e + d) = ((a-b)*e + c < (d::'a::pordered_ring))"
   263 apply (simp add: diff_minus left_distrib add_ac)
   264 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   265 done
   266 
   267 lemma less_add_iff2:
   268      "(a*e + c < b*e + d) = (c < (b-a)*e + (d::'a::pordered_ring))"
   269 apply (simp add: diff_minus left_distrib add_ac)
   270 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   271 done
   272 
   273 lemma le_add_iff1:
   274      "(a*e + c \<le> b*e + d) = ((a-b)*e + c \<le> (d::'a::pordered_ring))"
   275 apply (simp add: diff_minus left_distrib add_ac)
   276 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   277 done
   278 
   279 lemma le_add_iff2:
   280      "(a*e + c \<le> b*e + d) = (c \<le> (b-a)*e + (d::'a::pordered_ring))"
   281 apply (simp add: diff_minus left_distrib add_ac)
   282 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   283 done
   284 
   285 subsection {* Ordering Rules for Multiplication *}
   286 
   287 lemma mult_left_le_imp_le:
   288      "[|c*a \<le> c*b; 0 < c|] ==> a \<le> (b::'a::ordered_semiring_strict)"
   289   by (force simp add: mult_strict_left_mono linorder_not_less [symmetric])
   290  
   291 lemma mult_right_le_imp_le:
   292      "[|a*c \<le> b*c; 0 < c|] ==> a \<le> (b::'a::ordered_semiring_strict)"
   293   by (force simp add: mult_strict_right_mono linorder_not_less [symmetric])
   294 
   295 lemma mult_left_less_imp_less:
   296      "[|c*a < c*b; 0 \<le> c|] ==> a < (b::'a::ordered_semiring_strict)"
   297   by (force simp add: mult_left_mono linorder_not_le [symmetric])
   298  
   299 lemma mult_right_less_imp_less:
   300      "[|a*c < b*c; 0 \<le> c|] ==> a < (b::'a::ordered_semiring_strict)"
   301   by (force simp add: mult_right_mono linorder_not_le [symmetric])
   302 
   303 lemma mult_strict_left_mono_neg:
   304      "[|b < a; c < 0|] ==> c * a < c * (b::'a::ordered_ring_strict)"
   305 apply (drule mult_strict_left_mono [of _ _ "-c"])
   306 apply (simp_all add: minus_mult_left [symmetric]) 
   307 done
   308 
   309 lemma mult_left_mono_neg:
   310      "[|b \<le> a; c \<le> 0|] ==> c * a \<le>  c * (b::'a::pordered_ring)"
   311 apply (drule mult_left_mono [of _ _ "-c"])
   312 apply (simp_all add: minus_mult_left [symmetric]) 
   313 done
   314 
   315 lemma mult_strict_right_mono_neg:
   316      "[|b < a; c < 0|] ==> a * c < b * (c::'a::ordered_ring_strict)"
   317 apply (drule mult_strict_right_mono [of _ _ "-c"])
   318 apply (simp_all add: minus_mult_right [symmetric]) 
   319 done
   320 
   321 lemma mult_right_mono_neg:
   322      "[|b \<le> a; c \<le> 0|] ==> a * c \<le>  (b::'a::pordered_ring) * c"
   323 apply (drule mult_right_mono [of _ _ "-c"])
   324 apply (simp)
   325 apply (simp_all add: minus_mult_right [symmetric]) 
   326 done
   327 
   328 subsection{* Products of Signs *}
   329 
   330 lemma mult_pos: "[| (0::'a::ordered_semiring_strict) < a; 0 < b |] ==> 0 < a*b"
   331 by (drule mult_strict_left_mono [of 0 b], auto)
   332 
   333 lemma mult_pos_le: "[| (0::'a::pordered_cancel_semiring) \<le> a; 0 \<le> b |] ==> 0 \<le> a*b"
   334 by (drule mult_left_mono [of 0 b], auto)
   335 
   336 lemma mult_pos_neg: "[| (0::'a::ordered_semiring_strict) < a; b < 0 |] ==> a*b < 0"
   337 by (drule mult_strict_left_mono [of b 0], auto)
   338 
   339 lemma mult_pos_neg_le: "[| (0::'a::pordered_cancel_semiring) \<le> a; b \<le> 0 |] ==> a*b \<le> 0"
   340 by (drule mult_left_mono [of b 0], auto)
   341 
   342 lemma mult_pos_neg2: "[| (0::'a::ordered_semiring_strict) < a; b < 0 |] ==> b*a < 0" 
   343 by (drule mult_strict_right_mono[of b 0], auto)
   344 
   345 lemma mult_pos_neg2_le: "[| (0::'a::pordered_cancel_semiring) \<le> a; b \<le> 0 |] ==> b*a \<le> 0" 
   346 by (drule mult_right_mono[of b 0], auto)
   347 
   348 lemma mult_neg: "[| a < (0::'a::ordered_ring_strict); b < 0 |] ==> 0 < a*b"
   349 by (drule mult_strict_right_mono_neg, auto)
   350 
   351 lemma mult_neg_le: "[| a \<le> (0::'a::pordered_ring); b \<le> 0 |] ==> 0 \<le> a*b"
   352 by (drule mult_right_mono_neg[of a 0 b ], auto)
   353 
   354 lemma zero_less_mult_pos:
   355      "[| 0 < a*b; 0 < a|] ==> 0 < (b::'a::ordered_semiring_strict)"
   356 apply (case_tac "b\<le>0") 
   357  apply (auto simp add: order_le_less linorder_not_less)
   358 apply (drule_tac mult_pos_neg [of a b]) 
   359  apply (auto dest: order_less_not_sym)
   360 done
   361 
   362 lemma zero_less_mult_pos2:
   363      "[| 0 < b*a; 0 < a|] ==> 0 < (b::'a::ordered_semiring_strict)"
   364 apply (case_tac "b\<le>0") 
   365  apply (auto simp add: order_le_less linorder_not_less)
   366 apply (drule_tac mult_pos_neg2 [of a b]) 
   367  apply (auto dest: order_less_not_sym)
   368 done
   369 
   370 lemma zero_less_mult_iff:
   371      "((0::'a::ordered_ring_strict) < a*b) = (0 < a & 0 < b | a < 0 & b < 0)"
   372 apply (auto simp add: order_le_less linorder_not_less mult_pos mult_neg)
   373 apply (blast dest: zero_less_mult_pos) 
   374 apply (blast dest: zero_less_mult_pos2)
   375 done
   376 
   377 text{*A field has no "zero divisors", and this theorem holds without the
   378       assumption of an ordering.  See @{text field_mult_eq_0_iff} below.*}
   379 lemma mult_eq_0_iff [simp]: "(a*b = (0::'a::ordered_ring_strict)) = (a = 0 | b = 0)"
   380 apply (case_tac "a < 0")
   381 apply (auto simp add: linorder_not_less order_le_less linorder_neq_iff)
   382 apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono)+
   383 done
   384 
   385 lemma zero_le_mult_iff:
   386      "((0::'a::ordered_ring_strict) \<le> a*b) = (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
   387 by (auto simp add: eq_commute [of 0] order_le_less linorder_not_less
   388                    zero_less_mult_iff)
   389 
   390 lemma mult_less_0_iff:
   391      "(a*b < (0::'a::ordered_ring_strict)) = (0 < a & b < 0 | a < 0 & 0 < b)"
   392 apply (insert zero_less_mult_iff [of "-a" b]) 
   393 apply (force simp add: minus_mult_left[symmetric]) 
   394 done
   395 
   396 lemma mult_le_0_iff:
   397      "(a*b \<le> (0::'a::ordered_ring_strict)) = (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
   398 apply (insert zero_le_mult_iff [of "-a" b]) 
   399 apply (force simp add: minus_mult_left[symmetric]) 
   400 done
   401 
   402 lemma split_mult_pos_le: "(0 \<le> a & 0 \<le> b) | (a \<le> 0 & b \<le> 0) \<Longrightarrow> 0 \<le> a * (b::_::pordered_ring)"
   403 by (auto simp add: mult_pos_le mult_neg_le)
   404 
   405 lemma split_mult_neg_le: "(0 \<le> a & b \<le> 0) | (a \<le> 0 & 0 \<le> b) \<Longrightarrow> a * b \<le> (0::_::pordered_cancel_semiring)" 
   406 by (auto simp add: mult_pos_neg_le mult_pos_neg2_le)
   407 
   408 lemma zero_le_square: "(0::'a::ordered_ring_strict) \<le> a*a"
   409 by (simp add: zero_le_mult_iff linorder_linear) 
   410 
   411 text{*Proving axiom @{text zero_less_one} makes all @{text ordered_semidom}
   412       theorems available to members of @{term ordered_idom} *}
   413 
   414 instance ordered_idom \<subseteq> ordered_semidom
   415 proof
   416   have "(0::'a) \<le> 1*1" by (rule zero_le_square)
   417   thus "(0::'a) < 1" by (simp add: order_le_less) 
   418 qed
   419 
   420 instance ordered_ring_strict \<subseteq> axclass_no_zero_divisors 
   421 by (intro_classes, simp)
   422 
   423 instance ordered_idom \<subseteq> idom ..
   424 
   425 text{*All three types of comparision involving 0 and 1 are covered.*}
   426 
   427 declare zero_neq_one [THEN not_sym, simp]
   428 
   429 lemma zero_le_one [simp]: "(0::'a::ordered_semidom) \<le> 1"
   430   by (rule zero_less_one [THEN order_less_imp_le]) 
   431 
   432 lemma not_one_le_zero [simp]: "~ (1::'a::ordered_semidom) \<le> 0"
   433 by (simp add: linorder_not_le) 
   434 
   435 lemma not_one_less_zero [simp]: "~ (1::'a::ordered_semidom) < 0"
   436 by (simp add: linorder_not_less) 
   437 
   438 subsection{*More Monotonicity*}
   439 
   440 text{*Strict monotonicity in both arguments*}
   441 lemma mult_strict_mono:
   442      "[|a<b; c<d; 0<b; 0\<le>c|] ==> a * c < b * (d::'a::ordered_semiring_strict)"
   443 apply (case_tac "c=0")
   444  apply (simp add: mult_pos) 
   445 apply (erule mult_strict_right_mono [THEN order_less_trans])
   446  apply (force simp add: order_le_less) 
   447 apply (erule mult_strict_left_mono, assumption)
   448 done
   449 
   450 text{*This weaker variant has more natural premises*}
   451 lemma mult_strict_mono':
   452      "[| a<b; c<d; 0 \<le> a; 0 \<le> c|] ==> a * c < b * (d::'a::ordered_semiring_strict)"
   453 apply (rule mult_strict_mono)
   454 apply (blast intro: order_le_less_trans)+
   455 done
   456 
   457 lemma mult_mono:
   458      "[|a \<le> b; c \<le> d; 0 \<le> b; 0 \<le> c|] 
   459       ==> a * c  \<le>  b * (d::'a::pordered_semiring)"
   460 apply (erule mult_right_mono [THEN order_trans], assumption)
   461 apply (erule mult_left_mono, assumption)
   462 done
   463 
   464 lemma less_1_mult: "[| 1 < m; 1 < n |] ==> 1 < m*(n::'a::ordered_semidom)"
   465 apply (insert mult_strict_mono [of 1 m 1 n]) 
   466 apply (simp add:  order_less_trans [OF zero_less_one]) 
   467 done
   468 
   469 subsection{*Cancellation Laws for Relationships With a Common Factor*}
   470 
   471 text{*Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"},
   472    also with the relations @{text "\<le>"} and equality.*}
   473 
   474 text{*These ``disjunction'' versions produce two cases when the comparison is
   475  an assumption, but effectively four when the comparison is a goal.*}
   476 
   477 lemma mult_less_cancel_right_disj:
   478     "(a*c < b*c) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))"
   479 apply (case_tac "c = 0")
   480 apply (auto simp add: linorder_neq_iff mult_strict_right_mono 
   481                       mult_strict_right_mono_neg)
   482 apply (auto simp add: linorder_not_less 
   483                       linorder_not_le [symmetric, of "a*c"]
   484                       linorder_not_le [symmetric, of a])
   485 apply (erule_tac [!] notE)
   486 apply (auto simp add: order_less_imp_le mult_right_mono 
   487                       mult_right_mono_neg)
   488 done
   489 
   490 lemma mult_less_cancel_left_disj:
   491     "(c*a < c*b) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))"
   492 apply (case_tac "c = 0")
   493 apply (auto simp add: linorder_neq_iff mult_strict_left_mono 
   494                       mult_strict_left_mono_neg)
   495 apply (auto simp add: linorder_not_less 
   496                       linorder_not_le [symmetric, of "c*a"]
   497                       linorder_not_le [symmetric, of a])
   498 apply (erule_tac [!] notE)
   499 apply (auto simp add: order_less_imp_le mult_left_mono 
   500                       mult_left_mono_neg)
   501 done
   502 
   503 
   504 text{*The ``conjunction of implication'' lemmas produce two cases when the
   505 comparison is a goal, but give four when the comparison is an assumption.*}
   506 
   507 lemma mult_less_cancel_right:
   508   fixes c :: "'a :: ordered_ring_strict"
   509   shows      "(a*c < b*c) = ((0 \<le> c --> a < b) & (c \<le> 0 --> b < a))"
   510 by (insert mult_less_cancel_right_disj [of a c b], auto)
   511 
   512 lemma mult_less_cancel_left:
   513   fixes c :: "'a :: ordered_ring_strict"
   514   shows      "(c*a < c*b) = ((0 \<le> c --> a < b) & (c \<le> 0 --> b < a))"
   515 by (insert mult_less_cancel_left_disj [of c a b], auto)
   516 
   517 lemma mult_le_cancel_right:
   518      "(a*c \<le> b*c) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring_strict)))"
   519 by (simp add: linorder_not_less [symmetric] mult_less_cancel_right_disj)
   520 
   521 lemma mult_le_cancel_left:
   522      "(c*a \<le> c*b) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring_strict)))"
   523 by (simp add: linorder_not_less [symmetric] mult_less_cancel_left_disj)
   524 
   525 lemma mult_less_imp_less_left:
   526       assumes less: "c*a < c*b" and nonneg: "0 \<le> c"
   527       shows "a < (b::'a::ordered_semiring_strict)"
   528 proof (rule ccontr)
   529   assume "~ a < b"
   530   hence "b \<le> a" by (simp add: linorder_not_less)
   531   hence "c*b \<le> c*a" by (rule mult_left_mono)
   532   with this and less show False 
   533     by (simp add: linorder_not_less [symmetric])
   534 qed
   535 
   536 lemma mult_less_imp_less_right:
   537   assumes less: "a*c < b*c" and nonneg: "0 <= c"
   538   shows "a < (b::'a::ordered_semiring_strict)"
   539 proof (rule ccontr)
   540   assume "~ a < b"
   541   hence "b \<le> a" by (simp add: linorder_not_less)
   542   hence "b*c \<le> a*c" by (rule mult_right_mono)
   543   with this and less show False 
   544     by (simp add: linorder_not_less [symmetric])
   545 qed  
   546 
   547 text{*Cancellation of equalities with a common factor*}
   548 lemma mult_cancel_right [simp]:
   549      "(a*c = b*c) = (c = (0::'a::ordered_ring_strict) | a=b)"
   550 apply (cut_tac linorder_less_linear [of 0 c])
   551 apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono
   552              simp add: linorder_neq_iff)
   553 done
   554 
   555 text{*These cancellation theorems require an ordering. Versions are proved
   556       below that work for fields without an ordering.*}
   557 lemma mult_cancel_left [simp]:
   558      "(c*a = c*b) = (c = (0::'a::ordered_ring_strict) | a=b)"
   559 apply (cut_tac linorder_less_linear [of 0 c])
   560 apply (force dest: mult_strict_left_mono_neg mult_strict_left_mono
   561              simp add: linorder_neq_iff)
   562 done
   563 
   564 
   565 subsubsection{*Special Cancellation Simprules for Multiplication*}
   566 
   567 text{*These also produce two cases when the comparison is a goal.*}
   568 
   569 lemma mult_le_cancel_right1:
   570   fixes c :: "'a :: ordered_idom"
   571   shows "(c \<le> b*c) = ((0<c --> 1\<le>b) & (c<0 --> b \<le> 1))"
   572 by (insert mult_le_cancel_right [of 1 c b], simp)
   573 
   574 lemma mult_le_cancel_right2:
   575   fixes c :: "'a :: ordered_idom"
   576   shows "(a*c \<le> c) = ((0<c --> a\<le>1) & (c<0 --> 1 \<le> a))"
   577 by (insert mult_le_cancel_right [of a c 1], simp)
   578 
   579 lemma mult_le_cancel_left1:
   580   fixes c :: "'a :: ordered_idom"
   581   shows "(c \<le> c*b) = ((0<c --> 1\<le>b) & (c<0 --> b \<le> 1))"
   582 by (insert mult_le_cancel_left [of c 1 b], simp)
   583 
   584 lemma mult_le_cancel_left2:
   585   fixes c :: "'a :: ordered_idom"
   586   shows "(c*a \<le> c) = ((0<c --> a\<le>1) & (c<0 --> 1 \<le> a))"
   587 by (insert mult_le_cancel_left [of c a 1], simp)
   588 
   589 lemma mult_less_cancel_right1:
   590   fixes c :: "'a :: ordered_idom"
   591   shows "(c < b*c) = ((0 \<le> c --> 1<b) & (c \<le> 0 --> b < 1))"
   592 by (insert mult_less_cancel_right [of 1 c b], simp)
   593 
   594 lemma mult_less_cancel_right2:
   595   fixes c :: "'a :: ordered_idom"
   596   shows "(a*c < c) = ((0 \<le> c --> a<1) & (c \<le> 0 --> 1 < a))"
   597 by (insert mult_less_cancel_right [of a c 1], simp)
   598 
   599 lemma mult_less_cancel_left1:
   600   fixes c :: "'a :: ordered_idom"
   601   shows "(c < c*b) = ((0 \<le> c --> 1<b) & (c \<le> 0 --> b < 1))"
   602 by (insert mult_less_cancel_left [of c 1 b], simp)
   603 
   604 lemma mult_less_cancel_left2:
   605   fixes c :: "'a :: ordered_idom"
   606   shows "(c*a < c) = ((0 \<le> c --> a<1) & (c \<le> 0 --> 1 < a))"
   607 by (insert mult_less_cancel_left [of c a 1], simp)
   608 
   609 lemma mult_cancel_right1 [simp]:
   610 fixes c :: "'a :: ordered_idom"
   611   shows "(c = b*c) = (c = 0 | b=1)"
   612 by (insert mult_cancel_right [of 1 c b], force)
   613 
   614 lemma mult_cancel_right2 [simp]:
   615 fixes c :: "'a :: ordered_idom"
   616   shows "(a*c = c) = (c = 0 | a=1)"
   617 by (insert mult_cancel_right [of a c 1], simp)
   618  
   619 lemma mult_cancel_left1 [simp]:
   620 fixes c :: "'a :: ordered_idom"
   621   shows "(c = c*b) = (c = 0 | b=1)"
   622 by (insert mult_cancel_left [of c 1 b], force)
   623 
   624 lemma mult_cancel_left2 [simp]:
   625 fixes c :: "'a :: ordered_idom"
   626   shows "(c*a = c) = (c = 0 | a=1)"
   627 by (insert mult_cancel_left [of c a 1], simp)
   628 
   629 
   630 text{*Simprules for comparisons where common factors can be cancelled.*}
   631 lemmas mult_compare_simps =
   632     mult_le_cancel_right mult_le_cancel_left
   633     mult_le_cancel_right1 mult_le_cancel_right2
   634     mult_le_cancel_left1 mult_le_cancel_left2
   635     mult_less_cancel_right mult_less_cancel_left
   636     mult_less_cancel_right1 mult_less_cancel_right2
   637     mult_less_cancel_left1 mult_less_cancel_left2
   638     mult_cancel_right mult_cancel_left
   639     mult_cancel_right1 mult_cancel_right2
   640     mult_cancel_left1 mult_cancel_left2
   641 
   642 
   643 text{*This list of rewrites decides ring equalities by ordered rewriting.*}
   644 lemmas ring_eq_simps =  
   645 (*  mult_ac*)
   646   left_distrib right_distrib left_diff_distrib right_diff_distrib
   647   group_eq_simps
   648 (*  add_ac
   649   add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
   650   diff_eq_eq eq_diff_eq *)
   651     
   652 subsection {* Fields *}
   653 
   654 lemma right_inverse [simp]:
   655       assumes not0: "a \<noteq> 0" shows "a * inverse (a::'a::field) = 1"
   656 proof -
   657   have "a * inverse a = inverse a * a" by (simp add: mult_ac)
   658   also have "... = 1" using not0 by simp
   659   finally show ?thesis .
   660 qed
   661 
   662 lemma right_inverse_eq: "b \<noteq> 0 ==> (a / b = 1) = (a = (b::'a::field))"
   663 proof
   664   assume neq: "b \<noteq> 0"
   665   {
   666     hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac)
   667     also assume "a / b = 1"
   668     finally show "a = b" by simp
   669   next
   670     assume "a = b"
   671     with neq show "a / b = 1" by (simp add: divide_inverse)
   672   }
   673 qed
   674 
   675 lemma nonzero_inverse_eq_divide: "a \<noteq> 0 ==> inverse (a::'a::field) = 1/a"
   676 by (simp add: divide_inverse)
   677 
   678 lemma divide_self: "a \<noteq> 0 ==> a / (a::'a::field) = 1"
   679   by (simp add: divide_inverse)
   680 
   681 lemma divide_zero [simp]: "a / 0 = (0::'a::{field,division_by_zero})"
   682 by (simp add: divide_inverse)
   683 
   684 lemma divide_self_if [simp]:
   685      "a / (a::'a::{field,division_by_zero}) = (if a=0 then 0 else 1)"
   686   by (simp add: divide_self)
   687 
   688 lemma divide_zero_left [simp]: "0/a = (0::'a::field)"
   689 by (simp add: divide_inverse)
   690 
   691 lemma inverse_eq_divide: "inverse (a::'a::field) = 1/a"
   692 by (simp add: divide_inverse)
   693 
   694 lemma add_divide_distrib: "(a+b)/(c::'a::field) = a/c + b/c"
   695 by (simp add: divide_inverse left_distrib) 
   696 
   697 
   698 text{*Compared with @{text mult_eq_0_iff}, this version removes the requirement
   699       of an ordering.*}
   700 lemma field_mult_eq_0_iff [simp]: "(a*b = (0::'a::field)) = (a = 0 | b = 0)"
   701 proof cases
   702   assume "a=0" thus ?thesis by simp
   703 next
   704   assume anz [simp]: "a\<noteq>0"
   705   { assume "a * b = 0"
   706     hence "inverse a * (a * b) = 0" by simp
   707     hence "b = 0"  by (simp (no_asm_use) add: mult_assoc [symmetric])}
   708   thus ?thesis by force
   709 qed
   710 
   711 text{*Cancellation of equalities with a common factor*}
   712 lemma field_mult_cancel_right_lemma:
   713       assumes cnz: "c \<noteq> (0::'a::field)"
   714 	  and eq:  "a*c = b*c"
   715 	 shows "a=b"
   716 proof -
   717   have "(a * c) * inverse c = (b * c) * inverse c"
   718     by (simp add: eq)
   719   thus "a=b"
   720     by (simp add: mult_assoc cnz)
   721 qed
   722 
   723 lemma field_mult_cancel_right [simp]:
   724      "(a*c = b*c) = (c = (0::'a::field) | a=b)"
   725 proof cases
   726   assume "c=0" thus ?thesis by simp
   727 next
   728   assume "c\<noteq>0" 
   729   thus ?thesis by (force dest: field_mult_cancel_right_lemma)
   730 qed
   731 
   732 lemma field_mult_cancel_left [simp]:
   733      "(c*a = c*b) = (c = (0::'a::field) | a=b)"
   734   by (simp add: mult_commute [of c] field_mult_cancel_right) 
   735 
   736 lemma nonzero_imp_inverse_nonzero: "a \<noteq> 0 ==> inverse a \<noteq> (0::'a::field)"
   737 proof
   738   assume ianz: "inverse a = 0"
   739   assume "a \<noteq> 0"
   740   hence "1 = a * inverse a" by simp
   741   also have "... = 0" by (simp add: ianz)
   742   finally have "1 = (0::'a::field)" .
   743   thus False by (simp add: eq_commute)
   744 qed
   745 
   746 
   747 subsection{*Basic Properties of @{term inverse}*}
   748 
   749 lemma inverse_zero_imp_zero: "inverse a = 0 ==> a = (0::'a::field)"
   750 apply (rule ccontr) 
   751 apply (blast dest: nonzero_imp_inverse_nonzero) 
   752 done
   753 
   754 lemma inverse_nonzero_imp_nonzero:
   755    "inverse a = 0 ==> a = (0::'a::field)"
   756 apply (rule ccontr) 
   757 apply (blast dest: nonzero_imp_inverse_nonzero) 
   758 done
   759 
   760 lemma inverse_nonzero_iff_nonzero [simp]:
   761    "(inverse a = 0) = (a = (0::'a::{field,division_by_zero}))"
   762 by (force dest: inverse_nonzero_imp_nonzero) 
   763 
   764 lemma nonzero_inverse_minus_eq:
   765       assumes [simp]: "a\<noteq>0"  shows "inverse(-a) = -inverse(a::'a::field)"
   766 proof -
   767   have "-a * inverse (- a) = -a * - inverse a"
   768     by simp
   769   thus ?thesis 
   770     by (simp only: field_mult_cancel_left, simp)
   771 qed
   772 
   773 lemma inverse_minus_eq [simp]:
   774    "inverse(-a) = -inverse(a::'a::{field,division_by_zero})";
   775 proof cases
   776   assume "a=0" thus ?thesis by (simp add: inverse_zero)
   777 next
   778   assume "a\<noteq>0" 
   779   thus ?thesis by (simp add: nonzero_inverse_minus_eq)
   780 qed
   781 
   782 lemma nonzero_inverse_eq_imp_eq:
   783       assumes inveq: "inverse a = inverse b"
   784 	  and anz:  "a \<noteq> 0"
   785 	  and bnz:  "b \<noteq> 0"
   786 	 shows "a = (b::'a::field)"
   787 proof -
   788   have "a * inverse b = a * inverse a"
   789     by (simp add: inveq)
   790   hence "(a * inverse b) * b = (a * inverse a) * b"
   791     by simp
   792   thus "a = b"
   793     by (simp add: mult_assoc anz bnz)
   794 qed
   795 
   796 lemma inverse_eq_imp_eq:
   797      "inverse a = inverse b ==> a = (b::'a::{field,division_by_zero})"
   798 apply (case_tac "a=0 | b=0") 
   799  apply (force dest!: inverse_zero_imp_zero
   800               simp add: eq_commute [of "0::'a"])
   801 apply (force dest!: nonzero_inverse_eq_imp_eq) 
   802 done
   803 
   804 lemma inverse_eq_iff_eq [simp]:
   805      "(inverse a = inverse b) = (a = (b::'a::{field,division_by_zero}))"
   806 by (force dest!: inverse_eq_imp_eq) 
   807 
   808 lemma nonzero_inverse_inverse_eq:
   809       assumes [simp]: "a \<noteq> 0"  shows "inverse(inverse (a::'a::field)) = a"
   810   proof -
   811   have "(inverse (inverse a) * inverse a) * a = a" 
   812     by (simp add: nonzero_imp_inverse_nonzero)
   813   thus ?thesis
   814     by (simp add: mult_assoc)
   815   qed
   816 
   817 lemma inverse_inverse_eq [simp]:
   818      "inverse(inverse (a::'a::{field,division_by_zero})) = a"
   819   proof cases
   820     assume "a=0" thus ?thesis by simp
   821   next
   822     assume "a\<noteq>0" 
   823     thus ?thesis by (simp add: nonzero_inverse_inverse_eq)
   824   qed
   825 
   826 lemma inverse_1 [simp]: "inverse 1 = (1::'a::field)"
   827   proof -
   828   have "inverse 1 * 1 = (1::'a::field)" 
   829     by (rule left_inverse [OF zero_neq_one [symmetric]])
   830   thus ?thesis  by simp
   831   qed
   832 
   833 lemma inverse_unique: 
   834   assumes ab: "a*b = 1"
   835   shows "inverse a = (b::'a::field)"
   836 proof -
   837   have "a \<noteq> 0" using ab by auto
   838   moreover have "inverse a * (a * b) = inverse a" by (simp add: ab) 
   839   ultimately show ?thesis by (simp add: mult_assoc [symmetric]) 
   840 qed
   841 
   842 lemma nonzero_inverse_mult_distrib: 
   843       assumes anz: "a \<noteq> 0"
   844           and bnz: "b \<noteq> 0"
   845       shows "inverse(a*b) = inverse(b) * inverse(a::'a::field)"
   846   proof -
   847   have "inverse(a*b) * (a * b) * inverse(b) = inverse(b)" 
   848     by (simp add: field_mult_eq_0_iff anz bnz)
   849   hence "inverse(a*b) * a = inverse(b)" 
   850     by (simp add: mult_assoc bnz)
   851   hence "inverse(a*b) * a * inverse(a) = inverse(b) * inverse(a)" 
   852     by simp
   853   thus ?thesis
   854     by (simp add: mult_assoc anz)
   855   qed
   856 
   857 text{*This version builds in division by zero while also re-orienting
   858       the right-hand side.*}
   859 lemma inverse_mult_distrib [simp]:
   860      "inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})"
   861   proof cases
   862     assume "a \<noteq> 0 & b \<noteq> 0" 
   863     thus ?thesis  by (simp add: nonzero_inverse_mult_distrib mult_commute)
   864   next
   865     assume "~ (a \<noteq> 0 & b \<noteq> 0)" 
   866     thus ?thesis  by force
   867   qed
   868 
   869 text{*There is no slick version using division by zero.*}
   870 lemma inverse_add:
   871      "[|a \<noteq> 0;  b \<noteq> 0|]
   872       ==> inverse a + inverse b = (a+b) * inverse a * inverse (b::'a::field)"
   873 apply (simp add: left_distrib mult_assoc)
   874 apply (simp add: mult_commute [of "inverse a"]) 
   875 apply (simp add: mult_assoc [symmetric] add_commute)
   876 done
   877 
   878 lemma inverse_divide [simp]:
   879       "inverse (a/b) = b / (a::'a::{field,division_by_zero})"
   880   by (simp add: divide_inverse mult_commute)
   881 
   882 lemma nonzero_mult_divide_cancel_left:
   883   assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" 
   884     shows "(c*a)/(c*b) = a/(b::'a::field)"
   885 proof -
   886   have "(c*a)/(c*b) = c * a * (inverse b * inverse c)"
   887     by (simp add: field_mult_eq_0_iff divide_inverse 
   888                   nonzero_inverse_mult_distrib)
   889   also have "... =  a * inverse b * (inverse c * c)"
   890     by (simp only: mult_ac)
   891   also have "... =  a * inverse b"
   892     by simp
   893     finally show ?thesis 
   894     by (simp add: divide_inverse)
   895 qed
   896 
   897 lemma mult_divide_cancel_left:
   898      "c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})"
   899 apply (case_tac "b = 0")
   900 apply (simp_all add: nonzero_mult_divide_cancel_left)
   901 done
   902 
   903 lemma nonzero_mult_divide_cancel_right:
   904      "[|b\<noteq>0; c\<noteq>0|] ==> (a*c) / (b*c) = a/(b::'a::field)"
   905 by (simp add: mult_commute [of _ c] nonzero_mult_divide_cancel_left) 
   906 
   907 lemma mult_divide_cancel_right:
   908      "c\<noteq>0 ==> (a*c) / (b*c) = a / (b::'a::{field,division_by_zero})"
   909 apply (case_tac "b = 0")
   910 apply (simp_all add: nonzero_mult_divide_cancel_right)
   911 done
   912 
   913 (*For ExtractCommonTerm*)
   914 lemma mult_divide_cancel_eq_if:
   915      "(c*a) / (c*b) = 
   916       (if c=0 then 0 else a / (b::'a::{field,division_by_zero}))"
   917   by (simp add: mult_divide_cancel_left)
   918 
   919 lemma divide_1 [simp]: "a/1 = (a::'a::field)"
   920   by (simp add: divide_inverse)
   921 
   922 lemma times_divide_eq_right: "a * (b/c) = (a*b) / (c::'a::field)"
   923 by (simp add: divide_inverse mult_assoc)
   924 
   925 lemma times_divide_eq_left: "(b/c) * a = (b*a) / (c::'a::field)"
   926 by (simp add: divide_inverse mult_ac)
   927 
   928 lemma divide_divide_eq_right [simp]:
   929      "a / (b/c) = (a*c) / (b::'a::{field,division_by_zero})"
   930 by (simp add: divide_inverse mult_ac)
   931 
   932 lemma divide_divide_eq_left [simp]:
   933      "(a / b) / (c::'a::{field,division_by_zero}) = a / (b*c)"
   934 by (simp add: divide_inverse mult_assoc)
   935 
   936 
   937 subsubsection{*Special Cancellation Simprules for Division*}
   938 
   939 lemma mult_divide_cancel_left_if [simp]:
   940   fixes c :: "'a :: {field,division_by_zero}"
   941   shows "(c*a) / (c*b) = (if c=0 then 0 else a/b)"
   942 by (simp add: mult_divide_cancel_left)
   943 
   944 lemma mult_divide_cancel_right_if [simp]:
   945   fixes c :: "'a :: {field,division_by_zero}"
   946   shows "(a*c) / (b*c) = (if c=0 then 0 else a/b)"
   947 by (simp add: mult_divide_cancel_right)
   948 
   949 lemma mult_divide_cancel_left_if1 [simp]:
   950   fixes c :: "'a :: {field,division_by_zero}"
   951   shows "c / (c*b) = (if c=0 then 0 else 1/b)"
   952 apply (insert mult_divide_cancel_left_if [of c 1 b]) 
   953 apply (simp del: mult_divide_cancel_left_if)
   954 done
   955 
   956 lemma mult_divide_cancel_left_if2 [simp]:
   957   fixes c :: "'a :: {field,division_by_zero}"
   958   shows "(c*a) / c = (if c=0 then 0 else a)" 
   959 apply (insert mult_divide_cancel_left_if [of c a 1]) 
   960 apply (simp del: mult_divide_cancel_left_if)
   961 done
   962 
   963 lemma mult_divide_cancel_right_if1 [simp]:
   964   fixes c :: "'a :: {field,division_by_zero}"
   965   shows "c / (b*c) = (if c=0 then 0 else 1/b)"
   966 apply (insert mult_divide_cancel_right_if [of 1 c b]) 
   967 apply (simp del: mult_divide_cancel_right_if)
   968 done
   969 
   970 lemma mult_divide_cancel_right_if2 [simp]:
   971   fixes c :: "'a :: {field,division_by_zero}"
   972   shows "(a*c) / c = (if c=0 then 0 else a)" 
   973 apply (insert mult_divide_cancel_right_if [of a c 1]) 
   974 apply (simp del: mult_divide_cancel_right_if)
   975 done
   976 
   977 text{*Two lemmas for cancelling the denominator*}
   978 
   979 lemma times_divide_self_right [simp]: 
   980   fixes a :: "'a :: {field,division_by_zero}"
   981   shows "a * (b/a) = (if a=0 then 0 else b)"
   982 by (simp add: times_divide_eq_right)
   983 
   984 lemma times_divide_self_left [simp]: 
   985   fixes a :: "'a :: {field,division_by_zero}"
   986   shows "(b/a) * a = (if a=0 then 0 else b)"
   987 by (simp add: times_divide_eq_left)
   988 
   989 
   990 subsection {* Division and Unary Minus *}
   991 
   992 lemma nonzero_minus_divide_left: "b \<noteq> 0 ==> - (a/b) = (-a) / (b::'a::field)"
   993 by (simp add: divide_inverse minus_mult_left)
   994 
   995 lemma nonzero_minus_divide_right: "b \<noteq> 0 ==> - (a/b) = a / -(b::'a::field)"
   996 by (simp add: divide_inverse nonzero_inverse_minus_eq minus_mult_right)
   997 
   998 lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (-a)/(-b) = a / (b::'a::field)"
   999 by (simp add: divide_inverse nonzero_inverse_minus_eq)
  1000 
  1001 lemma minus_divide_left: "- (a/b) = (-a) / (b::'a::field)"
  1002 by (simp add: divide_inverse minus_mult_left [symmetric])
  1003 
  1004 lemma minus_divide_right: "- (a/b) = a / -(b::'a::{field,division_by_zero})"
  1005 by (simp add: divide_inverse minus_mult_right [symmetric])
  1006 
  1007 
  1008 text{*The effect is to extract signs from divisions*}
  1009 declare minus_divide_left  [symmetric, simp]
  1010 declare minus_divide_right [symmetric, simp]
  1011 
  1012 text{*Also, extract signs from products*}
  1013 declare minus_mult_left [symmetric, simp]
  1014 declare minus_mult_right [symmetric, simp]
  1015 
  1016 lemma minus_divide_divide [simp]:
  1017      "(-a)/(-b) = a / (b::'a::{field,division_by_zero})"
  1018 apply (case_tac "b=0", simp) 
  1019 apply (simp add: nonzero_minus_divide_divide) 
  1020 done
  1021 
  1022 lemma diff_divide_distrib: "(a-b)/(c::'a::field) = a/c - b/c"
  1023 by (simp add: diff_minus add_divide_distrib) 
  1024 
  1025 
  1026 subsection {* Ordered Fields *}
  1027 
  1028 lemma positive_imp_inverse_positive: 
  1029       assumes a_gt_0: "0 < a"  shows "0 < inverse (a::'a::ordered_field)"
  1030   proof -
  1031   have "0 < a * inverse a" 
  1032     by (simp add: a_gt_0 [THEN order_less_imp_not_eq2] zero_less_one)
  1033   thus "0 < inverse a" 
  1034     by (simp add: a_gt_0 [THEN order_less_not_sym] zero_less_mult_iff)
  1035   qed
  1036 
  1037 lemma negative_imp_inverse_negative:
  1038      "a < 0 ==> inverse a < (0::'a::ordered_field)"
  1039   by (insert positive_imp_inverse_positive [of "-a"], 
  1040       simp add: nonzero_inverse_minus_eq order_less_imp_not_eq) 
  1041 
  1042 lemma inverse_le_imp_le:
  1043       assumes invle: "inverse a \<le> inverse b"
  1044 	  and apos:  "0 < a"
  1045 	 shows "b \<le> (a::'a::ordered_field)"
  1046   proof (rule classical)
  1047   assume "~ b \<le> a"
  1048   hence "a < b"
  1049     by (simp add: linorder_not_le)
  1050   hence bpos: "0 < b"
  1051     by (blast intro: apos order_less_trans)
  1052   hence "a * inverse a \<le> a * inverse b"
  1053     by (simp add: apos invle order_less_imp_le mult_left_mono)
  1054   hence "(a * inverse a) * b \<le> (a * inverse b) * b"
  1055     by (simp add: bpos order_less_imp_le mult_right_mono)
  1056   thus "b \<le> a"
  1057     by (simp add: mult_assoc apos bpos order_less_imp_not_eq2)
  1058   qed
  1059 
  1060 lemma inverse_positive_imp_positive:
  1061       assumes inv_gt_0: "0 < inverse a"
  1062           and [simp]:   "a \<noteq> 0"
  1063         shows "0 < (a::'a::ordered_field)"
  1064   proof -
  1065   have "0 < inverse (inverse a)"
  1066     by (rule positive_imp_inverse_positive)
  1067   thus "0 < a"
  1068     by (simp add: nonzero_inverse_inverse_eq)
  1069   qed
  1070 
  1071 lemma inverse_positive_iff_positive [simp]:
  1072       "(0 < inverse a) = (0 < (a::'a::{ordered_field,division_by_zero}))"
  1073 apply (case_tac "a = 0", simp)
  1074 apply (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive)
  1075 done
  1076 
  1077 lemma inverse_negative_imp_negative:
  1078       assumes inv_less_0: "inverse a < 0"
  1079           and [simp]:   "a \<noteq> 0"
  1080         shows "a < (0::'a::ordered_field)"
  1081   proof -
  1082   have "inverse (inverse a) < 0"
  1083     by (rule negative_imp_inverse_negative)
  1084   thus "a < 0"
  1085     by (simp add: nonzero_inverse_inverse_eq)
  1086   qed
  1087 
  1088 lemma inverse_negative_iff_negative [simp]:
  1089       "(inverse a < 0) = (a < (0::'a::{ordered_field,division_by_zero}))"
  1090 apply (case_tac "a = 0", simp)
  1091 apply (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative)
  1092 done
  1093 
  1094 lemma inverse_nonnegative_iff_nonnegative [simp]:
  1095       "(0 \<le> inverse a) = (0 \<le> (a::'a::{ordered_field,division_by_zero}))"
  1096 by (simp add: linorder_not_less [symmetric])
  1097 
  1098 lemma inverse_nonpositive_iff_nonpositive [simp]:
  1099       "(inverse a \<le> 0) = (a \<le> (0::'a::{ordered_field,division_by_zero}))"
  1100 by (simp add: linorder_not_less [symmetric])
  1101 
  1102 
  1103 subsection{*Anti-Monotonicity of @{term inverse}*}
  1104 
  1105 lemma less_imp_inverse_less:
  1106       assumes less: "a < b"
  1107 	  and apos:  "0 < a"
  1108 	shows "inverse b < inverse (a::'a::ordered_field)"
  1109   proof (rule ccontr)
  1110   assume "~ inverse b < inverse a"
  1111   hence "inverse a \<le> inverse b"
  1112     by (simp add: linorder_not_less)
  1113   hence "~ (a < b)"
  1114     by (simp add: linorder_not_less inverse_le_imp_le [OF _ apos])
  1115   thus False
  1116     by (rule notE [OF _ less])
  1117   qed
  1118 
  1119 lemma inverse_less_imp_less:
  1120    "[|inverse a < inverse b; 0 < a|] ==> b < (a::'a::ordered_field)"
  1121 apply (simp add: order_less_le [of "inverse a"] order_less_le [of "b"])
  1122 apply (force dest!: inverse_le_imp_le nonzero_inverse_eq_imp_eq) 
  1123 done
  1124 
  1125 text{*Both premises are essential. Consider -1 and 1.*}
  1126 lemma inverse_less_iff_less [simp]:
  1127      "[|0 < a; 0 < b|] 
  1128       ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
  1129 by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less) 
  1130 
  1131 lemma le_imp_inverse_le:
  1132    "[|a \<le> b; 0 < a|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
  1133   by (force simp add: order_le_less less_imp_inverse_less)
  1134 
  1135 lemma inverse_le_iff_le [simp]:
  1136      "[|0 < a; 0 < b|] 
  1137       ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
  1138 by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le) 
  1139 
  1140 
  1141 text{*These results refer to both operands being negative.  The opposite-sign
  1142 case is trivial, since inverse preserves signs.*}
  1143 lemma inverse_le_imp_le_neg:
  1144    "[|inverse a \<le> inverse b; b < 0|] ==> b \<le> (a::'a::ordered_field)"
  1145   apply (rule classical) 
  1146   apply (subgoal_tac "a < 0") 
  1147    prefer 2 apply (force simp add: linorder_not_le intro: order_less_trans) 
  1148   apply (insert inverse_le_imp_le [of "-b" "-a"])
  1149   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1150   done
  1151 
  1152 lemma less_imp_inverse_less_neg:
  1153    "[|a < b; b < 0|] ==> inverse b < inverse (a::'a::ordered_field)"
  1154   apply (subgoal_tac "a < 0") 
  1155    prefer 2 apply (blast intro: order_less_trans) 
  1156   apply (insert less_imp_inverse_less [of "-b" "-a"])
  1157   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1158   done
  1159 
  1160 lemma inverse_less_imp_less_neg:
  1161    "[|inverse a < inverse b; b < 0|] ==> b < (a::'a::ordered_field)"
  1162   apply (rule classical) 
  1163   apply (subgoal_tac "a < 0") 
  1164    prefer 2
  1165    apply (force simp add: linorder_not_less intro: order_le_less_trans) 
  1166   apply (insert inverse_less_imp_less [of "-b" "-a"])
  1167   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1168   done
  1169 
  1170 lemma inverse_less_iff_less_neg [simp]:
  1171      "[|a < 0; b < 0|] 
  1172       ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
  1173   apply (insert inverse_less_iff_less [of "-b" "-a"])
  1174   apply (simp del: inverse_less_iff_less 
  1175 	      add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1176   done
  1177 
  1178 lemma le_imp_inverse_le_neg:
  1179    "[|a \<le> b; b < 0|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
  1180   by (force simp add: order_le_less less_imp_inverse_less_neg)
  1181 
  1182 lemma inverse_le_iff_le_neg [simp]:
  1183      "[|a < 0; b < 0|] 
  1184       ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
  1185 by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg) 
  1186 
  1187 
  1188 subsection{*Inverses and the Number One*}
  1189 
  1190 lemma one_less_inverse_iff:
  1191     "(1 < inverse x) = (0 < x & x < (1::'a::{ordered_field,division_by_zero}))"proof cases
  1192   assume "0 < x"
  1193     with inverse_less_iff_less [OF zero_less_one, of x]
  1194     show ?thesis by simp
  1195 next
  1196   assume notless: "~ (0 < x)"
  1197   have "~ (1 < inverse x)"
  1198   proof
  1199     assume "1 < inverse x"
  1200     also with notless have "... \<le> 0" by (simp add: linorder_not_less)
  1201     also have "... < 1" by (rule zero_less_one) 
  1202     finally show False by auto
  1203   qed
  1204   with notless show ?thesis by simp
  1205 qed
  1206 
  1207 lemma inverse_eq_1_iff [simp]:
  1208     "(inverse x = 1) = (x = (1::'a::{field,division_by_zero}))"
  1209 by (insert inverse_eq_iff_eq [of x 1], simp) 
  1210 
  1211 lemma one_le_inverse_iff:
  1212    "(1 \<le> inverse x) = (0 < x & x \<le> (1::'a::{ordered_field,division_by_zero}))"
  1213 by (force simp add: order_le_less one_less_inverse_iff zero_less_one 
  1214                     eq_commute [of 1]) 
  1215 
  1216 lemma inverse_less_1_iff:
  1217    "(inverse x < 1) = (x \<le> 0 | 1 < (x::'a::{ordered_field,division_by_zero}))"
  1218 by (simp add: linorder_not_le [symmetric] one_le_inverse_iff) 
  1219 
  1220 lemma inverse_le_1_iff:
  1221    "(inverse x \<le> 1) = (x \<le> 0 | 1 \<le> (x::'a::{ordered_field,division_by_zero}))"
  1222 by (simp add: linorder_not_less [symmetric] one_less_inverse_iff) 
  1223 
  1224 
  1225 subsection{*Division and Signs*}
  1226 
  1227 lemma zero_less_divide_iff:
  1228      "((0::'a::{ordered_field,division_by_zero}) < a/b) = (0 < a & 0 < b | a < 0 & b < 0)"
  1229 by (simp add: divide_inverse zero_less_mult_iff)
  1230 
  1231 lemma divide_less_0_iff:
  1232      "(a/b < (0::'a::{ordered_field,division_by_zero})) = 
  1233       (0 < a & b < 0 | a < 0 & 0 < b)"
  1234 by (simp add: divide_inverse mult_less_0_iff)
  1235 
  1236 lemma zero_le_divide_iff:
  1237      "((0::'a::{ordered_field,division_by_zero}) \<le> a/b) =
  1238       (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
  1239 by (simp add: divide_inverse zero_le_mult_iff)
  1240 
  1241 lemma divide_le_0_iff:
  1242      "(a/b \<le> (0::'a::{ordered_field,division_by_zero})) =
  1243       (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
  1244 by (simp add: divide_inverse mult_le_0_iff)
  1245 
  1246 lemma divide_eq_0_iff [simp]:
  1247      "(a/b = 0) = (a=0 | b=(0::'a::{field,division_by_zero}))"
  1248 by (simp add: divide_inverse field_mult_eq_0_iff)
  1249 
  1250 
  1251 subsection{*Simplification of Inequalities Involving Literal Divisors*}
  1252 
  1253 lemma pos_le_divide_eq: "0 < (c::'a::ordered_field) ==> (a \<le> b/c) = (a*c \<le> b)"
  1254 proof -
  1255   assume less: "0<c"
  1256   hence "(a \<le> b/c) = (a*c \<le> (b/c)*c)"
  1257     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1258   also have "... = (a*c \<le> b)"
  1259     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1260   finally show ?thesis .
  1261 qed
  1262 
  1263 
  1264 lemma neg_le_divide_eq: "c < (0::'a::ordered_field) ==> (a \<le> b/c) = (b \<le> a*c)"
  1265 proof -
  1266   assume less: "c<0"
  1267   hence "(a \<le> b/c) = ((b/c)*c \<le> a*c)"
  1268     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1269   also have "... = (b \<le> a*c)"
  1270     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1271   finally show ?thesis .
  1272 qed
  1273 
  1274 lemma le_divide_eq:
  1275   "(a \<le> b/c) = 
  1276    (if 0 < c then a*c \<le> b
  1277              else if c < 0 then b \<le> a*c
  1278              else  a \<le> (0::'a::{ordered_field,division_by_zero}))"
  1279 apply (case_tac "c=0", simp) 
  1280 apply (force simp add: pos_le_divide_eq neg_le_divide_eq linorder_neq_iff) 
  1281 done
  1282 
  1283 lemma pos_divide_le_eq: "0 < (c::'a::ordered_field) ==> (b/c \<le> a) = (b \<le> a*c)"
  1284 proof -
  1285   assume less: "0<c"
  1286   hence "(b/c \<le> a) = ((b/c)*c \<le> a*c)"
  1287     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1288   also have "... = (b \<le> a*c)"
  1289     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1290   finally show ?thesis .
  1291 qed
  1292 
  1293 lemma neg_divide_le_eq: "c < (0::'a::ordered_field) ==> (b/c \<le> a) = (a*c \<le> b)"
  1294 proof -
  1295   assume less: "c<0"
  1296   hence "(b/c \<le> a) = (a*c \<le> (b/c)*c)"
  1297     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1298   also have "... = (a*c \<le> b)"
  1299     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1300   finally show ?thesis .
  1301 qed
  1302 
  1303 lemma divide_le_eq:
  1304   "(b/c \<le> a) = 
  1305    (if 0 < c then b \<le> a*c
  1306              else if c < 0 then a*c \<le> b
  1307              else 0 \<le> (a::'a::{ordered_field,division_by_zero}))"
  1308 apply (case_tac "c=0", simp) 
  1309 apply (force simp add: pos_divide_le_eq neg_divide_le_eq linorder_neq_iff) 
  1310 done
  1311 
  1312 
  1313 lemma pos_less_divide_eq:
  1314      "0 < (c::'a::ordered_field) ==> (a < b/c) = (a*c < b)"
  1315 proof -
  1316   assume less: "0<c"
  1317   hence "(a < b/c) = (a*c < (b/c)*c)"
  1318     by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
  1319   also have "... = (a*c < b)"
  1320     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1321   finally show ?thesis .
  1322 qed
  1323 
  1324 lemma neg_less_divide_eq:
  1325  "c < (0::'a::ordered_field) ==> (a < b/c) = (b < a*c)"
  1326 proof -
  1327   assume less: "c<0"
  1328   hence "(a < b/c) = ((b/c)*c < a*c)"
  1329     by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
  1330   also have "... = (b < a*c)"
  1331     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1332   finally show ?thesis .
  1333 qed
  1334 
  1335 lemma less_divide_eq:
  1336   "(a < b/c) = 
  1337    (if 0 < c then a*c < b
  1338              else if c < 0 then b < a*c
  1339              else  a < (0::'a::{ordered_field,division_by_zero}))"
  1340 apply (case_tac "c=0", simp) 
  1341 apply (force simp add: pos_less_divide_eq neg_less_divide_eq linorder_neq_iff) 
  1342 done
  1343 
  1344 lemma pos_divide_less_eq:
  1345      "0 < (c::'a::ordered_field) ==> (b/c < a) = (b < a*c)"
  1346 proof -
  1347   assume less: "0<c"
  1348   hence "(b/c < a) = ((b/c)*c < a*c)"
  1349     by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
  1350   also have "... = (b < a*c)"
  1351     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1352   finally show ?thesis .
  1353 qed
  1354 
  1355 lemma neg_divide_less_eq:
  1356  "c < (0::'a::ordered_field) ==> (b/c < a) = (a*c < b)"
  1357 proof -
  1358   assume less: "c<0"
  1359   hence "(b/c < a) = (a*c < (b/c)*c)"
  1360     by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
  1361   also have "... = (a*c < b)"
  1362     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1363   finally show ?thesis .
  1364 qed
  1365 
  1366 lemma divide_less_eq:
  1367   "(b/c < a) = 
  1368    (if 0 < c then b < a*c
  1369              else if c < 0 then a*c < b
  1370              else 0 < (a::'a::{ordered_field,division_by_zero}))"
  1371 apply (case_tac "c=0", simp) 
  1372 apply (force simp add: pos_divide_less_eq neg_divide_less_eq linorder_neq_iff) 
  1373 done
  1374 
  1375 lemma nonzero_eq_divide_eq: "c\<noteq>0 ==> ((a::'a::field) = b/c) = (a*c = b)"
  1376 proof -
  1377   assume [simp]: "c\<noteq>0"
  1378   have "(a = b/c) = (a*c = (b/c)*c)"
  1379     by (simp add: field_mult_cancel_right)
  1380   also have "... = (a*c = b)"
  1381     by (simp add: divide_inverse mult_assoc) 
  1382   finally show ?thesis .
  1383 qed
  1384 
  1385 lemma eq_divide_eq:
  1386   "((a::'a::{field,division_by_zero}) = b/c) = (if c\<noteq>0 then a*c = b else a=0)"
  1387 by (simp add: nonzero_eq_divide_eq) 
  1388 
  1389 lemma nonzero_divide_eq_eq: "c\<noteq>0 ==> (b/c = (a::'a::field)) = (b = a*c)"
  1390 proof -
  1391   assume [simp]: "c\<noteq>0"
  1392   have "(b/c = a) = ((b/c)*c = a*c)"
  1393     by (simp add: field_mult_cancel_right)
  1394   also have "... = (b = a*c)"
  1395     by (simp add: divide_inverse mult_assoc) 
  1396   finally show ?thesis .
  1397 qed
  1398 
  1399 lemma divide_eq_eq:
  1400   "(b/c = (a::'a::{field,division_by_zero})) = (if c\<noteq>0 then b = a*c else a=0)"
  1401 by (force simp add: nonzero_divide_eq_eq) 
  1402 
  1403 
  1404 subsection{*Cancellation Laws for Division*}
  1405 
  1406 lemma divide_cancel_right [simp]:
  1407      "(a/c = b/c) = (c = 0 | a = (b::'a::{field,division_by_zero}))"
  1408 apply (case_tac "c=0", simp) 
  1409 apply (simp add: divide_inverse field_mult_cancel_right) 
  1410 done
  1411 
  1412 lemma divide_cancel_left [simp]:
  1413      "(c/a = c/b) = (c = 0 | a = (b::'a::{field,division_by_zero}))" 
  1414 apply (case_tac "c=0", simp) 
  1415 apply (simp add: divide_inverse field_mult_cancel_left) 
  1416 done
  1417 
  1418 subsection {* Division and the Number One *}
  1419 
  1420 text{*Simplify expressions equated with 1*}
  1421 lemma divide_eq_1_iff [simp]:
  1422      "(a/b = 1) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
  1423 apply (case_tac "b=0", simp) 
  1424 apply (simp add: right_inverse_eq) 
  1425 done
  1426 
  1427 
  1428 lemma one_eq_divide_iff [simp]:
  1429      "(1 = a/b) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
  1430 by (simp add: eq_commute [of 1])  
  1431 
  1432 lemma zero_eq_1_divide_iff [simp]:
  1433      "((0::'a::{ordered_field,division_by_zero}) = 1/a) = (a = 0)"
  1434 apply (case_tac "a=0", simp) 
  1435 apply (auto simp add: nonzero_eq_divide_eq) 
  1436 done
  1437 
  1438 lemma one_divide_eq_0_iff [simp]:
  1439      "(1/a = (0::'a::{ordered_field,division_by_zero})) = (a = 0)"
  1440 apply (case_tac "a=0", simp) 
  1441 apply (insert zero_neq_one [THEN not_sym]) 
  1442 apply (auto simp add: nonzero_divide_eq_eq) 
  1443 done
  1444 
  1445 text{*Simplify expressions such as @{text "0 < 1/x"} to @{text "0 < x"}*}
  1446 declare zero_less_divide_iff [of "1", simp]
  1447 declare divide_less_0_iff [of "1", simp]
  1448 declare zero_le_divide_iff [of "1", simp]
  1449 declare divide_le_0_iff [of "1", simp]
  1450 
  1451 
  1452 subsection {* Ordering Rules for Division *}
  1453 
  1454 lemma divide_strict_right_mono:
  1455      "[|a < b; 0 < c|] ==> a / c < b / (c::'a::ordered_field)"
  1456 by (simp add: order_less_imp_not_eq2 divide_inverse mult_strict_right_mono 
  1457               positive_imp_inverse_positive) 
  1458 
  1459 lemma divide_right_mono:
  1460      "[|a \<le> b; 0 \<le> c|] ==> a/c \<le> b/(c::'a::{ordered_field,division_by_zero})"
  1461   by (force simp add: divide_strict_right_mono order_le_less) 
  1462 
  1463 
  1464 text{*The last premise ensures that @{term a} and @{term b} 
  1465       have the same sign*}
  1466 lemma divide_strict_left_mono:
  1467        "[|b < a; 0 < c; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)"
  1468 by (force simp add: zero_less_mult_iff divide_inverse mult_strict_left_mono 
  1469       order_less_imp_not_eq order_less_imp_not_eq2  
  1470       less_imp_inverse_less less_imp_inverse_less_neg) 
  1471 
  1472 lemma divide_left_mono:
  1473      "[|b \<le> a; 0 \<le> c; 0 < a*b|] ==> c / a \<le> c / (b::'a::ordered_field)"
  1474   apply (subgoal_tac "a \<noteq> 0 & b \<noteq> 0") 
  1475    prefer 2 
  1476    apply (force simp add: zero_less_mult_iff order_less_imp_not_eq) 
  1477   apply (case_tac "c=0", simp add: divide_inverse)
  1478   apply (force simp add: divide_strict_left_mono order_le_less) 
  1479   done
  1480 
  1481 lemma divide_strict_left_mono_neg:
  1482      "[|a < b; c < 0; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)"
  1483   apply (subgoal_tac "a \<noteq> 0 & b \<noteq> 0") 
  1484    prefer 2 
  1485    apply (force simp add: zero_less_mult_iff order_less_imp_not_eq) 
  1486   apply (drule divide_strict_left_mono [of _ _ "-c"]) 
  1487    apply (simp_all add: mult_commute nonzero_minus_divide_left [symmetric]) 
  1488   done
  1489 
  1490 lemma divide_strict_right_mono_neg:
  1491      "[|b < a; c < 0|] ==> a / c < b / (c::'a::ordered_field)"
  1492 apply (drule divide_strict_right_mono [of _ _ "-c"], simp) 
  1493 apply (simp add: order_less_imp_not_eq nonzero_minus_divide_right [symmetric]) 
  1494 done
  1495 
  1496 
  1497 subsection {* Ordered Fields are Dense *}
  1498 
  1499 lemma less_add_one: "a < (a+1::'a::ordered_semidom)"
  1500 proof -
  1501   have "a+0 < (a+1::'a::ordered_semidom)"
  1502     by (blast intro: zero_less_one add_strict_left_mono) 
  1503   thus ?thesis by simp
  1504 qed
  1505 
  1506 lemma zero_less_two: "0 < (1+1::'a::ordered_semidom)"
  1507   by (blast intro: order_less_trans zero_less_one less_add_one) 
  1508 
  1509 lemma less_half_sum: "a < b ==> a < (a+b) / (1+1::'a::ordered_field)"
  1510 by (simp add: zero_less_two pos_less_divide_eq right_distrib) 
  1511 
  1512 lemma gt_half_sum: "a < b ==> (a+b)/(1+1::'a::ordered_field) < b"
  1513 by (simp add: zero_less_two pos_divide_less_eq right_distrib) 
  1514 
  1515 lemma dense: "a < b ==> \<exists>r::'a::ordered_field. a < r & r < b"
  1516 by (blast intro!: less_half_sum gt_half_sum)
  1517 
  1518 
  1519 lemmas times_divide_eq = times_divide_eq_right times_divide_eq_left
  1520 
  1521 text{*It's not obvious whether these should be simprules or not. 
  1522   Their effect is to gather terms into one big fraction, like
  1523   a*b*c / x*y*z. The rationale for that is unclear, but many proofs 
  1524   seem to need them.*}
  1525 
  1526 declare times_divide_eq [simp]
  1527 
  1528 
  1529 subsection {* Absolute Value *}
  1530 
  1531 lemma abs_one [simp]: "abs 1 = (1::'a::ordered_idom)"
  1532   by (simp add: abs_if zero_less_one [THEN order_less_not_sym]) 
  1533 
  1534 lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lordered_ring))" 
  1535 proof -
  1536   let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b"
  1537   let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
  1538   have a: "(abs a) * (abs b) = ?x"
  1539     by (simp only: abs_prts[of a] abs_prts[of b] ring_eq_simps)
  1540   {
  1541     fix u v :: 'a
  1542     have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow> 
  1543               u * v = pprt a * pprt b + pprt a * nprt b + 
  1544                       nprt a * pprt b + nprt a * nprt b"
  1545       apply (subst prts[of u], subst prts[of v])
  1546       apply (simp add: left_distrib right_distrib add_ac) 
  1547       done
  1548   }
  1549   note b = this[OF refl[of a] refl[of b]]
  1550   note addm = add_mono[of "0::'a" _ "0::'a", simplified]
  1551   note addm2 = add_mono[of _ "0::'a" _ "0::'a", simplified]
  1552   have xy: "- ?x <= ?y"
  1553     apply (simp)
  1554     apply (rule_tac y="0::'a" in order_trans)
  1555     apply (rule addm2)+
  1556     apply (simp_all add: mult_pos_le mult_neg_le)
  1557     apply (rule addm)+
  1558     apply (simp_all add: mult_pos_le mult_neg_le)
  1559     done
  1560   have yx: "?y <= ?x"
  1561     apply (simp add: add_ac)
  1562     apply (rule_tac y=0 in order_trans)
  1563     apply (rule addm2, (simp add: mult_pos_neg_le mult_pos_neg2_le)+)
  1564     apply (rule addm, (simp add: mult_pos_neg_le mult_pos_neg2_le)+)
  1565     done
  1566   have i1: "a*b <= abs a * abs b" by (simp only: a b yx)
  1567   have i2: "- (abs a * abs b) <= a*b" by (simp only: a b xy)
  1568   show ?thesis
  1569     apply (rule abs_leI)
  1570     apply (simp add: i1)
  1571     apply (simp add: i2[simplified minus_le_iff])
  1572     done
  1573 qed
  1574 
  1575 lemma abs_eq_mult: 
  1576   assumes "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0)"
  1577   shows "abs (a*b) = abs a * abs (b::'a::lordered_ring)"
  1578 proof -
  1579   have s: "(0 <= a*b) | (a*b <= 0)"
  1580     apply (auto)    
  1581     apply (rule_tac split_mult_pos_le)
  1582     apply (rule_tac contrapos_np[of "a*b <= 0"])
  1583     apply (simp)
  1584     apply (rule_tac split_mult_neg_le)
  1585     apply (insert prems)
  1586     apply (blast)
  1587     done
  1588   have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
  1589     by (simp add: prts[symmetric])
  1590   show ?thesis
  1591   proof cases
  1592     assume "0 <= a * b"
  1593     then show ?thesis
  1594       apply (simp_all add: mulprts abs_prts)
  1595       apply (insert prems)
  1596       apply (auto simp add: 
  1597 	ring_eq_simps 
  1598 	iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_zero_pprt]
  1599 	iff2imp[OF le_zero_iff_pprt_id] iff2imp[OF zero_le_iff_nprt_id])
  1600 	apply(drule (1) mult_pos_neg_le[of a b], simp)
  1601 	apply(drule (1) mult_pos_neg2_le[of b a], simp)
  1602       done
  1603   next
  1604     assume "~(0 <= a*b)"
  1605     with s have "a*b <= 0" by simp
  1606     then show ?thesis
  1607       apply (simp_all add: mulprts abs_prts)
  1608       apply (insert prems)
  1609       apply (auto simp add: ring_eq_simps)
  1610       apply(drule (1) mult_pos_le[of a b],simp)
  1611       apply(drule (1) mult_neg_le[of a b],simp)
  1612       done
  1613   qed
  1614 qed
  1615 
  1616 lemma abs_mult: "abs (a * b) = abs a * abs (b::'a::ordered_idom)" 
  1617 by (simp add: abs_eq_mult linorder_linear)
  1618 
  1619 lemma abs_mult_self: "abs a * abs a = a * (a::'a::ordered_idom)"
  1620 by (simp add: abs_if) 
  1621 
  1622 lemma nonzero_abs_inverse:
  1623      "a \<noteq> 0 ==> abs (inverse (a::'a::ordered_field)) = inverse (abs a)"
  1624 apply (auto simp add: linorder_neq_iff abs_if nonzero_inverse_minus_eq 
  1625                       negative_imp_inverse_negative)
  1626 apply (blast intro: positive_imp_inverse_positive elim: order_less_asym) 
  1627 done
  1628 
  1629 lemma abs_inverse [simp]:
  1630      "abs (inverse (a::'a::{ordered_field,division_by_zero})) = 
  1631       inverse (abs a)"
  1632 apply (case_tac "a=0", simp) 
  1633 apply (simp add: nonzero_abs_inverse) 
  1634 done
  1635 
  1636 lemma nonzero_abs_divide:
  1637      "b \<noteq> 0 ==> abs (a / (b::'a::ordered_field)) = abs a / abs b"
  1638 by (simp add: divide_inverse abs_mult nonzero_abs_inverse) 
  1639 
  1640 lemma abs_divide [simp]:
  1641      "abs (a / (b::'a::{ordered_field,division_by_zero})) = abs a / abs b"
  1642 apply (case_tac "b=0", simp) 
  1643 apply (simp add: nonzero_abs_divide) 
  1644 done
  1645 
  1646 lemma abs_mult_less:
  1647      "[| abs a < c; abs b < d |] ==> abs a * abs b < c*(d::'a::ordered_idom)"
  1648 proof -
  1649   assume ac: "abs a < c"
  1650   hence cpos: "0<c" by (blast intro: order_le_less_trans abs_ge_zero)
  1651   assume "abs b < d"
  1652   thus ?thesis by (simp add: ac cpos mult_strict_mono) 
  1653 qed
  1654 
  1655 lemma eq_minus_self_iff: "(a = -a) = (a = (0::'a::ordered_idom))"
  1656 by (force simp add: order_eq_iff le_minus_self_iff minus_le_self_iff)
  1657 
  1658 lemma less_minus_self_iff: "(a < -a) = (a < (0::'a::ordered_idom))"
  1659 by (simp add: order_less_le le_minus_self_iff eq_minus_self_iff)
  1660 
  1661 lemma abs_less_iff: "(abs a < b) = (a < b & -a < (b::'a::ordered_idom))" 
  1662 apply (simp add: order_less_le abs_le_iff)  
  1663 apply (auto simp add: abs_if minus_le_self_iff eq_minus_self_iff)
  1664 apply (simp add: le_minus_self_iff linorder_neq_iff) 
  1665 done
  1666 
  1667 lemma linprog_dual_estimate:
  1668   assumes
  1669   "A * x \<le> (b::'a::lordered_ring)"
  1670   "0 \<le> y"
  1671   "abs (A - A') \<le> \<delta>A"
  1672   "b \<le> b'"
  1673   "abs (c - c') \<le> \<delta>c"
  1674   "abs x \<le> r"
  1675   shows
  1676   "c * x \<le> y * b' + (y * \<delta>A + abs (y * A' - c') + \<delta>c) * r"
  1677 proof -
  1678   from prems have 1: "y * b <= y * b'" by (simp add: mult_left_mono)
  1679   from prems have 2: "y * (A * x) <= y * b" by (simp add: mult_left_mono) 
  1680   have 3: "y * (A * x) = c * x + (y * (A - A') + (y * A' - c') + (c'-c)) * x" by (simp add: ring_eq_simps)  
  1681   from 1 2 3 have 4: "c * x + (y * (A - A') + (y * A' - c') + (c'-c)) * x <= y * b'" by simp
  1682   have 5: "c * x <= y * b' + abs((y * (A - A') + (y * A' - c') + (c'-c)) * x)"
  1683     by (simp only: 4 estimate_by_abs)  
  1684   have 6: "abs((y * (A - A') + (y * A' - c') + (c'-c)) * x) <= abs (y * (A - A') + (y * A' - c') + (c'-c)) * abs x"
  1685     by (simp add: abs_le_mult)
  1686   have 7: "(abs (y * (A - A') + (y * A' - c') + (c'-c))) * abs x <= (abs (y * (A-A') + (y*A'-c')) + abs(c'-c)) * abs x"
  1687     by (simp add: abs_triangle_ineq mult_right_mono)
  1688   have 8: " (abs (y * (A-A') + (y*A'-c')) + abs(c'-c)) * abs x <=  (abs (y * (A-A')) + abs (y*A'-c') + abs(c'-c)) * abs x"
  1689     by (simp add: abs_triangle_ineq mult_right_mono)    
  1690   have 9: "(abs (y * (A-A')) + abs (y*A'-c') + abs(c'-c)) * abs x <= (abs y * abs (A-A') + abs (y*A'-c') + abs (c'-c)) * abs x"
  1691     by (simp add: abs_le_mult mult_right_mono)  
  1692   have 10: "c'-c = -(c-c')" by (simp add: ring_eq_simps)
  1693   have 11: "abs (c'-c) = abs (c-c')" 
  1694     by (subst 10, subst abs_minus_cancel, simp)
  1695   have 12: "(abs y * abs (A-A') + abs (y*A'-c') + abs (c'-c)) * abs x <= (abs y * abs (A-A') + abs (y*A'-c') + \<delta>c) * abs x"
  1696     by (simp add: 11 prems mult_right_mono)
  1697   have 13: "(abs y * abs (A-A') + abs (y*A'-c') + \<delta>c) * abs x <= (abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * abs x"
  1698     by (simp add: prems mult_right_mono mult_left_mono)  
  1699   have r: "(abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * abs x <=  (abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * r"
  1700     apply (rule mult_left_mono)
  1701     apply (simp add: prems)
  1702     apply (rule_tac add_mono[of "0::'a" _ "0", simplified])+
  1703     apply (rule mult_left_mono[of "0" "\<delta>A", simplified])
  1704     apply (simp_all)
  1705     apply (rule order_trans[where y="abs (A-A')"], simp_all add: prems)
  1706     apply (rule order_trans[where y="abs (c-c')"], simp_all add: prems)
  1707     done    
  1708   from 6 7 8 9 12 13 r have 14:" abs((y * (A - A') + (y * A' - c') + (c'-c)) * x) <=(abs y * \<delta>A + abs (y*A'-c') + \<delta>c) * r"     
  1709     by (simp)
  1710   show ?thesis 
  1711     apply (rule_tac le_add_right_mono[of _ _ "abs((y * (A - A') + (y * A' - c') + (c'-c)) * x)"])
  1712     apply (simp_all add: 5 14[simplified abs_of_ge_0[of y, simplified prems]])
  1713     done
  1714 qed
  1715 
  1716 lemma le_ge_imp_abs_diff_1:
  1717   assumes
  1718   "A1 <= (A::'a::lordered_ring)"
  1719   "A <= A2" 
  1720   shows "abs (A-A1) <= A2-A1"
  1721 proof -
  1722   have "0 <= A - A1"    
  1723   proof -
  1724     have 1: "A - A1 = A + (- A1)" by simp
  1725     show ?thesis by (simp only: 1 add_right_mono[of A1 A "-A1", simplified, simplified prems])
  1726   qed
  1727   then have "abs (A-A1) = A-A1" by (rule abs_of_ge_0)
  1728   with prems show "abs (A-A1) <= (A2-A1)" by simp
  1729 qed
  1730 
  1731 lemma mult_le_prts:
  1732   assumes
  1733   "a1 <= (a::'a::lordered_ring)"
  1734   "a <= a2"
  1735   "b1 <= b"
  1736   "b <= b2"
  1737   shows
  1738   "a * b <= pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
  1739 proof - 
  1740   have "a * b = (pprt a + nprt a) * (pprt b + nprt b)" 
  1741     apply (subst prts[symmetric])+
  1742     apply simp
  1743     done
  1744   then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
  1745     by (simp add: ring_eq_simps)
  1746   moreover have "pprt a * pprt b <= pprt a2 * pprt b2"
  1747     by (simp_all add: prems mult_mono)
  1748   moreover have "pprt a * nprt b <= pprt a1 * nprt b2"
  1749   proof -
  1750     have "pprt a * nprt b <= pprt a * nprt b2"
  1751       by (simp add: mult_left_mono prems)
  1752     moreover have "pprt a * nprt b2 <= pprt a1 * nprt b2"
  1753       by (simp add: mult_right_mono_neg prems)
  1754     ultimately show ?thesis
  1755       by simp
  1756   qed
  1757   moreover have "nprt a * pprt b <= nprt a2 * pprt b1"
  1758   proof - 
  1759     have "nprt a * pprt b <= nprt a2 * pprt b"
  1760       by (simp add: mult_right_mono prems)
  1761     moreover have "nprt a2 * pprt b <= nprt a2 * pprt b1"
  1762       by (simp add: mult_left_mono_neg prems)
  1763     ultimately show ?thesis
  1764       by simp
  1765   qed
  1766   moreover have "nprt a * nprt b <= nprt a1 * nprt b1"
  1767   proof -
  1768     have "nprt a * nprt b <= nprt a * nprt b1"
  1769       by (simp add: mult_left_mono_neg prems)
  1770     moreover have "nprt a * nprt b1 <= nprt a1 * nprt b1"
  1771       by (simp add: mult_right_mono_neg prems)
  1772     ultimately show ?thesis
  1773       by simp
  1774   qed
  1775   ultimately show ?thesis
  1776     by - (rule add_mono | simp)+
  1777 qed
  1778     
  1779 lemma mult_le_dual_prts: 
  1780   assumes
  1781   "A * x \<le> (b::'a::lordered_ring)"
  1782   "0 \<le> y"
  1783   "A1 \<le> A"
  1784   "A \<le> A2"
  1785   "c1 \<le> c"
  1786   "c \<le> c2"
  1787   "r1 \<le> x"
  1788   "x \<le> r2"
  1789   shows
  1790   "c * x \<le> y * b + (let s1 = c1 - y * A2; s2 = c2 - y * A1 in pprt s2 * pprt r2 + pprt s1 * nprt r2 + nprt s2 * pprt r1 + nprt s1 * nprt r1)"
  1791   (is "_ <= _ + ?C")
  1792 proof -
  1793   from prems have "y * (A * x) <= y * b" by (simp add: mult_left_mono) 
  1794   moreover have "y * (A * x) = c * x + (y * A - c) * x" by (simp add: ring_eq_simps)  
  1795   ultimately have "c * x + (y * A - c) * x <= y * b" by simp
  1796   then have "c * x <= y * b - (y * A - c) * x" by (simp add: le_diff_eq)
  1797   then have cx: "c * x <= y * b + (c - y * A) * x" by (simp add: ring_eq_simps)
  1798   have s2: "c - y * A <= c2 - y * A1"
  1799     by (simp add: diff_def prems add_mono mult_left_mono)
  1800   have s1: "c1 - y * A2 <= c - y * A"
  1801     by (simp add: diff_def prems add_mono mult_left_mono)
  1802   have prts: "(c - y * A) * x <= ?C"
  1803     apply (simp add: Let_def)
  1804     apply (rule mult_le_prts)
  1805     apply (simp_all add: prems s1 s2)
  1806     done
  1807   then have "y * b + (c - y * A) * x <= y * b + ?C"
  1808     by simp
  1809   with cx show ?thesis
  1810     by(simp only:)
  1811 qed
  1812 
  1813 ML {*
  1814 val left_distrib = thm "left_distrib";
  1815 val right_distrib = thm "right_distrib";
  1816 val mult_commute = thm "mult_commute";
  1817 val distrib = thm "distrib";
  1818 val zero_neq_one = thm "zero_neq_one";
  1819 val no_zero_divisors = thm "no_zero_divisors";
  1820 val left_inverse = thm "left_inverse";
  1821 val divide_inverse = thm "divide_inverse";
  1822 val mult_zero_left = thm "mult_zero_left";
  1823 val mult_zero_right = thm "mult_zero_right";
  1824 val field_mult_eq_0_iff = thm "field_mult_eq_0_iff";
  1825 val inverse_zero = thm "inverse_zero";
  1826 val ring_distrib = thms "ring_distrib";
  1827 val combine_common_factor = thm "combine_common_factor";
  1828 val minus_mult_left = thm "minus_mult_left";
  1829 val minus_mult_right = thm "minus_mult_right";
  1830 val minus_mult_minus = thm "minus_mult_minus";
  1831 val minus_mult_commute = thm "minus_mult_commute";
  1832 val right_diff_distrib = thm "right_diff_distrib";
  1833 val left_diff_distrib = thm "left_diff_distrib";
  1834 val mult_left_mono = thm "mult_left_mono";
  1835 val mult_right_mono = thm "mult_right_mono";
  1836 val mult_strict_left_mono = thm "mult_strict_left_mono";
  1837 val mult_strict_right_mono = thm "mult_strict_right_mono";
  1838 val mult_mono = thm "mult_mono";
  1839 val mult_strict_mono = thm "mult_strict_mono";
  1840 val abs_if = thm "abs_if";
  1841 val zero_less_one = thm "zero_less_one";
  1842 val eq_add_iff1 = thm "eq_add_iff1";
  1843 val eq_add_iff2 = thm "eq_add_iff2";
  1844 val less_add_iff1 = thm "less_add_iff1";
  1845 val less_add_iff2 = thm "less_add_iff2";
  1846 val le_add_iff1 = thm "le_add_iff1";
  1847 val le_add_iff2 = thm "le_add_iff2";
  1848 val mult_left_le_imp_le = thm "mult_left_le_imp_le";
  1849 val mult_right_le_imp_le = thm "mult_right_le_imp_le";
  1850 val mult_left_less_imp_less = thm "mult_left_less_imp_less";
  1851 val mult_right_less_imp_less = thm "mult_right_less_imp_less";
  1852 val mult_strict_left_mono_neg = thm "mult_strict_left_mono_neg";
  1853 val mult_left_mono_neg = thm "mult_left_mono_neg";
  1854 val mult_strict_right_mono_neg = thm "mult_strict_right_mono_neg";
  1855 val mult_right_mono_neg = thm "mult_right_mono_neg";
  1856 val mult_pos = thm "mult_pos";
  1857 val mult_pos_le = thm "mult_pos_le";
  1858 val mult_pos_neg = thm "mult_pos_neg";
  1859 val mult_pos_neg_le = thm "mult_pos_neg_le";
  1860 val mult_pos_neg2 = thm "mult_pos_neg2";
  1861 val mult_pos_neg2_le = thm "mult_pos_neg2_le";
  1862 val mult_neg = thm "mult_neg";
  1863 val mult_neg_le = thm "mult_neg_le";
  1864 val zero_less_mult_pos = thm "zero_less_mult_pos";
  1865 val zero_less_mult_pos2 = thm "zero_less_mult_pos2";
  1866 val zero_less_mult_iff = thm "zero_less_mult_iff";
  1867 val mult_eq_0_iff = thm "mult_eq_0_iff";
  1868 val zero_le_mult_iff = thm "zero_le_mult_iff";
  1869 val mult_less_0_iff = thm "mult_less_0_iff";
  1870 val mult_le_0_iff = thm "mult_le_0_iff";
  1871 val split_mult_pos_le = thm "split_mult_pos_le";
  1872 val split_mult_neg_le = thm "split_mult_neg_le";
  1873 val zero_le_square = thm "zero_le_square";
  1874 val zero_le_one = thm "zero_le_one";
  1875 val not_one_le_zero = thm "not_one_le_zero";
  1876 val not_one_less_zero = thm "not_one_less_zero";
  1877 val mult_left_mono_neg = thm "mult_left_mono_neg";
  1878 val mult_right_mono_neg = thm "mult_right_mono_neg";
  1879 val mult_strict_mono = thm "mult_strict_mono";
  1880 val mult_strict_mono' = thm "mult_strict_mono'";
  1881 val mult_mono = thm "mult_mono";
  1882 val less_1_mult = thm "less_1_mult";
  1883 val mult_less_cancel_right_disj = thm "mult_less_cancel_right_disj";
  1884 val mult_less_cancel_left_disj = thm "mult_less_cancel_left_disj";
  1885 val mult_less_cancel_right = thm "mult_less_cancel_right";
  1886 val mult_less_cancel_left = thm "mult_less_cancel_left";
  1887 val mult_le_cancel_right = thm "mult_le_cancel_right";
  1888 val mult_le_cancel_left = thm "mult_le_cancel_left";
  1889 val mult_less_imp_less_left = thm "mult_less_imp_less_left";
  1890 val mult_less_imp_less_right = thm "mult_less_imp_less_right";
  1891 val mult_cancel_right = thm "mult_cancel_right";
  1892 val mult_cancel_left = thm "mult_cancel_left";
  1893 val ring_eq_simps = thms "ring_eq_simps";
  1894 val right_inverse = thm "right_inverse";
  1895 val right_inverse_eq = thm "right_inverse_eq";
  1896 val nonzero_inverse_eq_divide = thm "nonzero_inverse_eq_divide";
  1897 val divide_self = thm "divide_self";
  1898 val divide_zero = thm "divide_zero";
  1899 val divide_zero_left = thm "divide_zero_left";
  1900 val inverse_eq_divide = thm "inverse_eq_divide";
  1901 val add_divide_distrib = thm "add_divide_distrib";
  1902 val field_mult_eq_0_iff = thm "field_mult_eq_0_iff";
  1903 val field_mult_cancel_right_lemma = thm "field_mult_cancel_right_lemma";
  1904 val field_mult_cancel_right = thm "field_mult_cancel_right";
  1905 val field_mult_cancel_left = thm "field_mult_cancel_left";
  1906 val nonzero_imp_inverse_nonzero = thm "nonzero_imp_inverse_nonzero";
  1907 val inverse_zero_imp_zero = thm "inverse_zero_imp_zero";
  1908 val inverse_nonzero_imp_nonzero = thm "inverse_nonzero_imp_nonzero";
  1909 val inverse_nonzero_iff_nonzero = thm "inverse_nonzero_iff_nonzero";
  1910 val nonzero_inverse_minus_eq = thm "nonzero_inverse_minus_eq";
  1911 val inverse_minus_eq = thm "inverse_minus_eq";
  1912 val nonzero_inverse_eq_imp_eq = thm "nonzero_inverse_eq_imp_eq";
  1913 val inverse_eq_imp_eq = thm "inverse_eq_imp_eq";
  1914 val inverse_eq_iff_eq = thm "inverse_eq_iff_eq";
  1915 val nonzero_inverse_inverse_eq = thm "nonzero_inverse_inverse_eq";
  1916 val inverse_inverse_eq = thm "inverse_inverse_eq";
  1917 val inverse_1 = thm "inverse_1";
  1918 val nonzero_inverse_mult_distrib = thm "nonzero_inverse_mult_distrib";
  1919 val inverse_mult_distrib = thm "inverse_mult_distrib";
  1920 val inverse_add = thm "inverse_add";
  1921 val inverse_divide = thm "inverse_divide";
  1922 val nonzero_mult_divide_cancel_left = thm "nonzero_mult_divide_cancel_left";
  1923 val mult_divide_cancel_left = thm "mult_divide_cancel_left";
  1924 val nonzero_mult_divide_cancel_right = thm "nonzero_mult_divide_cancel_right";
  1925 val mult_divide_cancel_right = thm "mult_divide_cancel_right";
  1926 val mult_divide_cancel_eq_if = thm "mult_divide_cancel_eq_if";
  1927 val divide_1 = thm "divide_1";
  1928 val times_divide_eq_right = thm "times_divide_eq_right";
  1929 val times_divide_eq_left = thm "times_divide_eq_left";
  1930 val divide_divide_eq_right = thm "divide_divide_eq_right";
  1931 val divide_divide_eq_left = thm "divide_divide_eq_left";
  1932 val nonzero_minus_divide_left = thm "nonzero_minus_divide_left";
  1933 val nonzero_minus_divide_right = thm "nonzero_minus_divide_right";
  1934 val nonzero_minus_divide_divide = thm "nonzero_minus_divide_divide";
  1935 val minus_divide_left = thm "minus_divide_left";
  1936 val minus_divide_right = thm "minus_divide_right";
  1937 val minus_divide_divide = thm "minus_divide_divide";
  1938 val diff_divide_distrib = thm "diff_divide_distrib";
  1939 val positive_imp_inverse_positive = thm "positive_imp_inverse_positive";
  1940 val negative_imp_inverse_negative = thm "negative_imp_inverse_negative";
  1941 val inverse_le_imp_le = thm "inverse_le_imp_le";
  1942 val inverse_positive_imp_positive = thm "inverse_positive_imp_positive";
  1943 val inverse_positive_iff_positive = thm "inverse_positive_iff_positive";
  1944 val inverse_negative_imp_negative = thm "inverse_negative_imp_negative";
  1945 val inverse_negative_iff_negative = thm "inverse_negative_iff_negative";
  1946 val inverse_nonnegative_iff_nonnegative = thm "inverse_nonnegative_iff_nonnegative";
  1947 val inverse_nonpositive_iff_nonpositive = thm "inverse_nonpositive_iff_nonpositive";
  1948 val less_imp_inverse_less = thm "less_imp_inverse_less";
  1949 val inverse_less_imp_less = thm "inverse_less_imp_less";
  1950 val inverse_less_iff_less = thm "inverse_less_iff_less";
  1951 val le_imp_inverse_le = thm "le_imp_inverse_le";
  1952 val inverse_le_iff_le = thm "inverse_le_iff_le";
  1953 val inverse_le_imp_le_neg = thm "inverse_le_imp_le_neg";
  1954 val less_imp_inverse_less_neg = thm "less_imp_inverse_less_neg";
  1955 val inverse_less_imp_less_neg = thm "inverse_less_imp_less_neg";
  1956 val inverse_less_iff_less_neg = thm "inverse_less_iff_less_neg";
  1957 val le_imp_inverse_le_neg = thm "le_imp_inverse_le_neg";
  1958 val inverse_le_iff_le_neg = thm "inverse_le_iff_le_neg";
  1959 val one_less_inverse_iff = thm "one_less_inverse_iff";
  1960 val inverse_eq_1_iff = thm "inverse_eq_1_iff";
  1961 val one_le_inverse_iff = thm "one_le_inverse_iff";
  1962 val inverse_less_1_iff = thm "inverse_less_1_iff";
  1963 val inverse_le_1_iff = thm "inverse_le_1_iff";
  1964 val zero_less_divide_iff = thm "zero_less_divide_iff";
  1965 val divide_less_0_iff = thm "divide_less_0_iff";
  1966 val zero_le_divide_iff = thm "zero_le_divide_iff";
  1967 val divide_le_0_iff = thm "divide_le_0_iff";
  1968 val divide_eq_0_iff = thm "divide_eq_0_iff";
  1969 val pos_le_divide_eq = thm "pos_le_divide_eq";
  1970 val neg_le_divide_eq = thm "neg_le_divide_eq";
  1971 val le_divide_eq = thm "le_divide_eq";
  1972 val pos_divide_le_eq = thm "pos_divide_le_eq";
  1973 val neg_divide_le_eq = thm "neg_divide_le_eq";
  1974 val divide_le_eq = thm "divide_le_eq";
  1975 val pos_less_divide_eq = thm "pos_less_divide_eq";
  1976 val neg_less_divide_eq = thm "neg_less_divide_eq";
  1977 val less_divide_eq = thm "less_divide_eq";
  1978 val pos_divide_less_eq = thm "pos_divide_less_eq";
  1979 val neg_divide_less_eq = thm "neg_divide_less_eq";
  1980 val divide_less_eq = thm "divide_less_eq";
  1981 val nonzero_eq_divide_eq = thm "nonzero_eq_divide_eq";
  1982 val eq_divide_eq = thm "eq_divide_eq";
  1983 val nonzero_divide_eq_eq = thm "nonzero_divide_eq_eq";
  1984 val divide_eq_eq = thm "divide_eq_eq";
  1985 val divide_cancel_right = thm "divide_cancel_right";
  1986 val divide_cancel_left = thm "divide_cancel_left";
  1987 val divide_eq_1_iff = thm "divide_eq_1_iff";
  1988 val one_eq_divide_iff = thm "one_eq_divide_iff";
  1989 val zero_eq_1_divide_iff = thm "zero_eq_1_divide_iff";
  1990 val one_divide_eq_0_iff = thm "one_divide_eq_0_iff";
  1991 val divide_strict_right_mono = thm "divide_strict_right_mono";
  1992 val divide_right_mono = thm "divide_right_mono";
  1993 val divide_strict_left_mono = thm "divide_strict_left_mono";
  1994 val divide_left_mono = thm "divide_left_mono";
  1995 val divide_strict_left_mono_neg = thm "divide_strict_left_mono_neg";
  1996 val divide_strict_right_mono_neg = thm "divide_strict_right_mono_neg";
  1997 val less_add_one = thm "less_add_one";
  1998 val zero_less_two = thm "zero_less_two";
  1999 val less_half_sum = thm "less_half_sum";
  2000 val gt_half_sum = thm "gt_half_sum";
  2001 val dense = thm "dense";
  2002 val abs_one = thm "abs_one";
  2003 val abs_le_mult = thm "abs_le_mult";
  2004 val abs_eq_mult = thm "abs_eq_mult";
  2005 val abs_mult = thm "abs_mult";
  2006 val abs_mult_self = thm "abs_mult_self";
  2007 val nonzero_abs_inverse = thm "nonzero_abs_inverse";
  2008 val abs_inverse = thm "abs_inverse";
  2009 val nonzero_abs_divide = thm "nonzero_abs_divide";
  2010 val abs_divide = thm "abs_divide";
  2011 val abs_mult_less = thm "abs_mult_less";
  2012 val eq_minus_self_iff = thm "eq_minus_self_iff";
  2013 val less_minus_self_iff = thm "less_minus_self_iff";
  2014 val abs_less_iff = thm "abs_less_iff";
  2015 *}
  2016 
  2017 end