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