Jupyter Snippet CB2nd 06_logic
Jupyter Snippet CB2nd 06_logic
15.6. Finding a Boolean propositional formula from a truth table
from sympy import *
init_printing()
var('x y z')
P = x & (y | ~z)
P
P.subs({x: True, y: False, z: True})
minterms = [[1, 0, 1], [1, 0, 0], [0, 0, 0]]
dontcare = [[1, 1, 1], [1, 1, 0]]
Q = SOPform(['x', 'y', 'z'], minterms, dontcare)
Q
Q.subs({x: True, y: False, z: False}), Q.subs(
{x: False, y: True, z: True})