src/HOL/Power.thy
changeset 57418 6ab1c7cb0b8d
parent 56544 b60d5d119489
child 57512 cc97b347b301
equal deleted inserted replaced
57417:29fe9bac501b 57418:6ab1c7cb0b8d
   759     apply (simp add: Pow_insert)
   759     apply (simp add: Pow_insert)
   760     apply (subst card_Un_disjoint, auto)
   760     apply (subst card_Un_disjoint, auto)
   761     done
   761     done
   762 qed
   762 qed
   763 
   763 
       
   764 
       
   765 subsubsection {* Generalized sum over a set *}
       
   766 
       
   767 lemma setsum_zero_power [simp]:
       
   768   fixes c :: "nat \<Rightarrow> 'a::division_ring"
       
   769   shows "(\<Sum>i\<in>A. c i * 0^i) = (if finite A \<and> 0 \<in> A then c 0 else 0)"
       
   770 apply (cases "finite A")
       
   771   by (induction A rule: finite_induct) auto
       
   772 
       
   773 lemma setsum_zero_power' [simp]:
       
   774   fixes c :: "nat \<Rightarrow> 'a::field"
       
   775   shows "(\<Sum>i\<in>A. c i * 0^i / d i) = (if finite A \<and> 0 \<in> A then c 0 / d 0 else 0)"
       
   776   using setsum_zero_power [of "\<lambda>i. c i / d i" A]
       
   777   by auto
       
   778 
       
   779 
   764 subsubsection {* Generalized product over a set *}
   780 subsubsection {* Generalized product over a set *}
   765 
   781 
   766 lemma setprod_constant: "finite A ==> (\<Prod>x\<in> A. (y::'a::{comm_monoid_mult})) = y^(card A)"
   782 lemma setprod_constant: "finite A ==> (\<Prod>x\<in> A. (y::'a::{comm_monoid_mult})) = y^(card A)"
   767 apply (erule finite_induct)
   783 apply (erule finite_induct)
   768 apply auto
   784 apply auto
   769 done
   785 done
       
   786 
       
   787 lemma setprod_power_distrib:
       
   788   fixes f :: "'a \<Rightarrow> 'b::comm_semiring_1"
       
   789   shows "setprod f A ^ n = setprod (\<lambda>x. (f x) ^ n) A"
       
   790 proof (cases "finite A") 
       
   791   case True then show ?thesis 
       
   792     by (induct A rule: finite_induct) (auto simp add: power_mult_distrib)
       
   793 next
       
   794   case False then show ?thesis 
       
   795     by simp
       
   796 qed
   770 
   797 
   771 lemma setprod_gen_delta:
   798 lemma setprod_gen_delta:
   772   assumes fS: "finite S"
   799   assumes fS: "finite S"
   773   shows "setprod (\<lambda>k. if k=a then b k else c) S = (if a \<in> S then (b a ::'a::comm_monoid_mult) * c^ (card S - 1) else c^ card S)"
   800   shows "setprod (\<lambda>k. if k=a then b k else c) S = (if a \<in> S then (b a ::'a::comm_monoid_mult) * c^ (card S - 1) else c^ card S)"
   774 proof-
   801 proof-
   782     let ?B = "{a}"
   809     let ?B = "{a}"
   783     have eq: "S = ?A \<union> ?B" using a by blast 
   810     have eq: "S = ?A \<union> ?B" using a by blast 
   784     have dj: "?A \<inter> ?B = {}" by simp
   811     have dj: "?A \<inter> ?B = {}" by simp
   785     from fS have fAB: "finite ?A" "finite ?B" by auto  
   812     from fS have fAB: "finite ?A" "finite ?B" by auto  
   786     have fA0:"setprod ?f ?A = setprod (\<lambda>i. c) ?A"
   813     have fA0:"setprod ?f ?A = setprod (\<lambda>i. c) ?A"
   787       apply (rule setprod_cong) by auto
   814       apply (rule setprod.cong) by auto
   788     have cA: "card ?A = card S - 1" using fS a by auto
   815     have cA: "card ?A = card S - 1" using fS a by auto
   789     have fA1: "setprod ?f ?A = c ^ card ?A"  unfolding fA0 apply (rule setprod_constant) using fS by auto
   816     have fA1: "setprod ?f ?A = c ^ card ?A"  unfolding fA0 apply (rule setprod_constant) using fS by auto
   790     have "setprod ?f ?A * setprod ?f ?B = setprod ?f S"
   817     have "setprod ?f ?A * setprod ?f ?B = setprod ?f S"
   791       using setprod_Un_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]]
   818       using setprod.union_disjoint[OF fAB dj, of ?f, unfolded eq[symmetric]]
   792       by simp
   819       by simp
   793     then have ?thesis using a cA
   820     then have ?thesis using a cA
   794       by (simp add: fA1 field_simps cong add: setprod_cong cong del: if_weak_cong)}
   821       by (simp add: fA1 field_simps cong add: setprod.cong cong del: if_weak_cong)}
   795   ultimately show ?thesis by blast
   822   ultimately show ?thesis by blast
   796 qed
   823 qed
   797 
   824 
   798 lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)"
   825 lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)"
   799   by auto
   826   by auto