Beispiel #1
0
 def __init__(self, action_dict):
     self.raw = action_dict
     self.action = dict()
     for act_name, attrib in action_dict.iteritems():
         cost = attrib[0]
         guard_formula = attrib[1]
         guard_expr = parse_guard(guard_formula)
         label = attrib[2]
         self.action[act_name] = (cost, guard_expr, label)
     self.action['None'] = (0, parse_guard('1'), set()) 
Beispiel #2
0
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