use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class StratifiedEvaluationTest method testIntervalFact.
@Test
public void testIntervalFact() {
String asp = "a(1..3).";
CompiledProgram evaluated = parseAndEvaluate.apply(asp);
Set<AnswerSet> answerSets = solveCompiledProg.apply(evaluated);
TestUtils.assertAnswerSetsEqual("a(1), a(2), a(3)", answerSets);
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class StratifiedEvaluationTest method testNegatedExternalLiteral.
@Test
public void testNegatedExternalLiteral() throws Exception {
String asp = "claimedTruth(bla). truth(X) :- claimedTruth(X), &sayTrue[X]. lie(X) :- claimedTruth(X), not &sayTrue[X].";
Map<String, PredicateInterpretation> externals = new HashMap<>();
externals.put("sayTrue", Externals.processPredicateMethod(this.getClass().getMethod("sayTrue", Object.class)));
ProgramParser parserWithExternals = new ProgramParserImpl();
AnalyzedProgram analyzed = AnalyzedProgram.analyzeNormalProgram(normalizer.apply(parserWithExternals.parse(asp, externals)));
CompiledProgram evaluated = new StratifiedEvaluation().apply(analyzed);
Set<AnswerSet> answerSets = solveCompiledProg.apply(evaluated);
TestUtils.assertAnswerSetsEqual("claimedTruth(bla), truth(bla)", answerSets);
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class StratifiedEvaluationTest method testCountAggregate.
@Test
public void testCountAggregate() {
String asp = "a. b :- 1 <= #count { 1 : a }.";
CompiledProgram evaluated = parseAndEvaluate.apply(asp);
Set<AnswerSet> answerSets = solveCompiledProg.apply(evaluated);
TestUtils.assertAnswerSetsEqual("a, b", answerSets);
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class StratifiedEvaluationTest method testNonGroundableRule.
@Test
public void testNonGroundableRule() {
String asp = "p(a). q(a, b). s(X, Y) :- p(X), q(X, Y), r(Y).";
CompiledProgram evaluated = parseAndEvaluate.apply(asp);
Set<AnswerSet> answerSets = solveCompiledProg.apply(evaluated);
TestUtils.assertAnswerSetsEqual("p(a), q(a,b)", answerSets);
}
use of at.ac.tuwien.kr.alpha.api.AnswerSet in project Alpha by alpha-asp.
the class StratifiedEvaluationTest method testNegatedFixedInterpretationLiteral.
@Test
public void testNegatedFixedInterpretationLiteral() {
String asp = "stuff(1). stuff(2). smallStuff(X) :- stuff(X), not X > 1.";
CompiledProgram evaluated = parseAndEvaluate.apply(asp);
Set<AnswerSet> answerSets = solveCompiledProg.apply(evaluated);
TestUtils.assertAnswerSetsEqual("stuff(1), stuff(2), smallStuff(1)", answerSets);
}
Aggregations