src/HOL/Arith_Tools.thy
author wenzelm
Mon Mar 16 18:24:30 2009 +0100 (2009-03-16)
changeset 30549 d2d7874648bd
parent 30079 293b896b9c25
permissions -rw-r--r--
simplified method setup;
wenzelm@23462
     1
(*  Title:      HOL/Arith_Tools.thy
wenzelm@23462
     2
    ID:         $Id$
wenzelm@23462
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
wenzelm@23462
     4
    Author:     Amine Chaieb, TU Muenchen
wenzelm@23462
     5
*)
wenzelm@23462
     6
wenzelm@23462
     7
header {* Setup of arithmetic tools *}
wenzelm@23462
     8
wenzelm@23462
     9
theory Arith_Tools
haftmann@28402
    10
imports NatBin
wenzelm@23462
    11
uses
wenzelm@23462
    12
  "~~/src/Provers/Arith/cancel_numeral_factor.ML"
wenzelm@23462
    13
  "~~/src/Provers/Arith/extract_common_term.ML"
haftmann@28952
    14
  "Tools/int_factor_simprocs.ML"
haftmann@28952
    15
  "Tools/nat_simprocs.ML"
haftmann@28402
    16
  "Tools/Qelim/qelim.ML"
wenzelm@23462
    17
begin
wenzelm@23462
    18
wenzelm@23462
    19
subsection {* Simprocs for the Naturals *}
wenzelm@23462
    20
wenzelm@24075
    21
declaration {* K nat_simprocs_setup *}
wenzelm@23462
    22
wenzelm@23462
    23
subsubsection{*For simplifying @{term "Suc m - K"} and  @{term "K - Suc m"}*}
wenzelm@23462
    24
wenzelm@23462
    25
text{*Where K above is a literal*}
wenzelm@23462
    26
wenzelm@23462
    27
lemma Suc_diff_eq_diff_pred: "Numeral0 < n ==> Suc m - n = m - (n - Numeral1)"
wenzelm@23462
    28
by (simp add: numeral_0_eq_0 numeral_1_eq_1 split add: nat_diff_split)
wenzelm@23462
    29
wenzelm@23462
    30
text {*Now just instantiating @{text n} to @{text "number_of v"} does
wenzelm@23462
    31
  the right simplification, but with some redundant inequality
wenzelm@23462
    32
  tests.*}
wenzelm@23462
    33
lemma neg_number_of_pred_iff_0:
haftmann@25919
    34
  "neg (number_of (Int.pred v)::int) = (number_of v = (0::nat))"
haftmann@25919
    35
apply (subgoal_tac "neg (number_of (Int.pred v)) = (number_of v < Suc 0) ")
wenzelm@23462
    36
apply (simp only: less_Suc_eq_le le_0_eq)
wenzelm@23462
    37
apply (subst less_number_of_Suc, simp)
wenzelm@23462
    38
done
wenzelm@23462
    39
wenzelm@23462
    40
text{*No longer required as a simprule because of the @{text inverse_fold}
wenzelm@23462
    41
   simproc*}
wenzelm@23462
    42
lemma Suc_diff_number_of:
huffman@29012
    43
     "Int.Pls < v ==>
haftmann@25919
    44
      Suc m - (number_of v) = m - (number_of (Int.pred v))"
wenzelm@23462
    45
apply (subst Suc_diff_eq_diff_pred)
wenzelm@23462
    46
apply simp
wenzelm@23462
    47
apply (simp del: nat_numeral_1_eq_1)
wenzelm@23462
    48
apply (auto simp only: diff_nat_number_of less_0_number_of [symmetric]
wenzelm@23462
    49
                        neg_number_of_pred_iff_0)
wenzelm@23462
    50
done
wenzelm@23462
    51
wenzelm@23462
    52
lemma diff_Suc_eq_diff_pred: "m - Suc n = (m - 1) - n"
wenzelm@23462
    53
by (simp add: numerals split add: nat_diff_split)
wenzelm@23462
    54
wenzelm@23462
    55
wenzelm@23462
    56
subsubsection{*For @{term nat_case} and @{term nat_rec}*}
wenzelm@23462
    57
wenzelm@23462
    58
lemma nat_case_number_of [simp]:
wenzelm@23462
    59
     "nat_case a f (number_of v) =
haftmann@25919
    60
        (let pv = number_of (Int.pred v) in
wenzelm@23462
    61
         if neg pv then a else f (nat pv))"
wenzelm@23462
    62
by (simp split add: nat.split add: Let_def neg_number_of_pred_iff_0)
wenzelm@23462
    63
wenzelm@23462
    64
lemma nat_case_add_eq_if [simp]:
wenzelm@23462
    65
     "nat_case a f ((number_of v) + n) =
haftmann@25919
    66
       (let pv = number_of (Int.pred v) in
wenzelm@23462
    67
         if neg pv then nat_case a f n else f (nat pv + n))"
wenzelm@23462
    68
apply (subst add_eq_if)
wenzelm@23462
    69
apply (simp split add: nat.split
wenzelm@23462
    70
            del: nat_numeral_1_eq_1
huffman@30079
    71
            add: nat_numeral_1_eq_1 [symmetric]
huffman@30079
    72
                 numeral_1_eq_Suc_0 [symmetric]
huffman@30079
    73
                 neg_number_of_pred_iff_0)
wenzelm@23462
    74
done
wenzelm@23462
    75
wenzelm@23462
    76
lemma nat_rec_number_of [simp]:
wenzelm@23462
    77
     "nat_rec a f (number_of v) =
haftmann@25919
    78
        (let pv = number_of (Int.pred v) in
wenzelm@23462
    79
         if neg pv then a else f (nat pv) (nat_rec a f (nat pv)))"
wenzelm@23462
    80
apply (case_tac " (number_of v) ::nat")
wenzelm@23462
    81
apply (simp_all (no_asm_simp) add: Let_def neg_number_of_pred_iff_0)
wenzelm@23462
    82
apply (simp split add: split_if_asm)
wenzelm@23462
    83
done
wenzelm@23462
    84
wenzelm@23462
    85
lemma nat_rec_add_eq_if [simp]:
wenzelm@23462
    86
     "nat_rec a f (number_of v + n) =
haftmann@25919
    87
        (let pv = number_of (Int.pred v) in
wenzelm@23462
    88
         if neg pv then nat_rec a f n
wenzelm@23462
    89
                   else f (nat pv + n) (nat_rec a f (nat pv + n)))"
wenzelm@23462
    90
apply (subst add_eq_if)
wenzelm@23462
    91
apply (simp split add: nat.split
wenzelm@23462
    92
            del: nat_numeral_1_eq_1
huffman@30079
    93
            add: nat_numeral_1_eq_1 [symmetric]
huffman@30079
    94
                 numeral_1_eq_Suc_0 [symmetric]
wenzelm@23462
    95
                 neg_number_of_pred_iff_0)
wenzelm@23462
    96
done
wenzelm@23462
    97
wenzelm@23462
    98
wenzelm@23462
    99
subsubsection{*Various Other Lemmas*}
wenzelm@23462
   100
wenzelm@23462
   101
text {*Evens and Odds, for Mutilated Chess Board*}
wenzelm@23462
   102
wenzelm@23462
   103
text{*Lemmas for specialist use, NOT as default simprules*}
wenzelm@23462
   104
lemma nat_mult_2: "2 * z = (z+z::nat)"
wenzelm@23462
   105
proof -
wenzelm@23462
   106
  have "2*z = (1 + 1)*z" by simp
wenzelm@23462
   107
  also have "... = z+z" by (simp add: left_distrib)
wenzelm@23462
   108
  finally show ?thesis .
wenzelm@23462
   109
qed
wenzelm@23462
   110
wenzelm@23462
   111
lemma nat_mult_2_right: "z * 2 = (z+z::nat)"
wenzelm@23462
   112
by (subst mult_commute, rule nat_mult_2)
wenzelm@23462
   113
wenzelm@23462
   114
text{*Case analysis on @{term "n<2"}*}
wenzelm@23462
   115
lemma less_2_cases: "(n::nat) < 2 ==> n = 0 | n = Suc 0"
wenzelm@23462
   116
by arith
wenzelm@23462
   117
wenzelm@23462
   118
lemma div2_Suc_Suc [simp]: "Suc(Suc m) div 2 = Suc (m div 2)"
wenzelm@23462
   119
by arith
wenzelm@23462
   120
wenzelm@23462
   121
lemma add_self_div_2 [simp]: "(m + m) div 2 = (m::nat)"
wenzelm@23462
   122
by (simp add: nat_mult_2 [symmetric])
wenzelm@23462
   123
wenzelm@23462
   124
lemma mod2_Suc_Suc [simp]: "Suc(Suc(m)) mod 2 = m mod 2"
wenzelm@23462
   125
apply (subgoal_tac "m mod 2 < 2")
wenzelm@23462
   126
apply (erule less_2_cases [THEN disjE])
wenzelm@23462
   127
apply (simp_all (no_asm_simp) add: Let_def mod_Suc nat_1)
wenzelm@23462
   128
done
wenzelm@23462
   129
wenzelm@23462
   130
lemma mod2_gr_0 [simp]: "!!m::nat. (0 < m mod 2) = (m mod 2 = 1)"
wenzelm@23462
   131
apply (subgoal_tac "m mod 2 < 2")
wenzelm@23462
   132
apply (force simp del: mod_less_divisor, simp)
wenzelm@23462
   133
done
wenzelm@23462
   134
wenzelm@23462
   135
text{*Removal of Small Numerals: 0, 1 and (in additive positions) 2*}
wenzelm@23462
   136
wenzelm@23462
   137
lemma add_2_eq_Suc [simp]: "2 + n = Suc (Suc n)"
wenzelm@23462
   138
by simp
wenzelm@23462
   139
wenzelm@23462
   140
lemma add_2_eq_Suc' [simp]: "n + 2 = Suc (Suc n)"
wenzelm@23462
   141
by simp
wenzelm@23462
   142
wenzelm@23462
   143
text{*Can be used to eliminate long strings of Sucs, but not by default*}
wenzelm@23462
   144
lemma Suc3_eq_add_3: "Suc (Suc (Suc n)) = 3 + n"
wenzelm@23462
   145
by simp
wenzelm@23462
   146
wenzelm@23462
   147
wenzelm@23462
   148
text{*These lemmas collapse some needless occurrences of Suc:
wenzelm@23462
   149
    at least three Sucs, since two and fewer are rewritten back to Suc again!
wenzelm@23462
   150
    We already have some rules to simplify operands smaller than 3.*}
wenzelm@23462
   151
wenzelm@23462
   152
lemma div_Suc_eq_div_add3 [simp]: "m div (Suc (Suc (Suc n))) = m div (3+n)"
wenzelm@23462
   153
by (simp add: Suc3_eq_add_3)
wenzelm@23462
   154
wenzelm@23462
   155
lemma mod_Suc_eq_mod_add3 [simp]: "m mod (Suc (Suc (Suc n))) = m mod (3+n)"
wenzelm@23462
   156
by (simp add: Suc3_eq_add_3)
wenzelm@23462
   157
wenzelm@23462
   158
lemma Suc_div_eq_add3_div: "(Suc (Suc (Suc m))) div n = (3+m) div n"
wenzelm@23462
   159
by (simp add: Suc3_eq_add_3)
wenzelm@23462
   160
wenzelm@23462
   161
lemma Suc_mod_eq_add3_mod: "(Suc (Suc (Suc m))) mod n = (3+m) mod n"
wenzelm@23462
   162
by (simp add: Suc3_eq_add_3)
wenzelm@23462
   163
wenzelm@23462
   164
lemmas Suc_div_eq_add3_div_number_of =
wenzelm@23462
   165
    Suc_div_eq_add3_div [of _ "number_of v", standard]
wenzelm@23462
   166
declare Suc_div_eq_add3_div_number_of [simp]
wenzelm@23462
   167
wenzelm@23462
   168
lemmas Suc_mod_eq_add3_mod_number_of =
wenzelm@23462
   169
    Suc_mod_eq_add3_mod [of _ "number_of v", standard]
wenzelm@23462
   170
declare Suc_mod_eq_add3_mod_number_of [simp]
wenzelm@23462
   171
wenzelm@23462
   172
wenzelm@23462
   173
subsubsection{*Special Simplification for Constants*}
wenzelm@23462
   174
wenzelm@23462
   175
text{*These belong here, late in the development of HOL, to prevent their
wenzelm@23462
   176
interfering with proofs of abstract properties of instances of the function
wenzelm@23462
   177
@{term number_of}*}
wenzelm@23462
   178
wenzelm@23462
   179
text{*These distributive laws move literals inside sums and differences.*}
wenzelm@23462
   180
lemmas left_distrib_number_of = left_distrib [of _ _ "number_of v", standard]
wenzelm@23462
   181
declare left_distrib_number_of [simp]
wenzelm@23462
   182
wenzelm@23462
   183
lemmas right_distrib_number_of = right_distrib [of "number_of v", standard]
wenzelm@23462
   184
declare right_distrib_number_of [simp]
wenzelm@23462
   185
wenzelm@23462
   186
wenzelm@23462
   187
lemmas left_diff_distrib_number_of =
wenzelm@23462
   188
    left_diff_distrib [of _ _ "number_of v", standard]
wenzelm@23462
   189
declare left_diff_distrib_number_of [simp]
wenzelm@23462
   190
wenzelm@23462
   191
lemmas right_diff_distrib_number_of =
wenzelm@23462
   192
    right_diff_distrib [of "number_of v", standard]
wenzelm@23462
   193
declare right_diff_distrib_number_of [simp]
wenzelm@23462
   194
wenzelm@23462
   195
wenzelm@23462
   196
text{*These are actually for fields, like real: but where else to put them?*}
wenzelm@23462
   197
lemmas zero_less_divide_iff_number_of =
wenzelm@23462
   198
    zero_less_divide_iff [of "number_of w", standard]
paulson@24286
   199
declare zero_less_divide_iff_number_of [simp,noatp]
wenzelm@23462
   200
wenzelm@23462
   201
lemmas divide_less_0_iff_number_of =
wenzelm@23462
   202
    divide_less_0_iff [of "number_of w", standard]
paulson@24286
   203
declare divide_less_0_iff_number_of [simp,noatp]
wenzelm@23462
   204
wenzelm@23462
   205
lemmas zero_le_divide_iff_number_of =
wenzelm@23462
   206
    zero_le_divide_iff [of "number_of w", standard]
paulson@24286
   207
declare zero_le_divide_iff_number_of [simp,noatp]
wenzelm@23462
   208
wenzelm@23462
   209
lemmas divide_le_0_iff_number_of =
wenzelm@23462
   210
    divide_le_0_iff [of "number_of w", standard]
paulson@24286
   211
declare divide_le_0_iff_number_of [simp,noatp]
wenzelm@23462
   212
wenzelm@23462
   213
wenzelm@23462
   214
(****
wenzelm@23462
   215
IF times_divide_eq_right and times_divide_eq_left are removed as simprules,
wenzelm@23462
   216
then these special-case declarations may be useful.
wenzelm@23462
   217
wenzelm@23462
   218
text{*These simprules move numerals into numerators and denominators.*}
wenzelm@23462
   219
lemma times_recip_eq_right [simp]: "a * (1/c) = a / (c::'a::field)"
wenzelm@23462
   220
by (simp add: times_divide_eq)
wenzelm@23462
   221
wenzelm@23462
   222
lemma times_recip_eq_left [simp]: "(1/c) * a = a / (c::'a::field)"
wenzelm@23462
   223
by (simp add: times_divide_eq)
wenzelm@23462
   224
wenzelm@23462
   225
lemmas times_divide_eq_right_number_of =
wenzelm@23462
   226
    times_divide_eq_right [of "number_of w", standard]
wenzelm@23462
   227
declare times_divide_eq_right_number_of [simp]
wenzelm@23462
   228
wenzelm@23462
   229
lemmas times_divide_eq_right_number_of =
wenzelm@23462
   230
    times_divide_eq_right [of _ _ "number_of w", standard]
wenzelm@23462
   231
declare times_divide_eq_right_number_of [simp]
wenzelm@23462
   232
wenzelm@23462
   233
lemmas times_divide_eq_left_number_of =
wenzelm@23462
   234
    times_divide_eq_left [of _ "number_of w", standard]
wenzelm@23462
   235
declare times_divide_eq_left_number_of [simp]
wenzelm@23462
   236
wenzelm@23462
   237
lemmas times_divide_eq_left_number_of =
wenzelm@23462
   238
    times_divide_eq_left [of _ _ "number_of w", standard]
wenzelm@23462
   239
declare times_divide_eq_left_number_of [simp]
wenzelm@23462
   240
wenzelm@23462
   241
****)
wenzelm@23462
   242
wenzelm@23462
   243
text {*Replaces @{text "inverse #nn"} by @{text "1/#nn"}.  It looks
wenzelm@23462
   244
  strange, but then other simprocs simplify the quotient.*}
wenzelm@23462
   245
wenzelm@23462
   246
lemmas inverse_eq_divide_number_of =
wenzelm@23462
   247
    inverse_eq_divide [of "number_of w", standard]
wenzelm@23462
   248
declare inverse_eq_divide_number_of [simp]
wenzelm@23462
   249
wenzelm@23462
   250
wenzelm@23462
   251
text {*These laws simplify inequalities, moving unary minus from a term
wenzelm@23462
   252
into the literal.*}
wenzelm@23462
   253
lemmas less_minus_iff_number_of =
wenzelm@23462
   254
    less_minus_iff [of "number_of v", standard]
paulson@24286
   255
declare less_minus_iff_number_of [simp,noatp]
wenzelm@23462
   256
wenzelm@23462
   257
lemmas le_minus_iff_number_of =
wenzelm@23462
   258
    le_minus_iff [of "number_of v", standard]
paulson@24286
   259
declare le_minus_iff_number_of [simp,noatp]
wenzelm@23462
   260
wenzelm@23462
   261
lemmas equation_minus_iff_number_of =
wenzelm@23462
   262
    equation_minus_iff [of "number_of v", standard]
paulson@24286
   263
declare equation_minus_iff_number_of [simp,noatp]
wenzelm@23462
   264
wenzelm@23462
   265
wenzelm@23462
   266
lemmas minus_less_iff_number_of =
wenzelm@23462
   267
    minus_less_iff [of _ "number_of v", standard]
paulson@24286
   268
declare minus_less_iff_number_of [simp,noatp]
wenzelm@23462
   269
wenzelm@23462
   270
lemmas minus_le_iff_number_of =
wenzelm@23462
   271
    minus_le_iff [of _ "number_of v", standard]
paulson@24286
   272
declare minus_le_iff_number_of [simp,noatp]
wenzelm@23462
   273
wenzelm@23462
   274
lemmas minus_equation_iff_number_of =
wenzelm@23462
   275
    minus_equation_iff [of _ "number_of v", standard]
paulson@24286
   276
declare minus_equation_iff_number_of [simp,noatp]
wenzelm@23462
   277
wenzelm@23462
   278
wenzelm@23462
   279
text{*To Simplify Inequalities Where One Side is the Constant 1*}
wenzelm@23462
   280
paulson@24286
   281
lemma less_minus_iff_1 [simp,noatp]:
wenzelm@23462
   282
  fixes b::"'b::{ordered_idom,number_ring}"
wenzelm@23462
   283
  shows "(1 < - b) = (b < -1)"
wenzelm@23462
   284
by auto
wenzelm@23462
   285
paulson@24286
   286
lemma le_minus_iff_1 [simp,noatp]:
wenzelm@23462
   287
  fixes b::"'b::{ordered_idom,number_ring}"
wenzelm@23462
   288
  shows "(1 \<le> - b) = (b \<le> -1)"
wenzelm@23462
   289
by auto
wenzelm@23462
   290
paulson@24286
   291
lemma equation_minus_iff_1 [simp,noatp]:
wenzelm@23462
   292
  fixes b::"'b::number_ring"
wenzelm@23462
   293
  shows "(1 = - b) = (b = -1)"
wenzelm@23462
   294
by (subst equation_minus_iff, auto)
wenzelm@23462
   295
paulson@24286
   296
lemma minus_less_iff_1 [simp,noatp]:
wenzelm@23462
   297
  fixes a::"'b::{ordered_idom,number_ring}"
wenzelm@23462
   298
  shows "(- a < 1) = (-1 < a)"
wenzelm@23462
   299
by auto
wenzelm@23462
   300
paulson@24286
   301
lemma minus_le_iff_1 [simp,noatp]:
wenzelm@23462
   302
  fixes a::"'b::{ordered_idom,number_ring}"
wenzelm@23462
   303
  shows "(- a \<le> 1) = (-1 \<le> a)"
wenzelm@23462
   304
by auto
wenzelm@23462
   305
paulson@24286
   306
lemma minus_equation_iff_1 [simp,noatp]:
wenzelm@23462
   307
  fixes a::"'b::number_ring"
wenzelm@23462
   308
  shows "(- a = 1) = (a = -1)"
wenzelm@23462
   309
by (subst minus_equation_iff, auto)
wenzelm@23462
   310
wenzelm@23462
   311
wenzelm@23462
   312
text {*Cancellation of constant factors in comparisons (@{text "<"} and @{text "\<le>"}) *}
wenzelm@23462
   313
wenzelm@23462
   314
lemmas mult_less_cancel_left_number_of =
wenzelm@23462
   315
    mult_less_cancel_left [of "number_of v", standard]
paulson@24286
   316
declare mult_less_cancel_left_number_of [simp,noatp]
wenzelm@23462
   317
wenzelm@23462
   318
lemmas mult_less_cancel_right_number_of =
wenzelm@23462
   319
    mult_less_cancel_right [of _ "number_of v", standard]
paulson@24286
   320
declare mult_less_cancel_right_number_of [simp,noatp]
wenzelm@23462
   321
wenzelm@23462
   322
lemmas mult_le_cancel_left_number_of =
wenzelm@23462
   323
    mult_le_cancel_left [of "number_of v", standard]
paulson@24286
   324
declare mult_le_cancel_left_number_of [simp,noatp]
wenzelm@23462
   325
wenzelm@23462
   326
lemmas mult_le_cancel_right_number_of =
wenzelm@23462
   327
    mult_le_cancel_right [of _ "number_of v", standard]
paulson@24286
   328
declare mult_le_cancel_right_number_of [simp,noatp]
wenzelm@23462
   329
wenzelm@23462
   330
wenzelm@23462
   331
text {*Multiplying out constant divisors in comparisons (@{text "<"}, @{text "\<le>"} and @{text "="}) *}
wenzelm@23462
   332
wenzelm@26314
   333
lemmas le_divide_eq_number_of1 [simp] = le_divide_eq [of _ _ "number_of w", standard]
wenzelm@26314
   334
lemmas divide_le_eq_number_of1 [simp] = divide_le_eq [of _ "number_of w", standard]
wenzelm@26314
   335
lemmas less_divide_eq_number_of1 [simp] = less_divide_eq [of _ _ "number_of w", standard]
wenzelm@26314
   336
lemmas divide_less_eq_number_of1 [simp] = divide_less_eq [of _ "number_of w", standard]
wenzelm@26314
   337
lemmas eq_divide_eq_number_of1 [simp] = eq_divide_eq [of _ _ "number_of w", standard]
wenzelm@26314
   338
lemmas divide_eq_eq_number_of1 [simp] = divide_eq_eq [of _ "number_of w", standard]
wenzelm@23462
   339
wenzelm@23462
   340
wenzelm@23462
   341
subsubsection{*Optional Simplification Rules Involving Constants*}
wenzelm@23462
   342
wenzelm@23462
   343
text{*Simplify quotients that are compared with a literal constant.*}
wenzelm@23462
   344
wenzelm@23462
   345
lemmas le_divide_eq_number_of = le_divide_eq [of "number_of w", standard]
wenzelm@23462
   346
lemmas divide_le_eq_number_of = divide_le_eq [of _ _ "number_of w", standard]
wenzelm@23462
   347
lemmas less_divide_eq_number_of = less_divide_eq [of "number_of w", standard]
wenzelm@23462
   348
lemmas divide_less_eq_number_of = divide_less_eq [of _ _ "number_of w", standard]
wenzelm@23462
   349
lemmas eq_divide_eq_number_of = eq_divide_eq [of "number_of w", standard]
wenzelm@23462
   350
lemmas divide_eq_eq_number_of = divide_eq_eq [of _ _ "number_of w", standard]
wenzelm@23462
   351
wenzelm@23462
   352
wenzelm@23462
   353
text{*Not good as automatic simprules because they cause case splits.*}
wenzelm@23462
   354
lemmas divide_const_simps =
wenzelm@23462
   355
  le_divide_eq_number_of divide_le_eq_number_of less_divide_eq_number_of
wenzelm@23462
   356
  divide_less_eq_number_of eq_divide_eq_number_of divide_eq_eq_number_of
wenzelm@23462
   357
  le_divide_eq_1 divide_le_eq_1 less_divide_eq_1 divide_less_eq_1
wenzelm@23462
   358
wenzelm@23462
   359
text{*Division By @{text "-1"}*}
wenzelm@23462
   360
wenzelm@23462
   361
lemma divide_minus1 [simp]:
wenzelm@23462
   362
     "x/-1 = -(x::'a::{field,division_by_zero,number_ring})"
wenzelm@23462
   363
by simp
wenzelm@23462
   364
wenzelm@23462
   365
lemma minus1_divide [simp]:
wenzelm@23462
   366
     "-1 / (x::'a::{field,division_by_zero,number_ring}) = - (1/x)"
wenzelm@23462
   367
by (simp add: divide_inverse inverse_minus_eq)
wenzelm@23462
   368
wenzelm@23462
   369
lemma half_gt_zero_iff:
wenzelm@23462
   370
     "(0 < r/2) = (0 < (r::'a::{ordered_field,division_by_zero,number_ring}))"
wenzelm@23462
   371
by auto
wenzelm@23462
   372
wenzelm@23462
   373
lemmas half_gt_zero = half_gt_zero_iff [THEN iffD2, standard]
wenzelm@23462
   374
declare half_gt_zero [simp]
wenzelm@23462
   375
wenzelm@23462
   376
(* The following lemma should appear in Divides.thy, but there the proof
wenzelm@23462
   377
   doesn't work. *)
wenzelm@23462
   378
wenzelm@23462
   379
lemma nat_dvd_not_less:
wenzelm@23462
   380
  "[| 0 < m; m < n |] ==> \<not> n dvd (m::nat)"
wenzelm@23462
   381
  by (unfold dvd_def) auto
wenzelm@23462
   382
wenzelm@23462
   383
ML {*
wenzelm@23462
   384
val divide_minus1 = @{thm divide_minus1};
wenzelm@23462
   385
val minus1_divide = @{thm minus1_divide};
wenzelm@23462
   386
*}
wenzelm@23462
   387
wenzelm@23462
   388
end