use of at.ac.tuwien.kr.alpha.api.programs.literals.Literal in project Alpha by alpha-asp.
the class LiteralBindingNonBindingVariablesTest method testPositiveComparisonLiteral_EQ_Bidirectional.
@Test
@Disabled("Literals of this kind are compiled away by VariableEqualityRemoval")
public void testPositiveComparisonLiteral_EQ_Bidirectional() {
Rule<Head> rule = parser.parse("p(X) :- q(X,Y), X = Y.").getRules().get(0);
Literal literal = rule.getBody().stream().filter((lit) -> lit.getPredicate() == ComparisonOperators.EQ.toPredicate()).findFirst().get();
assertEquals(false, literal.isNegated());
expectVariables(literal.getBindingVariables());
expectVariables(literal.getNonBindingVariables(), "X", "Y");
}
use of at.ac.tuwien.kr.alpha.api.programs.literals.Literal 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.programs.literals.Literal in project Alpha by alpha-asp.
the class LiteralBindingNonBindingVariablesTest method testNegativeExternalLiteral.
@Test
public void testNegativeExternalLiteral() {
externals.put("ext", new IntPredicateInterpretation(i -> i > 0));
Literal literal = parser.parse("p(X) :- q(Y), not &ext[Y](X).", externals).getRules().get(0).getNegativeBody().stream().findFirst().get();
assertEquals(true, literal.isNegated());
expectVariables(literal.getBindingVariables());
expectVariables(literal.getNonBindingVariables(), "X", "Y");
}
use of at.ac.tuwien.kr.alpha.api.programs.literals.Literal in project Alpha by alpha-asp.
the class LiteralBindingNonBindingVariablesTest method testPositiveBasicLiteral.
@Test
public void testPositiveBasicLiteral() {
Literal literal = parser.parse("p(X,Y) :- q(X,Y).").getRules().get(0).getBody().stream().findFirst().get();
assertEquals(false, literal.isNegated());
expectVariables(literal.getBindingVariables(), "X", "Y");
expectVariables(literal.getNonBindingVariables());
}
use of at.ac.tuwien.kr.alpha.api.programs.literals.Literal in project Alpha by alpha-asp.
the class LiteralBindingNonBindingVariablesTest method testNegativeComparisonLiteral_NEQ_LeftAssigning.
@Test
public void testNegativeComparisonLiteral_NEQ_LeftAssigning() {
Literal literal = parser.parse("p(X) :- q(X,Y), not Y != 5.").getRules().get(0).getNegativeBody().stream().findFirst().get();
assertEquals(true, literal.isNegated());
expectVariables(literal.getBindingVariables(), "Y");
expectVariables(literal.getNonBindingVariables());
}
Aggregations