Let $X$ be an infinite set and $M$ a commutative monoid. Find a function $f \colon \mathcal{P}(X) \to M$ such that
- $f(\emptyset) = 0$
- for each element $x$ of $X$, $f(\{x\}) = 0$,
- for any two disjoint subsets $A$ and $B$ of $X$, $f(A \cup B) = f(A) + f(B)$.
This has an obvious solution, the constant function $\mathcal{P}(X) \to \{0\}$. Is that the only solution? In particular, is that the only solution when $M$ is $\mathbf{N}$, $\mathbf{Z}$, $\mathbf{Q}$, or $\mathbf{R}$?
[Edited in light of Matthew Daly's answer]