Ejemplo n.º 1
0
def _conform2acw(initial_nodes, rejecting_nodes, nodes, vars):
    """ Modify 'incorrect' transitions:
        label->[set1,set2] modified to label->[set3], where set3=set1+set2
    """
    new_name_to_node = {}
    for n in nodes:
        new_node = get_add(new_name_to_node, n.name, Node(n.name))

        lbl_to_flagged_nodes = {}

        lbl_dst_set_pairs = [(lbl, _flatten(list_of_sets))
                             for lbl, list_of_sets in n.transitions.items()]
        for pattern_lbl, old_dst_nodes in lbl_dst_set_pairs:
            new_dst_nodes = _get_create_new_nodes(new_name_to_node,
                                                  old_dst_nodes)

            lbl_nodes = get_add(lbl_to_flagged_nodes, pattern_lbl, set())
            lbl_nodes.update(
                new_dst_nodes
            )  # TODO: determenize, make labels do not intersect

        for lbl, flagged_dst_nodes in lbl_to_flagged_nodes.items():
            new_node.add_transition(lbl, flagged_dst_nodes)

    new_init_nodes = [new_name_to_node[n.name] for n in initial_nodes]
    new_rejecting_nodes = [new_name_to_node[n.name] for n in rejecting_nodes]

    return new_init_nodes, new_rejecting_nodes, list(new_name_to_node.values())
Ejemplo n.º 2
0
def _conform2acw(initial_nodes, rejecting_nodes, nodes, vars):
    """ Modify 'incorrect' transitions:
        label->[set1,set2] modified to label->[set3], where set3=set1+set2
    """
    new_name_to_node = {}
    for n in nodes:
        new_node = get_add(new_name_to_node, n.name, Node(n.name))

        lbl_to_flagged_nodes = {}

        lbl_dst_set_pairs = [(lbl, _flatten(list_of_sets)) for lbl, list_of_sets in n.transitions.items()]
        for pattern_lbl, old_dst_nodes in lbl_dst_set_pairs:
            new_dst_nodes = _get_create_new_nodes(new_name_to_node, old_dst_nodes)

            lbl_nodes = get_add(lbl_to_flagged_nodes, pattern_lbl, set())
            lbl_nodes.update(new_dst_nodes)  # TODO: determenize, make labels do not intersect

        for lbl, flagged_dst_nodes in lbl_to_flagged_nodes.items():
            new_node.add_transition(lbl, flagged_dst_nodes)

    new_init_nodes = [new_name_to_node[n.name] for n in initial_nodes]
    new_rejecting_nodes = [new_name_to_node[n.name] for n in rejecting_nodes]

    return new_init_nodes, new_rejecting_nodes, list(new_name_to_node.values())
Ejemplo n.º 3
0
def _get_create_new_nodes(new_name_to_node, flagged_nodes_set):
    new_nodes = [(get_add(new_name_to_node, fn[0].name,
                          Node(fn[0].name)), fn[1])
                 for fn in flagged_nodes_set]
    return new_nodes
Ejemplo n.º 4
0
def _get_create_new_nodes(new_name_to_node, flagged_nodes_set):
    new_nodes = [(get_add(new_name_to_node, fn[0].name, Node(fn[0].name)), fn[1])
                 for fn in flagged_nodes_set]
    return new_nodes