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