예제 #1
0
 def testCaseFormula(self):
     objects = toPnf('p1')
     derF = derivatives(objects, '{p1}')
     solution = []
     for x in derF:
         solution.append(x.getName())
     self.assertEqual(solution, ['tt'])
예제 #2
0
 def testCaseTrue(self):
     objects = toPnf('tt')
     derTT = derivatives(objects, 'tt')
     solution = []
     for x in derTT:
         solution.append(x.getName())
     self.assertEqual(solution, ['tt'])
예제 #3
0
파일: testDef10Ex.py 프로젝트: JuAbels/LTL
 def testEx2(self):
     objects = toPnf('F p1')
     derCaseAnd = derivatives(objects, '{p1}')
     solution = []
     for x in derCaseAnd:
         solution.append(x.getName())
     self.assertEqual(len(solution), 2)
예제 #4
0
파일: pdMedium2.py 프로젝트: JuAbels/LTL
 def testX1(self):
     """X R q p & a b"""
     pd = derivatives(toPnf('X R q p & a b'), "{tt}")
     self.assertEqual(len(pd), 1)
     solu = set()
     for x in pd:
         solu.add(x.getName())
     self.assertEqual(solu, {'R'})
예제 #5
0
파일: pdMedium2.py 프로젝트: JuAbels/LTL
 def testOr2(self):
     """| U q p | a b"""
     pd = derivatives(toPnf('| U q p | a b'), "{a, p, b}")
     self.assertEqual(len(pd), 3)
     solu = set()
     for x in pd:
         solu.add(x.getName())
     self.assertEqual(solu, {'tt'})
예제 #6
0
파일: pdMedium2.py 프로젝트: JuAbels/LTL
    def testRelease3(self):
        pd = derivatives(toPnf('R | q1 p2 p3'), "{p3, q1}")
        solu = set()
        for x in pd:
            solu.add(x.getName())
        self.assertEqual({'R', 'tt'}, solu)

        self.assertEqual(len(pd), 2)
예제 #7
0
파일: pdMedium1.py 프로젝트: JuAbels/LTL
 def testPDMedium2(self):
     pd = derivatives(toPnf('& p2 | p1 p3'), "{p2}")
     solu = set()
     for x in pd:
         solu.add(x.getName())
         solu.add(x.getFirst().getName())
         solu.add(x.getSec().getName())
     self.assertEqual(solu, set())
예제 #8
0
파일: testDef10Ex.py 프로젝트: JuAbels/LTL
 def testNotEx1(self):
     objects = toPnf('G F p1')
     derCaseAnd = derivatives(objects, '{x}')
     solution = []
     for x in derCaseAnd:
         solution.append(x.getName())
     self.assertEqual(len(solution), 1)
     self.assertEqual(solution[0], '&')
예제 #9
0
파일: pdMedium1.py 프로젝트: JuAbels/LTL
 def testPDMedium4(self):
     pd = derivatives(toPnf('& p2 | p3 U p4 p2'), "{p3, p2}")
     self.assertEqual(len(pd), 2)
     solu = set()
     for x in pd:
         solu.add(x.getName())
         solu.add(x.getFirst().getName())
         solu.add(x.getSec().getName())
     self.assertEqual(solu, {'&', 'tt'})
예제 #10
0
 def testCaseOne(self):
     objects = toPnf('& p1 p2')
     derCaseAnd = derivatives(objects, '{p1, p2}')
     solution = []
     for x in derCaseAnd:
         solution.append(x.getName())
         solution.append(x.getFirst().getName())
         solution.append(x.getSec().getName())
     self.assertEqual(solution, ['&', 'tt', 'tt'])
예제 #11
0
파일: pdMedium1.py 프로젝트: JuAbels/LTL
 def testPDMedium(self):
     pd = derivatives(toPnf('p2'), "{p2}")
     solu = set()
     for x in pd:
         solu.add(x.getName())
     self.assertEqual({'tt'}, solu)
     pd = derivatives(toPnf('& p2 p3'), "{p2, p3}")
     solu = set()
     for x in pd:
         solu.add(x.getName())
         solu.add(x.getFirst().getName())
         solu.add(x.getSec().getName())
     self.assertEqual({'&', 'tt'}, solu)
     pd = derivatives(toPnf('& p2 | p1 p3'), "{p2, p1, p3}")
     solu = set()
     for x in pd:
         solu.add(x.getName())
         solu.add(x.getFirst().getName())
         solu.add(x.getSec().getName())
     self.assertEqual(solu, {'&', 'tt'})
예제 #12
0
def test10ex1():
    """
    >>> from LTL.tests.testDef10ExDoc import test10ex1
    >>> test10ex1()
    True
    True

    """
    objects = toPnf('G F p1')
    derCaseAnd = derivatives(objects, '{p1}')
    solution = []
    for x in derCaseAnd:
        solution.append(x.getName())
    helper = (len(solution) == 2)
    helper2 = (solution[1] == '&')
    if helper is True and helper2 is True:
        return True
예제 #13
0
def setTable(state, setAtom):
    """
    Function to compute table for graph.

    states: all states of automaton.
    return: Matrix with 1 and 0, where 1 means there exists a path from the
            start state to the other states.
            Futhermore, the first line has the order of the statuses. Thereby
            first position is the status of the second list etc.
    """
    dictionary = {}  # End Matrix
    for i in state:
        trans = derivatives(i, setAtom)  # calculate translation for state
        trans = [stringName(i) for i in trans]
        key = stringName(i)
        dictionary[key] = trans
    dictionary.pop('tt', None)
    return dictionary
예제 #14
0
 def testCaseAndEmpty(self):
     objects = toPnf('& p1 p2')
     derCaseAnd = derivatives(objects, 'x')
     self.assertEqual(derCaseAnd, set())
예제 #15
0
 def testCaseFormulaInvalid(self):
     objects = toPnf('p1')
     derFNot = derivatives(objects, 'n')
     self.assertEqual(derFNot, set())
예제 #16
0
파일: mainDemo.py 프로젝트: JuAbels/LTL
    objects = toPnf('& p2 | p3 U p4 p2')  # formulare)  # objects to PNF for LF
    # objectss = toPnf('& R p2 X p3 U p1 p3')
    # objects = toPnf('R q1 p')#formulare)  # objects to PNF for LF

    # print(lin1)
    # print(lin2)
    """for x in lin2:
        for z in x:
            if type(z) != frozenset:
                print(z.getName())
            else:
                for y in z:
                    print(y.getName())"""
    # linFac = lf(objects)  # Formel to linear Factors
    derivatives(objects, inp[1])  # inp[1] gives x to the function
    # testMain()

    states, transition, start, goals = automat(objects)
    matrix = setTable(objects, states)
    setGoal = goals
    states, transition, start, goals = printAutomaton(objects, states,
                                                      transition, start,
                                                      setGoal)
    nodes = matrix[0]
    liste = calcEdges(matrix)
    start = Automaton(objects).setStart()
    toGraph(nodes, liste, goals, start)
    print("test")
    # toGraph()
    # linFac = lf(objects)  # Formel to linear Factors