Exemplo n.º 1
0
def check_unreal(
    ltl_text,
    part_text,
    is_moore,
    ltl3ba: LTL3BA,
    solver_factory: Z3SolverFactory,
    min_size,
    max_size,
    ltl3ba_timeout_sec=None,
    opt_level=0,
) -> LTS:
    """
    :raise: subprocess.TimeoutException
    :arg opt_level: Note that opt_level > 0 may introduce unsoundness (returns unrealizable while it is)
    """
    timer = Timer()
    outputs, inputs, expr = parse_acacia_and_build_expr(ltl_text, part_text, ltl3ba, opt_level)

    timer.sec_restart()
    automaton = ltl3ba.convert(expr, timeout=ltl3ba_timeout_sec)  # note no negation
    logging.info("(unreal) automaton size is: %i" % len(automaton.nodes))
    logging.debug("(unreal) automaton (dot) is:\n" + automaton2dot.to_dot(automaton))
    logging.debug("(unreal) automaton translation took (sec): %i" % timer.sec_restart())

    encoder = create_encoder(inputs, outputs, not is_moore, automaton, solver_factory.create())

    model = model_searcher.search(min_size, max_size, encoder)
    logging.debug("(unreal) model_searcher.search took (sec): %i" % timer.sec_restart())

    return model
Exemplo n.º 2
0
def check_real(
    ltl_text, part_text, is_moore, ltl3ba, solver_factory: Z3SolverFactory, min_size, max_size, opt_level=2
) -> LTS:
    """
    :param opt_level: values > 0 introduce incompleteness (but it is sound: if returns REAL, then REAL)
    """
    timer = Timer()
    inputs, outputs, expr = parse_acacia_and_build_expr(ltl_text, part_text, ltl3ba, opt_level)

    timer.sec_restart()
    automaton = ltl3ba.convert(~expr)
    logging.info("(real) automaton size is: %i" % len(automaton.nodes))
    logging.debug("(real) automaton (dot) is:\n" + automaton2dot.to_dot(automaton))
    logging.debug("(real) automaton translation took (sec): %i" % timer.sec_restart())

    encoder = create_encoder(inputs, outputs, is_moore, automaton, solver_factory.create())

    model = model_searcher.search(min_size, max_size, encoder)
    logging.debug("(real) model_searcher.search took (sec): %i" % timer.sec_restart())

    return model