src/HOL/Algebra/FiniteProduct.thy
changeset 70044 da5857dbcbb9
parent 69895 6b03a8cf092d
equal deleted inserted replaced
70043:350acd367028 70044:da5857dbcbb9
   545   using i_in_A finprod_insert [of "A - {i}" i "(\<lambda>j. if i = j then f j else \<one>)"]
   545   using i_in_A finprod_insert [of "A - {i}" i "(\<lambda>j. if i = j then f j else \<one>)"]
   546     fin_A f_Pi finprod_one [of "A - {i}"]
   546     fin_A f_Pi finprod_one [of "A - {i}"]
   547     finprod_cong [of "A - {i}" "A - {i}" "(\<lambda>j. if i = j then f j else \<one>)" "(\<lambda>i. \<one>)"]
   547     finprod_cong [of "A - {i}" "A - {i}" "(\<lambda>j. if i = j then f j else \<one>)" "(\<lambda>i. \<one>)"]
   548   unfolding Pi_def simp_implies_def by (force simp add: insert_absorb)
   548   unfolding Pi_def simp_implies_def by (force simp add: insert_absorb)
   549 
   549 
       
   550 lemma finprod_singleton_swap:
       
   551   assumes i_in_A: "i \<in> A" and fin_A: "finite A" and f_Pi: "f \<in> A \<rightarrow> carrier G"
       
   552   shows "(\<Otimes>j\<in>A. if j = i then f j else \<one>) = f i"
       
   553   using finprod_singleton [OF assms] by (simp add: eq_commute)
       
   554 
       
   555 lemma finprod_mono_neutral_cong_left:
       
   556   assumes "finite B"
       
   557     and "A \<subseteq> B"
       
   558     and 1: "\<And>i. i \<in> B - A \<Longrightarrow> h i = \<one>"
       
   559     and gh: "\<And>x. x \<in> A \<Longrightarrow> g x = h x"
       
   560     and h: "h \<in> B \<rightarrow> carrier G"
       
   561   shows "finprod G g A = finprod G h B"
       
   562 proof-
       
   563   have eq: "A \<union> (B - A) = B" using \<open>A \<subseteq> B\<close> by blast
       
   564   have d: "A \<inter> (B - A) = {}" using \<open>A \<subseteq> B\<close> by blast
       
   565   from \<open>finite B\<close> \<open>A \<subseteq> B\<close> have f: "finite A" "finite (B - A)"
       
   566     by (auto intro: finite_subset)
       
   567   have "h \<in> A \<rightarrow> carrier G" "h \<in> B - A \<rightarrow> carrier G"
       
   568     using assms by (auto simp: image_subset_iff_funcset)
       
   569   moreover have "finprod G g A = finprod G h A \<otimes> finprod G h (B - A)"
       
   570   proof -
       
   571     have "finprod G h (B - A) = \<one>"
       
   572       using "1" finprod_one_eqI by blast
       
   573     moreover have "finprod G g A = finprod G h A"
       
   574       using \<open>h \<in> A \<rightarrow> carrier G\<close> finprod_cong' gh by blast
       
   575     ultimately show ?thesis
       
   576       by (simp add: \<open>h \<in> A \<rightarrow> carrier G\<close>)
       
   577   qed
       
   578   ultimately show ?thesis
       
   579     by (simp add: finprod_Un_disjoint [OF f d, unfolded eq])
       
   580 qed
       
   581 
       
   582 lemma finprod_mono_neutral_cong_right:
       
   583   assumes "finite B"
       
   584     and "A \<subseteq> B" "\<And>i. i \<in> B - A \<Longrightarrow> g i = \<one>" "\<And>x. x \<in> A \<Longrightarrow> g x = h x" "g \<in> B \<rightarrow> carrier G"
       
   585   shows "finprod G g B = finprod G h A"
       
   586   using assms  by (auto intro!: finprod_mono_neutral_cong_left [symmetric])
       
   587 
       
   588 lemma finprod_mono_neutral_cong:
       
   589   assumes [simp]: "finite B" "finite A"
       
   590     and *: "\<And>i. i \<in> B - A \<Longrightarrow> h i = \<one>" "\<And>i. i \<in> A - B \<Longrightarrow> g i = \<one>"
       
   591     and gh: "\<And>x. x \<in> A \<inter> B \<Longrightarrow> g x = h x"
       
   592     and g: "g \<in> A \<rightarrow> carrier G"
       
   593     and h: "h \<in> B \<rightarrow> carrier G"
       
   594  shows "finprod G g A = finprod G h B"
       
   595 proof-
       
   596   have "finprod G g A = finprod G g (A \<inter> B)"
       
   597     by (rule finprod_mono_neutral_cong_right) (use assms in auto)
       
   598   also have "\<dots> = finprod G h (A \<inter> B)"
       
   599     by (rule finprod_cong) (use assms in auto)
       
   600   also have "\<dots> = finprod G h B"
       
   601     by (rule finprod_mono_neutral_cong_left) (use assms in auto)
       
   602   finally show ?thesis .
       
   603 qed
       
   604 
   550 end
   605 end
   551 
   606 
   552 (* Jeremy Avigad. This should be generalized to arbitrary groups, not just commutative
   607 (* Jeremy Avigad. This should be generalized to arbitrary groups, not just commutative
   553    ones, using Lagrange's theorem. *)
   608    ones, using Lagrange's theorem. *)
   554 
   609