示例#1
0
 def test_full_witness(self):
     fsm = self.model()
     
     spec = parseCTLK("EF (EX nK<'c1'> 'c2.payer' & EG nD<'c1','c2'> 'c3.payer')")[0]
     self.assertIsNotNone(spec)
     state = fsm.pick_one_state(fsm.init & evalCTLK(fsm, spec))
     self.assertIsNotNone(state)
     
     expl = explain_witness(fsm, state, spec)
     self.assertIsNotNone(expl)
     
     print(xml_witness(fsm, expl, spec))
     
     
     spec = parseCTLK("E[nE<'c1','c2'> 'c3.payer' U"
                     " E[ nC<'c1','c3'> ('c1.payer' | 'c2.payer') W"
                     " nC<'c2'> ('c1.coin = head' <-> 'c2.coin = head')]]")[0]
     self.assertIsNotNone(spec)
     state = fsm.pick_one_state(fsm.init & evalCTLK(fsm, spec))
     self.assertIsNotNone(state)
     
     expl = explain_witness(fsm, state, spec)
     self.assertIsNotNone(expl)
     
     print(xml_witness(fsm, expl, spec))
     
     
     spec = parseCTLK("AG(~'c1.payer' | E<'c1'> ('c1.payer' -> "
                      "C<'c2','c3'> AF 'c1.payer'))")[0]
     self.assertIsNotNone(spec)
     state = fsm.pick_one_state(fsm.init & evalCTLK(fsm, spec))
     self.assertIsNotNone(state)
     
     expl = explain_witness(fsm, state, spec)
     self.assertIsNotNone(expl)
     
     print(xml_witness(fsm, expl, spec))
示例#2
0
 def test_true(self):
     fsm = self.simplemodel()
     
     spec = parseCTLK("True")[0]
     self.assertIsNotNone(spec)
     state = fsm.pick_one_state(fsm.init & evalCTLK(fsm, spec))
     self.assertIsNotNone(state)
     
     expl = explain_witness(fsm, state, spec)
     self.assertIsNotNone(expl)
     self.assertEqual(type(expl), Tlacenode)
     self.assertEqual(expl.state, state)
     self.assertEqual(len(expl.atomics), 0)
     self.assertEqual(len(expl.branches), 0)
     self.assertEqual(len(expl.universals), 0)
     
     print(xml_witness(fsm, expl, spec))
示例#3
0
 def test_reachable(self):
     fsm = self.simplemodel()
     
     lt = eval_simple_expression(fsm, "at.local")
     lf = eval_simple_expression(fsm, "af.local")
     g = eval_simple_expression(fsm, "global")
     true = eval_simple_expression(fsm, "TRUE")
     false = eval_simple_expression(fsm, "FALSE")
     
     spec = parseCTLK("Reachable")[0]
     self.assertIsNotNone(spec)
     state = fsm.pick_one_state(~lt & ~lf & ~g)
     self.assertIsNotNone(state)
     self.assertTrue(state <= evalCTLK(fsm, spec))
     
     expl = explain_witness(fsm, state, spec)
     self.assertIsNotNone(expl)
     self.assertEqual(type(expl), Tlacenode)
     self.assertEqual(expl.state, state)
     self.assertEqual(len(expl.atomics), 0)
     self.assertEqual(len(expl.branches), 1)
     self.assertEqual(len(expl.universals), 0)
     
     branch = expl.branches[0]
     self.assertEqual(type(branch), TemporalBranch)
     self.assertEqual(type(branch.specification), Reachable)
     path = branch.path
     self.assertIsNone(branch.loop)
     for (s, i, sp) in zip(path[::2], path[1::2], path[2::2]):
         self.assertIsNotNone(s)
         self.assertTrue(s.state <= fsm.reachable_states)
         self.assertEqual(len(s.atomics), 0)
         self.assertEqual(len(s.branches), 0)
         self.assertEqual(len(s.universals), 0)
         self.assertIsNotNone(sp)
         self.assertTrue(sp.state <= fsm.reachable_states)
         self.assertEqual(len(sp.branches), 0)
         self.assertEqual(len(sp.universals), 0)
         self.assertTrue(i <=
                            fsm.get_inputs_between_states(sp.state, s.state))
     self.assertEqual(len(path[-1].atomics), 1)
     self.assertEqual(type(path[-1].atomics[0]), Init)
     
     print(xml_witness(fsm, expl, spec))