def test_next_noloop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            i, k = 0, 2
            enc = self.enc
            # One step
            a = ast.Proposition("a")
            formula = ast.Next(a)
            tool = formula.semantic_no_loop(enc, i, k)
            manual = a.semantic_no_loop(enc, 1, k)
            nusmv = ltlspec.bounded_semantics(self.befsm,
                                              Node.from_ptr(
                                                  parse_ltl_spec("X a")),
                                              bound=k,
                                              loop=bmcutils.no_loopback())

            s_tool = tests.canonical_cnf(tool)
            s_manual = tests.canonical_cnf(manual)
            s_nusmv = tests.canonical_cnf(nusmv)

            self.assertEqual(s_tool, s_nusmv)
            self.assertEqual(s_tool, s_manual)

            # two steps
            formula = ast.Next(ast.Next(a))
            tool = formula.semantic_no_loop(enc, i, k)
            manual = a.semantic_no_loop(enc, 2, k)
            nusmv = ltlspec.bounded_semantics(self.befsm,
                                              Node.from_ptr(
                                                  parse_ltl_spec("X X a")),
                                              bound=k,
                                              loop=bmcutils.no_loopback())

            s_tool = tests.canonical_cnf(tool)
            s_manual = tests.canonical_cnf(manual)
            s_nusmv = tests.canonical_cnf(nusmv)

            self.assertEqual(s_tool, s_nusmv)
            self.assertEqual(s_tool, s_manual)

            # Three steps (getting over k)
            formula = ast.Next(ast.Next(ast.Next(a)))
            tool = formula.semantic_no_loop(enc, i, k)
            manual = Be.false(enc.manager)
            nusmv = ltlspec.bounded_semantics(self.befsm,
                                              Node.from_ptr(
                                                  parse_ltl_spec("X X X a")),
                                              bound=k,
                                              loop=bmcutils.no_loopback())

            s_tool = tests.canonical_cnf(tool)
            s_manual = tests.canonical_cnf(manual)
            s_nusmv = tests.canonical_cnf(nusmv)

            self.assertEqual(s_tool, s_nusmv)
            self.assertEqual(s_tool, s_manual)
Пример #2
0
 def test_next_noloop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         i,k     = 0,2
         enc     = self.enc
         # One step
         a       = ast.Proposition("a")
         formula = ast.Next(a)
         tool    = formula.semantic_no_loop(enc, i, k)
         manual  = a.semantic_no_loop(enc, 1, k)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X a")),
                                             bound = k, 
                                             loop  = bmcutils.no_loopback())
         
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
         
         # two steps
         formula = ast.Next(ast.Next(a))
         tool    = formula.semantic_no_loop(enc, i, k)
         manual  = a.semantic_no_loop(enc, 2, k)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X X a")),
                                             bound = k, 
                                             loop  = bmcutils.no_loopback())
         
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
         
         # Three steps (getting over k)
         formula = ast.Next(ast.Next(ast.Next(a)))
         tool    = formula.semantic_no_loop(enc, i, k)
         manual  = Be.false(enc.manager)
         nusmv   = ltlspec.bounded_semantics(self.befsm, 
                                             Node.from_ptr(parse_ltl_spec("X X X a")),
                                             bound = k, 
                                             loop  = bmcutils.no_loopback())
         
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
         
         self.assertEqual(s_tool, s_nusmv)
         self.assertEqual(s_tool, s_manual)
Пример #3
0
 def test_no_loopback(self):
     self.assertTrue(bmcutils.is_no_loopback(bmcutils.no_loopback()))
     self.assertFalse(bmcutils.is_no_loopback(1000))
     self.assertFalse(bmcutils.is_no_loopback(bmcutils.all_loopbacks()))
     self.assertFalse(bmcutils.is_no_loopback(-1 *
                                              bmcutils.all_loopbacks()))
     self.assertFalse(bmcutils.is_no_loopback(-10000))
    def test_eventually_no_loop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            i, k = 0, 2
            enc = self.enc
            a = ast.Proposition("a")
            formula = ast.Eventually(a)

            tool = formula.semantic_no_loop(enc, i, k)

            manual  = a.semantic_no_loop(enc, i+2, k)   |\
                      a.semantic_no_loop(enc, i+1, k) |\
                      a.semantic_no_loop(enc, i, k)

            nusmv = ltlspec.bounded_semantics(self.befsm,
                                              Node.from_ptr(
                                                  parse_ltl_spec("F a")),
                                              bound=k,
                                              loop=bmcutils.no_loopback())

            # normalized string representation of the BE's (make them comparable)
            s_tool = tests.canonical_cnf(tool)
            s_nusmv = tests.canonical_cnf(nusmv)
            s_manual = tests.canonical_cnf(manual)

            self.assertEqual(s_nusmv, s_tool)
            self.assertEqual(s_manual, s_tool)
    def test_weak_until_noloop(self):
        with tests.Configure(self, __file__, "/example.smv"):
            enc = self.enc
            a = ast.Proposition("a")
            b = ast.Proposition("b")

            expr = ast.WeakUntil(a, b)
            tool = expr.semantic_no_loop(enc, 0, 2)

            manual = (b.semantic_no_loop(enc, 0, 2)
                      | (a.semantic_no_loop(enc, 0, 2) &
                         (b.semantic_no_loop(enc, 1, 2)
                          | (a.semantic_no_loop(enc, 1, 2) &
                             (b.semantic_no_loop(enc, 2, 2))))))

            spec = Node.from_ptr(parse_ltl_spec("a U b"))
            nusmv = ltlspec.bounded_semantics(self.befsm,
                                              spec,
                                              bound=2,
                                              loop=bmcutils.no_loopback())

            # normalized string representation of the BE's (make them comparable)
            s_tool = tests.canonical_cnf(tool)
            s_nusmv = tests.canonical_cnf(nusmv)
            s_manual = tests.canonical_cnf(manual)

            self.assertEqual(s_tool, s_manual)
            self.assertEqual(s_tool, s_nusmv)
Пример #6
0
 def test_eventually_no_loop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         i,k     = 0,2
         enc     = self.enc
         a       = ast.Proposition("a")
         formula = ast.Eventually(a)
         
         tool    = formula.semantic_no_loop(enc, i, k)
         
         manual  = a.semantic_no_loop(enc, i+2, k)   |\
                   a.semantic_no_loop(enc, i+1, k) |\
                   a.semantic_no_loop(enc, i, k) 
         
         nusmv   = ltlspec.bounded_semantics(
                     self.befsm, Node.from_ptr(parse_ltl_spec("F a")), 
                     bound = k, 
                     loop  = bmcutils.no_loopback())
         
         # normalized string representation of the BE's (make them comparable)
         s_tool  = tests.canonical_cnf(tool)
         s_nusmv = tests.canonical_cnf(nusmv)
         s_manual= tests.canonical_cnf(manual)
         
         self.assertEqual(s_nusmv,  s_tool)
         self.assertEqual(s_manual, s_tool)
Пример #7
0
    def test_loop_from_string(self):
        self.assertEqual(4, bmcutils.loop_from_string("4"))
        self.assertEqual(-1, bmcutils.loop_from_string("-1"))
        self.assertEqual(bmcutils.all_loopbacks(),
                         bmcutils.loop_from_string("*"))
        self.assertEqual(bmcutils.all_loopbacks(),
                         bmcutils.loop_from_string("All"))
        self.assertEqual(bmcutils.all_loopbacks(),
                         bmcutils.loop_from_string("All Loops"))
        self.assertEqual(bmcutils.all_loopbacks(),
                         bmcutils.loop_from_string("all"))
        self.assertEqual(bmcutils.all_loopbacks(),
                         bmcutils.loop_from_string("all loops"))

        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("x"))
        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("No"))
        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("None"))
        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("No Loop"))
        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("no"))
        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("none"))
        self.assertEqual(bmcutils.no_loopback(),
                         bmcutils.loop_from_string("no loop"))
Пример #8
0
    def test_successor(self):
        # case where there is a loop
        self.assertEqual(2, bmcutils.successor(1, 10, 0))
        self.assertEqual(9, bmcutils.successor(8, 10, 0))
        self.assertEqual(0, bmcutils.successor(9, 10, 0))
        # case when there is none
        self.assertEqual(2, bmcutils.successor(1, 10, bmcutils.no_loopback()))
        self.assertEqual(10, bmcutils.successor(9, 10, bmcutils.no_loopback()))
        self.assertIsNone(bmcutils.successor(10, 10, bmcutils.no_loopback()))

        # time cannot be negative
        with self.assertRaises(ValueError):
            bmcutils.successor(-5, 10, 0)
        # bound cannot be negative
        with self.assertRaises(ValueError):
            bmcutils.successor(5, -5, 0)

        # bound and value must be consistent
        with self.assertRaises(ValueError):
            bmcutils.successor(5, 10, 20)
Пример #9
0
    def test_check_consistency(self):
        # when the bound is not meaningful
        with self.assertRaises(ValueError):
            bmcutils.check_consistency(-1, 2)

        # when the loop is greater than the bound
        with self.assertRaises(ValueError):
            bmcutils.check_consistency(1, 2)

        # unless it is a special value
        bmcutils.check_consistency(4, bmcutils.all_loopbacks())
        bmcutils.check_consistency(4, bmcutils.no_loopback())
Пример #10
0
 def test_weak_until_noloop(self):
     with tests.Configure(self, __file__, "/example.smv"):
         enc  = self.enc
         a    = ast.Proposition("a")
         b    = ast.Proposition("b")
 
         expr = ast.WeakUntil(a, b)
         tool = expr.semantic_no_loop(enc, 0, 2)
         
         manual = ( b.semantic_no_loop(enc, 0, 2) 
                | (a.semantic_no_loop(enc, 0, 2) & (b.semantic_no_loop(enc, 1, 2)
                | (a.semantic_no_loop(enc, 1, 2) & (b.semantic_no_loop(enc, 2, 2))))))
         
         
         spec  = Node.from_ptr(parse_ltl_spec("a U b"))
         nusmv = ltlspec.bounded_semantics(self.befsm, spec, bound=2, loop=bmcutils.no_loopback())
         
         # normalized string representation of the BE's (make them comparable)
         s_tool  = tests.canonical_cnf(tool)
         s_nusmv = tests.canonical_cnf(nusmv)
         s_manual= tests.canonical_cnf(manual)
         
         self.assertEqual(s_tool, s_manual)
         self.assertEqual(s_tool, s_nusmv)