Search in sources :

Example 31 with CompiledProgram

use of at.ac.tuwien.kr.alpha.core.programs.CompiledProgram in project Alpha by alpha-asp.

the class RuleGroundingOrderTest method testPositionFromWhichAllVarsAreBound_ground.

@Test
public void testPositionFromWhichAllVarsAreBound_ground() {
    String aspStr = "a :- b, not c.";
    CompiledProgram internalPrg = PARSE_AND_PREPROCESS.apply(aspStr);
    RuleGroundingInfo rgo0 = computeGroundingOrdersForRule(internalPrg, 0);
    assertEquals(0, rgo0.getFixedGroundingOrder().getPositionFromWhichAllVarsAreBound());
}
Also used : CompiledProgram(at.ac.tuwien.kr.alpha.core.programs.CompiledProgram) Test(org.junit.jupiter.api.Test)

Example 32 with CompiledProgram

use of at.ac.tuwien.kr.alpha.core.programs.CompiledProgram in project Alpha by alpha-asp.

the class AlphaImplTest method disableStratifiedEvalTest.

/**
 * Verifies that no stratified evaluation is performed up-front when disabled in config.
 */
@Test
public void disableStratifiedEvalTest() {
    // Note: This might be cleaner if the test used the debugSolve method from the interface
    String progstr = "p(a). q(X) :- p(X).";
    SystemConfig cfg = new SystemConfig();
    cfg.setEvaluateStratifiedPart(false);
    AlphaImpl system = new AlphaImpl(cfg);
    ASPCore2Program input = system.readProgramString(progstr);
    NormalProgram normal = system.normalizeProgram(input);
    CompiledProgram preprocessed = system.performProgramPreprocessing(normal);
    assertFalse(preprocessed.getFacts().contains(Atoms.newBasicAtom(Predicates.getPredicate("q", 1), Terms.newSymbolicConstant("a"))), "Preprocessed program contains fact derived from stratifiable rule, but should not!");
}
Also used : ASPCore2Program(at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) NormalProgram(at.ac.tuwien.kr.alpha.api.programs.NormalProgram) CompiledProgram(at.ac.tuwien.kr.alpha.core.programs.CompiledProgram) Test(org.junit.jupiter.api.Test)

Example 33 with CompiledProgram

use of at.ac.tuwien.kr.alpha.core.programs.CompiledProgram in project Alpha by alpha-asp.

the class AlphaImplTest method enableStratifiedEvalTest.

/**
 * Verifies that stratified evaluation is performed up-front if not otherwise configured.
 */
@Test
public void enableStratifiedEvalTest() {
    // Note: This might be cleaner if the test used the debugSolve method from the interface
    String progstr = "p(a). q(X) :- p(X).";
    SystemConfig cfg = new SystemConfig();
    AlphaImpl system = new AlphaImpl(cfg);
    ASPCore2Program input = system.readProgramString(progstr);
    NormalProgram normal = system.normalizeProgram(input);
    CompiledProgram preprocessed = system.performProgramPreprocessing(normal);
    assertTrue(preprocessed.getFacts().contains(Atoms.newBasicAtom(Predicates.getPredicate("q", 1), Terms.newSymbolicConstant("a"))), "Preprocessed program does not contain fact derived from stratifiable rule, but should!");
}
Also used : ASPCore2Program(at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program) SystemConfig(at.ac.tuwien.kr.alpha.api.config.SystemConfig) NormalProgram(at.ac.tuwien.kr.alpha.api.programs.NormalProgram) CompiledProgram(at.ac.tuwien.kr.alpha.core.programs.CompiledProgram) Test(org.junit.jupiter.api.Test)

Aggregations

CompiledProgram (at.ac.tuwien.kr.alpha.core.programs.CompiledProgram)33 Test (org.junit.jupiter.api.Test)30 AtomStoreImpl (at.ac.tuwien.kr.alpha.core.common.AtomStoreImpl)12 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)11 Literal (at.ac.tuwien.kr.alpha.api.programs.literals.Literal)11 AtomStore (at.ac.tuwien.kr.alpha.core.common.AtomStore)10 AnswerSet (at.ac.tuwien.kr.alpha.api.AnswerSet)9 TrailAssignment (at.ac.tuwien.kr.alpha.core.solver.TrailAssignment)9 NormalProgram (at.ac.tuwien.kr.alpha.api.programs.NormalProgram)7 SystemConfig (at.ac.tuwien.kr.alpha.api.config.SystemConfig)6 BasicAtom (at.ac.tuwien.kr.alpha.api.programs.atoms.BasicAtom)6 NaiveGrounder (at.ac.tuwien.kr.alpha.core.grounder.NaiveGrounder)6 ProgramParserImpl (at.ac.tuwien.kr.alpha.core.parser.ProgramParserImpl)6 ProgramParser (at.ac.tuwien.kr.alpha.api.programs.ProgramParser)5 AnalyzedProgram (at.ac.tuwien.kr.alpha.core.programs.AnalyzedProgram)5 CompiledRule (at.ac.tuwien.kr.alpha.core.rules.CompiledRule)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Substitution (at.ac.tuwien.kr.alpha.api.grounder.Substitution)4 BasicSubstitution (at.ac.tuwien.kr.alpha.commons.substitutions.BasicSubstitution)4 Instance (at.ac.tuwien.kr.alpha.commons.substitutions.Instance)4