Ejemplo n.º 1
0
def test_history_modifier(create_solver):
    solver = create_solver(False)
    solver.set_opt("incremental", "true")
    solver.set_opt("produce-models", "true")
    bvsort8 = solver.make_sort(ss.sortkinds.BV, 8)

    ts = pono.FunctionalTransitionSystem(solver)
    counter = ts.make_statevar("counter", bvsort8)
    ts.constrain_init(
        ts.make_term(ss.primops.Equal, counter, ts.make_term(0, bvsort8)))
    ts.assign_next(
        counter,
        ts.make_term(ss.primops.BVAdd, counter, ts.make_term(1, bvsort8)))

    hm = pono.HistoryModifier(ts)
    counter_delay_2 = hm.get_hist(counter, 2)

    p = pono.Property(
        solver,
        ts.make_term(ss.primops.BVUlt, counter, ts.make_term(5, bvsort8)))

    bmc = pono.Bmc(p, ts, solver)
    res = bmc.check_until(10)
    assert not res, "should be false"

    witness = bmc.witness()

    checked_at_least_one = False
    for i, m in enumerate(witness):
        if i > 1:
            checked_at_least_one = True
            # checking semantics of history modifier delay
            assert witness[i][counter_delay_2] == witness[i - 2][counter]

    assert checked_at_least_one
Ejemplo n.º 2
0
def test_vcd_trace(create_solver):
    solver = create_solver(False)
    solver.set_opt("incremental", "true")
    solver.set_opt("produce-models", "true")
    bvsort8 = solver.make_sort(ss.sortkinds.BV, 8)
    ts = pono.FunctionalTransitionSystem(solver)
    x = ts.make_statevar('x', bvsort8)
    ts.constrain_init(
        solver.make_term(ss.primops.Equal, x,
                         solver.make_term(0, x.get_sort())))
    ts.assign_next(
        x, ts.make_term(ss.primops.BVAdd, x, solver.make_term(1,
                                                              x.get_sort())))

    prop_term = solver.make_term(ss.primops.BVUle, x,
                                 solver.make_term(9, x.get_sort()))

    prop = pono.Property(solver, prop_term)
    bmc = pono.Bmc(prop, ts, solver)
    res = bmc.check_until(10)
    assert res == False, "res should be false, not just unknown (i.e. None)"

    witness = bmc.witness()

    with tempfile.NamedTemporaryFile() as temp:
        assert os.stat(temp.name).st_size == 0, "Expect file to start empty"
        vcd_printer = pono.VCDWitnessPrinter(ts, witness)
        vcd_printer.dump_trace_to_file(temp.name)
        assert os.stat(temp.name).st_size, "Expect file to be non-empty"
Ejemplo n.º 3
0
def test_bmc(create_solver):
    s = create_solver(False)
    s.set_opt('produce-models', 'true')
    s.set_opt('incremental', 'true')
    prop = build_simple_alu_fts(s)

    bmc = c.Bmc(prop, s)
    res = bmc.check_until(10)

    assert res is None, "BMC shouldn't be able to solve"