762 subsection{*More Properties of @{term setsum} and @{term setprod}*} |
762 subsection{*More Properties of @{term setsum} and @{term setprod}*} |
763 |
763 |
764 text{*By Jeremy Avigad*} |
764 text{*By Jeremy Avigad*} |
765 |
765 |
766 |
766 |
767 lemma setsum_of_nat: "of_nat (setsum f A) = setsum (of_nat \<circ> f) A" |
767 lemma of_nat_setsum: "of_nat (setsum f A) = (\<Sum>x\<in>A. of_nat(f x))" |
768 apply (case_tac "finite A") |
768 apply (case_tac "finite A") |
769 apply (erule finite_induct, auto) |
769 apply (erule finite_induct, auto) |
770 done |
770 done |
771 |
771 |
772 lemma setsum_of_int: "of_int (setsum f A) = setsum (of_int \<circ> f) A" |
772 lemma of_int_setsum: "of_int (setsum f A) = (\<Sum>x\<in>A. of_int(f x))" |
773 apply (case_tac "finite A") |
773 apply (case_tac "finite A") |
774 apply (erule finite_induct, auto) |
774 apply (erule finite_induct, auto) |
775 done |
775 done |
776 |
776 |
777 lemma int_setsum: "int (setsum f A) = setsum (int \<circ> f) A" |
777 lemma int_setsum: "int (setsum f A) = (\<Sum>x\<in>A. int(f x))" |
778 by (simp add: int_eq_of_nat setsum_of_nat) |
778 by (simp add: int_eq_of_nat of_nat_setsum) |
779 |
779 |
780 lemma setprod_of_nat: "of_nat (setprod f A) = setprod (of_nat \<circ> f) A" |
780 lemma of_nat_setprod: "of_nat (setprod f A) = (\<Prod>x\<in>A. of_nat(f x))" |
781 apply (case_tac "finite A") |
781 apply (case_tac "finite A") |
782 apply (erule finite_induct, auto) |
782 apply (erule finite_induct, auto) |
783 done |
783 done |
784 |
784 |
785 lemma setprod_of_int: "of_int (setprod f A) = setprod (of_int \<circ> f) A" |
785 lemma of_int_setprod: "of_int (setprod f A) = (\<Prod>x\<in>A. of_int(f x))" |
786 apply (case_tac "finite A") |
786 apply (case_tac "finite A") |
787 apply (erule finite_induct, auto) |
787 apply (erule finite_induct, auto) |
788 done |
788 done |
789 |
789 |
790 lemma int_setprod: "int (setprod f A) = setprod (int \<circ> f) A" |
790 lemma int_setprod: "int (setprod f A) = (\<Prod>x\<in>A. int(f x))" |
791 by (simp add: int_eq_of_nat setprod_of_nat) |
791 by (simp add: int_eq_of_nat of_nat_setprod) |
792 |
792 |
793 lemma setprod_nonzero_nat: |
793 lemma setprod_nonzero_nat: |
794 "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::nat)) ==> setprod f A \<noteq> 0" |
794 "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::nat)) ==> setprod f A \<noteq> 0" |
795 by (rule setprod_nonzero, auto) |
795 by (rule setprod_nonzero, auto) |
796 |
796 |