src/HOL/Parity.thy
 changeset 31148 7ba7c1f8bc22 parent 31017 2c227493ea56 child 31718 7715d4d3586f
```     1.1 --- a/src/HOL/Parity.thy	Thu May 14 08:22:07 2009 +0200
1.2 +++ b/src/HOL/Parity.thy	Thu May 14 15:39:15 2009 +0200
1.3 @@ -29,6 +29,18 @@
1.4  end
1.5
1.6
1.7 +lemma even_zero_int[simp]: "even (0::int)" by presburger
1.8 +
1.9 +lemma odd_one_int[simp]: "odd (1::int)" by presburger
1.10 +
1.11 +lemma even_zero_nat[simp]: "even (0::nat)" by presburger
1.12 +
1.13 +lemma odd_zero_nat [simp]: "odd (1::nat)" by presburger
1.14 +
1.15 +declare even_def[of "number_of v", standard, simp]
1.16 +
1.17 +declare even_nat_def[of "number_of v", standard, simp]
1.18 +
1.19  subsection {* Even and odd are mutually exclusive *}
1.20
1.21  lemma int_pos_lt_two_imp_zero_or_one:
1.22 @@ -54,66 +66,47 @@
1.23  lemma odd_times_odd: "odd (x::int) ==> odd y ==> odd (x * y)"
1.24    by (simp add: even_def zmod_zmult1_eq)
1.25
1.26 -lemma even_product[presburger]: "even((x::int) * y) = (even x | even y)"
1.27 +lemma even_product[simp,presburger]: "even((x::int) * y) = (even x | even y)"
1.28    apply (auto simp add: even_times_anything anything_times_even)
1.29    apply (rule ccontr)
1.30    apply (auto simp add: odd_times_odd)
1.31    done
1.32
1.33  lemma even_plus_even: "even (x::int) ==> even y ==> even (x + y)"
1.34 -  by presburger
1.35 +by presburger
1.36
1.37  lemma even_plus_odd: "even (x::int) ==> odd y ==> odd (x + y)"
1.38 -  by presburger
1.39 +by presburger
1.40
1.41  lemma odd_plus_even: "odd (x::int) ==> even y ==> odd (x + y)"
1.42 -  by presburger
1.43 +by presburger
1.44
1.45  lemma odd_plus_odd: "odd (x::int) ==> odd y ==> even (x + y)" by presburger
1.46
1.47 -lemma even_sum[presburger]: "even ((x::int) + y) = ((even x & even y) | (odd x & odd y))"
1.48 -  by presburger
1.49 +lemma even_sum[simp,presburger]:
1.50 +  "even ((x::int) + y) = ((even x & even y) | (odd x & odd y))"
1.51 +by presburger
1.52
1.53 -lemma even_neg[presburger, algebra]: "even (-(x::int)) = even x" by presburger
1.54 +lemma even_neg[simp,presburger,algebra]: "even (-(x::int)) = even x"
1.55 +by presburger
1.56
1.57 -lemma even_difference:
1.58 +lemma even_difference[simp]:
1.59      "even ((x::int) - y) = ((even x & even y) | (odd x & odd y))" by presburger
1.60
1.61 -lemma even_pow_gt_zero:
1.62 -    "even (x::int) ==> 0 < n ==> even (x^n)"
1.63 -  by (induct n) (auto simp add: even_product)
1.64 -
1.65 -lemma odd_pow_iff[presburger, algebra]:
1.66 -  "odd ((x::int) ^ n) \<longleftrightarrow> (n = 0 \<or> odd x)"
1.67 -  apply (induct n, simp_all)
1.68 -  apply presburger
1.69 -  apply (case_tac n, auto)
1.70 -  apply (simp_all add: even_product)
1.71 -  done
1.72 +lemma even_power[simp,presburger]: "even ((x::int)^n) = (even x & n \<noteq> 0)"
1.73 +by (induct n) auto
1.74
1.75 -lemma odd_pow: "odd x ==> odd((x::int)^n)" by (simp add: odd_pow_iff)
1.76 -
1.77 -lemma even_power[presburger]: "even ((x::int)^n) = (even x & 0 < n)"
1.78 -  apply (auto simp add: even_pow_gt_zero)
1.79 -  apply (erule contrapos_pp, erule odd_pow)
1.80 -  apply (erule contrapos_pp, simp add: even_def)
1.81 -  done
1.82 -
1.83 -lemma even_zero[presburger]: "even (0::int)" by presburger
1.84 -
1.85 -lemma odd_one[presburger]: "odd (1::int)" by presburger
1.86 -
1.87 -lemmas even_odd_simps [simp] = even_def[of "number_of v",standard] even_zero
1.88 -  odd_one even_product even_sum even_neg even_difference even_power
1.89 +lemma odd_pow: "odd x ==> odd((x::int)^n)" by simp
1.90
1.91
1.92  subsection {* Equivalent definitions *}
1.93
1.94  lemma two_times_even_div_two: "even (x::int) ==> 2 * (x div 2) = x"
1.95 -  by presburger
1.96 +by presburger
1.97
1.98 -lemma two_times_odd_div_two_plus_one: "odd (x::int) ==>
1.99 -    2 * (x div 2) + 1 = x" by presburger
1.100 +lemma two_times_odd_div_two_plus_one:
1.101 +  "odd (x::int) ==> 2 * (x div 2) + 1 = x"
1.102 +by presburger
1.103
1.104  lemma even_equiv_def: "even (x::int) = (EX y. x = 2 * y)" by presburger
1.105
1.106 @@ -122,45 +115,45 @@
1.107  subsection {* even and odd for nats *}
1.108
1.109  lemma pos_int_even_equiv_nat_even: "0 \<le> x ==> even x = even (nat x)"
1.110 -  by (simp add: even_nat_def)
1.111 -
1.112 -lemma even_nat_product[presburger, algebra]: "even((x::nat) * y) = (even x | even y)"
1.113 -  by (simp add: even_nat_def int_mult)
1.115
1.116 -lemma even_nat_sum[presburger, algebra]: "even ((x::nat) + y) =
1.117 -    ((even x & even y) | (odd x & odd y))" by presburger
1.118 +lemma even_product_nat[simp,presburger,algebra]:
1.119 +  "even((x::nat) * y) = (even x | even y)"
1.120 +by (simp add: even_nat_def int_mult)
1.121
1.122 -lemma even_nat_difference[presburger, algebra]:
1.123 -    "even ((x::nat) - y) = (x < y | (even x & even y) | (odd x & odd y))"
1.124 +lemma even_sum_nat[simp,presburger,algebra]:
1.125 +  "even ((x::nat) + y) = ((even x & even y) | (odd x & odd y))"
1.126  by presburger
1.127
1.128 -lemma even_nat_Suc[presburger, algebra]: "even (Suc x) = odd x" by presburger
1.129 -
1.130 -lemma even_nat_power[presburger, algebra]: "even ((x::nat)^y) = (even x & 0 < y)"
1.131 -  by (simp add: even_nat_def int_power)
1.132 +lemma even_difference_nat[simp,presburger,algebra]:
1.133 +  "even ((x::nat) - y) = (x < y | (even x & even y) | (odd x & odd y))"
1.134 +by presburger
1.135
1.136 -lemma even_nat_zero[presburger]: "even (0::nat)" by presburger
1.137 +lemma even_Suc[simp,presburger,algebra]: "even (Suc x) = odd x"
1.138 +by presburger
1.139
1.140 -lemmas even_odd_nat_simps [simp] = even_nat_def[of "number_of v",standard]
1.141 -  even_nat_zero even_nat_Suc even_nat_product even_nat_sum even_nat_power
1.142 +lemma even_power_nat[simp,presburger,algebra]:
1.143 +  "even ((x::nat)^y) = (even x & 0 < y)"
1.144 +by (simp add: even_nat_def int_power)
1.145
1.146
1.147  subsection {* Equivalent definitions *}
1.148
1.149 -lemma nat_lt_two_imp_zero_or_one: "(x::nat) < Suc (Suc 0) ==>
1.150 -    x = 0 | x = Suc 0" by presburger
1.151 +lemma nat_lt_two_imp_zero_or_one:
1.152 +  "(x::nat) < Suc (Suc 0) ==> x = 0 | x = Suc 0"
1.153 +by presburger
1.154
1.155  lemma even_nat_mod_two_eq_zero: "even (x::nat) ==> x mod (Suc (Suc 0)) = 0"
1.156 -  by presburger
1.157 +by presburger
1.158
1.159  lemma odd_nat_mod_two_eq_one: "odd (x::nat) ==> x mod (Suc (Suc 0)) = Suc 0"
1.160  by presburger
1.161
1.162  lemma even_nat_equiv_def: "even (x::nat) = (x mod Suc (Suc 0) = 0)"
1.163 -  by presburger
1.164 +by presburger
1.165
1.166  lemma odd_nat_equiv_def: "odd (x::nat) = (x mod Suc (Suc 0) = Suc 0)"
1.167 -  by presburger
1.168 +by presburger
1.169
1.170  lemma even_nat_div_two_times_two: "even (x::nat) ==>
1.171      Suc (Suc 0) * (x div Suc (Suc 0)) = x" by presburger
1.172 @@ -169,10 +162,10 @@
1.173      Suc( Suc (Suc 0) * (x div Suc (Suc 0))) = x" by presburger
1.174
1.175  lemma even_nat_equiv_def2: "even (x::nat) = (EX y. x = Suc (Suc 0) * y)"
1.176 -  by presburger
1.177 +by presburger
1.178
1.179  lemma odd_nat_equiv_def2: "odd (x::nat) = (EX y. x = Suc(Suc (Suc 0) * y))"
1.180 -  by presburger
1.181 +by presburger
1.182
1.183
1.184  subsection {* Parity and powers *}
1.185 @@ -183,7 +176,7 @@
1.186    apply (induct x)
1.187    apply (rule conjI)
1.188    apply simp
1.189 -  apply (insert even_nat_zero, blast)
1.190 +  apply (insert even_zero_nat, blast)