5

I think I might have stumbled across a general, albeit somewhat degenerate, monoid action. Pseudo-Haskell:

instance (Monoid m, Monoid n) => Act m n where
    act mempty x = x  -- let's pretend that we can use `mempty` as a pattern
    act _ _ = mempty

m's action on n is to set n to mempty unless m itself is empty.

Is this a law-abiding monoid action? Has it been invented before by someone other than me? If so, what is its name?

Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157

1 Answers1

5

It does not look as a monoid action, at least in the general case. If it were, we should have the following properties:

-- law 1
act mempty            x = x
-- law 2
act (m1 <> m2) x = act m1 (act m2 x)

and, because of the way act was defined in the pseudo-instance:

-- property 1
act x y = mempty
   when x /= mempty

Take m and n to be Sum Int, which is a monoid.

We have

act (Sum 0) (Sum 1)
= { definition of mempty }
act mempty (Sum 1)
= { law 1 }
Sum 1

we also have

act (Sum 0) (Sum 1)
= { definition of <> on Sum }
act (Sum (-2) <> Sum 2) (Sum 1)
= { law 2 }
act (Sum (-2)) (act (Sum 2) (Sum 1))
= { property 1, given Sum (-2) /= mempty }
mempty
= { definition of mempty }
Sum 0

leading to two incompatible results.

On the other side, when m is a monoid where no (nontrivial) element has an inverse, e.g. [a], then your act looks like a proper action.

chi
  • 111,837
  • 3
  • 133
  • 218
  • This makes sense, thanks. Are there any restrictions I can apply to `m` so that I do have a monoid action? For example, if `m` is not a group? Or if `m`'s `mappend` is monotonic? (I might have said the same thing two ways there.) – Benjamin Hodgson Jan 19 '21 at 22:16
  • @BenjaminHodgson You need more than "not a group". I guess you need "no element with an inverse, except mempty". In such case, it should be an action, I guess (?) – chi Jan 19 '21 at 22:21
  • Very helpful, thank you. Any idea if this thing has a name? – Benjamin Hodgson Jan 19 '21 at 22:21
  • @BenjaminHodgson Not that I know. A free monoid should suffice, but you don't need the monoid to be completely free. E.g. on lists `x <> y = take 4 (x++y)` should be OK (?), even if it does not form a free monoid. Not sure if there's a standard name for this. – chi Jan 19 '21 at 22:28