domain.addConstant("B");
domain.addConstant("C");
domain.addFunction("Plus");
domain.addPredicate("P");
FOLParser parser = new FOLParser(domain);
Sentence s1 = parser.parse("(P(A) AND P(B))");
Sentence s2 = parser.parse("(P(A) AND P(B))");
Map<Variable, Term> result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(0, result.size());
s1 = parser.parse("(P(A) AND P(B))");
s2 = parser.parse("(P(A) AND P(C))");
result = unifier.unify(s1, s2);
Assert.assertNull(result);
s1 = parser.parse("(P(A) AND P(B))");
s2 = parser.parse("(P(A) AND P(x))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());
Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));
s1 = parser.parse("(P(A) OR P(B))");
s2 = parser.parse("(P(A) OR P(B))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(0, result.size());
s1 = parser.parse("(P(A) OR P(B))");
s2 = parser.parse("(P(A) OR P(C))");
result = unifier.unify(s1, s2);
Assert.assertNull(result);
s1 = parser.parse("(P(A) OR P(B))");
s2 = parser.parse("(P(A) OR P(x))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());
Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));
s1 = parser.parse("(P(A) => P(B))");
s2 = parser.parse("(P(A) => P(B))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(0, result.size());
s1 = parser.parse("(P(A) => P(B))");
s2 = parser.parse("(P(A) => P(C))");
result = unifier.unify(s1, s2);
Assert.assertNull(result);
s1 = parser.parse("(P(A) => P(B))");
s2 = parser.parse("(P(A) => P(x))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());
Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));
s1 = parser.parse("(P(A) <=> P(B))");
s2 = parser.parse("(P(A) <=> P(B))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(0, result.size());
s1 = parser.parse("(P(A) <=> P(B))");
s2 = parser.parse("(P(A) <=> P(C))");
result = unifier.unify(s1, s2);
Assert.assertNull(result);
s1 = parser.parse("(P(A) <=> P(B))");
s2 = parser.parse("(P(A) <=> P(x))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());
Assert.assertEquals(new Constant("B"), result.get(new Variable("x")));
s1 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
s2 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(0, result.size());
s1 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
s2 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(A))))");
result = unifier.unify(s1, s2);
Assert.assertNull(result);
s1 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(C))))");
s2 = parser.parse("((P(A) AND P(B)) OR (P(C) => (P(A) <=> P(x))))");
result = unifier.unify(s1, s2);
Assert.assertNotNull(result);
Assert.assertEquals(1, result.size());