Currently, Python is trying to implement the following set of calculations:
If you have any implementation methods or websites that you can refer to, please let me know.
("B" or "D") and("A" or "B" or "C" or "D") and("A" or "B" or "C")
= ("B" or "D") and ("A" or "B" or "C")
= "A" and "D" or "B" or "C" and "D"
I look forward to your kind cooperation.
python
Why don't you use sympy?
>>import sympathy
>>> from sympathy.logic.boolalg import to_cnf, to_dnf
>>> A, B, C, D = sympy.symbols ('A, B, C, D')
>>>expr=(B|D)&(A|B|C|D)&(A|B|C)
>>> to_cnf(expr,simplify=True)
And (Or(A,B,C), Or(B,D))
>>> to_dnf(expr,simplify=True)
Or(And(A,D), And(C,D),B)
http://docs.sympy.org/latest/modules/logic.html
for more information.
© 2024 OneMinuteCode. All rights reserved.