예제 #1
0
파일: test_main.py 프로젝트: jtpaasch/inc
    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]])
예제 #2
0
파일: test_main.py 프로젝트: jtpaasch/inc
    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)
예제 #3
0
파일: test_main.py 프로젝트: jtpaasch/inc
    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)
예제 #4
0
 def test_molecule(self):
     """Ensure ``molecule()`` builds the right representation."""
     operand_1 = "dummy-proposition-1"
     operand_2 = "dummy-proposition-2"
     operator = "dummy-operator"
     result = language.molecule(operator, [operand_1, operand_2])
     expected = {"operator": operator, "operands": [operand_1, operand_2]}
     self.assertEqual(result, expected)
예제 #5
0
파일: test_main.py 프로젝트: jtpaasch/inc
    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]])
예제 #6
0
파일: test_main.py 프로젝트: jtpaasch/inc
    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]])