示例#1
0
def test_solver_constrained_unsatisfiable():
    domain = SignDomain(["a", "b", "c"])
    state = SignAbstractState({
        "a": Sign.Positive,
        "b": Sign.Negative,
        "c": Sign.Bottom
    })
    solution = domain.model(domain.gamma_hat(state))

    assert solution is None
示例#2
0
def test_solver_constrained_satisfiable():
    domain = SignDomain(["a", "b", "c"])
    state = SignAbstractState({
        "a": Sign.Positive,
        "b": Sign.Negative,
        "c": Sign.Positive
    })
    solution = domain.model(domain.gamma_hat(state))

    assert solution is not None

    assert solution.value_of("a") > 0
    assert solution.value_of("b") < 0
    assert solution.value_of("c") > 0
示例#3
0
def test_RSY_post_hat_add_subtract():
    """Here, we add the knowledge of the input state
    """
    domain = SignDomain(["x", "x'", "x''"])

    x = domain.z3_variable("x")
    xp = domain.z3_variable("x'")
    xpp = domain.z3_variable("x''")

    phi = z3.And(xp == x - 5, xpp == xp + 5)

    # This is where we add our supposition about the input
    state = SignAbstractState({
        "x": Sign.Positive,
        "x'": Sign.Top,
        "x''": Sign.Top
    })
    phi = z3.And(domain.gamma_hat(state), phi)

    post_hat = RSY(domain, phi)

    assert post_hat.sign_of("x") == Sign.Positive
    assert post_hat.sign_of("x'") == Sign.Top
    assert post_hat.sign_of("x''") == Sign.Positive