eliminated redundancies;
authorhaftmann
Sun Oct 26 19:11:16 2014 +0100 (2014-10-26)
changeset 58787af9eb5e566dd
parent 58786 fa5b67fb70ad
child 58788 d17b3844b726
eliminated redundancies;
more simp rules
src/HOL/GCD.thy
src/HOL/Library/Discrete.thy
src/HOL/Library/Extended_Real.thy
src/HOL/Library/FinFun.thy
src/HOL/NSA/NSComplex.thy
src/HOL/Parity.thy
src/HOL/Power.thy
src/HOL/Presburger.thy
src/HOL/Probability/Lebesgue_Measure.thy
     1.1 --- a/src/HOL/GCD.thy	Sat Oct 25 19:20:28 2014 +0200
     1.2 +++ b/src/HOL/GCD.thy	Sun Oct 26 19:11:16 2014 +0100
     1.3 @@ -870,7 +870,8 @@
     1.4        by (simp add: ab'(1,2)[symmetric])
     1.5      hence "?g^n*a'^n dvd ?g^n *b'^n"
     1.6        by (simp only: power_mult_distrib mult.commute)
     1.7 -    with zn z n have th0:"a'^n dvd b'^n" by auto
     1.8 +    then have th0: "a'^n dvd b'^n"
     1.9 +      using zn by auto
    1.10      have "a' dvd a'^n" by (simp add: m)
    1.11      with th0 have "a' dvd b'^n" using dvd_trans[of a' "a'^n" "b'^n"] by simp
    1.12      hence th1: "a' dvd b'^m * b'" by (simp add: m mult.commute)
     2.1 --- a/src/HOL/Library/Discrete.thy	Sat Oct 25 19:20:28 2014 +0200
     2.2 +++ b/src/HOL/Library/Discrete.thy	Sun Oct 26 19:11:16 2014 +0100
     2.3 @@ -109,7 +109,16 @@
     2.4      by (auto simp add: sqrt_def power2_nat_le_eq_le intro: antisym)
     2.5  qed
     2.6  
     2.7 -lemma mono_sqrt: "mono sqrt"
     2.8 +lemma sqrt_zero [simp]:
     2.9 +  "sqrt 0 = 0"
    2.10 +  using sqrt_inverse_power2 [of 0] by simp
    2.11 +
    2.12 +lemma sqrt_one [simp]:
    2.13 +  "sqrt 1 = 1"
    2.14 +  using sqrt_inverse_power2 [of 1] by simp
    2.15 +
    2.16 +lemma mono_sqrt:
    2.17 +  "mono sqrt"
    2.18  proof
    2.19    fix m n :: nat
    2.20    have *: "0 * 0 \<le> m" by simp
    2.21 @@ -140,7 +149,7 @@
    2.22  lemma sqrt_power2_le [simp]: (* FIXME tune proof *)
    2.23    "(sqrt n)\<^sup>2 \<le> n"
    2.24  proof (cases "n > 0")
    2.25 -  case False then show ?thesis by (simp add: sqrt_def)
    2.26 +  case False then show ?thesis by simp
    2.27  next
    2.28    case True then have "sqrt n > 0" by simp
    2.29    then have "mono (times (Max {m. m\<^sup>2 \<le> n}))" by (auto intro: mono_times_nat simp add: sqrt_def)
     3.1 --- a/src/HOL/Library/Extended_Real.thy	Sat Oct 25 19:20:28 2014 +0200
     3.2 +++ b/src/HOL/Library/Extended_Real.thy	Sun Oct 26 19:11:16 2014 +0100
     3.3 @@ -1232,9 +1232,8 @@
     3.4  lemma ereal_power_divide:
     3.5    fixes x y :: ereal
     3.6    shows "y \<noteq> 0 \<Longrightarrow> (x / y) ^ n = x^n / y^n"
     3.7 -  by (cases rule: ereal2_cases[of x y])
     3.8 -     (auto simp: one_ereal_def zero_ereal_def power_divide not_le
     3.9 -                 power_less_zero_eq zero_le_power_iff)
    3.10 +  by (cases rule: ereal2_cases [of x y])
    3.11 +     (auto simp: one_ereal_def zero_ereal_def power_divide zero_le_power_eq)
    3.12  
    3.13  lemma ereal_le_mult_one_interval:
    3.14    fixes x y :: ereal
     4.1 --- a/src/HOL/Library/FinFun.thy	Sat Oct 25 19:20:28 2014 +0200
     4.2 +++ b/src/HOL/Library/FinFun.thy	Sun Oct 26 19:11:16 2014 +0100
     4.3 @@ -890,7 +890,7 @@
     4.4  by(simp add: finfun_upd_apply)
     4.5  
     4.6  lemma finfun_ext: "(\<And>a. f $ a = g $ a) \<Longrightarrow> f = g"
     4.7 -by(auto simp add: finfun_apply_inject[symmetric] simp del: finfun_apply_inject)
     4.8 +by(auto simp add: finfun_apply_inject[symmetric])
     4.9  
    4.10  lemma expand_finfun_eq: "(f = g) = (op $ f = op $ g)"
    4.11  by(auto intro: finfun_ext)
    4.12 @@ -1287,7 +1287,7 @@
    4.13  lemma finfun_dom_update [simp]:
    4.14    "finfun_dom (f(a $:= b)) = (finfun_dom f)(a $:= (b \<noteq> finfun_default f))"
    4.15  including finfun unfolding finfun_dom_def finfun_update_def
    4.16 -apply(simp add: finfun_default_update_const fun_upd_apply finfun_dom_finfunI)
    4.17 +apply(simp add: finfun_default_update_const finfun_dom_finfunI)
    4.18  apply(fold finfun_update.rep_eq)
    4.19  apply(simp add: finfun_upd_apply fun_eq_iff fun_upd_def finfun_default_update_const)
    4.20  done
    4.21 @@ -1495,7 +1495,7 @@
    4.22      thus "finite (UNIV :: 'b set)"
    4.23        by(rule finite_imageD)(auto intro!: inj_onI)
    4.24    qed
    4.25 -  with False show ?thesis by simp
    4.26 +  with False show ?thesis by auto
    4.27  qed
    4.28  
    4.29  lemma finite_UNIV_finfun:
     5.1 --- a/src/HOL/NSA/NSComplex.thy	Sat Oct 25 19:20:28 2014 +0200
     5.2 +++ b/src/HOL/NSA/NSComplex.thy	Sun Oct 26 19:11:16 2014 +0100
     5.3 @@ -374,11 +374,11 @@
     5.4  lemma hcpow_minus:
     5.5       "!!x n. (-x::hcomplex) pow n =
     5.6        (if ( *p* even) n then (x pow n) else -(x pow n))"
     5.7 -by transfer (rule neg_power_if)
     5.8 +by transfer simp
     5.9  
    5.10  lemma hcpow_mult:
    5.11    "!!r s n. ((r::hcomplex) * s) pow n = (r pow n) * (s pow n)"
    5.12 -by transfer (rule power_mult_distrib)
    5.13 +  by (fact hyperpow_mult)
    5.14  
    5.15  lemma hcpow_zero2 [simp]:
    5.16    "\<And>n. 0 pow (hSuc n) = (0::'a::{power,semiring_0} star)"
     6.1 --- a/src/HOL/Parity.thy	Sat Oct 25 19:20:28 2014 +0200
     6.2 +++ b/src/HOL/Parity.thy	Sun Oct 26 19:11:16 2014 +0100
     6.3 @@ -3,148 +3,19 @@
     6.4      Author:     Jacques D. Fleuriot
     6.5  *)
     6.6  
     6.7 -header {* Even and Odd for int and nat *}
     6.8 +header {* Parity in rings and semirings *}
     6.9  
    6.10  theory Parity
    6.11  imports Nat_Transfer
    6.12  begin
    6.13  
    6.14 -subsection {* Preliminaries about divisibility on @{typ nat} and @{typ int} *}
    6.15 -
    6.16 -lemma two_dvd_Suc_Suc_iff [simp]:
    6.17 -  "2 dvd Suc (Suc n) \<longleftrightarrow> 2 dvd n"
    6.18 -  using dvd_add_triv_right_iff [of 2 n] by simp
    6.19 -
    6.20 -lemma two_dvd_Suc_iff:
    6.21 -  "2 dvd Suc n \<longleftrightarrow> \<not> 2 dvd n"
    6.22 -  by (induct n) auto
    6.23 -
    6.24 -lemma two_dvd_diff_nat_iff:
    6.25 -  fixes m n :: nat
    6.26 -  shows "2 dvd m - n \<longleftrightarrow> m < n \<or> 2 dvd m + n"
    6.27 -proof (cases "n \<le> m")
    6.28 -  case True
    6.29 -  then have "m - n + n * 2 = m + n" by (simp add: mult_2_right)
    6.30 -  moreover have "2 dvd m - n \<longleftrightarrow> 2 dvd m - n + n * 2" by simp
    6.31 -  ultimately have "2 dvd m - n \<longleftrightarrow> 2 dvd m + n" by (simp only:)
    6.32 -  then show ?thesis by auto
    6.33 -next
    6.34 -  case False
    6.35 -  then show ?thesis by simp
    6.36 -qed 
    6.37 -  
    6.38 -lemma two_dvd_diff_iff:
    6.39 -  fixes k l :: int
    6.40 -  shows "2 dvd k - l \<longleftrightarrow> 2 dvd k + l"
    6.41 -  using dvd_add_times_triv_right_iff [of 2 "k - l" l] by (simp add: mult_2_right)
    6.42 -
    6.43 -lemma two_dvd_abs_add_iff:
    6.44 -  fixes k l :: int
    6.45 -  shows "2 dvd \<bar>k\<bar> + l \<longleftrightarrow> 2 dvd k + l"
    6.46 -  by (cases "k \<ge> 0") (simp_all add: two_dvd_diff_iff ac_simps)
    6.47 -
    6.48 -lemma two_dvd_add_abs_iff:
    6.49 -  fixes k l :: int
    6.50 -  shows "2 dvd k + \<bar>l\<bar> \<longleftrightarrow> 2 dvd k + l"
    6.51 -  using two_dvd_abs_add_iff [of l k] by (simp add: ac_simps)
    6.52 -
    6.53 -
    6.54 -subsection {* Ring structures with parity *}
    6.55 +subsection {* Ring structures with parity and @{text even}/@{text odd} predicates *}
    6.56  
    6.57  class semiring_parity = semiring_dvd + semiring_numeral +
    6.58 -  assumes two_not_dvd_one [simp]: "\<not> 2 dvd 1"
    6.59 -  assumes not_dvd_not_dvd_dvd_add: "\<not> 2 dvd a \<Longrightarrow> \<not> 2 dvd b \<Longrightarrow> 2 dvd a + b"
    6.60 -  assumes two_is_prime: "2 dvd a * b \<Longrightarrow> 2 dvd a \<or> 2 dvd b"
    6.61 -  assumes not_dvd_ex_decrement: "\<not> 2 dvd a \<Longrightarrow> \<exists>b. a = b + 1"
    6.62 -begin
    6.63 -
    6.64 -lemma two_dvd_plus_one_iff [simp]:
    6.65 -  "2 dvd a + 1 \<longleftrightarrow> \<not> 2 dvd a"
    6.66 -  by (auto simp add: dvd_add_right_iff intro: not_dvd_not_dvd_dvd_add)
    6.67 -
    6.68 -lemma not_two_dvdE [elim?]:
    6.69 -  assumes "\<not> 2 dvd a"
    6.70 -  obtains b where "a = 2 * b + 1"
    6.71 -proof -
    6.72 -  from assms obtain b where *: "a = b + 1"
    6.73 -    by (blast dest: not_dvd_ex_decrement)
    6.74 -  with assms have "2 dvd b + 2" by simp
    6.75 -  then have "2 dvd b" by simp
    6.76 -  then obtain c where "b = 2 * c" ..
    6.77 -  with * have "a = 2 * c + 1" by simp
    6.78 -  with that show thesis .
    6.79 -qed
    6.80 -
    6.81 -end
    6.82 -
    6.83 -instance nat :: semiring_parity
    6.84 -proof
    6.85 -  show "\<not> (2 :: nat) dvd 1"
    6.86 -    by (rule notI, erule dvdE) simp
    6.87 -next
    6.88 -  fix m n :: nat
    6.89 -  assume "\<not> 2 dvd m"
    6.90 -  moreover assume "\<not> 2 dvd n"
    6.91 -  ultimately have *: "2 dvd Suc m \<and> 2 dvd Suc n"
    6.92 -    by (simp add: two_dvd_Suc_iff)
    6.93 -  then have "2 dvd Suc m + Suc n"
    6.94 -    by (blast intro: dvd_add)
    6.95 -  also have "Suc m + Suc n = m + n + 2"
    6.96 -    by simp
    6.97 -  finally show "2 dvd m + n"
    6.98 -    using dvd_add_triv_right_iff [of 2 "m + n"] by simp
    6.99 -next
   6.100 -  fix m n :: nat
   6.101 -  assume *: "2 dvd m * n"
   6.102 -  show "2 dvd m \<or> 2 dvd n"
   6.103 -  proof (rule disjCI)
   6.104 -    assume "\<not> 2 dvd n"
   6.105 -    then have "2 dvd Suc n" by (simp add: two_dvd_Suc_iff)
   6.106 -    then obtain r where "Suc n = 2 * r" ..
   6.107 -    moreover from * obtain s where "m * n = 2 * s" ..
   6.108 -    then have "2 * s + m = m * Suc n" by simp
   6.109 -    ultimately have " 2 * s + m = 2 * (m * r)" by (simp add: algebra_simps)
   6.110 -    then have "m = 2 * (m * r - s)" by simp
   6.111 -    then show "2 dvd m" ..
   6.112 -  qed
   6.113 -next
   6.114 -  fix n :: nat
   6.115 -  assume "\<not> 2 dvd n"
   6.116 -  then show "\<exists>m. n = m + 1"
   6.117 -    by (cases n) simp_all
   6.118 -qed
   6.119 -
   6.120 -class ring_parity = comm_ring_1 + semiring_parity
   6.121 -
   6.122 -instance int :: ring_parity
   6.123 -proof
   6.124 -  show "\<not> (2 :: int) dvd 1" by (simp add: dvd_int_unfold_dvd_nat)
   6.125 -  fix k l :: int
   6.126 -  assume "\<not> 2 dvd k"
   6.127 -  moreover assume "\<not> 2 dvd l"
   6.128 -  ultimately have "2 dvd nat \<bar>k\<bar> + nat \<bar>l\<bar>" 
   6.129 -    by (auto simp add: dvd_int_unfold_dvd_nat intro: not_dvd_not_dvd_dvd_add)
   6.130 -  then have "2 dvd \<bar>k\<bar> + \<bar>l\<bar>"
   6.131 -    by (simp add: dvd_int_unfold_dvd_nat nat_add_distrib)
   6.132 -  then show "2 dvd k + l"
   6.133 -    by (simp add: two_dvd_abs_add_iff two_dvd_add_abs_iff)
   6.134 -next
   6.135 -  fix k l :: int
   6.136 -  assume "2 dvd k * l"
   6.137 -  then show "2 dvd k \<or> 2 dvd l"
   6.138 -    by (simp add: dvd_int_unfold_dvd_nat two_is_prime nat_abs_mult_distrib)
   6.139 -next
   6.140 -  fix k :: int
   6.141 -  have "k = (k - 1) + 1" by simp
   6.142 -  then show "\<exists>l. k = l + 1" ..
   6.143 -qed
   6.144 -
   6.145 -
   6.146 -subsection {* Dedicated @{text even}/@{text odd} predicate *}
   6.147 -
   6.148 -subsubsection {* Properties *}
   6.149 -
   6.150 -context semiring_parity
   6.151 +  assumes odd_one [simp]: "\<not> 2 dvd 1"
   6.152 +  assumes odd_even_add: "\<not> 2 dvd a \<Longrightarrow> \<not> 2 dvd b \<Longrightarrow> 2 dvd a + b"
   6.153 +  assumes even_multD: "2 dvd a * b \<Longrightarrow> 2 dvd a \<or> 2 dvd b"
   6.154 +  assumes odd_ex_decrement: "\<not> 2 dvd a \<Longrightarrow> \<exists>b. a = b + 1"
   6.155  begin
   6.156  
   6.157  abbreviation even :: "'a \<Rightarrow> bool"
   6.158 @@ -155,6 +26,14 @@
   6.159  where
   6.160    "odd a \<equiv> \<not> 2 dvd a"
   6.161  
   6.162 +lemma even_zero [simp]:
   6.163 +  "even 0"
   6.164 +  by (fact dvd_0_right)
   6.165 +
   6.166 +lemma even_plus_one_iff [simp]:
   6.167 +  "even (a + 1) \<longleftrightarrow> odd a"
   6.168 +  by (auto simp add: dvd_add_right_iff intro: odd_even_add)
   6.169 +
   6.170  lemma evenE [elim?]:
   6.171    assumes "even a"
   6.172    obtains b where "a = 2 * b"
   6.173 @@ -163,19 +42,19 @@
   6.174  lemma oddE [elim?]:
   6.175    assumes "odd a"
   6.176    obtains b where "a = 2 * b + 1"
   6.177 -  using assms by (rule not_two_dvdE)
   6.178 -  
   6.179 +proof -
   6.180 +  from assms obtain b where *: "a = b + 1"
   6.181 +    by (blast dest: odd_ex_decrement)
   6.182 +  with assms have "even (b + 2)" by simp
   6.183 +  then have "even b" by simp
   6.184 +  then obtain c where "b = 2 * c" ..
   6.185 +  with * have "a = 2 * c + 1" by simp
   6.186 +  with that show thesis .
   6.187 +qed
   6.188 + 
   6.189  lemma even_times_iff [simp]:
   6.190    "even (a * b) \<longleftrightarrow> even a \<or> even b"
   6.191 -  by (auto simp add: dest: two_is_prime)
   6.192 -
   6.193 -lemma even_zero [simp]:
   6.194 -  "even 0"
   6.195 -  by simp
   6.196 -
   6.197 -lemma odd_one [simp]:
   6.198 -  "odd 1"
   6.199 -  by simp
   6.200 +  by (auto dest: even_multD)
   6.201  
   6.202  lemma even_numeral [simp]:
   6.203    "even (numeral (Num.Bit0 n))"
   6.204 @@ -206,7 +85,7 @@
   6.205  
   6.206  lemma even_add [simp]:
   6.207    "even (a + b) \<longleftrightarrow> (even a \<longleftrightarrow> even b)"
   6.208 -  by (auto simp add: dvd_add_right_iff dvd_add_left_iff not_dvd_not_dvd_dvd_add)
   6.209 +  by (auto simp add: dvd_add_right_iff dvd_add_left_iff odd_even_add)
   6.210  
   6.211  lemma odd_add [simp]:
   6.212    "odd (a + b) \<longleftrightarrow> (\<not> (odd a \<longleftrightarrow> odd b))"
   6.213 @@ -218,7 +97,7 @@
   6.214  
   6.215  end
   6.216  
   6.217 -context ring_parity
   6.218 +class ring_parity = comm_ring_1 + semiring_parity
   6.219  begin
   6.220  
   6.221  lemma even_minus [simp]:
   6.222 @@ -232,22 +111,110 @@
   6.223  end
   6.224  
   6.225  
   6.226 -subsubsection {* Particularities for @{typ nat} and @{typ int} *}
   6.227 +subsection {* Instances for @{typ nat} and @{typ int} *}
   6.228 +
   6.229 +lemma even_Suc_Suc_iff [simp]:
   6.230 +  "even (Suc (Suc n)) \<longleftrightarrow> even n"
   6.231 +  using dvd_add_triv_right_iff [of 2 n] by simp
   6.232  
   6.233  lemma even_Suc [simp]:
   6.234 -  "even (Suc n) = odd n"
   6.235 -  by (fact two_dvd_Suc_iff)
   6.236 +  "even (Suc n) \<longleftrightarrow> odd n"
   6.237 +  by (induct n) auto
   6.238 +
   6.239 +lemma even_diff_nat [simp]:
   6.240 +  fixes m n :: nat
   6.241 +  shows "even (m - n) \<longleftrightarrow> m < n \<or> even (m + n)"
   6.242 +proof (cases "n \<le> m")
   6.243 +  case True
   6.244 +  then have "m - n + n * 2 = m + n" by (simp add: mult_2_right)
   6.245 +  moreover have "even (m - n) \<longleftrightarrow> even (m - n + n * 2)" by simp
   6.246 +  ultimately have "even (m - n) \<longleftrightarrow> even (m + n)" by (simp only:)
   6.247 +  then show ?thesis by auto
   6.248 +next
   6.249 +  case False
   6.250 +  then show ?thesis by simp
   6.251 +qed 
   6.252 +  
   6.253 +lemma even_diff_iff [simp]:
   6.254 +  fixes k l :: int
   6.255 +  shows "even (k - l) \<longleftrightarrow> even (k + l)"
   6.256 +  using dvd_add_times_triv_right_iff [of 2 "k - l" l] by (simp add: mult_2_right)
   6.257 +
   6.258 +lemma even_abs_add_iff [simp]:
   6.259 +  fixes k l :: int
   6.260 +  shows "even (\<bar>k\<bar> + l) \<longleftrightarrow> even (k + l)"
   6.261 +  by (cases "k \<ge> 0") (simp_all add: ac_simps)
   6.262 +
   6.263 +lemma even_add_abs_iff [simp]:
   6.264 +  fixes k l :: int
   6.265 +  shows "even (k + \<bar>l\<bar>) \<longleftrightarrow> even (k + l)"
   6.266 +  using even_abs_add_iff [of l k] by (simp add: ac_simps)
   6.267 +
   6.268 +instance nat :: semiring_parity
   6.269 +proof
   6.270 +  show "odd (1 :: nat)"
   6.271 +    by (rule notI, erule dvdE) simp
   6.272 +next
   6.273 +  fix m n :: nat
   6.274 +  assume "odd m"
   6.275 +  moreover assume "odd n"
   6.276 +  ultimately have *: "even (Suc m) \<and> even (Suc n)"
   6.277 +    by simp
   6.278 +  then have "even (Suc m + Suc n)"
   6.279 +    by (blast intro: dvd_add)
   6.280 +  also have "Suc m + Suc n = m + n + 2"
   6.281 +    by simp
   6.282 +  finally show "even (m + n)"
   6.283 +    using dvd_add_triv_right_iff [of 2 "m + n"] by simp
   6.284 +next
   6.285 +  fix m n :: nat
   6.286 +  assume *: "even (m * n)"
   6.287 +  show "even m \<or> even n"
   6.288 +  proof (rule disjCI)
   6.289 +    assume "odd n"
   6.290 +    then have "even (Suc n)" by simp
   6.291 +    then obtain r where "Suc n = 2 * r" ..
   6.292 +    moreover from * obtain s where "m * n = 2 * s" ..
   6.293 +    then have "2 * s + m = m * Suc n" by simp
   6.294 +    ultimately have " 2 * s + m = 2 * (m * r)" by (simp add: algebra_simps)
   6.295 +    then have "m = 2 * (m * r - s)" by simp
   6.296 +    then show "even m" ..
   6.297 +  qed
   6.298 +next
   6.299 +  fix n :: nat
   6.300 +  assume "odd n"
   6.301 +  then show "\<exists>m. n = m + 1"
   6.302 +    by (cases n) simp_all
   6.303 +qed
   6.304  
   6.305  lemma odd_pos: 
   6.306    "odd (n :: nat) \<Longrightarrow> 0 < n"
   6.307    by (auto elim: oddE)
   6.308    
   6.309 -lemma even_diff_nat [simp]:
   6.310 -  fixes m n :: nat
   6.311 -  shows "even (m - n) \<longleftrightarrow> m < n \<or> even (m + n)"
   6.312 -  by (fact two_dvd_diff_nat_iff)
   6.313 +instance int :: ring_parity
   6.314 +proof
   6.315 +  show "odd (1 :: int)" by (simp add: dvd_int_unfold_dvd_nat)
   6.316 +  fix k l :: int
   6.317 +  assume "odd k"
   6.318 +  moreover assume "odd l"
   6.319 +  ultimately have "even (nat \<bar>k\<bar> + nat \<bar>l\<bar>)" 
   6.320 +    by (auto simp add: dvd_int_unfold_dvd_nat intro: odd_even_add)
   6.321 +  then have "even (\<bar>k\<bar> + \<bar>l\<bar>)"
   6.322 +    by (simp add: dvd_int_unfold_dvd_nat nat_add_distrib)
   6.323 +  then show "even (k + l)"
   6.324 +    by simp
   6.325 +next
   6.326 +  fix k l :: int
   6.327 +  assume "even (k * l)"
   6.328 +  then show "even k \<or> even l"
   6.329 +    by (simp add: dvd_int_unfold_dvd_nat even_multD nat_abs_mult_distrib)
   6.330 +next
   6.331 +  fix k :: int
   6.332 +  have "k = (k - 1) + 1" by simp
   6.333 +  then show "\<exists>l. k = l + 1" ..
   6.334 +qed
   6.335  
   6.336 -lemma even_int_iff:
   6.337 +lemma even_int_iff [simp]:
   6.338    "even (int n) \<longleftrightarrow> even n"
   6.339    by (simp add: dvd_int_iff)
   6.340  
   6.341 @@ -255,11 +222,8 @@
   6.342    "0 \<le> k \<Longrightarrow> even (nat k) \<longleftrightarrow> even k"
   6.343    by (simp add: even_int_iff [symmetric])
   6.344  
   6.345 -lemma even_num_iff:
   6.346 -  "0 < n \<Longrightarrow> even n = odd (n - 1 :: nat)"
   6.347 -  by simp
   6.348  
   6.349 -text {* Parity and powers *}
   6.350 +subsection {* Parity and powers *}
   6.351  
   6.352  context comm_ring_1
   6.353  begin
   6.354 @@ -272,10 +236,6 @@
   6.355    "odd n \<Longrightarrow> (- a) ^ n = - (a ^ n)"
   6.356    by (auto elim: oddE)
   6.357  
   6.358 -lemma neg_power_if:
   6.359 -  "(- a) ^ n = (if even n then a ^ n else - (a ^ n))"
   6.360 -  by simp
   6.361 -
   6.362  lemma neg_one_even_power [simp]:
   6.363    "even n \<Longrightarrow> (- 1) ^ n = 1"
   6.364    by simp
   6.365 @@ -286,28 +246,9 @@
   6.366  
   6.367  end  
   6.368  
   6.369 -lemma zero_less_power_nat_eq_numeral [simp]: -- \<open>FIXME move\<close>
   6.370 -  "0 < (n :: nat) ^ numeral w \<longleftrightarrow> 0 < n \<or> numeral w = (0 :: nat)"
   6.371 -  by (fact nat_zero_less_power_iff)
   6.372 -
   6.373  context linordered_idom
   6.374  begin
   6.375  
   6.376 -lemma power_eq_0_iff' [simp]: -- \<open>FIXME move\<close>
   6.377 -  "a ^ n = 0 \<longleftrightarrow> a = 0 \<and> n > 0"
   6.378 -  by (induct n) auto
   6.379 -
   6.380 -lemma power2_less_eq_zero_iff [simp]: -- \<open>FIXME move\<close>
   6.381 -  "a\<^sup>2 \<le> 0 \<longleftrightarrow> a = 0"
   6.382 -proof (cases "a = 0")
   6.383 -  case True then show ?thesis by simp
   6.384 -next
   6.385 -  case False then have "a < 0 \<or> a > 0" by auto
   6.386 -  then have "a\<^sup>2 > 0" by auto
   6.387 -  then have "\<not> a\<^sup>2 \<le> 0" by (simp add: not_le)
   6.388 -  with False show ?thesis by simp
   6.389 -qed
   6.390 -
   6.391  lemma zero_le_even_power:
   6.392    "even n \<Longrightarrow> 0 \<le> a ^ n"
   6.393    by (auto elim: evenE)
   6.394 @@ -316,35 +257,20 @@
   6.395    "odd n \<Longrightarrow> 0 \<le> a ^ n \<longleftrightarrow> 0 \<le> a"
   6.396    by (auto simp add: power_even_eq zero_le_mult_iff elim: oddE)
   6.397  
   6.398 -lemma zero_le_power_iff: -- \<open>FIXME cf. @{text zero_le_power_eq}\<close>
   6.399 -  "0 \<le> a ^ n \<longleftrightarrow> 0 \<le> a \<or> even n"
   6.400 -proof (cases "even n")
   6.401 -  case True
   6.402 -  then obtain k where "n = 2 * k" ..
   6.403 -  then show ?thesis by simp
   6.404 -next
   6.405 -  case False
   6.406 -  then obtain k where "n = 2 * k + 1" ..
   6.407 -  moreover have "a ^ (2 * k) \<le> 0 \<Longrightarrow> a = 0"
   6.408 -    by (induct k) (auto simp add: zero_le_mult_iff mult_le_0_iff)
   6.409 -  ultimately show ?thesis
   6.410 -    by (auto simp add: zero_le_mult_iff zero_le_even_power)
   6.411 -qed
   6.412 -
   6.413  lemma zero_le_power_eq:
   6.414    "0 \<le> a ^ n \<longleftrightarrow> even n \<or> odd n \<and> 0 \<le> a"
   6.415 -  using zero_le_power_iff [of a n] by auto
   6.416 -
   6.417 +  by (auto simp add: zero_le_even_power zero_le_odd_power)
   6.418 +  
   6.419  lemma zero_less_power_eq:
   6.420    "0 < a ^ n \<longleftrightarrow> n = 0 \<or> even n \<and> a \<noteq> 0 \<or> odd n \<and> 0 < a"
   6.421  proof -
   6.422    have [simp]: "0 = a ^ n \<longleftrightarrow> a = 0 \<and> n > 0"
   6.423 -    unfolding power_eq_0_iff' [of a n, symmetric] by blast
   6.424 +    unfolding power_eq_0_iff [of a n, symmetric] by blast
   6.425    show ?thesis
   6.426    unfolding less_le zero_le_power_eq by auto
   6.427  qed
   6.428  
   6.429 -lemma power_less_zero_eq:
   6.430 +lemma power_less_zero_eq [simp]:
   6.431    "a ^ n < 0 \<longleftrightarrow> odd n \<and> a < 0"
   6.432    unfolding not_le [symmetric] zero_le_power_eq by auto
   6.433    
   6.434 @@ -408,10 +334,6 @@
   6.435    "a ^ numeral w < 0 \<longleftrightarrow> odd (numeral w :: nat) \<and> a < 0"
   6.436    by (fact power_less_zero_eq)
   6.437  
   6.438 -lemma power_eq_0_iff_numeral [simp]:
   6.439 -  "a ^ numeral w = (0 :: nat) \<longleftrightarrow> a = 0 \<and> numeral w \<noteq> (0 :: nat)"
   6.440 -  by (fact power_eq_0_iff)
   6.441 -
   6.442  lemma power_even_abs_numeral [simp]:
   6.443    "even (numeral w :: nat) \<Longrightarrow> \<bar>a\<bar> ^ numeral w = a ^ numeral w"
   6.444    by (fact power_even_abs)
     7.1 --- a/src/HOL/Power.thy	Sat Oct 25 19:20:28 2014 +0200
     7.2 +++ b/src/HOL/Power.thy	Sun Oct 26 19:11:16 2014 +0100
     7.3 @@ -244,9 +244,18 @@
     7.4  
     7.5  end
     7.6  
     7.7 +lemma power_eq_0_nat_iff [simp]:
     7.8 +  fixes m n :: nat
     7.9 +  shows "m ^ n = 0 \<longleftrightarrow> m = 0 \<and> n > 0"
    7.10 +  by (induct n) auto
    7.11 +
    7.12  context ring_1_no_zero_divisors
    7.13  begin
    7.14  
    7.15 +lemma power_eq_0_iff [simp]:
    7.16 +  "a ^ n = 0 \<longleftrightarrow> a = 0 \<and> n > 0"
    7.17 +  by (induct n) auto
    7.18 +
    7.19  lemma field_power_not_zero:
    7.20    "a \<noteq> 0 \<Longrightarrow> a ^ n \<noteq> 0"
    7.21    by (induct n) auto
    7.22 @@ -559,6 +568,10 @@
    7.23    "\<not> a\<^sup>2 < 0"
    7.24    by (force simp add: power2_eq_square mult_less_0_iff)
    7.25  
    7.26 +lemma power2_less_eq_zero_iff [simp]:
    7.27 +  "a\<^sup>2 \<le> 0 \<longleftrightarrow> a = 0"
    7.28 +  by (simp add: le_less)
    7.29 +
    7.30  lemma abs_power2 [simp]:
    7.31    "abs (a\<^sup>2) = a\<^sup>2"
    7.32    by (simp add: power2_eq_square abs_mult abs_mult_self)
    7.33 @@ -631,15 +644,13 @@
    7.34  lemma power_eq_if: "p ^ m = (if m=0 then 1 else p * (p ^ (m - 1)))"
    7.35    unfolding One_nat_def by (cases m) simp_all
    7.36  
    7.37 -lemma power2_sum:
    7.38 -  fixes x y :: "'a::comm_semiring_1"
    7.39 -  shows "(x + y)\<^sup>2 = x\<^sup>2 + y\<^sup>2 + 2 * x * y"
    7.40 +lemma (in comm_semiring_1) power2_sum:
    7.41 +  "(x + y)\<^sup>2 = x\<^sup>2 + y\<^sup>2 + 2 * x * y"
    7.42    by (simp add: algebra_simps power2_eq_square mult_2_right)
    7.43  
    7.44 -lemma power2_diff:
    7.45 -  fixes x y :: "'a::comm_ring_1"
    7.46 -  shows "(x - y)\<^sup>2 = x\<^sup>2 + y\<^sup>2 - 2 * x * y"
    7.47 -  by (simp add: ring_distribs power2_eq_square mult_2) (rule mult.commute)
    7.48 +lemma (in comm_ring_1) power2_diff:
    7.49 +  "(x - y)\<^sup>2 = x\<^sup>2 + y\<^sup>2 - 2 * x * y"
    7.50 +  by (simp add: algebra_simps power2_eq_square mult_2_right)
    7.51  
    7.52  lemma power_0_Suc [simp]:
    7.53    "(0::'a::{power, semiring_0}) ^ Suc n = 0"
    7.54 @@ -650,12 +661,6 @@
    7.55    "0 ^ n = (if n = 0 then 1 else (0::'a::{power, semiring_0}))"
    7.56    by (induct n) simp_all
    7.57  
    7.58 -lemma power_eq_0_iff [simp]:
    7.59 -  "a ^ n = 0 \<longleftrightarrow>
    7.60 -     a = (0::'a::{mult_zero,zero_neq_one,no_zero_divisors,power}) \<and> n \<noteq> 0"
    7.61 -  by (induct n)
    7.62 -    (auto simp add: no_zero_divisors elim: contrapos_pp)
    7.63 -
    7.64  lemma (in field) power_diff:
    7.65    assumes nz: "a \<noteq> 0"
    7.66    shows "n \<le> m \<Longrightarrow> a ^ (m - n) = a ^ m / a ^ n"
     8.1 --- a/src/HOL/Presburger.thy	Sat Oct 25 19:20:28 2014 +0200
     8.2 +++ b/src/HOL/Presburger.thy	Sun Oct 26 19:11:16 2014 +0100
     8.3 @@ -457,8 +457,6 @@
     8.4  context linordered_idom
     8.5  begin
     8.6  
     8.7 -declare zero_le_power_iff [presburger]
     8.8 -
     8.9  declare zero_le_power_eq [presburger]
    8.10  
    8.11  declare zero_less_power_eq [presburger]
     9.1 --- a/src/HOL/Probability/Lebesgue_Measure.thy	Sat Oct 25 19:20:28 2014 +0200
     9.2 +++ b/src/HOL/Probability/Lebesgue_Measure.thy	Sun Oct 26 19:11:16 2014 +0100
     9.3 @@ -425,8 +425,8 @@
     9.4  qed
     9.5  
     9.6  lemma AE_lborel_singleton: "AE x in lborel::'a::euclidean_space measure. x \<noteq> c"
     9.7 -  using AE_discrete_difference[of "{c::'a}" lborel] emeasure_lborel_cbox[of c c]
     9.8 -  by (auto simp del: emeasure_lborel_cbox simp add: cbox_sing setprod_constant)
     9.9 +  using SOME_Basis AE_discrete_difference [of "{c}" lborel]
    9.10 +    emeasure_lborel_cbox [of c c] by (auto simp add: cbox_sing)
    9.11  
    9.12  lemma emeasure_lborel_Ioo[simp]:
    9.13    assumes [simp]: "l \<le> u"