use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class HeadBodyTransformationTests method checkNumberOfRulesAndParse.
private ASPCore2Program checkNumberOfRulesAndParse(List<String> strRules, int numberOfRules) {
assertEquals(numberOfRules, strRules.size());
String strProgram = strRules.stream().collect(Collectors.joining(System.lineSeparator()));
ASPCore2Program parsedProgram = new ProgramParserImpl().parse(strProgram);
assertEquals(numberOfRules, parsedProgram.getRules().size());
return parsedProgram;
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class UnifierTest method parseAtom.
private BasicAtom parseAtom(String atom) {
ProgramParser programParser = new ProgramParserImpl();
ASPCore2Program program = programParser.parse(atom + ".");
return (BasicAtom) program.getFacts().get(0);
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class AtomsTest method testIsExternalAtomGround.
@Test
public void testIsExternalAtomGround() {
ASPCore2Program p1 = parser.parse("a :- &isFoo[1].", externals);
Atom ext1 = p1.getRules().get(0).getBody().stream().findFirst().get().getAtom();
assertExternalAtomGround(ext1, true);
ASPCore2Program p2 = parser.parse("a :- &isFoo[bar(1)].", externals);
Atom ext2 = p2.getRules().get(0).getBody().stream().findFirst().get().getAtom();
assertExternalAtomGround(ext2, true);
ASPCore2Program p3 = parser.parse("a :- &isFoo[BLA].", externals);
Atom ext3 = p3.getRules().get(0).getBody().stream().findFirst().get().getAtom();
assertExternalAtomGround(ext3, false);
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class AtomsTest method testIsBasicAtomGround.
@Test
public void testIsBasicAtomGround() {
ASPCore2Program p = parser.parse("bla(blubb, foo(bar)).");
Atom a = p.getFacts().get(0);
assertBasicAtomGround(a, true);
ASPCore2Program p1 = parser.parse("foo(1, 2, 3, \"bar\").");
Atom a1 = p1.getFacts().get(0);
assertBasicAtomGround(a1, true);
ASPCore2Program p2 = parser.parse("foo(BAR).");
Atom a2 = p2.getFacts().get(0);
assertBasicAtomGround(a2, false);
ASPCore2Program p3 = parser.parse("foo(b, a, r(\"bla\", BLUBB)).");
Atom a3 = p3.getFacts().get(0);
assertBasicAtomGround(a3, false);
}
use of at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program in project Alpha by alpha-asp.
the class AlphaImplTest method smallGraph.
@Test
public void smallGraph() throws Exception {
Alpha system = new AlphaImpl();
InputConfig inputCfg = InputConfig.forString("node(1). node(2). node(3). a :- &connected[1,2].");
inputCfg.addPredicateMethod("connected", Externals.processPredicate((Integer a, Integer b) -> (a == 1 && b == 2) || (b == 2 || b == 3)));
ASPCore2Program program = system.readProgram(inputCfg);
Set<AnswerSet> actual = system.solve(program).collect(Collectors.toSet());
Set<AnswerSet> expected = AnswerSetsParser.parse("{ a, node(1), node(2), node(3) }");
assertEquals(expected, actual);
}
Aggregations