How do I convert a Boolean table to a Boolean expression using BooleanMinterms
.
For example:
table = {{0, 0, 0} -> 0, {0, 0, 1} -> 0, {0, 1, 0} -> 0, {0, 1, 1} ->
1, {1, 0, 0} -> 0, {1, 0, 1} -> 1, {1, 1, 0} -> 1, {1, 1, 1} -> 0}
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communitytable = {{0, 0, 0} -> 0, {0, 0, 1} -> 0, {0, 1, 0} -> 0, {0, 1, 1} ->
1, {1, 0, 0} -> 0, {1, 0, 1} -> 1, {1, 1, 0} -> 1, {1, 1, 1} -> 0}
tab = Pick[table, table[[All, 2]], 1]
(* {{0, 1, 1} -> 1, {1, 0, 1} -> 1, {1, 1, 0} -> 1} *)
bMin = BooleanMinterms[#, {a, b, c}] &@tab[[All, 1]]
(* (a && b && ! c) || (a && ! b && c) || (! a && b && c) *)
Check the result
TableForm[Reverse@Boole@BooleanTable[{a, b, c, bMin}], TableHeadings -> {None, {a, b, c, "bMin"}}]
The Mathematica documentation is the best source to learn Mathematica!
In addition to the answer above of @rewi there is a direct and simple method
BooleanMinterms[{3, 5, 6}, {a, b, c}]
where 3,5 and 6 represent the order of the minterms with an output =1, you can see the link below for more information on how to extract boolean expressions from truth table using Minterms. http://www.cs.ucr.edu/~ehwang/courses/cs120a/minterms.pdf
BooleanFunction[]
instead… $\endgroup$