/// <summary> /// Checks, that passed nodes can be unificated /// </summary> /// <param name="node1"></param> /// <param name="node2"></param> /// <returns></returns> public static bool CanUnificate(SkolemPredicateNode node1, SkolemPredicateNode node2) { // The predicate name is unique if (!node1.Name.Equals(node2.Name)) { return(false); } return(GetUnificationRules(node1, node2) != null); }
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()); }
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()); }