使用Python使用布尔表达式查找minterm

2024-09-27 00:20:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用sympy库。我可以用最小项来计算SOP

>>> from sympy.logic import POSform
>>> from sympy import symbols
>>> w, x, y, z = symbols('w x y z')
>>> minterms = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]]
>>> dontcares = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 1]]
>>> POSform([w, x, y, z], minterms, dontcares)
And(Or(Not(w), y), z)

我需要帮助从布尔表达式计算最小项。在


Tags: orandfromimport表达式notsymbolssympy

热门问题