Search in sources :

Example 1 with Recursive

use of com.sri.ai.grinder.rewriter.core.Recursive 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);
}
Also used : Exhaustive(com.sri.ai.grinder.rewriter.core.Exhaustive) ForAllRewriter(com.sri.ai.grinder.library.boole.ForAllRewriter) MaxRewriter(com.sri.ai.grinder.library.number.MaxRewriter) ThereExistsRewriter(com.sri.ai.grinder.library.boole.ThereExistsRewriter) ProductRewriter(com.sri.ai.grinder.library.number.ProductRewriter) RedirectingRewriter(com.sri.ai.grinder.rewriter.help.RedirectingRewriter) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) TopRewriter(com.sri.ai.grinder.rewriter.api.TopRewriter) SummationRewriter(com.sri.ai.grinder.library.number.SummationRewriter) Recursive(com.sri.ai.grinder.rewriter.core.Recursive)

Example 2 with Recursive

use of com.sri.ai.grinder.rewriter.core.Recursive in project aic-expresso by aic-sri-international.

the class SamplingAdderLazyIterator method makeSumOfSamplesIterator.

private AdderIterator makeSumOfSamplesIterator(MultiQuantifierEliminationProblem problem, TopRewriterUsingContextAssignments topRewriterUsingContextAssignments, Random random, Context context) {
    AssignmentsSamplingIterator sampledAssignmentsIterator = new AssignmentsSamplingIterator(problem.getIndices(), problem.getConstraint(), new Recursive(new Exhaustive(topRewriterUsingContextAssignments)), random, context);
    AdderIterator result = new AdderIterator(problem.getGroup(), sampledAssignmentsIterator, problem.getBody(), topRewriterUsingContextAssignments, context);
    return result;
}
Also used : Exhaustive(com.sri.ai.grinder.rewriter.core.Exhaustive) AssignmentsSamplingIterator(com.sri.ai.grinder.helper.AssignmentsSamplingIterator) Recursive(com.sri.ai.grinder.rewriter.core.Recursive)

Example 3 with Recursive

use of com.sri.ai.grinder.rewriter.core.Recursive 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);
}
Also used : CommonSimplifier(com.sri.ai.grinder.library.commonrewriters.CommonSimplifier) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) Expression(com.sri.ai.expresso.api.Expression) Exhaustive(com.sri.ai.grinder.rewriter.core.Exhaustive) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) ProceduralAttachments.getProceduralAttachmentsTopRewriter(com.sri.ai.grinder.library.proceduralattachment.ProceduralAttachments.getProceduralAttachmentsTopRewriter) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) TopRewriter(com.sri.ai.grinder.rewriter.api.TopRewriter) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) ProceduralAttachments.getProceduralAttachmentsTopRewriter(com.sri.ai.grinder.library.proceduralattachment.ProceduralAttachments.getProceduralAttachmentsTopRewriter) TopRewriter(com.sri.ai.grinder.rewriter.api.TopRewriter) Recursive(com.sri.ai.grinder.rewriter.core.Recursive)

Example 4 with Recursive

use of com.sri.ai.grinder.rewriter.core.Recursive 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);
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) Expression(com.sri.ai.expresso.api.Expression) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) Recursive(com.sri.ai.grinder.rewriter.core.Recursive) TrueContext(com.sri.ai.grinder.core.TrueContext)

Example 5 with Recursive

use of com.sri.ai.grinder.rewriter.core.Recursive 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);
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) Expression(com.sri.ai.expresso.api.Expression) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) TopRewriter(com.sri.ai.grinder.rewriter.api.TopRewriter) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) Recursive(com.sri.ai.grinder.rewriter.core.Recursive) TrueContext(com.sri.ai.grinder.core.TrueContext)

Aggregations

Recursive (com.sri.ai.grinder.rewriter.core.Recursive)8 Exhaustive (com.sri.ai.grinder.rewriter.core.Exhaustive)6 Rewriter (com.sri.ai.grinder.rewriter.api.Rewriter)5 Expression (com.sri.ai.expresso.api.Expression)4 TrueContext (com.sri.ai.grinder.core.TrueContext)3 TopRewriter (com.sri.ai.grinder.rewriter.api.TopRewriter)3 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)3 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)3 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)3 Context (com.sri.ai.grinder.api.Context)2 CombiningTopRewriter (com.sri.ai.grinder.rewriter.core.CombiningTopRewriter)2 AssignmentsSamplingIterator (com.sri.ai.grinder.helper.AssignmentsSamplingIterator)1 BruteForceCommonInterpreter (com.sri.ai.grinder.interpreter.BruteForceCommonInterpreter)1 ForAllRewriter (com.sri.ai.grinder.library.boole.ForAllRewriter)1 ThereExistsRewriter (com.sri.ai.grinder.library.boole.ThereExistsRewriter)1 CommonSimplifier (com.sri.ai.grinder.library.commonrewriters.CommonSimplifier)1 MaxRewriter (com.sri.ai.grinder.library.number.MaxRewriter)1 ProductRewriter (com.sri.ai.grinder.library.number.ProductRewriter)1 SummationRewriter (com.sri.ai.grinder.library.number.SummationRewriter)1 PrettySimplifier (com.sri.ai.grinder.library.pretty.PrettySimplifier)1