use of com.sri.ai.grinder.rewriter.api.TopRewriter in project aic-expresso by aic-sri-international.
the class CompoundTheory method makeTopRewriter.
@Override
public TopRewriter makeTopRewriter() {
List<TopRewriter> subRewriters = mapIntoList(subTheories, t -> t.getTopRewriter());
TopRewriter topRewriter = TopRewriter.makeTopRewriterFromTopRewritersThatAreEitherFirstOfOrSwitches(subRewriters);
return topRewriter;
}
use of com.sri.ai.grinder.rewriter.api.TopRewriter in project aic-expresso by aic-sri-international.
the class ProceduralAttachments method registerProceduralAttachment.
/**
* This method registers a procedural attachment top rewriter to a function with a given arity;
* the check of functor and arity will be added to the given top rewriter, so it does not need to do that.
* @param functor
* @param proceduralAttachmentParameters
* @param topRewriter
* @param context
* @return
*/
public static void registerProceduralAttachment(Expression functor, int arity, TopRewriter topRewriter, Context context) {
TopRewriter proceduralAttachment = new FunctorSwitch(functor.toString(), arity, topRewriter);
context.updateInplaceGlobalObject(PROCEDURAL_ATTACHEMENTS_KEY, EMPTY_REWRITER_MAKER, combine(proceduralAttachment));
}
use of com.sri.ai.grinder.rewriter.api.TopRewriter in project aic-expresso by aic-sri-international.
the class ProceduralAttachments method registerProceduralAttachment.
/**
* Same as {@link #registerProceduralAttachment(Expression, List, TopRewriter, Context)},
* but for a symbol.
* @param symbol
* @param topRewriter
* @param context
* @return
*/
public static void registerProceduralAttachment(Expression symbol, TopRewriter topRewriter, Context context) {
TopRewriter proceduralAttachment = new SymbolSwitch(symbol.toString(), topRewriter);
context.updateInplaceGlobalObject(PROCEDURAL_ATTACHEMENTS_KEY, EMPTY_REWRITER_MAKER, combine(proceduralAttachment));
}
use of com.sri.ai.grinder.rewriter.api.TopRewriter in project aic-expresso by aic-sri-international.
the class AbstractInterpreter method setBaseTopRewriter.
public void setBaseTopRewriter(TopRewriter baseTopRewriter) {
Rewriter result = new Recursive(new Exhaustive(new TopRewriterUsingQuantifierEliminatorAndContextAssignments(baseTopRewriter)));
setBaseRewriter(result);
}
use of com.sri.ai.grinder.rewriter.api.TopRewriter in project aic-expresso by aic-sri-international.
the class ProceduralAttachmentsTest method runTest.
private void runTest(Expression input, Expression expected, Context context) {
TopRewriter topRewriter;
Rewriter evaluator;
Expression output;
topRewriter = new CombiningTopRewriter(new CommonSimplifier(), getProceduralAttachmentsTopRewriter(context));
evaluator = new Recursive(new Exhaustive(topRewriter));
output = evaluator.apply(input, context);
println(output);
assertEquals(expected, output);
}
Aggregations