示例#1
0
            line = re.sub(' +', ' ', line)
            line = re.sub('\t', ' ', line).strip()
            a, b = line.split(' ')

            # Build mapping
            name_to_c[a] = b
            c_to_name[b] = a

    return name_to_c, c_to_name

if __name__ == "__main__":
    s1 = MealyState('s1')
    s2 = MealyState('s2')
    s3 = MealyState('s3')

    s1.add_edge('a', 'nice', s2)
    s1.add_edge('b', 'a', s1)
    s2.add_edge('a', 'nice', s3)
    s2.add_edge('b', 'back_lol', s1)
    s3.add_edge('a', 'b', s3)
    s3.add_edge('b', 'c', s1)

    mm = MealyMachine(s1)

    constrpath = '/home/tom/projects/lstar/rers/TrainingSeqLtlRers2020/Problem1/constraints-Problem1.txt'
    mappingpath= '/home/tom/projects/lstar/rers/TrainingSeqLtlRers2020/Problem1/Problem1_alphabet_mapping_C_version.txt'

    mealy_lines = mealy2nusmv_withintermediate(mm)
    ltl_lines = rersltl2smv_withintermediate(constrpath, mappingpath)

    with open('test.smv', 'w') as file:
示例#2
0
文件: genfig.py 项目: TCatshoek/lstar
from suls.mealymachine import MealyMachine
from suls.mealymachine import MealyState as State
from util.mealy2nusmv import mealy2nusmv_withintermediate
q0 = State('q0')
q1 = State('q1')

q0.add_edge('a', 'A', q1)

mm = MealyMachine(q0)

for line in mealy2nusmv_withintermediate(mm):
    print(line, end='')
示例#3
0
                    if len(cur) < self.m:
                        for a in A:
                            if access_sequence + cur + a not in self.sul.invalid_cache:
                                to_visit.append(cur + a)

            return equivalent, counterexample


if __name__ == "__main__":
    s1 = MealyState('1')
    s2 = MealyState('2')
    s3 = MealyState('3')
    s4 = MealyState('4')
    s5 = MealyState('5')

    s1.add_edge('a', 'nice', s2)
    s1.add_edge('b', 'nice', s3)

    s2.add_edge('a', 'nice!', s4)
    s2.add_edge('b', 'back', s1)

    s3.add_edge('a', 'nice', s4)
    s3.add_edge('b', 'back', s1)

    s4.add_edge('a', 'nice', s5)
    s4.add_edge('b', 'nice', s5)

    s5.add_edge('a', 'loop', s5)
    s5.add_edge('b', 'loop', s5)

    mm = MealyMachine(s1)
示例#4
0
import tempfile

from equivalencecheckers.bruteforce import BFEquivalenceChecker
from equivalencecheckers.wmethod import WmethodEquivalenceChecker
from learners.mealylearner import MealyLearner
from suls.mealymachine import MealyState, MealyMachine
from teachers.teacher import Teacher

# Set up an example mealy machine
s1 = MealyState('1')
s2 = MealyState('2')
s3 = MealyState('3')

s1.add_edge('a', 'nice', s2)
s1.add_edge('b', 'B', s1)
s2.add_edge('a', 'nice', s3)
s2.add_edge('b', 'back', s1)
s3.add_edge('a', 'A', s3)
s3.add_edge('b', 'back', s1)

mm = MealyMachine(s1)
mm.render_graph(tempfile.mktemp('.gv'))

# Use the W method equivalence checker
eqc = WmethodEquivalenceChecker(mm)

teacher = Teacher(mm, eqc)

# We are learning a mealy machine
learner = MealyLearner(teacher)
示例#5
0
        print("Not reached", reachable - reached)
        print("Falsely reached", reached - reachable)
        return False
    else:
        print("Reached everything!")
        return True


if __name__ == '__main__':
    s1 = MealyState('1')
    s2 = MealyState('2')
    s3 = MealyState('3')
    s4 = MealyState('4')
    s5 = MealyState('5')

    s1.add_edge('a', 'nice', s2)
    s1.add_edge('b', 'nice', s3)

    s2.add_edge('a', 'nice!', s4)
    s2.add_edge('b', 'back', s1)

    s3.add_edge('a', 'nice', s4)
    s3.add_edge('b', 'back', s1)

    s4.add_edge('a', 'nice', s5)
    s4.add_edge('b', 'nice', s5)

    s5.add_edge('a', 'error_10', s5)
    s5.add_edge('b', 'error_10', s5)

    mm = MealyMachine(s1)
示例#6
0
from suls.mealymachine import MealyState, MealyMachine

s1 = MealyState('q0')
s2 = MealyState('q1')
s3 = MealyState('q2')

s1.add_edge('a', '1', s2)
s1.add_edge('b', '0', s1)
s2.add_edge('b', '2', s3)
s2.add_edge('a', '0', s2)
s3.add_edge('a', '3', s3)
s3.add_edge('b', '3', s3)

dfa = MealyMachine(s1)

dfa.render_graph('example_mealy', format='png')