src/HOL/Groups_Big.thy
changeset 65680 378a2f11bec9
parent 64979 20a623d03d71
child 65687 a68973661472
equal deleted inserted replaced
65677:7d25b8dbdbfa 65680:378a2f11bec9
   673   by (induct A rule: infinite_finite_induct) (auto simp: sum_mono)
   673   by (induct A rule: infinite_finite_induct) (auto simp: sum_mono)
   674 
   674 
   675 context ordered_comm_monoid_add
   675 context ordered_comm_monoid_add
   676 begin
   676 begin
   677 
   677 
   678 lemma sum_nonneg: "\<forall>x\<in>A. 0 \<le> f x \<Longrightarrow> 0 \<le> sum f A"
   678 lemma sum_nonneg: "(\<And>x. x \<in> A \<Longrightarrow> 0 \<le> f x) \<Longrightarrow> 0 \<le> sum f A"
   679 proof (induct A rule: infinite_finite_induct)
   679 proof (induct A rule: infinite_finite_induct)
   680   case infinite
   680   case infinite
   681   then show ?case by simp
   681   then show ?case by simp
   682 next
   682 next
   683   case empty
   683   case empty
   686   case (insert x F)
   686   case (insert x F)
   687   then have "0 + 0 \<le> f x + sum f F" by (blast intro: add_mono)
   687   then have "0 + 0 \<le> f x + sum f F" by (blast intro: add_mono)
   688   with insert show ?case by simp
   688   with insert show ?case by simp
   689 qed
   689 qed
   690 
   690 
   691 lemma sum_nonpos: "\<forall>x\<in>A. f x \<le> 0 \<Longrightarrow> sum f A \<le> 0"
   691 lemma sum_nonpos: "(\<And>x. x \<in> A \<Longrightarrow> f x \<le> 0) \<Longrightarrow> sum f A \<le> 0"
   692 proof (induct A rule: infinite_finite_induct)
   692 proof (induct A rule: infinite_finite_induct)
   693   case infinite
   693   case infinite
   694   then show ?case by simp
   694   then show ?case by simp
   695 next
   695 next
   696   case empty
   696   case empty
   700   then have "f x + sum f F \<le> 0 + 0" by (blast intro: add_mono)
   700   then have "f x + sum f F \<le> 0 + 0" by (blast intro: add_mono)
   701   with insert show ?case by simp
   701   with insert show ?case by simp
   702 qed
   702 qed
   703 
   703 
   704 lemma sum_nonneg_eq_0_iff:
   704 lemma sum_nonneg_eq_0_iff:
   705   "finite A \<Longrightarrow> \<forall>x\<in>A. 0 \<le> f x \<Longrightarrow> sum f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
   705   "finite A \<Longrightarrow> (\<And>x. x \<in> A \<Longrightarrow> 0 \<le> f x) \<Longrightarrow> sum f A = 0 \<longleftrightarrow> (\<forall>x\<in>A. f x = 0)"
   706   by (induct set: finite) (simp_all add: add_nonneg_eq_0_iff sum_nonneg)
   706   by (induct set: finite) (simp_all add: add_nonneg_eq_0_iff sum_nonneg)
   707 
   707 
   708 lemma sum_nonneg_0:
   708 lemma sum_nonneg_0:
   709   "finite s \<Longrightarrow> (\<And>i. i \<in> s \<Longrightarrow> f i \<ge> 0) \<Longrightarrow> (\<Sum> i \<in> s. f i) = 0 \<Longrightarrow> i \<in> s \<Longrightarrow> f i = 0"
   709   "finite s \<Longrightarrow> (\<And>i. i \<in> s \<Longrightarrow> f i \<ge> 0) \<Longrightarrow> (\<Sum> i \<in> s. f i) = 0 \<Longrightarrow> i \<in> s \<Longrightarrow> f i = 0"
   710   by (simp add: sum_nonneg_eq_0_iff)
   710   by (simp add: sum_nonneg_eq_0_iff)
   725     and sub: "A \<subseteq> B"
   725     and sub: "A \<subseteq> B"
   726     and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b"
   726     and nn: "\<And>b. b \<in> B-A \<Longrightarrow> 0 \<le> f b"
   727   shows "sum f A \<le> sum f B"
   727   shows "sum f A \<le> sum f B"
   728 proof -
   728 proof -
   729   have "sum f A \<le> sum f A + sum f (B-A)"
   729   have "sum f A \<le> sum f A + sum f (B-A)"
   730     by(simp add: add_increasing2[OF sum_nonneg] nn Ball_def)
   730     by (auto intro: add_increasing2 [OF sum_nonneg] nn)
   731   also from fin finite_subset[OF sub fin] have "\<dots> = sum f (A \<union> (B-A))"
   731   also from fin finite_subset[OF sub fin] have "\<dots> = sum f (A \<union> (B-A))"
   732     by (simp add: sum.union_disjoint del: Un_Diff_cancel)
   732     by (simp add: sum.union_disjoint del: Un_Diff_cancel)
   733   also from sub have "A \<union> (B-A) = B" by blast
   733   also from sub have "A \<union> (B-A) = B" by blast
   734   finally show ?thesis .
   734   finally show ?thesis .
   735 qed
   735 qed
   752     using assms(2-4) by (auto intro!: sum_mono2 sum_nonneg)
   752     using assms(2-4) by (auto intro!: sum_mono2 sum_nonneg)
   753   also have "\<dots> \<le> sum g t"
   753   also have "\<dots> \<le> sum g t"
   754     using assms by (auto simp: sum_image_gen[symmetric])
   754     using assms by (auto simp: sum_image_gen[symmetric])
   755   finally show ?thesis .
   755   finally show ?thesis .
   756 qed
   756 qed
   757 
       
   758 lemma sum_mono3: "finite B \<Longrightarrow> A \<subseteq> B \<Longrightarrow> \<forall>x\<in>B - A. 0 \<le> f x \<Longrightarrow> sum f A \<le> sum f B"
       
   759   by (rule sum_mono2) auto
       
   760 
   757 
   761 end
   758 end
   762 
   759 
   763 lemma (in canonically_ordered_monoid_add) sum_eq_0_iff [simp]:
   760 lemma (in canonically_ordered_monoid_add) sum_eq_0_iff [simp]:
   764   "finite F \<Longrightarrow> (sum f F = 0) = (\<forall>a\<in>F. f a = 0)"
   761   "finite F \<Longrightarrow> (sum f F = 0) = (\<forall>a\<in>F. f a = 0)"
  1208 lemma sum_zero_power' [simp]:
  1205 lemma sum_zero_power' [simp]:
  1209   "(\<Sum>i\<in>A. c i * 0^i / d i) = (if finite A \<and> 0 \<in> A then c 0 / d 0 else 0)"
  1206   "(\<Sum>i\<in>A. c i * 0^i / d i) = (if finite A \<and> 0 \<in> A then c 0 / d 0 else 0)"
  1210   for c :: "nat \<Rightarrow> 'a::field"
  1207   for c :: "nat \<Rightarrow> 'a::field"
  1211   using sum_zero_power [of "\<lambda>i. c i / d i" A] by auto
  1208   using sum_zero_power [of "\<lambda>i. c i / d i" A] by auto
  1212 
  1209 
  1213 lemma (in field) prod_inversef:
  1210 lemma (in field) prod_inversef: "prod (inverse \<circ> f) A = inverse (prod f A)"
  1214   "finite A \<Longrightarrow> prod (inverse \<circ> f) A = inverse (prod f A)"
  1211  proof (cases "finite A")
  1215   by (induct A rule: finite_induct) simp_all
  1212    case True
  1216 
  1213    then show ?thesis
  1217 lemma (in field) prod_dividef: "finite A \<Longrightarrow> (\<Prod>x\<in>A. f x / g x) = prod f A / prod g A"
  1214      by (induct A rule: finite_induct) simp_all
  1218   using prod_inversef [of A g] by (simp add: divide_inverse prod.distrib)
  1215  next
       
  1216    case False
       
  1217    then show ?thesis
       
  1218      by auto
       
  1219  qed
       
  1220 
       
  1221 lemma (in field) prod_dividef: "(\<Prod>x\<in>A. f x / g x) = prod f A / prod g A"
       
  1222   using prod_inversef [of g A] by (simp add: divide_inverse prod.distrib)
  1219 
  1223 
  1220 lemma prod_Un:
  1224 lemma prod_Un:
  1221   fixes f :: "'b \<Rightarrow> 'a :: field"
  1225   fixes f :: "'b \<Rightarrow> 'a :: field"
  1222   assumes "finite A" and "finite B"
  1226   assumes "finite A" and "finite B"
  1223     and "\<forall>x\<in>A \<inter> B. f x \<noteq> 0"
  1227     and "\<forall>x\<in>A \<inter> B. f x \<noteq> 0"