예제 #1
0
def test_add_rules():
    solver = pycvc4.Solver()
    boolean = solver.getBooleanSort()
    integer = solver.getIntegerSort()

    nullTerm = pycvc4.Term(solver)
    start = solver.mkVar(boolean)
    nts = solver.mkVar(boolean)

    g = solver.mkSygusGrammar([], [start])

    g.addRules(start, {solver.mkBoolean(False)})

    #Expecting errors
    with pytest.raises(Exception):
        g.addRules(nullTerm, solver.mkBoolean(False))
    with pytest.raises(Exception):
        g.addRules(start, {nullTerm})
    with pytest.raises(Exception):
        g.addRules(nts, {solver.mkBoolean(False)})
    with pytest.raises(Exception):
        g.addRules(start, {solver.mkReal(0)})
    #Expecting no errors
    solver.synthFun("f", {}, boolean, g)

    #Expecting an error
    with pytest.raises(Exception):
        g.addRules(start, solver.mkBoolean(False))
예제 #2
0
def testAddAnyVariable():
    solver = pycvc4.Solver()
    boolean = solver.getBooleanSort()

    nullTerm = pycvc4.Term(solver)
    x = solver.mkVar(boolean)
    start = solver.mkVar(boolean)
    nts = solver.mkVar(boolean)

    g1 = solver.mkSygusGrammar({x}, {start})
    g2 = solver.mkSygusGrammar({}, {start})

    g1.addAnyVariable(start)
    g1.addAnyVariable(start)
    g2.addAnyVariable(start)

    with pytest.raises(Exception):
        g1.addAnyVariable(nullTerm)
    with pytest.raises(Exception):
        g1.addAnyVariable(nts)

    solver.synthFun("f", {}, boolean, g1)

    with pytest.raises(Exception):
        g1.addAnyVariable(start)
예제 #3
0
def testAddAnyConstant():
    solver = pycvc4.Solver()
    boolean = solver.getBooleanSort()

    nullTerm = pycvc4.Term(solver)
    start = solver.mkVar(boolean)
    nts = solver.mkVar(boolean)

    g = solver.mkSygusGrammar({}, {start})

    g.addAnyConstant(start)
    g.addAnyConstant(start)

    with pytest.raises(Exception):
        g.addAnyConstant(nullTerm)
    with pytest.raises(Exception):
        g.addAnyConstant(nts)

    solver.synthFun("f", {}, boolean, g)

    with pytest.raises(Exception):
        g.addAnyConstant(start)