Example #1
0
        /// <summary>
        /// Using resolution rule: A V B, C V !B |- A V C.
        /// </summary>
        /// <param name="z"></param>
        private static void Modificator(ITypizedDecorArray <MultipleOr, SkolemPredicateNode, MultipleOr, SkolemPredicateNode> z)
        {
            var rules = UnificationService.GetUnificationRules(z.B.Node, z.D.Node);

            UnificationService.Unificate(z.A.Node, rules);
            UnificationService.Unificate(z.C.Node, rules);
            var aChildren = z.A.Node.Children.ToList();
            var cChildren = z.C.Node.Children.ToList();

            aChildren.Remove(z.B.Node);
            cChildren.Remove(z.D.Node);
            z.A.Replace(new MultipleOr(aChildren.ToArray()));
            z.C.Replace(new MultipleOr(cChildren.ToArray()));
        }
Example #2
0
        public void HardUnificationTest()
        {
            // P(a,x,f(g(y))
            Expression <Del2> A = (x, y) => P(a, x, f(g(y)));
            // P(z,f(z),f(u))
            Expression <Del2> B = (z, u) => P(z, f(z), f(u));
            var node1           = (SkolemPredicateNode)Expressions2LogicTree.Parse(A).Children[0];
            var node2           = (SkolemPredicateNode)Expressions2LogicTree.Parse(B).Children[0];

            Assert.AreEqual(true, UnificationService.CanUnificate(node1, node2));
            var rules = UnificationService.GetUnificationRules(node1, node2);

            Assert.AreEqual(3, rules.Count);
            UnificationService.Unificate(node1, node2);
            Assert.AreEqual(node1.ToString(), node2.ToString());
        }
Example #3
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(true, UnificationService.CanUnificate(A, B));
            var rules = UnificationService.GetUnificationRules(A, B);

            Assert.AreEqual(2, rules.Count);
            UnificationService.Unificate(A, rules);
            UnificationService.Unificate(B, rules);
            Assert.AreEqual("P(f(x),a)", A.ToString());
            Assert.AreEqual(A.ToString(), B.ToString());
        }
Example #4
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());
        }