Example #1
0
def is_realizable(test):
    spec_status = stripped_non_empty(readfile(test).splitlines())[-1]
    if re.fullmatch('-- *realizable', spec_status):
        return True
    if re.fullmatch('-- *unrealizable', spec_status):
        return False

    assert 0, 'spec status is unknown'
Example #2
0
def is_realizable(test):
    spec_status = stripped_non_empty(readfile(test).splitlines())[-1]
    if re.fullmatch('-- *realizable', spec_status):
        return True
    if re.fullmatch('-- *unrealizable', spec_status):
        return False

    assert 0, 'spec status is unknown'
Example #3
0
def strip_unused_symbols(gff_automaton_text: str) -> str:
    # GOAL may produce automaton
    # whose alphabet contains symbols
    # not used in any transition labels
    # here we remove unused propositions from the alphabet

    lines = gff_automaton_text.splitlines()

    alphabet_start = find(lambda l: '<Alphabet' in l, lines)
    alphabet_end = find(lambda l: '</Alphabet' in l, lines)

    if alphabet_start == -1 or alphabet_end == -1:
        return gff_automaton_text

    trans_start = find(lambda l: '<TransitionSet' in l, lines)
    trans_end = find(lambda l: '</TransitionsSet' in l, lines)

    lbl_lines = list(filter(lambda l: '<Label' in l, lines[trans_start + 1:trans_end]))

    used_labels = set()
    for lbl_line in lbl_lines:
        # <Label>~g ~r</Label>
        #: :type: str
        lbls = lbl_line[lbl_line.find('>') + 1:
                        lbl_line.find('<', lbl_line.find('>'))]
        lbls = stripped_non_empty(lbls.replace('~', '').split())
        used_labels.update(lbls)

    # now construct the result
    result = lines[:alphabet_start + 1]
    for lbl in filter(lambda l: l != 'True', used_labels):
        result.append("        <Proposition>%s</Proposition>" % lbl)

    result += lines[alphabet_end:]

    return '\n'.join(result)