def buchi_from_ltl(formula,Type): promela_string = run_ltl2ba(formula) symbols = find_symbols(formula) edges = parse_ltl(promela_string) (states, initials, accepts) = find_states(edges) buchi = DiGraph(type=Type, initial=initials, accept=accepts, symbols=symbols) for state in states: buchi.add_node(state) for (ef,et) in edges.keys(): guard_formula = edges[(ef,et)] guard_expr = parse_guard(guard_formula) buchi.add_edge(ef, et, guard=guard_expr, guard_formula=guard_formula) return buchi
def buchi_from_ltl(formula, Type1): promela_string = "never { /* G(goods->Xdepot)&&G(depot->Xgoods)&&(G(!b)&&G(!door||open)) */ accept_init : /* init */ if :: (!goods && !depot && !b && !door) || (!goods && !depot && !b && open) -> goto accept_init :: (!goods && !b && !door) || (!goods && !b && open) -> goto accept_S2 :: (!depot && !b && !door) || (!depot && !b && open) -> goto accept_S3 :: (!b && !door) || (!b && open) -> goto accept_S4 fi;accept_S2 : /* 1 */ if :: (goods && !depot && !b && !door) || (goods && !depot && !b && open) -> goto accept_S3 :: (goods && !b && !door) || (goods && !b && open) -> goto accept_S4 fi;accept_S3 : /* 2 */ if :: (!goods && depot && !b && !door) || (!goods && depot && !b && open) -> goto accept_S2 :: (depot && !b && !door) || (depot && !b && open) -> goto accept_S4 fi;accept_S4 : /* 3 */ if :: (goods && depot && !b && !door) || (goods && depot && !b && open) -> goto accept_S4 fi;}" #promela_string = run_ltl2ba(formula) symbols = find_symbols(formula) edges = parse_ltl(promela_string) (states, initials, accepts) = find_states(edges) buchi = DiGraph(type=Type, initial=initials, accept=accepts, symbols=symbols) for state in states: buchi.add_node(state) for (ef, et) in edges.keys(): guard_formula = edges[(ef, et)] guard_expr = parse_guard(guard_formula) buchi.add_edge(ef, et, guard=guard_expr, guard_formula=guard_formula) return buchi
def buchi_from_ltl(formula, Type): promela_string = run_ltl2ba(formula) symbols = find_symbols(formula) # print "Output from symbols" # print symbols edges = parse_ltl(promela_string) (states, initials, accepts) = find_states(edges) # print "Output from find_states" # print states # print initials # print accepts buchi = DiGraph(type=Type, initial=initials, accept=accepts, symbols=symbols) for state in states: buchi.add_node(state) for (ef, et) in edges.keys(): guard_formula = edges[(ef, et)] guard_expr = parse_guard(guard_formula) buchi.add_edge(ef, et, guard=guard_expr, guard_formula=guard_formula) # write_dot(buchi, "./result.dot") return buchi
agent_task_1 = '[]<>t1&&[]<>t2&&[]<>t3&&[]<>t4&&[]<>t5&&[]<>t6&&[](!b)' agent_task_2 = '[]<>g&&[](!b)&&[](g-><>r)' agent_task_3 = '[]<>m1&&[]<>m2&&[]<>m3&&[]<>m4&&[]<>m5&&[]<>m6&&[](!b)' #couple_task = '[](! door U (open1&&open2))' couple_task = '[](!d U (o1 && o2))' agent_final_task_1 = agent_task_1 + '&&' + couple_task agent_final_task_2 = agent_task_2 agent_final_task_3 = agent_task_3 buchi_1 = buchi_from_ltl(agent_final_task_1, 'hard_buchi') buchi_2 = buchi_from_ltl(agent_final_task_2, 'hard_buchi') buchi_3 = buchi_from_ltl(agent_final_task_3, 'hard_buchi') couple_buchi = buchi_from_ltl(couple_task, 'hard_buchi') couple_task_symbols = find_symbols(couple_task) #print('guard:') #for f in buchi_1.nodes(): # for t in buchi_1.nodes(): # print(f,t,buchi_1.edges[f,t]['guard']) #def build_static(indi_pro,couple_pro): # return new_indi_pro pro_1 = ProdAut(robot_motion_1, buchi_1) pro_1.build_full(couple_task_symbols) #print('nodes:') #for item in pro_1.nodes(): # if item[1] == 'accept_S1': # print(item)