How to define a function with summation? 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$.

Here is an approach which might be useful:
  
  
*
  
*We have to be careful to not mix up elements from $A$ and $B$ in case $A\cap B\neq \emptyset$. We consider instead  $A\times\{0\}=\{(a_1,0),(a_2,0),(a_3,0)\}$ and $B\times\{1\}=\{(b_1,1),(b_2,1)(b_3,1)\}$ to overcome this problem.
  
*We want to add all elements from $A$ and all elements from $B$. We take therefore the powerset $\mathcal{P}$ of $(A\times\{0\})\cup(B\times\{1\})$ as domain of $\mu$.
We define $\mu$ as follows.
\begin{align*}
&\mu:\mathcal{P}\left((A\times\{0\})\cup(B\times\{1\})\right)\to\mathbb{R}\\
&\mu(Z)=\sum_{z\in Z}\pi_1(z)
\end{align*}
where $z\in Z\subseteq(A\times\{0\})\cup(B\times\{1\})$ and $\pi_1(z)=x$ is the projection of $z=(x,y)$ to the first coordinate.

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*}
