コード例 #1
0
ファイル: testBmcLTLspec.py プロジェクト: yyaan/pynusmv
    def test_bounded_semantics_with_loop(self):
        # parse the ltl property
        spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )"))

        # it must raise exception when the bound is not feasible
        with self.assertRaises(ValueError):
            ltlspec.bounded_semantics_single_loop(self.fsm, spec, -1, -2)
        # it must raise exception when the bound and loop are not consistent
        with self.assertRaises(ValueError):
            ltlspec.bounded_semantics_single_loop(self.fsm, spec, 5, 6)

        # verify that the generated problem corresponds to what is announced
        # without optimisation, the all loops is built as the conjunction of all
        # the possible 'single_loops'
        all_loops = ltlspec.bounded_semantics_all_loops(self.fsm,
                                                        spec,
                                                        10,
                                                        0,
                                                        optimized=False)

        acc_loops = Be.false(self.fsm.encoding.manager)
        for time_t in range(10):
            acc_loops |= ltlspec.bounded_semantics_single_loop(
                self.fsm, spec, 10, time_t)
        self.assertEqual(acc_loops, all_loops)

        # with optimisation, it's different
        all_loops = ltlspec.bounded_semantics_all_loops(self.fsm,
                                                        spec,
                                                        10,
                                                        0,
                                                        optimized=True)
        self.assertNotEqual(acc_loops, all_loops)
コード例 #2
0
 def test_until_with_loop(self):
     with Configure(self, __file__, "/models/flipflops.smv"):
         fsm     = self.befsm
         formula = self.nnf("(a U b)")
         
         # bound 1
         offset  = 0
         bound   = 1
         loop    = 0
         
         # remember: the NuSMV std apis incorporate the loop condition !
         ref_expr= ltlspec.bounded_semantics_single_loop(fsm, formula, bound, loop)
         expr    = ltlspec.bounded_semantics_with_loop_at_offset(fsm, formula, 0, bound, loop, offset) \
                 & bmcutils.loop_condition(self.enc, bound, loop)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # ---- other offset ----             
         #  bound 2
         offset  = 1
         bound   = 2
         loop    = 0
     
         car     = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding)
         cdr     = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         # because of the way the loop condition is encoded !
         ref_expr= self.enc.shift_to_time(cdr, offset) | (self.enc.shift_to_time(car, offset) \
                     & self.enc.shift_to_time(cdr, offset+1))
         expr    = ltlspec.bounded_semantics_with_loop_at_offset(fsm, formula, 0, bound, loop, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         # because loop < i, the condition must be the same as before
         expr    = ltlspec.bounded_semantics_with_loop_at_offset(fsm, formula, 1, bound, loop, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
コード例 #3
0
ファイル: testBmcLTLspec.py プロジェクト: xgillard/pynusmv
 def test_bounded_semantics_with_loop(self):
     # parse the ltl property
     spec = Node.from_ptr(parse_ltl_spec("G ( y <= 7 )"))
     
     # it must raise exception when the bound is not feasible
     with self.assertRaises(ValueError):
         ltlspec.bounded_semantics_single_loop(self.fsm, spec, -1, -2)
     # it must raise exception when the bound and loop are not consistent
     with self.assertRaises(ValueError):
         ltlspec.bounded_semantics_single_loop(self.fsm, spec, 5, 6)
     
     # verify that the generated problem corresponds to what is announced
     # without optimisation, the all loops is built as the conjunction of all
     # the possible 'single_loops'
     all_loops = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0, optimized=False)
     
     acc_loops = Be.false(self.fsm.encoding.manager)
     for time_t in range(10):
         acc_loops |= ltlspec.bounded_semantics_single_loop(self.fsm, spec, 10, time_t)
     self.assertEqual(acc_loops, all_loops)
     
     # with optimisation, it's different
     all_loops = ltlspec.bounded_semantics_all_loops(self.fsm, spec, 10, 0, optimized=True)
     self.assertNotEqual(acc_loops, all_loops)