src/HOL/Set_Interval.thy
changeset 70340 7383930fc946
parent 70113 c8deb8ba6d05
child 70365 4df0628e8545
equal deleted inserted replaced
70339:e939ea997f5f 70340:7383930fc946
  2011 
  2011 
  2012 lemma sum_diff_distrib: "\<forall>x. Q x \<le> P x  \<Longrightarrow> (\<Sum>x<n. P x) - (\<Sum>x<n. Q x) = (\<Sum>x<n. P x - Q x :: nat)"
  2012 lemma sum_diff_distrib: "\<forall>x. Q x \<le> P x  \<Longrightarrow> (\<Sum>x<n. P x) - (\<Sum>x<n. Q x) = (\<Sum>x<n. P x - Q x :: nat)"
  2013   by (subst sum_subtractf_nat) auto
  2013   by (subst sum_subtractf_nat) auto
  2014 
  2014 
  2015 
  2015 
  2016 context semiring_parity
  2016 context unique_euclidean_semiring_with_nat
  2017 begin
  2017 begin
  2018 
  2018 
  2019 lemma take_bit_sum:
  2019 lemma take_bit_sum:
  2020   "take_bit n a = (\<Sum>k = 0..<n. push_bit k (of_bool (odd (drop_bit k a))))"
  2020   "take_bit n a = (\<Sum>k = 0..<n. push_bit k (of_bool (odd (drop_bit k a))))"
  2021   for n :: nat
  2021   for n :: nat
  2270     by (simp add: algebra_simps double_gauss_sum left_add_twice)
  2270     by (simp add: algebra_simps double_gauss_sum left_add_twice)
  2271 qed
  2271 qed
  2272 
  2272 
  2273 end
  2273 end
  2274 
  2274 
  2275 context semiring_parity
  2275 context unique_euclidean_semiring_with_nat
  2276 begin
  2276 begin
  2277 
  2277 
  2278 lemma gauss_sum:
  2278 lemma gauss_sum:
  2279   "(\<Sum>i = 0..n. of_nat i) = of_nat n * (of_nat n + 1) div 2"
  2279   "(\<Sum>i = 0..n. of_nat i) = of_nat n * (of_nat n + 1) div 2"
  2280   using double_gauss_sum [of n, symmetric] by simp
  2280   using double_gauss_sum [of n, symmetric] by simp