use of at.ac.tuwien.kr.alpha.api.grounder.Substitution in project Alpha by alpha-asp.
the class SubstitutionTest method groundAndPrintRule.
@Test
public void groundAndPrintRule() {
Rule<Head> rule = PARSER.parse("x :- p(X,Y), not q(X,Y).").getRules().get(0);
CompiledRule nonGroundRule = InternalRule.fromNormalRule(NormalRuleImpl.fromBasicRule(rule));
Substitution substitution1 = BasicSubstitution.specializeSubstitution(PX, PA, BasicSubstitution.EMPTY_SUBSTITUTION);
Substitution substitution2 = BasicSubstitution.specializeSubstitution(PY, PB, substitution1);
String printedString = SubstitutionTestUtil.groundAndPrintRule(nonGroundRule, substitution2);
assertEquals("x :- p(a, b), not q(a, b).", printedString);
}
use of at.ac.tuwien.kr.alpha.api.grounder.Substitution in project Alpha by alpha-asp.
the class SubstitutionTest method substituteBasicAtomLiteral.
private void substituteBasicAtomLiteral(boolean negated) {
Predicate p = Predicates.getPredicate("p", 2);
BasicAtom atom = Atoms.newBasicAtom(p, Arrays.asList(X, Y));
Literal literal = Literals.fromAtom(atom, !negated);
Substitution substitution = new BasicSubstitution();
substitution.put(X, A);
substitution.put(Y, B);
literal = literal.substitute(substitution);
assertEquals(p, literal.getPredicate());
assertEquals(A, literal.getTerms().get(0));
assertEquals(B, literal.getTerms().get(1));
assertEquals(negated, literal.isNegated());
}
use of at.ac.tuwien.kr.alpha.api.grounder.Substitution in project Alpha by alpha-asp.
the class SubstitutionTest method putSimpleBinding.
@Test
public void putSimpleBinding() {
Substitution substitution = new BasicSubstitution();
substitution.put(Y, A);
assertEquals(A, substitution.eval(Y));
}
use of at.ac.tuwien.kr.alpha.api.grounder.Substitution in project Alpha by alpha-asp.
the class SubstitutionTest method specializeTermsSimpleBinding.
@Test
public void specializeTermsSimpleBinding() {
Substitution substitution = BasicSubstitution.specializeSubstitution(PY, PA, BasicSubstitution.EMPTY_SUBSTITUTION);
assertEquals(A, substitution.eval(Y));
}
Aggregations