예제 #1
0
        public void ComplexUnificationTest()
        {
            // !P(x,b,z,s) V ANS(f(g(z,b,h(x,z,s))))
            var A = new Logic.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(UnificationService.CanUnificate((SkolemPredicateNode)A.Children[0], B), true);
            var rules = UnificationService.GetUnificationRules((SkolemPredicateNode)A.Children[0], B);
            Assert.AreEqual(rules.Count, 3);
            UnificationService.Unificate(A, rules);
            Assert.AreEqual(A.ToString(), "!P(a,b,c,s0) V ANS(f(g(c,b,h(a,c,s0))))");
        }
예제 #2
0
 public void UnificationTest()
 {
     // P(f(x), z)
     var A = new SkolemPredicateNode("P", false, new FunctionNode("f", VariableNode.Make<bool>(0, "x")),
                               VariableNode.Make<bool>(2, "z"));
     // P(y,a)
     var B = new SkolemPredicateNode("P", false, VariableNode.Make<bool>(1, "y"), new FunctionNode("a"));
     Assert.AreEqual(UnificationService.CanUnificate(A,B), true);
     var rules = UnificationService.GetUnificationRules(A, B);
     Assert.AreEqual(rules.Count, 2);
     UnificationService.Unificate(A, rules);
     UnificationService.Unificate(B, rules);
     Assert.AreEqual(A.ToString(), "P(f(x),a)");
     Assert.AreEqual(A.ToString(), B.ToString());
 }