diff -r 8a105c235b1f -r 95c6cf433c91 src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Thu Feb 18 17:52:53 2016 +0100 +++ b/src/HOL/Library/Multiset.thy Thu Feb 18 17:53:09 2016 +0100 @@ -1164,6 +1164,15 @@ "replicate (count (mset xs) k) k = filter (HOL.eq k) xs" by (induct xs) auto +lemma replicate_mset_eq_empty_iff [simp]: + "replicate_mset n a = {#} \ n = 0" + by (induct n) simp_all + +lemma replicate_mset_eq_iff: + "replicate_mset m a = replicate_mset n b \ + m = 0 \ n = 0 \ m = n \ a = b" + by (auto simp add: multiset_eq_iff) + subsection \Big operators\ @@ -1237,6 +1246,12 @@ (simp_all del: mem_set_mset_iff add: size_multiset_overloaded_eq setsum.distrib setsum.delta' insert_absorb, simp) qed +syntax (ASCII) + "_msetsum_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_add" ("(3SUM _:#_. _)" [0, 51, 10] 10) +syntax + "_msetsum_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_add" ("(3\_\#_. _)" [0, 51, 10] 10) +translations + "\i \# A. b" \ "CONST msetsum (CONST image_mset (\i. b) A)" abbreviation Union_mset :: "'a multiset multiset \ 'a multiset" ("\#_" [900] 900) where "\# MM \ msetsum MM" @@ -1247,12 +1262,14 @@ lemma in_Union_mset_iff[iff]: "x \# \# MM \ (\M. M \# MM \ x \# M)" by (induct MM) auto -syntax (ASCII) - "_msetsum_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_add" ("(3SUM _:#_. _)" [0, 51, 10] 10) -syntax - "_msetsum_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_add" ("(3\_\#_. _)" [0, 51, 10] 10) -translations - "\i \# A. b" \ "CONST msetsum (CONST image_mset (\i. b) A)" +lemma count_setsum: + "count (setsum f A) x = setsum (\a. count (f a) x) A" + by (induct A rule: infinite_finite_induct) simp_all + +lemma setsum_eq_empty_iff: + assumes "finite A" + shows "setsum f A = {#} \ (\a\A. f a = {#})" + using assms by induct simp_all context comm_monoid_mult begin @@ -1302,6 +1319,10 @@ then show ?thesis by simp qed +lemma (in semidom) msetprod_zero_iff: + "msetprod A = 0 \ (\a\set_mset A. a = 0)" + by (induct A) auto + subsection \Alternative representations\