# Convert a Boolean table to a Boolean expression

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}

• You'll want to use BooleanFunction[] instead… Mar 5, 2016 at 13:27
• @J.M. no, i know that i can use BooleanFunction[], but i need to know how to use BooleanMinterms to convert Mar 5, 2016 at 14:50

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}

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!

• but if we check result it's wrong: !a &&!b must give 1 but in the table it's 0 Mar 5, 2016 at 14:58
• @Zineb.l I have made an edit. You are very quick!
– user36273
Mar 5, 2016 at 15:00
• Zineb.l You're welcome.
– user36273
Mar 5, 2016 at 15:10
• we didn't pay attention to an easiest way: BooleanMinterms[{3, 5, 6}, {a, b, c}] where 3,5 and 6 represent the indice of the minterms with an output =1 Mar 29, 2016 at 0:37
• @ Zineb.l You are right, however, you have only 3 pins (inputs). An 8 bit input has 256 rows, then your method becomes more difficult to act, while my method automatically determines "1".
– user36273
Mar 29, 2016 at 12:16

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