src/HOL/Ring_and_Field.thy
author haftmann
Fri Mar 09 08:45:50 2007 +0100 (2007-03-09)
changeset 22422 ee19cdb07528
parent 22390 378f34b1e380
child 22452 8a86fd2a1bf0
permissions -rw-r--r--
stepping towards uniform lattice theory development in HOL
paulson@14265
     1
(*  Title:   HOL/Ring_and_Field.thy
paulson@14265
     2
    ID:      $Id$
avigad@16775
     3
    Author:  Gertrud Bauer, Steven Obua, Lawrence C Paulson, and Markus Wenzel,
avigad@16775
     4
             with contributions by Jeremy Avigad
paulson@14265
     5
*)
paulson@14265
     6
obua@14738
     7
header {* (Ordered) Rings and Fields *}
paulson@14265
     8
paulson@15229
     9
theory Ring_and_Field
nipkow@15140
    10
imports OrderedGroup
nipkow@15131
    11
begin
paulson@14504
    12
obua@14738
    13
text {*
obua@14738
    14
  The theory of partially ordered rings is taken from the books:
obua@14738
    15
  \begin{itemize}
obua@14738
    16
  \item \emph{Lattice Theory} by Garret Birkhoff, American Mathematical Society 1979 
obua@14738
    17
  \item \emph{Partially Ordered Algebraic Systems}, Pergamon Press 1963
obua@14738
    18
  \end{itemize}
obua@14738
    19
  Most of the used notions can also be looked up in 
obua@14738
    20
  \begin{itemize}
wenzelm@14770
    21
  \item \url{http://www.mathworld.com} by Eric Weisstein et. al.
obua@14738
    22
  \item \emph{Algebra I} by van der Waerden, Springer.
obua@14738
    23
  \end{itemize}
obua@14738
    24
*}
paulson@14504
    25
haftmann@22390
    26
class semiring = ab_semigroup_add + semigroup_mult +
haftmann@22390
    27
  assumes left_distrib: "(a \<^loc>+ b) \<^loc>* c = a \<^loc>* c \<^loc>+ b \<^loc>* c"
haftmann@22390
    28
  assumes right_distrib: "a \<^loc>* (b \<^loc>+ c) = a \<^loc>* b \<^loc>+ a \<^loc>* c"
paulson@14504
    29
haftmann@22390
    30
class mult_zero = times + zero +
haftmann@22390
    31
  assumes mult_zero_left [simp]: "\<^loc>0 \<^loc>* a = \<^loc>0"
haftmann@22390
    32
  assumes mult_zero_right [simp]: "a \<^loc>* \<^loc>0 = \<^loc>0"
krauss@21199
    33
haftmann@22390
    34
class semiring_0 = semiring + comm_monoid_add + mult_zero
krauss@21199
    35
haftmann@22390
    36
class semiring_0_cancel = semiring + comm_monoid_add + cancel_ab_semigroup_add
paulson@14504
    37
krauss@21199
    38
instance semiring_0_cancel \<subseteq> semiring_0
krauss@21199
    39
proof
krauss@21199
    40
  fix a :: 'a
krauss@21199
    41
  have "0 * a + 0 * a = 0 * a + 0"
krauss@21199
    42
    by (simp add: left_distrib [symmetric])
krauss@21199
    43
  thus "0 * a = 0"
krauss@21199
    44
    by (simp only: add_left_cancel)
krauss@21199
    45
krauss@21199
    46
  have "a * 0 + a * 0 = a * 0 + 0"
krauss@21199
    47
    by (simp add: right_distrib [symmetric])
krauss@21199
    48
  thus "a * 0 = 0"
krauss@21199
    49
    by (simp only: add_left_cancel)
krauss@21199
    50
qed
obua@14940
    51
haftmann@22390
    52
class comm_semiring = ab_semigroup_add + ab_semigroup_mult +
haftmann@22390
    53
  assumes distrib: "(a \<^loc>+ b) \<^loc>* c = a \<^loc>* c \<^loc>+ b \<^loc>* c"
paulson@14504
    54
obua@14738
    55
instance comm_semiring \<subseteq> semiring
obua@14738
    56
proof
obua@14738
    57
  fix a b c :: 'a
obua@14738
    58
  show "(a + b) * c = a * c + b * c" by (simp add: distrib)
obua@14738
    59
  have "a * (b + c) = (b + c) * a" by (simp add: mult_ac)
obua@14738
    60
  also have "... = b * a + c * a" by (simp only: distrib)
obua@14738
    61
  also have "... = a * b + a * c" by (simp add: mult_ac)
obua@14738
    62
  finally show "a * (b + c) = a * b + a * c" by blast
paulson@14504
    63
qed
paulson@14504
    64
haftmann@22390
    65
class comm_semiring_0 = comm_semiring + comm_monoid_add + mult_zero
paulson@14504
    66
obua@14738
    67
instance comm_semiring_0 \<subseteq> semiring_0 ..
paulson@14504
    68
haftmann@22390
    69
class comm_semiring_0_cancel = comm_semiring + comm_monoid_add + cancel_ab_semigroup_add
obua@14940
    70
obua@14940
    71
instance comm_semiring_0_cancel \<subseteq> semiring_0_cancel ..
obua@14940
    72
krauss@21199
    73
instance comm_semiring_0_cancel \<subseteq> comm_semiring_0 ..
krauss@21199
    74
haftmann@22390
    75
class zero_neq_one = zero + one +
haftmann@22390
    76
  assumes zero_neq_one [simp]: "\<^loc>0 \<noteq> \<^loc>1"
paulson@14265
    77
haftmann@22390
    78
class semiring_1 = zero_neq_one + semiring_0 + monoid_mult
paulson@14504
    79
haftmann@22390
    80
class comm_semiring_1 = zero_neq_one + comm_semiring_0 + comm_monoid_mult
haftmann@22390
    81
  (*previously almost_semiring*)
obua@14738
    82
obua@14738
    83
instance comm_semiring_1 \<subseteq> semiring_1 ..
paulson@14421
    84
haftmann@22390
    85
class no_zero_divisors = zero + times +
haftmann@22390
    86
  assumes no_zero_divisors: "a \<noteq> \<^loc>0 \<Longrightarrow> b \<noteq> \<^loc>0 \<Longrightarrow> a \<^loc>* b \<noteq> \<^loc>0"
paulson@14504
    87
haftmann@22390
    88
class semiring_1_cancel = semiring + comm_monoid_add + zero_neq_one
haftmann@22390
    89
  + cancel_ab_semigroup_add + monoid_mult
obua@14940
    90
obua@14940
    91
instance semiring_1_cancel \<subseteq> semiring_0_cancel ..
obua@14940
    92
krauss@21199
    93
instance semiring_1_cancel \<subseteq> semiring_1 ..
krauss@21199
    94
haftmann@22390
    95
class comm_semiring_1_cancel = comm_semiring + comm_monoid_add + comm_monoid_mult
haftmann@22390
    96
  + zero_neq_one + cancel_ab_semigroup_add
obua@14738
    97
obua@14940
    98
instance comm_semiring_1_cancel \<subseteq> semiring_1_cancel ..
obua@14940
    99
obua@14940
   100
instance comm_semiring_1_cancel \<subseteq> comm_semiring_0_cancel ..
obua@14940
   101
krauss@21199
   102
instance comm_semiring_1_cancel \<subseteq> comm_semiring_1 ..
krauss@21199
   103
haftmann@22390
   104
class ring = semiring + ab_group_add
obua@14738
   105
obua@14940
   106
instance ring \<subseteq> semiring_0_cancel ..
paulson@14504
   107
haftmann@22390
   108
class comm_ring = comm_semiring + ab_group_add
obua@14738
   109
obua@14738
   110
instance comm_ring \<subseteq> ring ..
paulson@14504
   111
obua@14940
   112
instance comm_ring \<subseteq> comm_semiring_0_cancel ..
obua@14738
   113
haftmann@22390
   114
class ring_1 = ring + zero_neq_one + monoid_mult
paulson@14265
   115
obua@14940
   116
instance ring_1 \<subseteq> semiring_1_cancel ..
obua@14940
   117
haftmann@22390
   118
class comm_ring_1 = comm_ring + zero_neq_one + comm_monoid_mult
haftmann@22390
   119
  (*previously ring*)
obua@14738
   120
obua@14738
   121
instance comm_ring_1 \<subseteq> ring_1 ..
paulson@14421
   122
obua@14738
   123
instance comm_ring_1 \<subseteq> comm_semiring_1_cancel ..
paulson@14265
   124
haftmann@22390
   125
class idom = comm_ring_1 + no_zero_divisors
paulson@14421
   126
haftmann@22390
   127
class division_ring = ring_1 + inverse +
haftmann@22390
   128
  assumes left_inverse [simp]:  "a \<noteq> \<^loc>0 \<Longrightarrow> inverse a \<^loc>* a = \<^loc>1"
haftmann@22390
   129
  assumes right_inverse [simp]: "a \<noteq> \<^loc>0 \<Longrightarrow> a \<^loc>* inverse a = \<^loc>1"
huffman@20496
   130
haftmann@22390
   131
class field = comm_ring_1 + inverse +
haftmann@22390
   132
  assumes field_left_inverse: "a \<noteq> 0 \<Longrightarrow> inverse a \<^loc>* a = \<^loc>1"
haftmann@22390
   133
  assumes divide_inverse:     "a \<^loc>/ b = a \<^loc>* inverse b"
huffman@20496
   134
huffman@20496
   135
lemma field_right_inverse:
haftmann@22390
   136
  assumes not0: "a \<noteq> 0"
haftmann@22390
   137
  shows "a * inverse (a::'a::field) = 1"
huffman@20496
   138
proof -
huffman@20496
   139
  have "a * inverse a = inverse a * a" by (rule mult_commute)
huffman@20496
   140
  also have "... = 1" using not0 by (rule field_left_inverse)
huffman@20496
   141
  finally show ?thesis .
huffman@20496
   142
qed
huffman@20496
   143
huffman@20496
   144
instance field \<subseteq> division_ring
huffman@20496
   145
by (intro_classes, erule field_left_inverse, erule field_right_inverse)
paulson@14265
   146
huffman@20496
   147
lemma field_mult_eq_0_iff [simp]:
huffman@20496
   148
  "(a*b = (0::'a::division_ring)) = (a = 0 | b = 0)"
obua@14738
   149
proof cases
obua@14738
   150
  assume "a=0" thus ?thesis by simp
obua@14738
   151
next
obua@14738
   152
  assume anz [simp]: "a\<noteq>0"
obua@14738
   153
  { assume "a * b = 0"
obua@14738
   154
    hence "inverse a * (a * b) = 0" by simp
obua@14738
   155
    hence "b = 0"  by (simp (no_asm_use) add: mult_assoc [symmetric])}
obua@14738
   156
  thus ?thesis by force
obua@14738
   157
qed
obua@14738
   158
obua@14738
   159
instance field \<subseteq> idom
obua@14738
   160
by (intro_classes, simp)
huffman@20496
   161
haftmann@22390
   162
class division_by_zero = zero + inverse +
haftmann@22390
   163
  assumes inverse_zero [simp]: "inverse \<^loc>0 = \<^loc>0"
paulson@14265
   164
paulson@14265
   165
subsection {* Distribution rules *}
paulson@14265
   166
paulson@14265
   167
theorems ring_distrib = right_distrib left_distrib
paulson@14265
   168
paulson@14272
   169
text{*For the @{text combine_numerals} simproc*}
paulson@14421
   170
lemma combine_common_factor:
obua@14738
   171
     "a*e + (b*e + c) = (a+b)*e + (c::'a::semiring)"
paulson@14272
   172
by (simp add: left_distrib add_ac)
paulson@14272
   173
paulson@14265
   174
lemma minus_mult_left: "- (a * b) = (-a) * (b::'a::ring)"
paulson@14265
   175
apply (rule equals_zero_I)
paulson@14265
   176
apply (simp add: left_distrib [symmetric]) 
paulson@14265
   177
done
paulson@14265
   178
paulson@14265
   179
lemma minus_mult_right: "- (a * b) = a * -(b::'a::ring)"
paulson@14265
   180
apply (rule equals_zero_I)
paulson@14265
   181
apply (simp add: right_distrib [symmetric]) 
paulson@14265
   182
done
paulson@14265
   183
paulson@14268
   184
lemma minus_mult_minus [simp]: "(- a) * (- b) = a * (b::'a::ring)"
paulson@14268
   185
  by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric])
paulson@14268
   186
paulson@14365
   187
lemma minus_mult_commute: "(- a) * b = a * (- b::'a::ring)"
paulson@14365
   188
  by (simp add: minus_mult_left [symmetric] minus_mult_right [symmetric])
paulson@14365
   189
paulson@14265
   190
lemma right_diff_distrib: "a * (b - c) = a * b - a * (c::'a::ring)"
paulson@14265
   191
by (simp add: right_distrib diff_minus 
paulson@14265
   192
              minus_mult_left [symmetric] minus_mult_right [symmetric]) 
paulson@14265
   193
paulson@14272
   194
lemma left_diff_distrib: "(a - b) * c = a * c - b * (c::'a::ring)"
obua@14738
   195
by (simp add: left_distrib diff_minus 
obua@14738
   196
              minus_mult_left [symmetric] minus_mult_right [symmetric]) 
paulson@14265
   197
haftmann@22390
   198
class mult_mono = times + zero + ord +
haftmann@22390
   199
  assumes mult_left_mono: "a \<sqsubseteq> b \<Longrightarrow> \<^loc>0 \<sqsubseteq> c \<Longrightarrow> c \<^loc>* a \<sqsubseteq> c \<^loc>* b"
haftmann@22390
   200
  assumes mult_right_mono: "a \<sqsubseteq> b \<Longrightarrow> \<^loc>0 \<sqsubseteq> c \<Longrightarrow> a \<^loc>* c \<sqsubseteq> b \<^loc>* c"
paulson@14267
   201
haftmann@22390
   202
class pordered_semiring = mult_mono + semiring_0 + pordered_ab_semigroup_add 
krauss@21199
   203
haftmann@22390
   204
class pordered_cancel_semiring = mult_mono + pordered_ab_semigroup_add
haftmann@22390
   205
  + semiring + comm_monoid_add + pordered_ab_semigroup_add
haftmann@22390
   206
  + cancel_ab_semigroup_add
paulson@14268
   207
obua@14940
   208
instance pordered_cancel_semiring \<subseteq> semiring_0_cancel ..
obua@14940
   209
krauss@21199
   210
instance pordered_cancel_semiring \<subseteq> pordered_semiring .. 
krauss@21199
   211
haftmann@22390
   212
class ordered_semiring_strict = semiring + comm_monoid_add + ordered_cancel_ab_semigroup_add +
haftmann@22390
   213
  assumes mult_strict_left_mono: "a \<sqsubset> b \<Longrightarrow> \<^loc>0 \<sqsubset> c \<Longrightarrow> c \<^loc>* a \<sqsubset> c \<^loc>* b"
haftmann@22390
   214
  assumes mult_strict_right_mono: "a \<sqsubset> b \<Longrightarrow> \<^loc>0 \<sqsubset> c \<Longrightarrow> a \<^loc>* c \<sqsubset> b \<^loc>* c"
paulson@14341
   215
obua@14940
   216
instance ordered_semiring_strict \<subseteq> semiring_0_cancel ..
obua@14940
   217
obua@14738
   218
instance ordered_semiring_strict \<subseteq> pordered_cancel_semiring
obua@14738
   219
apply intro_classes
haftmann@21328
   220
apply (cases "a < b & 0 < c")
obua@14738
   221
apply (auto simp add: mult_strict_left_mono order_less_le)
obua@14738
   222
apply (auto simp add: mult_strict_left_mono order_le_less)
obua@14738
   223
apply (simp add: mult_strict_right_mono)
paulson@14270
   224
done
paulson@14270
   225
haftmann@22390
   226
class mult_mono1 = times + zero + ord +
haftmann@22390
   227
  assumes mult_mono: "a \<sqsubseteq> b \<Longrightarrow> \<^loc>0 \<sqsubseteq> c \<Longrightarrow> c \<^loc>* a \<sqsubseteq> c \<^loc>* b"
paulson@14270
   228
haftmann@22390
   229
class pordered_comm_semiring = comm_semiring_0
haftmann@22390
   230
  + pordered_ab_semigroup_add + mult_mono1
paulson@14270
   231
haftmann@22390
   232
class pordered_cancel_comm_semiring = comm_semiring_0_cancel
haftmann@22390
   233
  + pordered_ab_semigroup_add + mult_mono1
krauss@21199
   234
  
obua@14738
   235
instance pordered_cancel_comm_semiring \<subseteq> pordered_comm_semiring ..
paulson@14270
   236
haftmann@22390
   237
class ordered_comm_semiring_strict = comm_semiring_0 + ordered_cancel_ab_semigroup_add +
haftmann@22390
   238
  assumes mult_strict_mono: "a \<sqsubset> b \<Longrightarrow> \<^loc>0 \<sqsubset> c \<Longrightarrow> c \<^loc>* a \<sqsubset> c \<^loc>* b"
paulson@14265
   239
obua@14738
   240
instance pordered_comm_semiring \<subseteq> pordered_semiring
krauss@21199
   241
proof
krauss@21199
   242
  fix a b c :: 'a
krauss@21199
   243
  assume A: "a <= b" "0 <= c"
krauss@21199
   244
  with mult_mono show "c * a <= c * b" .
krauss@21199
   245
krauss@21199
   246
  from mult_commute have "a * c = c * a" ..
krauss@21199
   247
  also from mult_mono A have "\<dots> <= c * b" .
krauss@21199
   248
  also from mult_commute have "c * b = b * c" ..
krauss@21199
   249
  finally show "a * c <= b * c" .
krauss@21199
   250
qed
paulson@14265
   251
obua@14738
   252
instance pordered_cancel_comm_semiring \<subseteq> pordered_cancel_semiring ..
paulson@14265
   253
obua@14738
   254
instance ordered_comm_semiring_strict \<subseteq> ordered_semiring_strict
obua@14738
   255
by (intro_classes, insert mult_strict_mono, simp_all add: mult_commute, blast+)
paulson@14272
   256
obua@14738
   257
instance ordered_comm_semiring_strict \<subseteq> pordered_cancel_comm_semiring
obua@14738
   258
apply (intro_classes)
haftmann@21328
   259
apply (cases "a < b & 0 < c")
obua@14738
   260
apply (auto simp add: mult_strict_left_mono order_less_le)
obua@14738
   261
apply (auto simp add: mult_strict_left_mono order_le_less)
paulson@14272
   262
done
paulson@14272
   263
haftmann@22390
   264
class pordered_ring = ring + pordered_cancel_semiring 
paulson@14270
   265
obua@14738
   266
instance pordered_ring \<subseteq> pordered_ab_group_add ..
paulson@14270
   267
obua@14738
   268
axclass lordered_ring \<subseteq> pordered_ring, lordered_ab_group_abs
paulson@14270
   269
obua@14940
   270
instance lordered_ring \<subseteq> lordered_ab_group_meet ..
obua@14940
   271
obua@14940
   272
instance lordered_ring \<subseteq> lordered_ab_group_join ..
obua@14940
   273
haftmann@22390
   274
class abs_if = minus + ord + zero +
haftmann@22390
   275
  assumes abs_if: "abs a = (if a \<sqsubset> 0 then (uminus a) else a)"
paulson@14270
   276
haftmann@22390
   277
class ordered_ring_strict = ring + ordered_semiring_strict + abs_if
paulson@14270
   278
obua@14738
   279
instance ordered_ring_strict \<subseteq> lordered_ab_group ..
paulson@14270
   280
obua@14738
   281
instance ordered_ring_strict \<subseteq> lordered_ring
haftmann@22422
   282
  by intro_classes (simp add: abs_if sup_eq_if)
paulson@14270
   283
haftmann@22390
   284
class pordered_comm_ring = comm_ring + pordered_comm_semiring
paulson@14270
   285
haftmann@22390
   286
class ordered_semidom = comm_semiring_1_cancel + ordered_comm_semiring_strict +
haftmann@22390
   287
  (*previously ordered_semiring*)
haftmann@22390
   288
  assumes zero_less_one [simp]: "\<^loc>0 \<sqsubset> \<^loc>1"
paulson@14270
   289
haftmann@22390
   290
class ordered_idom = comm_ring_1 + ordered_comm_semiring_strict + abs_if
haftmann@22390
   291
  (*previously ordered_ring*)
paulson@14270
   292
obua@14738
   293
instance ordered_idom \<subseteq> ordered_ring_strict ..
paulson@14272
   294
haftmann@22390
   295
class ordered_field = field + ordered_idom
paulson@14272
   296
nipkow@15923
   297
lemmas linorder_neqE_ordered_idom =
nipkow@15923
   298
 linorder_neqE[where 'a = "?'b::ordered_idom"]
nipkow@15923
   299
paulson@14272
   300
lemma eq_add_iff1:
paulson@14272
   301
     "(a*e + c = b*e + d) = ((a-b)*e + c = (d::'a::ring))"
obua@14738
   302
apply (simp add: diff_minus left_distrib)
paulson@14272
   303
apply (simp add: diff_minus left_distrib add_ac)
obua@14738
   304
apply (simp add: compare_rls minus_mult_left [symmetric])
paulson@14272
   305
done
paulson@14272
   306
paulson@14272
   307
lemma eq_add_iff2:
paulson@14272
   308
     "(a*e + c = b*e + d) = (c = (b-a)*e + (d::'a::ring))"
paulson@14272
   309
apply (simp add: diff_minus left_distrib add_ac)
paulson@14272
   310
apply (simp add: compare_rls minus_mult_left [symmetric]) 
paulson@14272
   311
done
paulson@14272
   312
paulson@14272
   313
lemma less_add_iff1:
obua@14738
   314
     "(a*e + c < b*e + d) = ((a-b)*e + c < (d::'a::pordered_ring))"
paulson@14272
   315
apply (simp add: diff_minus left_distrib add_ac)
paulson@14272
   316
apply (simp add: compare_rls minus_mult_left [symmetric]) 
paulson@14272
   317
done
paulson@14272
   318
paulson@14272
   319
lemma less_add_iff2:
obua@14738
   320
     "(a*e + c < b*e + d) = (c < (b-a)*e + (d::'a::pordered_ring))"
paulson@14272
   321
apply (simp add: diff_minus left_distrib add_ac)
paulson@14272
   322
apply (simp add: compare_rls minus_mult_left [symmetric]) 
paulson@14272
   323
done
paulson@14272
   324
paulson@14272
   325
lemma le_add_iff1:
obua@14738
   326
     "(a*e + c \<le> b*e + d) = ((a-b)*e + c \<le> (d::'a::pordered_ring))"
paulson@14272
   327
apply (simp add: diff_minus left_distrib add_ac)
paulson@14272
   328
apply (simp add: compare_rls minus_mult_left [symmetric]) 
paulson@14272
   329
done
paulson@14272
   330
paulson@14272
   331
lemma le_add_iff2:
obua@14738
   332
     "(a*e + c \<le> b*e + d) = (c \<le> (b-a)*e + (d::'a::pordered_ring))"
paulson@14272
   333
apply (simp add: diff_minus left_distrib add_ac)
paulson@14272
   334
apply (simp add: compare_rls minus_mult_left [symmetric]) 
paulson@14272
   335
done
paulson@14272
   336
paulson@14270
   337
subsection {* Ordering Rules for Multiplication *}
paulson@14270
   338
paulson@14348
   339
lemma mult_left_le_imp_le:
obua@14738
   340
     "[|c*a \<le> c*b; 0 < c|] ==> a \<le> (b::'a::ordered_semiring_strict)"
paulson@14348
   341
  by (force simp add: mult_strict_left_mono linorder_not_less [symmetric])
paulson@14348
   342
 
paulson@14348
   343
lemma mult_right_le_imp_le:
obua@14738
   344
     "[|a*c \<le> b*c; 0 < c|] ==> a \<le> (b::'a::ordered_semiring_strict)"
paulson@14348
   345
  by (force simp add: mult_strict_right_mono linorder_not_less [symmetric])
paulson@14348
   346
paulson@14348
   347
lemma mult_left_less_imp_less:
obua@14738
   348
     "[|c*a < c*b; 0 \<le> c|] ==> a < (b::'a::ordered_semiring_strict)"
paulson@14348
   349
  by (force simp add: mult_left_mono linorder_not_le [symmetric])
paulson@14348
   350
 
paulson@14348
   351
lemma mult_right_less_imp_less:
obua@14738
   352
     "[|a*c < b*c; 0 \<le> c|] ==> a < (b::'a::ordered_semiring_strict)"
paulson@14348
   353
  by (force simp add: mult_right_mono linorder_not_le [symmetric])
paulson@14348
   354
paulson@14265
   355
lemma mult_strict_left_mono_neg:
obua@14738
   356
     "[|b < a; c < 0|] ==> c * a < c * (b::'a::ordered_ring_strict)"
paulson@14265
   357
apply (drule mult_strict_left_mono [of _ _ "-c"])
paulson@14265
   358
apply (simp_all add: minus_mult_left [symmetric]) 
paulson@14265
   359
done
paulson@14265
   360
obua@14738
   361
lemma mult_left_mono_neg:
obua@14738
   362
     "[|b \<le> a; c \<le> 0|] ==> c * a \<le>  c * (b::'a::pordered_ring)"
obua@14738
   363
apply (drule mult_left_mono [of _ _ "-c"])
obua@14738
   364
apply (simp_all add: minus_mult_left [symmetric]) 
obua@14738
   365
done
obua@14738
   366
paulson@14265
   367
lemma mult_strict_right_mono_neg:
obua@14738
   368
     "[|b < a; c < 0|] ==> a * c < b * (c::'a::ordered_ring_strict)"
paulson@14265
   369
apply (drule mult_strict_right_mono [of _ _ "-c"])
paulson@14265
   370
apply (simp_all add: minus_mult_right [symmetric]) 
paulson@14265
   371
done
paulson@14265
   372
obua@14738
   373
lemma mult_right_mono_neg:
obua@14738
   374
     "[|b \<le> a; c \<le> 0|] ==> a * c \<le>  (b::'a::pordered_ring) * c"
obua@14738
   375
apply (drule mult_right_mono [of _ _ "-c"])
obua@14738
   376
apply (simp)
obua@14738
   377
apply (simp_all add: minus_mult_right [symmetric]) 
obua@14738
   378
done
paulson@14265
   379
paulson@14265
   380
subsection{* Products of Signs *}
paulson@14265
   381
avigad@16775
   382
lemma mult_pos_pos: "[| (0::'a::ordered_semiring_strict) < a; 0 < b |] ==> 0 < a*b"
paulson@14265
   383
by (drule mult_strict_left_mono [of 0 b], auto)
paulson@14265
   384
avigad@16775
   385
lemma mult_nonneg_nonneg: "[| (0::'a::pordered_cancel_semiring) \<le> a; 0 \<le> b |] ==> 0 \<le> a*b"
obua@14738
   386
by (drule mult_left_mono [of 0 b], auto)
obua@14738
   387
obua@14738
   388
lemma mult_pos_neg: "[| (0::'a::ordered_semiring_strict) < a; b < 0 |] ==> a*b < 0"
paulson@14265
   389
by (drule mult_strict_left_mono [of b 0], auto)
paulson@14265
   390
avigad@16775
   391
lemma mult_nonneg_nonpos: "[| (0::'a::pordered_cancel_semiring) \<le> a; b \<le> 0 |] ==> a*b \<le> 0"
obua@14738
   392
by (drule mult_left_mono [of b 0], auto)
obua@14738
   393
obua@14738
   394
lemma mult_pos_neg2: "[| (0::'a::ordered_semiring_strict) < a; b < 0 |] ==> b*a < 0" 
obua@14738
   395
by (drule mult_strict_right_mono[of b 0], auto)
obua@14738
   396
avigad@16775
   397
lemma mult_nonneg_nonpos2: "[| (0::'a::pordered_cancel_semiring) \<le> a; b \<le> 0 |] ==> b*a \<le> 0" 
obua@14738
   398
by (drule mult_right_mono[of b 0], auto)
obua@14738
   399
avigad@16775
   400
lemma mult_neg_neg: "[| a < (0::'a::ordered_ring_strict); b < 0 |] ==> 0 < a*b"
paulson@14265
   401
by (drule mult_strict_right_mono_neg, auto)
paulson@14265
   402
avigad@16775
   403
lemma mult_nonpos_nonpos: "[| a \<le> (0::'a::pordered_ring); b \<le> 0 |] ==> 0 \<le> a*b"
obua@14738
   404
by (drule mult_right_mono_neg[of a 0 b ], auto)
obua@14738
   405
paulson@14341
   406
lemma zero_less_mult_pos:
obua@14738
   407
     "[| 0 < a*b; 0 < a|] ==> 0 < (b::'a::ordered_semiring_strict)"
haftmann@21328
   408
apply (cases "b\<le>0") 
paulson@14265
   409
 apply (auto simp add: order_le_less linorder_not_less)
paulson@14265
   410
apply (drule_tac mult_pos_neg [of a b]) 
paulson@14265
   411
 apply (auto dest: order_less_not_sym)
paulson@14265
   412
done
paulson@14265
   413
obua@14738
   414
lemma zero_less_mult_pos2:
obua@14738
   415
     "[| 0 < b*a; 0 < a|] ==> 0 < (b::'a::ordered_semiring_strict)"
haftmann@21328
   416
apply (cases "b\<le>0") 
obua@14738
   417
 apply (auto simp add: order_le_less linorder_not_less)
obua@14738
   418
apply (drule_tac mult_pos_neg2 [of a b]) 
obua@14738
   419
 apply (auto dest: order_less_not_sym)
obua@14738
   420
done
obua@14738
   421
paulson@14265
   422
lemma zero_less_mult_iff:
obua@14738
   423
     "((0::'a::ordered_ring_strict) < a*b) = (0 < a & 0 < b | a < 0 & b < 0)"
avigad@16775
   424
apply (auto simp add: order_le_less linorder_not_less mult_pos_pos 
avigad@16775
   425
  mult_neg_neg)
paulson@14265
   426
apply (blast dest: zero_less_mult_pos) 
obua@14738
   427
apply (blast dest: zero_less_mult_pos2)
paulson@14265
   428
done
paulson@14265
   429
paulson@14341
   430
text{*A field has no "zero divisors", and this theorem holds without the
paulson@14277
   431
      assumption of an ordering.  See @{text field_mult_eq_0_iff} below.*}
obua@14738
   432
lemma mult_eq_0_iff [simp]: "(a*b = (0::'a::ordered_ring_strict)) = (a = 0 | b = 0)"
haftmann@21328
   433
apply (cases "a < 0")
paulson@14265
   434
apply (auto simp add: linorder_not_less order_le_less linorder_neq_iff)
paulson@14265
   435
apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono)+
paulson@14265
   436
done
paulson@14265
   437
paulson@14265
   438
lemma zero_le_mult_iff:
obua@14738
   439
     "((0::'a::ordered_ring_strict) \<le> a*b) = (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
paulson@14265
   440
by (auto simp add: eq_commute [of 0] order_le_less linorder_not_less
paulson@14265
   441
                   zero_less_mult_iff)
paulson@14265
   442
paulson@14265
   443
lemma mult_less_0_iff:
obua@14738
   444
     "(a*b < (0::'a::ordered_ring_strict)) = (0 < a & b < 0 | a < 0 & 0 < b)"
paulson@14265
   445
apply (insert zero_less_mult_iff [of "-a" b]) 
paulson@14265
   446
apply (force simp add: minus_mult_left[symmetric]) 
paulson@14265
   447
done
paulson@14265
   448
paulson@14265
   449
lemma mult_le_0_iff:
obua@14738
   450
     "(a*b \<le> (0::'a::ordered_ring_strict)) = (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
paulson@14265
   451
apply (insert zero_le_mult_iff [of "-a" b]) 
paulson@14265
   452
apply (force simp add: minus_mult_left[symmetric]) 
paulson@14265
   453
done
paulson@14265
   454
obua@14738
   455
lemma split_mult_pos_le: "(0 \<le> a & 0 \<le> b) | (a \<le> 0 & b \<le> 0) \<Longrightarrow> 0 \<le> a * (b::_::pordered_ring)"
avigad@16775
   456
by (auto simp add: mult_nonneg_nonneg mult_nonpos_nonpos)
obua@14738
   457
obua@14738
   458
lemma split_mult_neg_le: "(0 \<le> a & b \<le> 0) | (a \<le> 0 & 0 \<le> b) \<Longrightarrow> a * b \<le> (0::_::pordered_cancel_semiring)" 
avigad@16775
   459
by (auto simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)
obua@14738
   460
obua@14738
   461
lemma zero_le_square: "(0::'a::ordered_ring_strict) \<le> a*a"
paulson@14265
   462
by (simp add: zero_le_mult_iff linorder_linear) 
paulson@14265
   463
obua@14738
   464
text{*Proving axiom @{text zero_less_one} makes all @{text ordered_semidom}
obua@14738
   465
      theorems available to members of @{term ordered_idom} *}
obua@14738
   466
obua@14738
   467
instance ordered_idom \<subseteq> ordered_semidom
paulson@14421
   468
proof
paulson@14421
   469
  have "(0::'a) \<le> 1*1" by (rule zero_le_square)
paulson@14430
   470
  thus "(0::'a) < 1" by (simp add: order_le_less) 
paulson@14421
   471
qed
paulson@14421
   472
obua@20609
   473
instance ordered_ring_strict \<subseteq> no_zero_divisors 
obua@14738
   474
by (intro_classes, simp)
obua@14738
   475
obua@14738
   476
instance ordered_idom \<subseteq> idom ..
obua@14738
   477
paulson@14387
   478
text{*All three types of comparision involving 0 and 1 are covered.*}
paulson@14387
   479
paulson@17085
   480
lemmas one_neq_zero = zero_neq_one [THEN not_sym]
paulson@17085
   481
declare one_neq_zero [simp]
paulson@14387
   482
obua@14738
   483
lemma zero_le_one [simp]: "(0::'a::ordered_semidom) \<le> 1"
paulson@14268
   484
  by (rule zero_less_one [THEN order_less_imp_le]) 
paulson@14268
   485
obua@14738
   486
lemma not_one_le_zero [simp]: "~ (1::'a::ordered_semidom) \<le> 0"
obua@14738
   487
by (simp add: linorder_not_le) 
paulson@14387
   488
obua@14738
   489
lemma not_one_less_zero [simp]: "~ (1::'a::ordered_semidom) < 0"
obua@14738
   490
by (simp add: linorder_not_less) 
paulson@14268
   491
paulson@14268
   492
subsection{*More Monotonicity*}
paulson@14268
   493
paulson@14268
   494
text{*Strict monotonicity in both arguments*}
paulson@14268
   495
lemma mult_strict_mono:
obua@14738
   496
     "[|a<b; c<d; 0<b; 0\<le>c|] ==> a * c < b * (d::'a::ordered_semiring_strict)"
haftmann@21328
   497
apply (cases "c=0")
avigad@16775
   498
 apply (simp add: mult_pos_pos) 
paulson@14268
   499
apply (erule mult_strict_right_mono [THEN order_less_trans])
paulson@14268
   500
 apply (force simp add: order_le_less) 
paulson@14268
   501
apply (erule mult_strict_left_mono, assumption)
paulson@14268
   502
done
paulson@14268
   503
paulson@14268
   504
text{*This weaker variant has more natural premises*}
paulson@14268
   505
lemma mult_strict_mono':
obua@14738
   506
     "[| a<b; c<d; 0 \<le> a; 0 \<le> c|] ==> a * c < b * (d::'a::ordered_semiring_strict)"
paulson@14268
   507
apply (rule mult_strict_mono)
paulson@14268
   508
apply (blast intro: order_le_less_trans)+
paulson@14268
   509
done
paulson@14268
   510
paulson@14268
   511
lemma mult_mono:
paulson@14268
   512
     "[|a \<le> b; c \<le> d; 0 \<le> b; 0 \<le> c|] 
obua@14738
   513
      ==> a * c  \<le>  b * (d::'a::pordered_semiring)"
paulson@14268
   514
apply (erule mult_right_mono [THEN order_trans], assumption)
paulson@14268
   515
apply (erule mult_left_mono, assumption)
paulson@14268
   516
done
paulson@14268
   517
huffman@21258
   518
lemma mult_mono':
huffman@21258
   519
     "[|a \<le> b; c \<le> d; 0 \<le> a; 0 \<le> c|] 
huffman@21258
   520
      ==> a * c  \<le>  b * (d::'a::pordered_semiring)"
huffman@21258
   521
apply (rule mult_mono)
huffman@21258
   522
apply (fast intro: order_trans)+
huffman@21258
   523
done
huffman@21258
   524
obua@14738
   525
lemma less_1_mult: "[| 1 < m; 1 < n |] ==> 1 < m*(n::'a::ordered_semidom)"
paulson@14387
   526
apply (insert mult_strict_mono [of 1 m 1 n]) 
paulson@14430
   527
apply (simp add:  order_less_trans [OF zero_less_one]) 
paulson@14387
   528
done
paulson@14387
   529
avigad@16775
   530
lemma mult_less_le_imp_less: "(a::'a::ordered_semiring_strict) < b ==>
avigad@16775
   531
    c <= d ==> 0 <= a ==> 0 < c ==> a * c < b * d"
avigad@16775
   532
  apply (subgoal_tac "a * c < b * c")
avigad@16775
   533
  apply (erule order_less_le_trans)
avigad@16775
   534
  apply (erule mult_left_mono)
avigad@16775
   535
  apply simp
avigad@16775
   536
  apply (erule mult_strict_right_mono)
avigad@16775
   537
  apply assumption
avigad@16775
   538
done
avigad@16775
   539
avigad@16775
   540
lemma mult_le_less_imp_less: "(a::'a::ordered_semiring_strict) <= b ==>
avigad@16775
   541
    c < d ==> 0 < a ==> 0 <= c ==> a * c < b * d"
avigad@16775
   542
  apply (subgoal_tac "a * c <= b * c")
avigad@16775
   543
  apply (erule order_le_less_trans)
avigad@16775
   544
  apply (erule mult_strict_left_mono)
avigad@16775
   545
  apply simp
avigad@16775
   546
  apply (erule mult_right_mono)
avigad@16775
   547
  apply simp
avigad@16775
   548
done
avigad@16775
   549
paulson@14268
   550
subsection{*Cancellation Laws for Relationships With a Common Factor*}
paulson@14268
   551
paulson@14268
   552
text{*Cancellation laws for @{term "c*a < c*b"} and @{term "a*c < b*c"},
paulson@14268
   553
   also with the relations @{text "\<le>"} and equality.*}
paulson@14268
   554
paulson@15234
   555
text{*These ``disjunction'' versions produce two cases when the comparison is
paulson@15234
   556
 an assumption, but effectively four when the comparison is a goal.*}
paulson@15234
   557
paulson@15234
   558
lemma mult_less_cancel_right_disj:
obua@14738
   559
    "(a*c < b*c) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))"
haftmann@21328
   560
apply (cases "c = 0")
paulson@14268
   561
apply (auto simp add: linorder_neq_iff mult_strict_right_mono 
paulson@14268
   562
                      mult_strict_right_mono_neg)
paulson@14268
   563
apply (auto simp add: linorder_not_less 
paulson@14268
   564
                      linorder_not_le [symmetric, of "a*c"]
paulson@14268
   565
                      linorder_not_le [symmetric, of a])
paulson@14268
   566
apply (erule_tac [!] notE)
paulson@14268
   567
apply (auto simp add: order_less_imp_le mult_right_mono 
paulson@14268
   568
                      mult_right_mono_neg)
paulson@14268
   569
done
paulson@14268
   570
paulson@15234
   571
lemma mult_less_cancel_left_disj:
obua@14738
   572
    "(c*a < c*b) = ((0 < c & a < b) | (c < 0 & b < (a::'a::ordered_ring_strict)))"
haftmann@21328
   573
apply (cases "c = 0")
obua@14738
   574
apply (auto simp add: linorder_neq_iff mult_strict_left_mono 
obua@14738
   575
                      mult_strict_left_mono_neg)
obua@14738
   576
apply (auto simp add: linorder_not_less 
obua@14738
   577
                      linorder_not_le [symmetric, of "c*a"]
obua@14738
   578
                      linorder_not_le [symmetric, of a])
obua@14738
   579
apply (erule_tac [!] notE)
obua@14738
   580
apply (auto simp add: order_less_imp_le mult_left_mono 
obua@14738
   581
                      mult_left_mono_neg)
obua@14738
   582
done
paulson@14268
   583
paulson@15234
   584
paulson@15234
   585
text{*The ``conjunction of implication'' lemmas produce two cases when the
paulson@15234
   586
comparison is a goal, but give four when the comparison is an assumption.*}
paulson@15234
   587
paulson@15234
   588
lemma mult_less_cancel_right:
paulson@15234
   589
  fixes c :: "'a :: ordered_ring_strict"
paulson@15234
   590
  shows      "(a*c < b*c) = ((0 \<le> c --> a < b) & (c \<le> 0 --> b < a))"
paulson@15234
   591
by (insert mult_less_cancel_right_disj [of a c b], auto)
paulson@15234
   592
paulson@15234
   593
lemma mult_less_cancel_left:
paulson@15234
   594
  fixes c :: "'a :: ordered_ring_strict"
paulson@15234
   595
  shows      "(c*a < c*b) = ((0 \<le> c --> a < b) & (c \<le> 0 --> b < a))"
paulson@15234
   596
by (insert mult_less_cancel_left_disj [of c a b], auto)
paulson@15234
   597
paulson@14268
   598
lemma mult_le_cancel_right:
obua@14738
   599
     "(a*c \<le> b*c) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring_strict)))"
paulson@15234
   600
by (simp add: linorder_not_less [symmetric] mult_less_cancel_right_disj)
paulson@14268
   601
paulson@14268
   602
lemma mult_le_cancel_left:
obua@14738
   603
     "(c*a \<le> c*b) = ((0<c --> a\<le>b) & (c<0 --> b \<le> (a::'a::ordered_ring_strict)))"
paulson@15234
   604
by (simp add: linorder_not_less [symmetric] mult_less_cancel_left_disj)
paulson@14268
   605
paulson@14268
   606
lemma mult_less_imp_less_left:
paulson@14341
   607
      assumes less: "c*a < c*b" and nonneg: "0 \<le> c"
obua@14738
   608
      shows "a < (b::'a::ordered_semiring_strict)"
paulson@14377
   609
proof (rule ccontr)
paulson@14377
   610
  assume "~ a < b"
paulson@14377
   611
  hence "b \<le> a" by (simp add: linorder_not_less)
paulson@14377
   612
  hence "c*b \<le> c*a" by (rule mult_left_mono)
paulson@14377
   613
  with this and less show False 
paulson@14377
   614
    by (simp add: linorder_not_less [symmetric])
paulson@14377
   615
qed
paulson@14268
   616
paulson@14268
   617
lemma mult_less_imp_less_right:
obua@14738
   618
  assumes less: "a*c < b*c" and nonneg: "0 <= c"
obua@14738
   619
  shows "a < (b::'a::ordered_semiring_strict)"
obua@14738
   620
proof (rule ccontr)
obua@14738
   621
  assume "~ a < b"
obua@14738
   622
  hence "b \<le> a" by (simp add: linorder_not_less)
obua@14738
   623
  hence "b*c \<le> a*c" by (rule mult_right_mono)
obua@14738
   624
  with this and less show False 
obua@14738
   625
    by (simp add: linorder_not_less [symmetric])
obua@14738
   626
qed  
paulson@14268
   627
paulson@14268
   628
text{*Cancellation of equalities with a common factor*}
paulson@14268
   629
lemma mult_cancel_right [simp]:
obua@14738
   630
     "(a*c = b*c) = (c = (0::'a::ordered_ring_strict) | a=b)"
paulson@14268
   631
apply (cut_tac linorder_less_linear [of 0 c])
paulson@14268
   632
apply (force dest: mult_strict_right_mono_neg mult_strict_right_mono
paulson@14268
   633
             simp add: linorder_neq_iff)
paulson@14268
   634
done
paulson@14268
   635
paulson@14268
   636
text{*These cancellation theorems require an ordering. Versions are proved
paulson@14268
   637
      below that work for fields without an ordering.*}
paulson@14268
   638
lemma mult_cancel_left [simp]:
obua@14738
   639
     "(c*a = c*b) = (c = (0::'a::ordered_ring_strict) | a=b)"
obua@14738
   640
apply (cut_tac linorder_less_linear [of 0 c])
obua@14738
   641
apply (force dest: mult_strict_left_mono_neg mult_strict_left_mono
obua@14738
   642
             simp add: linorder_neq_iff)
obua@14738
   643
done
paulson@14268
   644
paulson@15234
   645
paulson@15234
   646
subsubsection{*Special Cancellation Simprules for Multiplication*}
paulson@15234
   647
paulson@15234
   648
text{*These also produce two cases when the comparison is a goal.*}
paulson@15234
   649
paulson@15234
   650
lemma mult_le_cancel_right1:
paulson@15234
   651
  fixes c :: "'a :: ordered_idom"
paulson@15234
   652
  shows "(c \<le> b*c) = ((0<c --> 1\<le>b) & (c<0 --> b \<le> 1))"
paulson@15234
   653
by (insert mult_le_cancel_right [of 1 c b], simp)
paulson@15234
   654
paulson@15234
   655
lemma mult_le_cancel_right2:
paulson@15234
   656
  fixes c :: "'a :: ordered_idom"
paulson@15234
   657
  shows "(a*c \<le> c) = ((0<c --> a\<le>1) & (c<0 --> 1 \<le> a))"
paulson@15234
   658
by (insert mult_le_cancel_right [of a c 1], simp)
paulson@15234
   659
paulson@15234
   660
lemma mult_le_cancel_left1:
paulson@15234
   661
  fixes c :: "'a :: ordered_idom"
paulson@15234
   662
  shows "(c \<le> c*b) = ((0<c --> 1\<le>b) & (c<0 --> b \<le> 1))"
paulson@15234
   663
by (insert mult_le_cancel_left [of c 1 b], simp)
paulson@15234
   664
paulson@15234
   665
lemma mult_le_cancel_left2:
paulson@15234
   666
  fixes c :: "'a :: ordered_idom"
paulson@15234
   667
  shows "(c*a \<le> c) = ((0<c --> a\<le>1) & (c<0 --> 1 \<le> a))"
paulson@15234
   668
by (insert mult_le_cancel_left [of c a 1], simp)
paulson@15234
   669
paulson@15234
   670
lemma mult_less_cancel_right1:
paulson@15234
   671
  fixes c :: "'a :: ordered_idom"
paulson@15234
   672
  shows "(c < b*c) = ((0 \<le> c --> 1<b) & (c \<le> 0 --> b < 1))"
paulson@15234
   673
by (insert mult_less_cancel_right [of 1 c b], simp)
paulson@15234
   674
paulson@15234
   675
lemma mult_less_cancel_right2:
paulson@15234
   676
  fixes c :: "'a :: ordered_idom"
paulson@15234
   677
  shows "(a*c < c) = ((0 \<le> c --> a<1) & (c \<le> 0 --> 1 < a))"
paulson@15234
   678
by (insert mult_less_cancel_right [of a c 1], simp)
paulson@15234
   679
paulson@15234
   680
lemma mult_less_cancel_left1:
paulson@15234
   681
  fixes c :: "'a :: ordered_idom"
paulson@15234
   682
  shows "(c < c*b) = ((0 \<le> c --> 1<b) & (c \<le> 0 --> b < 1))"
paulson@15234
   683
by (insert mult_less_cancel_left [of c 1 b], simp)
paulson@15234
   684
paulson@15234
   685
lemma mult_less_cancel_left2:
paulson@15234
   686
  fixes c :: "'a :: ordered_idom"
paulson@15234
   687
  shows "(c*a < c) = ((0 \<le> c --> a<1) & (c \<le> 0 --> 1 < a))"
paulson@15234
   688
by (insert mult_less_cancel_left [of c a 1], simp)
paulson@15234
   689
paulson@15234
   690
lemma mult_cancel_right1 [simp]:
paulson@15234
   691
fixes c :: "'a :: ordered_idom"
paulson@15234
   692
  shows "(c = b*c) = (c = 0 | b=1)"
paulson@15234
   693
by (insert mult_cancel_right [of 1 c b], force)
paulson@15234
   694
paulson@15234
   695
lemma mult_cancel_right2 [simp]:
paulson@15234
   696
fixes c :: "'a :: ordered_idom"
paulson@15234
   697
  shows "(a*c = c) = (c = 0 | a=1)"
paulson@15234
   698
by (insert mult_cancel_right [of a c 1], simp)
paulson@15234
   699
 
paulson@15234
   700
lemma mult_cancel_left1 [simp]:
paulson@15234
   701
fixes c :: "'a :: ordered_idom"
paulson@15234
   702
  shows "(c = c*b) = (c = 0 | b=1)"
paulson@15234
   703
by (insert mult_cancel_left [of c 1 b], force)
paulson@15234
   704
paulson@15234
   705
lemma mult_cancel_left2 [simp]:
paulson@15234
   706
fixes c :: "'a :: ordered_idom"
paulson@15234
   707
  shows "(c*a = c) = (c = 0 | a=1)"
paulson@15234
   708
by (insert mult_cancel_left [of c a 1], simp)
paulson@15234
   709
paulson@15234
   710
paulson@15234
   711
text{*Simprules for comparisons where common factors can be cancelled.*}
paulson@15234
   712
lemmas mult_compare_simps =
paulson@15234
   713
    mult_le_cancel_right mult_le_cancel_left
paulson@15234
   714
    mult_le_cancel_right1 mult_le_cancel_right2
paulson@15234
   715
    mult_le_cancel_left1 mult_le_cancel_left2
paulson@15234
   716
    mult_less_cancel_right mult_less_cancel_left
paulson@15234
   717
    mult_less_cancel_right1 mult_less_cancel_right2
paulson@15234
   718
    mult_less_cancel_left1 mult_less_cancel_left2
paulson@15234
   719
    mult_cancel_right mult_cancel_left
paulson@15234
   720
    mult_cancel_right1 mult_cancel_right2
paulson@15234
   721
    mult_cancel_left1 mult_cancel_left2
paulson@15234
   722
paulson@15234
   723
obua@14738
   724
text{*This list of rewrites decides ring equalities by ordered rewriting.*}
obua@15178
   725
lemmas ring_eq_simps =  
obua@15178
   726
(*  mult_ac*)
obua@14738
   727
  left_distrib right_distrib left_diff_distrib right_diff_distrib
obua@15178
   728
  group_eq_simps
obua@15178
   729
(*  add_ac
obua@14738
   730
  add_diff_eq diff_add_eq diff_diff_eq diff_diff_eq2
obua@15178
   731
  diff_eq_eq eq_diff_eq *)
obua@14738
   732
    
paulson@14265
   733
subsection {* Fields *}
paulson@14265
   734
paulson@14288
   735
lemma right_inverse_eq: "b \<noteq> 0 ==> (a / b = 1) = (a = (b::'a::field))"
paulson@14288
   736
proof
paulson@14288
   737
  assume neq: "b \<noteq> 0"
paulson@14288
   738
  {
paulson@14288
   739
    hence "a = (a / b) * b" by (simp add: divide_inverse mult_ac)
paulson@14288
   740
    also assume "a / b = 1"
paulson@14288
   741
    finally show "a = b" by simp
paulson@14288
   742
  next
paulson@14288
   743
    assume "a = b"
paulson@14288
   744
    with neq show "a / b = 1" by (simp add: divide_inverse)
paulson@14288
   745
  }
paulson@14288
   746
qed
paulson@14288
   747
paulson@14288
   748
lemma nonzero_inverse_eq_divide: "a \<noteq> 0 ==> inverse (a::'a::field) = 1/a"
paulson@14288
   749
by (simp add: divide_inverse)
paulson@14288
   750
paulson@15228
   751
lemma divide_self: "a \<noteq> 0 ==> a / (a::'a::field) = 1"
paulson@14288
   752
  by (simp add: divide_inverse)
paulson@14288
   753
paulson@14430
   754
lemma divide_zero [simp]: "a / 0 = (0::'a::{field,division_by_zero})"
paulson@14430
   755
by (simp add: divide_inverse)
paulson@14277
   756
paulson@15228
   757
lemma divide_self_if [simp]:
paulson@15228
   758
     "a / (a::'a::{field,division_by_zero}) = (if a=0 then 0 else 1)"
paulson@15228
   759
  by (simp add: divide_self)
paulson@15228
   760
paulson@14430
   761
lemma divide_zero_left [simp]: "0/a = (0::'a::field)"
paulson@14430
   762
by (simp add: divide_inverse)
paulson@14277
   763
paulson@14430
   764
lemma inverse_eq_divide: "inverse (a::'a::field) = 1/a"
paulson@14430
   765
by (simp add: divide_inverse)
paulson@14277
   766
paulson@14430
   767
lemma add_divide_distrib: "(a+b)/(c::'a::field) = a/c + b/c"
paulson@14293
   768
by (simp add: divide_inverse left_distrib) 
paulson@14293
   769
paulson@14293
   770
paulson@14270
   771
text{*Compared with @{text mult_eq_0_iff}, this version removes the requirement
paulson@14270
   772
      of an ordering.*}
huffman@20496
   773
lemma field_mult_eq_0_iff [simp]:
huffman@20496
   774
  "(a*b = (0::'a::division_ring)) = (a = 0 | b = 0)"
paulson@14377
   775
proof cases
paulson@14377
   776
  assume "a=0" thus ?thesis by simp
paulson@14377
   777
next
paulson@14377
   778
  assume anz [simp]: "a\<noteq>0"
paulson@14377
   779
  { assume "a * b = 0"
paulson@14377
   780
    hence "inverse a * (a * b) = 0" by simp
paulson@14377
   781
    hence "b = 0"  by (simp (no_asm_use) add: mult_assoc [symmetric])}
paulson@14377
   782
  thus ?thesis by force
paulson@14377
   783
qed
paulson@14270
   784
paulson@14268
   785
text{*Cancellation of equalities with a common factor*}
paulson@14268
   786
lemma field_mult_cancel_right_lemma:
huffman@20496
   787
      assumes cnz: "c \<noteq> (0::'a::division_ring)"
huffman@20496
   788
         and eq:  "a*c = b*c"
huffman@20496
   789
        shows "a=b"
paulson@14377
   790
proof -
paulson@14268
   791
  have "(a * c) * inverse c = (b * c) * inverse c"
paulson@14268
   792
    by (simp add: eq)
paulson@14268
   793
  thus "a=b"
paulson@14268
   794
    by (simp add: mult_assoc cnz)
paulson@14377
   795
qed
paulson@14268
   796
paulson@14348
   797
lemma field_mult_cancel_right [simp]:
huffman@20496
   798
     "(a*c = b*c) = (c = (0::'a::division_ring) | a=b)"
huffman@20496
   799
proof -
huffman@20496
   800
  have "(a*c = b*c) = (a*c - b*c = 0)"
huffman@20496
   801
    by simp
huffman@20496
   802
  also have "\<dots> = ((a - b)*c = 0)"
huffman@20496
   803
     by (simp only: left_diff_distrib)
huffman@20496
   804
  also have "\<dots> = (c = 0 \<or> a = b)"
huffman@20496
   805
     by (simp add: disj_commute)
huffman@20496
   806
  finally show ?thesis .
paulson@14377
   807
qed
paulson@14268
   808
paulson@14348
   809
lemma field_mult_cancel_left [simp]:
huffman@20496
   810
     "(c*a = c*b) = (c = (0::'a::division_ring) | a=b)"
huffman@20496
   811
proof -
huffman@20496
   812
  have "(c*a = c*b) = (c*a - c*b = 0)"
huffman@20496
   813
    by simp
huffman@20496
   814
  also have "\<dots> = (c*(a - b) = 0)"
huffman@20496
   815
     by (simp only: right_diff_distrib)
huffman@20496
   816
  also have "\<dots> = (c = 0 \<or> a = b)"
huffman@20496
   817
     by simp
huffman@20496
   818
  finally show ?thesis .
huffman@20496
   819
qed
paulson@14268
   820
huffman@20496
   821
lemma nonzero_imp_inverse_nonzero:
huffman@20496
   822
  "a \<noteq> 0 ==> inverse a \<noteq> (0::'a::division_ring)"
paulson@14377
   823
proof
paulson@14268
   824
  assume ianz: "inverse a = 0"
paulson@14268
   825
  assume "a \<noteq> 0"
paulson@14268
   826
  hence "1 = a * inverse a" by simp
paulson@14268
   827
  also have "... = 0" by (simp add: ianz)
huffman@20496
   828
  finally have "1 = (0::'a::division_ring)" .
paulson@14268
   829
  thus False by (simp add: eq_commute)
paulson@14377
   830
qed
paulson@14268
   831
paulson@14277
   832
paulson@14277
   833
subsection{*Basic Properties of @{term inverse}*}
paulson@14277
   834
huffman@20496
   835
lemma inverse_zero_imp_zero: "inverse a = 0 ==> a = (0::'a::division_ring)"
paulson@14268
   836
apply (rule ccontr) 
paulson@14268
   837
apply (blast dest: nonzero_imp_inverse_nonzero) 
paulson@14268
   838
done
paulson@14268
   839
paulson@14268
   840
lemma inverse_nonzero_imp_nonzero:
huffman@20496
   841
   "inverse a = 0 ==> a = (0::'a::division_ring)"
paulson@14268
   842
apply (rule ccontr) 
paulson@14268
   843
apply (blast dest: nonzero_imp_inverse_nonzero) 
paulson@14268
   844
done
paulson@14268
   845
paulson@14268
   846
lemma inverse_nonzero_iff_nonzero [simp]:
huffman@20496
   847
   "(inverse a = 0) = (a = (0::'a::{division_ring,division_by_zero}))"
paulson@14268
   848
by (force dest: inverse_nonzero_imp_nonzero) 
paulson@14268
   849
paulson@14268
   850
lemma nonzero_inverse_minus_eq:
huffman@20496
   851
      assumes [simp]: "a\<noteq>0"
huffman@20496
   852
      shows "inverse(-a) = -inverse(a::'a::division_ring)"
paulson@14377
   853
proof -
paulson@14377
   854
  have "-a * inverse (- a) = -a * - inverse a"
paulson@14377
   855
    by simp
paulson@14377
   856
  thus ?thesis 
paulson@14377
   857
    by (simp only: field_mult_cancel_left, simp)
paulson@14377
   858
qed
paulson@14268
   859
paulson@14268
   860
lemma inverse_minus_eq [simp]:
huffman@20496
   861
   "inverse(-a) = -inverse(a::'a::{division_ring,division_by_zero})"
paulson@14377
   862
proof cases
paulson@14377
   863
  assume "a=0" thus ?thesis by (simp add: inverse_zero)
paulson@14377
   864
next
paulson@14377
   865
  assume "a\<noteq>0" 
paulson@14377
   866
  thus ?thesis by (simp add: nonzero_inverse_minus_eq)
paulson@14377
   867
qed
paulson@14268
   868
paulson@14268
   869
lemma nonzero_inverse_eq_imp_eq:
paulson@14269
   870
      assumes inveq: "inverse a = inverse b"
paulson@14269
   871
	  and anz:  "a \<noteq> 0"
paulson@14269
   872
	  and bnz:  "b \<noteq> 0"
huffman@20496
   873
	 shows "a = (b::'a::division_ring)"
paulson@14377
   874
proof -
paulson@14268
   875
  have "a * inverse b = a * inverse a"
paulson@14268
   876
    by (simp add: inveq)
paulson@14268
   877
  hence "(a * inverse b) * b = (a * inverse a) * b"
paulson@14268
   878
    by simp
paulson@14268
   879
  thus "a = b"
paulson@14268
   880
    by (simp add: mult_assoc anz bnz)
paulson@14377
   881
qed
paulson@14268
   882
paulson@14268
   883
lemma inverse_eq_imp_eq:
huffman@20496
   884
  "inverse a = inverse b ==> a = (b::'a::{division_ring,division_by_zero})"
haftmann@21328
   885
apply (cases "a=0 | b=0") 
paulson@14268
   886
 apply (force dest!: inverse_zero_imp_zero
paulson@14268
   887
              simp add: eq_commute [of "0::'a"])
paulson@14268
   888
apply (force dest!: nonzero_inverse_eq_imp_eq) 
paulson@14268
   889
done
paulson@14268
   890
paulson@14268
   891
lemma inverse_eq_iff_eq [simp]:
huffman@20496
   892
  "(inverse a = inverse b) = (a = (b::'a::{division_ring,division_by_zero}))"
huffman@20496
   893
by (force dest!: inverse_eq_imp_eq)
paulson@14268
   894
paulson@14270
   895
lemma nonzero_inverse_inverse_eq:
huffman@20496
   896
      assumes [simp]: "a \<noteq> 0"
huffman@20496
   897
      shows "inverse(inverse (a::'a::division_ring)) = a"
paulson@14270
   898
  proof -
paulson@14270
   899
  have "(inverse (inverse a) * inverse a) * a = a" 
paulson@14270
   900
    by (simp add: nonzero_imp_inverse_nonzero)
paulson@14270
   901
  thus ?thesis
paulson@14270
   902
    by (simp add: mult_assoc)
paulson@14270
   903
  qed
paulson@14270
   904
paulson@14270
   905
lemma inverse_inverse_eq [simp]:
huffman@20496
   906
     "inverse(inverse (a::'a::{division_ring,division_by_zero})) = a"
paulson@14270
   907
  proof cases
paulson@14270
   908
    assume "a=0" thus ?thesis by simp
paulson@14270
   909
  next
paulson@14270
   910
    assume "a\<noteq>0" 
paulson@14270
   911
    thus ?thesis by (simp add: nonzero_inverse_inverse_eq)
paulson@14270
   912
  qed
paulson@14270
   913
huffman@20496
   914
lemma inverse_1 [simp]: "inverse 1 = (1::'a::division_ring)"
paulson@14270
   915
  proof -
huffman@20496
   916
  have "inverse 1 * 1 = (1::'a::division_ring)" 
paulson@14270
   917
    by (rule left_inverse [OF zero_neq_one [symmetric]])
paulson@14270
   918
  thus ?thesis  by simp
paulson@14270
   919
  qed
paulson@14270
   920
paulson@15077
   921
lemma inverse_unique: 
paulson@15077
   922
  assumes ab: "a*b = 1"
huffman@20496
   923
  shows "inverse a = (b::'a::division_ring)"
paulson@15077
   924
proof -
paulson@15077
   925
  have "a \<noteq> 0" using ab by auto
paulson@15077
   926
  moreover have "inverse a * (a * b) = inverse a" by (simp add: ab) 
paulson@15077
   927
  ultimately show ?thesis by (simp add: mult_assoc [symmetric]) 
paulson@15077
   928
qed
paulson@15077
   929
paulson@14270
   930
lemma nonzero_inverse_mult_distrib: 
paulson@14270
   931
      assumes anz: "a \<noteq> 0"
paulson@14270
   932
          and bnz: "b \<noteq> 0"
huffman@20496
   933
      shows "inverse(a*b) = inverse(b) * inverse(a::'a::division_ring)"
paulson@14270
   934
  proof -
paulson@14270
   935
  have "inverse(a*b) * (a * b) * inverse(b) = inverse(b)" 
paulson@14270
   936
    by (simp add: field_mult_eq_0_iff anz bnz)
paulson@14270
   937
  hence "inverse(a*b) * a = inverse(b)" 
paulson@14270
   938
    by (simp add: mult_assoc bnz)
paulson@14270
   939
  hence "inverse(a*b) * a * inverse(a) = inverse(b) * inverse(a)" 
paulson@14270
   940
    by simp
paulson@14270
   941
  thus ?thesis
paulson@14270
   942
    by (simp add: mult_assoc anz)
paulson@14270
   943
  qed
paulson@14270
   944
paulson@14270
   945
text{*This version builds in division by zero while also re-orienting
paulson@14270
   946
      the right-hand side.*}
paulson@14270
   947
lemma inverse_mult_distrib [simp]:
paulson@14270
   948
     "inverse(a*b) = inverse(a) * inverse(b::'a::{field,division_by_zero})"
paulson@14270
   949
  proof cases
paulson@14270
   950
    assume "a \<noteq> 0 & b \<noteq> 0" 
paulson@14270
   951
    thus ?thesis  by (simp add: nonzero_inverse_mult_distrib mult_commute)
paulson@14270
   952
  next
paulson@14270
   953
    assume "~ (a \<noteq> 0 & b \<noteq> 0)" 
paulson@14270
   954
    thus ?thesis  by force
paulson@14270
   955
  qed
paulson@14270
   956
huffman@20496
   957
lemma division_ring_inverse_add:
huffman@20496
   958
  "[|(a::'a::division_ring) \<noteq> 0; b \<noteq> 0|]
huffman@20496
   959
   ==> inverse a + inverse b = inverse a * (a+b) * inverse b"
huffman@20496
   960
by (simp add: right_distrib left_distrib mult_assoc)
huffman@20496
   961
huffman@20496
   962
lemma division_ring_inverse_diff:
huffman@20496
   963
  "[|(a::'a::division_ring) \<noteq> 0; b \<noteq> 0|]
huffman@20496
   964
   ==> inverse a - inverse b = inverse a * (b-a) * inverse b"
huffman@20496
   965
by (simp add: right_diff_distrib left_diff_distrib mult_assoc)
huffman@20496
   966
paulson@14270
   967
text{*There is no slick version using division by zero.*}
paulson@14270
   968
lemma inverse_add:
paulson@14270
   969
     "[|a \<noteq> 0;  b \<noteq> 0|]
paulson@14270
   970
      ==> inverse a + inverse b = (a+b) * inverse a * inverse (b::'a::field)"
huffman@20496
   971
by (simp add: division_ring_inverse_add mult_ac)
paulson@14270
   972
paulson@14365
   973
lemma inverse_divide [simp]:
paulson@14365
   974
      "inverse (a/b) = b / (a::'a::{field,division_by_zero})"
paulson@14430
   975
  by (simp add: divide_inverse mult_commute)
paulson@14365
   976
avigad@16775
   977
subsection {* Calculations with fractions *}
avigad@16775
   978
paulson@14277
   979
lemma nonzero_mult_divide_cancel_left:
paulson@14277
   980
  assumes [simp]: "b\<noteq>0" and [simp]: "c\<noteq>0" 
paulson@14277
   981
    shows "(c*a)/(c*b) = a/(b::'a::field)"
paulson@14277
   982
proof -
paulson@14277
   983
  have "(c*a)/(c*b) = c * a * (inverse b * inverse c)"
paulson@14277
   984
    by (simp add: field_mult_eq_0_iff divide_inverse 
paulson@14277
   985
                  nonzero_inverse_mult_distrib)
paulson@14277
   986
  also have "... =  a * inverse b * (inverse c * c)"
paulson@14277
   987
    by (simp only: mult_ac)
paulson@14277
   988
  also have "... =  a * inverse b"
paulson@14277
   989
    by simp
paulson@14277
   990
    finally show ?thesis 
paulson@14277
   991
    by (simp add: divide_inverse)
paulson@14277
   992
qed
paulson@14277
   993
paulson@14277
   994
lemma mult_divide_cancel_left:
paulson@14277
   995
     "c\<noteq>0 ==> (c*a) / (c*b) = a / (b::'a::{field,division_by_zero})"
haftmann@21328
   996
apply (cases "b = 0")
paulson@14277
   997
apply (simp_all add: nonzero_mult_divide_cancel_left)
paulson@14277
   998
done
paulson@14277
   999
paulson@14321
  1000
lemma nonzero_mult_divide_cancel_right:
paulson@14321
  1001
     "[|b\<noteq>0; c\<noteq>0|] ==> (a*c) / (b*c) = a/(b::'a::field)"
paulson@14321
  1002
by (simp add: mult_commute [of _ c] nonzero_mult_divide_cancel_left) 
paulson@14321
  1003
paulson@14321
  1004
lemma mult_divide_cancel_right:
paulson@14321
  1005
     "c\<noteq>0 ==> (a*c) / (b*c) = a / (b::'a::{field,division_by_zero})"
haftmann@21328
  1006
apply (cases "b = 0")
paulson@14321
  1007
apply (simp_all add: nonzero_mult_divide_cancel_right)
paulson@14321
  1008
done
paulson@14321
  1009
paulson@14277
  1010
(*For ExtractCommonTerm*)
paulson@14277
  1011
lemma mult_divide_cancel_eq_if:
paulson@14277
  1012
     "(c*a) / (c*b) = 
paulson@14277
  1013
      (if c=0 then 0 else a / (b::'a::{field,division_by_zero}))"
paulson@14277
  1014
  by (simp add: mult_divide_cancel_left)
paulson@14277
  1015
paulson@14284
  1016
lemma divide_1 [simp]: "a/1 = (a::'a::field)"
paulson@14430
  1017
  by (simp add: divide_inverse)
paulson@14284
  1018
paulson@15234
  1019
lemma times_divide_eq_right: "a * (b/c) = (a*b) / (c::'a::field)"
paulson@14430
  1020
by (simp add: divide_inverse mult_assoc)
paulson@14288
  1021
paulson@14430
  1022
lemma times_divide_eq_left: "(b/c) * a = (b*a) / (c::'a::field)"
paulson@14430
  1023
by (simp add: divide_inverse mult_ac)
paulson@14288
  1024
paulson@14288
  1025
lemma divide_divide_eq_right [simp]:
paulson@14288
  1026
     "a / (b/c) = (a*c) / (b::'a::{field,division_by_zero})"
paulson@14430
  1027
by (simp add: divide_inverse mult_ac)
paulson@14288
  1028
paulson@14288
  1029
lemma divide_divide_eq_left [simp]:
paulson@14288
  1030
     "(a / b) / (c::'a::{field,division_by_zero}) = a / (b*c)"
paulson@14430
  1031
by (simp add: divide_inverse mult_assoc)
paulson@14288
  1032
avigad@16775
  1033
lemma add_frac_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==>
avigad@16775
  1034
    x / y + w / z = (x * z + w * y) / (y * z)"
avigad@16775
  1035
  apply (subgoal_tac "x / y = (x * z) / (y * z)")
avigad@16775
  1036
  apply (erule ssubst)
avigad@16775
  1037
  apply (subgoal_tac "w / z = (w * y) / (y * z)")
avigad@16775
  1038
  apply (erule ssubst)
avigad@16775
  1039
  apply (rule add_divide_distrib [THEN sym])
avigad@16775
  1040
  apply (subst mult_commute)
avigad@16775
  1041
  apply (erule nonzero_mult_divide_cancel_left [THEN sym])
avigad@16775
  1042
  apply assumption
avigad@16775
  1043
  apply (erule nonzero_mult_divide_cancel_right [THEN sym])
avigad@16775
  1044
  apply assumption
avigad@16775
  1045
done
paulson@14268
  1046
paulson@15234
  1047
subsubsection{*Special Cancellation Simprules for Division*}
paulson@15234
  1048
paulson@15234
  1049
lemma mult_divide_cancel_left_if [simp]:
paulson@15234
  1050
  fixes c :: "'a :: {field,division_by_zero}"
paulson@15234
  1051
  shows "(c*a) / (c*b) = (if c=0 then 0 else a/b)"
paulson@15234
  1052
by (simp add: mult_divide_cancel_left)
paulson@15234
  1053
paulson@15234
  1054
lemma mult_divide_cancel_right_if [simp]:
paulson@15234
  1055
  fixes c :: "'a :: {field,division_by_zero}"
paulson@15234
  1056
  shows "(a*c) / (b*c) = (if c=0 then 0 else a/b)"
paulson@15234
  1057
by (simp add: mult_divide_cancel_right)
paulson@15234
  1058
paulson@15234
  1059
lemma mult_divide_cancel_left_if1 [simp]:
paulson@15234
  1060
  fixes c :: "'a :: {field,division_by_zero}"
paulson@15234
  1061
  shows "c / (c*b) = (if c=0 then 0 else 1/b)"
paulson@15234
  1062
apply (insert mult_divide_cancel_left_if [of c 1 b]) 
paulson@15234
  1063
apply (simp del: mult_divide_cancel_left_if)
paulson@15234
  1064
done
paulson@15234
  1065
paulson@15234
  1066
lemma mult_divide_cancel_left_if2 [simp]:
paulson@15234
  1067
  fixes c :: "'a :: {field,division_by_zero}"
paulson@15234
  1068
  shows "(c*a) / c = (if c=0 then 0 else a)" 
paulson@15234
  1069
apply (insert mult_divide_cancel_left_if [of c a 1]) 
paulson@15234
  1070
apply (simp del: mult_divide_cancel_left_if)
paulson@15234
  1071
done
paulson@15234
  1072
paulson@15234
  1073
lemma mult_divide_cancel_right_if1 [simp]:
paulson@15234
  1074
  fixes c :: "'a :: {field,division_by_zero}"
paulson@15234
  1075
  shows "c / (b*c) = (if c=0 then 0 else 1/b)"
paulson@15234
  1076
apply (insert mult_divide_cancel_right_if [of 1 c b]) 
paulson@15234
  1077
apply (simp del: mult_divide_cancel_right_if)
paulson@15234
  1078
done
paulson@15234
  1079
paulson@15234
  1080
lemma mult_divide_cancel_right_if2 [simp]:
paulson@15234
  1081
  fixes c :: "'a :: {field,division_by_zero}"
paulson@15234
  1082
  shows "(a*c) / c = (if c=0 then 0 else a)" 
paulson@15234
  1083
apply (insert mult_divide_cancel_right_if [of a c 1]) 
paulson@15234
  1084
apply (simp del: mult_divide_cancel_right_if)
paulson@15234
  1085
done
paulson@15234
  1086
paulson@15234
  1087
text{*Two lemmas for cancelling the denominator*}
paulson@15234
  1088
paulson@15234
  1089
lemma times_divide_self_right [simp]: 
paulson@15234
  1090
  fixes a :: "'a :: {field,division_by_zero}"
paulson@15234
  1091
  shows "a * (b/a) = (if a=0 then 0 else b)"
paulson@15234
  1092
by (simp add: times_divide_eq_right)
paulson@15234
  1093
paulson@15234
  1094
lemma times_divide_self_left [simp]: 
paulson@15234
  1095
  fixes a :: "'a :: {field,division_by_zero}"
paulson@15234
  1096
  shows "(b/a) * a = (if a=0 then 0 else b)"
paulson@15234
  1097
by (simp add: times_divide_eq_left)
paulson@15234
  1098
paulson@15234
  1099
paulson@14293
  1100
subsection {* Division and Unary Minus *}
paulson@14293
  1101
paulson@14293
  1102
lemma nonzero_minus_divide_left: "b \<noteq> 0 ==> - (a/b) = (-a) / (b::'a::field)"
paulson@14293
  1103
by (simp add: divide_inverse minus_mult_left)
paulson@14293
  1104
paulson@14293
  1105
lemma nonzero_minus_divide_right: "b \<noteq> 0 ==> - (a/b) = a / -(b::'a::field)"
paulson@14293
  1106
by (simp add: divide_inverse nonzero_inverse_minus_eq minus_mult_right)
paulson@14293
  1107
paulson@14293
  1108
lemma nonzero_minus_divide_divide: "b \<noteq> 0 ==> (-a)/(-b) = a / (b::'a::field)"
paulson@14293
  1109
by (simp add: divide_inverse nonzero_inverse_minus_eq)
paulson@14293
  1110
paulson@14430
  1111
lemma minus_divide_left: "- (a/b) = (-a) / (b::'a::field)"
paulson@14430
  1112
by (simp add: divide_inverse minus_mult_left [symmetric])
paulson@14293
  1113
paulson@14293
  1114
lemma minus_divide_right: "- (a/b) = a / -(b::'a::{field,division_by_zero})"
paulson@14430
  1115
by (simp add: divide_inverse minus_mult_right [symmetric])
paulson@14430
  1116
paulson@14293
  1117
paulson@14293
  1118
text{*The effect is to extract signs from divisions*}
paulson@17085
  1119
lemmas divide_minus_left = minus_divide_left [symmetric]
paulson@17085
  1120
lemmas divide_minus_right = minus_divide_right [symmetric]
paulson@17085
  1121
declare divide_minus_left [simp]   divide_minus_right [simp]
paulson@14293
  1122
paulson@14387
  1123
text{*Also, extract signs from products*}
paulson@17085
  1124
lemmas mult_minus_left = minus_mult_left [symmetric]
paulson@17085
  1125
lemmas mult_minus_right = minus_mult_right [symmetric]
paulson@17085
  1126
declare mult_minus_left [simp]   mult_minus_right [simp]
paulson@14387
  1127
paulson@14293
  1128
lemma minus_divide_divide [simp]:
paulson@14293
  1129
     "(-a)/(-b) = a / (b::'a::{field,division_by_zero})"
haftmann@21328
  1130
apply (cases "b=0", simp) 
paulson@14293
  1131
apply (simp add: nonzero_minus_divide_divide) 
paulson@14293
  1132
done
paulson@14293
  1133
paulson@14430
  1134
lemma diff_divide_distrib: "(a-b)/(c::'a::field) = a/c - b/c"
paulson@14387
  1135
by (simp add: diff_minus add_divide_distrib) 
paulson@14387
  1136
avigad@16775
  1137
lemma diff_frac_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==>
avigad@16775
  1138
    x / y - w / z = (x * z - w * y) / (y * z)"
avigad@16775
  1139
  apply (subst diff_def)+
avigad@16775
  1140
  apply (subst minus_divide_left)
avigad@16775
  1141
  apply (subst add_frac_eq)
avigad@16775
  1142
  apply simp_all
avigad@16775
  1143
done
paulson@14293
  1144
paulson@14268
  1145
subsection {* Ordered Fields *}
paulson@14268
  1146
paulson@14277
  1147
lemma positive_imp_inverse_positive: 
paulson@14269
  1148
      assumes a_gt_0: "0 < a"  shows "0 < inverse (a::'a::ordered_field)"
paulson@14268
  1149
  proof -
paulson@14268
  1150
  have "0 < a * inverse a" 
paulson@14268
  1151
    by (simp add: a_gt_0 [THEN order_less_imp_not_eq2] zero_less_one)
paulson@14268
  1152
  thus "0 < inverse a" 
paulson@14268
  1153
    by (simp add: a_gt_0 [THEN order_less_not_sym] zero_less_mult_iff)
paulson@14268
  1154
  qed
paulson@14268
  1155
paulson@14277
  1156
lemma negative_imp_inverse_negative:
paulson@14268
  1157
     "a < 0 ==> inverse a < (0::'a::ordered_field)"
paulson@14277
  1158
  by (insert positive_imp_inverse_positive [of "-a"], 
paulson@14268
  1159
      simp add: nonzero_inverse_minus_eq order_less_imp_not_eq) 
paulson@14268
  1160
paulson@14268
  1161
lemma inverse_le_imp_le:
paulson@14269
  1162
      assumes invle: "inverse a \<le> inverse b"
paulson@14269
  1163
	  and apos:  "0 < a"
paulson@14269
  1164
	 shows "b \<le> (a::'a::ordered_field)"
paulson@14268
  1165
  proof (rule classical)
paulson@14268
  1166
  assume "~ b \<le> a"
paulson@14268
  1167
  hence "a < b"
paulson@14268
  1168
    by (simp add: linorder_not_le)
paulson@14268
  1169
  hence bpos: "0 < b"
paulson@14268
  1170
    by (blast intro: apos order_less_trans)
paulson@14268
  1171
  hence "a * inverse a \<le> a * inverse b"
paulson@14268
  1172
    by (simp add: apos invle order_less_imp_le mult_left_mono)
paulson@14268
  1173
  hence "(a * inverse a) * b \<le> (a * inverse b) * b"
paulson@14268
  1174
    by (simp add: bpos order_less_imp_le mult_right_mono)
paulson@14268
  1175
  thus "b \<le> a"
paulson@14268
  1176
    by (simp add: mult_assoc apos bpos order_less_imp_not_eq2)
paulson@14268
  1177
  qed
paulson@14268
  1178
paulson@14277
  1179
lemma inverse_positive_imp_positive:
paulson@14277
  1180
      assumes inv_gt_0: "0 < inverse a"
paulson@14277
  1181
          and [simp]:   "a \<noteq> 0"
paulson@14277
  1182
        shows "0 < (a::'a::ordered_field)"
paulson@14277
  1183
  proof -
paulson@14277
  1184
  have "0 < inverse (inverse a)"
paulson@14277
  1185
    by (rule positive_imp_inverse_positive)
paulson@14277
  1186
  thus "0 < a"
paulson@14277
  1187
    by (simp add: nonzero_inverse_inverse_eq)
paulson@14277
  1188
  qed
paulson@14277
  1189
paulson@14277
  1190
lemma inverse_positive_iff_positive [simp]:
paulson@14277
  1191
      "(0 < inverse a) = (0 < (a::'a::{ordered_field,division_by_zero}))"
haftmann@21328
  1192
apply (cases "a = 0", simp)
paulson@14277
  1193
apply (blast intro: inverse_positive_imp_positive positive_imp_inverse_positive)
paulson@14277
  1194
done
paulson@14277
  1195
paulson@14277
  1196
lemma inverse_negative_imp_negative:
paulson@14277
  1197
      assumes inv_less_0: "inverse a < 0"
paulson@14277
  1198
          and [simp]:   "a \<noteq> 0"
paulson@14277
  1199
        shows "a < (0::'a::ordered_field)"
paulson@14277
  1200
  proof -
paulson@14277
  1201
  have "inverse (inverse a) < 0"
paulson@14277
  1202
    by (rule negative_imp_inverse_negative)
paulson@14277
  1203
  thus "a < 0"
paulson@14277
  1204
    by (simp add: nonzero_inverse_inverse_eq)
paulson@14277
  1205
  qed
paulson@14277
  1206
paulson@14277
  1207
lemma inverse_negative_iff_negative [simp]:
paulson@14277
  1208
      "(inverse a < 0) = (a < (0::'a::{ordered_field,division_by_zero}))"
haftmann@21328
  1209
apply (cases "a = 0", simp)
paulson@14277
  1210
apply (blast intro: inverse_negative_imp_negative negative_imp_inverse_negative)
paulson@14277
  1211
done
paulson@14277
  1212
paulson@14277
  1213
lemma inverse_nonnegative_iff_nonnegative [simp]:
paulson@14277
  1214
      "(0 \<le> inverse a) = (0 \<le> (a::'a::{ordered_field,division_by_zero}))"
paulson@14277
  1215
by (simp add: linorder_not_less [symmetric])
paulson@14277
  1216
paulson@14277
  1217
lemma inverse_nonpositive_iff_nonpositive [simp]:
paulson@14277
  1218
      "(inverse a \<le> 0) = (a \<le> (0::'a::{ordered_field,division_by_zero}))"
paulson@14277
  1219
by (simp add: linorder_not_less [symmetric])
paulson@14277
  1220
paulson@14277
  1221
paulson@14277
  1222
subsection{*Anti-Monotonicity of @{term inverse}*}
paulson@14277
  1223
paulson@14268
  1224
lemma less_imp_inverse_less:
paulson@14269
  1225
      assumes less: "a < b"
paulson@14269
  1226
	  and apos:  "0 < a"
paulson@14269
  1227
	shows "inverse b < inverse (a::'a::ordered_field)"
paulson@14268
  1228
  proof (rule ccontr)
paulson@14268
  1229
  assume "~ inverse b < inverse a"
paulson@14268
  1230
  hence "inverse a \<le> inverse b"
paulson@14268
  1231
    by (simp add: linorder_not_less)
paulson@14268
  1232
  hence "~ (a < b)"
paulson@14268
  1233
    by (simp add: linorder_not_less inverse_le_imp_le [OF _ apos])
paulson@14268
  1234
  thus False
paulson@14268
  1235
    by (rule notE [OF _ less])
paulson@14268
  1236
  qed
paulson@14268
  1237
paulson@14268
  1238
lemma inverse_less_imp_less:
paulson@14268
  1239
   "[|inverse a < inverse b; 0 < a|] ==> b < (a::'a::ordered_field)"
paulson@14268
  1240
apply (simp add: order_less_le [of "inverse a"] order_less_le [of "b"])
paulson@14268
  1241
apply (force dest!: inverse_le_imp_le nonzero_inverse_eq_imp_eq) 
paulson@14268
  1242
done
paulson@14268
  1243
paulson@14268
  1244
text{*Both premises are essential. Consider -1 and 1.*}
paulson@14268
  1245
lemma inverse_less_iff_less [simp]:
paulson@14268
  1246
     "[|0 < a; 0 < b|] 
paulson@14268
  1247
      ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
paulson@14268
  1248
by (blast intro: less_imp_inverse_less dest: inverse_less_imp_less) 
paulson@14268
  1249
paulson@14268
  1250
lemma le_imp_inverse_le:
paulson@14268
  1251
   "[|a \<le> b; 0 < a|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
paulson@14268
  1252
  by (force simp add: order_le_less less_imp_inverse_less)
paulson@14268
  1253
paulson@14268
  1254
lemma inverse_le_iff_le [simp]:
paulson@14268
  1255
     "[|0 < a; 0 < b|] 
paulson@14268
  1256
      ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
paulson@14268
  1257
by (blast intro: le_imp_inverse_le dest: inverse_le_imp_le) 
paulson@14268
  1258
paulson@14268
  1259
paulson@14268
  1260
text{*These results refer to both operands being negative.  The opposite-sign
paulson@14268
  1261
case is trivial, since inverse preserves signs.*}
paulson@14268
  1262
lemma inverse_le_imp_le_neg:
paulson@14268
  1263
   "[|inverse a \<le> inverse b; b < 0|] ==> b \<le> (a::'a::ordered_field)"
paulson@14268
  1264
  apply (rule classical) 
paulson@14268
  1265
  apply (subgoal_tac "a < 0") 
paulson@14268
  1266
   prefer 2 apply (force simp add: linorder_not_le intro: order_less_trans) 
paulson@14268
  1267
  apply (insert inverse_le_imp_le [of "-b" "-a"])
paulson@14268
  1268
  apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
paulson@14268
  1269
  done
paulson@14268
  1270
paulson@14268
  1271
lemma less_imp_inverse_less_neg:
paulson@14268
  1272
   "[|a < b; b < 0|] ==> inverse b < inverse (a::'a::ordered_field)"
paulson@14268
  1273
  apply (subgoal_tac "a < 0") 
paulson@14268
  1274
   prefer 2 apply (blast intro: order_less_trans) 
paulson@14268
  1275
  apply (insert less_imp_inverse_less [of "-b" "-a"])
paulson@14268
  1276
  apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
paulson@14268
  1277
  done
paulson@14268
  1278
paulson@14268
  1279
lemma inverse_less_imp_less_neg:
paulson@14268
  1280
   "[|inverse a < inverse b; b < 0|] ==> b < (a::'a::ordered_field)"
paulson@14268
  1281
  apply (rule classical) 
paulson@14268
  1282
  apply (subgoal_tac "a < 0") 
paulson@14268
  1283
   prefer 2
paulson@14268
  1284
   apply (force simp add: linorder_not_less intro: order_le_less_trans) 
paulson@14268
  1285
  apply (insert inverse_less_imp_less [of "-b" "-a"])
paulson@14268
  1286
  apply (simp add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
paulson@14268
  1287
  done
paulson@14268
  1288
paulson@14268
  1289
lemma inverse_less_iff_less_neg [simp]:
paulson@14268
  1290
     "[|a < 0; b < 0|] 
paulson@14268
  1291
      ==> (inverse a < inverse b) = (b < (a::'a::ordered_field))"
paulson@14268
  1292
  apply (insert inverse_less_iff_less [of "-b" "-a"])
paulson@14268
  1293
  apply (simp del: inverse_less_iff_less 
paulson@14268
  1294
	      add: order_less_imp_not_eq nonzero_inverse_minus_eq) 
paulson@14268
  1295
  done
paulson@14268
  1296
paulson@14268
  1297
lemma le_imp_inverse_le_neg:
paulson@14268
  1298
   "[|a \<le> b; b < 0|] ==> inverse b \<le> inverse (a::'a::ordered_field)"
paulson@14268
  1299
  by (force simp add: order_le_less less_imp_inverse_less_neg)
paulson@14268
  1300
paulson@14268
  1301
lemma inverse_le_iff_le_neg [simp]:
paulson@14268
  1302
     "[|a < 0; b < 0|] 
paulson@14268
  1303
      ==> (inverse a \<le> inverse b) = (b \<le> (a::'a::ordered_field))"
paulson@14268
  1304
by (blast intro: le_imp_inverse_le_neg dest: inverse_le_imp_le_neg) 
paulson@14265
  1305
paulson@14277
  1306
paulson@14365
  1307
subsection{*Inverses and the Number One*}
paulson@14365
  1308
paulson@14365
  1309
lemma one_less_inverse_iff:
paulson@14365
  1310
    "(1 < inverse x) = (0 < x & x < (1::'a::{ordered_field,division_by_zero}))"proof cases
paulson@14365
  1311
  assume "0 < x"
paulson@14365
  1312
    with inverse_less_iff_less [OF zero_less_one, of x]
paulson@14365
  1313
    show ?thesis by simp
paulson@14365
  1314
next
paulson@14365
  1315
  assume notless: "~ (0 < x)"
paulson@14365
  1316
  have "~ (1 < inverse x)"
paulson@14365
  1317
  proof
paulson@14365
  1318
    assume "1 < inverse x"
paulson@14365
  1319
    also with notless have "... \<le> 0" by (simp add: linorder_not_less)
paulson@14365
  1320
    also have "... < 1" by (rule zero_less_one) 
paulson@14365
  1321
    finally show False by auto
paulson@14365
  1322
  qed
paulson@14365
  1323
  with notless show ?thesis by simp
paulson@14365
  1324
qed
paulson@14365
  1325
paulson@14365
  1326
lemma inverse_eq_1_iff [simp]:
paulson@14365
  1327
    "(inverse x = 1) = (x = (1::'a::{field,division_by_zero}))"
paulson@14365
  1328
by (insert inverse_eq_iff_eq [of x 1], simp) 
paulson@14365
  1329
paulson@14365
  1330
lemma one_le_inverse_iff:
paulson@14365
  1331
   "(1 \<le> inverse x) = (0 < x & x \<le> (1::'a::{ordered_field,division_by_zero}))"
paulson@14365
  1332
by (force simp add: order_le_less one_less_inverse_iff zero_less_one 
paulson@14365
  1333
                    eq_commute [of 1]) 
paulson@14365
  1334
paulson@14365
  1335
lemma inverse_less_1_iff:
paulson@14365
  1336
   "(inverse x < 1) = (x \<le> 0 | 1 < (x::'a::{ordered_field,division_by_zero}))"
paulson@14365
  1337
by (simp add: linorder_not_le [symmetric] one_le_inverse_iff) 
paulson@14365
  1338
paulson@14365
  1339
lemma inverse_le_1_iff:
paulson@14365
  1340
   "(inverse x \<le> 1) = (x \<le> 0 | 1 \<le> (x::'a::{ordered_field,division_by_zero}))"
paulson@14365
  1341
by (simp add: linorder_not_less [symmetric] one_less_inverse_iff) 
paulson@14365
  1342
paulson@14288
  1343
subsection{*Simplification of Inequalities Involving Literal Divisors*}
paulson@14288
  1344
paulson@14288
  1345
lemma pos_le_divide_eq: "0 < (c::'a::ordered_field) ==> (a \<le> b/c) = (a*c \<le> b)"
paulson@14288
  1346
proof -
paulson@14288
  1347
  assume less: "0<c"
paulson@14288
  1348
  hence "(a \<le> b/c) = (a*c \<le> (b/c)*c)"
paulson@14288
  1349
    by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
paulson@14288
  1350
  also have "... = (a*c \<le> b)"
paulson@14288
  1351
    by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
paulson@14288
  1352
  finally show ?thesis .
paulson@14288
  1353
qed
paulson@14288
  1354
paulson@14288
  1355
lemma neg_le_divide_eq: "c < (0::'a::ordered_field) ==> (a \<le> b/c) = (b \<le> a*c)"
paulson@14288
  1356
proof -
paulson@14288
  1357
  assume less: "c<0"
paulson@14288
  1358
  hence "(a \<le> b/c) = ((b/c)*c \<le> a*c)"
paulson@14288
  1359
    by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
paulson@14288
  1360
  also have "... = (b \<le> a*c)"
paulson@14288
  1361
    by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
paulson@14288
  1362
  finally show ?thesis .
paulson@14288
  1363
qed
paulson@14288
  1364
paulson@14288
  1365
lemma le_divide_eq:
paulson@14288
  1366
  "(a \<le> b/c) = 
paulson@14288
  1367
   (if 0 < c then a*c \<le> b
paulson@14288
  1368
             else if c < 0 then b \<le> a*c
paulson@14288
  1369
             else  a \<le> (0::'a::{ordered_field,division_by_zero}))"
haftmann@21328
  1370
apply (cases "c=0", simp) 
paulson@14288
  1371
apply (force simp add: pos_le_divide_eq neg_le_divide_eq linorder_neq_iff) 
paulson@14288
  1372
done
paulson@14288
  1373
paulson@14288
  1374
lemma pos_divide_le_eq: "0 < (c::'a::ordered_field) ==> (b/c \<le> a) = (b \<le> a*c)"
paulson@14288
  1375
proof -
paulson@14288
  1376
  assume less: "0<c"
paulson@14288
  1377
  hence "(b/c \<le> a) = ((b/c)*c \<le> a*c)"
paulson@14288
  1378
    by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
paulson@14288
  1379
  also have "... = (b \<le> a*c)"
paulson@14288
  1380
    by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
paulson@14288
  1381
  finally show ?thesis .
paulson@14288
  1382
qed
paulson@14288
  1383
paulson@14288
  1384
lemma neg_divide_le_eq: "c < (0::'a::ordered_field) ==> (b/c \<le> a) = (a*c \<le> b)"
paulson@14288
  1385
proof -
paulson@14288
  1386
  assume less: "c<0"
paulson@14288
  1387
  hence "(b/c \<le> a) = (a*c \<le> (b/c)*c)"
paulson@14288
  1388
    by (simp add: mult_le_cancel_right order_less_not_sym [OF less])
paulson@14288
  1389
  also have "... = (a*c \<le> b)"
paulson@14288
  1390
    by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
paulson@14288
  1391
  finally show ?thesis .
paulson@14288
  1392
qed
paulson@14288
  1393
paulson@14288
  1394
lemma divide_le_eq:
paulson@14288
  1395
  "(b/c \<le> a) = 
paulson@14288
  1396
   (if 0 < c then b \<le> a*c
paulson@14288
  1397
             else if c < 0 then a*c \<le> b
paulson@14288
  1398
             else 0 \<le> (a::'a::{ordered_field,division_by_zero}))"
haftmann@21328
  1399
apply (cases "c=0", simp) 
paulson@14288
  1400
apply (force simp add: pos_divide_le_eq neg_divide_le_eq linorder_neq_iff) 
paulson@14288
  1401
done
paulson@14288
  1402
paulson@14288
  1403
lemma pos_less_divide_eq:
paulson@14288
  1404
     "0 < (c::'a::ordered_field) ==> (a < b/c) = (a*c < b)"
paulson@14288
  1405
proof -
paulson@14288
  1406
  assume less: "0<c"
paulson@14288
  1407
  hence "(a < b/c) = (a*c < (b/c)*c)"
paulson@15234
  1408
    by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
paulson@14288
  1409
  also have "... = (a*c < b)"
paulson@14288
  1410
    by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
paulson@14288
  1411
  finally show ?thesis .
paulson@14288
  1412
qed
paulson@14288
  1413
paulson@14288
  1414
lemma neg_less_divide_eq:
paulson@14288
  1415
 "c < (0::'a::ordered_field) ==> (a < b/c) = (b < a*c)"
paulson@14288
  1416
proof -
paulson@14288
  1417
  assume less: "c<0"
paulson@14288
  1418
  hence "(a < b/c) = ((b/c)*c < a*c)"
paulson@15234
  1419
    by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
paulson@14288
  1420
  also have "... = (b < a*c)"
paulson@14288
  1421
    by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
paulson@14288
  1422
  finally show ?thesis .
paulson@14288
  1423
qed
paulson@14288
  1424
paulson@14288
  1425
lemma less_divide_eq:
paulson@14288
  1426
  "(a < b/c) = 
paulson@14288
  1427
   (if 0 < c then a*c < b
paulson@14288
  1428
             else if c < 0 then b < a*c
paulson@14288
  1429
             else  a < (0::'a::{ordered_field,division_by_zero}))"
haftmann@21328
  1430
apply (cases "c=0", simp) 
paulson@14288
  1431
apply (force simp add: pos_less_divide_eq neg_less_divide_eq linorder_neq_iff) 
paulson@14288
  1432
done
paulson@14288
  1433
paulson@14288
  1434
lemma pos_divide_less_eq:
paulson@14288
  1435
     "0 < (c::'a::ordered_field) ==> (b/c < a) = (b < a*c)"
paulson@14288
  1436
proof -
paulson@14288
  1437
  assume less: "0<c"
paulson@14288
  1438
  hence "(b/c < a) = ((b/c)*c < a*c)"
paulson@15234
  1439
    by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
paulson@14288
  1440
  also have "... = (b < a*c)"
paulson@14288
  1441
    by (simp add: order_less_imp_not_eq2 [OF less] divide_inverse mult_assoc) 
paulson@14288
  1442
  finally show ?thesis .
paulson@14288
  1443
qed
paulson@14288
  1444
paulson@14288
  1445
lemma neg_divide_less_eq:
paulson@14288
  1446
 "c < (0::'a::ordered_field) ==> (b/c < a) = (a*c < b)"
paulson@14288
  1447
proof -
paulson@14288
  1448
  assume less: "c<0"
paulson@14288
  1449
  hence "(b/c < a) = (a*c < (b/c)*c)"
paulson@15234
  1450
    by (simp add: mult_less_cancel_right_disj order_less_not_sym [OF less])
paulson@14288
  1451
  also have "... = (a*c < b)"
paulson@14288
  1452
    by (simp add: order_less_imp_not_eq [OF less] divide_inverse mult_assoc) 
paulson@14288
  1453
  finally show ?thesis .
paulson@14288
  1454
qed
paulson@14288
  1455
paulson@14288
  1456
lemma divide_less_eq:
paulson@14288
  1457
  "(b/c < a) = 
paulson@14288
  1458
   (if 0 < c then b < a*c
paulson@14288
  1459
             else if c < 0 then a*c < b
paulson@14288
  1460
             else 0 < (a::'a::{ordered_field,division_by_zero}))"
haftmann@21328
  1461
apply (cases "c=0", simp) 
paulson@14288
  1462
apply (force simp add: pos_divide_less_eq neg_divide_less_eq linorder_neq_iff) 
paulson@14288
  1463
done
paulson@14288
  1464
paulson@14288
  1465
lemma nonzero_eq_divide_eq: "c\<noteq>0 ==> ((a::'a::field) = b/c) = (a*c = b)"
paulson@14288
  1466
proof -
paulson@14288
  1467
  assume [simp]: "c\<noteq>0"
paulson@14288
  1468
  have "(a = b/c) = (a*c = (b/c)*c)"
paulson@14288
  1469
    by (simp add: field_mult_cancel_right)
paulson@14288
  1470
  also have "... = (a*c = b)"
paulson@14288
  1471
    by (simp add: divide_inverse mult_assoc) 
paulson@14288
  1472
  finally show ?thesis .
paulson@14288
  1473
qed
paulson@14288
  1474
paulson@14288
  1475
lemma eq_divide_eq:
paulson@14288
  1476
  "((a::'a::{field,division_by_zero}) = b/c) = (if c\<noteq>0 then a*c = b else a=0)"
paulson@14288
  1477
by (simp add: nonzero_eq_divide_eq) 
paulson@14288
  1478
paulson@14288
  1479
lemma nonzero_divide_eq_eq: "c\<noteq>0 ==> (b/c = (a::'a::field)) = (b = a*c)"
paulson@14288
  1480
proof -
paulson@14288
  1481
  assume [simp]: "c\<noteq>0"
paulson@14288
  1482
  have "(b/c = a) = ((b/c)*c = a*c)"
paulson@14288
  1483
    by (simp add: field_mult_cancel_right)
paulson@14288
  1484
  also have "... = (b = a*c)"
paulson@14288
  1485
    by (simp add: divide_inverse mult_assoc) 
paulson@14288
  1486
  finally show ?thesis .
paulson@14288
  1487
qed
paulson@14288
  1488
paulson@14288
  1489
lemma divide_eq_eq:
paulson@14288
  1490
  "(b/c = (a::'a::{field,division_by_zero})) = (if c\<noteq>0 then b = a*c else a=0)"
paulson@14288
  1491
by (force simp add: nonzero_divide_eq_eq) 
paulson@14288
  1492
avigad@16775
  1493
lemma divide_eq_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==>
avigad@16775
  1494
    b = a * c ==> b / c = a"
avigad@16775
  1495
  by (subst divide_eq_eq, simp)
avigad@16775
  1496
avigad@16775
  1497
lemma eq_divide_imp: "(c::'a::{division_by_zero,field}) ~= 0 ==>
avigad@16775
  1498
    a * c = b ==> a = b / c"
avigad@16775
  1499
  by (subst eq_divide_eq, simp)
avigad@16775
  1500
avigad@16775
  1501
lemma frac_eq_eq: "(y::'a::field) ~= 0 ==> z ~= 0 ==>
avigad@16775
  1502
    (x / y = w / z) = (x * z = w * y)"
avigad@16775
  1503
  apply (subst nonzero_eq_divide_eq)
avigad@16775
  1504
  apply assumption
avigad@16775
  1505
  apply (subst times_divide_eq_left)
avigad@16775
  1506
  apply (erule nonzero_divide_eq_eq) 
avigad@16775
  1507
done
avigad@16775
  1508
avigad@16775
  1509
subsection{*Division and Signs*}
avigad@16775
  1510
avigad@16775
  1511
lemma zero_less_divide_iff:
avigad@16775
  1512
     "((0::'a::{ordered_field,division_by_zero}) < a/b) = (0 < a & 0 < b | a < 0 & b < 0)"
avigad@16775
  1513
by (simp add: divide_inverse zero_less_mult_iff)
avigad@16775
  1514
avigad@16775
  1515
lemma divide_less_0_iff:
avigad@16775
  1516
     "(a/b < (0::'a::{ordered_field,division_by_zero})) = 
avigad@16775
  1517
      (0 < a & b < 0 | a < 0 & 0 < b)"
avigad@16775
  1518
by (simp add: divide_inverse mult_less_0_iff)
avigad@16775
  1519
avigad@16775
  1520
lemma zero_le_divide_iff:
avigad@16775
  1521
     "((0::'a::{ordered_field,division_by_zero}) \<le> a/b) =
avigad@16775
  1522
      (0 \<le> a & 0 \<le> b | a \<le> 0 & b \<le> 0)"
avigad@16775
  1523
by (simp add: divide_inverse zero_le_mult_iff)
avigad@16775
  1524
avigad@16775
  1525
lemma divide_le_0_iff:
avigad@16775
  1526
     "(a/b \<le> (0::'a::{ordered_field,division_by_zero})) =
avigad@16775
  1527
      (0 \<le> a & b \<le> 0 | a \<le> 0 & 0 \<le> b)"
avigad@16775
  1528
by (simp add: divide_inverse mult_le_0_iff)
avigad@16775
  1529
avigad@16775
  1530
lemma divide_eq_0_iff [simp]:
avigad@16775
  1531
     "(a/b = 0) = (a=0 | b=(0::'a::{field,division_by_zero}))"
avigad@16775
  1532
by (simp add: divide_inverse field_mult_eq_0_iff)
avigad@16775
  1533
avigad@16775
  1534
lemma divide_pos_pos: "0 < (x::'a::ordered_field) ==> 
avigad@16775
  1535
    0 < y ==> 0 < x / y"
avigad@16775
  1536
  apply (subst pos_less_divide_eq)
avigad@16775
  1537
  apply assumption
avigad@16775
  1538
  apply simp
avigad@16775
  1539
done
avigad@16775
  1540
avigad@16775
  1541
lemma divide_nonneg_pos: "0 <= (x::'a::ordered_field) ==> 0 < y ==> 
avigad@16775
  1542
    0 <= x / y"
avigad@16775
  1543
  apply (subst pos_le_divide_eq)
avigad@16775
  1544
  apply assumption
avigad@16775
  1545
  apply simp
avigad@16775
  1546
done
avigad@16775
  1547
avigad@16775
  1548
lemma divide_neg_pos: "(x::'a::ordered_field) < 0 ==> 0 < y ==> x / y < 0"
avigad@16775
  1549
  apply (subst pos_divide_less_eq)
avigad@16775
  1550
  apply assumption
avigad@16775
  1551
  apply simp
avigad@16775
  1552
done
avigad@16775
  1553
avigad@16775
  1554
lemma divide_nonpos_pos: "(x::'a::ordered_field) <= 0 ==> 
avigad@16775
  1555
    0 < y ==> x / y <= 0"
avigad@16775
  1556
  apply (subst pos_divide_le_eq)
avigad@16775
  1557
  apply assumption
avigad@16775
  1558
  apply simp
avigad@16775
  1559
done
avigad@16775
  1560
avigad@16775
  1561
lemma divide_pos_neg: "0 < (x::'a::ordered_field) ==> y < 0 ==> x / y < 0"
avigad@16775
  1562
  apply (subst neg_divide_less_eq)
avigad@16775
  1563
  apply assumption
avigad@16775
  1564
  apply simp
avigad@16775
  1565
done
avigad@16775
  1566
avigad@16775
  1567
lemma divide_nonneg_neg: "0 <= (x::'a::ordered_field) ==> 
avigad@16775
  1568
    y < 0 ==> x / y <= 0"
avigad@16775
  1569
  apply (subst neg_divide_le_eq)
avigad@16775
  1570
  apply assumption
avigad@16775
  1571
  apply simp
avigad@16775
  1572
done
avigad@16775
  1573
avigad@16775
  1574
lemma divide_neg_neg: "(x::'a::ordered_field) < 0 ==> y < 0 ==> 0 < x / y"
avigad@16775
  1575
  apply (subst neg_less_divide_eq)
avigad@16775
  1576
  apply assumption
avigad@16775
  1577
  apply simp
avigad@16775
  1578
done
avigad@16775
  1579
avigad@16775
  1580
lemma divide_nonpos_neg: "(x::'a::ordered_field) <= 0 ==> y < 0 ==> 
avigad@16775
  1581
    0 <= x / y"
avigad@16775
  1582
  apply (subst neg_le_divide_eq)
avigad@16775
  1583
  apply assumption
avigad@16775
  1584
  apply simp
avigad@16775
  1585
done
paulson@15234
  1586
paulson@14288
  1587
subsection{*Cancellation Laws for Division*}
paulson@14288
  1588
paulson@14288
  1589
lemma divide_cancel_right [simp]:
paulson@14288
  1590
     "(a/c = b/c) = (c = 0 | a = (b::'a::{field,division_by_zero}))"
haftmann@21328
  1591
apply (cases "c=0", simp) 
paulson@14430
  1592
apply (simp add: divide_inverse field_mult_cancel_right) 
paulson@14288
  1593
done
paulson@14288
  1594
paulson@14288
  1595
lemma divide_cancel_left [simp]:
paulson@14288
  1596
     "(c/a = c/b) = (c = 0 | a = (b::'a::{field,division_by_zero}))" 
haftmann@21328
  1597
apply (cases "c=0", simp) 
paulson@14430
  1598
apply (simp add: divide_inverse field_mult_cancel_left) 
paulson@14288
  1599
done
paulson@14288
  1600
paulson@14353
  1601
subsection {* Division and the Number One *}
paulson@14353
  1602
paulson@14353
  1603
text{*Simplify expressions equated with 1*}
paulson@14353
  1604
lemma divide_eq_1_iff [simp]:
paulson@14353
  1605
     "(a/b = 1) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
haftmann@21328
  1606
apply (cases "b=0", simp) 
paulson@14353
  1607
apply (simp add: right_inverse_eq) 
paulson@14353
  1608
done
paulson@14353
  1609
paulson@14353
  1610
lemma one_eq_divide_iff [simp]:
paulson@14353
  1611
     "(1 = a/b) = (b \<noteq> 0 & a = (b::'a::{field,division_by_zero}))"
paulson@14353
  1612
by (simp add: eq_commute [of 1])  
paulson@14353
  1613
paulson@14353
  1614
lemma zero_eq_1_divide_iff [simp]:
paulson@14353
  1615
     "((0::'a::{ordered_field,division_by_zero}) = 1/a) = (a = 0)"
haftmann@21328
  1616
apply (cases "a=0", simp) 
paulson@14353
  1617
apply (auto simp add: nonzero_eq_divide_eq) 
paulson@14353
  1618
done
paulson@14353
  1619
paulson@14353
  1620
lemma one_divide_eq_0_iff [simp]:
paulson@14353
  1621
     "(1/a = (0::'a::{ordered_field,division_by_zero})) = (a = 0)"
haftmann@21328
  1622
apply (cases "a=0", simp) 
paulson@14353
  1623
apply (insert zero_neq_one [THEN not_sym]) 
paulson@14353
  1624
apply (auto simp add: nonzero_divide_eq_eq) 
paulson@14353
  1625
done
paulson@14353
  1626
paulson@14353
  1627
text{*Simplify expressions such as @{text "0 < 1/x"} to @{text "0 < x"}*}
paulson@18623
  1628
lemmas zero_less_divide_1_iff = zero_less_divide_iff [of 1, simplified]
paulson@18623
  1629
lemmas divide_less_0_1_iff = divide_less_0_iff [of 1, simplified]
paulson@18623
  1630
lemmas zero_le_divide_1_iff = zero_le_divide_iff [of 1, simplified]
paulson@18623
  1631
lemmas divide_le_0_1_iff = divide_le_0_iff [of 1, simplified]
paulson@17085
  1632
paulson@17085
  1633
declare zero_less_divide_1_iff [simp]
paulson@17085
  1634
declare divide_less_0_1_iff [simp]
paulson@17085
  1635
declare zero_le_divide_1_iff [simp]
paulson@17085
  1636
declare divide_le_0_1_iff [simp]
paulson@14353
  1637
paulson@14293
  1638
subsection {* Ordering Rules for Division *}
paulson@14293
  1639
paulson@14293
  1640
lemma divide_strict_right_mono:
paulson@14293
  1641
     "[|a < b; 0 < c|] ==> a / c < b / (c::'a::ordered_field)"
paulson@14293
  1642
by (simp add: order_less_imp_not_eq2 divide_inverse mult_strict_right_mono 
paulson@14293
  1643
              positive_imp_inverse_positive) 
paulson@14293
  1644
paulson@14293
  1645
lemma divide_right_mono:
paulson@14293
  1646
     "[|a \<le> b; 0 \<le> c|] ==> a/c \<le> b/(c::'a::{ordered_field,division_by_zero})"
paulson@14293
  1647
  by (force simp add: divide_strict_right_mono order_le_less) 
paulson@14293
  1648
avigad@16775
  1649
lemma divide_right_mono_neg: "(a::'a::{division_by_zero,ordered_field}) <= b 
avigad@16775
  1650
    ==> c <= 0 ==> b / c <= a / c"
avigad@16775
  1651
  apply (drule divide_right_mono [of _ _ "- c"])
avigad@16775
  1652
  apply auto
avigad@16775
  1653
done
avigad@16775
  1654
avigad@16775
  1655
lemma divide_strict_right_mono_neg:
avigad@16775
  1656
     "[|b < a; c < 0|] ==> a / c < b / (c::'a::ordered_field)"
avigad@16775
  1657
apply (drule divide_strict_right_mono [of _ _ "-c"], simp) 
avigad@16775
  1658
apply (simp add: order_less_imp_not_eq nonzero_minus_divide_right [symmetric]) 
avigad@16775
  1659
done
paulson@14293
  1660
paulson@14293
  1661
text{*The last premise ensures that @{term a} and @{term b} 
paulson@14293
  1662
      have the same sign*}
paulson@14293
  1663
lemma divide_strict_left_mono:
paulson@14293
  1664
       "[|b < a; 0 < c; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)"
paulson@14293
  1665
by (force simp add: zero_less_mult_iff divide_inverse mult_strict_left_mono 
paulson@14293
  1666
      order_less_imp_not_eq order_less_imp_not_eq2  
paulson@14293
  1667
      less_imp_inverse_less less_imp_inverse_less_neg) 
paulson@14293
  1668
paulson@14293
  1669
lemma divide_left_mono:
paulson@14293
  1670
     "[|b \<le> a; 0 \<le> c; 0 < a*b|] ==> c / a \<le> c / (b::'a::ordered_field)"
paulson@14293
  1671
  apply (subgoal_tac "a \<noteq> 0 & b \<noteq> 0") 
paulson@14293
  1672
   prefer 2 
paulson@14293
  1673
   apply (force simp add: zero_less_mult_iff order_less_imp_not_eq) 
haftmann@21328
  1674
  apply (cases "c=0", simp add: divide_inverse)
paulson@14293
  1675
  apply (force simp add: divide_strict_left_mono order_le_less) 
paulson@14293
  1676
  done
paulson@14293
  1677
avigad@16775
  1678
lemma divide_left_mono_neg: "(a::'a::{division_by_zero,ordered_field}) <= b 
avigad@16775
  1679
    ==> c <= 0 ==> 0 < a * b ==> c / a <= c / b"
avigad@16775
  1680
  apply (drule divide_left_mono [of _ _ "- c"])
avigad@16775
  1681
  apply (auto simp add: mult_commute)
avigad@16775
  1682
done
avigad@16775
  1683
paulson@14293
  1684
lemma divide_strict_left_mono_neg:
paulson@14293
  1685
     "[|a < b; c < 0; 0 < a*b|] ==> c / a < c / (b::'a::ordered_field)"
paulson@14293
  1686
  apply (subgoal_tac "a \<noteq> 0 & b \<noteq> 0") 
paulson@14293
  1687
   prefer 2 
paulson@14293
  1688
   apply (force simp add: zero_less_mult_iff order_less_imp_not_eq) 
paulson@14293
  1689
  apply (drule divide_strict_left_mono [of _ _ "-c"]) 
paulson@14293
  1690
   apply (simp_all add: mult_commute nonzero_minus_divide_left [symmetric]) 
paulson@14293
  1691
  done
paulson@14293
  1692
avigad@16775
  1693
text{*Simplify quotients that are compared with the value 1.*}
avigad@16775
  1694
avigad@16775
  1695
lemma le_divide_eq_1:
avigad@16775
  1696
  fixes a :: "'a :: {ordered_field,division_by_zero}"
avigad@16775
  1697
  shows "(1 \<le> b / a) = ((0 < a & a \<le> b) | (a < 0 & b \<le> a))"
avigad@16775
  1698
by (auto simp add: le_divide_eq)
avigad@16775
  1699
avigad@16775
  1700
lemma divide_le_eq_1:
avigad@16775
  1701
  fixes a :: "'a :: {ordered_field,division_by_zero}"
avigad@16775
  1702
  shows "(b / a \<le> 1) = ((0 < a & b \<le> a) | (a < 0 & a \<le> b) | a=0)"
avigad@16775
  1703
by (auto simp add: divide_le_eq)
avigad@16775
  1704
avigad@16775
  1705
lemma less_divide_eq_1:
avigad@16775
  1706
  fixes a :: "'a :: {ordered_field,division_by_zero}"
avigad@16775
  1707
  shows "(1 < b / a) = ((0 < a & a < b) | (a < 0 & b < a))"
avigad@16775
  1708
by (auto simp add: less_divide_eq)
avigad@16775
  1709
avigad@16775
  1710
lemma divide_less_eq_1:
avigad@16775
  1711
  fixes a :: "'a :: {ordered_field,division_by_zero}"
avigad@16775
  1712
  shows "(b / a < 1) = ((0 < a & b < a) | (a < 0 & a < b) | a=0)"
avigad@16775
  1713
by (auto simp add: divide_less_eq)
avigad@16775
  1714
avigad@16775
  1715
subsection{*Conditional Simplification Rules: No Case Splits*}
avigad@16775
  1716
avigad@16775
  1717
lemma le_divide_eq_1_pos [simp]:
avigad@16775
  1718
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1719
  shows "0 < a \<Longrightarrow> (1 \<le> b/a) = (a \<le> b)"
avigad@16775
  1720
by (auto simp add: le_divide_eq)
avigad@16775
  1721
avigad@16775
  1722
lemma le_divide_eq_1_neg [simp]:
avigad@16775
  1723
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1724
  shows "a < 0 \<Longrightarrow> (1 \<le> b/a) = (b \<le> a)"
avigad@16775
  1725
by (auto simp add: le_divide_eq)
avigad@16775
  1726
avigad@16775
  1727
lemma divide_le_eq_1_pos [simp]:
avigad@16775
  1728
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1729
  shows "0 < a \<Longrightarrow> (b/a \<le> 1) = (b \<le> a)"
avigad@16775
  1730
by (auto simp add: divide_le_eq)
avigad@16775
  1731
avigad@16775
  1732
lemma divide_le_eq_1_neg [simp]:
avigad@16775
  1733
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1734
  shows "a < 0 \<Longrightarrow> (b/a \<le> 1) = (a \<le> b)"
avigad@16775
  1735
by (auto simp add: divide_le_eq)
avigad@16775
  1736
avigad@16775
  1737
lemma less_divide_eq_1_pos [simp]:
avigad@16775
  1738
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1739
  shows "0 < a \<Longrightarrow> (1 < b/a) = (a < b)"
avigad@16775
  1740
by (auto simp add: less_divide_eq)
avigad@16775
  1741
avigad@16775
  1742
lemma less_divide_eq_1_neg [simp]:
avigad@16775
  1743
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1744
  shows "a < 0 \<Longrightarrow> (1 < b/a) = (b < a)"
avigad@16775
  1745
by (auto simp add: less_divide_eq)
avigad@16775
  1746
avigad@16775
  1747
lemma divide_less_eq_1_pos [simp]:
avigad@16775
  1748
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1749
  shows "0 < a \<Longrightarrow> (b/a < 1) = (b < a)"
paulson@18649
  1750
by (auto simp add: divide_less_eq)
paulson@18649
  1751
paulson@18649
  1752
lemma divide_less_eq_1_neg [simp]:
paulson@18649
  1753
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1754
  shows "a < 0 \<Longrightarrow> b/a < 1 <-> a < b"
avigad@16775
  1755
by (auto simp add: divide_less_eq)
avigad@16775
  1756
avigad@16775
  1757
lemma eq_divide_eq_1 [simp]:
avigad@16775
  1758
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1759
  shows "(1 = b/a) = ((a \<noteq> 0 & a = b))"
avigad@16775
  1760
by (auto simp add: eq_divide_eq)
avigad@16775
  1761
avigad@16775
  1762
lemma divide_eq_eq_1 [simp]:
avigad@16775
  1763
  fixes a :: "'a :: {ordered_field,division_by_zero}"
paulson@18649
  1764
  shows "(b/a = 1) = ((a \<noteq> 0 & a = b))"
avigad@16775
  1765
by (auto simp add: divide_eq_eq)
avigad@16775
  1766
avigad@16775
  1767
subsection {* Reasoning about inequalities with division *}
avigad@16775
  1768
avigad@16775
  1769
lemma mult_right_le_one_le: "0 <= (x::'a::ordered_idom) ==> 0 <= y ==> y <= 1
avigad@16775
  1770
    ==> x * y <= x"
avigad@16775
  1771
  by (auto simp add: mult_compare_simps);
avigad@16775
  1772
avigad@16775
  1773
lemma mult_left_le_one_le: "0 <= (x::'a::ordered_idom) ==> 0 <= y ==> y <= 1
avigad@16775
  1774
    ==> y * x <= x"
avigad@16775
  1775
  by (auto simp add: mult_compare_simps);
avigad@16775
  1776
avigad@16775
  1777
lemma mult_imp_div_pos_le: "0 < (y::'a::ordered_field) ==> x <= z * y ==>
avigad@16775
  1778
    x / y <= z";
avigad@16775
  1779
  by (subst pos_divide_le_eq, assumption+);
avigad@16775
  1780
avigad@16775
  1781
lemma mult_imp_le_div_pos: "0 < (y::'a::ordered_field) ==> z * y <= x ==>
avigad@16775
  1782
    z <= x / y";
avigad@16775
  1783
  by (subst pos_le_divide_eq, assumption+)
avigad@16775
  1784
avigad@16775
  1785
lemma mult_imp_div_pos_less: "0 < (y::'a::ordered_field) ==> x < z * y ==>
avigad@16775
  1786
    x / y < z"
avigad@16775
  1787
  by (subst pos_divide_less_eq, assumption+)
avigad@16775
  1788
avigad@16775
  1789
lemma mult_imp_less_div_pos: "0 < (y::'a::ordered_field) ==> z * y < x ==>
avigad@16775
  1790
    z < x / y"
avigad@16775
  1791
  by (subst pos_less_divide_eq, assumption+)
avigad@16775
  1792
avigad@16775
  1793
lemma frac_le: "(0::'a::ordered_field) <= x ==> 
avigad@16775
  1794
    x <= y ==> 0 < w ==> w <= z  ==> x / z <= y / w"
avigad@16775
  1795
  apply (rule mult_imp_div_pos_le)
avigad@16775
  1796
  apply simp;
avigad@16775
  1797
  apply (subst times_divide_eq_left);
avigad@16775
  1798
  apply (rule mult_imp_le_div_pos, assumption)
avigad@16775
  1799
  apply (rule mult_mono)
avigad@16775
  1800
  apply simp_all
paulson@14293
  1801
done
paulson@14293
  1802
avigad@16775
  1803
lemma frac_less: "(0::'a::ordered_field) <= x ==> 
avigad@16775
  1804
    x < y ==> 0 < w ==> w <= z  ==> x / z < y / w"
avigad@16775
  1805
  apply (rule mult_imp_div_pos_less)
avigad@16775
  1806
  apply simp;
avigad@16775
  1807
  apply (subst times_divide_eq_left);
avigad@16775
  1808
  apply (rule mult_imp_less_div_pos, assumption)
avigad@16775
  1809
  apply (erule mult_less_le_imp_less)
avigad@16775
  1810
  apply simp_all
avigad@16775
  1811
done
avigad@16775
  1812
avigad@16775
  1813
lemma frac_less2: "(0::'a::ordered_field) < x ==> 
avigad@16775
  1814
    x <= y ==> 0 < w ==> w < z  ==> x / z < y / w"
avigad@16775
  1815
  apply (rule mult_imp_div_pos_less)
avigad@16775
  1816
  apply simp_all
avigad@16775
  1817
  apply (subst times_divide_eq_left);
avigad@16775
  1818
  apply (rule mult_imp_less_div_pos, assumption)
avigad@16775
  1819
  apply (erule mult_le_less_imp_less)
avigad@16775
  1820
  apply simp_all
avigad@16775
  1821
done
avigad@16775
  1822
avigad@16775
  1823
lemmas times_divide_eq = times_divide_eq_right times_divide_eq_left
avigad@16775
  1824
avigad@16775
  1825
text{*It's not obvious whether these should be simprules or not. 
avigad@16775
  1826
  Their effect is to gather terms into one big fraction, like
avigad@16775
  1827
  a*b*c / x*y*z. The rationale for that is unclear, but many proofs 
avigad@16775
  1828
  seem to need them.*}
avigad@16775
  1829
avigad@16775
  1830
declare times_divide_eq [simp]
paulson@14293
  1831
paulson@14293
  1832
subsection {* Ordered Fields are Dense *}
paulson@14293
  1833
obua@14738
  1834
lemma less_add_one: "a < (a+1::'a::ordered_semidom)"
paulson@14293
  1835
proof -
obua@14738
  1836
  have "a+0 < (a+1::'a::ordered_semidom)"
paulson@14365
  1837
    by (blast intro: zero_less_one add_strict_left_mono) 
paulson@14293
  1838
  thus ?thesis by simp
paulson@14293
  1839
qed
paulson@14293
  1840
obua@14738
  1841
lemma zero_less_two: "0 < (1+1::'a::ordered_semidom)"
paulson@14365
  1842
  by (blast intro: order_less_trans zero_less_one less_add_one) 
paulson@14365
  1843
paulson@14293
  1844
lemma less_half_sum: "a < b ==> a < (a+b) / (1+1::'a::ordered_field)"
paulson@14293
  1845
by (simp add: zero_less_two pos_less_divide_eq right_distrib) 
paulson@14293
  1846
paulson@14293
  1847
lemma gt_half_sum: "a < b ==> (a+b)/(1+1::'a::ordered_field) < b"
paulson@14293
  1848
by (simp add: zero_less_two pos_divide_less_eq right_distrib) 
paulson@14293
  1849
paulson@14293
  1850
lemma dense: "a < b ==> \<exists>r::'a::ordered_field. a < r & r < b"
paulson@14293
  1851
by (blast intro!: less_half_sum gt_half_sum)
paulson@14293
  1852
paulson@15234
  1853
paulson@14293
  1854
subsection {* Absolute Value *}
paulson@14293
  1855
obua@14738
  1856
lemma abs_one [simp]: "abs 1 = (1::'a::ordered_idom)"
paulson@14294
  1857
  by (simp add: abs_if zero_less_one [THEN order_less_not_sym]) 
paulson@14294
  1858
obua@14738
  1859
lemma abs_le_mult: "abs (a * b) \<le> (abs a) * (abs (b::'a::lordered_ring))" 
obua@14738
  1860
proof -
obua@14738
  1861
  let ?x = "pprt a * pprt b - pprt a * nprt b - nprt a * pprt b + nprt a * nprt b"
obua@14738
  1862
  let ?y = "pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
obua@14738
  1863
  have a: "(abs a) * (abs b) = ?x"
obua@14738
  1864
    by (simp only: abs_prts[of a] abs_prts[of b] ring_eq_simps)
obua@14738
  1865
  {
obua@14738
  1866
    fix u v :: 'a
paulson@15481
  1867
    have bh: "\<lbrakk>u = a; v = b\<rbrakk> \<Longrightarrow> 
paulson@15481
  1868
              u * v = pprt a * pprt b + pprt a * nprt b + 
paulson@15481
  1869
                      nprt a * pprt b + nprt a * nprt b"
obua@14738
  1870
      apply (subst prts[of u], subst prts[of v])
obua@14738
  1871
      apply (simp add: left_distrib right_distrib add_ac) 
obua@14738
  1872
      done
obua@14738
  1873
  }
obua@14738
  1874
  note b = this[OF refl[of a] refl[of b]]
obua@14738
  1875
  note addm = add_mono[of "0::'a" _ "0::'a", simplified]
obua@14738
  1876
  note addm2 = add_mono[of _ "0::'a" _ "0::'a", simplified]
obua@14738
  1877
  have xy: "- ?x <= ?y"
obua@14754
  1878
    apply (simp)
obua@14754
  1879
    apply (rule_tac y="0::'a" in order_trans)
nipkow@16568
  1880
    apply (rule addm2)
avigad@16775
  1881
    apply (simp_all add: mult_nonneg_nonneg mult_nonpos_nonpos)
nipkow@16568
  1882
    apply (rule addm)
avigad@16775
  1883
    apply (simp_all add: mult_nonneg_nonneg mult_nonpos_nonpos)
obua@14754
  1884
    done
obua@14738
  1885
  have yx: "?y <= ?x"
nipkow@16568
  1886
    apply (simp add:diff_def)
obua@14754
  1887
    apply (rule_tac y=0 in order_trans)
avigad@16775
  1888
    apply (rule addm2, (simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)+)
avigad@16775
  1889
    apply (rule addm, (simp add: mult_nonneg_nonpos mult_nonneg_nonpos2)+)
obua@14738
  1890
    done
obua@14738
  1891
  have i1: "a*b <= abs a * abs b" by (simp only: a b yx)
obua@14738
  1892
  have i2: "- (abs a * abs b) <= a*b" by (simp only: a b xy)
obua@14738
  1893
  show ?thesis
obua@14738
  1894
    apply (rule abs_leI)
obua@14738
  1895
    apply (simp add: i1)
obua@14738
  1896
    apply (simp add: i2[simplified minus_le_iff])
obua@14738
  1897
    done
obua@14738
  1898
qed
paulson@14294
  1899
obua@14738
  1900
lemma abs_eq_mult: 
obua@14738
  1901
  assumes "(0 \<le> a \<or> a \<le> 0) \<and> (0 \<le> b \<or> b \<le> 0)"
obua@14738
  1902
  shows "abs (a*b) = abs a * abs (b::'a::lordered_ring)"
obua@14738
  1903
proof -
obua@14738
  1904
  have s: "(0 <= a*b) | (a*b <= 0)"
obua@14738
  1905
    apply (auto)    
obua@14738
  1906
    apply (rule_tac split_mult_pos_le)
obua@14738
  1907
    apply (rule_tac contrapos_np[of "a*b <= 0"])
obua@14738
  1908
    apply (simp)
obua@14738
  1909
    apply (rule_tac split_mult_neg_le)
obua@14738
  1910
    apply (insert prems)
obua@14738
  1911
    apply (blast)
obua@14738
  1912
    done
obua@14738
  1913
  have mulprts: "a * b = (pprt a + nprt a) * (pprt b + nprt b)"
obua@14738
  1914
    by (simp add: prts[symmetric])
obua@14738
  1915
  show ?thesis
obua@14738
  1916
  proof cases
obua@14738
  1917
    assume "0 <= a * b"
obua@14738
  1918
    then show ?thesis
obua@14738
  1919
      apply (simp_all add: mulprts abs_prts)
obua@14738
  1920
      apply (insert prems)
obua@14754
  1921
      apply (auto simp add: 
obua@14754
  1922
	ring_eq_simps 
obua@14754
  1923
	iff2imp[OF zero_le_iff_zero_nprt] iff2imp[OF le_zero_iff_zero_pprt]
nipkow@15197
  1924
	iff2imp[OF le_zero_iff_pprt_id] iff2imp[OF zero_le_iff_nprt_id])
avigad@16775
  1925
	apply(drule (1) mult_nonneg_nonpos[of a b], simp)
avigad@16775
  1926
	apply(drule (1) mult_nonneg_nonpos2[of b a], simp)
obua@14738
  1927
      done
obua@14738
  1928
  next
obua@14738
  1929
    assume "~(0 <= a*b)"
obua@14738
  1930
    with s have "a*b <= 0" by simp
obua@14738
  1931
    then show ?thesis
obua@14738
  1932
      apply (simp_all add: mulprts abs_prts)
obua@14738
  1933
      apply (insert prems)
obua@15580
  1934
      apply (auto simp add: ring_eq_simps)
avigad@16775
  1935
      apply(drule (1) mult_nonneg_nonneg[of a b],simp)
avigad@16775
  1936
      apply(drule (1) mult_nonpos_nonpos[of a b],simp)
obua@14738
  1937
      done
obua@14738
  1938
  qed
obua@14738
  1939
qed
paulson@14294
  1940
obua@14738
  1941
lemma abs_mult: "abs (a * b) = abs a * abs (b::'a::ordered_idom)" 
obua@14738
  1942
by (simp add: abs_eq_mult linorder_linear)
paulson@14293
  1943
obua@14738
  1944
lemma abs_mult_self: "abs a * abs a = a * (a::'a::ordered_idom)"
obua@14738
  1945
by (simp add: abs_if) 
paulson@14294
  1946
paulson@14294
  1947
lemma nonzero_abs_inverse:
paulson@14294
  1948
     "a \<noteq> 0 ==> abs (inverse (a::'a::ordered_field)) = inverse (abs a)"
paulson@14294
  1949
apply (auto simp add: linorder_neq_iff abs_if nonzero_inverse_minus_eq 
paulson@14294
  1950
                      negative_imp_inverse_negative)
paulson@14294
  1951
apply (blast intro: positive_imp_inverse_positive elim: order_less_asym) 
paulson@14294
  1952
done
paulson@14294
  1953
paulson@14294
  1954
lemma abs_inverse [simp]:
paulson@14294
  1955
     "abs (inverse (a::'a::{ordered_field,division_by_zero})) = 
paulson@14294
  1956
      inverse (abs a)"
haftmann@21328
  1957
apply (cases "a=0", simp) 
paulson@14294
  1958
apply (simp add: nonzero_abs_inverse) 
paulson@14294
  1959
done
paulson@14294
  1960
paulson@14294
  1961
lemma nonzero_abs_divide:
paulson@14294
  1962
     "b \<noteq> 0 ==> abs (a / (b::'a::ordered_field)) = abs a / abs b"
paulson@14294
  1963
by (simp add: divide_inverse abs_mult nonzero_abs_inverse) 
paulson@14294
  1964
paulson@15234
  1965
lemma abs_divide [simp]:
paulson@14294
  1966
     "abs (a / (b::'a::{ordered_field,division_by_zero})) = abs a / abs b"
haftmann@21328
  1967
apply (cases "b=0", simp) 
paulson@14294
  1968
apply (simp add: nonzero_abs_divide) 
paulson@14294
  1969
done
paulson@14294
  1970
paulson@14294
  1971
lemma abs_mult_less:
obua@14738
  1972
     "[| abs a < c; abs b < d |] ==> abs a * abs b < c*(d::'a::ordered_idom)"
paulson@14294
  1973
proof -
paulson@14294
  1974
  assume ac: "abs a < c"
paulson@14294
  1975
  hence cpos: "0<c" by (blast intro: order_le_less_trans abs_ge_zero)
paulson@14294
  1976
  assume "abs b < d"
paulson@14294
  1977
  thus ?thesis by (simp add: ac cpos mult_strict_mono) 
paulson@14294
  1978
qed
paulson@14293
  1979
obua@14738
  1980
lemma eq_minus_self_iff: "(a = -a) = (a = (0::'a::ordered_idom))"
obua@14738
  1981
by (force simp add: order_eq_iff le_minus_self_iff minus_le_self_iff)
obua@14738
  1982
obua@14738
  1983
lemma less_minus_self_iff: "(a < -a) = (a < (0::'a::ordered_idom))"
obua@14738
  1984
by (simp add: order_less_le le_minus_self_iff eq_minus_self_iff)
obua@14738
  1985
obua@14738
  1986
lemma abs_less_iff: "(abs a < b) = (a < b & -a < (b::'a::ordered_idom))" 
obua@14738
  1987
apply (simp add: order_less_le abs_le_iff)  
obua@14738
  1988
apply (auto simp add: abs_if minus_le_self_iff eq_minus_self_iff)
obua@14738
  1989
apply (simp add: le_minus_self_iff linorder_neq_iff) 
obua@14738
  1990
done
obua@14738
  1991
avigad@16775
  1992
lemma abs_mult_pos: "(0::'a::ordered_idom) <= x ==> 
avigad@16775
  1993
    (abs y) * x = abs (y * x)";
avigad@16775
  1994
  apply (subst abs_mult);
avigad@16775
  1995
  apply simp;
avigad@16775
  1996
done;
avigad@16775
  1997
avigad@16775
  1998
lemma abs_div_pos: "(0::'a::{division_by_zero,ordered_field}) < y ==> 
avigad@16775
  1999
    abs x / y = abs (x / y)";
avigad@16775
  2000
  apply (subst abs_divide);
avigad@16775
  2001
  apply (simp add: order_less_imp_le);
avigad@16775
  2002
done;
avigad@16775
  2003
obua@19404
  2004
subsection {* Bounds of products via negative and positive Part *}
obua@15178
  2005
obua@15580
  2006
lemma mult_le_prts:
obua@15580
  2007
  assumes
obua@15580
  2008
  "a1 <= (a::'a::lordered_ring)"
obua@15580
  2009
  "a <= a2"
obua@15580
  2010
  "b1 <= b"
obua@15580
  2011
  "b <= b2"
obua@15580
  2012
  shows
obua@15580
  2013
  "a * b <= pprt a2 * pprt b2 + pprt a1 * nprt b2 + nprt a2 * pprt b1 + nprt a1 * nprt b1"
obua@15580
  2014
proof - 
obua@15580
  2015
  have "a * b = (pprt a + nprt a) * (pprt b + nprt b)" 
obua@15580
  2016
    apply (subst prts[symmetric])+
obua@15580
  2017
    apply simp
obua@15580
  2018
    done
obua@15580
  2019
  then have "a * b = pprt a * pprt b + pprt a * nprt b + nprt a * pprt b + nprt a * nprt b"
obua@15580
  2020
    by (simp add: ring_eq_simps)
obua@15580
  2021
  moreover have "pprt a * pprt b <= pprt a2 * pprt b2"
obua@15580
  2022
    by (simp_all add: prems mult_mono)
obua@15580
  2023
  moreover have "pprt a * nprt b <= pprt a1 * nprt b2"
obua@15580
  2024
  proof -
obua@15580
  2025
    have "pprt a * nprt b <= pprt a * nprt b2"
obua@15580
  2026
      by (simp add: mult_left_mono prems)
obua@15580
  2027
    moreover have "pprt a * nprt b2 <= pprt a1 * nprt b2"
obua@15580
  2028
      by (simp add: mult_right_mono_neg prems)
obua@15580
  2029
    ultimately show ?thesis
obua@15580
  2030
      by simp
obua@15580
  2031
  qed
obua@15580
  2032
  moreover have "nprt a * pprt b <= nprt a2 * pprt b1"
obua@15580
  2033
  proof - 
obua@15580
  2034
    have "nprt a * pprt b <= nprt a2 * pprt b"
obua@15580
  2035
      by (simp add: mult_right_mono prems)
obua@15580
  2036
    moreover have "nprt a2 * pprt b <= nprt a2 * pprt b1"
obua@15580
  2037
      by (simp add: mult_left_mono_neg prems)
obua@15580
  2038
    ultimately show ?thesis
obua@15580
  2039
      by simp
obua@15580
  2040
  qed
obua@15580
  2041
  moreover have "nprt a * nprt b <= nprt a1 * nprt b1"
obua@15580
  2042
  proof -
obua@15580
  2043
    have "nprt a * nprt b <= nprt a * nprt b1"
obua@15580
  2044
      by (simp add: mult_left_mono_neg prems)
obua@15580
  2045
    moreover have "nprt a * nprt b1 <= nprt a1 * nprt b1"
obua@15580
  2046
      by (simp add: mult_right_mono_neg prems)
obua@15580
  2047
    ultimately show ?thesis
obua@15580
  2048
      by simp
obua@15580
  2049
  qed
obua@15580
  2050
  ultimately show ?thesis
obua@15580
  2051
    by - (rule add_mono | simp)+
obua@15580
  2052
qed
obua@19404
  2053
obua@19404
  2054
lemma mult_ge_prts:
obua@15178
  2055
  assumes
obua@19404
  2056
  "a1 <= (a::'a::lordered_ring)"
obua@19404
  2057
  "a <= a2"
obua@19404
  2058
  "b1 <= b"
obua@19404
  2059
  "b <= b2"
obua@15178
  2060
  shows
obua@19404
  2061
  "a * b >= nprt a1 * pprt b2 + nprt a2 * nprt b2 + pprt a1 * pprt b1 + pprt a2 * nprt b1"
obua@19404
  2062
proof - 
obua@19404
  2063
  from prems have a1:"- a2 <= -a" by auto
obua@19404
  2064
  from prems have a2: "-a <= -a1" by auto
obua@19404
  2065
  from mult_le_prts[of "-a2" "-a" "-a1" "b1" b "b2", OF a1 a2 prems(3) prems(4), simplified nprt_neg pprt_neg] 
obua@19404
  2066
  have le: "- (a * b) <= - nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1" by simp  
obua@19404
  2067
  then have "-(- nprt a1 * pprt b2 + - nprt a2 * nprt b2 + - pprt a1 * pprt b1 + - pprt a2 * nprt b1) <= a * b"
obua@19404
  2068
    by (simp only: minus_le_iff)
obua@19404
  2069
  then show ?thesis by simp
obua@15178
  2070
qed
obua@15178
  2071
obua@14738
  2072
ML {*
paulson@14334
  2073
val left_distrib = thm "left_distrib";
obua@14738
  2074
val right_distrib = thm "right_distrib";
obua@14738
  2075
val mult_commute = thm "mult_commute";
obua@14738
  2076
val distrib = thm "distrib";
obua@14738
  2077
val zero_neq_one = thm "zero_neq_one";
obua@14738
  2078
val no_zero_divisors = thm "no_zero_divisors";
paulson@14331
  2079
val left_inverse = thm "left_inverse";
obua@14738
  2080
val divide_inverse = thm "divide_inverse";
obua@14738
  2081
val mult_zero_left = thm "mult_zero_left";
obua@14738
  2082
val mult_zero_right = thm "mult_zero_right";
obua@14738
  2083
val field_mult_eq_0_iff = thm "field_mult_eq_0_iff";
obua@14738
  2084
val inverse_zero = thm "inverse_zero";
obua@14738
  2085
val ring_distrib = thms "ring_distrib";
obua@14738
  2086
val combine_common_factor = thm "combine_common_factor";
obua@14738
  2087
val minus_mult_left = thm "minus_mult_left";
obua@14738
  2088
val minus_mult_right = thm "minus_mult_right";
obua@14738
  2089
val minus_mult_minus = thm "minus_mult_minus";
obua@14738
  2090
val minus_mult_commute = thm "minus_mult_commute";
obua@14738
  2091
val right_diff_distrib = thm "right_diff_distrib";
obua@14738
  2092
val left_diff_distrib = thm "left_diff_distrib";
obua@14738
  2093
val mult_left_mono = thm "mult_left_mono";
obua@14738
  2094
val mult_right_mono = thm "mult_right_mono";
obua@14738
  2095
val mult_strict_left_mono = thm "mult_strict_left_mono";
obua@14738
  2096
val mult_strict_right_mono = thm "mult_strict_right_mono";
obua@14738
  2097
val mult_mono = thm "mult_mono";
obua@14738
  2098
val mult_strict_mono = thm "mult_strict_mono";
obua@14738
  2099
val abs_if = thm "abs_if";
obua@14738
  2100
val zero_less_one = thm "zero_less_one";
obua@14738
  2101
val eq_add_iff1 = thm "eq_add_iff1";
obua@14738
  2102
val eq_add_iff2 = thm "eq_add_iff2";
obua@14738
  2103
val less_add_iff1 = thm "less_add_iff1";
obua@14738
  2104
val less_add_iff2 = thm "less_add_iff2";
obua@14738
  2105
val le_add_iff1 = thm "le_add_iff1";
obua@14738
  2106
val le_add_iff2 = thm "le_add_iff2";
obua@14738
  2107
val mult_left_le_imp_le = thm "mult_left_le_imp_le";
obua@14738
  2108
val mult_right_le_imp_le = thm "mult_right_le_imp_le";
obua@14738
  2109
val mult_left_less_imp_less = thm "mult_left_less_imp_less";
obua@14738
  2110
val mult_right_less_imp_less = thm "mult_right_less_imp_less";
obua@14738
  2111
val mult_strict_left_mono_neg = thm "mult_strict_left_mono_neg";
obua@14738
  2112
val mult_left_mono_neg = thm "mult_left_mono_neg";
obua@14738
  2113
val mult_strict_right_mono_neg = thm "mult_strict_right_mono_neg";
obua@14738
  2114
val mult_right_mono_neg = thm "mult_right_mono_neg";
avigad@16775
  2115
(*
obua@14738
  2116
val mult_pos = thm "mult_pos";
obua@14738
  2117
val mult_pos_le = thm "mult_pos_le";
obua@14738
  2118
val mult_pos_neg = thm "mult_pos_neg";
obua@14738
  2119
val mult_pos_neg_le = thm "mult_pos_neg_le";
obua@14738
  2120
val mult_pos_neg2 = thm "mult_pos_neg2";
obua@14738
  2121
val mult_pos_neg2_le = thm "mult_pos_neg2_le";
obua@14738
  2122
val mult_neg = thm "mult_neg";
obua@14738
  2123
val mult_neg_le = thm "mult_neg_le";
avigad@16775
  2124
*)
obua@14738
  2125
val zero_less_mult_pos = thm "zero_less_mult_pos";
obua@14738
  2126
val zero_less_mult_pos2 = thm "zero_less_mult_pos2";
obua@14738
  2127
val zero_less_mult_iff = thm "zero_less_mult_iff";
obua@14738
  2128
val mult_eq_0_iff = thm "mult_eq_0_iff";
obua@14738
  2129
val zero_le_mult_iff = thm "zero_le_mult_iff";
obua@14738
  2130
val mult_less_0_iff = thm "mult_less_0_iff";
obua@14738
  2131
val mult_le_0_iff = thm "mult_le_0_iff";
obua@14738
  2132
val split_mult_pos_le = thm "split_mult_pos_le";
obua@14738
  2133
val split_mult_neg_le = thm "split_mult_neg_le";
obua@14738
  2134
val zero_le_square = thm "zero_le_square";
obua@14738
  2135
val zero_le_one = thm "zero_le_one";
obua@14738
  2136
val not_one_le_zero = thm "not_one_le_zero";
obua@14738
  2137
val not_one_less_zero = thm "not_one_less_zero";
obua@14738
  2138
val mult_left_mono_neg = thm "mult_left_mono_neg";
obua@14738
  2139
val mult_right_mono_neg = thm "mult_right_mono_neg";
obua@14738
  2140
val mult_strict_mono = thm "mult_strict_mono";
obua@14738
  2141
val mult_strict_mono' = thm "mult_strict_mono'";
obua@14738
  2142
val mult_mono = thm "mult_mono";
obua@14738
  2143
val less_1_mult = thm "less_1_mult";
paulson@15234
  2144
val mult_less_cancel_right_disj = thm "mult_less_cancel_right_disj";
paulson@15234
  2145
val mult_less_cancel_left_disj = thm "mult_less_cancel_left_disj";
obua@14738
  2146
val mult_less_cancel_right = thm "mult_less_cancel_right";
obua@