diff -r 1d43f86f48be -r e96292f32c3c src/HOL/Library/Multiset.thy --- a/src/HOL/Library/Multiset.thy Mon Dec 28 19:23:15 2015 +0100 +++ b/src/HOL/Library/Multiset.thy Mon Dec 28 21:47:32 2015 +0100 @@ -25,11 +25,11 @@ setup_lifting type_definition_multiset -abbreviation Melem :: "'a \ 'a multiset \ bool" ("(_/ :# _)" [50, 51] 50) where - "a :# M == 0 < count M a" - -notation (xsymbols) - Melem (infix "\#" 50) +abbreviation Melem :: "'a \ 'a multiset \ bool" (infix "\#" 50) + where "a \# M \ 0 < count M a" + +notation (ASCII) + Melem ("(_/ :# _)" [50, 51] 50) (* FIXME !? *) lemma multiset_eq_iff: "M = N \ (\a. count M a = count N a)" by (simp only: count_inject [symmetric] fun_eq_iff) @@ -265,16 +265,18 @@ subsubsection \Pointwise ordering induced by count\ -definition subseteq_mset :: "'a multiset \ 'a multiset \ bool" (infix "<=#" 50) where -"subseteq_mset A B = (\a. count A a \ count B a)" - -definition subset_mset :: "'a multiset \ 'a multiset \ bool" (infix "<#" 50) where -"subset_mset A B = (A <=# B \ A \ B)" - -notation subseteq_mset (infix "\#" 50) -notation (xsymbols) subseteq_mset (infix "\#" 50) - -notation (xsymbols) subset_mset (infix "\#" 50) +definition subseteq_mset :: "'a multiset \ 'a multiset \ bool" (infix "\#" 50) + where "A \# B = (\a. count A a \ count B a)" + +definition subset_mset :: "'a multiset \ 'a multiset \ bool" (infix "\#" 50) + where "A \# B = (A \# B \ A \ B)" + +notation (input) + subseteq_mset (infix "\#" 50) + +notation (ASCII) + subseteq_mset (infix "<=#" 50) and + subset_mset (infix "<#" 50) interpretation subset_mset: ordered_ab_semigroup_add_imp_le "op +" "op -" "op \#" "op \#" by standard (auto simp add: subset_mset_def subseteq_mset_def multiset_eq_iff intro: order_trans antisym) @@ -504,9 +506,9 @@ show ?thesis unfolding B by auto qed -syntax +syntax (ASCII) "_MCollect" :: "pttrn \ 'a multiset \ bool \ 'a multiset" ("(1{# _ :# _./ _#})") -syntax (xsymbol) +syntax "_MCollect" :: "pttrn \ 'a multiset \ bool \ 'a multiset" ("(1{# _ \# _./ _#})") translations "{#x \# M. P#}" == "CONST filter_mset (\x. P) M" @@ -855,27 +857,17 @@ lemma image_mset_is_empty_iff [simp]: "image_mset f M = {#} \ M = {#}" by (cases M) auto +syntax (ASCII) + "_comprehension_mset" :: "'a \ 'b \ 'b multiset \ 'a multiset" ("({#_/. _ :# _#})") syntax - "_comprehension1_mset" :: "'a \ 'b \ 'b multiset \ 'a multiset" - ("({#_/. _ :# _#})") -translations - "{#e. x:#M#}" == "CONST image_mset (\x. e) M" - -syntax (xsymbols) - "_comprehension2_mset" :: "'a \ 'b \ 'b multiset \ 'a multiset" - ("({#_/. _ \# _#})") + "_comprehension_mset" :: "'a \ 'b \ 'b multiset \ 'a multiset" ("({#_/. _ \# _#})") translations - "{#e. x \# M#}" == "CONST image_mset (\x. e) M" - + "{#e. x \# M#}" \ "CONST image_mset (\x. e) M" + +syntax (ASCII) + "_comprehension_mset'" :: "'a \ 'b \ 'b multiset \ bool \ 'a multiset" ("({#_/ | _ :# _./ _#})") syntax - "_comprehension3_mset" :: "'a \ 'b \ 'b multiset \ bool \ 'a multiset" - ("({#_/ | _ :# _./ _#})") -translations - "{#e | x:#M. P#}" \ "{#e. x :# {# x:#M. P#}#}" - -syntax - "_comprehension4_mset" :: "'a \ 'b \ 'b multiset \ bool \ 'a multiset" - ("({#_/ | _ \# _./ _#})") + "_comprehension_mset'" :: "'a \ 'b \ 'b multiset \ bool \ 'a multiset" ("({#_/ | _ \# _./ _#})") translations "{#e | x\#M. P#}" \ "{#e. x \# {# x\#M. P#}#}" @@ -1235,10 +1227,8 @@ qed -abbreviation Union_mset :: "'a multiset multiset \ 'a multiset" where - "Union_mset MM \ msetsum MM" - -notation (xsymbols) Union_mset ("\#_" [900] 900) +abbreviation Union_mset :: "'a multiset multiset \ 'a multiset" ("\#_" [900] 900) + where "\# MM \ msetsum MM" lemma set_mset_Union_mset[simp]: "set_mset (\# MM) = (\M \ set_mset MM. set_mset M)" by (induct MM) auto @@ -1246,14 +1236,12 @@ 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" - ("(3SUM _:#_. _)" [0, 51, 10] 10) -syntax (xsymbols) - "_msetsum_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_add" - ("(3\_\#_. _)" [0, 51, 10] 10) + "_msetsum_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_add" ("(3\_\#_. _)" [0, 51, 10] 10) translations - "SUM i :# A. b" == "CONST msetsum (CONST image_mset (\i. b) A)" + "\i \# A. b" \ "CONST msetsum (CONST image_mset (\i. b) A)" context comm_monoid_mult begin @@ -1287,14 +1275,12 @@ end +syntax (ASCII) + "_msetprod_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_mult" ("(3PROD _:#_. _)" [0, 51, 10] 10) syntax - "_msetprod_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_mult" - ("(3PROD _:#_. _)" [0, 51, 10] 10) -syntax (xsymbols) - "_msetprod_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_mult" - ("(3\_\#_. _)" [0, 51, 10] 10) + "_msetprod_image" :: "pttrn \ 'b set \ 'a \ 'a::comm_monoid_mult" ("(3\_\#_. _)" [0, 51, 10] 10) translations - "PROD i :# A. b" == "CONST msetprod (CONST image_mset (\i. b) A)" + "\i \# A. b" \ "CONST msetprod (CONST image_mset (\i. b) A)" lemma (in comm_semiring_1) dvd_msetprod: assumes "x \# A" @@ -1718,14 +1704,15 @@ subsubsection \Partial-order properties\ -definition less_multiset :: "'a::order multiset \ 'a multiset \ bool" (infix "#<#" 50) where - "M' #<# M \ (M', M) \ mult {(x', x). x' < x}" - -definition le_multiset :: "'a::order multiset \ 'a multiset \ bool" (infix "#<=#" 50) where - "M' #<=# M \ M' #<# M \ M' = M" - -notation (xsymbols) less_multiset (infix "#\#" 50) -notation (xsymbols) le_multiset (infix "#\#" 50) +definition less_multiset :: "'a::order multiset \ 'a multiset \ bool" (infix "#\#" 50) + where "M' #\# M \ (M', M) \ mult {(x', x). x' < x}" + +definition le_multiset :: "'a::order multiset \ 'a multiset \ bool" (infix "#\#" 50) + where "M' #\# M \ M' #\# M \ M' = M" + +notation (ASCII) + less_multiset (infix "#<#" 50) and + le_multiset (infix "#<=#" 50) interpretation multiset_order: order le_multiset less_multiset proof -