Esempio n. 1
0
def test_quantifier_syntax():
    b = BDD()
    [b.add_var(var) for var in ['x', 'y']]
    # constants
    u = b.add_expr('\E x: True')
    assert u == b.true, u
    u = b.add_expr('\E x, y: True')
    assert u == b.true, u
    u = b.add_expr('\E x: False')
    assert u == b.false, u
    u = b.add_expr('\A x: True')
    assert u == b.true, u
    u = b.add_expr('\A x: False')
    assert u == b.false, u
    u = b.add_expr('\A x, y: False')
    assert u == b.false, u
    # variables
    u = b.add_expr('\E x: x')
    assert u == b.true, u
    u = b.add_expr('\A x: x')
    assert u == b.false, u
    u = b.add_expr('\E x, y: x')
    assert u == b.true, u
    u = b.add_expr('\E x, y: y')
    assert u == b.true, u
    u = b.add_expr('\A x: y')
    assert u == b.var('y'), u
    u = b.add_expr('\A x: ! y')
    u_ = b.apply('not', b.var('y'))
    assert u == u_, (u, u_)
Esempio n. 2
0
def test_quantifier_syntax():
    b = BDD()
    [b.add_var(var) for var in ['x', 'y']]
    # constants
    u = b.add_expr('\E x: True')
    assert u == b.true, u
    u = b.add_expr('\E x, y: True')
    assert u == b.true, u
    u = b.add_expr('\E x: False')
    assert u == b.false, u
    u = b.add_expr('\A x: True')
    assert u == b.true, u
    u = b.add_expr('\A x: False')
    assert u == b.false, u
    u = b.add_expr('\A x, y: False')
    assert u == b.false, u
    # variables
    u = b.add_expr('\E x: x')
    assert u == b.true, u
    u = b.add_expr('\A x: x')
    assert u == b.false, u
    u = b.add_expr('\E x, y: x')
    assert u == b.true, u
    u = b.add_expr('\E x, y: y')
    assert u == b.true, u
    u = b.add_expr('\A x: y')
    assert u == b.var('y'), u
    u = b.add_expr('\A x: ! y')
    u_ = b.apply('not', b.var('y'))
    assert u == u_, (u, u_)
Esempio n. 3
0
def test_var():
    b = BDD()
    with nt.assert_raises(AssertionError):
        b.var('x')
    j = b.add_var('x')
    u = b.var('x')
    assert u > 0, u
    level, low, high = b.succ(u)
    assert level == j, (level, j)
    assert low == b.false, low
    assert high == b.true, high