use of at.ac.tuwien.kr.alpha.commons.substitutions.Unifier in project Alpha by alpha-asp.
the class UnificationTest method unificationWithFunctionTerms.
@Test
public void unificationWithFunctionTerms() {
Atom left = partsParser.parseLiteral("a(b, f(X, 13), g(Z), d)").getAtom();
Atom right = partsParser.parseLiteral("a(b, A, g(e), d)").getAtom();
Unifier unifier = Unification.unifyAtoms(left, right);
assertNotNull(unifier);
assertEquals(3, unifier.getMappedVariables().size());
assertEquals(left.substitute(unifier).toString(), right.substitute(unifier).toString());
}
use of at.ac.tuwien.kr.alpha.commons.substitutions.Unifier in project Alpha by alpha-asp.
the class UnificationTest method nonunificationSimple.
@Test
public void nonunificationSimple() {
Atom left = partsParser.parseLiteral("a(b,X)").getAtom();
Atom right = partsParser.parseLiteral("a(c,Y)").getAtom();
Unifier unifier = Unification.unifyAtoms(left, right);
assertNull(unifier);
}
use of at.ac.tuwien.kr.alpha.commons.substitutions.Unifier in project Alpha by alpha-asp.
the class UnificationTest method unificationBothSides.
@Test
public void unificationBothSides() {
Atom left = partsParser.parseLiteral("p(X, 1)").getAtom();
Atom right = partsParser.parseLiteral("p(d, Y)").getAtom();
Unifier unifier = Unification.unifyAtoms(left, right);
assertNotNull(unifier);
assertEquals(2, unifier.getMappedVariables().size());
assertEquals("d", unifier.eval(Terms.newVariable("X")).toString());
assertEquals("1", unifier.eval(Terms.newVariable("Y")).toString());
}
use of at.ac.tuwien.kr.alpha.commons.substitutions.Unifier in project Alpha by alpha-asp.
the class UnificationTest method nonunificationNested.
@Test
public void nonunificationNested() {
Atom left = partsParser.parseLiteral("a(f(X,a))").getAtom();
Atom right = partsParser.parseLiteral("a(f(a,b))").getAtom();
Unifier unifier = Unification.unifyAtoms(left, right);
assertNull(unifier);
}
use of at.ac.tuwien.kr.alpha.commons.substitutions.Unifier in project Alpha by alpha-asp.
the class UnificationTest method simpleGroundUnification.
@Test
public void simpleGroundUnification() {
Atom pX = partsParser.parseLiteral("p(X)").getAtom();
Atom pa = partsParser.parseLiteral("p(abc)").getAtom();
Unifier unifier = Unification.unifyAtoms(pa, pX);
assertNotNull(unifier);
assertEquals(1, unifier.getMappedVariables().size());
assertEquals("abc", unifier.eval(Terms.newVariable("X")).toString());
}
Aggregations