src/HOL/Ring_and_Field.thy
author obua
Mon Jun 14 14:20:55 2004 +0200 (2004-06-14)
changeset 14940 b9ab8babd8b3
parent 14770 fe9504ba63d5
child 15010 72fbe711e414
permissions -rw-r--r--
Further development of matrix theory
     1 (*  Title:   HOL/Ring_and_Field.thy
     2     ID:      $Id$
     3     Author:  Gertrud Bauer, Steven Obua, Lawrence C Paulson and Markus Wenzel
     4     License: GPL (GNU GENERAL PUBLIC LICENSE)
     5 *)
     6 
     7 header {* (Ordered) Rings and Fields *}
     8 
     9 theory Ring_and_Field = OrderedGroup:
    10 
    11 text {*
    12   The theory of partially ordered rings is taken from the books:
    13   \begin{itemize}
    14   \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 
    15   \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
    16   \end{itemize}
    17   Most of the used notions can also be looked up in 
    18   \begin{itemize}
    19   \item \url{http://www.mathworld.com} by Eric Weisstein et. al.
    20   \item \emph{Algebra I} by van der Waerden, Springer.
    21   \end{itemize}
    22 *}
    23 
    24 axclass semiring \<subseteq> ab_semigroup_add, semigroup_mult
    25   left_distrib: "(a + b) * c = a * c + b * c"
    26   right_distrib: "a * (b + c) = a * b + a * c"
    27 
    28 axclass semiring_0 \<subseteq> semiring, comm_monoid_add
    29 
    30 axclass semiring_0_cancel \<subseteq> semiring_0, cancel_ab_semigroup_add
    31 
    32 axclass comm_semiring \<subseteq> ab_semigroup_add, ab_semigroup_mult  
    33   mult_commute: "a * b = b * a"
    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 lemma mult_less_cancel_right:
   475     "(a*c < b*c) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))"
   476 apply (case_tac "c = 0")
   477 apply (auto simp add: linorder_neq_iff mult_strict_right_mono 
   478                       mult_strict_right_mono_neg)
   479 apply (auto simp add: linorder_not_less 
   480                       linorder_not_le [symmetric, of "a*c"]
   481                       linorder_not_le [symmetric, of a])
   482 apply (erule_tac [!] notE)
   483 apply (auto simp add: order_less_imp_le mult_right_mono 
   484                       mult_right_mono_neg)
   485 done
   486 
   487 lemma mult_less_cancel_left:
   488     "(c*a < c*b) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))"
   489 apply (case_tac "c = 0")
   490 apply (auto simp add: linorder_neq_iff mult_strict_left_mono 
   491                       mult_strict_left_mono_neg)
   492 apply (auto simp add: linorder_not_less 
   493                       linorder_not_le [symmetric, of "c*a"]
   494                       linorder_not_le [symmetric, of a])
   495 apply (erule_tac [!] notE)
   496 apply (auto simp add: order_less_imp_le mult_left_mono 
   497                       mult_left_mono_neg)
   498 done
   499 
   500 lemma mult_le_cancel_right:
   501      "(a*c \<le> b*c) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring_strict)))"
   502 by (simp add: linorder_not_less [symmetric] mult_less_cancel_right)
   503 
   504 lemma mult_le_cancel_left:
   505      "(c*a \<le> c*b) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring_strict)))"
   506 by (simp add: linorder_not_less [symmetric] mult_less_cancel_left)
   507 
   508 lemma mult_less_imp_less_left:
   509       assumes less: "c*a < c*b" and nonneg: "0 \<le> c"
   510       shows "a < (b::'a::ordered_semiring_strict)"
   511 proof (rule ccontr)
   512   assume "~ a < b"
   513   hence "b \<le> a" by (simp add: linorder_not_less)
   514   hence "c*b \<le> c*a" by (rule mult_left_mono)
   515   with this and less show False 
   516     by (simp add: linorder_not_less [symmetric])
   517 qed
   518 
   519 lemma mult_less_imp_less_right:
   520   assumes less: "a*c < b*c" and nonneg: "0 <= c"
   521   shows "a < (b::'a::ordered_semiring_strict)"
   522 proof (rule ccontr)
   523   assume "~ a < b"
   524   hence "b \<le> a" by (simp add: linorder_not_less)
   525   hence "b*c \<le> a*c" by (rule mult_right_mono)
   526   with this and less show False 
   527     by (simp add: linorder_not_less [symmetric])
   528 qed  
   529 
   530 text{*Cancellation of equalities with a common factor*}
   531 lemma mult_cancel_right [simp]:
   532      "(a*c = b*c) = (c = (0::'a::ordered_ring_strict) | a=b)"
   533 apply (cut_tac linorder_less_linear [of 0 c])
   534 apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono
   535              simp add: linorder_neq_iff)
   536 done
   537 
   538 text{*These cancellation theorems require an ordering. Versions are proved
   539       below that work for fields without an ordering.*}
   540 lemma mult_cancel_left [simp]:
   541      "(c*a = c*b) = (c = (0::'a::ordered_ring_strict) | a=b)"
   542 apply (cut_tac linorder_less_linear [of 0 c])
   543 apply (force dest: mult_strict_left_mono_neg mult_strict_left_mono
   544              simp add: linorder_neq_iff)
   545 done
   546 
   547 text{*This list of rewrites decides ring equalities by ordered rewriting.*}
   548 lemmas ring_eq_simps =
   549   mult_ac
   550   left_distrib right_distrib left_diff_distrib right_diff_distrib
   551   add_ac
   552   add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
   553   diff_eq_eq eq_diff_eq
   554     
   555 
   556 subsection {* Fields *}
   557 
   558 lemma right_inverse [simp]:
   559       assumes not0: "a \<noteq> 0" shows "a * inverse (a::'a::field) = 1"
   560 proof -
   561   have "a * inverse a = inverse a * a" by (simp add: mult_ac)
   562   also have "... = 1" using not0 by simp
   563   finally show ?thesis .
   564 qed
   565 
   566 lemma right_inverse_eq: "b \<noteq> 0 ==> (a / b = 1) = (a = (b::'a::field))"
   567 proof
   568   assume neq: "b \<noteq> 0"
   569   {
   570     hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac)
   571     also assume "a / b = 1"
   572     finally show "a = b" by simp
   573   next
   574     assume "a = b"
   575     with neq show "a / b = 1" by (simp add: divide_inverse)
   576   }
   577 qed
   578 
   579 lemma nonzero_inverse_eq_divide: "a \<noteq> 0 ==> inverse (a::'a::field) = 1/a"
   580 by (simp add: divide_inverse)
   581 
   582 lemma divide_self [simp]: "a \<noteq> 0 ==> a / (a::'a::field) = 1"
   583   by (simp add: divide_inverse)
   584 
   585 lemma divide_zero [simp]: "a / 0 = (0::'a::{field,division_by_zero})"
   586 by (simp add: divide_inverse)
   587 
   588 lemma divide_zero_left [simp]: "0/a = (0::'a::field)"
   589 by (simp add: divide_inverse)
   590 
   591 lemma inverse_eq_divide: "inverse (a::'a::field) = 1/a"
   592 by (simp add: divide_inverse)
   593 
   594 lemma add_divide_distrib: "(a+b)/(c::'a::field) = a/c + b/c"
   595 by (simp add: divide_inverse left_distrib) 
   596 
   597 
   598 text{*Compared with @{text mult_eq_0_iff}, this version removes the requirement
   599       of an ordering.*}
   600 lemma field_mult_eq_0_iff [simp]: "(a*b = (0::'a::field)) = (a = 0 | b = 0)"
   601 proof cases
   602   assume "a=0" thus ?thesis by simp
   603 next
   604   assume anz [simp]: "a\<noteq>0"
   605   { assume "a * b = 0"
   606     hence "inverse a * (a * b) = 0" by simp
   607     hence "b = 0"  by (simp (no_asm_use) add: mult_assoc [symmetric])}
   608   thus ?thesis by force
   609 qed
   610 
   611 text{*Cancellation of equalities with a common factor*}
   612 lemma field_mult_cancel_right_lemma:
   613       assumes cnz: "c \<noteq> (0::'a::field)"
   614 	  and eq:  "a*c = b*c"
   615 	 shows "a=b"
   616 proof -
   617   have "(a * c) * inverse c = (b * c) * inverse c"
   618     by (simp add: eq)
   619   thus "a=b"
   620     by (simp add: mult_assoc cnz)
   621 qed
   622 
   623 lemma field_mult_cancel_right [simp]:
   624      "(a*c = b*c) = (c = (0::'a::field) | a=b)"
   625 proof cases
   626   assume "c=0" thus ?thesis by simp
   627 next
   628   assume "c\<noteq>0" 
   629   thus ?thesis by (force dest: field_mult_cancel_right_lemma)
   630 qed
   631 
   632 lemma field_mult_cancel_left [simp]:
   633      "(c*a = c*b) = (c = (0::'a::field) | a=b)"
   634   by (simp add: mult_commute [of c] field_mult_cancel_right) 
   635 
   636 lemma nonzero_imp_inverse_nonzero: "a \<noteq> 0 ==> inverse a \<noteq> (0::'a::field)"
   637 proof
   638   assume ianz: "inverse a = 0"
   639   assume "a \<noteq> 0"
   640   hence "1 = a * inverse a" by simp
   641   also have "... = 0" by (simp add: ianz)
   642   finally have "1 = (0::'a::field)" .
   643   thus False by (simp add: eq_commute)
   644 qed
   645 
   646 
   647 subsection{*Basic Properties of @{term inverse}*}
   648 
   649 lemma inverse_zero_imp_zero: "inverse a = 0 ==> a = (0::'a::field)"
   650 apply (rule ccontr) 
   651 apply (blast dest: nonzero_imp_inverse_nonzero) 
   652 done
   653 
   654 lemma inverse_nonzero_imp_nonzero:
   655    "inverse a = 0 ==> a = (0::'a::field)"
   656 apply (rule ccontr) 
   657 apply (blast dest: nonzero_imp_inverse_nonzero) 
   658 done
   659 
   660 lemma inverse_nonzero_iff_nonzero [simp]:
   661    "(inverse a = 0) = (a = (0::'a::{field,division_by_zero}))"
   662 by (force dest: inverse_nonzero_imp_nonzero) 
   663 
   664 lemma nonzero_inverse_minus_eq:
   665       assumes [simp]: "a\<noteq>0"  shows "inverse(-a) = -inverse(a::'a::field)"
   666 proof -
   667   have "-a * inverse (- a) = -a * - inverse a"
   668     by simp
   669   thus ?thesis 
   670     by (simp only: field_mult_cancel_left, simp)
   671 qed
   672 
   673 lemma inverse_minus_eq [simp]:
   674    "inverse(-a) = -inverse(a::'a::{field,division_by_zero})";
   675 proof cases
   676   assume "a=0" thus ?thesis by (simp add: inverse_zero)
   677 next
   678   assume "a\<noteq>0" 
   679   thus ?thesis by (simp add: nonzero_inverse_minus_eq)
   680 qed
   681 
   682 lemma nonzero_inverse_eq_imp_eq:
   683       assumes inveq: "inverse a = inverse b"
   684 	  and anz:  "a \<noteq> 0"
   685 	  and bnz:  "b \<noteq> 0"
   686 	 shows "a = (b::'a::field)"
   687 proof -
   688   have "a * inverse b = a * inverse a"
   689     by (simp add: inveq)
   690   hence "(a * inverse b) * b = (a * inverse a) * b"
   691     by simp
   692   thus "a = b"
   693     by (simp add: mult_assoc anz bnz)
   694 qed
   695 
   696 lemma inverse_eq_imp_eq:
   697      "inverse a = inverse b ==> a = (b::'a::{field,division_by_zero})"
   698 apply (case_tac "a=0 | b=0") 
   699  apply (force dest!: inverse_zero_imp_zero
   700               simp add: eq_commute [of "0::'a"])
   701 apply (force dest!: nonzero_inverse_eq_imp_eq) 
   702 done
   703 
   704 lemma inverse_eq_iff_eq [simp]:
   705      "(inverse a = inverse b) = (a = (b::'a::{field,division_by_zero}))"
   706 by (force dest!: inverse_eq_imp_eq) 
   707 
   708 lemma nonzero_inverse_inverse_eq:
   709       assumes [simp]: "a \<noteq> 0"  shows "inverse(inverse (a::'a::field)) = a"
   710   proof -
   711   have "(inverse (inverse a) * inverse a) * a = a" 
   712     by (simp add: nonzero_imp_inverse_nonzero)
   713   thus ?thesis
   714     by (simp add: mult_assoc)
   715   qed
   716 
   717 lemma inverse_inverse_eq [simp]:
   718      "inverse(inverse (a::'a::{field,division_by_zero})) = a"
   719   proof cases
   720     assume "a=0" thus ?thesis by simp
   721   next
   722     assume "a\<noteq>0" 
   723     thus ?thesis by (simp add: nonzero_inverse_inverse_eq)
   724   qed
   725 
   726 lemma inverse_1 [simp]: "inverse 1 = (1::'a::field)"
   727   proof -
   728   have "inverse 1 * 1 = (1::'a::field)" 
   729     by (rule left_inverse [OF zero_neq_one [symmetric]])
   730   thus ?thesis  by simp
   731   qed
   732 
   733 lemma nonzero_inverse_mult_distrib: 
   734       assumes anz: "a \<noteq> 0"
   735           and bnz: "b \<noteq> 0"
   736       shows "inverse(a*b) = inverse(b) * inverse(a::'a::field)"
   737   proof -
   738   have "inverse(a*b) * (a * b) * inverse(b) = inverse(b)" 
   739     by (simp add: field_mult_eq_0_iff anz bnz)
   740   hence "inverse(a*b) * a = inverse(b)" 
   741     by (simp add: mult_assoc bnz)
   742   hence "inverse(a*b) * a * inverse(a) = inverse(b) * inverse(a)" 
   743     by simp
   744   thus ?thesis
   745     by (simp add: mult_assoc anz)
   746   qed
   747 
   748 text{*This version builds in division by zero while also re-orienting
   749       the right-hand side.*}
   750 lemma inverse_mult_distrib [simp]:
   751      "inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})"
   752   proof cases
   753     assume "a \<noteq> 0 & b \<noteq> 0" 
   754     thus ?thesis  by (simp add: nonzero_inverse_mult_distrib mult_commute)
   755   next
   756     assume "~ (a \<noteq> 0 & b \<noteq> 0)" 
   757     thus ?thesis  by force
   758   qed
   759 
   760 text{*There is no slick version using division by zero.*}
   761 lemma inverse_add:
   762      "[|a \<noteq> 0;  b \<noteq> 0|]
   763       ==> inverse a + inverse b = (a+b) * inverse a * inverse (b::'a::field)"
   764 apply (simp add: left_distrib mult_assoc)
   765 apply (simp add: mult_commute [of "inverse a"]) 
   766 apply (simp add: mult_assoc [symmetric] add_commute)
   767 done
   768 
   769 lemma inverse_divide [simp]:
   770       "inverse (a/b) = b / (a::'a::{field,division_by_zero})"
   771   by (simp add: divide_inverse mult_commute)
   772 
   773 lemma nonzero_mult_divide_cancel_left:
   774   assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" 
   775     shows "(c*a)/(c*b) = a/(b::'a::field)"
   776 proof -
   777   have "(c*a)/(c*b) = c * a * (inverse b * inverse c)"
   778     by (simp add: field_mult_eq_0_iff divide_inverse 
   779                   nonzero_inverse_mult_distrib)
   780   also have "... =  a * inverse b * (inverse c * c)"
   781     by (simp only: mult_ac)
   782   also have "... =  a * inverse b"
   783     by simp
   784     finally show ?thesis 
   785     by (simp add: divide_inverse)
   786 qed
   787 
   788 lemma mult_divide_cancel_left:
   789      "c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})"
   790 apply (case_tac "b = 0")
   791 apply (simp_all add: nonzero_mult_divide_cancel_left)
   792 done
   793 
   794 lemma nonzero_mult_divide_cancel_right:
   795      "[|b\<noteq>0; c\<noteq>0|] ==> (a*c) / (b*c) = a/(b::'a::field)"
   796 by (simp add: mult_commute [of _ c] nonzero_mult_divide_cancel_left) 
   797 
   798 lemma mult_divide_cancel_right:
   799      "c\<noteq>0 ==> (a*c) / (b*c) = a / (b::'a::{field,division_by_zero})"
   800 apply (case_tac "b = 0")
   801 apply (simp_all add: nonzero_mult_divide_cancel_right)
   802 done
   803 
   804 (*For ExtractCommonTerm*)
   805 lemma mult_divide_cancel_eq_if:
   806      "(c*a) / (c*b) = 
   807       (if c=0 then 0 else a / (b::'a::{field,division_by_zero}))"
   808   by (simp add: mult_divide_cancel_left)
   809 
   810 lemma divide_1 [simp]: "a/1 = (a::'a::field)"
   811   by (simp add: divide_inverse)
   812 
   813 lemma times_divide_eq_right [simp]: "a * (b/c) = (a*b) / (c::'a::field)"
   814 by (simp add: divide_inverse mult_assoc)
   815 
   816 lemma times_divide_eq_left: "(b/c) * a = (b*a) / (c::'a::field)"
   817 by (simp add: divide_inverse mult_ac)
   818 
   819 lemma divide_divide_eq_right [simp]:
   820      "a / (b/c) = (a*c) / (b::'a::{field,division_by_zero})"
   821 by (simp add: divide_inverse mult_ac)
   822 
   823 lemma divide_divide_eq_left [simp]:
   824      "(a / b) / (c::'a::{field,division_by_zero}) = a / (b*c)"
   825 by (simp add: divide_inverse mult_assoc)
   826 
   827 
   828 subsection {* Division and Unary Minus *}
   829 
   830 lemma nonzero_minus_divide_left: "b \<noteq> 0 ==> - (a/b) = (-a) / (b::'a::field)"
   831 by (simp add: divide_inverse minus_mult_left)
   832 
   833 lemma nonzero_minus_divide_right: "b \<noteq> 0 ==> - (a/b) = a / -(b::'a::field)"
   834 by (simp add: divide_inverse nonzero_inverse_minus_eq minus_mult_right)
   835 
   836 lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (-a)/(-b) = a / (b::'a::field)"
   837 by (simp add: divide_inverse nonzero_inverse_minus_eq)
   838 
   839 lemma minus_divide_left: "- (a/b) = (-a) / (b::'a::field)"
   840 by (simp add: divide_inverse minus_mult_left [symmetric])
   841 
   842 lemma minus_divide_right: "- (a/b) = a / -(b::'a::{field,division_by_zero})"
   843 by (simp add: divide_inverse minus_mult_right [symmetric])
   844 
   845 
   846 text{*The effect is to extract signs from divisions*}
   847 declare minus_divide_left  [symmetric, simp]
   848 declare minus_divide_right [symmetric, simp]
   849 
   850 text{*Also, extract signs from products*}
   851 declare minus_mult_left [symmetric, simp]
   852 declare minus_mult_right [symmetric, simp]
   853 
   854 lemma minus_divide_divide [simp]:
   855      "(-a)/(-b) = a / (b::'a::{field,division_by_zero})"
   856 apply (case_tac "b=0", simp) 
   857 apply (simp add: nonzero_minus_divide_divide) 
   858 done
   859 
   860 lemma diff_divide_distrib: "(a-b)/(c::'a::field) = a/c - b/c"
   861 by (simp add: diff_minus add_divide_distrib) 
   862 
   863 
   864 subsection {* Ordered Fields *}
   865 
   866 lemma positive_imp_inverse_positive: 
   867       assumes a_gt_0: "0 < a"  shows "0 < inverse (a::'a::ordered_field)"
   868   proof -
   869   have "0 < a * inverse a" 
   870     by (simp add: a_gt_0 [THEN order_less_imp_not_eq2] zero_less_one)
   871   thus "0 < inverse a" 
   872     by (simp add: a_gt_0 [THEN order_less_not_sym] zero_less_mult_iff)
   873   qed
   874 
   875 lemma negative_imp_inverse_negative:
   876      "a < 0 ==> inverse a < (0::'a::ordered_field)"
   877   by (insert positive_imp_inverse_positive [of "-a"], 
   878       simp add: nonzero_inverse_minus_eq order_less_imp_not_eq) 
   879 
   880 lemma inverse_le_imp_le:
   881       assumes invle: "inverse a \<le> inverse b"
   882 	  and apos:  "0 < a"
   883 	 shows "b \<le> (a::'a::ordered_field)"
   884   proof (rule classical)
   885   assume "~ b \<le> a"
   886   hence "a < b"
   887     by (simp add: linorder_not_le)
   888   hence bpos: "0 < b"
   889     by (blast intro: apos order_less_trans)
   890   hence "a * inverse a \<le> a * inverse b"
   891     by (simp add: apos invle order_less_imp_le mult_left_mono)
   892   hence "(a * inverse a) * b \<le> (a * inverse b) * b"
   893     by (simp add: bpos order_less_imp_le mult_right_mono)
   894   thus "b \<le> a"
   895     by (simp add: mult_assoc apos bpos order_less_imp_not_eq2)
   896   qed
   897 
   898 lemma inverse_positive_imp_positive:
   899       assumes inv_gt_0: "0 < inverse a"
   900           and [simp]:   "a \<noteq> 0"
   901         shows "0 < (a::'a::ordered_field)"
   902   proof -
   903   have "0 < inverse (inverse a)"
   904     by (rule positive_imp_inverse_positive)
   905   thus "0 < a"
   906     by (simp add: nonzero_inverse_inverse_eq)
   907   qed
   908 
   909 lemma inverse_positive_iff_positive [simp]:
   910       "(0 < inverse a) = (0 < (a::'a::{ordered_field,division_by_zero}))"
   911 apply (case_tac "a = 0", simp)
   912 apply (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive)
   913 done
   914 
   915 lemma inverse_negative_imp_negative:
   916       assumes inv_less_0: "inverse a < 0"
   917           and [simp]:   "a \<noteq> 0"
   918         shows "a < (0::'a::ordered_field)"
   919   proof -
   920   have "inverse (inverse a) < 0"
   921     by (rule negative_imp_inverse_negative)
   922   thus "a < 0"
   923     by (simp add: nonzero_inverse_inverse_eq)
   924   qed
   925 
   926 lemma inverse_negative_iff_negative [simp]:
   927       "(inverse a < 0) = (a < (0::'a::{ordered_field,division_by_zero}))"
   928 apply (case_tac "a = 0", simp)
   929 apply (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative)
   930 done
   931 
   932 lemma inverse_nonnegative_iff_nonnegative [simp]:
   933       "(0 \<le> inverse a) = (0 \<le> (a::'a::{ordered_field,division_by_zero}))"
   934 by (simp add: linorder_not_less [symmetric])
   935 
   936 lemma inverse_nonpositive_iff_nonpositive [simp]:
   937       "(inverse a \<le> 0) = (a \<le> (0::'a::{ordered_field,division_by_zero}))"
   938 by (simp add: linorder_not_less [symmetric])
   939 
   940 
   941 subsection{*Anti-Monotonicity of @{term inverse}*}
   942 
   943 lemma less_imp_inverse_less:
   944       assumes less: "a < b"
   945 	  and apos:  "0 < a"
   946 	shows "inverse b < inverse (a::'a::ordered_field)"
   947   proof (rule ccontr)
   948   assume "~ inverse b < inverse a"
   949   hence "inverse a \<le> inverse b"
   950     by (simp add: linorder_not_less)
   951   hence "~ (a < b)"
   952     by (simp add: linorder_not_less inverse_le_imp_le [OF _ apos])
   953   thus False
   954     by (rule notE [OF _ less])
   955   qed
   956 
   957 lemma inverse_less_imp_less:
   958    "[|inverse a < inverse b; 0 < a|] ==> b < (a::'a::ordered_field)"
   959 apply (simp add: order_less_le [of "inverse a"] order_less_le [of "b"])
   960 apply (force dest!: inverse_le_imp_le nonzero_inverse_eq_imp_eq) 
   961 done
   962 
   963 text{*Both premises are essential. Consider -1 and 1.*}
   964 lemma inverse_less_iff_less [simp]:
   965      "[|0 < a; 0 < b|] 
   966       ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
   967 by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less) 
   968 
   969 lemma le_imp_inverse_le:
   970    "[|a \<le> b; 0 < a|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
   971   by (force simp add: order_le_less less_imp_inverse_less)
   972 
   973 lemma inverse_le_iff_le [simp]:
   974      "[|0 < a; 0 < b|] 
   975       ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
   976 by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le) 
   977 
   978 
   979 text{*These results refer to both operands being negative.  The opposite-sign
   980 case is trivial, since inverse preserves signs.*}
   981 lemma inverse_le_imp_le_neg:
   982    "[|inverse a \<le> inverse b; b < 0|] ==> b \<le> (a::'a::ordered_field)"
   983   apply (rule classical) 
   984   apply (subgoal_tac "a < 0") 
   985    prefer 2 apply (force simp add: linorder_not_le intro: order_less_trans) 
   986   apply (insert inverse_le_imp_le [of "-b" "-a"])
   987   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
   988   done
   989 
   990 lemma less_imp_inverse_less_neg:
   991    "[|a < b; b < 0|] ==> inverse b < inverse (a::'a::ordered_field)"
   992   apply (subgoal_tac "a < 0") 
   993    prefer 2 apply (blast intro: order_less_trans) 
   994   apply (insert less_imp_inverse_less [of "-b" "-a"])
   995   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
   996   done
   997 
   998 lemma inverse_less_imp_less_neg:
   999    "[|inverse a < inverse b; b < 0|] ==> b < (a::'a::ordered_field)"
  1000   apply (rule classical) 
  1001   apply (subgoal_tac "a < 0") 
  1002    prefer 2
  1003    apply (force simp add: linorder_not_less intro: order_le_less_trans) 
  1004   apply (insert inverse_less_imp_less [of "-b" "-a"])
  1005   apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1006   done
  1007 
  1008 lemma inverse_less_iff_less_neg [simp]:
  1009      "[|a < 0; b < 0|] 
  1010       ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
  1011   apply (insert inverse_less_iff_less [of "-b" "-a"])
  1012   apply (simp del: inverse_less_iff_less 
  1013 	      add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
  1014   done
  1015 
  1016 lemma le_imp_inverse_le_neg:
  1017    "[|a \<le> b; b < 0|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
  1018   by (force simp add: order_le_less less_imp_inverse_less_neg)
  1019 
  1020 lemma inverse_le_iff_le_neg [simp]:
  1021      "[|a < 0; b < 0|] 
  1022       ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
  1023 by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg) 
  1024 
  1025 
  1026 subsection{*Inverses and the Number One*}
  1027 
  1028 lemma one_less_inverse_iff:
  1029     "(1 < inverse x) = (0 < x & x < (1::'a::{ordered_field,division_by_zero}))"proof cases
  1030   assume "0 < x"
  1031     with inverse_less_iff_less [OF zero_less_one, of x]
  1032     show ?thesis by simp
  1033 next
  1034   assume notless: "~ (0 < x)"
  1035   have "~ (1 < inverse x)"
  1036   proof
  1037     assume "1 < inverse x"
  1038     also with notless have "... \<le> 0" by (simp add: linorder_not_less)
  1039     also have "... < 1" by (rule zero_less_one) 
  1040     finally show False by auto
  1041   qed
  1042   with notless show ?thesis by simp
  1043 qed
  1044 
  1045 lemma inverse_eq_1_iff [simp]:
  1046     "(inverse x = 1) = (x = (1::'a::{field,division_by_zero}))"
  1047 by (insert inverse_eq_iff_eq [of x 1], simp) 
  1048 
  1049 lemma one_le_inverse_iff:
  1050    "(1 \<le> inverse x) = (0 < x & x \<le> (1::'a::{ordered_field,division_by_zero}))"
  1051 by (force simp add: order_le_less one_less_inverse_iff zero_less_one 
  1052                     eq_commute [of 1]) 
  1053 
  1054 lemma inverse_less_1_iff:
  1055    "(inverse x < 1) = (x \<le> 0 | 1 < (x::'a::{ordered_field,division_by_zero}))"
  1056 by (simp add: linorder_not_le [symmetric] one_le_inverse_iff) 
  1057 
  1058 lemma inverse_le_1_iff:
  1059    "(inverse x \<le> 1) = (x \<le> 0 | 1 \<le> (x::'a::{ordered_field,division_by_zero}))"
  1060 by (simp add: linorder_not_less [symmetric] one_less_inverse_iff) 
  1061 
  1062 
  1063 subsection{*Division and Signs*}
  1064 
  1065 lemma zero_less_divide_iff:
  1066      "((0::'a::{ordered_field,division_by_zero}) < a/b) = (0 < a & 0 < b | a < 0 & b < 0)"
  1067 by (simp add: divide_inverse zero_less_mult_iff)
  1068 
  1069 lemma divide_less_0_iff:
  1070      "(a/b < (0::'a::{ordered_field,division_by_zero})) = 
  1071       (0 < a & b < 0 | a < 0 & 0 < b)"
  1072 by (simp add: divide_inverse mult_less_0_iff)
  1073 
  1074 lemma zero_le_divide_iff:
  1075      "((0::'a::{ordered_field,division_by_zero}) \<le> a/b) =
  1076       (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
  1077 by (simp add: divide_inverse zero_le_mult_iff)
  1078 
  1079 lemma divide_le_0_iff:
  1080      "(a/b \<le> (0::'a::{ordered_field,division_by_zero})) =
  1081       (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
  1082 by (simp add: divide_inverse mult_le_0_iff)
  1083 
  1084 lemma divide_eq_0_iff [simp]:
  1085      "(a/b = 0) = (a=0 | b=(0::'a::{field,division_by_zero}))"
  1086 by (simp add: divide_inverse field_mult_eq_0_iff)
  1087 
  1088 
  1089 subsection{*Simplification of Inequalities Involving Literal Divisors*}
  1090 
  1091 lemma pos_le_divide_eq: "0 < (c::'a::ordered_field) ==> (a \<le> b/c) = (a*c \<le> b)"
  1092 proof -
  1093   assume less: "0<c"
  1094   hence "(a \<le> b/c) = (a*c \<le> (b/c)*c)"
  1095     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1096   also have "... = (a*c \<le> b)"
  1097     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1098   finally show ?thesis .
  1099 qed
  1100 
  1101 
  1102 lemma neg_le_divide_eq: "c < (0::'a::ordered_field) ==> (a \<le> b/c) = (b \<le> a*c)"
  1103 proof -
  1104   assume less: "c<0"
  1105   hence "(a \<le> b/c) = ((b/c)*c \<le> a*c)"
  1106     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1107   also have "... = (b \<le> a*c)"
  1108     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1109   finally show ?thesis .
  1110 qed
  1111 
  1112 lemma le_divide_eq:
  1113   "(a \<le> b/c) = 
  1114    (if 0 < c then a*c \<le> b
  1115              else if c < 0 then b \<le> a*c
  1116              else  a \<le> (0::'a::{ordered_field,division_by_zero}))"
  1117 apply (case_tac "c=0", simp) 
  1118 apply (force simp add: pos_le_divide_eq neg_le_divide_eq linorder_neq_iff) 
  1119 done
  1120 
  1121 lemma pos_divide_le_eq: "0 < (c::'a::ordered_field) ==> (b/c \<le> a) = (b \<le> a*c)"
  1122 proof -
  1123   assume less: "0<c"
  1124   hence "(b/c \<le> a) = ((b/c)*c \<le> a*c)"
  1125     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1126   also have "... = (b \<le> a*c)"
  1127     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1128   finally show ?thesis .
  1129 qed
  1130 
  1131 lemma neg_divide_le_eq: "c < (0::'a::ordered_field) ==> (b/c \<le> a) = (a*c \<le> b)"
  1132 proof -
  1133   assume less: "c<0"
  1134   hence "(b/c \<le> a) = (a*c \<le> (b/c)*c)"
  1135     by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
  1136   also have "... = (a*c \<le> b)"
  1137     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1138   finally show ?thesis .
  1139 qed
  1140 
  1141 lemma divide_le_eq:
  1142   "(b/c \<le> a) = 
  1143    (if 0 < c then b \<le> a*c
  1144              else if c < 0 then a*c \<le> b
  1145              else 0 \<le> (a::'a::{ordered_field,division_by_zero}))"
  1146 apply (case_tac "c=0", simp) 
  1147 apply (force simp add: pos_divide_le_eq neg_divide_le_eq linorder_neq_iff) 
  1148 done
  1149 
  1150 
  1151 lemma pos_less_divide_eq:
  1152      "0 < (c::'a::ordered_field) ==> (a < b/c) = (a*c < b)"
  1153 proof -
  1154   assume less: "0<c"
  1155   hence "(a < b/c) = (a*c < (b/c)*c)"
  1156     by (simp add: mult_less_cancel_right order_less_not_sym [OF less])
  1157   also have "... = (a*c < b)"
  1158     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1159   finally show ?thesis .
  1160 qed
  1161 
  1162 lemma neg_less_divide_eq:
  1163  "c < (0::'a::ordered_field) ==> (a < b/c) = (b < a*c)"
  1164 proof -
  1165   assume less: "c<0"
  1166   hence "(a < b/c) = ((b/c)*c < a*c)"
  1167     by (simp add: mult_less_cancel_right order_less_not_sym [OF less])
  1168   also have "... = (b < a*c)"
  1169     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1170   finally show ?thesis .
  1171 qed
  1172 
  1173 lemma less_divide_eq:
  1174   "(a < b/c) = 
  1175    (if 0 < c then a*c < b
  1176              else if c < 0 then b < a*c
  1177              else  a < (0::'a::{ordered_field,division_by_zero}))"
  1178 apply (case_tac "c=0", simp) 
  1179 apply (force simp add: pos_less_divide_eq neg_less_divide_eq linorder_neq_iff) 
  1180 done
  1181 
  1182 lemma pos_divide_less_eq:
  1183      "0 < (c::'a::ordered_field) ==> (b/c < a) = (b < a*c)"
  1184 proof -
  1185   assume less: "0<c"
  1186   hence "(b/c < a) = ((b/c)*c < a*c)"
  1187     by (simp add: mult_less_cancel_right order_less_not_sym [OF less])
  1188   also have "... = (b < a*c)"
  1189     by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
  1190   finally show ?thesis .
  1191 qed
  1192 
  1193 lemma neg_divide_less_eq:
  1194  "c < (0::'a::ordered_field) ==> (b/c < a) = (a*c < b)"
  1195 proof -
  1196   assume less: "c<0"
  1197   hence "(b/c < a) = (a*c < (b/c)*c)"
  1198     by (simp add: mult_less_cancel_right order_less_not_sym [OF less])
  1199   also have "... = (a*c < b)"
  1200     by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
  1201   finally show ?thesis .
  1202 qed
  1203 
  1204 lemma divide_less_eq:
  1205   "(b/c < a) = 
  1206    (if 0 < c then b < a*c
  1207              else if c < 0 then a*c < b
  1208              else 0 < (a::'a::{ordered_field,division_by_zero}))"
  1209 apply (case_tac "c=0", simp) 
  1210 apply (force simp add: pos_divide_less_eq neg_divide_less_eq linorder_neq_iff) 
  1211 done
  1212 
  1213 lemma nonzero_eq_divide_eq: "c\<noteq>0 ==> ((a::'a::field) = b/c) = (a*c = b)"
  1214 proof -
  1215   assume [simp]: "c\<noteq>0"
  1216   have "(a = b/c) = (a*c = (b/c)*c)"
  1217     by (simp add: field_mult_cancel_right)
  1218   also have "... = (a*c = b)"
  1219     by (simp add: divide_inverse mult_assoc) 
  1220   finally show ?thesis .
  1221 qed
  1222 
  1223 lemma eq_divide_eq:
  1224   "((a::'a::{field,division_by_zero}) = b/c) = (if c\<noteq>0 then a*c = b else a=0)"
  1225 by (simp add: nonzero_eq_divide_eq) 
  1226 
  1227 lemma nonzero_divide_eq_eq: "c\<noteq>0 ==> (b/c = (a::'a::field)) = (b = a*c)"
  1228 proof -
  1229   assume [simp]: "c\<noteq>0"
  1230   have "(b/c = a) = ((b/c)*c = a*c)"
  1231     by (simp add: field_mult_cancel_right)
  1232   also have "... = (b = a*c)"
  1233     by (simp add: divide_inverse mult_assoc) 
  1234   finally show ?thesis .
  1235 qed
  1236 
  1237 lemma divide_eq_eq:
  1238   "(b/c = (a::'a::{field,division_by_zero})) = (if c\<noteq>0 then b = a*c else a=0)"
  1239 by (force simp add: nonzero_divide_eq_eq) 
  1240 
  1241 subsection{*Cancellation Laws for Division*}
  1242 
  1243 lemma divide_cancel_right [simp]:
  1244      "(a/c = b/c) = (c = 0 | a = (b::'a::{field,division_by_zero}))"
  1245 apply (case_tac "c=0", simp) 
  1246 apply (simp add: divide_inverse field_mult_cancel_right) 
  1247 done
  1248 
  1249 lemma divide_cancel_left [simp]:
  1250      "(c/a = c/b) = (c = 0 | a = (b::'a::{field,division_by_zero}))" 
  1251 apply (case_tac "c=0", simp) 
  1252 apply (simp add: divide_inverse field_mult_cancel_left) 
  1253 done
  1254 
  1255 subsection {* Division and the Number One *}
  1256 
  1257 text{*Simplify expressions equated with 1*}
  1258 lemma divide_eq_1_iff [simp]:
  1259      "(a/b = 1) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
  1260 apply (case_tac "b=0", simp) 
  1261 apply (simp add: right_inverse_eq) 
  1262 done
  1263 
  1264 
  1265 lemma one_eq_divide_iff [simp]:
  1266      "(1 = a/b) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
  1267 by (simp add: eq_commute [of 1])  
  1268 
  1269 lemma zero_eq_1_divide_iff [simp]:
  1270      "((0::'a::{ordered_field,division_by_zero}) = 1/a) = (a = 0)"
  1271 apply (case_tac "a=0", simp) 
  1272 apply (auto simp add: nonzero_eq_divide_eq) 
  1273 done
  1274 
  1275 lemma one_divide_eq_0_iff [simp]:
  1276      "(1/a = (0::'a::{ordered_field,division_by_zero})) = (a = 0)"
  1277 apply (case_tac "a=0", simp) 
  1278 apply (insert zero_neq_one [THEN not_sym]) 
  1279 apply (auto simp add: nonzero_divide_eq_eq) 
  1280 done
  1281 
  1282 text{*Simplify expressions such as @{text "0 < 1/x"} to @{text "0 < x"}*}
  1283 declare zero_less_divide_iff [of "1", simp]
  1284 declare divide_less_0_iff [of "1", simp]
  1285 declare zero_le_divide_iff [of "1", simp]
  1286 declare divide_le_0_iff [of "1", simp]
  1287 
  1288 
  1289 subsection {* Ordering Rules for Division *}
  1290 
  1291 lemma divide_strict_right_mono:
  1292      "[|a < b; 0 < c|] ==> a / c < b / (c::'a::ordered_field)"
  1293 by (simp add: order_less_imp_not_eq2 divide_inverse mult_strict_right_mono 
  1294               positive_imp_inverse_positive) 
  1295 
  1296 lemma divide_right_mono:
  1297      "[|a \<le> b; 0 \<le> c|] ==> a/c \<le> b/(c::'a::{ordered_field,division_by_zero})"
  1298   by (force simp add: divide_strict_right_mono order_le_less) 
  1299 
  1300 
  1301 text{*The last premise ensures that @{term a} and @{term b} 
  1302       have the same sign*}
  1303 lemma divide_strict_left_mono:
  1304        "[|b < a; 0 < c; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)"
  1305 by (force simp add: zero_less_mult_iff divide_inverse mult_strict_left_mono 
  1306       order_less_imp_not_eq order_less_imp_not_eq2  
  1307       less_imp_inverse_less less_imp_inverse_less_neg) 
  1308 
  1309 lemma divide_left_mono:
  1310      "[|b \<le> a; 0 \<le> c; 0 < a*b|] ==> c / a \<le> c / (b::'a::ordered_field)"
  1311   apply (subgoal_tac "a \<noteq> 0 & b \<noteq> 0") 
  1312    prefer 2 
  1313    apply (force simp add: zero_less_mult_iff order_less_imp_not_eq) 
  1314   apply (case_tac "c=0", simp add: divide_inverse)
  1315   apply (force simp add: divide_strict_left_mono order_le_less) 
  1316   done
  1317 
  1318 lemma divide_strict_left_mono_neg:
  1319      "[|a < b; c < 0; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)"
  1320   apply (subgoal_tac "a \<noteq> 0 & b \<noteq> 0") 
  1321    prefer 2 
  1322    apply (force simp add: zero_less_mult_iff order_less_imp_not_eq) 
  1323   apply (drule divide_strict_left_mono [of _ _ "-c"]) 
  1324    apply (simp_all add: mult_commute nonzero_minus_divide_left [symmetric]) 
  1325   done
  1326 
  1327 lemma divide_strict_right_mono_neg:
  1328      "[|b < a; c < 0|] ==> a / c < b / (c::'a::ordered_field)"
  1329 apply (drule divide_strict_right_mono [of _ _ "-c"], simp) 
  1330 apply (simp add: order_less_imp_not_eq nonzero_minus_divide_right [symmetric]) 
  1331 done
  1332 
  1333 
  1334 subsection {* Ordered Fields are Dense *}
  1335 
  1336 lemma less_add_one: "a < (a+1::'a::ordered_semidom)"
  1337 proof -
  1338   have "a+0 < (a+1::'a::ordered_semidom)"
  1339     by (blast intro: zero_less_one add_strict_left_mono) 
  1340   thus ?thesis by simp
  1341 qed
  1342 
  1343 lemma zero_less_two: "0 < (1+1::'a::ordered_semidom)"
  1344   by (blast intro: order_less_trans zero_less_one less_add_one) 
  1345 
  1346 lemma less_half_sum: "a < b ==> a < (a+b) / (1+1::'a::ordered_field)"
  1347 by (simp add: zero_less_two pos_less_divide_eq right_distrib) 
  1348 
  1349 lemma gt_half_sum: "a < b ==> (a+b)/(1+1::'a::ordered_field) < b"
  1350 by (simp add: zero_less_two pos_divide_less_eq right_distrib) 
  1351 
  1352 lemma dense: "a < b ==> \<exists>r::'a::ordered_field. a < r & r < b"
  1353 by (blast intro!: less_half_sum gt_half_sum)
  1354 
  1355 subsection {* Absolute Value *}
  1356 
  1357 lemma abs_one [simp]: "abs 1 = (1::'a::ordered_idom)"
  1358   by (simp add: abs_if zero_less_one [THEN order_less_not_sym]) 
  1359 
  1360 lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lordered_ring))" 
  1361 proof -
  1362   let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b"
  1363   let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
  1364   have a: "(abs a) * (abs b) = ?x"
  1365     by (simp only: abs_prts[of a] abs_prts[of b] ring_eq_simps)
  1366   {
  1367     fix u v :: 'a
  1368     have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow> u * v = ?y"
  1369       apply (subst prts[of u], subst prts[of v])
  1370       apply (simp add: left_distrib right_distrib add_ac) 
  1371       done
  1372   }
  1373   note b = this[OF refl[of a] refl[of b]]
  1374   note addm = add_mono[of "0::'a" _ "0::'a", simplified]
  1375   note addm2 = add_mono[of _ "0::'a" _ "0::'a", simplified]
  1376   have xy: "- ?x <= ?y"
  1377     apply (simp)
  1378     apply (rule_tac y="0::'a" in order_trans)
  1379     apply (rule addm2)+
  1380     apply (simp_all add: mult_pos_le mult_neg_le)
  1381     apply (rule addm)+
  1382     apply (simp_all add: mult_pos_le mult_neg_le)
  1383     done
  1384   have yx: "?y <= ?x"
  1385     apply (simp add: add_ac)
  1386     apply (rule_tac y=0 in order_trans)
  1387     apply (rule addm2, (simp add: mult_pos_neg_le mult_pos_neg2_le)+)
  1388     apply (rule addm, (simp add: mult_pos_neg_le mult_pos_neg2_le)+)
  1389     done
  1390   have i1: "a*b <= abs a * abs b" by (simp only: a b yx)
  1391   have i2: "- (abs a * abs b) <= a*b" by (simp only: a b xy)
  1392   show ?thesis
  1393     apply (rule abs_leI)
  1394     apply (simp add: i1)
  1395     apply (simp add: i2[simplified minus_le_iff])
  1396     done
  1397 qed
  1398 
  1399 lemma abs_eq_mult: 
  1400   assumes "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0)"
  1401   shows "abs (a*b) = abs a * abs (b::'a::lordered_ring)"
  1402 proof -
  1403   have s: "(0 <= a*b) | (a*b <= 0)"
  1404     apply (auto)    
  1405     apply (rule_tac split_mult_pos_le)
  1406     apply (rule_tac contrapos_np[of "a*b <= 0"])
  1407     apply (simp)
  1408     apply (rule_tac split_mult_neg_le)
  1409     apply (insert prems)
  1410     apply (blast)
  1411     done
  1412   have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
  1413     by (simp add: prts[symmetric])
  1414   show ?thesis
  1415   proof cases
  1416     assume "0 <= a * b"
  1417     then show ?thesis
  1418       apply (simp_all add: mulprts abs_prts)
  1419       apply (simp add: 
  1420 	iff2imp[OF zero_le_iff_zero_nprt]
  1421 	iff2imp[OF le_zero_iff_pprt_id]
  1422       )
  1423       apply (insert prems)
  1424       apply (auto simp add: 
  1425 	ring_eq_simps 
  1426 	iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_zero_pprt]
  1427 	iff2imp[OF le_zero_iff_pprt_id] iff2imp[OF zero_le_iff_nprt_id] 
  1428 	order_antisym mult_pos_neg_le[of a b] mult_pos_neg2_le[of b a])
  1429       done
  1430   next
  1431     assume "~(0 <= a*b)"
  1432     with s have "a*b <= 0" by simp
  1433     then show ?thesis
  1434       apply (simp_all add: mulprts abs_prts)
  1435       apply (insert prems)
  1436       apply (auto simp add: ring_eq_simps iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_zero_pprt]
  1437 	iff2imp[OF le_zero_iff_pprt_id] iff2imp[OF zero_le_iff_nprt_id] order_antisym mult_pos_le[of a b] mult_neg_le[of a b])
  1438       done
  1439   qed
  1440 qed
  1441 
  1442 lemma abs_mult: "abs (a * b) = abs a * abs (b::'a::ordered_idom)" 
  1443 by (simp add: abs_eq_mult linorder_linear)
  1444 
  1445 lemma abs_mult_self: "abs a * abs a = a * (a::'a::ordered_idom)"
  1446 by (simp add: abs_if) 
  1447 
  1448 lemma nonzero_abs_inverse:
  1449      "a \<noteq> 0 ==> abs (inverse (a::'a::ordered_field)) = inverse (abs a)"
  1450 apply (auto simp add: linorder_neq_iff abs_if nonzero_inverse_minus_eq 
  1451                       negative_imp_inverse_negative)
  1452 apply (blast intro: positive_imp_inverse_positive elim: order_less_asym) 
  1453 done
  1454 
  1455 lemma abs_inverse [simp]:
  1456      "abs (inverse (a::'a::{ordered_field,division_by_zero})) = 
  1457       inverse (abs a)"
  1458 apply (case_tac "a=0", simp) 
  1459 apply (simp add: nonzero_abs_inverse) 
  1460 done
  1461 
  1462 lemma nonzero_abs_divide:
  1463      "b \<noteq> 0 ==> abs (a / (b::'a::ordered_field)) = abs a / abs b"
  1464 by (simp add: divide_inverse abs_mult nonzero_abs_inverse) 
  1465 
  1466 lemma abs_divide:
  1467      "abs (a / (b::'a::{ordered_field,division_by_zero})) = abs a / abs b"
  1468 apply (case_tac "b=0", simp) 
  1469 apply (simp add: nonzero_abs_divide) 
  1470 done
  1471 
  1472 lemma abs_mult_less:
  1473      "[| abs a < c; abs b < d |] ==> abs a * abs b < c*(d::'a::ordered_idom)"
  1474 proof -
  1475   assume ac: "abs a < c"
  1476   hence cpos: "0<c" by (blast intro: order_le_less_trans abs_ge_zero)
  1477   assume "abs b < d"
  1478   thus ?thesis by (simp add: ac cpos mult_strict_mono) 
  1479 qed
  1480 
  1481 lemma eq_minus_self_iff: "(a = -a) = (a = (0::'a::ordered_idom))"
  1482 by (force simp add: order_eq_iff le_minus_self_iff minus_le_self_iff)
  1483 
  1484 lemma less_minus_self_iff: "(a < -a) = (a < (0::'a::ordered_idom))"
  1485 by (simp add: order_less_le le_minus_self_iff eq_minus_self_iff)
  1486 
  1487 lemma abs_less_iff: "(abs a < b) = (a < b & -a < (b::'a::ordered_idom))" 
  1488 apply (simp add: order_less_le abs_le_iff)  
  1489 apply (auto simp add: abs_if minus_le_self_iff eq_minus_self_iff)
  1490 apply (simp add: le_minus_self_iff linorder_neq_iff) 
  1491 done
  1492 
  1493 text{*Moving this up spoils many proofs using @{text mult_le_cancel_right}*}
  1494 declare times_divide_eq_left [simp]
  1495 
  1496 ML {*
  1497 val left_distrib = thm "left_distrib";
  1498 val right_distrib = thm "right_distrib";
  1499 val mult_commute = thm "mult_commute";
  1500 val distrib = thm "distrib";
  1501 val zero_neq_one = thm "zero_neq_one";
  1502 val no_zero_divisors = thm "no_zero_divisors";
  1503 val left_inverse = thm "left_inverse";
  1504 val divide_inverse = thm "divide_inverse";
  1505 val mult_zero_left = thm "mult_zero_left";
  1506 val mult_zero_right = thm "mult_zero_right";
  1507 val field_mult_eq_0_iff = thm "field_mult_eq_0_iff";
  1508 val inverse_zero = thm "inverse_zero";
  1509 val ring_distrib = thms "ring_distrib";
  1510 val combine_common_factor = thm "combine_common_factor";
  1511 val minus_mult_left = thm "minus_mult_left";
  1512 val minus_mult_right = thm "minus_mult_right";
  1513 val minus_mult_minus = thm "minus_mult_minus";
  1514 val minus_mult_commute = thm "minus_mult_commute";
  1515 val right_diff_distrib = thm "right_diff_distrib";
  1516 val left_diff_distrib = thm "left_diff_distrib";
  1517 val mult_left_mono = thm "mult_left_mono";
  1518 val mult_right_mono = thm "mult_right_mono";
  1519 val mult_strict_left_mono = thm "mult_strict_left_mono";
  1520 val mult_strict_right_mono = thm "mult_strict_right_mono";
  1521 val mult_mono = thm "mult_mono";
  1522 val mult_strict_mono = thm "mult_strict_mono";
  1523 val abs_if = thm "abs_if";
  1524 val zero_less_one = thm "zero_less_one";
  1525 val eq_add_iff1 = thm "eq_add_iff1";
  1526 val eq_add_iff2 = thm "eq_add_iff2";
  1527 val less_add_iff1 = thm "less_add_iff1";
  1528 val less_add_iff2 = thm "less_add_iff2";
  1529 val le_add_iff1 = thm "le_add_iff1";
  1530 val le_add_iff2 = thm "le_add_iff2";
  1531 val mult_left_le_imp_le = thm "mult_left_le_imp_le";
  1532 val mult_right_le_imp_le = thm "mult_right_le_imp_le";
  1533 val mult_left_less_imp_less = thm "mult_left_less_imp_less";
  1534 val mult_right_less_imp_less = thm "mult_right_less_imp_less";
  1535 val mult_strict_left_mono_neg = thm "mult_strict_left_mono_neg";
  1536 val mult_left_mono_neg = thm "mult_left_mono_neg";
  1537 val mult_strict_right_mono_neg = thm "mult_strict_right_mono_neg";
  1538 val mult_right_mono_neg = thm "mult_right_mono_neg";
  1539 val mult_pos = thm "mult_pos";
  1540 val mult_pos_le = thm "mult_pos_le";
  1541 val mult_pos_neg = thm "mult_pos_neg";
  1542 val mult_pos_neg_le = thm "mult_pos_neg_le";
  1543 val mult_pos_neg2 = thm "mult_pos_neg2";
  1544 val mult_pos_neg2_le = thm "mult_pos_neg2_le";
  1545 val mult_neg = thm "mult_neg";
  1546 val mult_neg_le = thm "mult_neg_le";
  1547 val zero_less_mult_pos = thm "zero_less_mult_pos";
  1548 val zero_less_mult_pos2 = thm "zero_less_mult_pos2";
  1549 val zero_less_mult_iff = thm "zero_less_mult_iff";
  1550 val mult_eq_0_iff = thm "mult_eq_0_iff";
  1551 val zero_le_mult_iff = thm "zero_le_mult_iff";
  1552 val mult_less_0_iff = thm "mult_less_0_iff";
  1553 val mult_le_0_iff = thm "mult_le_0_iff";
  1554 val split_mult_pos_le = thm "split_mult_pos_le";
  1555 val split_mult_neg_le = thm "split_mult_neg_le";
  1556 val zero_le_square = thm "zero_le_square";
  1557 val zero_le_one = thm "zero_le_one";
  1558 val not_one_le_zero = thm "not_one_le_zero";
  1559 val not_one_less_zero = thm "not_one_less_zero";
  1560 val mult_left_mono_neg = thm "mult_left_mono_neg";
  1561 val mult_right_mono_neg = thm "mult_right_mono_neg";
  1562 val mult_strict_mono = thm "mult_strict_mono";
  1563 val mult_strict_mono' = thm "mult_strict_mono'";
  1564 val mult_mono = thm "mult_mono";
  1565 val less_1_mult = thm "less_1_mult";
  1566 val mult_less_cancel_right = thm "mult_less_cancel_right";
  1567 val mult_less_cancel_left = thm "mult_less_cancel_left";
  1568 val mult_le_cancel_right = thm "mult_le_cancel_right";
  1569 val mult_le_cancel_left = thm "mult_le_cancel_left";
  1570 val mult_less_imp_less_left = thm "mult_less_imp_less_left";
  1571 val mult_less_imp_less_right = thm "mult_less_imp_less_right";
  1572 val mult_cancel_right = thm "mult_cancel_right";
  1573 val mult_cancel_left = thm "mult_cancel_left";
  1574 val ring_eq_simps = thms "ring_eq_simps";
  1575 val right_inverse = thm "right_inverse";
  1576 val right_inverse_eq = thm "right_inverse_eq";
  1577 val nonzero_inverse_eq_divide = thm "nonzero_inverse_eq_divide";
  1578 val divide_self = thm "divide_self";
  1579 val divide_zero = thm "divide_zero";
  1580 val divide_zero_left = thm "divide_zero_left";
  1581 val inverse_eq_divide = thm "inverse_eq_divide";
  1582 val add_divide_distrib = thm "add_divide_distrib";
  1583 val field_mult_eq_0_iff = thm "field_mult_eq_0_iff";
  1584 val field_mult_cancel_right_lemma = thm "field_mult_cancel_right_lemma";
  1585 val field_mult_cancel_right = thm "field_mult_cancel_right";
  1586 val field_mult_cancel_left = thm "field_mult_cancel_left";
  1587 val nonzero_imp_inverse_nonzero = thm "nonzero_imp_inverse_nonzero";
  1588 val inverse_zero_imp_zero = thm "inverse_zero_imp_zero";
  1589 val inverse_nonzero_imp_nonzero = thm "inverse_nonzero_imp_nonzero";
  1590 val inverse_nonzero_iff_nonzero = thm "inverse_nonzero_iff_nonzero";
  1591 val nonzero_inverse_minus_eq = thm "nonzero_inverse_minus_eq";
  1592 val inverse_minus_eq = thm "inverse_minus_eq";
  1593 val nonzero_inverse_eq_imp_eq = thm "nonzero_inverse_eq_imp_eq";
  1594 val inverse_eq_imp_eq = thm "inverse_eq_imp_eq";
  1595 val inverse_eq_iff_eq = thm "inverse_eq_iff_eq";
  1596 val nonzero_inverse_inverse_eq = thm "nonzero_inverse_inverse_eq";
  1597 val inverse_inverse_eq = thm "inverse_inverse_eq";
  1598 val inverse_1 = thm "inverse_1";
  1599 val nonzero_inverse_mult_distrib = thm "nonzero_inverse_mult_distrib";
  1600 val inverse_mult_distrib = thm "inverse_mult_distrib";
  1601 val inverse_add = thm "inverse_add";
  1602 val inverse_divide = thm "inverse_divide";
  1603 val nonzero_mult_divide_cancel_left = thm "nonzero_mult_divide_cancel_left";
  1604 val mult_divide_cancel_left = thm "mult_divide_cancel_left";
  1605 val nonzero_mult_divide_cancel_right = thm "nonzero_mult_divide_cancel_right";
  1606 val mult_divide_cancel_right = thm "mult_divide_cancel_right";
  1607 val mult_divide_cancel_eq_if = thm "mult_divide_cancel_eq_if";
  1608 val divide_1 = thm "divide_1";
  1609 val times_divide_eq_right = thm "times_divide_eq_right";
  1610 val times_divide_eq_left = thm "times_divide_eq_left";
  1611 val divide_divide_eq_right = thm "divide_divide_eq_right";
  1612 val divide_divide_eq_left = thm "divide_divide_eq_left";
  1613 val nonzero_minus_divide_left = thm "nonzero_minus_divide_left";
  1614 val nonzero_minus_divide_right = thm "nonzero_minus_divide_right";
  1615 val nonzero_minus_divide_divide = thm "nonzero_minus_divide_divide";
  1616 val minus_divide_left = thm "minus_divide_left";
  1617 val minus_divide_right = thm "minus_divide_right";
  1618 val minus_divide_divide = thm "minus_divide_divide";
  1619 val diff_divide_distrib = thm "diff_divide_distrib";
  1620 val positive_imp_inverse_positive = thm "positive_imp_inverse_positive";
  1621 val negative_imp_inverse_negative = thm "negative_imp_inverse_negative";
  1622 val inverse_le_imp_le = thm "inverse_le_imp_le";
  1623 val inverse_positive_imp_positive = thm "inverse_positive_imp_positive";
  1624 val inverse_positive_iff_positive = thm "inverse_positive_iff_positive";
  1625 val inverse_negative_imp_negative = thm "inverse_negative_imp_negative";
  1626 val inverse_negative_iff_negative = thm "inverse_negative_iff_negative";
  1627 val inverse_nonnegative_iff_nonnegative = thm "inverse_nonnegative_iff_nonnegative";
  1628 val inverse_nonpositive_iff_nonpositive = thm "inverse_nonpositive_iff_nonpositive";
  1629 val less_imp_inverse_less = thm "less_imp_inverse_less";
  1630 val inverse_less_imp_less = thm "inverse_less_imp_less";
  1631 val inverse_less_iff_less = thm "inverse_less_iff_less";
  1632 val le_imp_inverse_le = thm "le_imp_inverse_le";
  1633 val inverse_le_iff_le = thm "inverse_le_iff_le";
  1634 val inverse_le_imp_le_neg = thm "inverse_le_imp_le_neg";
  1635 val less_imp_inverse_less_neg = thm "less_imp_inverse_less_neg";
  1636 val inverse_less_imp_less_neg = thm "inverse_less_imp_less_neg";
  1637 val inverse_less_iff_less_neg = thm "inverse_less_iff_less_neg";
  1638 val le_imp_inverse_le_neg = thm "le_imp_inverse_le_neg";
  1639 val inverse_le_iff_le_neg = thm "inverse_le_iff_le_neg";
  1640 val one_less_inverse_iff = thm "one_less_inverse_iff";
  1641 val inverse_eq_1_iff = thm "inverse_eq_1_iff";
  1642 val one_le_inverse_iff = thm "one_le_inverse_iff";
  1643 val inverse_less_1_iff = thm "inverse_less_1_iff";
  1644 val inverse_le_1_iff = thm "inverse_le_1_iff";
  1645 val zero_less_divide_iff = thm "zero_less_divide_iff";
  1646 val divide_less_0_iff = thm "divide_less_0_iff";
  1647 val zero_le_divide_iff = thm "zero_le_divide_iff";
  1648 val divide_le_0_iff = thm "divide_le_0_iff";
  1649 val divide_eq_0_iff = thm "divide_eq_0_iff";
  1650 val pos_le_divide_eq = thm "pos_le_divide_eq";
  1651 val neg_le_divide_eq = thm "neg_le_divide_eq";
  1652 val le_divide_eq = thm "le_divide_eq";
  1653 val pos_divide_le_eq = thm "pos_divide_le_eq";
  1654 val neg_divide_le_eq = thm "neg_divide_le_eq";
  1655 val divide_le_eq = thm "divide_le_eq";
  1656 val pos_less_divide_eq = thm "pos_less_divide_eq";
  1657 val neg_less_divide_eq = thm "neg_less_divide_eq";
  1658 val less_divide_eq = thm "less_divide_eq";
  1659 val pos_divide_less_eq = thm "pos_divide_less_eq";
  1660 val neg_divide_less_eq = thm "neg_divide_less_eq";
  1661 val divide_less_eq = thm "divide_less_eq";
  1662 val nonzero_eq_divide_eq = thm "nonzero_eq_divide_eq";
  1663 val eq_divide_eq = thm "eq_divide_eq";
  1664 val nonzero_divide_eq_eq = thm "nonzero_divide_eq_eq";
  1665 val divide_eq_eq = thm "divide_eq_eq";
  1666 val divide_cancel_right = thm "divide_cancel_right";
  1667 val divide_cancel_left = thm "divide_cancel_left";
  1668 val divide_eq_1_iff = thm "divide_eq_1_iff";
  1669 val one_eq_divide_iff = thm "one_eq_divide_iff";
  1670 val zero_eq_1_divide_iff = thm "zero_eq_1_divide_iff";
  1671 val one_divide_eq_0_iff = thm "one_divide_eq_0_iff";
  1672 val divide_strict_right_mono = thm "divide_strict_right_mono";
  1673 val divide_right_mono = thm "divide_right_mono";
  1674 val divide_strict_left_mono = thm "divide_strict_left_mono";
  1675 val divide_left_mono = thm "divide_left_mono";
  1676 val divide_strict_left_mono_neg = thm "divide_strict_left_mono_neg";
  1677 val divide_strict_right_mono_neg = thm "divide_strict_right_mono_neg";
  1678 val less_add_one = thm "less_add_one";
  1679 val zero_less_two = thm "zero_less_two";
  1680 val less_half_sum = thm "less_half_sum";
  1681 val gt_half_sum = thm "gt_half_sum";
  1682 val dense = thm "dense";
  1683 val abs_one = thm "abs_one";
  1684 val abs_le_mult = thm "abs_le_mult";
  1685 val abs_eq_mult = thm "abs_eq_mult";
  1686 val abs_mult = thm "abs_mult";
  1687 val abs_mult_self = thm "abs_mult_self";
  1688 val nonzero_abs_inverse = thm "nonzero_abs_inverse";
  1689 val abs_inverse = thm "abs_inverse";
  1690 val nonzero_abs_divide = thm "nonzero_abs_divide";
  1691 val abs_divide = thm "abs_divide";
  1692 val abs_mult_less = thm "abs_mult_less";
  1693 val eq_minus_self_iff = thm "eq_minus_self_iff";
  1694 val less_minus_self_iff = thm "less_minus_self_iff";
  1695 val abs_less_iff = thm "abs_less_iff";
  1696 *}
  1697 
  1698 end