def test_prune_nested_False(self): phi = NamedAtomicProposition("phi") psi = NamedAtomicProposition("psi") formula = And(And(phi, False), And(False, psi)) exp = And(phi, psi) got = simplify(formula) self.assertFalse(got, f"Problem discovered. Expected {exp}, got {got}")
def test_prune_nested_True(self): phi = NamedAtomicProposition("phi") psi = NamedAtomicProposition("psi") formula = And(And(phi, True), And(True, psi)) exp = And(phi, psi) got = simplify(formula) self.assertTrue(exp.eq(got), f"Problem discovered. Expected {exp}, got {got}")
def test_deMorgan_negated_Or(self): phi = NamedAtomicProposition("phi") psi = NamedAtomicProposition("psi") formula = Not(And(phi, psi)) exp = Or(Not(phi), Not(psi)) got = simplify(formula) self.assertTrue(exp.eq(got), f"Problem discovered. Expected {exp}, got {got}")
def test_prune_True_from_Or_right(self): phi = NamedAtomicProposition("phi") formula = Or(phi, True) exp = phi got = simplify(formula) self.assertTrue(got, f"Problem discovered. Expected {exp}, got {got}")
def test_prune_False_from_And_right(self): phi = NamedAtomicProposition("phi") formula = And(phi, False) exp = False got = simplify(formula) self.assertFalse(got, f"Problem discovered. Expected {exp}, got {got}")
def test_need_transformation_timed_formula_other_interval( self, statespace): ap = NamedAtomicProposition("myAP") formula = tctl.EG(ap, interval=(tctl.Interval() <= 15)) mc = ContinuousModelChecker(statespace) self.assertTrue(mc.need_transformation(formula))
def test_formula_attribute_setting(self): ap = NamedAtomicProposition("myAP") formula = tctl.And(ap, ap) verifier = verif.Verifier() verifier.formula = formula self.assertEqual(verifier.formula, formula)
def test_need_transformation_timed_formula_modified_interval_operators( self, statespace): ap = NamedAtomicProposition("myAP") formula = tctl.EG(ap, interval=(tctl.Interval() <= math.inf) > 0) mc = ContinuousModelChecker(statespace) self.assertFalse(mc.need_transformation(formula))
def test_formula_creation_with_after(self): ap = NamedAtomicProposition("myAP") verifier = verif.is_possible(ap).after(52) exp = tctl.EF(ap, interval=tctl.Interval() > 52) got = verifier.formula self.assertTrue(exp.eq(got))
def test_never_formula(self): ap = NamedAtomicProposition("myAP") verifier = verif.never(ap) exp = tctl.AG(tctl.Not(ap)) got = verifier.formula self.assertTrue(exp.eq(got))
def test_always_possible_formula(self): ap = NamedAtomicProposition("myAP") verifier = verif.always_possible(ap) exp = tctl.AG(tctl.EF(ap)) got = verifier.formula self.assertTrue(exp.eq(got))
def test_prune_True_from_And_left(self): phi = NamedAtomicProposition("phi") formula = And(True, phi) exp = phi got = simplify(formula) self.assertTrue(exp.eq(got), f"Problem discovered. Expected {exp}, got {got}")
def test_always_possible_within_formula(self): ap = NamedAtomicProposition("myAP") verifier = verif.always_possible(ap, within=30) exp = tctl.AG(tctl.AF(ap, interval=tctl.Interval() <= 30)) got = verifier.formula self.assertTrue(exp.eq(got))
def test_prune_quadruple_nested_Not(self): phi = NamedAtomicProposition("phi") formula = Not(Not(Not(Not(Not(phi))))) exp = Not(phi) got = simplify(formula) self.assertTrue(exp.eq(got), f"Problem discovered. Expected {exp}, got {got}")
def test_large_example(self): pa = NamedAtomicProposition("pa") phi = NamedAtomicProposition("phi") formula = \ Not(And( pa, Not(And( Not(Not(phi)), Not(And( Not(EU( Not(And(Not(phi), Not(And(Not(Not(pa)), Not(True))))) , True )), Not( EU( Not(And( Not(phi), Not(And( Not(Not(pa)), Not(True) )) )), And( Not(True), Not(And( Not(phi), Not(And( Not(Not(pa)), Not(True) )) )) ) ) ) )) )) )) exp = \ Or(Not(pa), phi) got = simplify(formula) self.assertTrue(exp.eq(got), f"Problem discovered. Expected {exp}, got {got}")
def test_formula_attribute_override(self): ap = NamedAtomicProposition("myAP") formula = tctl.And(ap, ap) verifier = verif.Verifier() verifier.formula = ap """The log verification doesn't work. Not sure why.""" # with self.assertLogs('crestdsl.verification.verifier', level='WARNING') as cm: # verifier.formula = formula """for now, just check for exceptions""" verifier.formula = formula self.assertTrue(formula.eq(verifier.formula))
def test_need_transformation_formula(self, statespace): ap = NamedAtomicProposition("myAP") formula = tctl.EG(ap) mc = ContinuousModelChecker(statespace) self.assertFalse(mc.need_transformation(formula))
def test_need_transformation_atomic(self, statespace): formula = NamedAtomicProposition("myAP") mc = ContinuousModelChecker(statespace) self.assertFalse(mc.need_transformation(formula))