in reply to Logical Equations
Perusing the following may help:
Truth Table Math::BooleanEval generating random thruth-tables Generate a truth table from input string parser for evaluating arbitrarily complex boolean function in a string A "but" operator.
HTH,