Exemplo n.º 1
0
 def test_model_problem(self):
     with tests.Configure(self, __file__, "/example.smv"):
         enc = self.enc
         # no step taken
         bound = 0
          
         tool  = gen.model_problem(self.befsm, bound)
         manual= enc.shift_to_time(self.befsm.init, 0)
          
         nusmv = bmcutils.BmcModel().path(bound, with_init=True)
          
         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)
          
         # one step taken
         bound = 1
          
         tool  = gen.model_problem(self.befsm, bound)
         manual= enc.shift_to_time(self.befsm.trans,0) &\
                 enc.shift_to_time(self.befsm.init, 0)
          
         nusmv = bmcutils.BmcModel().path(bound, with_init=True)
          
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
          
         self.assertEqual(s_tool, s_manual)
         self.assertEqual(s_tool, s_nusmv)
          
         # two steps
         bound = 2
          
         tool  = gen.model_problem(self.befsm, bound)
         manual= enc.shift_to_time(self.befsm.init, 0) &\
                 enc.shift_to_time(self.befsm.trans,0) &\
                 enc.shift_to_time(self.befsm.trans,1)
          
         nusmv = bmcutils.BmcModel().path(bound, with_init=True)
          
         s_tool   = tests.canonical_cnf(tool)
         s_manual = tests.canonical_cnf(manual)
         s_nusmv  = tests.canonical_cnf(nusmv)
          
         self.assertEqual(s_tool, s_manual)
         self.assertEqual(s_tool, s_nusmv)
Exemplo n.º 2
0
 def validate_generate_problem(self, bound, custom_text, nusmv_text):
     fsm     = self.befsm
     # formulae
     formula = parseLTL(custom_text)
     fml_node= Node.from_ptr(parse_ltl_spec(nusmv_text))
      
     # IMPORTANT NOTE: each instantiation of the problem creates new CNF 
     #   literal which appears in the clauses list (even in canonical form)
     #   hence, the canonical forms of the different instantiations cannot
     #   simply be compared as there is no a priori way to know what CNF 
     #   literal reconcile with what other.
     #   However, the different expressions should all have the exact same
     #   satisfiability. So, that's how this test proceeds.
       
     smv     = ltlspec.generate_ltl_problem(fsm, fml_node, bound)
     tool    = gen.generate_problem(formula, fsm, bound)
     manual  = gen.model_problem(fsm, bound) &\
               formula.nnf(True).bounded_semantics(fsm, bound)
      
     sat_smv = self.satisfiability(smv)
     sat_tool= self.satisfiability(tool)
     sat_man = self.satisfiability(manual)
      
     self.assertEqual(sat_tool, sat_man)
     self.assertEqual(sat_tool, sat_smv)