# HG changeset patch # User paulson # Date 1554383973 -3600 # Node ID da5857dbcbb9326bc5da162e2c84281d5c7c57c4 # Parent 350acd3670285741742b3fe6c162c099abdf2c00 More group theory. Sum and product indexed by the non-neutral part of a set diff -r 350acd367028 -r da5857dbcbb9 src/HOL/Algebra/FiniteProduct.thy --- a/src/HOL/Algebra/FiniteProduct.thy Wed Apr 03 16:38:59 2019 +0100 +++ b/src/HOL/Algebra/FiniteProduct.thy Thu Apr 04 14:19:33 2019 +0100 @@ -547,6 +547,61 @@ finprod_cong [of "A - {i}" "A - {i}" "(\j. if i = j then f j else \)" "(\i. \)"] unfolding Pi_def simp_implies_def by (force simp add: insert_absorb) +lemma finprod_singleton_swap: + assumes i_in_A: "i \ A" and fin_A: "finite A" and f_Pi: "f \ A \ carrier G" + shows "(\j\A. if j = i then f j else \) = f i" + using finprod_singleton [OF assms] by (simp add: eq_commute) + +lemma finprod_mono_neutral_cong_left: + assumes "finite B" + and "A \ B" + and 1: "\i. i \ B - A \ h i = \" + and gh: "\x. x \ A \ g x = h x" + and h: "h \ B \ carrier G" + shows "finprod G g A = finprod G h B" +proof- + have eq: "A \ (B - A) = B" using \A \ B\ by blast + have d: "A \ (B - A) = {}" using \A \ B\ by blast + from \finite B\ \A \ B\ have f: "finite A" "finite (B - A)" + by (auto intro: finite_subset) + have "h \ A \ carrier G" "h \ B - A \ carrier G" + using assms by (auto simp: image_subset_iff_funcset) + moreover have "finprod G g A = finprod G h A \ finprod G h (B - A)" + proof - + have "finprod G h (B - A) = \" + using "1" finprod_one_eqI by blast + moreover have "finprod G g A = finprod G h A" + using \h \ A \ carrier G\ finprod_cong' gh by blast + ultimately show ?thesis + by (simp add: \h \ A \ carrier G\) + qed + ultimately show ?thesis + by (simp add: finprod_Un_disjoint [OF f d, unfolded eq]) +qed + +lemma finprod_mono_neutral_cong_right: + assumes "finite B" + and "A \ B" "\i. i \ B - A \ g i = \" "\x. x \ A \ g x = h x" "g \ B \ carrier G" + shows "finprod G g B = finprod G h A" + using assms by (auto intro!: finprod_mono_neutral_cong_left [symmetric]) + +lemma finprod_mono_neutral_cong: + assumes [simp]: "finite B" "finite A" + and *: "\i. i \ B - A \ h i = \" "\i. i \ A - B \ g i = \" + and gh: "\x. x \ A \ B \ g x = h x" + and g: "g \ A \ carrier G" + and h: "h \ B \ carrier G" + shows "finprod G g A = finprod G h B" +proof- + have "finprod G g A = finprod G g (A \ B)" + by (rule finprod_mono_neutral_cong_right) (use assms in auto) + also have "\ = finprod G h (A \ B)" + by (rule finprod_cong) (use assms in auto) + also have "\ = finprod G h B" + by (rule finprod_mono_neutral_cong_left) (use assms in auto) + finally show ?thesis . +qed + end (* Jeremy Avigad. This should be generalized to arbitrary groups, not just commutative diff -r 350acd367028 -r da5857dbcbb9 src/HOL/Algebra/Group.thy --- a/src/HOL/Algebra/Group.thy Wed Apr 03 16:38:59 2019 +0100 +++ b/src/HOL/Algebra/Group.thy Thu Apr 04 14:19:33 2019 +0100 @@ -9,11 +9,6 @@ imports Complete_Lattice "HOL-Library.FuncSet" begin -(*MOVE*) -lemma image_paired_Times: - "(\(x,y). (f x,g y)) ` (A \ B) = (f ` A) \ (g ` B)" - by auto - section \Monoids and Groups\ subsection \Definitions\ diff -r 350acd367028 -r da5857dbcbb9 src/HOL/Analysis/Abstract_Topology.thy --- a/src/HOL/Analysis/Abstract_Topology.thy Wed Apr 03 16:38:59 2019 +0100 +++ b/src/HOL/Analysis/Abstract_Topology.thy Thu Apr 04 14:19:33 2019 +0100 @@ -4063,7 +4063,7 @@ "openin (topology_generated_by S) s \ generate_topology_on S s" using openin_topology_generated_by_iff by auto -lemma topology_generated_by_topspace: +lemma topology_generated_by_topspace [simp]: "topspace (topology_generated_by S) = (\S)" proof { diff -r 350acd367028 -r da5857dbcbb9 src/HOL/Analysis/Elementary_Topology.thy --- a/src/HOL/Analysis/Elementary_Topology.thy Wed Apr 03 16:38:59 2019 +0100 +++ b/src/HOL/Analysis/Elementary_Topology.thy Thu Apr 04 14:19:33 2019 +0100 @@ -1459,25 +1459,6 @@ qed qed -text\Deducing things about the limit from the elements.\ - -lemma Lim_in_closed_set: - assumes "closed S" - and "eventually (\x. f(x) \ S) net" - and "\ trivial_limit net" "(f \ l) net" - shows "l \ S" -proof (rule ccontr) - assume "l \ S" - with \closed S\ have "open (- S)" "l \ - S" - by (simp_all add: open_Compl) - with assms(4) have "eventually (\x. f x \ - S) net" - by (rule topological_tendstoD) - with assms(2) have "eventually (\x. False) net" - by (rule eventually_elim2) simp - with assms(3) show "False" - by (simp add: eventually_False) -qed - text\These are special for limits out of the same topological space.\ lemma Lim_within_id: "(id \ a) (at a within s)" diff -r 350acd367028 -r da5857dbcbb9 src/HOL/Groups_Big.thy --- a/src/HOL/Groups_Big.thy Wed Apr 03 16:38:59 2019 +0100 +++ b/src/HOL/Groups_Big.thy Thu Apr 04 14:19:33 2019 +0100 @@ -16,6 +16,8 @@ locale comm_monoid_set = comm_monoid begin +subsubsection \Standard sum or product indexed by a finite set\ + interpretation comp_fun_commute f by standard (simp add: fun_eq_iff left_commute) @@ -523,6 +525,92 @@ shows "F \ A = F \ B" by (rule eq_general [where h=h]) (force intro: dest: A B)+ +subsubsection \HOL Light variant: sum/product indexed by the non-neutral subset\ +text \NB only a subset of the properties above are proved\ + +definition G :: "['b \ 'a,'b set] \ 'a" + where "G p I \ if finite {x \ I. p x \ \<^bold>1} then F p {x \ I. p x \ \<^bold>1} else \<^bold>1" + +lemma finite_Collect_op: + shows "\finite {i \ I. x i \ \<^bold>1}; finite {i \ I. y i \ \<^bold>1}\ \ finite {i \ I. x i \<^bold>* y i \ \<^bold>1}" + apply (rule finite_subset [where B = "{i \ I. x i \ \<^bold>1} \ {i \ I. y i \ \<^bold>1}"]) + using left_neutral by force+ + +lemma empty' [simp]: "G p {} = \<^bold>1" + by (auto simp: G_def) + +lemma eq_sum [simp]: "finite I \ G p I = F p I" + by (auto simp: G_def intro: mono_neutral_cong_left) + +lemma insert' [simp]: + assumes "finite {x \ I. p x \ \<^bold>1}" + shows "G p (insert i I) = (if i \ I then G p I else p i \<^bold>* G p I)" +proof - + have "{x. x = i \ p x \ \<^bold>1 \ x \ I \ p x \ \<^bold>1} = (if p i = \<^bold>1 then {x \ I. p x \ \<^bold>1} else insert i {x \ I. p x \ \<^bold>1})" + by auto + then show ?thesis + using assms by (simp add: G_def conj_disj_distribR insert_absorb) +qed + +lemma distrib_triv': + assumes "finite I" + shows "G (\i. g i \<^bold>* h i) I = G g I \<^bold>* G h I" + by (simp add: assms local.distrib) + +lemma non_neutral': "G g {x \ I. g x \ \<^bold>1} = G g I" + by (simp add: G_def) + +lemma distrib': + assumes "finite {x \ I. g x \ \<^bold>1}" "finite {x \ I. h x \ \<^bold>1}" + shows "G (\i. g i \<^bold>* h i) I = G g I \<^bold>* G h I" +proof - + have "a \<^bold>* a \ a \ a \ \<^bold>1" for a + by auto + then have "G (\i. g i \<^bold>* h i) I = G (\i. g i \<^bold>* h i) ({i \ I. g i \ \<^bold>1} \ {i \ I. h i \ \<^bold>1})" + using assms by (force simp: G_def finite_Collect_op intro!: mono_neutral_cong) + also have "\ = G g I \<^bold>* G h I" + proof - + have "F g ({i \ I. g i \ \<^bold>1} \ {i \ I. h i \ \<^bold>1}) = G g I" + "F h ({i \ I. g i \ \<^bold>1} \ {i \ I. h i \ \<^bold>1}) = G h I" + by (auto simp: G_def assms intro: mono_neutral_right) + then show ?thesis + using assms by (simp add: distrib) + qed + finally show ?thesis . +qed + +lemma cong': + assumes "A = B" + assumes g_h: "\x. x \ B \ g x = h x" + shows "G g A = G h B" + using assms by (auto simp: G_def cong: conj_cong intro: cong) + + +lemma mono_neutral_cong_left': + assumes "S \ T" + and "\i. i \ T - S \ h i = \<^bold>1" + and "\x. x \ S \ g x = h x" + shows "G g S = G h T" +proof - + have *: "{x \ S. g x \ \<^bold>1} = {x \ T. h x \ \<^bold>1}" + using assms by (metis DiffI subset_eq) + then have "finite {x \ S. g x \ \<^bold>1} = finite {x \ T. h x \ \<^bold>1}" + by simp + then show ?thesis + using assms by (auto simp add: G_def * intro: cong) +qed + +lemma mono_neutral_cong_right': + "S \ T \ \i \ T - S. g i = \<^bold>1 \ (\x. x \ S \ g x = h x) \ + G g T = G h S" + by (auto intro!: mono_neutral_cong_left' [symmetric]) + +lemma mono_neutral_left': "S \ T \ \i \ T - S. g i = \<^bold>1 \ G g S = G g T" + by (blast intro: mono_neutral_cong_left') + +lemma mono_neutral_right': "S \ T \ \i \ T - S. g i = \<^bold>1 \ G g T = G g S" + by (blast intro!: mono_neutral_left' [symmetric]) + end @@ -532,7 +620,7 @@ begin sublocale sum: comm_monoid_set plus 0 - defines sum = sum.F .. + defines sum = sum.F and sum' = sum.G .. abbreviation Sum ("\") where "\ \ sum (\x. x)" @@ -1134,7 +1222,7 @@ begin sublocale prod: comm_monoid_set times 1 - defines prod = prod.F .. + defines prod = prod.F and prod' = prod.G .. abbreviation Prod ("\_" [1000] 999) where "\A \ prod (\x. x) A" diff -r 350acd367028 -r da5857dbcbb9 src/HOL/Product_Type.thy --- a/src/HOL/Product_Type.thy Wed Apr 03 16:38:59 2019 +0100 +++ b/src/HOL/Product_Type.thy Thu Apr 04 14:19:33 2019 +0100 @@ -1137,6 +1137,10 @@ lemma Times_Int_Times: "A \ B \ C \ D = (A \ C) \ (B \ D)" by auto +lemma image_paired_Times: + "(\(x,y). (f x, g y)) ` (A \ B) = (f ` A) \ (g ` B)" + by auto + lemma product_swap: "prod.swap ` (A \ B) = B \ A" by (auto simp add: set_eq_iff)