Suppose we have two sets: $A=\{a_1,a_2,a_3\}$ and $B=\{b_1,b_2,b_3\}$.
Is there a way to define a function that simply adds/subtracts the elements of these two sets? For example, $$\mu(\cdot)=\sum_{i\in\mathbb{N}:\;a_i\in A}a_i+\sum_{j\in\mathbb{N}:\;b_j\in B}b_j.$$ I am not sure if I am allowed to say that $\mu(\cdot)$ is a function with domain $A\times B$.
Basically, my question is about rigorously defining a function that simply adds elements from two different sets. Is that possible? If yes, then how?
Hint: The cartesian product \begin{align*} A\times B&=\{(a_1,b_1),(a_1,b_2),(a_1,b_3),\\ &\qquad(a_2,b_1),(a_2,b_2),(a_2,b_3),\\ &\qquad(a_3,b_1),(a_3,b_2),(a_3,b_3)\} \end{align*} is not appropriate as domain for $\mu$, since a function $f:A\times B\to \mathbb{R}$ can only map elements of $A\times B$ i.e. pairs $(a_j,b_k)$ to $\mathbb{R}$. But we want to be able to sum up all elements from $A$ and $B$.
Taking $Z=(A\times\{0\})\cup(B\times\{1\})$ we obtain \begin{align*} \color{blue}{\mu(Z)}&=\mu((A\times\{0\})\cup(B\times\{1\}))\\ &=\sum_{z\in (A\times\{0\})\cup(B\times\{1\})}\pi_1(z)\\ &=\pi_1((a_1,0))+\pi_1((a_2,0))+\pi_1((a_3,0))\\ &\qquad+\pi_1((b_1,1))+\pi_1((b_2,1))+\pi_1((b_3,1))\\ &\,\,\color{blue}{=a_1+a_2+a_3+b_1+b_2+b_3}\\ \end{align*}