2

I just posted How to write boolean expressions as linear equations and asked about a simple example. Here's what we know so far:

Suppose a,b,c,d,e ∈ {0,1}.

  1. if the boolean expression is: a ≠ b, I could use the linear equation a+b=1.

  2. if the boolean expression is: a=b ∧ c. I could describe this expression with: −1 ≤ 2b+2c−4a ≤ 3.

  3. if the boolean expression is: a=b ∨ c, we can use the inequality 2a−1 ≤ b+c ≤ 2a. This expression can also be written as: -2 ≤ 2b+2c-4a ≤ 1.

Now suppose I have a more complicated case, say a = (b $\wedge$ c) $\vee$ (d $\wedge$ e).

Any ideas on how to write this as a linear equation? Is there an algorithm one can use to describe many of these expressions?

Thanks,

KBBALL


Here are two attempts to translate a = (b ∧ c) ∨ (d ∧ e).

1.

-1 $\le$ $(2b+2c)^3$+$(2d+2e)^3$ -65a $\le$ 63

(As some have pointed out, this solution doesn't count because it's not linear)

2.

0 $\le$ b+c+d+e-2a

b+c-a $\le$ 1

d+e-a $\le$ 1

|b-c| + |d-e| + a $\le$ 2

I think that attempt 2 is correct. And I also think that absolute values are allowed in "linear" equations. What do you think?

  • 1
    What about introducing additional variables? In your example, set $a=f\vee g$ with $f=b\wedge c$ and $g=d\wedge e$, then substitute with your basic linear inequality expressions. – ccorn Jul 10 '13 at 22:26
  • As you commented on Hagen's answer, you are happy with several [in]equalities as well. This leads to my proposal above: Introduce variables for the subexpressions that you know how to translate. – ccorn Jul 10 '13 at 23:07
  • @ccorn I actually thought of that myself, and it's one way to approach the problem. But really I'd rather not introduce any new variables. Other ideas? –  Jul 11 '13 at 19:59
  • In many of the inequalities the coefficients of the middle terms are all even. In those cases you may simplify by moving any odd integer bounds toward $0$ and dividing through by $2$. – coffeemath Jul 12 '13 at 00:20
  • 1
    Your version of $a=(b\lor c) \land (d \lor e)$ should give true when all of $a,b,c,d,e$ are $1$, but the middle of the inequality calculates to $4$. Even if you fix this, the case of $b=c=0, d=e=1, a=1$ gives false in the Boolean, but here the middle of the inequality calculates to $0$, which you include in your range. I haven't found a workable inequality for this Boolean. – coffeemath Jul 12 '13 at 10:28
  • @coffeemath Dang. You're right. Back to the drawing board... –  Jul 12 '13 at 16:40
  • @kbball I am interested in a similar problem. Could you please tell me if you have found a solution? Even to write as many inequalities. – triomphe Dec 09 '13 at 03:38
  • @kbball Thanks, I emailed you. Does your method work for any Boolean expression like the one given in the answer below by Hagen? – triomphe Dec 09 '13 at 14:31
  • @triomphe: I don't think so. My "method" was rather ad hoc. I was able only to come up with expressions for particular equations. –  Dec 11 '13 at 20:55

2 Answers2

1

Rewrite the logical proposition in conjunctive normal form and read off the linear constraints: \begin{align} & a \iff (b \wedge c) \vee (d \wedge e) \\ & \left(a \implies (b \wedge c) \vee (d \wedge e)\right) \bigwedge \left((b \wedge c) \vee (d \wedge e) \implies a\right)\\ & \left(\neg a \vee ((b \wedge c) \vee (d \wedge e))\right) \bigwedge \left(\neg((b \wedge c) \vee (d \wedge e)) \vee a\right)\\ & \left(\neg a \vee ((b \vee d) \wedge (b \vee e) \wedge (c \vee d) \wedge (c \vee e))\right) \bigwedge \left((\neg(b \wedge c) \wedge \neg(d \wedge e)) \vee a\right)\\ & \left((\neg a \vee b \vee d) \wedge (\neg a \vee b \vee e) \wedge (\neg a \vee c \vee d) \wedge (\neg a \vee c \vee e))\right) \bigwedge \left((\neg b \vee \neg c) \wedge (\neg d \vee \neg e)) \vee a\right)\\ & (\neg a \vee b \vee d) \bigwedge (\neg a \vee b \vee e) \bigwedge (\neg a \vee c \vee d) \bigwedge (\neg a \vee c \vee e) \bigwedge (\neg b \vee \neg c \vee a) \bigwedge (\neg d \vee \neg e \vee a)\\ & (1- a + b + d \ge 1) \bigwedge (1- a + b + e \ge 1) \bigwedge (1- a + c + d \ge 1) \bigwedge (1- a + c + e \ge 1) \bigwedge (1- b + 1- c + a \ge 1) \bigwedge (1- d + 1- e + a \ge 1)\\ & (a \le b + d) \bigwedge (a \le b + e) \bigwedge (a \le c + d) \bigwedge (a \le c + e) \bigwedge (a \ge b+c-1) \bigwedge (a \ge d+e-1) \end{align}

RobPratt
  • 50,938
1

It is not always possible to find something like $u\le c_1a_1+\ldots + c_na_n\le v$. Consider (with $n\ge 3$) $$ \neg(a_1\land a_2\land \ldots \land a_n)\land \neg (a_1\land \neg a_2\land\neg a_3\land\ldots \land \neg a_n)\land \neg (\neg a_1\land a_2\land\neg a_3\land\ldots \land \neg a_n)$$ Wlog. the coefficient $c_n$ is $\ge 0$. Then $(1,1,\ldots,1)$ must be cut off by $v$, i.e. $c_1+\ldots +c_n>v$. But replacing a single $1$ with a $0$ must yield an expression in $[u,v]$, hence all $c_i$ are positive. On the other hand, we have $0\in[u,v], c_1\notin [u,v]$, $c_2\notin[u,v]$, $c_1+c_2\in[u,v]$. This is a contradiction because $c_1\in[0,c_1+c_2]$.

  • You might be right, but I don't require that the linear equation is of the form that you mentioned. If we can describe a boolean expression with several equations, I'm happy. –  Jul 10 '13 at 22:07
  • As you originally asked for "a" linear [in]equation, I find Hagen's answer is much to the point (and much more interesting than constructing a system of inequalities from your known patterns). – ccorn Jul 10 '13 at 23:16
  • @Hagen von Eitzen. I guess you're right that it's not always possible to find the kind of equations(s) that I want. But in the example I gave, is it possible? –  Jul 11 '13 at 20:01
  • @Hagenvoneitzen Could you explain what is the fundamental reason for this impossibility? Has is something to do with groups and fields? thank you. – triomphe Dec 09 '13 at 03:43