src/HOL/Library/Multiset.thy
changeset 61566 c3d6e570ccef
parent 61424 c3658c18b7bc
child 61585 a9599d3d7610
equal deleted inserted replaced
61565:352c73a689da 61566:c3d6e570ccef
  1058 definition mset_set :: "'a set \<Rightarrow> 'a multiset"
  1058 definition mset_set :: "'a set \<Rightarrow> 'a multiset"
  1059 where
  1059 where
  1060   "mset_set = folding.F (\<lambda>x M. {#x#} + M) {#}"
  1060   "mset_set = folding.F (\<lambda>x M. {#x#} + M) {#}"
  1061 
  1061 
  1062 interpretation mset_set!: folding "\<lambda>x M. {#x#} + M" "{#}"
  1062 interpretation mset_set!: folding "\<lambda>x M. {#x#} + M" "{#}"
  1063 where
  1063 rewrites
  1064   "folding.F (\<lambda>x M. {#x#} + M) {#} = mset_set"
  1064   "folding.F (\<lambda>x M. {#x#} + M) {#} = mset_set"
  1065 proof -
  1065 proof -
  1066   interpret comp_fun_commute "\<lambda>x M. {#x#} + M"
  1066   interpret comp_fun_commute "\<lambda>x M. {#x#} + M"
  1067     by standard (simp add: fun_eq_iff ac_simps)
  1067     by standard (simp add: fun_eq_iff ac_simps)
  1068   show "folding (\<lambda>x M. {#x#} + M)"
  1068   show "folding (\<lambda>x M. {#x#} + M)"
  1221 
  1221 
  1222 definition msetsum :: "'a multiset \<Rightarrow> 'a"
  1222 definition msetsum :: "'a multiset \<Rightarrow> 'a"
  1223   where "msetsum = comm_monoid_mset.F plus 0"
  1223   where "msetsum = comm_monoid_mset.F plus 0"
  1224 
  1224 
  1225 sublocale msetsum!: comm_monoid_mset plus 0
  1225 sublocale msetsum!: comm_monoid_mset plus 0
  1226   where "comm_monoid_mset.F plus 0 = msetsum"
  1226   rewrites "comm_monoid_mset.F plus 0 = msetsum"
  1227 proof -
  1227 proof -
  1228   show "comm_monoid_mset plus 0" ..
  1228   show "comm_monoid_mset plus 0" ..
  1229   from msetsum_def show "comm_monoid_mset.F plus 0 = msetsum" ..
  1229   from msetsum_def show "comm_monoid_mset.F plus 0 = msetsum" ..
  1230 qed
  1230 qed
  1231 
  1231 
  1279 
  1279 
  1280 definition msetprod :: "'a multiset \<Rightarrow> 'a"
  1280 definition msetprod :: "'a multiset \<Rightarrow> 'a"
  1281   where "msetprod = comm_monoid_mset.F times 1"
  1281   where "msetprod = comm_monoid_mset.F times 1"
  1282 
  1282 
  1283 sublocale msetprod!: comm_monoid_mset times 1
  1283 sublocale msetprod!: comm_monoid_mset times 1
  1284   where "comm_monoid_mset.F times 1 = msetprod"
  1284   rewrites "comm_monoid_mset.F times 1 = msetprod"
  1285 proof -
  1285 proof -
  1286   show "comm_monoid_mset times 1" ..
  1286   show "comm_monoid_mset times 1" ..
  1287   show "comm_monoid_mset.F times 1 = msetprod" using msetprod_def ..
  1287   show "comm_monoid_mset.F times 1 = msetprod" using msetprod_def ..
  1288 qed
  1288 qed
  1289 
  1289