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')

png

P = x & (y | ~z)
P

png

P.subs({x: True, y: False, z: True})

png

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

png

Q.subs({x: True, y: False, z: False}), Q.subs(
    {x: False, y: True, z: True})

png