Skip to main content

Boolean function from incomplete truth table


BooleanFunction in mathematica can convert an input truth table to a Boolean function. It can do so even if the truth table is incomplete. But the interpretation of truth table obtained from such an incomplete truth table is not clear.


For example, let the incomplete truth table be:


A  B  C

0 0 0
0 1 0
1 0 1

The output Boolean function is C=A in this case.


But if the truth table is


A  B  C
0 0 0
0 1 1
1 0 0


Then the output truth table is C= !A & B, instead of C=B


The code for generating Boolean function from first truth tables is as follows:


BooleanFunction[{{False, False}->False,{False,True}->False,{True,False}->True},{A,B}];

For the second truth table, it is


BooleanFunction[{{False, False}->False,{False,True}->True,{True,False}->False},{A,B}];

Can anyone help in giving consistent explanation for above results? The algorithm used in BooleanFunction is not clear.



Answer




Using BooleanMinterms to solve the system:


1st


table1 = {{0, 0} -> 0, {0, 1} -> 0, {1, 0} -> 1};
trueTab1 = Pick[table1, table1[[All, 2]], 1];
boolMin1 = BooleanMinterms[trueTab1[[All, 1]], {a, b}]

(* a && ! b *)

BooleanFunction has a problem here (bug?)


BooleanFunction[table1, {a, b}]

(* a *)

2nd


table2 = {{0, 0} -> 0, {0, 1} -> 1, {1, 0} -> 0};
trueTab2 = Pick[table2, table2[[All, 2]], 1];
boolMin2 = BooleanMinterms[trueTab2[[All, 1]], {a, b}]

(* ! a && b *)

and with BooleanFunction



BooleanFunction[table2, {a, b}]
(* ! a && b *)

addendum


table = {{0, 0} -> 0, {0, 1} -> 1, {1, 0} -> 1};
trueTab = Pick[table, table[[All, 2]], 1]
{{0, 1} -> 1, {1, 0} -> 1}

BooleanMinterms[trueTab[[All, 1]], {a, b}]
(a && ! b) || (! a && b)


This code snippet "trueTab" is very helpful if you have 32 bit or more input.


Comments