def run_checking_mode(arguments): root, env, parse_object, solution_file_present = startup(arguments) if not isinstance(parse_object, BMachine): # #PREDICATE or #EXPRESSION result = interpret(parse_object.root, env) # eval predicate or expression print result else: assert isinstance(parse_object, BMachine) # 8. typecheck type_check_root_bmch(root, env, parse_object) # also checks all included, seen, used and extend mch = parse_object bstates = set_up_constants(root, env, mch, solution_file_present) # also evals properties if not bstates==[]: result = None for bstate in bstates: env.state_space.add_state(bstate) #if mch.has_properties_mc: # assert interpret(mch.aPropertiesMachineClause, env) init_bstates = exec_initialisation(root, env, mch, solution_file_present) for init_bstate in init_bstates: env.state_space.add_state(init_bstate) if mch.has_invariant_mc: # TODO: why not result=result and interpret ? Add comment or fix code result = interpret(mch.aInvariantMachineClause, env) env.state_space.undo() if mch.has_assertions_mc: interpret(mch.aAssertionsMachineClause, env) env.state_space.undo() return result else: # TODO: dont repeat yourself init_bstates = exec_initialisation(root, env, mch, solution_file_present) for bstate in init_bstates: env.state_space.add_state(bstate) if mch.has_invariant_mc: assert interpret(mch.aInvariantMachineClause, env) if mch.has_assertions_mc: interpret(mch.aAssertionsMachineClause, env) env.state_space.undo() if not init_bstates==[]: env.state_space.add_state(init_bstates[0]) return eval_Invariant(root, env, mch)
def __calc_states_and_print_ui(root, env, mch, solution_file_read): # Schneider Book page 62-64: # The parameters p make the constraints C True # #p.C # Sets St and constants k which meet the constraints c make the properties B True # C => #St,k.B if not env.set_up_done: next_states = set_up_constants(root, env, mch, solution_file_read) if len(next_states)>0: print_set_up_bstates(next_states, mch) return next_states else: # no bstates and no exception: set up to do (e.g no constants) env.set_up_done = True # If C and B is True there should be Variables v which make the Invaraiant I True # B & C => #v.I if not env.init_done: next_states = exec_initialisation(root, env, mch, solution_file_read) if len(next_states)>0: undo_possible = not env.state_space.empty() print_init_bstates(next_states, mch, undo_possible) return next_states else: # no bstates and no exception: no init to do (e.g no variables) env.init_done = True print mch.mch_name," - Invariant:", eval_Invariant(root, env, mch) # TODO: move print to animation_clui if EVAL_CHILD_INVARIANT: bstate = env.state_space.get_state() for bmachine in bstate.bmch_list: if not bmachine is None and not bmachine.mch_name==mch.mch_name : print bmachine.mch_name, " - Invariant:", interpret(bmachine.aInvariantMachineClause, env) bstate_lst = calc_next_states(env, mch) show_ui(env, mch, bstate_lst) next_states = [] for n in bstate_lst: # all other data inside bstate_lst has already been processed by show_ui next_states.append(n.bstate) return next_states