# 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})
```

8c7dfc0cc772f2ac8670818a8b608905fc901ee5
ipynb
Jupyter Notebook
Chapter15/06_logic.ipynb
PacktPublishing/IPython-Interactive-Computing-and-Visualization-Cookbook-Second-Edition
7c41466113641abf7070f7bd14cc687c19c9c1ea
MIT
2018-03-06T19:38:30.000Z
2022-02-25T06:54:38.000Z
Chapter15/06_logic.ipynb
PacktPublishing/IPython-Interactive-Computing-and-Visualization-Cookbook-Second-Edition
7c41466113641abf7070f7bd14cc687c19c9c1ea
MIT
Chapter15/06_logic.ipynb
PacktPublishing/IPython-Interactive-Computing-and-Visualization-Cookbook-Second-Edition
7c41466113641abf7070f7bd14cc687c19c9c1ea
MIT
2018-02-19T16:11:16.000Z
2022-02-25T06:54:40.000Z
Qwen/Qwen-72B
1. YES
2. YES