def test_prenex_basic(self): a,b,c = (Symbol(x) for x in "abc") f = Not(And(a, Exists([b], And(a, b)), ForAll([c], Or(a, c)))) prenex = prenex_normal_form(f) # Two prenex normal forms are possible my_prenex_1 = Exists([c], ForAll([b], Not(And(a, And(a, b), Or(a, c))))) my_prenex_2 = ForAll([b], Exists([c], Not(And(a, And(a, b), Or(a, c))))) self.assertTrue(prenex == my_prenex_1 or prenex == my_prenex_2)
def test_prenex_examples(self): for (f, _, _, logic) in get_example_formulae(): if get_env().factory.has_solvers(logic=logic): prenex = prenex_normal_form(f) try: ok = is_valid(Iff(f, prenex), logic=logic) except SolverReturnedUnknownResultError: ok = not logic.quantifier_free self.assertTrue(ok)
def test_prenex_examples(self): for (f, _, _, logic) in get_example_formulae(): if get_env().factory.has_solvers(logic=logic): prenex = prenex_normal_form(f) try: ok = is_valid(Iff(f, prenex), logic=logic) except SolverReturnedUnknownResultError: ok = not logic.quantifier_free self.assertTrue(ok)
def test_prenex_basic(self): a, b, c = (Symbol(x) for x in "abc") f = Not(And(a, Exists([b], And(a, b)), ForAll([c], Or(a, c)))) prenex = prenex_normal_form(f) # Two prenex normal forms are possible my_prenex_1 = Exists([c], ForAll([b], Not(And(a, And(a, b), Or(a, c))))) my_prenex_2 = ForAll([b], Exists([c], Not(And(a, And(a, b), Or(a, c))))) self.assertTrue(prenex == my_prenex_1 or prenex == my_prenex_2)
def test_prenex_negated_forall(self): a,b = (Symbol(x) for x in "ab") f = Implies(ForAll([b], Implies(a, b)), b) prenex = prenex_normal_form(f) self.assertTrue(prenex.is_exists()) self.assertValid(Iff(f, prenex), logic=BOOL)
def test_prenex_simple_forall(self): a,b = (Symbol(x) for x in "ab") f = Or(b, ForAll([b], Implies(a, b))) prenex = prenex_normal_form(f) self.assertTrue(prenex.is_forall()) self.assertValid(Iff(f, prenex), logic=BOOL)
def test_prenex_simple_exists(self): a,b = (Symbol(x) for x in "ab") f = And(b, Exists([b], Implies(a, b))) prenex = prenex_normal_form(f) self.assertTrue(prenex.is_exists()) self.assertValid(Iff(f, prenex), logic=BOOL)
def test_prenex_negated_forall(self): a, b = (Symbol(x) for x in "ab") f = Implies(ForAll([b], Implies(a, b)), b) prenex = prenex_normal_form(f) self.assertTrue(prenex.is_exists()) self.assertValid(Iff(f, prenex), logic=BOOL)
def test_prenex_simple_forall(self): a, b = (Symbol(x) for x in "ab") f = Or(b, ForAll([b], Implies(a, b))) prenex = prenex_normal_form(f) self.assertTrue(prenex.is_forall()) self.assertValid(Iff(f, prenex), logic=BOOL)
def test_prenex_simple_exists(self): a, b = (Symbol(x) for x in "ab") f = And(b, Exists([b], Implies(a, b))) prenex = prenex_normal_form(f) self.assertTrue(prenex.is_exists()) self.assertValid(Iff(f, prenex), logic=BOOL)