Beispiel #1
0
 def btestComplexityVer2(self):
     """Test more complex formulare"""
     formulare = toPnf("| R p2 p1 & p2 p3")
     alphabet = returnAlphabet()
     testAutomat = automat(formulare, alphabet)
     liste = calcEdges(testAutomat.transitionsTable)
     testcase = [ele.split(" ") for ele in testAutomat.printStart]
     for index, ele in enumerate(testcase):
         testcase[index] = frozenset(ele)
     setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
     for ele in setAtom:
         print(setAtom[ele])
         setAtom[ele] = set(setAtom[ele].split(" "))
     self.assertEqual(testAutomat.printState, {"p1", "p2", "R p2 p1", "p3"})
     self.assertEqual(testAutomat.printGoal, {"tt", "R p2 p1"})
     self.assertEqual(
         set(testcase),
         {frozenset({'R', 'p2', 'p1'}),
          frozenset({'p3', '&', 'p2'})})
     self.assertEqual(
         set(setAtom), {
             ("p1", "tt"): {'p1'},
             ("p2", "tt"): {'p2'},
             ("p3", "tt"): {'p3'},
             ("R p1 p2", "tt"): {'p1', '&', 'p2'},
             ("R p1 p2", "R p1 p2"): {'p1'}
         })
Beispiel #2
0
 def testOr(self):
     """Test for two elements which are interwinded by OR operator"""
     formulare = toPnf('| p1 p2')
     alphabet = returnAlphabet()
     testAutomat = automat(formulare, alphabet)
     liste = calcEdges(testAutomat.transitionsTable)
     setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
     self.assertEqual(testAutomat.printState, {"p1", "p2"})
     self.assertEqual(testAutomat.printGoal, {"tt"})
     self.assertEqual(testAutomat.printStart, {"p1", "p2"})
     self.assertEqual(setAtom, {("p1", "tt"): "p1", ("p2", "tt"): "p2"})
Beispiel #3
0
 def testNegation(self):
     """test case with one element."""
     formulare = toPnf('! p')
     alphabet = returnAlphabet()
     testAutomat = automat(formulare, alphabet)
     liste = calcEdges(testAutomat.transitionsTable)
     setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
     self.assertEqual(testAutomat.printState, {"p"})
     self.assertEqual(testAutomat.printGoal, {"tt"})
     self.assertEqual(testAutomat.printStart, {"p"})
     self.assertEqual(setAtom, {("p", "tt"): "p"})
Beispiel #4
0
 def testAnd(self):
     """Test for two elements which are interwinded by AND operator"""
     formulare = toPnf('& p1 p2')
     alphabet = returnAlphabet()
     testAutomat = automat(formulare, alphabet)
     liste = calcEdges(testAutomat.transitionsTable)
     testcase = [ele.split(" ") for ele in testAutomat.printStart]
     for index, ele in enumerate(testcase):
         testcase[index] = set(ele)
     setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
     self.assertEqual(testAutomat.printState, {"p1", "p2"})
     self.assertEqual(testAutomat.printGoal, {"tt"})
     self.assertEqual(testcase, [{"&", "p1", "p2"}])
     self.assertEqual(setAtom, {("p1", "tt"): "p1", ("p2", "tt"): "p2"})
Beispiel #5
0
 def testRelease(self):
     """Test for two elements which are interwinded by RELEASE operator"""
     formulare = toPnf("R p1 p2")
     alphabet = returnAlphabet()
     testAutomat = automat(formulare, alphabet)
     liste = calcEdges(testAutomat.transitionsTable)
     setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
     self.assertEqual(testAutomat.printState, {"p1", "p2", "R p1 p2"})
     self.assertEqual(testAutomat.printGoal, {"tt", "R p1 p2"})
     self.assertEqual(testAutomat.printStart, {"R p1 p2"})
     for x in setAtom:
         if x == ("R p1 p2", "tt") and setAtom[("R p1 p2",
                                                "tt")] == "p2 & p1":
             setAtom.update({("R p1 p2", "tt"): "p1 & p2"})
     self.assertEqual(
         setAtom, {
             ("p1", "tt"): "p1",
             ("p2", "tt"): "p2",
             ("R p1 p2", "tt"): "p1 & p2",
             ("R p1 p2", "R p1 p2"): "p2"
         })
Beispiel #6
0
 def testComplexityVer3(self):
     """Test more complex formulare"""
     formulare = toPnf("& p1 U p1 | p2 p3")
     alphabet = returnAlphabet()
     testAutomat = automat(formulare, alphabet)
     liste = calcEdges(testAutomat.transitionsTable)
     setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
     for ele in setAtom:
         setAtom[ele] = set(setAtom[ele].split(" "))
     self.assertEqual(testAutomat.printState,
                      {"p1", "p2", "U p1 | p2 p3", "p3"})
     self.assertEqual(testAutomat.printGoal, {"tt"})
     self.assertEqual(testAutomat.printStart, {"& p1 U p1 | p2 p3"})
     self.assertEqual(
         setAtom, {
             ("p1", "tt"): {'p1'},
             ("p2", "tt"): {'p2'},
             ("p3", "tt"): {'p3'},
             ("U p1 | p2 p3", "tt"): {'p2', '|', 'p3'},
             ("U p1 | p2 p3", "U p1 | p2 p3"): {'p1'}
         })
Beispiel #7
0
    def testComplexityVer1(self):
        """Test more complex formulare"""
        formulare = toPnf("| R p2 p1 p3")
        alphabet = returnAlphabet()
        testAutomat = automat(formulare, alphabet)
        liste = calcEdges(testAutomat.transitionsTable)
        setAtom = setLabels(liste, len(liste), testAutomat.alphabet)
        self.assertEqual(testAutomat.printState, {"p1", "p2", "R p2 p1", "p3"})
        self.assertEqual(testAutomat.printGoal, {"tt", "R p2 p1"})
        self.assertEqual(testAutomat.printStart, {"R p2 p1", "p3"})
        for x in setAtom:
            if x == ("R p2 p1", "tt") and setAtom[("R p2 p1",
                                                   "tt")] == "p2 & p1":
                setAtom.update({("R p2 p1", "tt"): "p1 & p2"})

        self.assertEqual(
            setAtom, {
                ("p1", "tt"): "p1",
                ("p2", "tt"): "p2",
                ("p3", "tt"): "p3",
                ("R p2 p1", "tt"): "p1 & p2",
                ("R p2 p1", "R p2 p1"): "p1"
            })
Beispiel #8
0
"""
from LTL.tools.getInp import getInp
from LTL.tools.toPnfObjects import toPnf
from LTL.tools.toPnfObjects import returnAlphabet
from LTL.tools.omegaAutomaton import automat
from LTL.tools.omegaAutomaton import writeAutomaton
from LTL.tests.testMain import testMain
from LTL.tools.toGraphViz import toGraph
from LTL.tools.toGraphViz import calcEdges
from LTL.tools.tableauDecision import def17

if __name__ == "__main__":
    inp = getInp()
    formulare = inp[0]

    testMain()  # call testCases

    file_automat = inp[2]

    objects = toPnf(formulare)  # reform formulare to objects.

    alphabet = returnAlphabet()  # get all atoms of object formel
    omegaAutomaton = automat(objects, alphabet)

    writeAutomaton(file_automat, objects, omegaAutomaton)

    liste = calcEdges(omegaAutomaton.transitionsTable)
    toGraph(liste, omegaAutomaton.printGoal, omegaAutomaton.start,
            omegaAutomaton.alphabet)
    def17(objects, True)
Beispiel #9
0
    # 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
    # (derivatives(objects, inp[1])) # inp[1] gives x to the function
    # testMain()