use of at.ac.tuwien.kr.alpha.core.programs.NormalProgramImpl in project Alpha by alpha-asp.
the class IntervalTermToIntervalAtom method apply.
@Override
public NormalProgram apply(NormalProgram inputProgram) {
boolean didChange = false;
List<NormalRule> rewrittenRules = new ArrayList<>();
for (NormalRule rule : inputProgram.getRules()) {
NormalRule rewrittenRule = rewriteIntervalSpecifications(rule);
rewrittenRules.add(rewrittenRule);
// If no rewriting occurred, the output rule is the same as the input to the rewriting.
if (rewrittenRule != rule) {
didChange = true;
}
}
// Return original program if no rule was actually rewritten.
if (!didChange) {
return inputProgram;
}
return new NormalProgramImpl(rewrittenRules, inputProgram.getFacts(), inputProgram.getInlineDirectives());
}
use of at.ac.tuwien.kr.alpha.core.programs.NormalProgramImpl in project Alpha by alpha-asp.
the class ArithmeticTermsRewriting method apply.
@Override
public NormalProgram apply(NormalProgram inputProgram) {
List<NormalRule> rewrittenRules = new ArrayList<>();
boolean didRewrite = false;
for (NormalRule inputProgramRule : inputProgram.getRules()) {
if (containsArithmeticTermsToRewrite(inputProgramRule)) {
rewrittenRules.add(rewriteRule(inputProgramRule));
didRewrite = true;
} else {
// Keep rule as-is if no ArithmeticTerm occurs.
rewrittenRules.add(inputProgramRule);
}
}
if (!didRewrite) {
return inputProgram;
}
// Create new program with rewritten rules.
return new NormalProgramImpl(rewrittenRules, inputProgram.getFacts(), inputProgram.getInlineDirectives());
}
Aggregations