I am doing some simple Boolean algebra and wanted to perform some calculations in Mathematica but found it doesn't work.

Let us consider the expression:

expr1 = ((b < 0 && A <= AA) || A < AA);
expr2 = ((b < 0 && A == AA) || A < AA);

From our point of view they are the same. Or do we miss a special case?

FullSimplify[{expr1 == expr2}, #] & /@ {A < AA, A > AA, A == AA}

{{True}, {True}, {True}}

Now the problem is Mathematica does not see them as equivalent, in general:

A > 0 && AA > 0]

This does not yield True, but instead expr1 == expr2.

Do we have an error in reasoning?

How can I make Mathematica simplify expr1 to expr2?


2 Answers 2

Equivalent[expr1, expr2] // FullSimplify

(* True*)
  • $\begingroup$ Whats the difference to my code? $\endgroup$
    – Philipp
    Feb 13, 2015 at 17:13
  • 3
    $\begingroup$ @Philipp Equivalent does not mean Equal.It only means that the truth tables for both are the same $\endgroup$ Feb 13, 2015 at 17:19

Just to amplify belisarius comments, let b<0 be x, A < AA be y and A==AA be z,

then your expressions are:

e1 = (x && (y || z)) || z
e2 = (x && y) || z

BooleanMinimize applied to these yields: (x && y) || z

The truth tables can be shown:

Framed@TableForm[BooleanTable[{x, y, z, e1, e2}], 
  TableHeadings -> {None, {x, y, z, e1, e2}}]

enter image description here

And TautologyQ[Equivalent[e1, e2]] yields True.


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.