Search in sources :

Example 21 with CompiledRule

use of at.ac.tuwien.kr.alpha.core.rules.CompiledRule in project Alpha by alpha-asp.

the class SubstitutionTest method groundAndPrintRule.

@Test
public void groundAndPrintRule() {
    Rule<Head> rule = PARSER.parse("x :- p(X,Y), not q(X,Y).").getRules().get(0);
    CompiledRule nonGroundRule = InternalRule.fromNormalRule(NormalRuleImpl.fromBasicRule(rule));
    Substitution substitution1 = BasicSubstitution.specializeSubstitution(PX, PA, BasicSubstitution.EMPTY_SUBSTITUTION);
    Substitution substitution2 = BasicSubstitution.specializeSubstitution(PY, PB, substitution1);
    String printedString = SubstitutionTestUtil.groundAndPrintRule(nonGroundRule, substitution2);
    assertEquals("x :- p(a, b), not q(a, b).", printedString);
}
Also used : Head(at.ac.tuwien.kr.alpha.api.rules.heads.Head) Substitution(at.ac.tuwien.kr.alpha.api.grounder.Substitution) BasicSubstitution(at.ac.tuwien.kr.alpha.commons.substitutions.BasicSubstitution) CompiledRule(at.ac.tuwien.kr.alpha.core.rules.CompiledRule) Test(org.junit.jupiter.api.Test)

Aggregations

CompiledRule (at.ac.tuwien.kr.alpha.core.rules.CompiledRule)21 Literal (at.ac.tuwien.kr.alpha.api.programs.literals.Literal)10 BasicSubstitution (at.ac.tuwien.kr.alpha.commons.substitutions.BasicSubstitution)10 Substitution (at.ac.tuwien.kr.alpha.api.grounder.Substitution)9 Predicate (at.ac.tuwien.kr.alpha.api.programs.Predicate)8 Test (org.junit.jupiter.api.Test)8 Instance (at.ac.tuwien.kr.alpha.commons.substitutions.Instance)7 Atom (at.ac.tuwien.kr.alpha.api.programs.atoms.Atom)6 RuleAtom (at.ac.tuwien.kr.alpha.core.atoms.RuleAtom)6 NoGood (at.ac.tuwien.kr.alpha.core.common.NoGood)6 Map (java.util.Map)6 BindingResult (at.ac.tuwien.kr.alpha.core.grounder.instantiation.BindingResult)5 CompiledProgram (at.ac.tuwien.kr.alpha.core.programs.CompiledProgram)5 ASPCore2Program (at.ac.tuwien.kr.alpha.api.programs.ASPCore2Program)4 NormalProgram (at.ac.tuwien.kr.alpha.api.programs.NormalProgram)4 AtomStore (at.ac.tuwien.kr.alpha.core.common.AtomStore)4 AtomStoreImpl (at.ac.tuwien.kr.alpha.core.common.AtomStoreImpl)4 AnalyzedProgram (at.ac.tuwien.kr.alpha.core.programs.AnalyzedProgram)4 InternalProgram (at.ac.tuwien.kr.alpha.core.programs.InternalProgram)4 Collections (java.util.Collections)4