Binary operation commutative, associative, and distributive over multiplication

The nicest way to do this if we restrict our attention to positive integers is to take something similar to Zander's answer... but work with prime powers. It should be able to be extended to positive rationals, if you're careful.

It works like this: if you have two integers of the form $$ a = \prod_{i=1}^n p_i^{k_i} $$ and $$ b = \prod_{i=1}^n p_i^{m_i} $$ where $n$ is simply the index of the highest prime present in the pair of integers (that is, it's an arbitrary number for representing the primes in question), then we define our operation as $$ a\circ b = \prod_{i=1}^n p_i^{k_i\times m_i} $$ With this operation, we have commutativity (obvious). We have associativity: $$ (a\circ b)\circ c = a\circ (b\circ c) = \prod_{i=1}^n p_i^{k_i\times m_i\times l_i} $$ We have distributivity: $$ a\circ (b\times c) = \prod_{i=1}^n p_i^{k_i\times (m_i+l_i)} = \prod_{i=1}^n p_i^{k_i\times m_i}\times \prod_{i=1}^n p_i^{k_i\times l_i} $$ (and similarly for the right-distributivity).

Interestingly, this operation maps any pair of coprime integers to one, and more generally the result of this operation on any pair of integers will produce an integer having only prime factors present in both the original integers. Some specific examples...

$$ p^m \circ p^n = p^{mn}\\ 100\circ 750 = 62500\\ 224\circ 147 = 49 $$


You want a pairing $\phi: \mathbb{Z} \times \mathbb{Z} \rightarrow \mathbb{Z}$ which is distributive over multiplication, commutative, and associative.

Let me ignore signs for now (any such map can have the signs stripped out and map to nonnegative integers).

It's possible that $\phi$ is "zero at a prime $p$" by having $\phi(p,1) = 0$, which implies any expression involving a factor of $p$ is zero.

Other than this, and not yet considering associativity (i.e. only distributivity and commutativity), $\phi$ is determined by $\phi(p,q)$ for primes $p$ and $q$, and these are unconstrained (i.e. any value in $\mathbb{Z}$) except by $\phi(p,q) = \phi(q,p)$ if we want commutativity.

Associativity adds the condition $\phi(\phi(p,q),r) = \phi(p,\phi(q,r))$. This is quite restrictive compared to the above, but still there are many maps satisfying this.

For example, take $\phi(p,q) = 2$ for all $p$ and $q$. This works.

What does this give for $\phi$? Define $f(n)$ to be the sum of the exponents in the prime factorization of $n$.

Then $\phi(m,n) = 2^{f(n)f(m)}$. This satisfies all your conditions. (Let it be zero if $m$ or $n$ is zero, and ignore factors of $-1$.)

This of course has a variant for any other prime in place of $2$. It's also an amusingly similar idea to the partial example over the reals. (That example may be fixed by ignoring signs in the input and giving zero as the result if either input is zero.)

There are many others. For example, to get something just slightly more complicated, partition the primes into two sets, one containing $2$ and one containing $3$. Let $\phi(p,q)$ be $2$ if either is in the first set, and $3$ if they're both in the second. (There's also a variant: $2$ if both in the first, $3$ if both in the second, $0$ if one of each.)


We can also consider the map, instead of pairing, version:

$\phi: (\mathbb{Z},\cdot) \rightarrow \mathrm{End}(\mathbb{Z},\cdot)$

The condition $\phi(a)(b\cdot c) = \phi(a)(b) \cdot \phi(a)(c)$ is the statement that $\phi(a)$ is in $\mathrm{End}(\mathbb{Z},\cdot)$.

Then $\phi(a\cdot b)(c) = \phi(a)(c) \cdot \phi(b)(c)$ is the statement that $\phi$ is a morphism of monoids from $(\mathbb{Z},\cdot)$ to $\mathrm{End}(\mathbb{Z},\cdot)$. (Where given $f$ and $g$ we let $(f \cdot g)(c) = f(c) \cdot g(c)$. If $f$ and $g$ are endomorphisms of $(\mathbb{Z},\cdot)$, so is $f\cdot g$.)

The positive integers with multiplication are a free, unital monoid generated by the primes. (Signs and zero fit into this picture as well.)

This is only the distributivity part of the story, but it's a nice way to think about it.


Let $ a\circ b = a^{\log b} $ then $$ a\circ b = a^{\log b} = \exp(\log a\log b) = b^{\log a} = b\circ a\\ (a\circ b)\circ c = (a^{\log b})^{\log c} = \exp(\log a\log b\log c) = a\circ (b\circ c) \\ a\circ (b\times c) = a^{\log b + \log c} = a\circ b \times a\circ c \\ (a\times b)\circ c = a^{\log c} \times b^{\log c} = a\circ c \times b\circ c $$