src/HOL/Ring_and_Field.thy
author paulson
Fri Dec 05 18:10:59 2003 +0100 (2003-12-05)
changeset 14277 ad66687ece6e
parent 14272 5efbb548107d
child 14284 f1abe67c448a
permissions -rw-r--r--
more field division lemmas transferred from Real to Ring_and_Field
     1 (*  Title:   HOL/Ring_and_Field.thy
     2     ID:      $Id$
     3     Author:  Gertrud Bauer and Markus Wenzel, TU Muenchen
     4              Lawrence C Paulson, University of Cambridge
     5     License: GPL (GNU GENERAL PUBLIC LICENSE)
     6 *)
     7 
     8 header {*
     9   \title{Ring and field structures}
    10   \author{Gertrud Bauer and Markus Wenzel}
    11 *}
    12 
    13 theory Ring_and_Field = Inductive:
    14 
    15 text{*Lemmas and extension to semirings by L. C. Paulson*}
    16 
    17 subsection {* Abstract algebraic structures *}
    18 
    19 axclass semiring \<subseteq> zero, one, plus, times
    20   add_assoc: "(a + b) + c = a + (b + c)"
    21   add_commute: "a + b = b + a"
    22   left_zero [simp]: "0 + a = a"
    23 
    24   mult_assoc: "(a * b) * c = a * (b * c)"
    25   mult_commute: "a * b = b * a"
    26   mult_1 [simp]: "1 * a = a"
    27 
    28   left_distrib: "(a + b) * c = a * c + b * c"
    29   zero_neq_one [simp]: "0 \<noteq> 1"
    30 
    31 axclass ring \<subseteq> semiring, minus
    32   left_minus [simp]: "- a + a = 0"
    33   diff_minus: "a - b = a + (-b)"
    34 
    35 axclass ordered_semiring \<subseteq> semiring, linorder
    36   add_left_mono: "a \<le> b ==> c + a \<le> c + b"
    37   mult_strict_left_mono: "a < b ==> 0 < c ==> c * a < c * b"
    38 
    39 axclass ordered_ring \<subseteq> ordered_semiring, ring
    40   abs_if: "\<bar>a\<bar> = (if a < 0 then -a else a)"
    41 
    42 axclass field \<subseteq> ring, inverse
    43   left_inverse [simp]: "a \<noteq> 0 ==> inverse a * a = 1"
    44   divide_inverse:      "b \<noteq> 0 ==> a / b = a * inverse b"
    45 
    46 axclass ordered_field \<subseteq> ordered_ring, field
    47 
    48 axclass division_by_zero \<subseteq> zero, inverse
    49   inverse_zero [simp]: "inverse 0 = 0"
    50   divide_zero [simp]: "a / 0 = 0"
    51 
    52 
    53 subsection {* Derived Rules for Addition *}
    54 
    55 lemma right_zero [simp]: "a + 0 = (a::'a::semiring)"
    56 proof -
    57   have "a + 0 = 0 + a" by (simp only: add_commute)
    58   also have "... = a" by simp
    59   finally show ?thesis .
    60 qed
    61 
    62 lemma add_left_commute: "a + (b + c) = b + (a + (c::'a::semiring))"
    63   by (rule mk_left_commute [of "op +", OF add_assoc add_commute])
    64 
    65 theorems add_ac = add_assoc add_commute add_left_commute
    66 
    67 lemma right_minus [simp]: "a + -(a::'a::ring) = 0"
    68 proof -
    69   have "a + -a = -a + a" by (simp add: add_ac)
    70   also have "... = 0" by simp
    71   finally show ?thesis .
    72 qed
    73 
    74 lemma right_minus_eq: "(a - b = 0) = (a = (b::'a::ring))"
    75 proof
    76   have "a = a - b + b" by (simp add: diff_minus add_ac)
    77   also assume "a - b = 0"
    78   finally show "a = b" by simp
    79 next
    80   assume "a = b"
    81   thus "a - b = 0" by (simp add: diff_minus)
    82 qed
    83 
    84 lemma add_left_cancel [simp]:
    85      "(a + b = a + c) = (b = (c::'a::ring))"
    86 proof
    87   assume eq: "a + b = a + c"
    88   hence "(-a + a) + b = (-a + a) + c"
    89     by (simp only: eq add_assoc)
    90   thus "b = c" by simp
    91 next
    92   assume eq: "b = c"
    93   thus "a + b = a + c" by simp
    94 qed
    95 
    96 lemma add_right_cancel [simp]:
    97      "(b + a = c + a) = (b = (c::'a::ring))"
    98   by (simp add: add_commute)
    99 
   100 lemma minus_minus [simp]: "- (- (a::'a::ring)) = a"
   101   proof (rule add_left_cancel [of "-a", THEN iffD1])
   102     show "(-a + -(-a) = -a + a)"
   103     by simp
   104   qed
   105 
   106 lemma equals_zero_I: "a+b = 0 ==> -a = (b::'a::ring)"
   107 apply (rule right_minus_eq [THEN iffD1, symmetric])
   108 apply (simp add: diff_minus add_commute) 
   109 done
   110 
   111 lemma minus_zero [simp]: "- 0 = (0::'a::ring)"
   112 by (simp add: equals_zero_I)
   113 
   114 lemma diff_self [simp]: "a - (a::'a::ring) = 0"
   115   by (simp add: diff_minus)
   116 
   117 lemma diff_0 [simp]: "(0::'a::ring) - a = -a"
   118 by (simp add: diff_minus)
   119 
   120 lemma diff_0_right [simp]: "a - (0::'a::ring) = a" 
   121 by (simp add: diff_minus)
   122 
   123 lemma neg_equal_iff_equal [simp]: "(-a = -b) = (a = (b::'a::ring))" 
   124   proof 
   125     assume "- a = - b"
   126     hence "- (- a) = - (- b)"
   127       by simp
   128     thus "a=b" by simp
   129   next
   130     assume "a=b"
   131     thus "-a = -b" by simp
   132   qed
   133 
   134 lemma neg_equal_0_iff_equal [simp]: "(-a = 0) = (a = (0::'a::ring))"
   135 by (subst neg_equal_iff_equal [symmetric], simp)
   136 
   137 lemma neg_0_equal_iff_equal [simp]: "(0 = -a) = (0 = (a::'a::ring))"
   138 by (subst neg_equal_iff_equal [symmetric], simp)
   139 
   140 text{*The next two equations can make the simplifier loop!*}
   141 
   142 lemma equation_minus_iff: "(a = - b) = (b = - (a::'a::ring))"
   143   proof -
   144   have "(- (-a) = - b) = (- a = b)" by (rule neg_equal_iff_equal)
   145   thus ?thesis by (simp add: eq_commute)
   146   qed
   147 
   148 lemma minus_equation_iff: "(- a = b) = (- (b::'a::ring) = a)"
   149   proof -
   150   have "(- a = - (-b)) = (a = -b)" by (rule neg_equal_iff_equal)
   151   thus ?thesis by (simp add: eq_commute)
   152   qed
   153 
   154 
   155 subsection {* Derived rules for multiplication *}
   156 
   157 lemma mult_1_right [simp]: "a * (1::'a::semiring) = a"
   158 proof -
   159   have "a * 1 = 1 * a" by (simp add: mult_commute)
   160   also have "... = a" by simp
   161   finally show ?thesis .
   162 qed
   163 
   164 lemma mult_left_commute: "a * (b * c) = b * (a * (c::'a::semiring))"
   165   by (rule mk_left_commute [of "op *", OF mult_assoc mult_commute])
   166 
   167 theorems mult_ac = mult_assoc mult_commute mult_left_commute
   168 
   169 lemma right_inverse [simp]:
   170       assumes not0: "a \<noteq> 0" shows "a * inverse (a::'a::field) = 1"
   171 proof -
   172   have "a * inverse a = inverse a * a" by (simp add: mult_ac)
   173   also have "... = 1" using not0 by simp
   174   finally show ?thesis .
   175 qed
   176 
   177 lemma right_inverse_eq: "b \<noteq> 0 ==> (a / b = 1) = (a = (b::'a::field))"
   178 proof
   179   assume neq: "b \<noteq> 0"
   180   {
   181     hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac)
   182     also assume "a / b = 1"
   183     finally show "a = b" by simp
   184   next
   185     assume "a = b"
   186     with neq show "a / b = 1" by (simp add: divide_inverse)
   187   }
   188 qed
   189 
   190 lemma nonzero_inverse_eq_divide: "a \<noteq> 0 ==> inverse (a::'a::field) = 1/a"
   191 by (simp add: divide_inverse)
   192 
   193 lemma divide_self [simp]: "a \<noteq> 0 ==> a / (a::'a::field) = 1"
   194   by (simp add: divide_inverse)
   195 
   196 lemma mult_left_zero [simp]: "0 * a = (0::'a::ring)"
   197 proof -
   198   have "0*a + 0*a = 0*a + 0"
   199     by (simp add: left_distrib [symmetric])
   200   thus ?thesis by (simp only: add_left_cancel)
   201 qed
   202 
   203 lemma mult_right_zero [simp]: "a * 0 = (0::'a::ring)"
   204   by (simp add: mult_commute)
   205 
   206 
   207 subsection {* Distribution rules *}
   208 
   209 lemma right_distrib: "a * (b + c) = a * b + a * (c::'a::semiring)"
   210 proof -
   211   have "a * (b + c) = (b + c) * a" by (simp add: mult_ac)
   212   also have "... = b * a + c * a" by (simp only: left_distrib)
   213   also have "... = a * b + a * c" by (simp add: mult_ac)
   214   finally show ?thesis .
   215 qed
   216 
   217 theorems ring_distrib = right_distrib left_distrib
   218 
   219 text{*For the @{text combine_numerals} simproc*}
   220 lemma combine_common_factor: "a*e + (b*e + c) = (a+b)*e + (c::'a::semiring)"
   221 by (simp add: left_distrib add_ac)
   222 
   223 lemma minus_add_distrib [simp]: "- (a + b) = -a + -(b::'a::ring)"
   224 apply (rule equals_zero_I)
   225 apply (simp add: add_ac) 
   226 done
   227 
   228 lemma minus_mult_left: "- (a * b) = (-a) * (b::'a::ring)"
   229 apply (rule equals_zero_I)
   230 apply (simp add: left_distrib [symmetric]) 
   231 done
   232 
   233 lemma minus_mult_right: "- (a * b) = a * -(b::'a::ring)"
   234 apply (rule equals_zero_I)
   235 apply (simp add: right_distrib [symmetric]) 
   236 done
   237 
   238 lemma minus_mult_minus [simp]: "(- a) * (- b) = a * (b::'a::ring)"
   239   by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric])
   240 
   241 lemma right_diff_distrib: "a * (b - c) = a * b - a * (c::'a::ring)"
   242 by (simp add: right_distrib diff_minus 
   243               minus_mult_left [symmetric] minus_mult_right [symmetric]) 
   244 
   245 lemma left_diff_distrib: "(a - b) * c = a * c - b * (c::'a::ring)"
   246 by (simp add: mult_commute [of _ c] right_diff_distrib) 
   247 
   248 lemma minus_diff_eq [simp]: "- (a - b) = b - (a::'a::ring)"
   249 by (simp add: diff_minus add_commute) 
   250 
   251 
   252 subsection {* Ordering Rules for Addition *}
   253 
   254 lemma add_right_mono: "a \<le> (b::'a::ordered_semiring) ==> a + c \<le> b + c"
   255 by (simp add: add_commute [of _ c] add_left_mono)
   256 
   257 text {* non-strict, in both arguments *}
   258 lemma add_mono: "[|a \<le> b;  c \<le> d|] ==> a + c \<le> b + (d::'a::ordered_semiring)"
   259   apply (erule add_right_mono [THEN order_trans])
   260   apply (simp add: add_commute add_left_mono)
   261   done
   262 
   263 lemma add_strict_left_mono:
   264      "a < b ==> c + a < c + (b::'a::ordered_ring)"
   265  by (simp add: order_less_le add_left_mono) 
   266 
   267 lemma add_strict_right_mono:
   268      "a < b ==> a + c < b + (c::'a::ordered_ring)"
   269  by (simp add: add_commute [of _ c] add_strict_left_mono)
   270 
   271 text{*Strict monotonicity in both arguments*}
   272 lemma add_strict_mono: "[|a<b; c<d|] ==> a + c < b + (d::'a::ordered_ring)"
   273 apply (erule add_strict_right_mono [THEN order_less_trans])
   274 apply (erule add_strict_left_mono)
   275 done
   276 
   277 lemma add_less_imp_less_left:
   278       assumes less: "c + a < c + b"  shows "a < (b::'a::ordered_ring)"
   279   proof -
   280   have "-c + (c + a) < -c + (c + b)"
   281     by (rule add_strict_left_mono [OF less])
   282   thus "a < b" by (simp add: add_assoc [symmetric])
   283   qed
   284 
   285 lemma add_less_imp_less_right:
   286       "a + c < b + c ==> a < (b::'a::ordered_ring)"
   287 apply (rule add_less_imp_less_left [of c])
   288 apply (simp add: add_commute)  
   289 done
   290 
   291 lemma add_less_cancel_left [simp]:
   292     "(c+a < c+b) = (a < (b::'a::ordered_ring))"
   293 by (blast intro: add_less_imp_less_left add_strict_left_mono) 
   294 
   295 lemma add_less_cancel_right [simp]:
   296     "(a+c < b+c) = (a < (b::'a::ordered_ring))"
   297 by (blast intro: add_less_imp_less_right add_strict_right_mono)
   298 
   299 lemma add_le_cancel_left [simp]:
   300     "(c+a \<le> c+b) = (a \<le> (b::'a::ordered_ring))"
   301 by (simp add: linorder_not_less [symmetric]) 
   302 
   303 lemma add_le_cancel_right [simp]:
   304     "(a+c \<le> b+c) = (a \<le> (b::'a::ordered_ring))"
   305 by (simp add: linorder_not_less [symmetric]) 
   306 
   307 lemma add_le_imp_le_left:
   308       "c + a \<le> c + b ==> a \<le> (b::'a::ordered_ring)"
   309 by simp
   310 
   311 lemma add_le_imp_le_right:
   312       "a + c \<le> b + c ==> a \<le> (b::'a::ordered_ring)"
   313 by simp
   314 
   315 
   316 subsection {* Ordering Rules for Unary Minus *}
   317 
   318 lemma le_imp_neg_le:
   319       assumes "a \<le> (b::'a::ordered_ring)" shows "-b \<le> -a"
   320   proof -
   321   have "-a+a \<le> -a+b"
   322     by (rule add_left_mono) 
   323   hence "0 \<le> -a+b"
   324     by simp
   325   hence "0 + (-b) \<le> (-a + b) + (-b)"
   326     by (rule add_right_mono) 
   327   thus ?thesis
   328     by (simp add: add_assoc)
   329   qed
   330 
   331 lemma neg_le_iff_le [simp]: "(-b \<le> -a) = (a \<le> (b::'a::ordered_ring))"
   332   proof 
   333     assume "- b \<le> - a"
   334     hence "- (- a) \<le> - (- b)"
   335       by (rule le_imp_neg_le)
   336     thus "a\<le>b" by simp
   337   next
   338     assume "a\<le>b"
   339     thus "-b \<le> -a" by (rule le_imp_neg_le)
   340   qed
   341 
   342 lemma neg_le_0_iff_le [simp]: "(-a \<le> 0) = (0 \<le> (a::'a::ordered_ring))"
   343 by (subst neg_le_iff_le [symmetric], simp)
   344 
   345 lemma neg_0_le_iff_le [simp]: "(0 \<le> -a) = (a \<le> (0::'a::ordered_ring))"
   346 by (subst neg_le_iff_le [symmetric], simp)
   347 
   348 lemma neg_less_iff_less [simp]: "(-b < -a) = (a < (b::'a::ordered_ring))"
   349 by (force simp add: order_less_le) 
   350 
   351 lemma neg_less_0_iff_less [simp]: "(-a < 0) = (0 < (a::'a::ordered_ring))"
   352 by (subst neg_less_iff_less [symmetric], simp)
   353 
   354 lemma neg_0_less_iff_less [simp]: "(0 < -a) = (a < (0::'a::ordered_ring))"
   355 by (subst neg_less_iff_less [symmetric], simp)
   356 
   357 text{*The next several equations can make the simplifier loop!*}
   358 
   359 lemma less_minus_iff: "(a < - b) = (b < - (a::'a::ordered_ring))"
   360   proof -
   361   have "(- (-a) < - b) = (b < - a)" by (rule neg_less_iff_less)
   362   thus ?thesis by simp
   363   qed
   364 
   365 lemma minus_less_iff: "(- a < b) = (- b < (a::'a::ordered_ring))"
   366   proof -
   367   have "(- a < - (-b)) = (- b < a)" by (rule neg_less_iff_less)
   368   thus ?thesis by simp
   369   qed
   370 
   371 lemma le_minus_iff: "(a \<le> - b) = (b \<le> - (a::'a::ordered_ring))"
   372 apply (simp add: linorder_not_less [symmetric])
   373 apply (rule minus_less_iff) 
   374 done
   375 
   376 lemma minus_le_iff: "(- a \<le> b) = (- b \<le> (a::'a::ordered_ring))"
   377 apply (simp add: linorder_not_less [symmetric])
   378 apply (rule less_minus_iff) 
   379 done
   380 
   381 
   382 subsection{*Subtraction Laws*}
   383 
   384 lemma add_diff_eq: "a + (b - c) = (a + b) - (c::'a::ring)"
   385 by (simp add: diff_minus add_ac)
   386 
   387 lemma diff_add_eq: "(a - b) + c = (a + c) - (b::'a::ring)"
   388 by (simp add: diff_minus add_ac)
   389 
   390 lemma diff_eq_eq: "(a-b = c) = (a = c + (b::'a::ring))"
   391 by (auto simp add: diff_minus add_assoc)
   392 
   393 lemma eq_diff_eq: "(a = c-b) = (a + (b::'a::ring) = c)"
   394 by (auto simp add: diff_minus add_assoc)
   395 
   396 lemma diff_diff_eq: "(a - b) - c = a - (b + (c::'a::ring))"
   397 by (simp add: diff_minus add_ac)
   398 
   399 lemma diff_diff_eq2: "a - (b - c) = (a + c) - (b::'a::ring)"
   400 by (simp add: diff_minus add_ac)
   401 
   402 text{*Further subtraction laws for ordered rings*}
   403 
   404 lemma less_iff_diff_less_0: "(a < b) = (a - b < (0::'a::ordered_ring))"
   405 proof -
   406   have  "(a < b) = (a + (- b) < b + (-b))"  
   407     by (simp only: add_less_cancel_right)
   408   also have "... =  (a - b < 0)" by (simp add: diff_minus)
   409   finally show ?thesis .
   410 qed
   411 
   412 lemma diff_less_eq: "(a-b < c) = (a < c + (b::'a::ordered_ring))"
   413 apply (subst less_iff_diff_less_0)
   414 apply (rule less_iff_diff_less_0 [of _ c, THEN ssubst])
   415 apply (simp add: diff_minus add_ac)
   416 done
   417 
   418 lemma less_diff_eq: "(a < c-b) = (a + (b::'a::ordered_ring) < c)"
   419 apply (subst less_iff_diff_less_0)
   420 apply (rule less_iff_diff_less_0 [of _ "c-b", THEN ssubst])
   421 apply (simp add: diff_minus add_ac)
   422 done
   423 
   424 lemma diff_le_eq: "(a-b \<le> c) = (a \<le> c + (b::'a::ordered_ring))"
   425 by (simp add: linorder_not_less [symmetric] less_diff_eq)
   426 
   427 lemma le_diff_eq: "(a \<le> c-b) = (a + (b::'a::ordered_ring) \<le> c)"
   428 by (simp add: linorder_not_less [symmetric] diff_less_eq)
   429 
   430 text{*This list of rewrites simplifies (in)equalities by bringing subtractions
   431   to the top and then moving negative terms to the other side.
   432   Use with @{text add_ac}*}
   433 lemmas compare_rls =
   434        diff_minus [symmetric]
   435        add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
   436        diff_less_eq less_diff_eq diff_le_eq le_diff_eq
   437        diff_eq_eq eq_diff_eq
   438 
   439 
   440 subsection{*Lemmas for the @{text cancel_numerals} simproc*}
   441 
   442 lemma eq_iff_diff_eq_0: "(a = b) = (a-b = (0::'a::ring))"
   443 by (simp add: compare_rls)
   444 
   445 lemma le_iff_diff_le_0: "(a \<le> b) = (a-b \<le> (0::'a::ordered_ring))"
   446 by (simp add: compare_rls)
   447 
   448 lemma eq_add_iff1:
   449      "(a*e + c = b*e + d) = ((a-b)*e + c = (d::'a::ring))"
   450 apply (simp add: diff_minus left_distrib add_ac)
   451 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   452 done
   453 
   454 lemma eq_add_iff2:
   455      "(a*e + c = b*e + d) = (c = (b-a)*e + (d::'a::ring))"
   456 apply (simp add: diff_minus left_distrib add_ac)
   457 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   458 done
   459 
   460 lemma less_add_iff1:
   461      "(a*e + c < b*e + d) = ((a-b)*e + c < (d::'a::ordered_ring))"
   462 apply (simp add: diff_minus left_distrib add_ac)
   463 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   464 done
   465 
   466 lemma less_add_iff2:
   467      "(a*e + c < b*e + d) = (c < (b-a)*e + (d::'a::ordered_ring))"
   468 apply (simp add: diff_minus left_distrib add_ac)
   469 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   470 done
   471 
   472 lemma le_add_iff1:
   473      "(a*e + c \<le> b*e + d) = ((a-b)*e + c \<le> (d::'a::ordered_ring))"
   474 apply (simp add: diff_minus left_distrib add_ac)
   475 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   476 done
   477 
   478 lemma le_add_iff2:
   479      "(a*e + c \<le> b*e + d) = (c \<le> (b-a)*e + (d::'a::ordered_ring))"
   480 apply (simp add: diff_minus left_distrib add_ac)
   481 apply (simp add: compare_rls minus_mult_left [symmetric]) 
   482 done
   483 
   484 
   485 subsection {* Ordering Rules for Multiplication *}
   486 
   487 lemma mult_strict_right_mono:
   488      "[|a < b; 0 < c|] ==> a * c < b * (c::'a::ordered_semiring)"
   489 by (simp add: mult_commute [of _ c] mult_strict_left_mono)
   490 
   491 lemma mult_left_mono:
   492      "[|a \<le> b; 0 \<le> c|] ==> c * a \<le> c * (b::'a::ordered_ring)"
   493   apply (case_tac "c=0", simp)
   494   apply (force simp add: mult_strict_left_mono order_le_less) 
   495   done
   496 
   497 lemma mult_right_mono:
   498      "[|a \<le> b; 0 \<le> c|] ==> a*c \<le> b * (c::'a::ordered_ring)"
   499   by (simp add: mult_left_mono mult_commute [of _ c]) 
   500 
   501 lemma mult_strict_left_mono_neg:
   502      "[|b < a; c < 0|] ==> c * a < c * (b::'a::ordered_ring)"
   503 apply (drule mult_strict_left_mono [of _ _ "-c"])
   504 apply (simp_all add: minus_mult_left [symmetric]) 
   505 done
   506 
   507 lemma mult_strict_right_mono_neg:
   508      "[|b < a; c < 0|] ==> a * c < b * (c::'a::ordered_ring)"
   509 apply (drule mult_strict_right_mono [of _ _ "-c"])
   510 apply (simp_all add: minus_mult_right [symmetric]) 
   511 done
   512 
   513 
   514 subsection{* Products of Signs *}
   515 
   516 lemma mult_pos: "[| (0::'a::ordered_ring) < a; 0 < b |] ==> 0 < a*b"
   517 by (drule mult_strict_left_mono [of 0 b], auto)
   518 
   519 lemma mult_pos_neg: "[| (0::'a::ordered_ring) < a; b < 0 |] ==> a*b < 0"
   520 by (drule mult_strict_left_mono [of b 0], auto)
   521 
   522 lemma mult_neg: "[| a < (0::'a::ordered_ring); b < 0 |] ==> 0 < a*b"
   523 by (drule mult_strict_right_mono_neg, auto)
   524 
   525 lemma zero_less_mult_pos: "[| 0 < a*b; 0 < a|] ==> 0 < (b::'a::ordered_ring)"
   526 apply (case_tac "b\<le>0") 
   527  apply (auto simp add: order_le_less linorder_not_less)
   528 apply (drule_tac mult_pos_neg [of a b]) 
   529  apply (auto dest: order_less_not_sym)
   530 done
   531 
   532 lemma zero_less_mult_iff:
   533      "((0::'a::ordered_ring) < a*b) = (0 < a & 0 < b | a < 0 & b < 0)"
   534 apply (auto simp add: order_le_less linorder_not_less mult_pos mult_neg)
   535 apply (blast dest: zero_less_mult_pos) 
   536 apply (simp add: mult_commute [of a b]) 
   537 apply (blast dest: zero_less_mult_pos) 
   538 done
   539 
   540 text{*A field has no "zero divisors", so this theorem should hold without the
   541       assumption of an ordering.  See @{text field_mult_eq_0_iff} below.*}
   542 lemma mult_eq_0_iff [simp]: "(a*b = (0::'a::ordered_ring)) = (a = 0 | b = 0)"
   543 apply (case_tac "a < 0")
   544 apply (auto simp add: linorder_not_less order_le_less linorder_neq_iff)
   545 apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono)+
   546 done
   547 
   548 lemma zero_le_mult_iff:
   549      "((0::'a::ordered_ring) \<le> a*b) = (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
   550 by (auto simp add: eq_commute [of 0] order_le_less linorder_not_less
   551                    zero_less_mult_iff)
   552 
   553 lemma mult_less_0_iff:
   554      "(a*b < (0::'a::ordered_ring)) = (0 < a & b < 0 | a < 0 & 0 < b)"
   555 apply (insert zero_less_mult_iff [of "-a" b]) 
   556 apply (force simp add: minus_mult_left[symmetric]) 
   557 done
   558 
   559 lemma mult_le_0_iff:
   560      "(a*b \<le> (0::'a::ordered_ring)) = (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
   561 apply (insert zero_le_mult_iff [of "-a" b]) 
   562 apply (force simp add: minus_mult_left[symmetric]) 
   563 done
   564 
   565 lemma zero_le_square: "(0::'a::ordered_ring) \<le> a*a"
   566 by (simp add: zero_le_mult_iff linorder_linear) 
   567 
   568 lemma zero_less_one: "(0::'a::ordered_ring) < 1"
   569 apply (insert zero_le_square [of 1]) 
   570 apply (simp add: order_less_le) 
   571 done
   572 
   573 lemma zero_le_one: "(0::'a::ordered_ring) \<le> 1"
   574   by (rule zero_less_one [THEN order_less_imp_le]) 
   575 
   576 
   577 subsection{*More Monotonicity*}
   578 
   579 lemma mult_left_mono_neg:
   580      "[|b \<le> a; c \<le> 0|] ==> c * a \<le> c * (b::'a::ordered_ring)"
   581 apply (drule mult_left_mono [of _ _ "-c"]) 
   582 apply (simp_all add: minus_mult_left [symmetric]) 
   583 done
   584 
   585 lemma mult_right_mono_neg:
   586      "[|b \<le> a; c \<le> 0|] ==> a * c \<le> b * (c::'a::ordered_ring)"
   587   by (simp add: mult_left_mono_neg mult_commute [of _ c]) 
   588 
   589 text{*Strict monotonicity in both arguments*}
   590 lemma mult_strict_mono:
   591      "[|a<b; c<d; 0<b; 0\<le>c|] ==> a * c < b * (d::'a::ordered_ring)"
   592 apply (case_tac "c=0")
   593  apply (simp add: mult_pos) 
   594 apply (erule mult_strict_right_mono [THEN order_less_trans])
   595  apply (force simp add: order_le_less) 
   596 apply (erule mult_strict_left_mono, assumption)
   597 done
   598 
   599 text{*This weaker variant has more natural premises*}
   600 lemma mult_strict_mono':
   601      "[| a<b; c<d; 0 \<le> a; 0 \<le> c|] ==> a * c < b * (d::'a::ordered_ring)"
   602 apply (rule mult_strict_mono)
   603 apply (blast intro: order_le_less_trans)+
   604 done
   605 
   606 lemma mult_mono:
   607      "[|a \<le> b; c \<le> d; 0 \<le> b; 0 \<le> c|] 
   608       ==> a * c  \<le>  b * (d::'a::ordered_ring)"
   609 apply (erule mult_right_mono [THEN order_trans], assumption)
   610 apply (erule mult_left_mono, assumption)
   611 done
   612 
   613 
   614 subsection{*Cancellation Laws for Relationships With a Common Factor*}
   615 
   616 text{*Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"},
   617    also with the relations @{text "\<le>"} and equality.*}
   618 
   619 lemma mult_less_cancel_right:
   620     "(a*c < b*c) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring)))"
   621 apply (case_tac "c = 0")
   622 apply (auto simp add: linorder_neq_iff mult_strict_right_mono 
   623                       mult_strict_right_mono_neg)
   624 apply (auto simp add: linorder_not_less 
   625                       linorder_not_le [symmetric, of "a*c"]
   626                       linorder_not_le [symmetric, of a])
   627 apply (erule_tac [!] notE)
   628 apply (auto simp add: order_less_imp_le mult_right_mono 
   629                       mult_right_mono_neg)
   630 done
   631 
   632 lemma mult_less_cancel_left:
   633     "(c*a < c*b) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring)))"
   634 by (simp add: mult_commute [of c] mult_less_cancel_right)
   635 
   636 lemma mult_le_cancel_right:
   637      "(a*c \<le> b*c) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring)))"
   638 by (simp add: linorder_not_less [symmetric] mult_less_cancel_right)
   639 
   640 lemma mult_le_cancel_left:
   641      "(c*a \<le> c*b) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring)))"
   642 by (simp add: mult_commute [of c] mult_le_cancel_right)
   643 
   644 lemma mult_less_imp_less_left:
   645     "[|c*a < c*b; 0 < c|] ==> a < (b::'a::ordered_ring)"
   646   by (force elim: order_less_asym simp add: mult_less_cancel_left)
   647 
   648 lemma mult_less_imp_less_right:
   649     "[|a*c < b*c; 0 < c|] ==> a < (b::'a::ordered_ring)"
   650   by (force elim: order_less_asym simp add: mult_less_cancel_right)
   651 
   652 text{*Cancellation of equalities with a common factor*}
   653 lemma mult_cancel_right [simp]:
   654      "(a*c = b*c) = (c = (0::'a::ordered_ring) | a=b)"
   655 apply (cut_tac linorder_less_linear [of 0 c])
   656 apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono
   657              simp add: linorder_neq_iff)
   658 done
   659 
   660 text{*These cancellation theorems require an ordering. Versions are proved
   661       below that work for fields without an ordering.*}
   662 lemma mult_cancel_left [simp]:
   663      "(c*a = c*b) = (c = (0::'a::ordered_ring) | a=b)"
   664 by (simp add: mult_commute [of c] mult_cancel_right)
   665 
   666 
   667 subsection {* Absolute Value *}
   668 
   669 text{*But is it really better than just rewriting with @{text abs_if}?*}
   670 lemma abs_split:
   671      "P(abs(a::'a::ordered_ring)) = ((0 \<le> a --> P a) & (a < 0 --> P(-a)))"
   672 by (force dest: order_less_le_trans simp add: abs_if linorder_not_less)
   673 
   674 lemma abs_zero [simp]: "abs 0 = (0::'a::ordered_ring)"
   675 by (simp add: abs_if)
   676 
   677 lemma abs_mult: "abs (x * y) = abs x * abs (y::'a::ordered_ring)" 
   678 apply (case_tac "x=0 | y=0", force) 
   679 apply (auto elim: order_less_asym
   680             simp add: abs_if mult_less_0_iff linorder_neq_iff
   681                   minus_mult_left [symmetric] minus_mult_right [symmetric])  
   682 done
   683 
   684 lemma abs_eq_0 [simp]: "(abs x = 0) = (x = (0::'a::ordered_ring))"
   685 by (simp add: abs_if)
   686 
   687 lemma zero_less_abs_iff [simp]: "(0 < abs x) = (x ~= (0::'a::ordered_ring))"
   688 by (simp add: abs_if linorder_neq_iff)
   689 
   690 
   691 subsection {* Fields *}
   692 
   693 lemma divide_inverse_zero: "a/b = a * inverse(b::'a::{field,division_by_zero})"
   694 apply (case_tac "b = 0")
   695 apply (simp_all add: divide_inverse)
   696 done
   697 
   698 lemma divide_zero_left [simp]: "0/a = (0::'a::{field,division_by_zero})"
   699 by (simp add: divide_inverse_zero)
   700 
   701 lemma inverse_eq_divide: "inverse (a::'a::{field,division_by_zero}) = 1/a"
   702 by (simp add: divide_inverse_zero)
   703 
   704 text{*Compared with @{text mult_eq_0_iff}, this version removes the requirement
   705       of an ordering.*}
   706 lemma field_mult_eq_0_iff: "(a*b = (0::'a::field)) = (a = 0 | b = 0)"
   707   proof cases
   708     assume "a=0" thus ?thesis by simp
   709   next
   710     assume anz [simp]: "a\<noteq>0"
   711     thus ?thesis
   712     proof auto
   713       assume "a * b = 0"
   714       hence "inverse a * (a * b) = 0" by simp
   715       thus "b = 0"  by (simp (no_asm_use) add: mult_assoc [symmetric])
   716     qed
   717   qed
   718 
   719 text{*Cancellation of equalities with a common factor*}
   720 lemma field_mult_cancel_right_lemma:
   721       assumes cnz: "c \<noteq> (0::'a::field)"
   722 	  and eq:  "a*c = b*c"
   723 	 shows "a=b"
   724   proof -
   725   have "(a * c) * inverse c = (b * c) * inverse c"
   726     by (simp add: eq)
   727   thus "a=b"
   728     by (simp add: mult_assoc cnz)
   729   qed
   730 
   731 lemma field_mult_cancel_right:
   732      "(a*c = b*c) = (c = (0::'a::field) | a=b)"
   733   proof cases
   734     assume "c=0" thus ?thesis by simp
   735   next
   736     assume "c\<noteq>0" 
   737     thus ?thesis by (force dest: field_mult_cancel_right_lemma)
   738   qed
   739 
   740 lemma field_mult_cancel_left:
   741      "(c*a = c*b) = (c = (0::'a::field) | a=b)"
   742   by (simp add: mult_commute [of c] field_mult_cancel_right) 
   743 
   744 lemma nonzero_imp_inverse_nonzero: "a \<noteq> 0 ==> inverse a \<noteq> (0::'a::field)"
   745   proof
   746   assume ianz: "inverse a = 0"
   747   assume "a \<noteq> 0"
   748   hence "1 = a * inverse a" by simp
   749   also have "... = 0" by (simp add: ianz)
   750   finally have "1 = (0::'a::field)" .
   751   thus False by (simp add: eq_commute)
   752   qed
   753 
   754 
   755 subsection{*Basic Properties of @{term inverse}*}
   756 
   757 lemma inverse_zero_imp_zero: "inverse a = 0 ==> a = (0::'a::field)"
   758 apply (rule ccontr) 
   759 apply (blast dest: nonzero_imp_inverse_nonzero) 
   760 done
   761 
   762 lemma inverse_nonzero_imp_nonzero:
   763    "inverse a = 0 ==> a = (0::'a::field)"
   764 apply (rule ccontr) 
   765 apply (blast dest: nonzero_imp_inverse_nonzero) 
   766 done
   767 
   768 lemma inverse_nonzero_iff_nonzero [simp]:
   769    "(inverse a = 0) = (a = (0::'a::{field,division_by_zero}))"
   770 by (force dest: inverse_nonzero_imp_nonzero) 
   771 
   772 lemma nonzero_inverse_minus_eq:
   773       assumes [simp]: "a\<noteq>0"  shows "inverse(-a) = -inverse(a::'a::field)"
   774   proof -
   775     have "-a * inverse (- a) = -a * - inverse a"
   776       by simp
   777     thus ?thesis 
   778       by (simp only: field_mult_cancel_left, simp)
   779   qed
   780 
   781 lemma inverse_minus_eq [simp]:
   782      "inverse(-a) = -inverse(a::'a::{field,division_by_zero})";
   783   proof cases
   784     assume "a=0" thus ?thesis by (simp add: inverse_zero)
   785   next
   786     assume "a\<noteq>0" 
   787     thus ?thesis by (simp add: nonzero_inverse_minus_eq)
   788   qed
   789 
   790 lemma nonzero_inverse_eq_imp_eq:
   791       assumes inveq: "inverse a = inverse b"
   792 	  and anz:  "a \<noteq> 0"
   793 	  and bnz:  "b \<noteq> 0"
   794 	 shows "a = (b::'a::field)"
   795   proof -
   796   have "a * inverse b = a * inverse a"
   797     by (simp add: inveq)
   798   hence "(a * inverse b) * b = (a * inverse a) * b"
   799     by simp
   800   thus "a = b"
   801     by (simp add: mult_assoc anz bnz)
   802   qed
   803 
   804 lemma inverse_eq_imp_eq:
   805      "inverse a = inverse b ==> a = (b::'a::{field,division_by_zero})"
   806 apply (case_tac "a=0 | b=0") 
   807  apply (force dest!: inverse_zero_imp_zero
   808               simp add: eq_commute [of "0::'a"])
   809 apply (force dest!: nonzero_inverse_eq_imp_eq) 
   810 done
   811 
   812 lemma inverse_eq_iff_eq [simp]:
   813      "(inverse a = inverse b) = (a = (b::'a::{field,division_by_zero}))"
   814 by (force dest!: inverse_eq_imp_eq) 
   815 
   816 lemma nonzero_inverse_inverse_eq:
   817       assumes [simp]: "a \<noteq> 0"  shows "inverse(inverse (a::'a::field)) = a"
   818   proof -
   819   have "(inverse (inverse a) * inverse a) * a = a" 
   820     by (simp add: nonzero_imp_inverse_nonzero)
   821   thus ?thesis
   822     by (simp add: mult_assoc)
   823   qed
   824 
   825 lemma inverse_inverse_eq [simp]:
   826      "inverse(inverse (a::'a::{field,division_by_zero})) = a"
   827   proof cases
   828     assume "a=0" thus ?thesis by simp
   829   next
   830     assume "a\<noteq>0" 
   831     thus ?thesis by (simp add: nonzero_inverse_inverse_eq)
   832   qed
   833 
   834 lemma inverse_1 [simp]: "inverse 1 = (1::'a::field)"
   835   proof -
   836   have "inverse 1 * 1 = (1::'a::field)" 
   837     by (rule left_inverse [OF zero_neq_one [symmetric]])
   838   thus ?thesis  by simp
   839   qed
   840 
   841 lemma nonzero_inverse_mult_distrib: 
   842       assumes anz: "a \<noteq> 0"
   843           and bnz: "b \<noteq> 0"
   844       shows "inverse(a*b) = inverse(b) * inverse(a::'a::field)"
   845   proof -
   846   have "inverse(a*b) * (a * b) * inverse(b) = inverse(b)" 
   847     by (simp add: field_mult_eq_0_iff anz bnz)
   848   hence "inverse(a*b) * a = inverse(b)" 
   849     by (simp add: mult_assoc bnz)
   850   hence "inverse(a*b) * a * inverse(a) = inverse(b) * inverse(a)" 
   851     by simp
   852   thus ?thesis
   853     by (simp add: mult_assoc anz)
   854   qed
   855 
   856 text{*This version builds in division by zero while also re-orienting
   857       the right-hand side.*}
   858 lemma inverse_mult_distrib [simp]:
   859      "inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})"
   860   proof cases
   861     assume "a \<noteq> 0 & b \<noteq> 0" 
   862     thus ?thesis  by (simp add: nonzero_inverse_mult_distrib mult_commute)
   863   next
   864     assume "~ (a \<noteq> 0 & b \<noteq> 0)" 
   865     thus ?thesis  by force
   866   qed
   867 
   868 text{*There is no slick version using division by zero.*}
   869 lemma inverse_add:
   870      "[|a \<noteq> 0;  b \<noteq> 0|]
   871       ==> inverse a + inverse b = (a+b) * inverse a * inverse (b::'a::field)"
   872 apply (simp add: left_distrib mult_assoc)
   873 apply (simp add: mult_commute [of "inverse a"]) 
   874 apply (simp add: mult_assoc [symmetric] add_commute)
   875 done
   876 
   877 lemma nonzero_mult_divide_cancel_left:
   878   assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" 
   879     shows "(c*a)/(c*b) = a/(b::'a::field)"
   880 proof -
   881   have "(c*a)/(c*b) = c * a * (inverse b * inverse c)"
   882     by (simp add: field_mult_eq_0_iff divide_inverse 
   883                   nonzero_inverse_mult_distrib)
   884   also have "... =  a * inverse b * (inverse c * c)"
   885     by (simp only: mult_ac)
   886   also have "... =  a * inverse b"
   887     by simp
   888     finally show ?thesis 
   889     by (simp add: divide_inverse)
   890 qed
   891 
   892 lemma mult_divide_cancel_left:
   893      "c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})"
   894 apply (case_tac "b = 0")
   895 apply (simp_all add: nonzero_mult_divide_cancel_left)
   896 done
   897 
   898 (*For ExtractCommonTerm*)
   899 lemma mult_divide_cancel_eq_if:
   900      "(c*a) / (c*b) = 
   901       (if c=0 then 0 else a / (b::'a::{field,division_by_zero}))"
   902   by (simp add: mult_divide_cancel_left)
   903 
   904 
   905 subsection {* Ordered Fields *}
   906 
   907 lemma positive_imp_inverse_positive: 
   908       assumes a_gt_0: "0 < a"  shows "0 < inverse (a::'a::ordered_field)"
   909   proof -
   910   have "0 < a * inverse a" 
   911     by (simp add: a_gt_0 [THEN order_less_imp_not_eq2] zero_less_one)
   912   thus "0 < inverse a" 
   913     by (simp add: a_gt_0 [THEN order_less_not_sym] zero_less_mult_iff)
   914   qed
   915 
   916 lemma negative_imp_inverse_negative:
   917      "a < 0 ==> inverse a < (0::'a::ordered_field)"
   918   by (insert positive_imp_inverse_positive [of "-a"], 
   919       simp add: nonzero_inverse_minus_eq order_less_imp_not_eq) 
   920 
   921 lemma inverse_le_imp_le:
   922       assumes invle: "inverse a \<le> inverse b"
   923 	  and apos:  "0 < a"
   924 	 shows "b \<le> (a::'a::ordered_field)"
   925   proof (rule classical)
   926   assume "~ b \<le> a"
   927   hence "a < b"
   928     by (simp add: linorder_not_le)
   929   hence bpos: "0 < b"
   930     by (blast intro: apos order_less_trans)
   931   hence "a * inverse a \<le> a * inverse b"
   932     by (simp add: apos invle order_less_imp_le mult_left_mono)
   933   hence "(a * inverse a) * b \<le> (a * inverse b) * b"
   934     by (simp add: bpos order_less_imp_le mult_right_mono)
   935   thus "b \<le> a"
   936     by (simp add: mult_assoc apos bpos order_less_imp_not_eq2)
   937   qed
   938 
   939 lemma inverse_positive_imp_positive:
   940       assumes inv_gt_0: "0 < inverse a"
   941           and [simp]:   "a \<noteq> 0"
   942         shows "0 < (a::'a::ordered_field)"
   943   proof -
   944   have "0 < inverse (inverse a)"
   945     by (rule positive_imp_inverse_positive)
   946   thus "0 < a"
   947     by (simp add: nonzero_inverse_inverse_eq)
   948   qed
   949 
   950 lemma inverse_positive_iff_positive [simp]:
   951       "(0 < inverse a) = (0 < (a::'a::{ordered_field,division_by_zero}))"
   952 apply (case_tac "a = 0", simp)
   953 apply (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive)
   954 done
   955 
   956 lemma inverse_negative_imp_negative:
   957       assumes inv_less_0: "inverse a < 0"
   958           and [simp]:   "a \<noteq> 0"
   959         shows "a < (0::'a::ordered_field)"
   960   proof -
   961   have "inverse (inverse a) < 0"
   962     by (rule negative_imp_inverse_negative)
   963   thus "a < 0"
   964     by (simp add: nonzero_inverse_inverse_eq)
   965   qed
   966 
   967 lemma inverse_negative_iff_negative [simp]:
   968       "(inverse a < 0) = (a < (0::'a::{ordered_field,division_by_zero}))"
   969 apply (case_tac "a = 0", simp)
   970 apply (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative)
   971 done
   972 
   973 lemma inverse_nonnegative_iff_nonnegative [simp]:
   974       "(0 \<le> inverse a) = (0 \<le> (a::'a::{ordered_field,division_by_zero}))"
   975 by (simp add: linorder_not_less [symmetric])
   976 
   977 lemma inverse_nonpositive_iff_nonpositive [simp]:
   978       "(inverse a \<le> 0) = (a \<le> (0::'a::{ordered_field,division_by_zero}))"
   979 by (simp add: linorder_not_less [symmetric])
   980 
   981 
   982 subsection{*Anti-Monotonicity of @{term inverse}*}
   983 
   984 lemma less_imp_inverse_less:
   985       assumes less: "a < b"
   986 	  and apos:  "0 < a"
   987 	shows "inverse b < inverse (a::'a::ordered_field)"
   988   proof (rule ccontr)
   989   assume "~ inverse b < inverse a"
   990   hence "inverse a \<le> inverse b"
   991     by (simp add: linorder_not_less)
   992   hence "~ (a < b)"
   993     by (simp add: linorder_not_less inverse_le_imp_le [OF _ apos])
   994   thus False
   995     by (rule notE [OF _ less])
   996   qed
   997 
   998 lemma inverse_less_imp_less:
   999    "[|inverse a < inverse b; 0 < a|] ==> b < (a::'a::ordered_field)"
  1000 apply (simp add: order_less_le [of "inverse a"] order_less_le [of "b"])
  1001 apply (force dest!: inverse_le_imp_le nonzero_inverse_eq_imp_eq) 
  1002 done
  1003 
  1004 text{*Both premises are essential. Consider -1 and 1.*}
  1005 lemma inverse_less_iff_less [simp]:
  1006      "[|0 < a; 0 < b|] 
  1007       ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
  1008 by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less) 
  1009 
  1010 lemma le_imp_inverse_le:
  1011    "[|a \<le> b; 0 < a|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
  1012   by (force simp add: order_le_less less_imp_inverse_less)
  1013 
  1014 lemma inverse_le_iff_le [simp]:
  1015      "[|0 < a; 0 < b|] 
  1016       ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
  1017 by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le) 
  1018 
  1019 
  1020 text{*These results refer to both operands being negative.  The opposite-sign
  1021 case is trivial, since inverse preserves signs.*}
  1022 lemma inverse_le_imp_le_neg:
  1023    "[|inverse a \<le> inverse b; b < 0|] ==> b \<le> (a::'a::ordered_field)"
  1024   apply (rule classical) 
  1025   apply (subgoal_tac "a < 0") 
  1026    prefer 2 apply (force simp add: linorder_not_le intro: order_less_trans) 
  1027   apply (insert inverse_le_imp_le [of "-b" "-a"])
  1028   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1029   done
  1030 
  1031 lemma less_imp_inverse_less_neg:
  1032    "[|a < b; b < 0|] ==> inverse b < inverse (a::'a::ordered_field)"
  1033   apply (subgoal_tac "a < 0") 
  1034    prefer 2 apply (blast intro: order_less_trans) 
  1035   apply (insert less_imp_inverse_less [of "-b" "-a"])
  1036   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1037   done
  1038 
  1039 lemma inverse_less_imp_less_neg:
  1040    "[|inverse a < inverse b; b < 0|] ==> b < (a::'a::ordered_field)"
  1041   apply (rule classical) 
  1042   apply (subgoal_tac "a < 0") 
  1043    prefer 2
  1044    apply (force simp add: linorder_not_less intro: order_le_less_trans) 
  1045   apply (insert inverse_less_imp_less [of "-b" "-a"])
  1046   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1047   done
  1048 
  1049 lemma inverse_less_iff_less_neg [simp]:
  1050      "[|a < 0; b < 0|] 
  1051       ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
  1052   apply (insert inverse_less_iff_less [of "-b" "-a"])
  1053   apply (simp del: inverse_less_iff_less 
  1054 	      add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1055   done
  1056 
  1057 lemma le_imp_inverse_le_neg:
  1058    "[|a \<le> b; b < 0|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
  1059   by (force simp add: order_le_less less_imp_inverse_less_neg)
  1060 
  1061 lemma inverse_le_iff_le_neg [simp]:
  1062      "[|a < 0; b < 0|] 
  1063       ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
  1064 by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg) 
  1065 
  1066 
  1067 subsection{*Division and Signs*}
  1068 
  1069 lemma zero_less_divide_iff:
  1070      "((0::'a::{ordered_field,division_by_zero}) < a/b) = (0 < a & 0 < b | a < 0 & b < 0)"
  1071 by (simp add: divide_inverse_zero zero_less_mult_iff)
  1072 
  1073 lemma divide_less_0_iff:
  1074      "(a/b < (0::'a::{ordered_field,division_by_zero})) = 
  1075       (0 < a & b < 0 | a < 0 & 0 < b)"
  1076 by (simp add: divide_inverse_zero mult_less_0_iff)
  1077 
  1078 lemma zero_le_divide_iff:
  1079      "((0::'a::{ordered_field,division_by_zero}) \<le> a/b) =
  1080       (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
  1081 by (simp add: divide_inverse_zero zero_le_mult_iff)
  1082 
  1083 lemma divide_le_0_iff:
  1084      "(a/b \<le> (0::'a::{ordered_field,division_by_zero})) = (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
  1085 by (simp add: divide_inverse_zero mult_le_0_iff)
  1086 
  1087 lemma divide_eq_0_iff [simp]:
  1088      "(a/b = 0) = (a=0 | b=(0::'a::{field,division_by_zero}))"
  1089 by (simp add: divide_inverse_zero field_mult_eq_0_iff)
  1090 
  1091 
  1092 end