Exemple #1
0
def read_solution_file(env, solution_file_name_str):
    ast_str, error = solution_file_to_AST_str(solution_file_name_str)
    if error:
        print error
    root = str_ast_to_python_ast(ast_str)
    env.solution_root = root
    env.write_solution_nodes_to_env(root)
    if env.solutions and VERBOSE:
        print "learned from solution-file (constants and variables): ", [x for x in env.solutions] 
Exemple #2
0
def run_with_pyb(bfile_name, dir=""):
    # Build b-mch AST
    ast_string = file_to_AST_str("%s%s.mch" % (dir, bfile_name))
    ast_root = str_ast_to_python_ast(ast_string)

    # Get ProB Solution, write to env
    env = Environment()
    env._min_int = -2**31
    env._max_int = 2**31
    ast_str, err = solution_file_to_AST_str("%s%s_values.txt" % (dir, bfile_name))
    assert err==''
    root = str_ast_to_python_ast(ast_str)
    env.solution_root = root
    env.write_solution_nodes_to_env(root)

    # Init B-mch
    #dh = DefinitionHandler(env, remove_defs_and_parse_ast) 
    dh = DefinitionHandler(env, str_ast_to_python_ast)                                       
    dh.repl_defs(ast_root)
    mch = parse_ast(ast_root, env)    
    type_check_root_bmch(ast_root, env, mch) # also checks all included, seen, used and extend 
    #if env.solution_root:
    #    idNodes = find_var_nodes(root.children[0]) 
    #    idNames = [n.idName for n in idNodes]
    #    type_check_predicate(env.solution_root, env, idNames)   
    # side-effect: check properties and invariant 
    print "team-test:calc set up.."
    bstates = set_up_constants(root, env, mch, solution_file_read=True)
    env.state_space.add_state(bstates[0]) 
    print "team-test:calc set init.."
    bstates = exec_initialisation(root, env, mch, solution_file_read=True)
    env.state_space.add_state(bstates[0]) 
    if mch.has_properties_mc:
        print "team-test:eval properties..."
        assert interpret(mch.aPropertiesMachineClause, env)
    if mch.has_invariant_mc:
        print "team-test:eval invariant..."
        assert interpret(mch.aInvariantMachineClause, env)