equal
deleted
inserted
replaced
1056 |
1056 |
1057 definition mset_set :: "'a set \<Rightarrow> 'a multiset" |
1057 definition mset_set :: "'a set \<Rightarrow> 'a multiset" |
1058 where |
1058 where |
1059 "mset_set = folding.F (\<lambda>x M. {#x#} + M) {#}" |
1059 "mset_set = folding.F (\<lambda>x M. {#x#} + M) {#}" |
1060 |
1060 |
1061 interpretation mset_set!: folding "\<lambda>x M. {#x#} + M" "{#}" |
1061 interpretation mset_set: folding "\<lambda>x M. {#x#} + M" "{#}" |
1062 rewrites |
1062 rewrites |
1063 "folding.F (\<lambda>x M. {#x#} + M) {#} = mset_set" |
1063 "folding.F (\<lambda>x M. {#x#} + M) {#} = mset_set" |
1064 proof - |
1064 proof - |
1065 interpret comp_fun_commute "\<lambda>x M. {#x#} + M" |
1065 interpret comp_fun_commute "\<lambda>x M. {#x#} + M" |
1066 by standard (simp add: fun_eq_iff ac_simps) |
1066 by standard (simp add: fun_eq_iff ac_simps) |
1219 begin |
1219 begin |
1220 |
1220 |
1221 definition msetsum :: "'a multiset \<Rightarrow> 'a" |
1221 definition msetsum :: "'a multiset \<Rightarrow> 'a" |
1222 where "msetsum = comm_monoid_mset.F plus 0" |
1222 where "msetsum = comm_monoid_mset.F plus 0" |
1223 |
1223 |
1224 sublocale msetsum!: comm_monoid_mset plus 0 |
1224 sublocale msetsum: comm_monoid_mset plus 0 |
1225 rewrites "comm_monoid_mset.F plus 0 = msetsum" |
1225 rewrites "comm_monoid_mset.F plus 0 = msetsum" |
1226 proof - |
1226 proof - |
1227 show "comm_monoid_mset plus 0" .. |
1227 show "comm_monoid_mset plus 0" .. |
1228 from msetsum_def show "comm_monoid_mset.F plus 0 = msetsum" .. |
1228 from msetsum_def show "comm_monoid_mset.F plus 0 = msetsum" .. |
1229 qed |
1229 qed |
1277 begin |
1277 begin |
1278 |
1278 |
1279 definition msetprod :: "'a multiset \<Rightarrow> 'a" |
1279 definition msetprod :: "'a multiset \<Rightarrow> 'a" |
1280 where "msetprod = comm_monoid_mset.F times 1" |
1280 where "msetprod = comm_monoid_mset.F times 1" |
1281 |
1281 |
1282 sublocale msetprod!: comm_monoid_mset times 1 |
1282 sublocale msetprod: comm_monoid_mset times 1 |
1283 rewrites "comm_monoid_mset.F times 1 = msetprod" |
1283 rewrites "comm_monoid_mset.F times 1 = msetprod" |
1284 proof - |
1284 proof - |
1285 show "comm_monoid_mset times 1" .. |
1285 show "comm_monoid_mset times 1" .. |
1286 show "comm_monoid_mset.F times 1 = msetprod" using msetprod_def .. |
1286 show "comm_monoid_mset.F times 1 = msetprod" using msetprod_def .. |
1287 qed |
1287 qed |