Search in sources :

Example 1 with MethodPredicateInterpretation

use of at.ac.tuwien.kr.alpha.core.common.fixedinterpretations.MethodPredicateInterpretation in project Alpha by alpha-asp.

the class AlphaImplTest method withExternalSubtype.

@Test
public void withExternalSubtype() throws Exception {
    SubThingy thingy = new SubThingy();
    BasicRule rule = new BasicRule(Heads.newNormalHead(Atoms.newBasicAtom(Predicates.getPredicate("p", 1), Terms.newConstant("x"))), singletonList(Literals.fromAtom(Atoms.newExternalAtom(Predicates.getPredicate("thinger", 1), new MethodPredicateInterpretation(this.getClass().getMethod("thinger", Thingy.class)), singletonList(Terms.newConstant(thingy)), emptyList()), true)));
    Alpha system = new AlphaImpl();
    InputProgram prog = new InputProgram(singletonList(rule), emptyList(), new InlineDirectivesImpl());
    Set<AnswerSet> actual = system.solve(prog).collect(Collectors.toSet());
    Set<AnswerSet> expected = new HashSet<>(singletonList(new AnswerSetBuilder().predicate("p").instance("x").build()));
    assertEquals(expected, actual);
}
Also used : BasicRule(at.ac.tuwien.kr.alpha.core.rules.BasicRule) AnswerSet(at.ac.tuwien.kr.alpha.api.AnswerSet) Alpha(at.ac.tuwien.kr.alpha.api.Alpha) MethodPredicateInterpretation(at.ac.tuwien.kr.alpha.core.common.fixedinterpretations.MethodPredicateInterpretation) AnswerSetBuilder(at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder) InlineDirectivesImpl(at.ac.tuwien.kr.alpha.core.parser.InlineDirectivesImpl) InputProgram(at.ac.tuwien.kr.alpha.core.programs.InputProgram) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

Alpha (at.ac.tuwien.kr.alpha.api.Alpha)1 AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)1 AnswerSetBuilder (at.ac.tuwien.kr.alpha.commons.AnswerSetBuilder)1 MethodPredicateInterpretation (at.ac.tuwien.kr.alpha.core.common.fixedinterpretations.MethodPredicateInterpretation)1 InlineDirectivesImpl (at.ac.tuwien.kr.alpha.core.parser.InlineDirectivesImpl)1 InputProgram (at.ac.tuwien.kr.alpha.core.programs.InputProgram)1 BasicRule (at.ac.tuwien.kr.alpha.core.rules.BasicRule)1 HashSet (java.util.HashSet)1 Test (org.junit.jupiter.api.Test)1