2
$\begingroup$

The bag monad, sometimes called the multiset monad or free commutative monoid monad is a functor on Set that takes a set to its set of bags. These bags are like strings written in the elements of the set along with an equivalence between any two strings that are equal due to the commutativity of the elements. So, we can write the Bag data structure in terms of a monad $Bag = (B, \mu_B, \eta_B)$. This is also true of lists. Lists are very much like bags, except there is no commutativity equivalence. They are litterally strings, so the theory of Lists (ie the category of algebraic structures which has an adjunction into Set that generates the LIst monad) is just free monoids. So, we can write the List data structure as a monad, $List = (L, \mu_L, \eta_L)$. I am looking for a map between Monads that will take the Bag monad to the List monad. Does this map exist? Are there several ways to do it?

Edit: I think I get why my desire to turn Bag elements to every permutation is a bad idea. This question conflates two desires of mine. First, I just want to see the transformation from Bag to List, whatever that may be. Second, I have been trying to find a Monad-like permutation gadget. I think I found that in terms of an operad over here. I just forgot, so apologies.

$\endgroup$
4
  • 5
    $\begingroup$ Pretty sure it does not exist. If it existed, then we could compose it with the projection that sends each nonempty list of nonempty lists to the first element of its first element; thus we would get a natural transformation from the "nonempty bags" monad to the identity monad. This natural transformation would have to commute with endomorphisms of the original type, such as permutations; thus, if it takes a bag $ab = ba$ to $a$, then it must also take it to $b$, and vice versa, which is absurd. $\endgroup$ Commented Jul 14, 2018 at 20:36
  • 1
    $\begingroup$ "The map $M:Bag \to List$ would take $x$ to every permutation of the elements of $b$" Is this a multivalued map? $\endgroup$ Commented Jul 15, 2018 at 3:19
  • 2
    $\begingroup$ It may be worth noting that there's a map going in the opposite direction, and that can be quite useful too. We may be able to help better if you explained why you need the transformation from bags to lists. $\endgroup$ Commented Jul 15, 2018 at 8:17
  • 1
    $\begingroup$ I second @FrançoisG.Dorais's question. A map $M$ from the bag monad to the list monad would consist of, for each set $X$, a function $M_X$ from the (underlying set of) the free commutative monoid on $X$ to the (underlying set of) the free monoid on $X$. You want this function to send a bag not to one list but to many, and functions don't do that. $\endgroup$ Commented Jul 15, 2018 at 16:59

0

You must log in to answer this question.

Browse other questions tagged .