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