Exemplo n.º 1
0
def test_bool_equal():
    """
    Test working of bool_equal function.
    """

    minterms = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 1, 1]]
    from sympy.abc import a, b, c, x, y, z

    assert bool_equal(Not(Not(a)), a)
    assert bool_equal(SOPform(["w", "x", "y", "z"], minterms), POSform(["w", "x", "y", "z"], minterms))
    assert bool_equal(SOPform(["x", "z", "y"], [[1, 0, 1]]), SOPform(["a", "b", "c"], [[1, 0, 1]])) != False
    function1 = SOPform(["x", "z", "y"], [[1, 0, 1], [0, 0, 1]])
    function2 = SOPform(["a", "b", "c"], [[1, 0, 1], [1, 0, 0]])
    assert bool_equal(function1, function2, info=True) == (function1, {y: a, z: b})
Exemplo n.º 2
0
def test_bool_equal():
    """
    Test working of bool_equal function.
    """

    minterms = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1],
        [1, 1, 1, 1]]
    from sympy.abc import a, b, c, x, y, z
    assert bool_equal(Not(Not(a)), a)
    assert bool_equal(SOPform(['w', 'x', 'y', 'z'], minterms),
        POSform(['w', 'x', 'y', 'z'], minterms))
    assert bool_equal(SOPform(['x', 'z', 'y'],[[1, 0, 1]]),
        SOPform(['a', 'b', 'c'],[[1, 0, 1]])) != False
    function1 = SOPform(['x','z','y'],[[1, 0, 1], [0, 0, 1]])
    function2 = SOPform(['a','b','c'],[[1, 0, 1], [1, 0, 0]])
    assert bool_equal(function1, function2, info=True) == \
        (function1, {y: a, z: b})
Exemplo n.º 3
0
from sympy import *
from sympy.logic.boolalg import bool_equal, simplify_logic

a, b, c, d, e = symbols("a b c d e")

f = (b & ~a) | (a & ~b)
g = (a | b) & ~(a & b)

print(f)
print(g)
print(bool_equal(f, g))
print

f = (~(a | b) & ~(c | d | e)) | ~(a | b)

print(f)
print(simplify_logic(f))
print

f = (a | b) & (d | ~b) & (d | a)

print(f)
print(simplify_logic(f))
print