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