src/HOL/Word/Word_Miscellaneous.thy
author haftmann
Tue Oct 14 08:23:23 2014 +0200 (2014-10-14)
changeset 58681 a478a0742a8e
parent 57514 bdc2c6b40bf2
child 58770 ae5e9b4f8daf
permissions -rw-r--r--
legacy cleanup
haftmann@53062
     1
(*  Title:      HOL/Word/Word_Miscellaneous.thy
haftmann@53062
     2
    Author:     Miscellaneous
haftmann@53062
     3
*)
haftmann@53062
     4
haftmann@53062
     5
header {* Miscellaneous lemmas, of at least doubtful value *}
haftmann@53062
     6
haftmann@53062
     7
theory Word_Miscellaneous
haftmann@53062
     8
imports Main Parity "~~/src/HOL/Library/Bit" Misc_Numeric
haftmann@53062
     9
begin
haftmann@53062
    10
haftmann@53062
    11
lemma power_minus_simp:
haftmann@53062
    12
  "0 < n \<Longrightarrow> a ^ n = a * a ^ (n - 1)"
haftmann@53062
    13
  by (auto dest: gr0_implies_Suc)
haftmann@53062
    14
haftmann@53062
    15
lemma funpow_minus_simp:
haftmann@53062
    16
  "0 < n \<Longrightarrow> f ^^ n = f \<circ> f ^^ (n - 1)"
haftmann@53062
    17
  by (auto dest: gr0_implies_Suc)
haftmann@53062
    18
haftmann@53062
    19
lemma power_numeral:
haftmann@53062
    20
  "a ^ numeral k = a * a ^ (pred_numeral k)"
haftmann@53062
    21
  by (simp add: numeral_eq_Suc)
haftmann@53062
    22
haftmann@53062
    23
lemma funpow_numeral [simp]:
haftmann@53062
    24
  "f ^^ numeral k = f \<circ> f ^^ (pred_numeral k)"
haftmann@53062
    25
  by (simp add: numeral_eq_Suc)
haftmann@53062
    26
haftmann@53062
    27
lemma replicate_numeral [simp]:
haftmann@53062
    28
  "replicate (numeral k) x = x # replicate (pred_numeral k) x"
haftmann@53062
    29
  by (simp add: numeral_eq_Suc)
haftmann@53062
    30
haftmann@53062
    31
lemma rco_alt: "(f o g) ^^ n o f = f o (g o f) ^^ n"
haftmann@53062
    32
  apply (rule ext)
haftmann@53062
    33
  apply (induct n)
haftmann@53062
    34
   apply (simp_all add: o_def)
haftmann@53062
    35
  done
haftmann@53062
    36
haftmann@53062
    37
lemma list_exhaust_size_gt0:
haftmann@53062
    38
  assumes y: "\<And>a list. y = a # list \<Longrightarrow> P"
haftmann@53062
    39
  shows "0 < length y \<Longrightarrow> P"
haftmann@53062
    40
  apply (cases y, simp)
haftmann@53062
    41
  apply (rule y)
haftmann@53062
    42
  apply fastforce
haftmann@53062
    43
  done
haftmann@53062
    44
haftmann@53062
    45
lemma list_exhaust_size_eq0:
haftmann@53062
    46
  assumes y: "y = [] \<Longrightarrow> P"
haftmann@53062
    47
  shows "length y = 0 \<Longrightarrow> P"
haftmann@53062
    48
  apply (cases y)
haftmann@53062
    49
   apply (rule y, simp)
haftmann@53062
    50
  apply simp
haftmann@53062
    51
  done
haftmann@53062
    52
haftmann@53062
    53
lemma size_Cons_lem_eq:
haftmann@53062
    54
  "y = xa # list ==> size y = Suc k ==> size list = k"
haftmann@53062
    55
  by auto
haftmann@53062
    56
haftmann@53062
    57
lemmas ls_splits = prod.split prod.split_asm split_if_asm
haftmann@53062
    58
haftmann@53062
    59
lemma not_B1_is_B0: "y \<noteq> (1::bit) \<Longrightarrow> y = (0::bit)"
haftmann@53062
    60
  by (cases y) auto
haftmann@53062
    61
haftmann@53062
    62
lemma B1_ass_B0: 
haftmann@53062
    63
  assumes y: "y = (0::bit) \<Longrightarrow> y = (1::bit)"
haftmann@53062
    64
  shows "y = (1::bit)"
haftmann@53062
    65
  apply (rule classical)
haftmann@53062
    66
  apply (drule not_B1_is_B0)
haftmann@53062
    67
  apply (erule y)
haftmann@53062
    68
  done
haftmann@53062
    69
haftmann@53062
    70
-- "simplifications for specific word lengths"
haftmann@53062
    71
lemmas n2s_ths [THEN eq_reflection] = add_2_eq_Suc add_2_eq_Suc'
haftmann@53062
    72
haftmann@53062
    73
lemmas s2n_ths = n2s_ths [symmetric]
haftmann@53062
    74
haftmann@53062
    75
lemma and_len: "xs = ys ==> xs = ys & length xs = length ys"
haftmann@53062
    76
  by auto
haftmann@53062
    77
haftmann@53062
    78
lemma size_if: "size (if p then xs else ys) = (if p then size xs else size ys)"
haftmann@53062
    79
  by auto
haftmann@53062
    80
haftmann@53062
    81
lemma tl_if: "tl (if p then xs else ys) = (if p then tl xs else tl ys)"
haftmann@53062
    82
  by auto
haftmann@53062
    83
haftmann@53062
    84
lemma hd_if: "hd (if p then xs else ys) = (if p then hd xs else hd ys)"
haftmann@53062
    85
  by auto
haftmann@53062
    86
haftmann@53062
    87
lemma if_Not_x: "(if p then ~ x else x) = (p = (~ x))"
haftmann@53062
    88
  by auto
haftmann@53062
    89
haftmann@53062
    90
lemma if_x_Not: "(if p then x else ~ x) = (p = x)"
haftmann@53062
    91
  by auto
haftmann@53062
    92
haftmann@53062
    93
lemma if_same_and: "(If p x y & If p u v) = (if p then x & u else y & v)"
haftmann@53062
    94
  by auto
haftmann@53062
    95
haftmann@53062
    96
lemma if_same_eq: "(If p x y  = (If p u v)) = (if p then x = (u) else y = (v))"
haftmann@53062
    97
  by auto
haftmann@53062
    98
haftmann@53062
    99
lemma if_same_eq_not:
haftmann@53062
   100
  "(If p x y  = (~ If p u v)) = (if p then x = (~u) else y = (~v))"
haftmann@53062
   101
  by auto
haftmann@53062
   102
haftmann@53062
   103
(* note - if_Cons can cause blowup in the size, if p is complex,
haftmann@53062
   104
  so make a simproc *)
haftmann@53062
   105
lemma if_Cons: "(if p then x # xs else y # ys) = If p x y # If p xs ys"
haftmann@53062
   106
  by auto
haftmann@53062
   107
haftmann@53062
   108
lemma if_single:
haftmann@53062
   109
  "(if xc then [xab] else [an]) = [if xc then xab else an]"
haftmann@53062
   110
  by auto
haftmann@53062
   111
haftmann@53062
   112
lemma if_bool_simps:
haftmann@53062
   113
  "If p True y = (p | y) & If p False y = (~p & y) & 
haftmann@53062
   114
    If p y True = (p --> y) & If p y False = (p & y)"
haftmann@53062
   115
  by auto
haftmann@53062
   116
haftmann@53062
   117
lemmas if_simps = if_x_Not if_Not_x if_cancel if_True if_False if_bool_simps
haftmann@53062
   118
haftmann@53062
   119
lemmas seqr = eq_reflection [where x = "size w"] for w (* FIXME: delete *)
haftmann@53062
   120
haftmann@53062
   121
lemma the_elemI: "y = {x} ==> the_elem y = x" 
haftmann@53062
   122
  by simp
haftmann@53062
   123
haftmann@53062
   124
lemma nonemptyE: "S ~= {} ==> (!!x. x : S ==> R) ==> R" by auto
haftmann@53062
   125
haftmann@53062
   126
lemma gt_or_eq_0: "0 < y \<or> 0 = (y::nat)" by arith 
haftmann@53062
   127
haftmann@53062
   128
lemmas xtr1 = xtrans(1)
haftmann@53062
   129
lemmas xtr2 = xtrans(2)
haftmann@53062
   130
lemmas xtr3 = xtrans(3)
haftmann@53062
   131
lemmas xtr4 = xtrans(4)
haftmann@53062
   132
lemmas xtr5 = xtrans(5)
haftmann@53062
   133
lemmas xtr6 = xtrans(6)
haftmann@53062
   134
lemmas xtr7 = xtrans(7)
haftmann@53062
   135
lemmas xtr8 = xtrans(8)
haftmann@53062
   136
haftmann@53062
   137
lemmas nat_simps = diff_add_inverse2 diff_add_inverse
haftmann@53062
   138
lemmas nat_iffs = le_add1 le_add2
haftmann@53062
   139
haftmann@53062
   140
lemma sum_imp_diff: "j = k + i ==> j - i = (k :: nat)" by arith
haftmann@53062
   141
haftmann@53062
   142
lemmas pos_mod_sign2 = zless2 [THEN pos_mod_sign [where b = "2::int"]]
haftmann@53062
   143
lemmas pos_mod_bound2 = zless2 [THEN pos_mod_bound [where b = "2::int"]]
haftmann@53062
   144
haftmann@58681
   145
lemma nmod2: "n mod (2::int) = 0 | n mod 2 = 1"
haftmann@58681
   146
  by arith
haftmann@53062
   147
haftmann@57512
   148
lemmas eme1p = emep1 [simplified add.commute]
haftmann@53062
   149
haftmann@53062
   150
lemma le_diff_eq': "(a \<le> c - b) = (b + a \<le> (c::int))" by arith
haftmann@53062
   151
haftmann@53062
   152
lemma less_diff_eq': "(a < c - b) = (b + a < (c::int))" by arith
haftmann@53062
   153
haftmann@53062
   154
lemma diff_less_eq': "(a - b < c) = (a < b + (c::int))" by arith
haftmann@53062
   155
haftmann@53062
   156
lemmas m1mod22k = mult_pos_pos [OF zless2 zless2p, THEN zmod_minus1]
haftmann@53062
   157
lemmas z1pmod2' = zero_le_one [THEN pos_zmod_mult_2, simplified]
haftmann@53062
   158
lemmas z1pdiv2' = zero_le_one [THEN pos_zdiv_mult_2, simplified]
haftmann@53062
   159
haftmann@53062
   160
lemma z1pdiv2:
haftmann@53062
   161
  "(2 * b + 1) div 2 = (b::int)" by arith
haftmann@53062
   162
haftmann@53062
   163
lemmas zdiv_le_dividend = xtr3 [OF div_by_1 [symmetric] zdiv_mono2,
haftmann@53062
   164
  simplified int_one_le_iff_zero_less, simplified]
haftmann@53062
   165
  
haftmann@53062
   166
lemma axxbyy:
haftmann@53062
   167
  "a + m + m = b + n + n ==> (a = 0 | a = 1) ==> (b = 0 | b = 1) ==>  
haftmann@53062
   168
   a = b & m = (n :: int)" by arith
haftmann@53062
   169
haftmann@53062
   170
lemma axxmod2:
haftmann@53062
   171
  "(1 + x + x) mod 2 = (1 :: int) & (0 + x + x) mod 2 = (0 :: int)" by arith
haftmann@53062
   172
haftmann@53062
   173
lemma axxdiv2:
haftmann@53062
   174
  "(1 + x + x) div 2 = (x :: int) & (0 + x + x) div 2 = (x :: int)"  by arith
haftmann@53062
   175
haftmann@53062
   176
lemmas iszero_minus = trans [THEN trans,
haftmann@53062
   177
  OF iszero_def neg_equal_0_iff_equal iszero_def [symmetric]]
haftmann@53062
   178
haftmann@57512
   179
lemmas zadd_diff_inverse = trans [OF diff_add_cancel [symmetric] add.commute]
haftmann@53062
   180
haftmann@57512
   181
lemmas add_diff_cancel2 = add.commute [THEN diff_eq_eq [THEN iffD2]]
haftmann@53062
   182
haftmann@53062
   183
lemmas rdmods [symmetric] = mod_minus_eq
haftmann@53062
   184
  mod_diff_left_eq mod_diff_right_eq mod_add_left_eq
haftmann@53062
   185
  mod_add_right_eq mod_mult_right_eq mod_mult_left_eq
haftmann@53062
   186
haftmann@53062
   187
lemma mod_plus_right:
haftmann@53062
   188
  "((a + x) mod m = (b + x) mod m) = (a mod m = b mod (m :: nat))"
haftmann@53062
   189
  apply (induct x)
haftmann@53062
   190
   apply (simp_all add: mod_Suc)
haftmann@53062
   191
  apply arith
haftmann@53062
   192
  done
haftmann@53062
   193
haftmann@53062
   194
lemma nat_minus_mod: "(n - n mod m) mod m = (0 :: nat)"
haftmann@53062
   195
  by (induct n) (simp_all add : mod_Suc)
haftmann@53062
   196
haftmann@53062
   197
lemmas nat_minus_mod_plus_right = trans [OF nat_minus_mod mod_0 [symmetric],
haftmann@53062
   198
  THEN mod_plus_right [THEN iffD2], simplified]
haftmann@53062
   199
haftmann@53062
   200
lemmas push_mods' = mod_add_eq
haftmann@53062
   201
  mod_mult_eq mod_diff_eq
haftmann@53062
   202
  mod_minus_eq
haftmann@53062
   203
haftmann@53062
   204
lemmas push_mods = push_mods' [THEN eq_reflection]
haftmann@53062
   205
lemmas pull_mods = push_mods [symmetric] rdmods [THEN eq_reflection]
haftmann@53062
   206
lemmas mod_simps = 
haftmann@53062
   207
  mod_mult_self2_is_0 [THEN eq_reflection]
haftmann@53062
   208
  mod_mult_self1_is_0 [THEN eq_reflection]
haftmann@53062
   209
  mod_mod_trivial [THEN eq_reflection]
haftmann@53062
   210
haftmann@53062
   211
lemma nat_mod_eq:
haftmann@53062
   212
  "!!b. b < n ==> a mod n = b mod n ==> a mod n = (b :: nat)" 
haftmann@53062
   213
  by (induct a) auto
haftmann@53062
   214
haftmann@53062
   215
lemmas nat_mod_eq' = refl [THEN [2] nat_mod_eq]
haftmann@53062
   216
haftmann@53062
   217
lemma nat_mod_lem: 
haftmann@53062
   218
  "(0 :: nat) < n ==> b < n = (b mod n = b)"
haftmann@53062
   219
  apply safe
haftmann@53062
   220
   apply (erule nat_mod_eq')
haftmann@53062
   221
  apply (erule subst)
haftmann@53062
   222
  apply (erule mod_less_divisor)
haftmann@53062
   223
  done
haftmann@53062
   224
haftmann@53062
   225
lemma mod_nat_add: 
haftmann@53062
   226
  "(x :: nat) < z ==> y < z ==> 
haftmann@53062
   227
   (x + y) mod z = (if x + y < z then x + y else x + y - z)"
haftmann@53062
   228
  apply (rule nat_mod_eq)
haftmann@53062
   229
   apply auto
haftmann@53062
   230
  apply (rule trans)
haftmann@53062
   231
   apply (rule le_mod_geq)
haftmann@53062
   232
   apply simp
haftmann@53062
   233
  apply (rule nat_mod_eq')
haftmann@53062
   234
  apply arith
haftmann@53062
   235
  done
haftmann@53062
   236
haftmann@53062
   237
lemma mod_nat_sub: 
haftmann@53062
   238
  "(x :: nat) < z ==> (x - y) mod z = x - y"
haftmann@53062
   239
  by (rule nat_mod_eq') arith
haftmann@53062
   240
haftmann@53062
   241
lemma int_mod_eq:
haftmann@53062
   242
  "(0 :: int) <= b ==> b < n ==> a mod n = b mod n ==> a mod n = b"
haftmann@55816
   243
  by (metis mod_pos_pos_trivial)
haftmann@53062
   244
haftmann@55816
   245
lemmas int_mod_eq' = mod_pos_pos_trivial (* FIXME delete *)
haftmann@53062
   246
haftmann@53062
   247
lemma int_mod_le: "(0::int) <= a ==> a mod n <= a"
haftmann@58681
   248
  by (fact Divides.semiring_numeral_div_class.mod_less_eq_dividend) (* FIXME: delete *)
haftmann@53062
   249
haftmann@53062
   250
lemma mod_add_if_z:
haftmann@53062
   251
  "(x :: int) < z ==> y < z ==> 0 <= y ==> 0 <= x ==> 0 <= z ==> 
haftmann@53062
   252
   (x + y) mod z = (if x + y < z then x + y else x + y - z)"
haftmann@53062
   253
  by (auto intro: int_mod_eq)
haftmann@53062
   254
haftmann@53062
   255
lemma mod_sub_if_z:
haftmann@53062
   256
  "(x :: int) < z ==> y < z ==> 0 <= y ==> 0 <= x ==> 0 <= z ==> 
haftmann@53062
   257
   (x - y) mod z = (if y <= x then x - y else x - y + z)"
haftmann@53062
   258
  by (auto intro: int_mod_eq)
haftmann@53062
   259
haftmann@53062
   260
lemmas zmde = zmod_zdiv_equality [THEN diff_eq_eq [THEN iffD2], symmetric]
haftmann@53062
   261
lemmas mcl = mult_cancel_left [THEN iffD1, THEN make_pos_rule]
haftmann@53062
   262
haftmann@53062
   263
(* already have this for naturals, div_mult_self1/2, but not for ints *)
haftmann@53062
   264
lemma zdiv_mult_self: "m ~= (0 :: int) ==> (a + m * n) div m = a div m + n"
haftmann@53062
   265
  apply (rule mcl)
haftmann@53062
   266
   prefer 2
haftmann@53062
   267
   apply (erule asm_rl)
haftmann@53062
   268
  apply (simp add: zmde ring_distribs)
haftmann@53062
   269
  done
haftmann@53062
   270
haftmann@53062
   271
lemma mod_power_lem:
haftmann@53062
   272
  "a > 1 ==> a ^ n mod a ^ m = (if m <= n then 0 else (a :: int) ^ n)"
haftmann@53062
   273
  apply clarsimp
haftmann@53062
   274
  apply safe
haftmann@53062
   275
   apply (simp add: dvd_eq_mod_eq_0 [symmetric])
haftmann@53062
   276
   apply (drule le_iff_add [THEN iffD1])
haftmann@53062
   277
   apply (force simp: power_add)
haftmann@53062
   278
  apply (rule mod_pos_pos_trivial)
haftmann@53062
   279
   apply (simp)
haftmann@53062
   280
  apply (rule power_strict_increasing)
haftmann@53062
   281
   apply auto
haftmann@53062
   282
  done
haftmann@53062
   283
haftmann@53062
   284
lemma pl_pl_rels: 
haftmann@53062
   285
  "a + b = c + d ==> 
haftmann@53062
   286
   a >= c & b <= d | a <= c & b >= (d :: nat)" by arith
haftmann@53062
   287
haftmann@57512
   288
lemmas pl_pl_rels' = add.commute [THEN [2] trans, THEN pl_pl_rels]
haftmann@53062
   289
haftmann@53062
   290
lemma minus_eq: "(m - k = m) = (k = 0 | m = (0 :: nat))"  by arith
haftmann@53062
   291
haftmann@53062
   292
lemma pl_pl_mm: "(a :: nat) + b = c + d ==> a - c = d - b"  by arith
haftmann@53062
   293
haftmann@57512
   294
lemmas pl_pl_mm' = add.commute [THEN [2] trans, THEN pl_pl_mm]
haftmann@53062
   295
haftmann@53062
   296
lemmas dme = box_equals [OF div_mod_equality add_0_right add_0_right]
haftmann@53062
   297
lemmas dtle = xtr3 [OF dme [symmetric] le_add1]
haftmann@53062
   298
lemmas th2 = order_trans [OF order_refl [THEN [2] mult_le_mono] dtle]
haftmann@53062
   299
haftmann@53062
   300
lemma td_gal: 
haftmann@53062
   301
  "0 < c ==> (a >= b * c) = (a div c >= (b :: nat))"
haftmann@53062
   302
  apply safe
haftmann@53062
   303
   apply (erule (1) xtr4 [OF div_le_mono div_mult_self_is_m])
haftmann@53062
   304
  apply (erule th2)
haftmann@53062
   305
  done
haftmann@53062
   306
  
haftmann@53062
   307
lemmas td_gal_lt = td_gal [simplified not_less [symmetric], simplified]
haftmann@53062
   308
haftmann@53062
   309
lemma div_mult_le: "(a :: nat) div b * b <= a"
haftmann@53062
   310
  by (fact dtle)
haftmann@53062
   311
haftmann@53062
   312
lemmas sdl = split_div_lemma [THEN iffD1, symmetric]
haftmann@53062
   313
haftmann@53062
   314
lemma given_quot: "f > (0 :: nat) ==> (f * l + (f - 1)) div f = l"
haftmann@53062
   315
  by (rule sdl, assumption) (simp (no_asm))
haftmann@53062
   316
haftmann@53062
   317
lemma given_quot_alt: "f > (0 :: nat) ==> (l * f + f - Suc 0) div f = l"
haftmann@53062
   318
  apply (frule given_quot)
haftmann@53062
   319
  apply (rule trans)
haftmann@53062
   320
   prefer 2
haftmann@53062
   321
   apply (erule asm_rl)
haftmann@53062
   322
  apply (rule_tac f="%n. n div f" in arg_cong)
haftmann@57514
   323
  apply (simp add : ac_simps)
haftmann@53062
   324
  done
haftmann@53062
   325
    
haftmann@53062
   326
lemma diff_mod_le: "(a::nat) < d ==> b dvd d ==> a - a mod b <= d - b"
haftmann@53062
   327
  apply (unfold dvd_def)
haftmann@53062
   328
  apply clarify
haftmann@53062
   329
  apply (case_tac k)
haftmann@53062
   330
   apply clarsimp
haftmann@53062
   331
  apply clarify
haftmann@53062
   332
  apply (cases "b > 0")
haftmann@57512
   333
   apply (drule mult.commute [THEN xtr1])
haftmann@53062
   334
   apply (frule (1) td_gal_lt [THEN iffD1])
haftmann@53062
   335
   apply (clarsimp simp: le_simps)
haftmann@53062
   336
   apply (rule mult_div_cancel [THEN [2] xtr4])
haftmann@53062
   337
   apply (rule mult_mono)
haftmann@53062
   338
      apply auto
haftmann@53062
   339
  done
haftmann@53062
   340
haftmann@53062
   341
lemma less_le_mult':
haftmann@53062
   342
  "w * c < b * c ==> 0 \<le> c ==> (w + 1) * c \<le> b * (c::int)"
haftmann@53062
   343
  apply (rule mult_right_mono)
haftmann@53062
   344
   apply (rule zless_imp_add1_zle)
haftmann@53062
   345
   apply (erule (1) mult_right_less_imp_less)
haftmann@53062
   346
  apply assumption
haftmann@53062
   347
  done
haftmann@53062
   348
haftmann@55816
   349
lemma less_le_mult:
haftmann@55816
   350
  "w * c < b * c \<Longrightarrow> 0 \<le> c \<Longrightarrow> w * c + c \<le> b * (c::int)"
haftmann@55816
   351
  using less_le_mult' [of w c b] by (simp add: algebra_simps)
haftmann@53062
   352
haftmann@53062
   353
lemmas less_le_mult_minus = iffD2 [OF le_diff_eq less_le_mult, 
haftmann@53062
   354
  simplified left_diff_distrib]
haftmann@53062
   355
haftmann@53062
   356
lemma gen_minus: "0 < n ==> f n = f (Suc (n - 1))"
haftmann@53062
   357
  by auto
haftmann@53062
   358
haftmann@53062
   359
lemma mpl_lem: "j <= (i :: nat) ==> k < j ==> i - j + k < i" by arith
haftmann@53062
   360
haftmann@53062
   361
lemma nonneg_mod_div:
haftmann@53062
   362
  "0 <= a ==> 0 <= b ==> 0 <= (a mod b :: int) & 0 <= a div b"
haftmann@53062
   363
  apply (cases "b = 0", clarsimp)
haftmann@53062
   364
  apply (auto intro: pos_imp_zdiv_nonneg_iff [THEN iffD2])
haftmann@53062
   365
  done
haftmann@53062
   366
haftmann@54872
   367
declare iszero_0 [intro]
haftmann@54872
   368
haftmann@54872
   369
lemma min_pm [simp]:
haftmann@54872
   370
  "min a b + (a - b) = (a :: nat)"
haftmann@54872
   371
  by arith
haftmann@54872
   372
  
haftmann@54872
   373
lemma min_pm1 [simp]:
haftmann@54872
   374
  "a - b + min a b = (a :: nat)"
haftmann@54872
   375
  by arith
haftmann@54872
   376
haftmann@54872
   377
lemma rev_min_pm [simp]:
haftmann@54872
   378
  "min b a + (a - b) = (a :: nat)"
haftmann@54872
   379
  by arith
haftmann@54872
   380
haftmann@54872
   381
lemma rev_min_pm1 [simp]:
haftmann@54872
   382
  "a - b + min b a = (a :: nat)"
haftmann@54872
   383
  by arith
haftmann@54872
   384
haftmann@54872
   385
lemma min_minus [simp]:
haftmann@54872
   386
  "min m (m - k) = (m - k :: nat)"
haftmann@54872
   387
  by arith
haftmann@54872
   388
  
haftmann@54872
   389
lemma min_minus' [simp]:
haftmann@54872
   390
  "min (m - k) m = (m - k :: nat)"
haftmann@54872
   391
  by arith
haftmann@54872
   392
haftmann@53062
   393
end
haftmann@53062
   394