Exemplo n.º 1
0
    def test_prove_nothing(self):
        """Ensure ``prove()`` doesn't prove non-sequiturs."""
        a = language.atom("A")
        b = language.atom("B")
        t_a = language.sign_formula("T", a)
        f_b = language.sign_formula("F", b)

        result = main.prove(PC.rules, [t_a, f_b])

        expected = (False, [[]], [[t_a, f_b]])
        self.assertEqual(result, expected)
Exemplo n.º 2
0
    def test_prove_explosion(self):
        """Ensure ``prove()`` proves explosion."""
        a = language.atom("A")
        b = language.atom("B")
        t_a = language.sign_formula("T", a)
        f_a = language.sign_formula("F", a)
        f_b = language.sign_formula("F", b)

        result = main.prove(PC.rules, [t_a, f_a, f_b])

        expected = (True, [[(t_a, f_a)]], [[t_a, f_a, f_b]])
        self.assertEqual(result, expected)
Exemplo n.º 3
0
    def test_expand_t_conj(self):
        """Ensure ``expand()`` expands true conjunctions."""
        a = language.atom("A")
        b = language.atom("B")
        conj = language.molecule("CONJ", [a, b])
        t_conj = language.sign_formula("T", conj)
        t_a = language.sign_formula("T", a)
        t_b = language.sign_formula("T", b)

        branches = [[t_conj]]

        result = main.expand(PC.rules, branches)
        self.assertEqual(result, [[t_a, t_b]])
Exemplo n.º 4
0
    def test_expand_right(self):
        """Test the case where ``expand()`` expands only right."""
        a = language.atom("A")
        t_a = language.sign_formula("T", a)
        neg_a = language.molecule("NEG", [a])
        f_neg_a = language.sign_formula("F", neg_a)

        rules = [{
            "input": [
                {
                    "sign": "T",
                    "formula": {
                        "operator": None,
                        "operands": ["A"],
                    }
                },
            ],
            "output": {
                "left": [],
                "right": [{
                    "sign": "F",
                    "formula": {
                        "operator": "NEG",
                        "operands": ["A"],
                    }
                }],
            },
        }]

        result = main.prove(rules, [t_a])
        expected = (False, [[], []], [[], [f_neg_a]])
        self.assertEqual(result, expected)
Exemplo n.º 5
0
    def test_prove_modus_ponens(self):
        """Ensure ``prove()`` proves modus ponens."""
        a = language.atom("A")
        b = language.atom("B")
        neg_b = language.molecule("NEG", [b])
        conj = language.molecule("CONJ", [a, neg_b])
        f_conj = language.sign_formula("F", conj)
        t_a = language.sign_formula("T", a)
        f_a = language.sign_formula("F", a)
        t_b = language.sign_formula("T", b)
        f_b = language.sign_formula("F", b)

        result = main.prove(PC.rules, [t_a, f_conj, f_b])

        expected = (True, [[(t_a, f_a)], [(f_b, t_b)]], [[t_a, f_b, f_a],
                                                         [t_a, f_b, t_b]])
        self.assertEqual(result, expected)
Exemplo n.º 6
0
    def test_expand_f_neg(self):
        """Ensure ``expand()`` expands false negations."""
        a = language.atom("A")
        neg_a = language.molecule("NEG", [a])
        f_neg_a = language.sign_formula("F", neg_a)
        t_a = language.sign_formula("T", a)

        branches = [[f_neg_a]]

        result = main.expand(PC.rules, branches)
        self.assertEqual(result, [[t_a]])
Exemplo n.º 7
0
    def test_expand_t_neg_mbC(self):
        """Ensure ``expand()`` expands false negations (for mbC)."""
        a = language.atom("A")
        neg_a = language.molecule("NEG", [a])
        ball_a = language.molecule("BALL", [a])
        f_a = language.sign_formula("F", a)
        t_neg_a = language.sign_formula("T", neg_a)
        t_ball_a = language.sign_formula("T", ball_a)

        branches = [[t_neg_a, t_ball_a]]

        result = main.expand(mbC.rules, branches)
        self.assertEqual(result, [[f_a]])
Exemplo n.º 8
0
 def test_atom(self):
     """Ensure ``atom()`` builds the right representation."""
     operand = "dummy-proposition"
     result = language.atom(operand)
     expected = {"operator": None, "operands": [operand]}
     self.assertEqual(result, expected)
Exemplo n.º 9
0
 def test_sign_formula(self):
     """Ensure ``sign_formula()`` builds the right representation."""
     formula = language.atom("dummy-formula")
     result = language.sign_formula("T", formula)
     expected = {"sign": "T", "formula": formula}
     self.assertEqual(result, expected)