6

I want to convert a set of boolean expressions to linear equations. In some cases, this is easy. For example, suppose $a, b, c$ $\in$ {0,1}. Then if the boolean expression is: $a$ $\ne$ b, I could use the linear equation $a + b = 1$.

To give a more complicated example, suppose I'm dealing with the boolean expression $a=b$ $\wedge$ $c$. I could describe this expression with: $-1$ $\le$ $2b+2c-4a$ $\le$ $3$.

Does that make sense?

Now how would I convert a=$b$ $\vee$ $c$? Any ideas?

Thanks for considering!

K

RobPratt
  • 50,938

3 Answers3

1

A general approach to this type of problem is to rewrite the logical proposition in conjunctive normal form (CNF) and then read off the resulting linear constraints. For $a \iff b \wedge c$, the resulting CNF yields constraints $a \le b, a \le c, a \ge b + c - 1$, as shown here.

For $a \iff b \vee c$, here is the corresponding derivation: \begin{align*} & a \iff b \vee c \\ & \left(a \implies (b \vee c)\right) \bigwedge \left((b \vee c) \implies a\right) \\ & \left(\neg a \vee (b \vee c)\right) \bigwedge \left(\neg(b \vee c) \vee a\right) \\ & \left(\neg a \vee b \vee c\right) \bigwedge \left((\neg b \wedge \neg c) \vee a\right) \\ & \left(\neg a \vee b \vee c\right) \bigwedge \left((\neg b \vee a) \wedge (\neg c \vee a)\right) \\ & \left(\neg a \vee b \vee c\right) \bigwedge \left(\neg b \vee a\right) \bigwedge \left(\neg c \vee a\right) \\ & \left(1 - a + b + c \ge 1\right) \bigwedge \left(1 - b + a \ge 1\right) \bigwedge \left(1 - c + a \ge 1\right) \\ & \left(a \le b + c\right) \bigwedge \left(a \ge b\right) \bigwedge \left(a \ge c\right) \end{align*}

RobPratt
  • 50,938
0

Notice that you have a couple different solutions to consider here:

$a+b+c=0$ is part of your solution set.

Next, if $a=1$ then you'd want at least one of the other two to also be on, so possibly something like:

$2a+b+c\ge3$ would be the other part you'd need so that you cover for (a,b,c) the possibilities (1,1,0), (1,0,1), and (1,1,1).

JB King
  • 3,666
0

You can translate $x \land y$ directly to $x+y=2$, and $x \lor y$ to $1 \le x+y \le 2.$ Also $\lnot x$ can be $x-1 \le 0$. This gives a basis for translation into equations or inequalities.

A simpler version of $a=b \land c$ I found to be $2a=b+c$. (This use of the 2 on the left is because of there being two variables on the right side).

Fiddling around I also found for $a=b \lor c$ the inequality $2a-1 \le b+c \le 2a$, based on using the above inequality for $x \lor y.$

coffeemath
  • 30,190
  • 2
  • 34
  • 53
  • For the equation 2a=b+c, suppose b=1 and c=0. Then what is a supposed to be? a would have to be .5 in order to satisfy that equation, but a is by definition either a 0 or 1. The last equation works though. Nice! –  Jul 08 '13 at 22:46
  • @kbball. Yes I think it has problems, but maybe the case of $x=y$ should be $x+y \neq 1$ and maybe that idea could work. This is based on your idea in the question of using $x+y=1$ for $x \neq y.$ Then it would be $a+b+c\neq 1$. – coffeemath Jul 08 '13 at 23:07
  • I found another way to describe a=b∨c. Try the inequality -2 ≤ 2b+2c-4a ≤ 1. –  Jul 11 '13 at 20:05
  • @kball This last inequality seems OK but since the middle must be even, the right side could be replaced by $0$. – coffeemath Jul 11 '13 at 23:55