use of at.ac.tuwien.kr.alpha.grounder.parser.ParsedProgram in project Alpha by alpha-asp.
the class ParserTest method parseFactWithFunctionTerms.
@Test
public void parseFactWithFunctionTerms() throws IOException {
ParsedProgram parsedProgram = parseVisit("p(f(a),g(h(Y))).");
assertEquals("Program contains one fact.", 1, parsedProgram.facts.size());
assertEquals("Predicate name of fact is p.", "p", parsedProgram.facts.get(0).getFact().getPredicate());
assertEquals("Fact has two terms.", 2, parsedProgram.facts.get(0).getFact().getArity());
assertEquals("First term is function term f.", "f", ((ParsedFunctionTerm) parsedProgram.facts.get(0).getFact().getTerms().get(0)).getFunctionName());
assertEquals("Second term is function term g.", "g", ((ParsedFunctionTerm) parsedProgram.facts.get(0).getFact().getTerms().get(1)).getFunctionName());
}
use of at.ac.tuwien.kr.alpha.grounder.parser.ParsedProgram in project Alpha by alpha-asp.
the class ParserTest method parseSmallProgram.
@Test
public void parseSmallProgram() throws IOException {
ParsedProgram parsedProgram = parseVisit("a :- b, not d.\n" + "c(X) :- p(X,a,_), q(Xaa,xaa). :- f(Y).");
assertEquals("Program contains two rules.", 2, parsedProgram.rules.size());
assertEquals("Program contains one constraint.", 1, parsedProgram.constraints.size());
}
use of at.ac.tuwien.kr.alpha.grounder.parser.ParsedProgram in project Alpha by alpha-asp.
the class ParserTest method parseBuiltinAtom.
@Test
public void parseBuiltinAtom() throws IOException {
ParsedProgram parsedProgram = parseVisit("a :- p(X), X != Y, q(Y).");
assertEquals(1, parsedProgram.rules.size());
assertEquals(3, parsedProgram.rules.get(0).body.size());
}
use of at.ac.tuwien.kr.alpha.grounder.parser.ParsedProgram in project Alpha by alpha-asp.
the class ChoiceManagerTests method setUp.
@Before
public void setUp() throws IOException {
String testProgram = "h :- b1, b2, not b3, not b4.";
ParsedProgram parsedProgram = parseVisit(testProgram);
this.grounder = new NaiveGrounder(parsedProgram);
Assignment assignment = new ArrayAssignment();
this.choiceManager = new ChoiceManager(assignment);
}
use of at.ac.tuwien.kr.alpha.grounder.parser.ParsedProgram in project Alpha by alpha-asp.
the class OmigaBenchmarksTest method test.
private void test(String folder, String aspFileName) throws IOException {
ANTLRFileStream programInputStream = new ANTLRFileStream(Paths.get("benchmarks", "omiga", "omiga-testcases", folder, aspFileName).toString());
ParsedProgram parsedProgram = parseVisit(programInputStream);
NaiveGrounder grounder = new NaiveGrounder(parsedProgram);
Solver solver = getInstance(grounder);
Optional<AnswerSet> answerSet = solver.stream().findFirst();
System.out.println(answerSet);
// TODO: check correctness of answer set
}
Aggregations