use of com.sri.ai.grinder.rewriter.api.Rewriter in project aic-expresso by aic-sri-international.
the class FirstOfTest method runTest.
private void runTest(List<Rewriter> rewriters, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
Rewriter firstOf = new FirstOf(rewriters);
Expression solution = firstOf.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.rewriter.api.Rewriter in project aic-expresso by aic-sri-international.
the class RecursiveTest method runTest.
private void runTest(Rewriter rewriter, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
Rewriter recursive = new Recursive(rewriter);
Expression solution = recursive.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.rewriter.api.Rewriter in project aic-expresso by aic-sri-international.
the class SwitchTest method runTest.
private void runTest(Rewriter rewriter, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
Rewriter recursive = new Recursive(rewriter);
Expression solution = recursive.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.rewriter.api.Rewriter in project aic-expresso by aic-sri-international.
the class Switch method makeStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver makeStepSolver(Expression expression) {
ExpressionLiteralSplitterStepSolver result;
T key = keyMaker.apply(expression);
Rewriter baseRewriter = fromKeyValueToRewriter.get(key);
if (baseRewriter != null) {
result = baseRewriter.makeStepSolver(expression);
} else {
result = new ConstantExpressionStepSolver(expression);
}
return result;
}
use of com.sri.ai.grinder.rewriter.api.Rewriter in project aic-expresso by aic-sri-international.
the class SymbolicShell method evaluate.
private static void evaluate(Expression input, ConsoleIterator consoleIterator, Theory theory, Context context) {
Rewriter prettyRewriter = new Exhaustive(new Recursive(new FirstOf(theory.getTopRewriter(), new PrettySimplifier())));
Expression result = theory.evaluate(input, context);
result = prettyRewriter.apply(result, context);
consoleIterator.getOutputWriter().println(result + "\n");
}
Aggregations