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