Example #1
0
    def test_standardize_apart(self):
        var1, var2 = tree.Var(1), tree.Var(2)
        tr1 = tree.T('ListLink', var1, var2)

        tr2 = tree.standardize_apart(tr1)

        print tr1
        print tr2

        self.assertNotEquals(tree.unify(tr1, tr2, {}), None)

        var1_new, var2_new = tr2.args

        self.assertNotEquals(var1_new, var2_new)
        assert var1_new not in [var1, var2]
        assert var2_new not in [var1, var2]
Example #2
0
    def test_apply_rule(self):
        atoms = [self.l1, self.l2]

        # This is supposed to look up all Atoms of (exactly) type 'Link', and return their first outgoing atom
        link_template = tree.T('Link', 1, 2)
        first = tree.Var(1)
        result_trees = tree.apply_rule(link_template, first, atoms)
        result_correct = map(tree.tree_from_atom, [self.x1, self.l1])
        self.assertEquals(result_trees, result_correct)
Example #3
0
 def test_is_variable(self):
     var_tree = tree.Var(1)
     self.assertEquals(var_tree.is_variable(), True)
     node_tree = tree.T(self.x1)
     self.assertEquals(node_tree.is_variable(), False)