map two sets of integers into two integers such that the number of intersections of these two sets can be found using only these two integers Given two multisets $A$ and $B$, is it possible to map all of the elements of these two multisets into two integer (for example, integer $A_1$ will represent the elements of multiset $A$, and integer $B_1$ will represent the elements of multiset $B$), in a way that allows for the number of intersections of multiset $A$ and $B$ to be found using only the integers $A_1$ and $B_1$?
For example, if multiset $A = \{1,2,3,4,5\}$ and multiset $B = \{7, 1, 2, 6, 7, 8\}$, then these two multisets should be able to be mapped to two integers that represent the data in these two multisets ($A_1$ and $B_1$), such that the number of intersections of these two multisets should be able to be computed using only the integers $A_1$ and $B_1$ (without using the underlying data). The number of intersections of the multisets $A$ and $B$ in this case is 2.
 A: I think a precise phrasing of the question is:
Is there a function $f\colon \scr P(\mathbb Z)\to \mathbb Z$ such that for all $A, A', B, B'\in \scr P(\mathbb Z),$ if $f(A) = f(A')$ and $f(B) = f(B'),$ then $|A \cap B | = |A' \cap B'|?$
The answer to this is "No."
If $f$ were such a function, then it would be injective, because for any $A, A'\in\scr P(\mathbb Z):$
$$ \begin{align}
f(A) = f(A') &\implies (\forall x\in\mathbb Z)\,\big(\,|A \cap \{x\} | = |A' \cap \{x\}|\,\big)\\
&\implies A=A',
\end{align}$$
where you can see that the first implication is true by taking $B = B' = \{x\}$ in the property that $f$ is required to have.
But there is no injective function from $\mathscr P(\mathbb Z)$ to $\mathbb Z,$ by Cantor's theorem.

Note that if you replace $\mathscr P(\mathbb Z)$ with the set $S$ of all finite subsets of $\mathbb Z,$ then the answer is positive (as @StevenStadnicki pointed out in a comment): $S$ and $\mathbb Z$ have the same cardinality, so you can just let $f$ be any injective function from $S$ to $\mathbb Z.$
A: If we assume the sets to be finite, this can be done by mapping a set to the product of primes corresponding to the elements, i.e the element $j\in A$ corresponds to the $j$th prime $p_j$. By the fundamental theorem of arithmetic, from the product $\prod_{j\in A} p_j$ we see which primes are present and can recover the set $A$.
Now as you have two (finite) sets, just recover them both and you can recover the intersection.
For infinite sets this doesn't work, of course. And nothing does, as proved in the earlier answer.
BTW: are you talking about multisets because you have $7$ appearing twice in $B$? Well, this method still works because the multiplicities of primes are also accounted for in the prime factorization.
EDIT: To allow integers, leave every other prime for the sign (its presence marks negativity for example. And for zero take the first prime. Or even better zero to two and then onwards 3 to 1, 5 to -1 and so on...
