def test_quantifier_namespace_saturation(self): a = Universal("x", Atom("Saturated", ("x", "NAME", "NAME"))) b = Universal("x", Atom("Saturated", ("x", "x", "NAME"))) self.assertNotEqual(a, b) c = Existential("a", Universal("b", Atom("Saturated", ("a", "b", "b")))) d = Existential("a", Universal("b", Atom("Saturated", ("a", "a", "b")))) self.assertNotEqual(c, d)
def test_nested_quantifier_with_unquantified(self): string = "(exists(x)(Tasty(x) and exists(y)(Eats(y; x))))" actual = String(string).to_proposition() expected = Existential("x", Conjunction( Atom("Tasty", ("x",)), Existential("y", Atom("Eats", ("y", "x"))))) self.assertEqual(expected, actual)
def test_nested_quantified_sequents(self): """forall(x)(exists(y)(Predicate(x; y)) |~""" sequent = Sequent([ Universal( "alpha", Existential("beta", Atom("Predicate", ("alpha", "beta")))) ], []) with patch("json.load", lambda *args: self.names): decomp = sequent.decompose() self.assertEqual( Sequent( [Existential("beta", Atom("Predicate", ("Adrian", "beta")))], []), decomp[0][0]) self.assertEqual( Sequent([Existential("beta", Atom("Predicate", ("Eve", "beta")))], []), decomp[1][0])
def test_complex_quantified_sequent(self): sequent = Sequent( [Existential( "alpha", Conjunction( Universal( "beta", Atom("Predicate", ("alpha", "beta")) ), Atom("AnotherPredicate", ("alpha",)) ))], []) with patch("json.load", lambda *args: self.names): decomp = sequent.decompose() self.assertEqual( Sequent( [ Conjunction( Universal("beta", Atom("Predicate", ("Adrian", "beta"))), Atom("AnotherPredicate", ("Adrian",)) ) ], [] ), decomp[0][0] )
def test_right_existential(self): """|~ exists(x)(Predicate(x)) """ with patch("json.load", lambda *args: self.names): sequent = Sequent([], [Existential("alpha", self.alpha)]) decomp = sequent.decompose() self.assertEqual(Sequent([], [Atom("Predicate", ("Adrian",))]), decomp[0][0]) self.assertEqual(Sequent([], [Atom("Predicate", ("Eve",))]), decomp[1][0])
def test_complex_existential_from_string(self): e = "(exists(x)(Cute(x) and Cat(x)))" convert = String(e).to_proposition() self.assertEqual( Existential("x", Conjunction( Atom("Cute", ("x",)), Atom("Cat", ("x",)))), convert)
def test_nested_two_name_complex_quantifier(self): nest = Universal("w", Existential("x", Disjunction( Atom("Nested", ("x", "w")), Atom("Nested", ("w", "x")))) ) self.assertEqual( Existential("x", Disjunction( Atom("Nested", ("x", "w")), Atom("Nested", ("w", "x")))), nest.prop ) self.assertEqual( Disjunction( Atom("Nested", ("x", "w")), Atom("Nested", ("w", "x"))), nest.prop.prop)
def test_nested_complex_quantifier_init(self): nest = Universal("x", Existential("y", Conjunction( Atom("Nested", ("x",)), Atom("Nested", ("y",)))) ) self.assertEqual( Existential("y", Conjunction( Atom("Nested", ("x",)), Atom("Nested", ("y",)))), nest.prop ) self.assertEqual("x", nest.var) self.assertEqual([], nest.names) self.assertEqual( Conjunction( Atom("Nested", ("x",)), Atom("Nested", ("y",))), nest.prop.prop ) self.assertEqual("y", nest.prop.var)
def test_existential_init(self): existential = Existential("x", self.test_atom) self.assertEqual("x", existential.var) self.assertEqual(self.test_atom, existential.prop)
def test_nested_quantifier_from_string(self): string = "(forall(x)(exists(y)(Nested(x; y))))" actual = String(string).to_proposition() expected = Universal("x", Existential("y", Atom("Nested", ("x", "y")))) self.assertEqual(expected, actual)
def test_nested_quantifier_string(self): expected = "forall(x)(exists(y)(Nested(x; y)))" actual = str(Universal("x", Existential("y", Atom("Nested", ("x", "y"))))) self.assertEqual(expected, actual)
def test_nested_instantiated(self): uni = Universal("x", Existential("y", Atom("Nested", ("x", "y")))) inst = uni.instantiate("x", "alpha") self.assertEqual(Existential("y", Atom("Nested", ("alpha", "y"))), inst)
def test_nested_two_name_atomic_quantifier(self): nest = Universal("w", Existential("x", Atom("Nested", ("x", "w")))) self.assertEqual(Existential("x", Atom("Nested", ("x", "w"))), nest.prop) self.assertEqual(Atom("Nested", ("x", "w")), nest.prop.prop)
def test_nested_atomic_quantifier_init(self): nest = Universal("x", Existential("y", Atom("Nested", ("x", "y")))) self.assertEqual(Existential("y", Atom("Nested", ("x", "y"))), nest.prop) self.assertEqual("x", nest.var) self.assertEqual([], nest.names) self.assertEqual(Atom("Nested", ("x", "y")), nest.prop.prop)
def test_quantifier_eq_with_same_predicate_different_names(self): a = Existential("x", Atom("Simple", ("x",))) b = Existential("y", Atom("Simple", ("y",))) self.assertEqual(a, b)
def test_existential_predicate_from_string(self): e = "(exists(x)(LikesFudge(x)))" convert = String(e).to_proposition() self.assertEqual(Existential("x", Atom("LikesFudge", ("x",))), convert)