def test_explain(self): fsm = self.init_model() initState = fsm.pick_one_state(fsm.init) adminNone = eval_ctl_spec(fsm, atom("admin = none")) adminAlice = eval_ctl_spec(fsm, atom("admin = alice")) egAlice = eval_ctl_spec(fsm, eg(atom("admin = alice"))) euNoneUAlice = eval_ctl_spec(fsm, eu(atom("admin = none"), atom("admin = alice"))) spec = Spec(parse_ctl_spec("EX admin = none")) path = explain(fsm, initState, spec) self.assertEqual(initState, path[0]) self.assertTrue(path[2] <= adminNone) state = fsm.pick_one_state(egAlice) spec = Spec(parse_ctl_spec("EG admin = alice")) path = explain(fsm, state, spec) self.assertEqual(state, path[0]) self.assertIn(path[-1], path[:-1]) for i in range(0,len(path), 2): self.assertTrue(path[i] <= adminAlice) self.assertTrue(path[-1] <= adminAlice) self.assertTrue(initState <= euNoneUAlice) spec = Spec(parse_ctl_spec("E[admin = none U admin = alice]")) path = explain(fsm, initState, spec) self.assertEqual(initState, path[0]) for i in range(2,len(path)-2,2): self.assertTrue(path[i] <= adminNone) self.assertTrue(path[-1] <= adminAlice)
def test_ex(self): glob.load("tests/pynusmv/models/admin.smv") glob.compute_model() fsm = glob.prop_database().master.bddFsm alice = mc.eval_simple_expression(fsm, "admin = alice") spec = prop.Spec(parser.parse_ctl_spec("EX admin = alice")) exalice = mc.eval_ctl_spec(fsm, spec) self.assertEqual(mc.ex(fsm, alice), exalice)
def test_au(self): glob.load("tests/pynusmv/models/admin.smv") glob.compute_model() fsm = glob.prop_database().master.bddFsm none = mc.eval_simple_expression(fsm, "admin = none") alice = mc.eval_simple_expression(fsm, "admin = alice") spec = prop.Spec( parser.parse_ctl_spec("A[admin = none U admin = alice]")) aunonealice = mc.eval_ctl_spec(fsm, spec) self.assertEqual(mc.au(fsm, none, alice), aunonealice)
def test_explain_atom(self): fsm = self.init_model() manager = fsm.bddEnc.DDmanager init = fsm.init initState = fsm.pick_one_state(init) spec = Spec(parse_ctl_spec("admin = none")) path = explain(fsm, initState, spec) self.assertEqual(initState, path[0]) self.assertEqual(len(path), 1)
def test_eg(self): glob.load("tests/pynusmv/models/admin.smv") glob.compute_model() fsm = glob.prop_database().master.bddFsm alice = mc.eval_simple_expression(fsm, "admin = alice") spec = prop.Spec(parser.parse_ctl_spec("EG admin = alice")) egalice = mc.eval_ctl_spec(fsm, spec) self.assertEqual(mc.eg(fsm, alice), egalice) self.assertEqual( egalice, fixpoint(lambda Z: alice & fsm.pre(Z), BDD.true()) & fsm.reachable_states)
def test_car_cdr(self): spec = au(atom("s", type_checking=False), atom("t", type_checking=False)) self.assertEqual(spec.car, spec.car) self.assertNotEqual(spec.car, spec.cdr) parsed_spec = parse_ctl_spec("A [s U s]") spec = Spec(parsed_spec) self.assertNotEqual(spec.car, spec.cdr) self.assertEqual(spec.car, spec.car) newspec = au(spec.car, spec.cdr) self.assertEqual(spec.car, newspec.car) self.assertEqual(spec.cdr, newspec.cdr) self.assertNotEqual(spec, newspec) newspec2 = au(spec.car, spec.cdr) self.assertEqual(newspec, newspec2) s = {spec.car, spec.car, spec.cdr} self.assertEqual(len(s), 2)
def test_ctl(self): spec = parse_ctl_spec("AG EF x") self.assertIsNotNone(spec) with self.assertRaises(NuSMVParsingError): spec = parse_ctl_spec("A A")
def test_cdr(self): glob.load(*self.counters()) glob.compute_model() spec = node.Node.from_ptr(parse_ctl_spec("A [x U y]")) self.assertEqual(type(spec.cdr), node.Atom) self.assertEqual(str(spec.cdr), "y")