I have an if-then-else condition with three binary variables $A$, $B$ and $C$:if A = 1       then B = 1else              B = CHow do I express this as an integer linear program with equality constraints?
Converting if-then-else condition to integer linear programming with equality constraints
linear programming;integer programming
We have three binary variables $x, y, z \in \{0,1\}$ and the following if-then-else (ITE) condition$$\text{if } x = 1 \text{ then } y = 1 \text{ else } y = z$$If $x = 1$, then $y = 1$ but $z \in \{0,1\}$. If $x = 0$, then $y = z \in \{0,1\}$. Therefore, we have the following $4$ vertices of the $3$-cube$$\{ (0,0,0), (0,1,1), (1,1,0), (1,1,1) \}$$Using SymPy, we obtain the following product of sums (POS):>>> from sympy import *>>> x, y, z = symbols('x y z')>>> minterms = [[0, 0, 0], [0, 1, 1], [1, 1, 0], [1, 1, 1]]>>> POSform([x, y, z], minterms, [])And(Or(Not(x), y), Or(Not(y), x, z), Or(Not(z), y))Converting the formula in POS, i.e., in conjunctive normal form (CNF), to integer programming, we obtain the following system of linear inequalities$$\begin{array}{rl} (1-x) + y &\geq 1\\ x + (1-y) + z &\geq 1\\ y + (1-z) &\geq 1\end{array}$$which can be rewritten as follows$$\begin{array}{rl} -x + y &\geq 0\\ x - y + z &\geq 0\\ y -z &\geq 0\end{array}$$Verifying in Haskell:> triples = [ (x,y,z) | x <- [0,1], y <- [0,1], z <- [0,1] ]> filter (\(x,y,z)->(-x+y>=0) && (x-y+z>=0) && (y-z>=0)) triples[(0,0,0),(0,1,1),(1,1,0),(1,1,1)]