equal
deleted
inserted
replaced
91 "\<lambda>a M b. if b = a then Suc (M b) else M b" |
91 "\<lambda>a M b. if b = a then Suc (M b) else M b" |
92 by (rule add_mset_in_multiset) |
92 by (rule add_mset_in_multiset) |
93 |
93 |
94 syntax |
94 syntax |
95 "_multiset" :: "args \<Rightarrow> 'a multiset" ("{#(_)#}") |
95 "_multiset" :: "args \<Rightarrow> 'a multiset" ("{#(_)#}") |
|
96 syntax_consts |
|
97 "_multiset" == add_mset |
96 translations |
98 translations |
97 "{#x, xs#}" == "CONST add_mset x {#xs#}" |
99 "{#x, xs#}" == "CONST add_mset x {#xs#}" |
98 "{#x#}" == "CONST add_mset x {#}" |
100 "{#x#}" == "CONST add_mset x {#}" |
99 |
101 |
100 lemma count_empty [simp]: "count {#} a = 0" |
102 lemma count_empty [simp]: "count {#} a = 0" |
166 "_MBex" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> bool \<Rightarrow> bool" ("(3\<exists>_\<in>#_./ _)" [0, 0, 10] 10) |
168 "_MBex" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> bool \<Rightarrow> bool" ("(3\<exists>_\<in>#_./ _)" [0, 0, 10] 10) |
167 |
169 |
168 syntax (ASCII) |
170 syntax (ASCII) |
169 "_MBall" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> bool \<Rightarrow> bool" ("(3\<forall>_:#_./ _)" [0, 0, 10] 10) |
171 "_MBall" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> bool \<Rightarrow> bool" ("(3\<forall>_:#_./ _)" [0, 0, 10] 10) |
170 "_MBex" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> bool \<Rightarrow> bool" ("(3\<exists>_:#_./ _)" [0, 0, 10] 10) |
172 "_MBex" :: "pttrn \<Rightarrow> 'a set \<Rightarrow> bool \<Rightarrow> bool" ("(3\<exists>_:#_./ _)" [0, 0, 10] 10) |
|
173 |
|
174 syntax_consts |
|
175 "_MBall" \<rightleftharpoons> Multiset.Ball and |
|
176 "_MBex" \<rightleftharpoons> Multiset.Bex |
171 |
177 |
172 translations |
178 translations |
173 "\<forall>x\<in>#A. P" \<rightleftharpoons> "CONST Multiset.Ball A (\<lambda>x. P)" |
179 "\<forall>x\<in>#A. P" \<rightleftharpoons> "CONST Multiset.Ball A (\<lambda>x. P)" |
174 "\<exists>x\<in>#A. P" \<rightleftharpoons> "CONST Multiset.Bex A (\<lambda>x. P)" |
180 "\<exists>x\<in>#A. P" \<rightleftharpoons> "CONST Multiset.Bex A (\<lambda>x. P)" |
175 |
181 |
1246 |
1252 |
1247 syntax (ASCII) |
1253 syntax (ASCII) |
1248 "_MCollect" :: "pttrn \<Rightarrow> 'a multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("(1{#_ :# _./ _#})") |
1254 "_MCollect" :: "pttrn \<Rightarrow> 'a multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("(1{#_ :# _./ _#})") |
1249 syntax |
1255 syntax |
1250 "_MCollect" :: "pttrn \<Rightarrow> 'a multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("(1{#_ \<in># _./ _#})") |
1256 "_MCollect" :: "pttrn \<Rightarrow> 'a multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("(1{#_ \<in># _./ _#})") |
|
1257 syntax_consts |
|
1258 "_MCollect" == filter_mset |
1251 translations |
1259 translations |
1252 "{#x \<in># M. P#}" == "CONST filter_mset (\<lambda>x. P) M" |
1260 "{#x \<in># M. P#}" == "CONST filter_mset (\<lambda>x. P) M" |
1253 |
1261 |
1254 lemma count_filter_mset [simp]: |
1262 lemma count_filter_mset [simp]: |
1255 "count (filter_mset P M) a = (if P a then count M a else 0)" |
1263 "count (filter_mset P M) a = (if P a then count M a else 0)" |
1819 |
1827 |
1820 syntax (ASCII) |
1828 syntax (ASCII) |
1821 "_comprehension_mset" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> 'a multiset" ("({#_/. _ :# _#})") |
1829 "_comprehension_mset" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> 'a multiset" ("({#_/. _ :# _#})") |
1822 syntax |
1830 syntax |
1823 "_comprehension_mset" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> 'a multiset" ("({#_/. _ \<in># _#})") |
1831 "_comprehension_mset" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> 'a multiset" ("({#_/. _ \<in># _#})") |
|
1832 syntax_consts |
|
1833 "_comprehension_mset" \<rightleftharpoons> image_mset |
1824 translations |
1834 translations |
1825 "{#e. x \<in># M#}" \<rightleftharpoons> "CONST image_mset (\<lambda>x. e) M" |
1835 "{#e. x \<in># M#}" \<rightleftharpoons> "CONST image_mset (\<lambda>x. e) M" |
1826 |
1836 |
1827 syntax (ASCII) |
1837 syntax (ASCII) |
1828 "_comprehension_mset'" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("({#_/ | _ :# _./ _#})") |
1838 "_comprehension_mset'" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("({#_/ | _ :# _./ _#})") |
1829 syntax |
1839 syntax |
1830 "_comprehension_mset'" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("({#_/ | _ \<in># _./ _#})") |
1840 "_comprehension_mset'" :: "'a \<Rightarrow> 'b \<Rightarrow> 'b multiset \<Rightarrow> bool \<Rightarrow> 'a multiset" ("({#_/ | _ \<in># _./ _#})") |
|
1841 syntax_consts |
|
1842 "_comprehension_mset'" \<rightleftharpoons> image_mset |
1831 translations |
1843 translations |
1832 "{#e | x\<in>#M. P#}" \<rightharpoonup> "{#e. x \<in># {# x\<in>#M. P#}#}" |
1844 "{#e | x\<in>#M. P#}" \<rightharpoonup> "{#e. x \<in># {# x\<in>#M. P#}#}" |
1833 |
1845 |
1834 text \<open> |
1846 text \<open> |
1835 This allows to write not just filters like \<^term>\<open>{#x\<in>#M. x<c#}\<close> |
1847 This allows to write not just filters like \<^term>\<open>{#x\<in>#M. x<c#}\<close> |
2673 |
2685 |
2674 syntax (ASCII) |
2686 syntax (ASCII) |
2675 "_sum_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_add" ("(3SUM _:#_. _)" [0, 51, 10] 10) |
2687 "_sum_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_add" ("(3SUM _:#_. _)" [0, 51, 10] 10) |
2676 syntax |
2688 syntax |
2677 "_sum_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_add" ("(3\<Sum>_\<in>#_. _)" [0, 51, 10] 10) |
2689 "_sum_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_add" ("(3\<Sum>_\<in>#_. _)" [0, 51, 10] 10) |
|
2690 syntax_consts |
|
2691 "_sum_mset_image" \<rightleftharpoons> sum_mset |
2678 translations |
2692 translations |
2679 "\<Sum>i \<in># A. b" \<rightleftharpoons> "CONST sum_mset (CONST image_mset (\<lambda>i. b) A)" |
2693 "\<Sum>i \<in># A. b" \<rightleftharpoons> "CONST sum_mset (CONST image_mset (\<lambda>i. b) A)" |
2680 |
2694 |
2681 context comm_monoid_add |
2695 context comm_monoid_add |
2682 begin |
2696 begin |
2852 |
2866 |
2853 syntax (ASCII) |
2867 syntax (ASCII) |
2854 "_prod_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_mult" ("(3PROD _:#_. _)" [0, 51, 10] 10) |
2868 "_prod_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_mult" ("(3PROD _:#_. _)" [0, 51, 10] 10) |
2855 syntax |
2869 syntax |
2856 "_prod_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_mult" ("(3\<Prod>_\<in>#_. _)" [0, 51, 10] 10) |
2870 "_prod_mset_image" :: "pttrn \<Rightarrow> 'b set \<Rightarrow> 'a \<Rightarrow> 'a::comm_monoid_mult" ("(3\<Prod>_\<in>#_. _)" [0, 51, 10] 10) |
|
2871 syntax_consts |
|
2872 "_prod_mset_image" \<rightleftharpoons> prod_mset |
2857 translations |
2873 translations |
2858 "\<Prod>i \<in># A. b" \<rightleftharpoons> "CONST prod_mset (CONST image_mset (\<lambda>i. b) A)" |
2874 "\<Prod>i \<in># A. b" \<rightleftharpoons> "CONST prod_mset (CONST image_mset (\<lambda>i. b) A)" |
2859 |
2875 |
2860 lemma prod_mset_constant [simp]: "(\<Prod>_\<in>#A. c) = c ^ size A" |
2876 lemma prod_mset_constant [simp]: "(\<Prod>_\<in>#A. c) = c ^ size A" |
2861 by (simp add: image_mset_const_eq) |
2877 by (simp add: image_mset_const_eq) |