def test_EVENTUALLY_check_ltl_onepb(self): with tests.Configure(self, __file__, "/example.smv"): # proving a violation of this prop necessitates at least two # steps: flip --> flop --> flip formula = parseLTL("<>(a <=> b)") status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Ok", status) self.assertIsNone(trace) # a loop is identified status, trace = check.check_ltl_onepb(formula, 2) self.assertEqual("Violation", status) self.assertIsNotNone(trace) self.assertEqual(2, len(trace)) # valid in the initial state (hence for any bound) formula = parseLTL("<>(a | b)") for k in range(10): status, trace = check.check_ltl_onepb(formula, k) self.assertEqual("Ok", status) self.assertIsNone(trace)
def test_GLOBALLY_check_ltl_onepb(self): with tests.Configure(self, __file__, "/example.smv"): formula = parseLTL("[](a <=> !b)") for k in range(10): status, trace = check.check_ltl_onepb(formula, k) self.assertEqual("Ok", status) self.assertIsNone(trace) # already violated in the initial state formula = parseLTL("[](a <=> b)") status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Violation", status) self.assertIsNotNone(trace) self.assertEqual(0, len(trace))
def test_NEXT_check_ltl_onepb(self): with tests.Configure(self, __file__, "/example.smv"): # false in the initial state formula = parseLTL("() a") # however the violation is not detected when no move is allowed status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Violation", status) self.assertIsNotNone(trace) self.assertEqual(1, len(trace)) # true in the initial state formula = parseLTL("()() a") # not reachable status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) # not quite yet status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Ok", status) self.assertIsNone(trace) # ok status, trace = check.check_ltl_onepb(formula, 2) self.assertEqual("Ok", status) self.assertIsNone(trace) # and even for longer traces status, trace = check.check_ltl_onepb(formula, 3) self.assertEqual("Ok", status) self.assertIsNone(trace)
def test_UNTIL_check_ltl_onepb(self): with tests.Configure(self, __file__, "/never_b.smv"): # entailed by the automaton formula = parseLTL("a U b") # not reachable status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) # this is where U differs from W: at infinity, b must hold status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Violation", status) self.assertIsNotNone(trace) self.assertEqual(1, len(trace)) # true in the initial state formula = parseLTL("b U a") status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 2) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 3) self.assertEqual("Ok", status) self.assertIsNone(trace) # violated right away formula = parseLTL("b U !a") status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Violation", status) self.assertIsNotNone(trace) self.assertEqual(0, len(trace))
def test_WEAKUNTIL_check_ltl_onepb(self): with tests.Configure(self, __file__, "/never_b.smv"): # entailed by the automaton formula = parseLTL("a W b") # not reachable status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) # already looping but no counter example status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Ok", status) self.assertIsNone(trace) # true in the initial state formula = parseLTL("b W a") status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 1) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 2) self.assertEqual("Ok", status) self.assertIsNone(trace) status, trace = check.check_ltl_onepb(formula, 3) self.assertEqual("Ok", status) self.assertIsNone(trace) # violated right away formula = parseLTL("b W !a") status, trace = check.check_ltl_onepb(formula, 0) self.assertEqual("Violation", status) self.assertIsNotNone(trace) self.assertEqual(0, len(trace))