Esempio n. 1
0
        public void TreeHasCorrectStringForm()
        {
            var tree = new ScalarProduct <int>(VariableNode.Make <int>(0, "x"),
                                               new Addition <int>(VariableNode.Make <int>(1, "y"),
                                                                  new Constant <int>(3)));

            Assert.AreEqual("(x∙(y+3))", tree.ToString());
            var tree2 = new MultipleOr(new PredicateNode("P", VariableNode.Make <int>(0, "x")),
                                       new PredicateNode("Q", VariableNode.Make <int>(1, "y"), VariableNode.Make <int>(2, "z")),
                                       new PredicateNode("H", new FunctionNode("f", VariableNode.Make <int>(0, "x")), new FunctionNode("c")));

            Assert.AreEqual("P(x) ∨ Q(y,z) ∨ H(f(x),c)", tree2.ToString());
        }
Esempio n. 2
0
        public void ComplexUnificationTest()
        {
            // !P(x,b,z,s) V ANS(f(g(z,b,h(x,z,s))))
            var A = new MultipleOr(
                new SkolemPredicateNode("P", true, VariableNode.Make <bool>(0, "x"), new FunctionNode("b"), VariableNode.Make <bool>(2, "z"), VariableNode.Make <bool>(3, "s")),
                new SkolemPredicateNode("ANS", false,
                                        new FunctionNode("f",
                                                         new FunctionNode("g", VariableNode.Make <bool>(2, "z"), new FunctionNode("b"),
                                                                          new FunctionNode("h", VariableNode.Make <bool>(0, "x"), VariableNode.Make <bool>(2, "z"), VariableNode.Make <bool>(3, "s"))))));

            // P(a,b,c,s0)
            var B = new SkolemPredicateNode("P", false, new FunctionNode("a"), new FunctionNode("b"), new FunctionNode("c"), new FunctionNode("s0"));

            Assert.AreEqual(true, UnificationService.CanUnificate((SkolemPredicateNode)A.Children[0], B));
            var rules = UnificationService.GetUnificationRules((SkolemPredicateNode)A.Children[0], B);

            Assert.AreEqual(3, rules.Count);
            UnificationService.Unificate(A, rules);
            Assert.AreEqual("!P(a,b,c,s0) ∨ ANS(f(g(c,b,h(a,c,s0))))", A.ToString());
        }