0
$\begingroup$

Suppose I have $X,Y$ that are equal to one or zero.

Is it possible to formulate a binary variable that is equal to $1$ if both $X,Y$ have the same value (i.e. $X=0$, $Y=0$ or $X=1$, $Y=1$) or equal to $0$ if they are different (i.e. $X=1$, $Y=0$ or $X=0$, $Y=1$)

Something like $(2X-1)(2Y-1)$ is kind of close but not there.

Thank you!

$\endgroup$
6
  • 1
    $\begingroup$ en.wikipedia.org/wiki/Symmetric_difference $\endgroup$ Commented Jul 7, 2022 at 18:04
  • 2
    $\begingroup$ Which connectives can you use? $\endgroup$
    – aschepler
    Commented Jul 7, 2022 at 18:06
  • 2
    $\begingroup$ If we view $X$ and $Y$ as Boolean variables, the operation you're describing is the logical connective $\leftrightarrow$ a.k.a. the material biconditional or (especially in the context of digital circuits) $\operatorname{XNOR}$. $\endgroup$ Commented Jul 7, 2022 at 18:07
  • 1
    $\begingroup$ Maybe $Z=1-|X-Y|$ will be OK? $\endgroup$
    – PC1
    Commented Jul 7, 2022 at 18:09
  • 1
    $\begingroup$ Or $Z=1-(X-Y)^2$ if you want to have a polynomial $\endgroup$ Commented Jul 7, 2022 at 18:11

1 Answer 1

1
$\begingroup$

If true is $1$ and false is $0$, then $x+y \equiv 0 \, \textrm{mod}(2)$ if and only if the binary variables $x$ and $y$ are equal.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .