Пример #1
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))
Пример #2
0
 def test_until(self):
     with Configure(self, __file__, "/models/flipflops.smv"):
         fsm     = self.befsm
         formula = self.nnf("(a U !b)")
         
         # bound 0
         offset  = 0
         bound   = 0
         
         ref_expr= ltlspec.bounded_semantics(fsm, formula, bound)
         expr    = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # bound 1
         offset  = 0
         bound   = 1
         
         ref_expr= ltlspec.bounded_semantics(fsm, formula, bound)
         expr    = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         
         # ---- other offset ----             
         #  bound 0
         offset  = 2
         bound   = 0
     
         cdr     = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         
         ref_expr= self.enc.shift_to_time(cdr, 0+offset)
         expr    = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         #  bound 1
         offset  = 2
         bound   = 1
          
         car     = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding)
         cdr     = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         
         ref_expr= self.enc.shift_to_time(cdr, 0+offset) \
                 | (self.enc.shift_to_time(car, 0+offset) & self.enc.shift_to_time(cdr, 1+offset))
         expr    = ltlspec.bounded_semantics_at_offset(fsm, formula, bound, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
Пример #3
0
 def test_releases_no_loop(self):
     with Configure(self, __file__, "/models/flipflops.smv"):
         fsm     = self.befsm
         formula = self.nnf("(a V b)")
         
         #  bound 0
         ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0)
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # bound 1
         ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1)
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # bound 2 -- verification must be done by hand because the different 
         #           cnf literals mess the comparison
         ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 2)
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 2, 0)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # ---- other offset ----
         #  bound 0
         offset  = 1
         bound   = 0
         
         left    = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding)
         right   = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         ref_expr= self.enc.shift_to_time(right, offset) & self.enc.shift_to_time(left, offset)
           
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
           
         #  bound 1
         offset  = 1
         bound   = 1
         
         left    = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding)
         right   = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         ref_expr= self.enc.shift_to_time(right, offset) & ( self.enc.shift_to_time(left, offset) \
                   | (self.enc.shift_to_time(right, 1+offset) & self.enc.shift_to_time(left, 1+offset)))
           
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, bound, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
Пример #4
0
 def test_until_no_loop(self):
     with Configure(self, __file__, "/models/flipflops.smv"):
         fsm     = self.befsm
         formula = self.nnf("(a U b)")
         
         #  bound 0
         ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 0)
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, 0)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # bound 1
         ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 1)
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, 0)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # bound 2 -- verification must be done by hand because the different 
         #           cnf literals mess the comparison
         # ref_expr= ltlspec.bounded_semantics_without_loop(fsm, formula, 2)
         # expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 2, 0)
         # self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
         
         # ---- other offset ----
         #  bound 0
         offset  = 1
         ref_expr= Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         ref_expr= fsm.encoding.shift_to_time(ref_expr, offset)
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 0, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))
          
         #  bound 1
         offset  = 1
         cdr = Wff.decorate(ltlspec.cdr(formula)).to_be(fsm.encoding)
         car = Wff.decorate(ltlspec.car(formula)).to_be(fsm.encoding)
         
         ref_expr= fsm.encoding.shift_to_time(cdr, offset)   \
                 | ( fsm.encoding.shift_to_time(car, offset) \
                   & fsm.encoding.shift_to_time(cdr, offset+1))
                 
         expr    = ltlspec.bounded_semantics_without_loop_at_offset(fsm, formula, 0, 1, offset)
         self.assertEqual(canonical_cnf(expr), canonical_cnf(ref_expr))