use of at.ac.tuwien.kr.alpha.grounder.Grounder in project Alpha by alpha-asp.
the class SolverTests method testFactsOnlyProgram.
@Test
public void testFactsOnlyProgram() throws IOException {
String testProgram = "p(a). p(b). foo(13). foo(16). q(a). q(c).";
ParsedProgram parsedProgram = parseVisit(testProgram);
Grounder grounder = new NaiveGrounder(parsedProgram);
Solver solver = getInstance(grounder);
List<AnswerSet> answerSets = solver.collectList();
assertEquals(1, answerSets.size());
AnswerSet expected = new BasicAnswerSet.Builder().predicate("q").instance("a").instance("c").predicate("p").instance("a").instance("b").predicate("foo").instance("13").instance("16").build();
assertEquals(expected, answerSets.get(0));
}
use of at.ac.tuwien.kr.alpha.grounder.Grounder in project Alpha by alpha-asp.
the class SolverTests method testSimpleRule.
@Test
public void testSimpleRule() throws Exception {
String testProgram = "p(a). p(b). r(X) :- p(X).";
ParsedProgram parsedProgram = parseVisit(testProgram);
Grounder grounder = new NaiveGrounder(parsedProgram);
Solver solver = getInstance(grounder);
List<AnswerSet> answerSets = solver.collectList();
AnswerSet expected = new BasicAnswerSet.Builder().predicate("p").instance("a").instance("b").predicate("r").instance("a").instance("b").build();
assertEquals(1, answerSets.size());
assertEquals(expected, answerSets.get(0));
}
use of at.ac.tuwien.kr.alpha.grounder.Grounder in project Alpha by alpha-asp.
the class SolverTests method testSimpleRuleWithGroundPart.
@Test
public void testSimpleRuleWithGroundPart() throws Exception {
String testProgram = "p(1)." + "p(2)." + "q(X) :- p(X), p(1).";
ParsedProgram parsedProgram = parseVisit(testProgram);
Grounder grounder = new NaiveGrounder(parsedProgram);
Solver solver = getInstance(grounder);
List<AnswerSet> answerSets = solver.collectList();
assertEquals(1, answerSets.size());
AnswerSet expected = new BasicAnswerSet.Builder().predicate("q").instance("1").instance("2").predicate("p").instance("1").instance("2").build();
assertEquals(expected, answerSets.get(0));
}
Aggregations