author nipkow Thu May 14 15:39:15 2009 +0200 (2009-05-14) changeset 31148 7ba7c1f8bc22 parent 31144 bdc1504ad456 child 31149 7be8054639cd
Cleaned up Parity a little
 src/HOL/Decision_Procs/Approximation.thy file | annotate | diff | revisions src/HOL/Library/Formal_Power_Series.thy file | annotate | diff | revisions src/HOL/MacLaurin.thy file | annotate | diff | revisions src/HOL/Parity.thy file | annotate | diff | revisions src/HOL/Transcendental.thy file | annotate | diff | revisions
```     1.1 --- a/src/HOL/Decision_Procs/Approximation.thy	Thu May 14 08:22:07 2009 +0200
1.2 +++ b/src/HOL/Decision_Procs/Approximation.thy	Thu May 14 15:39:15 2009 +0200
1.3 @@ -460,7 +460,7 @@
1.4  proof (cases "even n")
1.5    case True
1.6    obtain n' where "Suc n' = get_odd n" and "odd (Suc n')" using get_odd_ex by auto
1.7 -  hence "even n'" unfolding even_nat_Suc by auto
1.8 +  hence "even n'" unfolding even_Suc by auto
1.9    have "arctan (real x) \<le> real (x * ub_arctan_horner prec (get_odd n) 1 (x * x))"
1.10      unfolding `Suc n' = get_odd n`[symmetric] using arctan_0_1_bounds'[OF `0 \<le> real x` `real x \<le> 1` `even n'`] by auto
1.11    moreover
1.12 @@ -470,7 +470,7 @@
1.13  next
1.14    case False hence "0 < n" by (rule odd_pos)
1.15    from gr0_implies_Suc[OF this] obtain n' where "n = Suc n'" ..
1.16 -  from False[unfolded this even_nat_Suc]
1.17 +  from False[unfolded this even_Suc]
1.18    have "even n'" and "even (Suc (Suc n'))" by auto
1.19    have "get_odd n = Suc n'" unfolding get_odd_def if_P[OF False] using `n = Suc n'` .
1.20
```
```     2.1 --- a/src/HOL/Library/Formal_Power_Series.thy	Thu May 14 08:22:07 2009 +0200
2.2 +++ b/src/HOL/Library/Formal_Power_Series.thy	Thu May 14 15:39:15 2009 +0200
2.3 @@ -917,8 +917,7 @@
2.4  proof-
2.5    have eq: "(1 + X) * ?r = 1"
2.6      unfolding minus_one_power_iff
2.7 -    apply (auto simp add: ring_simps fps_eq_iff)
2.8 -    by presburger+
2.9 +    by (auto simp add: ring_simps fps_eq_iff)
2.10    show ?thesis by (auto simp add: eq intro: fps_inverse_unique)
2.11  qed
2.12
2.13 @@ -2286,9 +2285,7 @@
2.14    (is "inverse ?l = ?r")
2.15  proof-
2.16    have th: "?l * ?r = 1"
2.17 -    apply (auto simp add: ring_simps fps_eq_iff X_mult_nth  minus_one_power_iff)
2.18 -    apply presburger+
2.19 -    done
2.20 +    by (auto simp add: ring_simps fps_eq_iff minus_one_power_iff)
2.21    have th': "?l \$ 0 \<noteq> 0" by (simp add: )
2.22    from fps_inverse_unique[OF th' th] show ?thesis .
2.23  qed
```
```     3.1 --- a/src/HOL/MacLaurin.thy	Thu May 14 08:22:07 2009 +0200
3.2 +++ b/src/HOL/MacLaurin.thy	Thu May 14 15:39:15 2009 +0200
3.3 @@ -552,10 +552,6 @@
3.4      "[|x = y; abs u \<le> (v::real) |] ==> \<bar>(x + u) - y\<bar> \<le> v"
3.5  by auto
3.6
3.7 -text {* TODO: move to Parity.thy *}
3.8 -lemma nat_odd_1 [simp]: "odd (1::nat)"
3.9 -  unfolding even_nat_def by simp
3.10 -
3.11  lemma Maclaurin_sin_bound:
3.12    "abs(sin x - (\<Sum>m=0..<n. (if even m then 0 else (-1 ^ ((m - Suc 0) div 2)) / real (fact m)) *
3.13    x ^ m))  \<le> inverse(real (fact n)) * \<bar>x\<bar> ^ n"
```
```     4.1 --- a/src/HOL/Parity.thy	Thu May 14 08:22:07 2009 +0200
4.2 +++ b/src/HOL/Parity.thy	Thu May 14 15:39:15 2009 +0200
4.3 @@ -29,6 +29,18 @@
4.4  end
4.5
4.6
4.7 +lemma even_zero_int[simp]: "even (0::int)" by presburger
4.8 +
4.9 +lemma odd_one_int[simp]: "odd (1::int)" by presburger
4.10 +
4.11 +lemma even_zero_nat[simp]: "even (0::nat)" by presburger
4.12 +
4.13 +lemma odd_zero_nat [simp]: "odd (1::nat)" by presburger
4.14 +
4.15 +declare even_def[of "number_of v", standard, simp]
4.16 +
4.17 +declare even_nat_def[of "number_of v", standard, simp]
4.18 +
4.19  subsection {* Even and odd are mutually exclusive *}
4.20
4.21  lemma int_pos_lt_two_imp_zero_or_one:
4.22 @@ -54,66 +66,47 @@
4.23  lemma odd_times_odd: "odd (x::int) ==> odd y ==> odd (x * y)"
4.24    by (simp add: even_def zmod_zmult1_eq)
4.25
4.26 -lemma even_product[presburger]: "even((x::int) * y) = (even x | even y)"
4.27 +lemma even_product[simp,presburger]: "even((x::int) * y) = (even x | even y)"
4.28    apply (auto simp add: even_times_anything anything_times_even)
4.29    apply (rule ccontr)
4.30    apply (auto simp add: odd_times_odd)
4.31    done
4.32
4.33  lemma even_plus_even: "even (x::int) ==> even y ==> even (x + y)"
4.34 -  by presburger
4.35 +by presburger
4.36
4.37  lemma even_plus_odd: "even (x::int) ==> odd y ==> odd (x + y)"
4.38 -  by presburger
4.39 +by presburger
4.40
4.41  lemma odd_plus_even: "odd (x::int) ==> even y ==> odd (x + y)"
4.42 -  by presburger
4.43 +by presburger
4.44
4.45  lemma odd_plus_odd: "odd (x::int) ==> odd y ==> even (x + y)" by presburger
4.46
4.47 -lemma even_sum[presburger]: "even ((x::int) + y) = ((even x & even y) | (odd x & odd y))"
4.48 -  by presburger
4.49 +lemma even_sum[simp,presburger]:
4.50 +  "even ((x::int) + y) = ((even x & even y) | (odd x & odd y))"
4.51 +by presburger
4.52
4.53 -lemma even_neg[presburger, algebra]: "even (-(x::int)) = even x" by presburger
4.54 +lemma even_neg[simp,presburger,algebra]: "even (-(x::int)) = even x"
4.55 +by presburger
4.56
4.57 -lemma even_difference:
4.58 +lemma even_difference[simp]:
4.59      "even ((x::int) - y) = ((even x & even y) | (odd x & odd y))" by presburger
4.60
4.61 -lemma even_pow_gt_zero:
4.62 -    "even (x::int) ==> 0 < n ==> even (x^n)"
4.63 -  by (induct n) (auto simp add: even_product)
4.64 -
4.65 -lemma odd_pow_iff[presburger, algebra]:
4.66 -  "odd ((x::int) ^ n) \<longleftrightarrow> (n = 0 \<or> odd x)"
4.67 -  apply (induct n, simp_all)
4.68 -  apply presburger
4.69 -  apply (case_tac n, auto)
4.70 -  apply (simp_all add: even_product)
4.71 -  done
4.72 +lemma even_power[simp,presburger]: "even ((x::int)^n) = (even x & n \<noteq> 0)"
4.73 +by (induct n) auto
4.74
4.75 -lemma odd_pow: "odd x ==> odd((x::int)^n)" by (simp add: odd_pow_iff)
4.76 -
4.77 -lemma even_power[presburger]: "even ((x::int)^n) = (even x & 0 < n)"
4.78 -  apply (auto simp add: even_pow_gt_zero)
4.79 -  apply (erule contrapos_pp, erule odd_pow)
4.80 -  apply (erule contrapos_pp, simp add: even_def)
4.81 -  done
4.82 -
4.83 -lemma even_zero[presburger]: "even (0::int)" by presburger
4.84 -
4.85 -lemma odd_one[presburger]: "odd (1::int)" by presburger
4.86 -
4.87 -lemmas even_odd_simps [simp] = even_def[of "number_of v",standard] even_zero
4.88 -  odd_one even_product even_sum even_neg even_difference even_power
4.89 +lemma odd_pow: "odd x ==> odd((x::int)^n)" by simp
4.90
4.91
4.92  subsection {* Equivalent definitions *}
4.93
4.94  lemma two_times_even_div_two: "even (x::int) ==> 2 * (x div 2) = x"
4.95 -  by presburger
4.96 +by presburger
4.97
4.98 -lemma two_times_odd_div_two_plus_one: "odd (x::int) ==>
4.99 -    2 * (x div 2) + 1 = x" by presburger
4.100 +lemma two_times_odd_div_two_plus_one:
4.101 +  "odd (x::int) ==> 2 * (x div 2) + 1 = x"
4.102 +by presburger
4.103
4.104  lemma even_equiv_def: "even (x::int) = (EX y. x = 2 * y)" by presburger
4.105
4.106 @@ -122,45 +115,45 @@
4.107  subsection {* even and odd for nats *}
4.108
4.109  lemma pos_int_even_equiv_nat_even: "0 \<le> x ==> even x = even (nat x)"
4.110 -  by (simp add: even_nat_def)
4.111 -
4.112 -lemma even_nat_product[presburger, algebra]: "even((x::nat) * y) = (even x | even y)"
4.113 -  by (simp add: even_nat_def int_mult)
4.115
4.116 -lemma even_nat_sum[presburger, algebra]: "even ((x::nat) + y) =
4.117 -    ((even x & even y) | (odd x & odd y))" by presburger
4.118 +lemma even_product_nat[simp,presburger,algebra]:
4.119 +  "even((x::nat) * y) = (even x | even y)"
4.120 +by (simp add: even_nat_def int_mult)
4.121
4.122 -lemma even_nat_difference[presburger, algebra]:
4.123 -    "even ((x::nat) - y) = (x < y | (even x & even y) | (odd x & odd y))"
4.124 +lemma even_sum_nat[simp,presburger,algebra]:
4.125 +  "even ((x::nat) + y) = ((even x & even y) | (odd x & odd y))"
4.126  by presburger
4.127
4.128 -lemma even_nat_Suc[presburger, algebra]: "even (Suc x) = odd x" by presburger
4.129 -
4.130 -lemma even_nat_power[presburger, algebra]: "even ((x::nat)^y) = (even x & 0 < y)"
4.131 -  by (simp add: even_nat_def int_power)
4.132 +lemma even_difference_nat[simp,presburger,algebra]:
4.133 +  "even ((x::nat) - y) = (x < y | (even x & even y) | (odd x & odd y))"
4.134 +by presburger
4.135
4.136 -lemma even_nat_zero[presburger]: "even (0::nat)" by presburger
4.137 +lemma even_Suc[simp,presburger,algebra]: "even (Suc x) = odd x"
4.138 +by presburger
4.139
4.140 -lemmas even_odd_nat_simps [simp] = even_nat_def[of "number_of v",standard]
4.141 -  even_nat_zero even_nat_Suc even_nat_product even_nat_sum even_nat_power
4.142 +lemma even_power_nat[simp,presburger,algebra]:
4.143 +  "even ((x::nat)^y) = (even x & 0 < y)"
4.144 +by (simp add: even_nat_def int_power)
4.145
4.146
4.147  subsection {* Equivalent definitions *}
4.148
4.149 -lemma nat_lt_two_imp_zero_or_one: "(x::nat) < Suc (Suc 0) ==>
4.150 -    x = 0 | x = Suc 0" by presburger
4.151 +lemma nat_lt_two_imp_zero_or_one:
4.152 +  "(x::nat) < Suc (Suc 0) ==> x = 0 | x = Suc 0"
4.153 +by presburger
4.154
4.155  lemma even_nat_mod_two_eq_zero: "even (x::nat) ==> x mod (Suc (Suc 0)) = 0"
4.156 -  by presburger
4.157 +by presburger
4.158
4.159  lemma odd_nat_mod_two_eq_one: "odd (x::nat) ==> x mod (Suc (Suc 0)) = Suc 0"
4.160  by presburger
4.161
4.162  lemma even_nat_equiv_def: "even (x::nat) = (x mod Suc (Suc 0) = 0)"
4.163 -  by presburger
4.164 +by presburger
4.165
4.166  lemma odd_nat_equiv_def: "odd (x::nat) = (x mod Suc (Suc 0) = Suc 0)"
4.167 -  by presburger
4.168 +by presburger
4.169
4.170  lemma even_nat_div_two_times_two: "even (x::nat) ==>
4.171      Suc (Suc 0) * (x div Suc (Suc 0)) = x" by presburger
4.172 @@ -169,10 +162,10 @@
4.173      Suc( Suc (Suc 0) * (x div Suc (Suc 0))) = x" by presburger
4.174
4.175  lemma even_nat_equiv_def2: "even (x::nat) = (EX y. x = Suc (Suc 0) * y)"
4.176 -  by presburger
4.177 +by presburger
4.178
4.179  lemma odd_nat_equiv_def2: "odd (x::nat) = (EX y. x = Suc(Suc (Suc 0) * y))"
4.180 -  by presburger
4.181 +by presburger
4.182
4.183
4.184  subsection {* Parity and powers *}
4.185 @@ -183,7 +176,7 @@
4.186    apply (induct x)
4.187    apply (rule conjI)
4.188    apply simp
4.189 -  apply (insert even_nat_zero, blast)
4.190 +  apply (insert even_zero_nat, blast)
4.192    done
4.193
```
```     5.1 --- a/src/HOL/Transcendental.thy	Thu May 14 08:22:07 2009 +0200
5.2 +++ b/src/HOL/Transcendental.thy	Thu May 14 15:39:15 2009 +0200
5.3 @@ -173,7 +173,7 @@
5.4      have "(\<lambda> n. if even n then f (n div 2) else 0) sums y"
5.5        unfolding sums_def setsum_shift_lb_Suc0_0_upt[where f="?s", OF `?s 0 = 0`, symmetric]
5.6                  image_Suc_atLeastLessThan[symmetric] setsum_reindex[OF inj_Suc, unfolded comp_def]
5.7 -                even_nat_Suc Suc_m1 if_eq .
5.8 +                even_Suc Suc_m1 if_eq .
5.9    } from sums_add[OF g_sums this]
5.10    show ?thesis unfolding if_sum .
5.11  qed
```