Mathematica doesn't use the usual boolean notation with which circuit designers are familiar.
The plan is to enter boolean expression as
a c d + b d not a + a not b not c (a not c not d + b not c not d)
and produce overbars on the complemented variables. I can't get the overbars to show as code, so I'll use images. A notebook is attached with all the code.
The not is implemented as:
$PreRead =.
$PreRead = (ReplaceAll[#, "not" :> "OverBar@"] &)
Boolean minimization is a Mathematica function, but it uses boolean expressions in the usual logical form. That is foreign to circuit designers.
Here is the minimization converted to engineering format:
boolmin[m_, opts_: "DNF"] :=
Module[{ans},
ans = BooleanMinimize[
m /. {Plus -> Or, Times -> And, OverBar -> Not}, opts];
ans = ans /. {Or -> Plus, And -> Times, Not -> OverBar};
ans /. {a_^_ -> a, _Integer a_ -> a}
]
The engineering format is converted to logical format, minimized, and then converted back to engineering. {a^ -> a, Integer a -> a} is necessary because the expression is arithmetic.
Here it is applied to the expression above:
There are options:
Here is a truth table in engineering format:
variables[
m_] := (Variables[m] /. OverBar -> Variables // Flatten //
DeleteDuplicates // Sort) /. List -> Sequence
truthTable[m_] :=
Module[{mm}, mm := variables[m];
TableForm[
Boole@BooleanTable[{variables[m],
m /. Plus -> Or /. Times -> And /. OverBar -> Not}, {variables[
m]}], TableHeadings -> {None, {mm}}]]
tt = truthTable
Expressions can be checked for truth:
Here are the boolean axioms applied to the above expression:
This particular expression minimizes to the same expression as the default Mathematica minimization but that is an unfortunate choice. In general that is not so.
DANGER!! The opening line in the first attached notebook removes all current work in your notebook. I can't replace the downloaded file with a new file.
Use the corrected version, please. One error found and fixed.
With some tweaking, the boole.nb notebook below resulted. It's pretty robust.
Attachments: