Exemple #1
0
def main(ltl_text:str, part_text:str, is_moore, dot_file_name, nusmv_file_name, bounds,
         ltl2ucw_converter, underlying_solver,
         logger):
    """:return: is realizable? """

    input_signals, output_signals, spec_property = _get_acacia_spec(ltl_text, part_text, logger)
    if not input_signals or not output_signals or not spec_property:
        return None

    automaton = ltl2ucw_converter.convert(to_expr(spec_property))
    logger.info('spec automaton has {0} states'.format(len(automaton.nodes)))

    models = search(automaton, not is_moore, input_signals, output_signals, bounds, underlying_solver, UFLIA(None))

    assert models is None or len(models) == 1

    model = models[0] if models else None
    is_realizable = model is not None

    logger.info(['unrealizable', 'realizable'][is_realizable])

    if is_realizable:
        dot_model = moore_to_dot(model) if is_moore else to_dot(model)

        if not dot_file_name:
            logger.info(dot_model)
        else:
            _write_out(dot_model, is_moore, 'dot', dot_file_name, logger)

        if nusmv_file_name:
            nusmv_model = to_boolean_nusmv(model, spec_property)
            _write_out(nusmv_model, is_moore, 'smv', nusmv_file_name, logger)

    return is_realizable
Exemple #2
0
def _write_results(dot_files_prefix, is_moore, logger, models):
    for i, lts in enumerate(models):
        if is_moore:
            dot = moore_to_dot(lts)
        else:
            dot = to_dot(lts, [SENDS_NAME, HAS_TOK_NAME])

        if dot_files_prefix is None:
            logger.info(dot)
        else:
            with open(dot_files_prefix + str(i) + '.dot', mode='w') as out:
                out.write(dot)

                logger.info('{type} model is written to {file}'.format(
                    type=['Mealy', 'Moore'][is_moore], file=out.name))
Exemple #3
0
def _write_results(dot_files_prefix, is_moore, logger, models):
    for i, lts in enumerate(models):
        if is_moore:
            dot = moore_to_dot(lts)
        else:
            dot = to_dot(lts, [SENDS_NAME, HAS_TOK_NAME])

        if dot_files_prefix is None:
            logger.info(dot)
        else:
            with open(dot_files_prefix + str(i) + '.dot', mode='w') as out:
                out.write(dot)

                logger.info('{type} model is written to {file}'.format(
                    type=['Mealy', 'Moore'][is_moore],
                    file=out.name))
Exemple #4
0
def main(ltl_text: str, part_text: str, is_moore, dot_file_name,
         nusmv_file_name, bounds, ltl2ucw_converter, underlying_solver,
         logger):
    """:return: is realizable? """

    input_signals, output_signals, spec_property = _get_acacia_spec(
        ltl_text, part_text, logger)
    if not input_signals or not output_signals or not spec_property:
        return None

    automaton = ltl2ucw_converter.convert(to_expr(spec_property))
    logger.info('spec automaton has {0} states'.format(len(automaton.nodes)))

    models = search(automaton, not is_moore, input_signals, output_signals,
                    bounds, underlying_solver, UFLIA(None))

    assert models is None or len(models) == 1

    model = models[0] if models else None
    is_realizable = model is not None

    logger.info(['unrealizable', 'realizable'][is_realizable])

    if is_realizable:
        dot_model = moore_to_dot(model) if is_moore else to_dot(model)

        if not dot_file_name:
            logger.info(dot_model)
        else:
            _write_out(dot_model, is_moore, 'dot', dot_file_name, logger)

        if nusmv_file_name:
            nusmv_model = to_boolean_nusmv(model, spec_property)
            _write_out(nusmv_model, is_moore, 'smv', nusmv_file_name, logger)

    return is_realizable