Search in sources :

Example 21 with Head

use of at.ac.tuwien.kr.alpha.api.rules.heads.Head in project Alpha by alpha-asp.

the class LiteralBindingNonBindingVariablesTest method testPositiveComparisonLiteral_NEQ_RightAssigning.

@Test
public void testPositiveComparisonLiteral_NEQ_RightAssigning() {
    Rule<Head> rule = parser.parse("p(X) :- q(X,Y), 5 != Y.").getRules().get(0);
    Literal literal = rule.getBody().stream().filter((lit) -> lit.getPredicate() == ComparisonOperators.NE.toPredicate()).findFirst().get();
    assertEquals(false, literal.isNegated());
    expectVariables(literal.getBindingVariables());
    expectVariables(literal.getNonBindingVariables(), "Y");
}
Also used : Head(at.ac.tuwien.kr.alpha.api.rules.heads.Head) Literal(at.ac.tuwien.kr.alpha.api.programs.literals.Literal) Test(org.junit.jupiter.api.Test)

Aggregations

Head (at.ac.tuwien.kr.alpha.api.rules.heads.Head)21 Literal (at.ac.tuwien.kr.alpha.api.programs.literals.Literal)12 Test (org.junit.jupiter.api.Test)12 Rule (at.ac.tuwien.kr.alpha.api.rules.Rule)6 BasicRule (at.ac.tuwien.kr.alpha.core.rules.BasicRule)6 ArrayList (java.util.ArrayList)6 InputProgram (at.ac.tuwien.kr.alpha.core.programs.InputProgram)5 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)4 NormalHead (at.ac.tuwien.kr.alpha.api.rules.heads.NormalHead)3 CompiledRule (at.ac.tuwien.kr.alpha.core.rules.CompiledRule)3 Substitution (at.ac.tuwien.kr.alpha.api.grounder.Substitution)2 Atom (at.ac.tuwien.kr.alpha.api.programs.atoms.Atom)2 BasicAtom (at.ac.tuwien.kr.alpha.api.programs.atoms.BasicAtom)2 AggregateLiteral (at.ac.tuwien.kr.alpha.api.programs.literals.AggregateLiteral)2 BasicLiteral (at.ac.tuwien.kr.alpha.api.programs.literals.BasicLiteral)2 Term (at.ac.tuwien.kr.alpha.api.terms.Term)2 VariableTerm (at.ac.tuwien.kr.alpha.api.terms.VariableTerm)2 BasicSubstitution (at.ac.tuwien.kr.alpha.commons.substitutions.BasicSubstitution)2 InlineDirectivesImpl (at.ac.tuwien.kr.alpha.core.parser.InlineDirectivesImpl)2 ProgramParserImpl (at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl)2