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