This maybe more of a computer science problem but maybe the solution lies in number theory.
Given integers $x,y$, define a function $f$ so that
$$f(x,y) = \begin{cases} 1 & \text{if $x=y$} \\ 0 & \text{otherwise.} \end{cases} $$
The obvious solution Negate( $x-y$ ) cannot be applied. The reason is that $f$ needs to operate on homomorphically encrypted integers, and negation is not homomorphic.