Example #1
0
        public void ErrorUnificationTest()
        {
            // Q(f(a),g(x))
            Expression <Del1> A = (x) => Q(f(a), g(x));
            // Q(y,y)
            Expression <Del1> B = (y) => Q(y, y);
            var node1           = (SkolemPredicateNode)Expressions2LogicTree.Parse(A).Children[0];
            var node2           = (SkolemPredicateNode)Expressions2LogicTree.Parse(B).Children[0];

            Assert.AreEqual(false, UnificationService.CanUnificate(node1, node2));
        }
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());
        }
Example #5
0
 public static IRule Get()
 {
     return(Rule
            .New("Resolve", StdTags.Inductive, StdTags.Logic, StdTags.SafeResection)
            .Select(A[ChildB], C[ChildD])
            .Where <MultipleOr, SkolemPredicateNode, MultipleOr, SkolemPredicateNode>(z =>
                                                                                      UnificationService.CanUnificate(z.B, z.D) && (z.B.IsNegate || z.D.IsNegate))
            .Mod(Modificator));
 }