예제 #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'}
         })
예제 #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"})
예제 #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"})
예제 #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"})
예제 #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"
         })
예제 #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'}
         })
예제 #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"
            })
예제 #8
0
파일: main.py 프로젝트: JuAbels/LTL
"""
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)
예제 #9
0
파일: mainDemo.py 프로젝트: JuAbels/LTL
    # 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()