def test_inv_left_disjunction(self):
        """Predicate(alpha) or Predicate(beta) |~"""

        sequent = Sequent([Disjunction(self.alpha, self.beta)], [])
        decomp = sequent.decompose()[0]
        self.assertEqual(Sequent([self.alpha], []), decomp[0])
        self.assertEqual(Sequent([self.beta], []), decomp[1])
    def test_inv_left_conditional(self):
        """Predicate(alpha) implies Predicate(beta) |~ """

        sequent = Sequent([Conditional(self.alpha, self.beta)], [])
        decomp = sequent.decompose()[0]
        self.assertEqual(Sequent([], [self.alpha]), decomp[0])
        self.assertEqual(Sequent([self.beta], []), decomp[1])
    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_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_left_universal(self):
        """forall(x)(Predicate(x)) |~"""

        with patch("json.load", lambda *args: self.names):
            sequent = Sequent([Universal("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_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])
예제 #8
0
 def _decompose(self, key: str, sequent: Sequent) -> dict:
     """Returns the results of decomposing a sequent as a dictionary
     with keys matching their locations in the tree. If reflexivity
     is off, deletes reflexive results and marks the tree as having
     been truncated."""
     new_items = {}
     children: tuple = sequent.decompose()
     if sequent.principal.proposition.is_invertible:
         new_items.update(_invertible_decomp(children, key))
     else:
         new_items.update(_non_invertible_decomp(children, key))
     if not Settings()['Reflexivity']:
         for new_key, new_sequent in new_items.items():
             if new_sequent.is_reflexive:
                 del new_items[new_key]
                 if not self.has_been_truncated:
                     self.has_been_truncated = True
     return new_items
    def test_inv_left_negation(self):
        """not Predicate(alpha) |~"""

        sequent = Sequent([Negation(self.alpha)], [])
        decomp = sequent.decompose()[0][0]
        self.assertEqual(Sequent([], [self.alpha]), decomp)
    def test_inv_right_disjunction(self):
        """|~ Predicate(alpha) or Predicate(beta)"""

        sequent = Sequent([], [Disjunction(self.alpha, self.beta)])
        decomp = sequent.decompose()[0][0]
        self.assertEqual(Sequent([], [self.alpha, self.beta]), decomp)
    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)
    def test_inv_right_conditional(self):
        """|~ Predicate(alpha) implies Predicate(beta)"""

        sequent = Sequent([], [Conditional(self.alpha, self.beta)])
        decomp = sequent.decompose()[0][0]
        self.assertEqual(Sequent([self.alpha], [self.beta]), decomp)
    def test_inv_right_negation(self):
        """|~ not Predicate(alpha)"""

        sequent = Sequent([], [Negation(self.alpha)])
        decomp = sequent.decompose()[0][0]
        self.assertEqual(Sequent([self.alpha], []), decomp)