I want to enter a⟺b∨c to Mathematica and to have an answer


I tried some BooleanConvert and such functions but cannot find the right one. How to do it?

This example is taken from here (Mr Pratt's reply):


and this is about the same thing


  • $\begingroup$ Please show the code you have tried and the problems you encountered. $\endgroup$
    – bbgodfrey
    Oct 12, 2021 at 20:56

1 Answer 1


Mathematica treats boolean variables and integers as different types, so I'm not sure that there's a built-in way to do this. But I think the following code, done by replacing the functions Not and Or with other functions that apply on the set {0,1}, will work.

Clear[a, b, c]
expr = Equivalent[a, Or[b, c]]
cnform = BooleanConvert[expr, "CNF"]
linearform = cnform /. {Not -> Function[x, 1 - x], Or -> GreaterEqualThan[1]@*Plus}

(* b + c >= a && a >= b && a >= c *)

This follows the process detailed in the other question: it converts the original expression into conjunctive normal form, and then replaces all instances of Not[x] with 1-x and all instances of Or[args] with Plus[args] >= 1.

  • $\begingroup$ Thank You, it does just what I need. I tested it few times, for example In[7]:= expr = Equivalent[z, Or[Xnor[a,b],Nand[b,c],And[c,a]]] Out[10]:= z >= a && 2 + a >= b + c + z && b + z >= 1 && c + z >= 1 $\endgroup$ Oct 13, 2021 at 10:45
  • $\begingroup$ My pleasure. After another day or two (to let other answers come in), please select the "best answer" by clicking the check mark next to the answer that best resolved your question. This will mark the question as "resolved" in the database. $\endgroup$ Oct 13, 2021 at 11:33
  • $\begingroup$ Ok I will click the check mark in a few days. $\endgroup$ Oct 13, 2021 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.