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