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