コード例 #1
0
 def test_atom(self):
     fsm = self.init_model()
     
     spec = parseArctl("'c1.c = 0'")[0]
     self.assertTrue(checkArctl(fsm, spec))
     
     spec = parseArctl("'c2.c = 1'")[0]
     self.assertFalse(checkArctl(fsm, spec)[0])
コード例 #2
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_fail(self):
     kos = ["", "'test", "A<'test'>H 'q'", "O", "A<'a'>E<'e'>G 'true'",
            "E<'ac'>[A<'ac'>['a' E<'ac'>['b' W 'c'] W 'd'] "
            "U A<'ac'>['e' U 'f']]", "A<'t't'>G 'q'"]
     
     for s in kos:
         with self.assertRaises(ParseException):
             parseArctl(s)
コード例 #3
0
 def test_aax(self):
     fsm = self.init_model()
     
     spec = parseArctl("A<'run = rc1'>X 'c1.c = 1'")[0]
     self.assertTrue(checkArctl(fsm, spec)[0])
     
     spec = parseArctl("A<'run = rc1'>X 'c2.c = 1'")[0]
     self.assertFalse(checkArctl(fsm, spec)[0])
コード例 #4
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_fail(self):
        kos = [
            "", "'test", "A<'test'>H 'q'", "O", "A<'a'>E<'e'>G 'true'",
            "E<'ac'>[A<'ac'>['a' E<'ac'>['b' W 'c'] W 'd'] "
            "U A<'ac'>['e' U 'f']]", "A<'t't'>G 'q'"
        ]

        for s in kos:
            with self.assertRaises(ParseException):
                parseArctl(s)
コード例 #5
0
 def test_x(self):
     fsm = self.init_model()
     
     spec = parseArctl("E<'FALSE'>X 'TRUE'")[0]
     self.assertFalse(checkArctl(fsm, spec)[0])
     
     spec = parseArctl("A<'FALSE'>X 'TRUE'")[0]
     self.assertFalse(checkArctl(fsm, spec)[0])
     
     spec = parseArctl("~E<'FALSE'>X 'TRUE'")[0]
     self.assertTrue(checkArctl(fsm, spec)[0])
コード例 #6
0
ファイル: trace.py プロジェクト: ancailliau/pynusmv
 def do_check(self, arg):
     """
     Check an ARCTL specification on the current FSM.
     usage: check SPEC
     """
     if self.fsm is None:
         print("[ERROR] No FSM read. Use read command before.")
     elif arg == "":
         print("[ERROR] Need a specification.")
     else:
         try:
             spec = parseArctl(arg)[0]
             (res, (wit, (inp, loop))) = checkArctl(self.fsm, spec)
             if res:
                 print("The specification", arg, "is true,",
                       "witnessed by")
                 #print_path(wit, inp, loop)
                     
             else:
                 print("The specification", arg, "is false,",
                       "as shown by")
                 #print_path(wit, inp, loop)
                 
         except PyNuSMVError as e:
             print("[ERROR]", e)
             
         except ParseException as e:
             print("[ERROR]", e)
コード例 #7
0
ファイル: testExplain.py プロジェクト: ankur8931/sdn-nrl
    def test_eag_explain(self):
        fsm = self.init_model()
        self.assertIsNotNone(fsm)

        spec = parseArctl("E<'run = rc1'>G 'c1.c <= 2'")[0]
        specbdd = evalArctl(fsm, spec)

        s = fsm.pick_one_state(specbdd & fsm.init)
        self.assertTrue((specbdd & fsm.init).isnot_false())
        self.assertIsNotNone(s)
        self.assertTrue(s.isnot_false())

        ac = evalStr(fsm, "'run = rc1'")
        phi = evalStr(fsm, "'c1.c <= 2'")

        (path, (inputs, loop)) = explain_eag(fsm, s, ac, phi)

        # loop and inputs are not None: the explanation is an infinite path
        self.assertIsNotNone(inputs)
        self.assertIsNotNone(loop)

        # Check that path contains states of phi and psi
        self.assertTrue(s == path[0])
        for state, inputs in zip(path[::2], path[1::2]):
            self.assertTrue(state <= phi)
            self.assertTrue(inputs <= ac)
        self.assertTrue(path[-1] <= phi)

        # Check that path is a path of fsm
        for s, i, sp in zip(path[::2], path[1::2], path[2::2]):
            self.assertTrue(sp <= fsm.post(s, i))

        # Check that loop is effectively a loop
        self.assertTrue(loop in path)
        self.assertTrue(loop <= fsm.post(path[-1], inputs))
コード例 #8
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_full2(self):
     s = ("A<'past' | 'present'>G (E<'true'>F ('future is now' & 'later')"
          "<-> A<'min'>['past' U 'present' -> 'future'])")
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), AaG)
     self.assertEqual(type(ast.action), Or)
     self.assertEqual(type(ast.action.left), Atom)
     self.assertEqual(ast.action.left.value, "past")
     self.assertEqual(type(ast.action.right), Atom)
     self.assertEqual(ast.action.right.value, "present")
     self.assertEqual(type(ast.child), Iff)
     self.assertEqual(type(ast.child.left), EaF)
     self.assertEqual(type(ast.child.left.action), Atom)
     self.assertEqual(ast.child.left.action.value, "true")
     self.assertEqual(type(ast.child.left.child), And)
     self.assertEqual(type(ast.child.left.child.left), Atom)
     self.assertEqual(ast.child.left.child.left.value, "future is now")
     self.assertEqual(type(ast.child.left.child.right), Atom)
     self.assertEqual(ast.child.left.child.right.value, "later")
     self.assertEqual(type(ast.child.right), AaU)
     self.assertEqual(type(ast.child.right.action), Atom)
     self.assertEqual(ast.child.right.action.value, "min")
     self.assertEqual(type(ast.child.right.left), Atom)
     self.assertEqual(ast.child.right.left.value, "past")
     self.assertEqual(type(ast.child.right.right), Implies)
     self.assertEqual(type(ast.child.right.right.left), Atom)
     self.assertEqual(ast.child.right.right.left.value, "present")
     self.assertEqual(type(ast.child.right.right.right), Atom)
     self.assertEqual(ast.child.right.right.right.value, "future")
コード例 #9
0
ファイル: testExplain.py プロジェクト: ankur8931/sdn-nrl
    def test_eau_explain(self):
        fsm = self.init_model()
        self.assertIsNotNone(fsm)

        spec = parseArctl("E<'TRUE'>['c1.c < 2' U 'c1.c = 2']")[0]
        specbdd = evalArctl(fsm, spec)

        s = fsm.pick_one_state(specbdd & fsm.init)
        self.assertTrue((specbdd & fsm.init).isnot_false())
        self.assertIsNotNone(s)
        self.assertTrue(s.isnot_false())

        ac = evalStr(fsm, "'TRUE'")
        phi = evalStr(fsm, "'c1.c < 2'")
        psi = evalStr(fsm, "'c1.c = 2'")

        path = explain_eau(fsm, s, ac, phi, psi)

        # Check that path contains states of phi and psi
        self.assertTrue(s == path[0])
        for state, inputs in zip(path[::2], path[1::2]):
            self.assertTrue(state <= phi)
            self.assertTrue(inputs <= ac)
        self.assertTrue(path[-1] <= psi)

        # Check that path is a path of fsm
        for s, i, sp in zip(path[::2], path[1::2], path[2::2]):
            self.assertTrue(sp <= fsm.post(s, i))
コード例 #10
0
    def do_check(self, arg):
        """
        Check an ARCTL specification on the current FSM.
        usage: check SPEC
        """
        if self.fsm is None:
            print("[ERROR] No FSM read. Use read command before.")
        elif arg == "":
            print("[ERROR] Need a specification.")
        else:
            try:
                spec = parseArctl(arg)[0]
                (res, (wit, (inp, loop))) = checkArctl(self.fsm, spec)
                if res:
                    print("The specification", arg, "is true,", "witnessed by")
                    #print_path(wit, inp, loop)

                else:
                    print("The specification", arg, "is false,", "as shown by")
                    #print_path(wit, inp, loop)

            except PyNuSMVError as e:
                print("[ERROR]", e)

            except ParseException as e:
                print("[ERROR]", e)
コード例 #11
0
ファイル: testExplain.py プロジェクト: sbusard/pynusmv
    def test_full(self):
        fsm = self.init_model()

        spec = parseArctl("A<'run = rc1'>[" "E<'TRUE'>G 'c1.c < 3' W " "A<'TRUE'>X 'c1.c = 0' ]")[0]

        (result, expl) = checkArctl(fsm, spec, explain_witness, explain_countex)
        self.assertTrue(result)
コード例 #12
0
 def do_check(self, arg):
     """
     Check an ARCTL specification on the current FSM.
     usage: check SPEC
     """
     if self.fsm is None:
         print("[ERROR] No FSM read. Use read command before.")
     elif arg == "":
         print("[ERROR] Need a specification.")
     else:
         try:
             spec = parseArctl(arg)[0]
             (res, wit) = checkArctl(self.fsm, spec,
                                     explain_witness, explain_countex)
             if res:
                 print("The specification", arg, "is true,",
                       "witnessed by")
                 print(xml_representation(self.fsm, wit, spec))
                     
             else:
                 print("The specification", arg, "is false,",
                       "as shown by")
                 print(xml_representation(self.fsm, wit, spec))
                 
         except PyNuSMVError as e:
             print("[ERROR]", e)
             
         except ParseException as e:
             print("[ERROR]", e)
コード例 #13
0
ファイル: testExplain.py プロジェクト: sbusard/pynusmv
    def test_full_finite(self):
        fsm = self.init_finite_model()

        spec = parseArctl("A<'TRUE'>F (~ E<'TRUE'>X 'TRUE')")[0]

        (result, expl) = checkArctl(fsm, spec, explain_witness, explain_countex)
        self.assertTrue(result)
コード例 #14
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_full2(self):
        s = ("A<'past' | 'present'>G (E<'true'>F ('future is now' & 'later')"
             "<-> A<'min'>['past' U 'present' -> 'future'])")
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), AaG)
        self.assertEqual(type(ast.action), Or)
        self.assertEqual(type(ast.action.left), Atom)
        self.assertEqual(ast.action.left.value, "past")
        self.assertEqual(type(ast.action.right), Atom)
        self.assertEqual(ast.action.right.value, "present")
        self.assertEqual(type(ast.child), Iff)
        self.assertEqual(type(ast.child.left), EaF)
        self.assertEqual(type(ast.child.left.action), Atom)
        self.assertEqual(ast.child.left.action.value, "true")
        self.assertEqual(type(ast.child.left.child), And)
        self.assertEqual(type(ast.child.left.child.left), Atom)
        self.assertEqual(ast.child.left.child.left.value, "future is now")
        self.assertEqual(type(ast.child.left.child.right), Atom)
        self.assertEqual(ast.child.left.child.right.value, "later")
        self.assertEqual(type(ast.child.right), AaU)
        self.assertEqual(type(ast.child.right.action), Atom)
        self.assertEqual(ast.child.right.action.value, "min")
        self.assertEqual(type(ast.child.right.left), Atom)
        self.assertEqual(ast.child.right.left.value, "past")
        self.assertEqual(type(ast.child.right.right), Implies)
        self.assertEqual(type(ast.child.right.right.left), Atom)
        self.assertEqual(ast.child.right.right.left.value, "present")
        self.assertEqual(type(ast.child.right.right.right), Atom)
        self.assertEqual(ast.child.right.right.right.value, "future")
コード例 #15
0
ファイル: testExplain.py プロジェクト: ancailliau/pynusmv
 def test_eag_explain(self):
     fsm = self.init_model()
     self.assertIsNotNone(fsm)
     
     spec = parseArctl("E<'run = rc1'>G 'c1.c <= 2'")[0]
     specbdd = evalArctl(fsm, spec)
     
     s = fsm.pick_one_state(specbdd & fsm.init)
     self.assertTrue((specbdd & fsm.init).isnot_false())
     self.assertIsNotNone(s)
     self.assertTrue(s.isnot_false())
     
     ac = evalStr(fsm, "'run = rc1'")
     phi = evalStr(fsm, "'c1.c <= 2'")
     
     (path, (inputs, loop)) = explain_eag(fsm, s, ac, phi)
     
     # loop and inputs are not None: the explanation is an infinite path
     self.assertIsNotNone(inputs)
     self.assertIsNotNone(loop)
     
     # Check that path contains states of phi and psi
     self.assertTrue(s == path[0])
     for state, inputs in zip(path[::2], path[1::2]):
         self.assertTrue(state <= phi)
         self.assertTrue(inputs <= ac)
     self.assertTrue(path[-1] <= phi)
     
     # Check that path is a path of fsm
     for s, i, sp in zip(path[::2], path[1::2], path[2::2]):
         self.assertTrue(sp <= fsm.post(s, i))
         
     # Check that loop is effectively a loop
     self.assertTrue(loop in path)
     self.assertTrue(loop <= fsm.post(path[-1], inputs))
コード例 #16
0
ファイル: testExplain.py プロジェクト: ancailliau/pynusmv
 def test_eau_explain(self):
     fsm = self.init_model()
     self.assertIsNotNone(fsm)
     
     spec = parseArctl("E<'TRUE'>['c1.c < 2' U 'c1.c = 2']")[0]
     specbdd = evalArctl(fsm, spec)
     
     s = fsm.pick_one_state(specbdd & fsm.init)
     self.assertTrue((specbdd & fsm.init).isnot_false())
     self.assertIsNotNone(s)
     self.assertTrue(s.isnot_false())
     
     ac = evalStr(fsm, "'TRUE'")
     phi = evalStr(fsm, "'c1.c < 2'")
     psi = evalStr(fsm, "'c1.c = 2'")
     
     path = explain_eau(fsm, s, ac, phi, psi)
     
     # Check that path contains states of phi and psi
     self.assertTrue(s == path[0])
     for state, inputs in zip(path[::2], path[1::2]):
         self.assertTrue(state <= phi)
         self.assertTrue(inputs <= ac)
     self.assertTrue(path[-1] <= psi)
     
     # Check that path is a path of fsm
     for s, i, sp in zip(path[::2], path[1::2], path[2::2]):
         self.assertTrue(sp <= fsm.post(s, i))
コード例 #17
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_atom(self):
        s = "'c <= 3'"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), Atom)
        self.assertEqual(ast.value, "c <= 3")
コード例 #18
0
ファイル: testExplain.py プロジェクト: ankur8931/sdn-nrl
    def test_full_finite(self):
        fsm = self.init_finite_model()

        spec = parseArctl("A<'TRUE'>F (~ E<'TRUE'>X 'TRUE')")[0]

        (result, expl) = checkArctl(fsm, spec, explain_witness,
                                    explain_countex)
        self.assertTrue(result)
コード例 #19
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_atom(self):
     s = "'c <= 3'"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), Atom)
     self.assertEqual(ast.value, "c <= 3")
コード例 #20
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_not(self):
     s = "~'a'"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), Not)
     self.assertEqual(type(ast.child), Atom)
     self.assertEqual(ast.child.value, "a")
コード例 #21
0
    def test_not(self):
        fsm = self.init_model()

        specs = parseArctl("~'c'")
        self.assertEqual(len(specs), 1)
        spec = specs[0]

        nc = evalArctl(fsm, spec)
        self.assertTrue((nc & fsm.init).is_false())
コード例 #22
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_not(self):
        s = "~'a'"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), Not)
        self.assertEqual(type(ast.child), Atom)
        self.assertEqual(ast.child.value, "a")
コード例 #23
0
ファイル: testEval.py プロジェクト: ancailliau/pynusmv
 def test_not(self):
     fsm = self.init_model()
     
     specs = parseArctl("~'c'")
     self.assertEqual(len(specs), 1)
     spec = specs[0]
     
     nc = evalArctl(fsm, spec)
     self.assertTrue((nc & fsm.init).is_false())
コード例 #24
0
ファイル: testXML.py プロジェクト: ankur8931/sdn-nrl
 def test_full_finite(self):
     fsm = self.init_finite_model()
     
     spec = parseArctl("A<'TRUE'>F (~ E<'TRUE'>X 'TRUE')")[0]
     
     (result, expl) = checkArctl(fsm, spec, explain_witness, explain_countex)
     self.assertTrue(result)
     
     self.assertIsNotNone(xml_representation(fsm, expl, spec))
     print(xml_representation(fsm, expl, spec))
コード例 #25
0
ファイル: testExplain.py プロジェクト: ankur8931/sdn-nrl
    def test_full(self):
        fsm = self.init_model()

        spec = parseArctl("A<'run = rc1'>["
                          "E<'TRUE'>G 'c1.c < 3' W "
                          "A<'TRUE'>X 'c1.c = 0' ]")[0]

        (result, expl) = checkArctl(fsm, spec, explain_witness,
                                    explain_countex)
        self.assertTrue(result)
コード例 #26
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_implies(self):
     s = "'a' -> 'b'"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), Implies)
     self.assertEqual(type(ast.left), Atom)
     self.assertEqual(ast.left.value, "a")
     self.assertEqual(type(ast.right), Atom)
     self.assertEqual(ast.right.value, "b")
コード例 #27
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_implies(self):
        s = "'a' -> 'b'"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), Implies)
        self.assertEqual(type(ast.left), Atom)
        self.assertEqual(ast.left.value, "a")
        self.assertEqual(type(ast.right), Atom)
        self.assertEqual(ast.right.value, "b")
コード例 #28
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_not_eax(self):
        s = "E<'a'>X ~ 'c'"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), EaX)
        self.assertEqual(type(ast.action), Atom)
        self.assertEqual(ast.action.value, "a")
        self.assertEqual(type(ast.child), Not)
        self.assertEqual(type(ast.child.child), Atom)
        self.assertEqual(ast.child.child.value, "c")
コード例 #29
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_not_eax(self):
     s = "E<'a'>X ~ 'c'"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), EaX)
     self.assertEqual(type(ast.action), Atom)
     self.assertEqual(ast.action.value, "a")
     self.assertEqual(type(ast.child), Not)
     self.assertEqual(type(ast.child.child), Atom)
     self.assertEqual(ast.child.child.value, "c")
コード例 #30
0
    def test_atom(self):
        fsm = self.init_model()

        specs = parseArctl("'c'")
        self.assertEqual(len(specs), 1)
        spec = specs[0]
        self.assertEqual(type(spec), Atom)
        self.assertEqual(spec.value, "c")

        c = evalArctl(fsm, spec)
        self.assertIsNotNone(c)
        self.assertTrue(fsm.init <= c)
コード例 #31
0
ファイル: testXML.py プロジェクト: ankur8931/sdn-nrl
 def test_full(self):
     fsm = self.init_model()
     
     spec = parseArctl("A<'run = rc1'>["
                         "E<'TRUE'>G 'c1.c < 3' W "
                         "A<'TRUE'>X 'c1.c = 0' ]")[0]
                         
     (result, expl) = checkArctl(fsm, spec, explain_witness, explain_countex)
     self.assertTrue(result)
     
     self.assertIsNotNone(xml_representation(fsm, expl, spec))
     print(xml_representation(fsm, expl, spec))
コード例 #32
0
ファイル: testEval.py プロジェクト: ancailliau/pynusmv
 def test_atom(self):
     fsm = self.init_model()
     
     specs = parseArctl("'c'")
     self.assertEqual(len(specs), 1)
     spec = specs[0]
     self.assertEqual(type(spec), Atom)
     self.assertEqual(spec.value, "c")
     
     c = evalArctl(fsm, spec)
     self.assertIsNotNone(c)
     self.assertTrue(fsm.init <= c)
コード例 #33
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_eauw(self):
     s = "E<'ac'>[A<'ac'>[E<'ac'>['b' W 'c'] W 'd'] U A<'ac'>['e' U 'f']]"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), EaU)
     self.assertEqual(type(ast.action), Atom)
     self.assertEqual(ast.action.value, "ac")
     self.assertEqual(type(ast.left), AaW)
     self.assertEqual(type(ast.left.action), Atom)
     self.assertEqual(ast.left.action.value, "ac")
     self.assertEqual(type(ast.left.right), Atom)
     self.assertEqual(ast.left.right.value, "d")
コード例 #34
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_and(self):
        s = "'a' & ('b' & 'c')"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), And)
        self.assertEqual(type(ast.left), Atom)
        self.assertEqual(ast.left.value, "a")
        self.assertEqual(type(ast.right), And)
        self.assertEqual(type(ast.right.left), Atom)
        self.assertEqual(ast.right.left.value, "b")
        self.assertEqual(type(ast.right.right), Atom)
        self.assertEqual(ast.right.right.value, "c")
コード例 #35
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_eauw(self):
        s = "E<'ac'>[A<'ac'>[E<'ac'>['b' W 'c'] W 'd'] U A<'ac'>['e' U 'f']]"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), EaU)
        self.assertEqual(type(ast.action), Atom)
        self.assertEqual(ast.action.value, "ac")
        self.assertEqual(type(ast.left), AaW)
        self.assertEqual(type(ast.left.action), Atom)
        self.assertEqual(ast.left.action.value, "ac")
        self.assertEqual(type(ast.left.right), Atom)
        self.assertEqual(ast.left.right.value, "d")
コード例 #36
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_and(self):
     s = "'a' & ('b' & 'c')"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), And)
     self.assertEqual(type(ast.left), Atom)
     self.assertEqual(ast.left.value, "a")
     self.assertEqual(type(ast.right), And)
     self.assertEqual(type(ast.right.left), Atom)
     self.assertEqual(ast.right.left.value, "b")
     self.assertEqual(type(ast.right.right), Atom)
     self.assertEqual(ast.right.right.value, "c")
コード例 #37
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_afnext(self):
        s = "A<'TRUE'>F (~ E<'TRUE'>X 'TRUE')"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), AaF)
        self.assertEqual(type(ast.action), Atom)
        self.assertEqual(ast.action.value, "TRUE")
        self.assertEqual(type(ast.child), Not)
        self.assertEqual(type(ast.child.child), EaX)
        self.assertEqual(type(ast.child.child.action), Atom)
        self.assertEqual(ast.child.child.action.value, "TRUE")
        self.assertEqual(type(ast.child.child.child), Atom)
        self.assertEqual(ast.child.child.child.value, "TRUE")
コード例 #38
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_afnext(self):
     s = "A<'TRUE'>F (~ E<'TRUE'>X 'TRUE')"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), AaF)
     self.assertEqual(type(ast.action), Atom)
     self.assertEqual(ast.action.value, "TRUE")
     self.assertEqual(type(ast.child), Not)
     self.assertEqual(type(ast.child.child), EaX)
     self.assertEqual(type(ast.child.child.action), Atom)
     self.assertEqual(ast.child.child.action.value, "TRUE")
     self.assertEqual(type(ast.child.child.child), Atom)
     self.assertEqual(ast.child.child.child.value, "TRUE")
コード例 #39
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_ef_and(self):
     s = "E<'a'>F 'admin = alice' & E<'b'>F 'admin = bob'"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), And)
     self.assertEqual(type(ast.left), EaF)
     self.assertEqual(type(ast.left.action), Atom)
     self.assertEqual(ast.left.action.value, "a")
     self.assertEqual(type(ast.left.child), Atom)
     self.assertEqual(ast.left.child.value, "admin = alice")
     self.assertEqual(type(ast.right), EaF)
     self.assertEqual(type(ast.right.action), Atom)
     self.assertEqual(ast.right.action.value, "b")
     self.assertEqual(type(ast.right.child), Atom)
     self.assertEqual(ast.right.child.value, "admin = bob")
コード例 #40
0
ファイル: testExplain.py プロジェクト: ancailliau/pynusmv
 def test_explain_atom(self):
     fsm = self.init_model()
     self.assertIsNotNone(fsm)
     
     spec = parseArctl("'c1.c <= 2'")[0]
     specbdd = evalArctl(fsm, spec)
     
     s = fsm.pick_one_state(specbdd & fsm.init)
     self.assertTrue(s.isnot_false())
     
     (path, (inp, loop)) = explain_witness(fsm, s, spec)
     # Check that no loop
     self.assertIsNone(inp)
     self.assertIsNone(loop)
     
     # Check path
     self.assertEqual(path, (s,))
コード例 #41
0
ファイル: testExplain.py プロジェクト: ankur8931/sdn-nrl
    def test_explain_and_atom(self):
        fsm = self.init_model()
        self.assertIsNotNone(fsm)

        spec = parseArctl("'c1.c <= 2' & 'c2.c < 1'")[0]
        specbdd = evalArctl(fsm, spec)

        s = fsm.pick_one_state(specbdd & fsm.init)
        self.assertTrue(s.isnot_false())

        (path, (inp, loop)) = explain_witness(fsm, s, spec)
        # Check that no loop
        self.assertIsNone(inp)
        self.assertIsNone(loop)

        # Check path
        self.assertEqual(path, (s, ))
コード例 #42
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_full(self):
        s = ("A<'past'>G (E<'true'>F 'future is now'"
             "<-> A<'min'>['past' U 'present'])")
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), AaG)
        self.assertEqual(type(ast.action), Atom)
        self.assertEqual(ast.action.value, "past")
        self.assertEqual(type(ast.child), Iff)
        self.assertEqual(type(ast.child.left), EaF)
        self.assertEqual(type(ast.child.left.action), Atom)
        self.assertEqual(ast.child.left.action.value, "true")
        self.assertEqual(type(ast.child.left.child), Atom)
        self.assertEqual(ast.child.left.child.value, "future is now")
        self.assertEqual(type(ast.child.right), AaU)
コード例 #43
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_full(self):
     s = ("A<'past'>G (E<'true'>F 'future is now'"
          "<-> A<'min'>['past' U 'present'])")
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), AaG)
     self.assertEqual(type(ast.action), Atom)
     self.assertEqual(ast.action.value, "past")
     self.assertEqual(type(ast.child), Iff)
     self.assertEqual(type(ast.child.left), EaF)
     self.assertEqual(type(ast.child.left.action), Atom)
     self.assertEqual(ast.child.left.action.value, "true")
     self.assertEqual(type(ast.child.left.child), Atom)
     self.assertEqual(ast.child.left.child.value, "future is now")
     self.assertEqual(type(ast.child.right), AaU)
コード例 #44
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_ef_and(self):
        s = "E<'a'>F 'admin = alice' & E<'b'>F 'admin = bob'"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), And)
        self.assertEqual(type(ast.left), EaF)
        self.assertEqual(type(ast.left.action), Atom)
        self.assertEqual(ast.left.action.value, "a")
        self.assertEqual(type(ast.left.child), Atom)
        self.assertEqual(ast.left.child.value, "admin = alice")
        self.assertEqual(type(ast.right), EaF)
        self.assertEqual(type(ast.right.action), Atom)
        self.assertEqual(ast.right.action.value, "b")
        self.assertEqual(type(ast.right.child), Atom)
        self.assertEqual(ast.right.child.value, "admin = bob")
コード例 #45
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_logicals(self):
     s = "'a' & 'c' -> (~'b' | 'c')"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), Implies)
     self.assertEqual(type(ast.left), And)
     self.assertEqual(type(ast.left.left), Atom)
     self.assertEqual(ast.left.left.value, "a")
     self.assertEqual(type(ast.left.right), Atom)
     self.assertEqual(ast.left.right.value, "c")
     self.assertEqual(type(ast.right), Or)
     self.assertEqual(type(ast.right.left), Not)
     self.assertEqual(type(ast.right.left.child), Atom)
     self.assertEqual(ast.right.left.child.value, "b")
     self.assertEqual(type(ast.right.right), Atom)
     self.assertEqual(ast.right.right.value, "c")
コード例 #46
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_actions(self):
     s = "A<'a' & 'b' | 'c'>F 'b'"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), AaF)
     self.assertEqual(type(ast.action), Or)
     self.assertEqual(type(ast.action.left), And)
     self.assertEqual(type(ast.action.left.left), Atom)
     self.assertEqual(ast.action.left.left.value, "a")
     self.assertEqual(type(ast.action.left.right), Atom)
     self.assertEqual(ast.action.left.right.value, "b")
     self.assertEqual(type(ast.action.right), Atom)
     self.assertEqual(ast.action.right.value, "c")
     
     self.assertEqual(type(ast.child), Atom)
     self.assertEqual(ast.child.value, "b")
コード例 #47
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_logicals(self):
        s = "'a' & 'c' -> (~'b' | 'c')"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), Implies)
        self.assertEqual(type(ast.left), And)
        self.assertEqual(type(ast.left.left), Atom)
        self.assertEqual(ast.left.left.value, "a")
        self.assertEqual(type(ast.left.right), Atom)
        self.assertEqual(ast.left.right.value, "c")
        self.assertEqual(type(ast.right), Or)
        self.assertEqual(type(ast.right.left), Not)
        self.assertEqual(type(ast.right.left.child), Atom)
        self.assertEqual(ast.right.left.child.value, "b")
        self.assertEqual(type(ast.right.right), Atom)
        self.assertEqual(ast.right.right.value, "c")
コード例 #48
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_actions(self):
        s = "A<'a' & 'b' | 'c'>F 'b'"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), AaF)
        self.assertEqual(type(ast.action), Or)
        self.assertEqual(type(ast.action.left), And)
        self.assertEqual(type(ast.action.left.left), Atom)
        self.assertEqual(ast.action.left.left.value, "a")
        self.assertEqual(type(ast.action.left.right), Atom)
        self.assertEqual(ast.action.left.right.value, "b")
        self.assertEqual(type(ast.action.right), Atom)
        self.assertEqual(ast.action.right.value, "c")

        self.assertEqual(type(ast.child), Atom)
        self.assertEqual(ast.child.value, "b")
コード例 #49
0
ファイル: testExplain.py プロジェクト: ankur8931/sdn-nrl
    def test_eax_explain(self):
        fsm = self.init_model()
        self.assertIsNotNone(fsm)

        spec = parseArctl("E<'TRUE'>X 'c1.c = 1'")[0]
        specbdd = evalArctl(fsm, spec)

        s = fsm.pick_one_state(specbdd & fsm.init)
        self.assertIsNotNone(s)

        ac = evalStr(fsm, "'TRUE'")
        phi = evalStr(fsm, "'c1.c = 1'")

        path = explain_eax(fsm, s, ac, phi)

        self.assertTrue(s == path[0])
        self.assertTrue(path[1] <= ac)
        self.assertTrue(path[2] <= phi)
        self.assertTrue(path[2] <= fsm.post(s, path[1]))
コード例 #50
0
ファイル: testExplain.py プロジェクト: ancailliau/pynusmv
 def test_eax_explain(self):
     fsm = self.init_model()
     self.assertIsNotNone(fsm)
     
     spec = parseArctl("E<'TRUE'>X 'c1.c = 1'")[0]
     specbdd = evalArctl(fsm, spec)
     
     s = fsm.pick_one_state(specbdd & fsm.init)
     self.assertIsNotNone(s)
     
     ac = evalStr(fsm, "'TRUE'")
     phi = evalStr(fsm, "'c1.c = 1'")
     
     path = explain_eax(fsm, s, ac, phi)
     
     self.assertTrue(s == path[0])
     self.assertTrue(path[1] <= ac)
     self.assertTrue(path[2] <= phi)
     self.assertTrue(path[2] <= fsm.post(s, path[1]))
コード例 #51
0
ファイル: testParsing.py プロジェクト: ankur8931/sdn-nrl
    def test_x(self):
        s = "E<'a'>X (A<'b'> X 'c' & E<'f'>X E<'g'>X 'h')"
        asts = parseArctl(s)
        self.assertEqual(len(asts), 1)

        ast = asts[0]
        self.assertEqual(type(ast), EaX)
        self.assertEqual(type(ast.action), Atom)
        self.assertEqual(ast.action.value, "a")
        self.assertEqual(type(ast.child), And)
        self.assertEqual(type(ast.child.left), AaX)
        self.assertEqual(type(ast.child.left.action), Atom)
        self.assertEqual(ast.child.left.action.value, "b")
        self.assertEqual(type(ast.child.left.child), Atom)
        self.assertEqual(ast.child.left.child.value, "c")
        self.assertEqual(type(ast.child.right), EaX)
        self.assertEqual(type(ast.child.right.action), Atom)
        self.assertEqual(ast.child.right.action.value, "f")
        self.assertEqual(type(ast.child.right.child), EaX)
        self.assertEqual(type(ast.child.right.child.action), Atom)
        self.assertEqual(ast.child.right.child.action.value, "g")
        self.assertEqual(type(ast.child.right.child.child), Atom)
        self.assertEqual(ast.child.right.child.child.value, "h")
コード例 #52
0
ファイル: testParsing.py プロジェクト: ancailliau/pynusmv
 def test_x(self):
     s = "E<'a'>X (A<'b'> X 'c' & E<'f'>X E<'g'>X 'h')"
     asts = parseArctl(s)
     self.assertEqual(len(asts), 1)
     
     ast = asts[0]
     self.assertEqual(type(ast), EaX)
     self.assertEqual(type(ast.action), Atom)
     self.assertEqual(ast.action.value, "a")
     self.assertEqual(type(ast.child), And)
     self.assertEqual(type(ast.child.left), AaX)
     self.assertEqual(type(ast.child.left.action), Atom)
     self.assertEqual(ast.child.left.action.value, "b")
     self.assertEqual(type(ast.child.left.child), Atom)
     self.assertEqual(ast.child.left.child.value, "c")
     self.assertEqual(type(ast.child.right), EaX)
     self.assertEqual(type(ast.child.right.action), Atom)
     self.assertEqual(ast.child.right.action.value, "f")
     self.assertEqual(type(ast.child.right.child), EaX)
     self.assertEqual(type(ast.child.right.child.action), Atom)
     self.assertEqual(ast.child.right.child.action.value, "g")
     self.assertEqual(type(ast.child.right.child.child), Atom)
     self.assertEqual(ast.child.right.child.child.value, "h")