def test_bdd2expr():
    f = a & b | a & c | b & c
    zero = bdd(BDDNODEZERO)
    one = bdd(BDDNODEONE)
    assert bdd2expr(zero) is EXPRZERO
    assert bdd2expr(one) is EXPRONE
    assert bdd2expr(expr2bdd(f)).equivalent(f)
    assert bdd2expr(expr2bdd(f), conj=True).equivalent(f)
Esempio n. 2
0
def test_bdd2expr():
    ex = bdd2expr(a ^ b ^ c, conj=False)
    assert ex.equivalent(expr("a ^ b ^ c"))
    assert type(ex) is OrOp and ex.depth == 2

    ex = bdd2expr(a ^ b ^ c, conj=True)
    assert ex.equivalent(expr("a ^ b ^ c"))
    assert type(ex) is AndOp and ex.depth == 2
Esempio n. 3
0
def test_bdd2expr():
    ex = bdd2expr(a ^ b ^ c, conj=False)
    assert ex.equivalent(expr("a ^ b ^ c"))
    assert type(ex) is OrOp and ex.depth == 2

    ex = bdd2expr(a ^ b ^ c, conj=True)
    assert ex.equivalent(expr("a ^ b ^ c"))
    assert type(ex) is AndOp and ex.depth == 2
Esempio n. 4
0
def test_ops():
    assert aa | 0 is aa
    assert aa | 1 is BDDONE
    assert 0 | aa is aa
    assert 1 | aa is BDDONE

    assert aa & 0 is BDDZERO
    assert aa & 1 is aa
    assert 0 & aa is BDDZERO
    assert 1 & aa is aa

    assert aa ^ 0 is aa
    assert aa ^ 1 is ~aa

    assert bdd2expr(~aa & bb | aa & ~bb).equivalent(~a & b | a & ~b)
    assert bdd2expr(aa ^ bb).equivalent(Xor(a, b))
def test_ops():
    assert aa | 0 == aa
    assert aa | 1 is BDDONE
    assert 0 | aa == aa
    assert 1 | aa is BDDONE

    assert aa - 0 is BDDONE
    assert aa - 1 == aa
    assert 0 - aa == ~aa
    assert 1 - aa is BDDONE

    assert aa & 0 is BDDZERO
    assert aa & 1 == aa
    assert 0 & aa is BDDZERO
    assert 1 & aa == aa

    assert aa ^ 0 == aa
    assert aa ^ 1 == ~aa

    assert bdd2expr(~aa & bb | aa & ~bb).equivalent(~a & b | a & ~b)
    assert bdd2expr(aa - bb).equivalent(a - b)
    assert bdd2expr(aa ^ bb).equivalent(Xor(a, b))
Esempio n. 6
0
def test_ops():
    assert aa + 0 == aa
    assert aa + 1 is BDDONE
    assert 0 + aa == aa
    assert 1 + aa is BDDONE

    assert aa - 0 is BDDONE
    assert aa - 1 == aa
    assert 0 - aa == -aa
    assert 1 - aa is BDDONE

    assert aa * 0 is BDDZERO
    assert aa * 1 == aa
    assert 0 * aa is BDDZERO
    assert 1 * aa == aa

    assert aa.xor(0) == aa
    assert aa.xor(1) == -aa

    assert bdd2expr(-aa * bb + aa * -bb).equivalent(-a * b + a * -b)
    assert bdd2expr(aa - bb).equivalent(a - b)
    assert bdd2expr(aa.xor(bb)).equivalent(Xor(a, b))
Esempio n. 7
0
def test_bdd2expr():
    assert bdd2expr(a & ~a).is_zero()
    assert bdd2expr(a | ~a).is_one()
    f = a & b | a & c | b & c
    assert bdd2expr(f).equivalent(expr("Majority(a, b, c)"))
    assert bdd2expr(f, conj=True).equivalent(expr("Majority(a, b, c)"))
def test_negate():
    f = a & b | a & c | b & c
    ff = expr2bdd(f)
    assert bdd2expr(~ff).equivalent(~f)
Esempio n. 9
0
def test_negate():
    f = a * b + a * c + b * c
    ff = expr2bdd(f)
    assert bdd2expr(-ff).equivalent(-f)