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