1
$\begingroup$

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}
$\endgroup$
2
  • 1
    $\begingroup$ You'll want to use BooleanFunction[] instead… $\endgroup$ Mar 5, 2016 at 13:27
  • $\begingroup$ @J.M. no, i know that i can use BooleanFunction[], but i need to know how to use BooleanMinterms to convert $\endgroup$ Mar 5, 2016 at 14:50

2 Answers 2

1
$\begingroup$
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"}}]

enter image description here

The Mathematica documentation is the best source to learn Mathematica!

$\endgroup$
6
  • $\begingroup$ but if we check result it's wrong: !a &&!b must give 1 but in the table it's 0 $\endgroup$ Mar 5, 2016 at 14:58
  • $\begingroup$ @Zineb.l I have made an edit. You are very quick! $\endgroup$
    – user36273
    Mar 5, 2016 at 15:00
  • $\begingroup$ Zineb.l You're welcome. $\endgroup$
    – user36273
    Mar 5, 2016 at 15:10
  • $\begingroup$ 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 $\endgroup$ Mar 29, 2016 at 0:37
  • 1
    $\begingroup$ @ 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". $\endgroup$
    – user36273
    Mar 29, 2016 at 12:16
1
$\begingroup$

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

$\endgroup$

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.