src/HOL/Groups_Big.thy
changeset 69144 f13b82281715
parent 69127 4596b580d1dd
child 69164 74f1b0f10b2b
equal deleted inserted replaced
69143:5acb1eece41b 69144:f13b82281715
   972 next
   972 next
   973   case False
   973   case False
   974   then show ?thesis by simp
   974   then show ?thesis by simp
   975 qed
   975 qed
   976 
   976 
       
   977 lemma sum_bounded_above_divide:
       
   978   fixes K :: "'a::linordered_field"
       
   979   assumes le: "\<And>i. i\<in>A \<Longrightarrow> f i \<le> K / of_nat (card A)" and fin: "finite A" "A \<noteq> {}"
       
   980   shows "sum f A \<le> K"
       
   981   using sum_bounded_above [of A f "K / of_nat (card A)", OF le] fin by simp
       
   982 
   977 lemma sum_bounded_above_strict:
   983 lemma sum_bounded_above_strict:
   978   fixes K :: "'a::{ordered_cancel_comm_monoid_add,semiring_1}"
   984   fixes K :: "'a::{ordered_cancel_comm_monoid_add,semiring_1}"
   979   assumes "\<And>i. i\<in>A \<Longrightarrow> f i < K" "card A > 0"
   985   assumes "\<And>i. i\<in>A \<Longrightarrow> f i < K" "card A > 0"
   980   shows "sum f A < of_nat (card A) * K"
   986   shows "sum f A < of_nat (card A) * K"
   981   using assms sum_strict_mono[where A=A and g = "\<lambda>x. K"]
   987   using assms sum_strict_mono[where A=A and g = "\<lambda>x. K"]
   990   then show ?thesis
   996   then show ?thesis
   991     using le sum_mono[where K=A and f = "\<lambda>x. K"] by simp
   997     using le sum_mono[where K=A and f = "\<lambda>x. K"] by simp
   992 next
   998 next
   993   case False
   999   case False
   994   then show ?thesis by simp
  1000   then show ?thesis by simp
       
  1001 qed
       
  1002 
       
  1003 lemma convex_sum_bound_le:
       
  1004   fixes x :: "'a \<Rightarrow> 'b::linordered_idom"
       
  1005   assumes 0: "\<And>i. i \<in> I \<Longrightarrow> 0 \<le> x i" and 1: "sum x I = 1"
       
  1006       and \<delta>: "\<And>i. i \<in> I \<Longrightarrow> \<bar>a i - b\<bar> \<le> \<delta>"
       
  1007     shows "\<bar>(\<Sum>i\<in>I. a i * x i) - b\<bar> \<le> \<delta>"
       
  1008 proof -
       
  1009   have [simp]: "(\<Sum>i\<in>I. c * x i) = c" for c
       
  1010     by (simp flip: sum_distrib_left 1)
       
  1011   then have "\<bar>(\<Sum>i\<in>I. a i * x i) - b\<bar> = \<bar>\<Sum>i\<in>I. (a i - b) * x i\<bar>"
       
  1012     by (simp add: sum_subtractf left_diff_distrib)
       
  1013   also have "\<dots> \<le> (\<Sum>i\<in>I. \<bar>(a i - b) * x i\<bar>)"
       
  1014     using abs_abs abs_of_nonneg by blast
       
  1015   also have "\<dots> \<le> (\<Sum>i\<in>I. \<bar>(a i - b)\<bar> * x i)"
       
  1016     by (simp add: abs_mult 0)
       
  1017   also have "\<dots> \<le> (\<Sum>i\<in>I. \<delta> * x i)"
       
  1018     by (rule sum_mono) (use \<delta> "0" mult_right_mono in blast)
       
  1019   also have "\<dots> = \<delta>"
       
  1020     by simp
       
  1021   finally show ?thesis .
   995 qed
  1022 qed
   996 
  1023 
   997 lemma card_UN_disjoint:
  1024 lemma card_UN_disjoint:
   998   assumes "finite I" and "\<forall>i\<in>I. finite (A i)"
  1025   assumes "finite I" and "\<forall>i\<in>I. finite (A i)"
   999     and "\<forall>i\<in>I. \<forall>j\<in>I. i \<noteq> j \<longrightarrow> A i \<inter> A j = {}"
  1026     and "\<forall>i\<in>I. \<forall>j\<in>I. i \<noteq> j \<longrightarrow> A i \<inter> A j = {}"