src/HOL/Parity.thy
author haftmann
Fri Oct 10 19:55:32 2014 +0200 (2014-10-10)
changeset 58646 cd63a4b12a33
parent 58645 94bef115c08f
child 58678 398e05aa84d4
permissions -rw-r--r--
specialized specification: avoid trivial instances
wenzelm@41959
     1
(*  Title:      HOL/Parity.thy
wenzelm@41959
     2
    Author:     Jeremy Avigad
wenzelm@41959
     3
    Author:     Jacques D. Fleuriot
wenzelm@21256
     4
*)
wenzelm@21256
     5
wenzelm@21256
     6
header {* Even and Odd for int and nat *}
wenzelm@21256
     7
wenzelm@21256
     8
theory Parity
haftmann@30738
     9
imports Main
wenzelm@21256
    10
begin
wenzelm@21256
    11
haftmann@54228
    12
class even_odd = semiring_div_parity
haftmann@54227
    13
begin
wenzelm@21256
    14
haftmann@54228
    15
definition even :: "'a \<Rightarrow> bool"
haftmann@54228
    16
where
haftmann@58645
    17
  [algebra]: "even a \<longleftrightarrow> 2 dvd a"
haftmann@54228
    18
haftmann@58645
    19
lemmas even_iff_2_dvd = even_def
haftmann@58645
    20
haftmann@58645
    21
lemma even_iff_mod_2_eq_zero [presburger]:
haftmann@58645
    22
  "even a \<longleftrightarrow> a mod 2 = 0"
haftmann@54228
    23
  by (simp add: even_def dvd_eq_mod_eq_0)
haftmann@54228
    24
haftmann@54228
    25
lemma even_zero [simp]:
haftmann@54228
    26
  "even 0"
haftmann@58645
    27
  by (simp add: even_iff_mod_2_eq_zero)
haftmann@54228
    28
haftmann@54228
    29
lemma even_times_anything:
haftmann@54228
    30
  "even a \<Longrightarrow> even (a * b)"
haftmann@54228
    31
  by (simp add: even_iff_2_dvd)
haftmann@54228
    32
haftmann@54228
    33
lemma anything_times_even:
haftmann@54228
    34
  "even a \<Longrightarrow> even (b * a)"
haftmann@54228
    35
  by (simp add: even_iff_2_dvd)
haftmann@54228
    36
haftmann@54227
    37
abbreviation odd :: "'a \<Rightarrow> bool"
haftmann@54227
    38
where
haftmann@54228
    39
  "odd a \<equiv> \<not> even a"
haftmann@54228
    40
haftmann@54228
    41
lemma odd_times_odd:
haftmann@54228
    42
  "odd a \<Longrightarrow> odd b \<Longrightarrow> odd (a * b)" 
haftmann@58645
    43
  by (auto simp add: even_iff_mod_2_eq_zero mod_mult_left_eq)
haftmann@54228
    44
haftmann@54228
    45
lemma even_product [simp, presburger]:
haftmann@54228
    46
  "even (a * b) \<longleftrightarrow> even a \<or> even b"
haftmann@54228
    47
  apply (auto simp add: even_times_anything anything_times_even)
haftmann@54228
    48
  apply (rule ccontr)
haftmann@54228
    49
  apply (auto simp add: odd_times_odd)
haftmann@54228
    50
  done
haftmann@22390
    51
haftmann@54227
    52
end
haftmann@54227
    53
haftmann@54228
    54
instance nat and int  :: even_odd ..
haftmann@22390
    55
haftmann@54228
    56
lemma even_nat_def [presburger]:
haftmann@54228
    57
  "even x \<longleftrightarrow> even (int x)"
haftmann@58645
    58
  by (auto simp add: even_iff_mod_2_eq_zero int_eq_iff int_mult nat_mult_distrib)
haftmann@54228
    59
  
haftmann@33318
    60
lemma transfer_int_nat_relations:
haftmann@33318
    61
  "even (int x) \<longleftrightarrow> even x"
haftmann@33318
    62
  by (simp add: even_nat_def)
haftmann@33318
    63
haftmann@35644
    64
declare transfer_morphism_int_nat[transfer add return:
haftmann@33318
    65
  transfer_int_nat_relations
haftmann@33318
    66
]
wenzelm@21256
    67
haftmann@54228
    68
lemma odd_one_int [simp]:
haftmann@54228
    69
  "odd (1::int)"
haftmann@54228
    70
  by presburger
nipkow@31148
    71
haftmann@54228
    72
lemma odd_1_nat [simp]:
haftmann@54228
    73
  "odd (1::nat)"
haftmann@54228
    74
  by presburger
nipkow@31148
    75
huffman@47224
    76
lemma even_numeral_int [simp]: "even (numeral (Num.Bit0 k) :: int)"
haftmann@58645
    77
  unfolding even_iff_mod_2_eq_zero by simp
huffman@47224
    78
huffman@47224
    79
lemma odd_numeral_int [simp]: "odd (numeral (Num.Bit1 k) :: int)"
haftmann@58645
    80
  unfolding even_iff_mod_2_eq_zero by simp
huffman@47224
    81
huffman@47108
    82
(* TODO: proper simp rules for Num.Bit0, Num.Bit1 *)
haftmann@58645
    83
declare even_iff_mod_2_eq_zero [of "- numeral v", simp] for v
nipkow@31148
    84
huffman@47224
    85
lemma even_numeral_nat [simp]: "even (numeral (Num.Bit0 k) :: nat)"
huffman@47224
    86
  unfolding even_nat_def by simp
huffman@47224
    87
huffman@47224
    88
lemma odd_numeral_nat [simp]: "odd (numeral (Num.Bit1 k) :: nat)"
huffman@47224
    89
  unfolding even_nat_def by simp
nipkow@31148
    90
wenzelm@21256
    91
subsection {* Even and odd are mutually exclusive *}
wenzelm@21256
    92
haftmann@25600
    93
wenzelm@21256
    94
subsection {* Behavior under integer arithmetic operations *}
wenzelm@21256
    95
wenzelm@21256
    96
lemma even_plus_even: "even (x::int) ==> even y ==> even (x + y)"
nipkow@31148
    97
by presburger
wenzelm@21256
    98
wenzelm@21256
    99
lemma even_plus_odd: "even (x::int) ==> odd y ==> odd (x + y)"
nipkow@31148
   100
by presburger
wenzelm@21256
   101
wenzelm@21256
   102
lemma odd_plus_even: "odd (x::int) ==> even y ==> odd (x + y)"
nipkow@31148
   103
by presburger
wenzelm@21256
   104
chaieb@23522
   105
lemma odd_plus_odd: "odd (x::int) ==> odd y ==> even (x + y)" by presburger
wenzelm@21256
   106
nipkow@31148
   107
lemma even_sum[simp,presburger]:
nipkow@31148
   108
  "even ((x::int) + y) = ((even x & even y) | (odd x & odd y))"
nipkow@31148
   109
by presburger
wenzelm@21256
   110
nipkow@31148
   111
lemma even_neg[simp,presburger,algebra]: "even (-(x::int)) = even x"
nipkow@31148
   112
by presburger
wenzelm@21256
   113
nipkow@31148
   114
lemma even_difference[simp]:
chaieb@23522
   115
    "even ((x::int) - y) = ((even x & even y) | (odd x & odd y))" by presburger
wenzelm@21256
   116
nipkow@31148
   117
lemma even_power[simp,presburger]: "even ((x::int)^n) = (even x & n \<noteq> 0)"
nipkow@31148
   118
by (induct n) auto
wenzelm@21256
   119
nipkow@31148
   120
lemma odd_pow: "odd x ==> odd((x::int)^n)" by simp
wenzelm@21256
   121
wenzelm@21256
   122
wenzelm@21256
   123
subsection {* Equivalent definitions *}
wenzelm@21256
   124
chaieb@23522
   125
lemma two_times_even_div_two: "even (x::int) ==> 2 * (x div 2) = x" 
nipkow@31148
   126
by presburger
wenzelm@21256
   127
nipkow@31148
   128
lemma two_times_odd_div_two_plus_one:
nipkow@31148
   129
  "odd (x::int) ==> 2 * (x div 2) + 1 = x"
nipkow@31148
   130
by presburger
wenzelm@21256
   131
chaieb@23522
   132
lemma even_equiv_def: "even (x::int) = (EX y. x = 2 * y)" by presburger
wenzelm@21256
   133
chaieb@23522
   134
lemma odd_equiv_def: "odd (x::int) = (EX y. x = 2 * y + 1)" by presburger
wenzelm@21256
   135
wenzelm@21256
   136
subsection {* even and odd for nats *}
wenzelm@21256
   137
wenzelm@21256
   138
lemma pos_int_even_equiv_nat_even: "0 \<le> x ==> even x = even (nat x)"
nipkow@31148
   139
by (simp add: even_nat_def)
wenzelm@21256
   140
nipkow@31148
   141
lemma even_product_nat[simp,presburger,algebra]:
nipkow@31148
   142
  "even((x::nat) * y) = (even x | even y)"
nipkow@31148
   143
by (simp add: even_nat_def int_mult)
wenzelm@21256
   144
nipkow@31148
   145
lemma even_sum_nat[simp,presburger,algebra]:
nipkow@31148
   146
  "even ((x::nat) + y) = ((even x & even y) | (odd x & odd y))"
chaieb@23522
   147
by presburger
wenzelm@21256
   148
nipkow@31148
   149
lemma even_difference_nat[simp,presburger,algebra]:
nipkow@31148
   150
  "even ((x::nat) - y) = (x < y | (even x & even y) | (odd x & odd y))"
nipkow@31148
   151
by presburger
wenzelm@21256
   152
nipkow@31148
   153
lemma even_Suc[simp,presburger,algebra]: "even (Suc x) = odd x"
nipkow@31148
   154
by presburger
wenzelm@21256
   155
nipkow@31148
   156
lemma even_power_nat[simp,presburger,algebra]:
nipkow@31148
   157
  "even ((x::nat)^y) = (even x & 0 < y)"
nipkow@31148
   158
by (simp add: even_nat_def int_power)
wenzelm@21256
   159
wenzelm@21256
   160
wenzelm@21256
   161
subsection {* Equivalent definitions *}
wenzelm@21256
   162
wenzelm@21256
   163
lemma even_nat_mod_two_eq_zero: "even (x::nat) ==> x mod (Suc (Suc 0)) = 0"
nipkow@31148
   164
by presburger
wenzelm@21256
   165
wenzelm@21256
   166
lemma odd_nat_mod_two_eq_one: "odd (x::nat) ==> x mod (Suc (Suc 0)) = Suc 0"
chaieb@23522
   167
by presburger
wenzelm@21256
   168
wenzelm@21263
   169
lemma even_nat_equiv_def: "even (x::nat) = (x mod Suc (Suc 0) = 0)"
nipkow@31148
   170
by presburger
wenzelm@21256
   171
wenzelm@21256
   172
lemma odd_nat_equiv_def: "odd (x::nat) = (x mod Suc (Suc 0) = Suc 0)"
nipkow@31148
   173
by presburger
wenzelm@21256
   174
wenzelm@21263
   175
lemma even_nat_div_two_times_two: "even (x::nat) ==>
chaieb@23522
   176
    Suc (Suc 0) * (x div Suc (Suc 0)) = x" by presburger
wenzelm@21256
   177
wenzelm@21263
   178
lemma odd_nat_div_two_times_two_plus_one: "odd (x::nat) ==>
chaieb@23522
   179
    Suc( Suc (Suc 0) * (x div Suc (Suc 0))) = x" by presburger
wenzelm@21256
   180
wenzelm@21256
   181
lemma even_nat_equiv_def2: "even (x::nat) = (EX y. x = Suc (Suc 0) * y)"
nipkow@31148
   182
by presburger
wenzelm@21256
   183
wenzelm@21256
   184
lemma odd_nat_equiv_def2: "odd (x::nat) = (EX y. x = Suc(Suc (Suc 0) * y))"
nipkow@31148
   185
by presburger
wenzelm@21256
   186
haftmann@25600
   187
wenzelm@21256
   188
subsection {* Parity and powers *}
wenzelm@21256
   189
haftmann@54228
   190
lemma (in comm_ring_1) neg_power_if:
haftmann@54228
   191
  "(- a) ^ n = (if even n then (a ^ n) else - (a ^ n))"
haftmann@54228
   192
  by (induct n) simp_all
wenzelm@21256
   193
haftmann@54228
   194
lemma (in comm_ring_1)
haftmann@54489
   195
  shows neg_one_even_power [simp]: "even n \<Longrightarrow> (- 1) ^ n = 1"
haftmann@54489
   196
  and neg_one_odd_power [simp]: "odd n \<Longrightarrow> (- 1) ^ n = - 1"
haftmann@54489
   197
  by (simp_all add: neg_power_if)
wenzelm@21256
   198
wenzelm@21263
   199
lemma zero_le_even_power: "even n ==>
huffman@35631
   200
    0 <= (x::'a::{linordered_ring,monoid_mult}) ^ n"
wenzelm@21256
   201
  apply (simp add: even_nat_equiv_def2)
wenzelm@21256
   202
  apply (erule exE)
wenzelm@21256
   203
  apply (erule ssubst)
wenzelm@21256
   204
  apply (subst power_add)
wenzelm@21256
   205
  apply (rule zero_le_square)
wenzelm@21256
   206
  done
wenzelm@21256
   207
wenzelm@21263
   208
lemma zero_le_odd_power: "odd n ==>
haftmann@35028
   209
    (0 <= (x::'a::{linordered_idom}) ^ n) = (0 <= x)"
huffman@35216
   210
apply (auto simp: odd_nat_equiv_def2 power_add zero_le_mult_iff)
haftmann@36722
   211
apply (metis field_power_not_zero divisors_zero order_antisym_conv zero_le_square)
nipkow@30056
   212
done
wenzelm@21256
   213
haftmann@54227
   214
lemma zero_le_power_eq [presburger]: "(0 <= (x::'a::{linordered_idom}) ^ n) =
wenzelm@21256
   215
    (even n | (odd n & 0 <= x))"
wenzelm@21256
   216
  apply auto
wenzelm@21263
   217
  apply (subst zero_le_odd_power [symmetric])
wenzelm@21256
   218
  apply assumption+
wenzelm@21256
   219
  apply (erule zero_le_even_power)
wenzelm@21263
   220
  done
wenzelm@21256
   221
haftmann@35028
   222
lemma zero_less_power_eq[presburger]: "(0 < (x::'a::{linordered_idom}) ^ n) =
wenzelm@21256
   223
    (n = 0 | (even n & x ~= 0) | (odd n & 0 < x))"
chaieb@27668
   224
chaieb@27668
   225
  unfolding order_less_le zero_le_power_eq by auto
wenzelm@21256
   226
haftmann@35028
   227
lemma power_less_zero_eq[presburger]: "((x::'a::{linordered_idom}) ^ n < 0) =
chaieb@27668
   228
    (odd n & x < 0)"
wenzelm@21263
   229
  apply (subst linorder_not_le [symmetric])+
wenzelm@21256
   230
  apply (subst zero_le_power_eq)
wenzelm@21256
   231
  apply auto
wenzelm@21263
   232
  done
wenzelm@21256
   233
haftmann@35028
   234
lemma power_le_zero_eq[presburger]: "((x::'a::{linordered_idom}) ^ n <= 0) =
wenzelm@21256
   235
    (n ~= 0 & ((odd n & x <= 0) | (even n & x = 0)))"
wenzelm@21263
   236
  apply (subst linorder_not_less [symmetric])+
wenzelm@21256
   237
  apply (subst zero_less_power_eq)
wenzelm@21256
   238
  apply auto
wenzelm@21263
   239
  done
wenzelm@21256
   240
wenzelm@21263
   241
lemma power_even_abs: "even n ==>
haftmann@35028
   242
    (abs (x::'a::{linordered_idom}))^n = x^n"
wenzelm@21263
   243
  apply (subst power_abs [symmetric])
wenzelm@21256
   244
  apply (simp add: zero_le_even_power)
wenzelm@21263
   245
  done
wenzelm@21256
   246
wenzelm@21263
   247
lemma power_minus_even [simp]: "even n ==>
haftmann@31017
   248
    (- x)^n = (x^n::'a::{comm_ring_1})"
wenzelm@21256
   249
  apply (subst power_minus)
wenzelm@21256
   250
  apply simp
wenzelm@21263
   251
  done
wenzelm@21256
   252
wenzelm@21263
   253
lemma power_minus_odd [simp]: "odd n ==>
haftmann@31017
   254
    (- x)^n = - (x^n::'a::{comm_ring_1})"
wenzelm@21256
   255
  apply (subst power_minus)
wenzelm@21256
   256
  apply simp
wenzelm@21263
   257
  done
wenzelm@21256
   258
haftmann@35028
   259
lemma power_mono_even: fixes x y :: "'a :: {linordered_idom}"
hoelzl@29803
   260
  assumes "even n" and "\<bar>x\<bar> \<le> \<bar>y\<bar>"
hoelzl@29803
   261
  shows "x^n \<le> y^n"
hoelzl@29803
   262
proof -
hoelzl@29803
   263
  have "0 \<le> \<bar>x\<bar>" by auto
hoelzl@29803
   264
  with `\<bar>x\<bar> \<le> \<bar>y\<bar>`
hoelzl@29803
   265
  have "\<bar>x\<bar>^n \<le> \<bar>y\<bar>^n" by (rule power_mono)
hoelzl@29803
   266
  thus ?thesis unfolding power_even_abs[OF `even n`] .
hoelzl@29803
   267
qed
hoelzl@29803
   268
hoelzl@29803
   269
lemma odd_pos: "odd (n::nat) \<Longrightarrow> 0 < n" by presburger
hoelzl@29803
   270
haftmann@35028
   271
lemma power_mono_odd: fixes x y :: "'a :: {linordered_idom}"
hoelzl@29803
   272
  assumes "odd n" and "x \<le> y"
hoelzl@29803
   273
  shows "x^n \<le> y^n"
hoelzl@29803
   274
proof (cases "y < 0")
hoelzl@29803
   275
  case True with `x \<le> y` have "-y \<le> -x" and "0 \<le> -y" by auto
hoelzl@29803
   276
  hence "(-y)^n \<le> (-x)^n" by (rule power_mono)
hoelzl@29803
   277
  thus ?thesis unfolding power_minus_odd[OF `odd n`] by auto
hoelzl@29803
   278
next
hoelzl@29803
   279
  case False
hoelzl@29803
   280
  show ?thesis
hoelzl@29803
   281
  proof (cases "x < 0")
hoelzl@29803
   282
    case True hence "n \<noteq> 0" and "x \<le> 0" using `odd n`[THEN odd_pos] by auto
hoelzl@29803
   283
    hence "x^n \<le> 0" unfolding power_le_zero_eq using `odd n` by auto
hoelzl@29803
   284
    moreover
hoelzl@29803
   285
    from `\<not> y < 0` have "0 \<le> y" by auto
hoelzl@29803
   286
    hence "0 \<le> y^n" by auto
hoelzl@29803
   287
    ultimately show ?thesis by auto
hoelzl@29803
   288
  next
hoelzl@29803
   289
    case False hence "0 \<le> x" by auto
hoelzl@29803
   290
    with `x \<le> y` show ?thesis using power_mono by auto
hoelzl@29803
   291
  qed
hoelzl@29803
   292
qed
wenzelm@21263
   293
haftmann@25600
   294
haftmann@25600
   295
subsection {* More Even/Odd Results *}
haftmann@25600
   296
 
chaieb@27668
   297
lemma even_mult_two_ex: "even(n) = (\<exists>m::nat. n = 2*m)" by presburger
chaieb@27668
   298
lemma odd_Suc_mult_two_ex: "odd(n) = (\<exists>m. n = Suc (2*m))" by presburger
chaieb@27668
   299
lemma even_add [simp]: "even(m + n::nat) = (even m = even n)"  by presburger
haftmann@25600
   300
chaieb@27668
   301
lemma odd_add [simp]: "odd(m + n::nat) = (odd m \<noteq> odd n)" by presburger
haftmann@25600
   302
chaieb@27668
   303
lemma lemma_even_div2 [simp]: "even (n::nat) ==> (n + 1) div 2 = n div 2" by presburger
haftmann@25600
   304
haftmann@25600
   305
lemma lemma_not_even_div2 [simp]: "~even n ==> (n + 1) div 2 = Suc (n div 2)"
chaieb@27668
   306
by presburger
haftmann@25600
   307
chaieb@27668
   308
lemma even_num_iff: "0 < n ==> even n = (~ even(n - 1 :: nat))"  by presburger
chaieb@27668
   309
lemma even_even_mod_4_iff: "even (n::nat) = even (n mod 4)" by presburger
haftmann@25600
   310
chaieb@27668
   311
lemma lemma_odd_mod_4_div_2: "n mod 4 = (3::nat) ==> odd((n - 1) div 2)" by presburger
haftmann@25600
   312
haftmann@25600
   313
lemma lemma_even_mod_4_div_2: "n mod 4 = (1::nat) ==> even ((n - 1) div 2)"
chaieb@27668
   314
  by presburger
haftmann@25600
   315
wenzelm@21263
   316
text {* Simplify, when the exponent is a numeral *}
wenzelm@21256
   317
huffman@47108
   318
lemmas zero_le_power_eq_numeral [simp] =
haftmann@54227
   319
  zero_le_power_eq [of _ "numeral w"] for w
wenzelm@21256
   320
huffman@47108
   321
lemmas zero_less_power_eq_numeral [simp] =
haftmann@54227
   322
  zero_less_power_eq [of _ "numeral w"] for w
wenzelm@21256
   323
huffman@47108
   324
lemmas power_le_zero_eq_numeral [simp] =
haftmann@54227
   325
  power_le_zero_eq [of _ "numeral w"] for w
wenzelm@21256
   326
huffman@47108
   327
lemmas power_less_zero_eq_numeral [simp] =
haftmann@54227
   328
  power_less_zero_eq [of _ "numeral w"] for w
wenzelm@21256
   329
huffman@47108
   330
lemmas zero_less_power_nat_eq_numeral [simp] =
haftmann@54227
   331
  nat_zero_less_power_iff [of _ "numeral w"] for w
wenzelm@21256
   332
haftmann@54227
   333
lemmas power_eq_0_iff_numeral [simp] =
haftmann@54227
   334
  power_eq_0_iff [of _ "numeral w"] for w
wenzelm@21256
   335
haftmann@54227
   336
lemmas power_even_abs_numeral [simp] =
haftmann@54227
   337
  power_even_abs [of "numeral w" _] for w
wenzelm@21256
   338
wenzelm@21256
   339
wenzelm@21256
   340
subsection {* An Equivalence for @{term [source] "0 \<le> a^n"} *}
wenzelm@21256
   341
chaieb@23522
   342
lemma zero_le_power_iff[presburger]:
haftmann@35028
   343
  "(0 \<le> a^n) = (0 \<le> (a::'a::{linordered_idom}) | even n)"
wenzelm@21256
   344
proof cases
wenzelm@21256
   345
  assume even: "even n"
wenzelm@21256
   346
  then obtain k where "n = 2*k"
wenzelm@21256
   347
    by (auto simp add: even_nat_equiv_def2 numeral_2_eq_2)
wenzelm@21263
   348
  thus ?thesis by (simp add: zero_le_even_power even)
wenzelm@21256
   349
next
wenzelm@21256
   350
  assume odd: "odd n"
wenzelm@21256
   351
  then obtain k where "n = Suc(2*k)"
wenzelm@21256
   352
    by (auto simp add: odd_nat_equiv_def2 numeral_2_eq_2)
haftmann@54227
   353
  moreover have "a ^ (2 * k) \<le> 0 \<Longrightarrow> a = 0"
haftmann@54227
   354
    by (induct k) (auto simp add: zero_le_mult_iff mult_le_0_iff)
haftmann@54227
   355
  ultimately show ?thesis
haftmann@54227
   356
    by (auto simp add: zero_le_mult_iff zero_le_even_power)
wenzelm@21263
   357
qed
wenzelm@21263
   358
wenzelm@21256
   359
wenzelm@21256
   360
subsection {* Miscellaneous *}
wenzelm@21256
   361
chaieb@23522
   362
lemma [presburger]:"(x + 1) div 2 = x div 2 \<longleftrightarrow> even (x::int)" by presburger
chaieb@23522
   363
lemma [presburger]: "(x + 1) div 2 = x div 2 + 1 \<longleftrightarrow> odd (x::int)" by presburger
chaieb@23522
   364
lemma even_plus_one_div_two: "even (x::int) ==> (x + 1) div 2 = x div 2"  by presburger
chaieb@23522
   365
lemma odd_plus_one_div_two: "odd (x::int) ==> (x + 1) div 2 = x div 2 + 1" by presburger
wenzelm@21256
   366
chaieb@23522
   367
lemma [presburger]: "(Suc x) div Suc (Suc 0) = x div Suc (Suc 0) \<longleftrightarrow> even x" by presburger
wenzelm@21263
   368
lemma even_nat_plus_one_div_two: "even (x::nat) ==>
chaieb@23522
   369
    (Suc x) div Suc (Suc 0) = x div Suc (Suc 0)" by presburger
wenzelm@21256
   370
wenzelm@21263
   371
lemma odd_nat_plus_one_div_two: "odd (x::nat) ==>
chaieb@23522
   372
    (Suc x) div Suc (Suc 0) = Suc (x div Suc (Suc 0))" by presburger
wenzelm@21256
   373
wenzelm@21256
   374
end
haftmann@54227
   375