src/HOL/Ring_and_Field.thy
author paulson
Tue Nov 25 10:37:03 2003 +0100 (2003-11-25)
changeset 14267 b963e9cee2a0
parent 14266 08b34c902618
child 14268 5cf13e80be0e
permissions -rw-r--r--
More refinements to Ring_and_Field and numerics. Conversion of Divides_lemmas
to Isar script.
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@14265
     4
    License: GPL (GNU GENERAL PUBLIC LICENSE)
paulson@14265
     5
*)
paulson@14265
     6
paulson@14265
     7
header {*
paulson@14265
     8
  \title{Ring and field structures}
paulson@14265
     9
  \author{Gertrud Bauer and Markus Wenzel}
paulson@14265
    10
*}
paulson@14265
    11
paulson@14265
    12
theory Ring_and_Field = Inductive:
paulson@14265
    13
paulson@14265
    14
text{*Lemmas and extension to semirings by L. C. Paulson*}
paulson@14265
    15
paulson@14265
    16
subsection {* Abstract algebraic structures *}
paulson@14265
    17
paulson@14265
    18
axclass semiring \<subseteq> zero, one, plus, times
paulson@14265
    19
  add_assoc: "(a + b) + c = a + (b + c)"
paulson@14265
    20
  add_commute: "a + b = b + a"
paulson@14265
    21
  left_zero [simp]: "0 + a = a"
paulson@14265
    22
paulson@14265
    23
  mult_assoc: "(a * b) * c = a * (b * c)"
paulson@14265
    24
  mult_commute: "a * b = b * a"
paulson@14267
    25
  mult_1 [simp]: "1 * a = a"
paulson@14265
    26
paulson@14265
    27
  left_distrib: "(a + b) * c = a * c + b * c"
paulson@14265
    28
  zero_neq_one [simp]: "0 \<noteq> 1"
paulson@14265
    29
paulson@14265
    30
axclass ring \<subseteq> semiring, minus
paulson@14265
    31
  left_minus [simp]: "- a + a = 0"
paulson@14265
    32
  diff_minus: "a - b = a + (-b)"
paulson@14265
    33
paulson@14265
    34
axclass ordered_semiring \<subseteq> semiring, linorder
paulson@14265
    35
  add_left_mono: "a \<le> b ==> c + a \<le> c + b"
paulson@14265
    36
  mult_strict_left_mono: "a < b ==> 0 < c ==> c * a < c * b"
paulson@14265
    37
paulson@14265
    38
axclass ordered_ring \<subseteq> ordered_semiring, ring
paulson@14265
    39
  abs_if: "\<bar>a\<bar> = (if a < 0 then -a else a)"
paulson@14265
    40
paulson@14265
    41
axclass field \<subseteq> ring, inverse
paulson@14265
    42
  left_inverse [simp]: "a \<noteq> 0 ==> inverse a * a = 1"
paulson@14265
    43
  divide_inverse:      "b \<noteq> 0 ==> a / b = a * inverse b"
paulson@14265
    44
paulson@14265
    45
axclass ordered_field \<subseteq> ordered_ring, field
paulson@14265
    46
paulson@14265
    47
axclass division_by_zero \<subseteq> zero, inverse
paulson@14265
    48
  inverse_zero: "inverse 0 = 0"
paulson@14265
    49
  divide_zero: "a / 0 = 0"
paulson@14265
    50
paulson@14265
    51
paulson@14265
    52
subsection {* Derived rules for addition *}
paulson@14265
    53
paulson@14265
    54
lemma right_zero [simp]: "a + 0 = (a::'a::semiring)"
paulson@14265
    55
proof -
paulson@14265
    56
  have "a + 0 = 0 + a" by (simp only: add_commute)
paulson@14265
    57
  also have "... = a" by simp
paulson@14265
    58
  finally show ?thesis .
paulson@14265
    59
qed
paulson@14265
    60
paulson@14265
    61
lemma add_left_commute: "a + (b + c) = b + (a + (c::'a::semiring))"
paulson@14265
    62
  by (rule mk_left_commute [of "op +", OF add_assoc add_commute])
paulson@14265
    63
paulson@14265
    64
theorems add_ac = add_assoc add_commute add_left_commute
paulson@14265
    65
paulson@14265
    66
lemma right_minus [simp]: "a + -(a::'a::ring) = 0"
paulson@14265
    67
proof -
paulson@14265
    68
  have "a + -a = -a + a" by (simp add: add_ac)
paulson@14265
    69
  also have "... = 0" by simp
paulson@14265
    70
  finally show ?thesis .
paulson@14265
    71
qed
paulson@14265
    72
paulson@14265
    73
lemma right_minus_eq: "(a - b = 0) = (a = (b::'a::ring))"
paulson@14265
    74
proof
paulson@14265
    75
  have "a = a - b + b" by (simp add: diff_minus add_ac)
paulson@14265
    76
  also assume "a - b = 0"
paulson@14265
    77
  finally show "a = b" by simp
paulson@14265
    78
next
paulson@14265
    79
  assume "a = b"
paulson@14265
    80
  thus "a - b = 0" by (simp add: diff_minus)
paulson@14265
    81
qed
paulson@14265
    82
paulson@14265
    83
lemma diff_self [simp]: "a - (a::'a::ring) = 0"
paulson@14265
    84
  by (simp add: diff_minus)
paulson@14265
    85
paulson@14265
    86
lemma add_left_cancel [simp]:
paulson@14265
    87
     "(a + b = a + c) = (b = (c::'a::ring))"
paulson@14265
    88
proof
paulson@14265
    89
  assume eq: "a + b = a + c"
paulson@14265
    90
  then have "(-a + a) + b = (-a + a) + c"
paulson@14265
    91
    by (simp only: eq add_assoc)
paulson@14266
    92
  thus "b = c" by simp
paulson@14265
    93
next
paulson@14265
    94
  assume eq: "b = c"
paulson@14266
    95
  thus "a + b = a + c" by simp
paulson@14265
    96
qed
paulson@14265
    97
paulson@14265
    98
lemma add_right_cancel [simp]:
paulson@14265
    99
     "(b + a = c + a) = (b = (c::'a::ring))"
paulson@14265
   100
  by (simp add: add_commute)
paulson@14265
   101
paulson@14265
   102
lemma minus_minus [simp]: "- (- (a::'a::ring)) = a"
paulson@14265
   103
  proof (rule add_left_cancel [of "-a", THEN iffD1])
paulson@14265
   104
    show "(-a + -(-a) = -a + a)"
paulson@14265
   105
    by simp
paulson@14265
   106
  qed
paulson@14265
   107
paulson@14265
   108
lemma equals_zero_I: "a+b = 0 ==> -a = (b::'a::ring)"
paulson@14265
   109
apply (rule right_minus_eq [THEN iffD1, symmetric])
paulson@14265
   110
apply (simp add: diff_minus add_commute) 
paulson@14265
   111
done
paulson@14265
   112
paulson@14265
   113
lemma minus_zero [simp]: "- 0 = (0::'a::ring)"
paulson@14265
   114
by (simp add: equals_zero_I)
paulson@14265
   115
paulson@14265
   116
lemma neg_equal_iff_equal [simp]: "(-a = -b) = (a = (b::'a::ring))" 
paulson@14265
   117
  proof 
paulson@14265
   118
    assume "- a = - b"
paulson@14265
   119
    then have "- (- a) = - (- b)"
paulson@14265
   120
      by simp
paulson@14266
   121
    thus "a=b" by simp
paulson@14265
   122
  next
paulson@14265
   123
    assume "a=b"
paulson@14266
   124
    thus "-a = -b" by simp
paulson@14265
   125
  qed
paulson@14265
   126
paulson@14265
   127
lemma neg_equal_0_iff_equal [simp]: "(-a = 0) = (a = (0::'a::ring))"
paulson@14265
   128
by (subst neg_equal_iff_equal [symmetric], simp)
paulson@14265
   129
paulson@14265
   130
lemma neg_0_equal_iff_equal [simp]: "(0 = -a) = (0 = (a::'a::ring))"
paulson@14265
   131
by (subst neg_equal_iff_equal [symmetric], simp)
paulson@14265
   132
paulson@14265
   133
paulson@14265
   134
subsection {* Derived rules for multiplication *}
paulson@14265
   135
paulson@14267
   136
lemma mult_1_right [simp]: "a * (1::'a::semiring) = a"
paulson@14265
   137
proof -
paulson@14267
   138
  have "a * 1 = 1 * a" by (simp add: mult_commute)
paulson@14267
   139
  also have "... = a" by simp
paulson@14265
   140
  finally show ?thesis .
paulson@14265
   141
qed
paulson@14265
   142
paulson@14265
   143
lemma mult_left_commute: "a * (b * c) = b * (a * (c::'a::semiring))"
paulson@14265
   144
  by (rule mk_left_commute [of "op *", OF mult_assoc mult_commute])
paulson@14265
   145
paulson@14265
   146
theorems mult_ac = mult_assoc mult_commute mult_left_commute
paulson@14265
   147
paulson@14265
   148
lemma right_inverse [simp]: "a \<noteq> 0 ==>  a * inverse (a::'a::field) = 1"
paulson@14265
   149
proof -
paulson@14265
   150
  have "a * inverse a = inverse a * a" by (simp add: mult_ac)
paulson@14265
   151
  also assume "a \<noteq> 0"
paulson@14265
   152
  hence "inverse a * a = 1" by simp
paulson@14265
   153
  finally show ?thesis .
paulson@14265
   154
qed
paulson@14265
   155
paulson@14265
   156
lemma right_inverse_eq: "b \<noteq> 0 ==> (a / b = 1) = (a = (b::'a::field))"
paulson@14265
   157
proof
paulson@14265
   158
  assume neq: "b \<noteq> 0"
paulson@14265
   159
  {
paulson@14265
   160
    hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac)
paulson@14265
   161
    also assume "a / b = 1"
paulson@14265
   162
    finally show "a = b" by simp
paulson@14265
   163
  next
paulson@14265
   164
    assume "a = b"
paulson@14265
   165
    with neq show "a / b = 1" by (simp add: divide_inverse)
paulson@14265
   166
  }
paulson@14265
   167
qed
paulson@14265
   168
paulson@14265
   169
lemma divide_self [simp]: "a \<noteq> 0 ==> a / (a::'a::field) = 1"
paulson@14265
   170
  by (simp add: divide_inverse)
paulson@14265
   171
paulson@14265
   172
lemma mult_left_zero [simp]: "0 * a = (0::'a::ring)"
paulson@14265
   173
proof -
paulson@14265
   174
  have "0*a + 0*a = 0*a + 0"
paulson@14265
   175
    by (simp add: left_distrib [symmetric])
paulson@14266
   176
  thus ?thesis by (simp only: add_left_cancel)
paulson@14265
   177
qed
paulson@14265
   178
paulson@14265
   179
lemma mult_right_zero [simp]: "a * 0 = (0::'a::ring)"
paulson@14265
   180
  by (simp add: mult_commute)
paulson@14265
   181
paulson@14265
   182
paulson@14265
   183
subsection {* Distribution rules *}
paulson@14265
   184
paulson@14265
   185
lemma right_distrib: "a * (b + c) = a * b + a * (c::'a::semiring)"
paulson@14265
   186
proof -
paulson@14265
   187
  have "a * (b + c) = (b + c) * a" by (simp add: mult_ac)
paulson@14265
   188
  also have "... = b * a + c * a" by (simp only: left_distrib)
paulson@14265
   189
  also have "... = a * b + a * c" by (simp add: mult_ac)
paulson@14265
   190
  finally show ?thesis .
paulson@14265
   191
qed
paulson@14265
   192
paulson@14265
   193
theorems ring_distrib = right_distrib left_distrib
paulson@14265
   194
paulson@14265
   195
lemma minus_add_distrib [simp]: "- (a + b) = -a + -(b::'a::ring)"
paulson@14265
   196
apply (rule equals_zero_I)
paulson@14265
   197
apply (simp add: add_ac) 
paulson@14265
   198
done
paulson@14265
   199
paulson@14265
   200
lemma minus_mult_left: "- (a * b) = (-a) * (b::'a::ring)"
paulson@14265
   201
apply (rule equals_zero_I)
paulson@14265
   202
apply (simp add: left_distrib [symmetric]) 
paulson@14265
   203
done
paulson@14265
   204
paulson@14265
   205
lemma minus_mult_right: "- (a * b) = a * -(b::'a::ring)"
paulson@14265
   206
apply (rule equals_zero_I)
paulson@14265
   207
apply (simp add: right_distrib [symmetric]) 
paulson@14265
   208
done
paulson@14265
   209
paulson@14265
   210
lemma right_diff_distrib: "a * (b - c) = a * b - a * (c::'a::ring)"
paulson@14265
   211
by (simp add: right_distrib diff_minus 
paulson@14265
   212
              minus_mult_left [symmetric] minus_mult_right [symmetric]) 
paulson@14265
   213
paulson@14265
   214
paulson@14265
   215
subsection {* Ordering rules *}
paulson@14265
   216
paulson@14265
   217
lemma add_right_mono: "a \<le> (b::'a::ordered_semiring) ==> a + c \<le> b + c"
paulson@14265
   218
by (simp add: add_commute [of _ c] add_left_mono)
paulson@14265
   219
paulson@14267
   220
text {* non-strict, in both arguments *}
paulson@14267
   221
lemma add_mono: "[|a \<le> b;  c \<le> d|] ==> a + c \<le> b + (d::'a::ordered_semiring)"
paulson@14267
   222
  apply (erule add_right_mono [THEN order_trans])
paulson@14267
   223
  apply (simp add: add_commute add_left_mono)
paulson@14267
   224
  done
paulson@14267
   225
paulson@14265
   226
lemma le_imp_neg_le:
paulson@14265
   227
   assumes "a \<le> (b::'a::ordered_ring)" shows "-b \<le> -a"
paulson@14265
   228
  proof -
paulson@14265
   229
  have "-a+a \<le> -a+b"
paulson@14265
   230
    by (rule add_left_mono) 
paulson@14265
   231
  then have "0 \<le> -a+b"
paulson@14265
   232
    by simp
paulson@14265
   233
  then have "0 + (-b) \<le> (-a + b) + (-b)"
paulson@14265
   234
    by (rule add_right_mono) 
paulson@14266
   235
  thus ?thesis
paulson@14265
   236
    by (simp add: add_assoc)
paulson@14265
   237
  qed
paulson@14265
   238
paulson@14265
   239
lemma neg_le_iff_le [simp]: "(-b \<le> -a) = (a \<le> (b::'a::ordered_ring))"
paulson@14265
   240
  proof 
paulson@14265
   241
    assume "- b \<le> - a"
paulson@14265
   242
    then have "- (- a) \<le> - (- b)"
paulson@14265
   243
      by (rule le_imp_neg_le)
paulson@14266
   244
    thus "a\<le>b" by simp
paulson@14265
   245
  next
paulson@14265
   246
    assume "a\<le>b"
paulson@14266
   247
    thus "-b \<le> -a" by (rule le_imp_neg_le)
paulson@14265
   248
  qed
paulson@14265
   249
paulson@14265
   250
lemma neg_le_0_iff_le [simp]: "(-a \<le> 0) = (0 \<le> (a::'a::ordered_ring))"
paulson@14265
   251
by (subst neg_le_iff_le [symmetric], simp)
paulson@14265
   252
paulson@14265
   253
lemma neg_0_le_iff_le [simp]: "(0 \<le> -a) = (a \<le> (0::'a::ordered_ring))"
paulson@14265
   254
by (subst neg_le_iff_le [symmetric], simp)
paulson@14265
   255
paulson@14265
   256
lemma neg_less_iff_less [simp]: "(-b < -a) = (a < (b::'a::ordered_ring))"
paulson@14265
   257
by (force simp add: order_less_le) 
paulson@14265
   258
paulson@14265
   259
lemma neg_less_0_iff_less [simp]: "(-a < 0) = (0 < (a::'a::ordered_ring))"
paulson@14265
   260
by (subst neg_less_iff_less [symmetric], simp)
paulson@14265
   261
paulson@14265
   262
lemma neg_0_less_iff_less [simp]: "(0 < -a) = (a < (0::'a::ordered_ring))"
paulson@14265
   263
by (subst neg_less_iff_less [symmetric], simp)
paulson@14265
   264
paulson@14265
   265
lemma mult_strict_right_mono:
paulson@14265
   266
     "[|a < b; 0 < c|] ==> a * c < b * (c::'a::ordered_semiring)"
paulson@14265
   267
by (simp add: mult_commute [of _ c] mult_strict_left_mono)
paulson@14265
   268
paulson@14265
   269
lemma mult_left_mono:
paulson@14267
   270
     "[|a \<le> b; 0 \<le> c|] ==> c * a \<le> c * (b::'a::ordered_ring)"
paulson@14267
   271
  apply (case_tac "c=0", simp)
paulson@14267
   272
  apply (force simp add: mult_strict_left_mono order_le_less) 
paulson@14267
   273
  done
paulson@14265
   274
paulson@14265
   275
lemma mult_right_mono:
paulson@14267
   276
     "[|a \<le> b; 0 \<le> c|] ==> a*c \<le> b * (c::'a::ordered_ring)"
paulson@14267
   277
  by (simp add: mult_left_mono mult_commute [of _ c]) 
paulson@14265
   278
paulson@14265
   279
lemma mult_strict_left_mono_neg:
paulson@14265
   280
     "[|b < a; c < 0|] ==> c * a < c * (b::'a::ordered_ring)"
paulson@14265
   281
apply (drule mult_strict_left_mono [of _ _ "-c"])
paulson@14265
   282
apply (simp_all add: minus_mult_left [symmetric]) 
paulson@14265
   283
done
paulson@14265
   284
paulson@14265
   285
lemma mult_strict_right_mono_neg:
paulson@14265
   286
     "[|b < a; c < 0|] ==> a * c < b * (c::'a::ordered_ring)"
paulson@14265
   287
apply (drule mult_strict_right_mono [of _ _ "-c"])
paulson@14265
   288
apply (simp_all add: minus_mult_right [symmetric]) 
paulson@14265
   289
done
paulson@14265
   290
paulson@14265
   291
lemma mult_left_mono_neg:
paulson@14267
   292
     "[|b \<le> a; c \<le> 0|] ==> c * a \<le> c * (b::'a::ordered_ring)"
paulson@14267
   293
apply (drule mult_left_mono [of _ _ "-c"]) 
paulson@14267
   294
apply (simp_all add: minus_mult_left [symmetric]) 
paulson@14267
   295
done
paulson@14265
   296
paulson@14265
   297
lemma mult_right_mono_neg:
paulson@14267
   298
     "[|b \<le> a; c \<le> 0|] ==> a * c \<le> b * (c::'a::ordered_ring)"
paulson@14267
   299
  by (simp add: mult_left_mono_neg mult_commute [of _ c]) 
paulson@14265
   300
paulson@14266
   301
text{*Strict monotonicity in both arguments*}
paulson@14266
   302
lemma mult_strict_mono:
paulson@14266
   303
     "[|a<b; c<d; 0<b; 0<c|] ==> a * c < b * (d::'a::ordered_semiring)"
paulson@14266
   304
apply (erule mult_strict_right_mono [THEN order_less_trans], assumption)
paulson@14266
   305
apply (erule mult_strict_left_mono, assumption)
paulson@14266
   306
done
paulson@14266
   307
paulson@14267
   308
lemma mult_mono:
paulson@14267
   309
     "[|a \<le> b; c \<le> d; 0 \<le> b; 0 \<le> c|] 
paulson@14267
   310
      ==> a * c  \<le>  b * (d::'a::ordered_ring)"
paulson@14267
   311
apply (erule mult_right_mono [THEN order_trans], assumption)
paulson@14267
   312
apply (erule mult_left_mono, assumption)
paulson@14267
   313
done
paulson@14267
   314
paulson@14267
   315
paulson@14266
   316
subsection{*Cancellation Laws for Relationships With a Common Factor*}
paulson@14266
   317
paulson@14266
   318
text{*Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"},
paulson@14266
   319
   also with the relations @{text "\<le>"} and equality.*}
paulson@14266
   320
paulson@14266
   321
lemma mult_less_cancel_right:
paulson@14266
   322
    "(a*c < b*c) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring)))"
paulson@14266
   323
apply (case_tac "c = 0")
paulson@14266
   324
apply (auto simp add: linorder_neq_iff mult_strict_right_mono 
paulson@14266
   325
                      mult_strict_right_mono_neg)
paulson@14266
   326
apply (auto simp add: linorder_not_less 
paulson@14266
   327
                      linorder_not_le [symmetric, of "a*c"]
paulson@14266
   328
                      linorder_not_le [symmetric, of a])
paulson@14266
   329
apply (erule_tac [!] notE)
paulson@14266
   330
apply (auto simp add: order_less_imp_le mult_right_mono 
paulson@14266
   331
                      mult_right_mono_neg)
paulson@14266
   332
done
paulson@14266
   333
paulson@14266
   334
lemma mult_less_cancel_left:
paulson@14266
   335
    "(c*a < c*b) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring)))"
paulson@14266
   336
by (simp add: mult_commute [of c] mult_less_cancel_right)
paulson@14266
   337
paulson@14266
   338
lemma mult_le_cancel_right:
paulson@14266
   339
     "(a*c \<le> b*c) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring)))"
paulson@14266
   340
by (simp add: linorder_not_less [symmetric] mult_less_cancel_right)
paulson@14266
   341
paulson@14266
   342
lemma mult_le_cancel_left:
paulson@14266
   343
     "(c*a \<le> c*b) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring)))"
paulson@14266
   344
by (simp add: mult_commute [of c] mult_le_cancel_right)
paulson@14266
   345
paulson@14266
   346
text{*Cancellation of equalities with a common factor*}
paulson@14266
   347
lemma mult_cancel_right [simp]:
paulson@14266
   348
     "(a*c = b*c) = (c = (0::'a::ordered_ring) | a=b)"
paulson@14266
   349
apply (cut_tac linorder_less_linear [of 0 c])
paulson@14266
   350
apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono
paulson@14266
   351
             simp add: linorder_neq_iff)
paulson@14266
   352
done
paulson@14266
   353
paulson@14266
   354
lemma mult_cancel_left [simp]:
paulson@14266
   355
     "(c*a = c*b) = (c = (0::'a::ordered_ring) | a=b)"
paulson@14266
   356
by (simp add: mult_commute [of c] mult_cancel_right)
paulson@14266
   357
paulson@14265
   358
paulson@14265
   359
subsection{* Products of Signs *}
paulson@14265
   360
paulson@14265
   361
lemma mult_pos: "[| (0::'a::ordered_ring) < a; 0 < b |] ==> 0 < a*b"
paulson@14265
   362
by (drule mult_strict_left_mono [of 0 b], auto)
paulson@14265
   363
paulson@14265
   364
lemma mult_pos_neg: "[| (0::'a::ordered_ring) < a; b < 0 |] ==> a*b < 0"
paulson@14265
   365
by (drule mult_strict_left_mono [of b 0], auto)
paulson@14265
   366
paulson@14265
   367
lemma mult_neg: "[| a < (0::'a::ordered_ring); b < 0 |] ==> 0 < a*b"
paulson@14265
   368
by (drule mult_strict_right_mono_neg, auto)
paulson@14265
   369
paulson@14265
   370
lemma zero_less_mult_pos: "[| 0 < a*b; 0 < a|] ==> 0 < (b::'a::ordered_ring)"
paulson@14265
   371
apply (case_tac "b\<le>0") 
paulson@14265
   372
 apply (auto simp add: order_le_less linorder_not_less)
paulson@14265
   373
apply (drule_tac mult_pos_neg [of a b]) 
paulson@14265
   374
 apply (auto dest: order_less_not_sym)
paulson@14265
   375
done
paulson@14265
   376
paulson@14265
   377
lemma zero_less_mult_iff:
paulson@14265
   378
     "((0::'a::ordered_ring) < a*b) = (0 < a & 0 < b | a < 0 & b < 0)"
paulson@14265
   379
apply (auto simp add: order_le_less linorder_not_less mult_pos mult_neg)
paulson@14265
   380
apply (blast dest: zero_less_mult_pos) 
paulson@14265
   381
apply (simp add: mult_commute [of a b]) 
paulson@14265
   382
apply (blast dest: zero_less_mult_pos) 
paulson@14265
   383
done
paulson@14265
   384
paulson@14266
   385
lemma mult_eq_0_iff [simp]: "(a*b = (0::'a::ordered_ring)) = (a = 0 | b = 0)"
paulson@14265
   386
apply (case_tac "a < 0")
paulson@14265
   387
apply (auto simp add: linorder_not_less order_le_less linorder_neq_iff)
paulson@14265
   388
apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono)+
paulson@14265
   389
done
paulson@14265
   390
paulson@14265
   391
lemma zero_le_mult_iff:
paulson@14265
   392
     "((0::'a::ordered_ring) \<le> a*b) = (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
paulson@14265
   393
by (auto simp add: eq_commute [of 0] order_le_less linorder_not_less
paulson@14265
   394
                   zero_less_mult_iff)
paulson@14265
   395
paulson@14265
   396
lemma mult_less_0_iff:
paulson@14265
   397
     "(a*b < (0::'a::ordered_ring)) = (0 < a & b < 0 | a < 0 & 0 < b)"
paulson@14265
   398
apply (insert zero_less_mult_iff [of "-a" b]) 
paulson@14265
   399
apply (force simp add: minus_mult_left[symmetric]) 
paulson@14265
   400
done
paulson@14265
   401
paulson@14265
   402
lemma mult_le_0_iff:
paulson@14265
   403
     "(a*b \<le> (0::'a::ordered_ring)) = (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
paulson@14265
   404
apply (insert zero_le_mult_iff [of "-a" b]) 
paulson@14265
   405
apply (force simp add: minus_mult_left[symmetric]) 
paulson@14265
   406
done
paulson@14265
   407
paulson@14265
   408
lemma zero_le_square: "(0::'a::ordered_ring) \<le> a*a"
paulson@14265
   409
by (simp add: zero_le_mult_iff linorder_linear) 
paulson@14265
   410
paulson@14265
   411
lemma zero_less_one: "(0::'a::ordered_ring) < 1"
paulson@14265
   412
apply (insert zero_le_square [of 1]) 
paulson@14265
   413
apply (simp add: order_less_le) 
paulson@14265
   414
done
paulson@14265
   415
paulson@14265
   416
paulson@14265
   417
subsection {* Absolute Value *}
paulson@14265
   418
paulson@14265
   419
text{*But is it really better than just rewriting with @{text abs_if}?*}
paulson@14265
   420
lemma abs_split:
paulson@14265
   421
     "P(abs(a::'a::ordered_ring)) = ((0 \<le> a --> P a) & (a < 0 --> P(-a)))"
paulson@14265
   422
by (force dest: order_less_le_trans simp add: abs_if linorder_not_less)
paulson@14265
   423
paulson@14265
   424
lemma abs_zero [simp]: "abs 0 = (0::'a::ordered_ring)"
paulson@14265
   425
by (simp add: abs_if)
paulson@14265
   426
paulson@14265
   427
lemma abs_mult: "abs (x * y) = abs x * abs (y::'a::ordered_ring)" 
paulson@14265
   428
apply (case_tac "x=0 | y=0", force) 
paulson@14265
   429
apply (auto elim: order_less_asym
paulson@14265
   430
            simp add: abs_if mult_less_0_iff linorder_neq_iff
paulson@14265
   431
                  minus_mult_left [symmetric] minus_mult_right [symmetric])  
paulson@14265
   432
done
paulson@14265
   433
paulson@14266
   434
lemma abs_eq_0 [simp]: "(abs x = 0) = (x = (0::'a::ordered_ring))"
paulson@14265
   435
by (simp add: abs_if)
paulson@14265
   436
paulson@14266
   437
lemma zero_less_abs_iff [simp]: "(0 < abs x) = (x ~= (0::'a::ordered_ring))"
paulson@14265
   438
by (simp add: abs_if linorder_neq_iff)
paulson@14265
   439
paulson@14265
   440
paulson@14265
   441
subsection {* Fields *}
paulson@14265
   442
paulson@14265
   443
paulson@14265
   444
end