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_inv_right_conjunction(self):
        """|~ Predicate(alpha) and Predicate(beta)"""

        sequent = Sequent([], [Conjunction(self.alpha, self.beta)])
        decomp = sequent.decompose()[0]
        self.assertEqual(Sequent([], [self.alpha]), decomp[0])
        self.assertEqual(Sequent([], [self.beta]), decomp[1])
 def test_string_to_sequent(self):
     string = "Predicate(alpha), (Relation(alpha; beta) and Relation(beta; delta)) " \
              "|~ (Relation(beta; gamma) implies Predicate(delta)), Predicate(delta) or Predicate(zeta)"
     sequent = String(string).to_sequent()
     self.assertEqual(
         Sequent(
             [
                 Atom("Predicate", ("alpha",)),
                 Conjunction(
                     Atom("Relation", ("alpha", "beta")),
                     Atom("Relation", ("beta", "delta"))
                 )
             ],
             [
                 Conditional(
                     Atom("Relation", ("beta", "gamma")),
                     Atom("Predicate", ("delta",))
                 ),
                 Disjunction(
                     Atom("Predicate", ("delta",)),
                     Atom("Predicate", ("zeta",))
                 )
             ]
         ),
         sequent
     )
 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_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_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_complex_quantifier_eq_same_object_multi_predicate(self):
     a = Universal("x", Conjunction(Atom("Tough", ("x", "x")), Atom("Hard", ("x", "x"))))
     b = Universal("y", Conjunction(Atom("Tough", ("y", "y")), Atom("Hard", ("y", "y"))))
     self.assertEqual(a, b)
 def test_complex_quantifier_eq_same_object_predicate_different_names(self):
     a = Universal("x", Conjunction(Atom("Tough", ("x",)), Atom("Hard", ("x",))))
     b = Universal("y", Conjunction(Atom("Tough", ("y",)), Atom("Hard", ("y",))))
     self.assertEqual(a, b)
    def test_inv_left_conjunction(self):
        """Predicate(alpha) and Predicate(beta) |~"""

        sequent = Sequent([Conjunction(self.alpha, self.beta)], [])
        decomp = sequent.decompose()[0][0]
        self.assertEqual(Sequent([self.alpha, self.beta], []), decomp)
Пример #10
0
import os
import json
from Objects.Sequents import Sequent

# Propositions
from Propositions.BaseClasses import Atom
from Propositions.Propositions import Negation, Conditional, Conjunction, Disjunction

atom = Atom('Proposition')
negation = Negation(atom)
conditional = Conditional(atom, atom)
conjunction = Conjunction(atom, atom)
disjunction = Disjunction(atom, atom)

propositions_list = [atom, negation, conditional, conjunction, disjunction]

# Proposition Strings
atom_str = 'Proposition'
neg_str = '(not Proposition)'
cond_str = '(Proposition implies Proposition)'
conj_str = '(Proposition and Proposition)'
disj_str = '(Proposition or Proposition)'

proposition_strings_list = [atom_str, neg_str, cond_str, conj_str, disj_str]

# Reflexive Sequents
# Note: do not attempt to decompose universal sequents non-invertibly.
empty_sequent = Sequent([], [])
reflexive_atomic_sequent = Sequent([atom], [atom])
reflexive_negation_sequent = Sequent([negation], [negation])
reflexive_conditional_sequent = Sequent([conditional], [conditional])