Search in sources :

Example 1 with Exhaustive

use of com.sri.ai.grinder.rewriter.core.Exhaustive 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 Exhaustive

use of com.sri.ai.grinder.rewriter.core.Exhaustive 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 Exhaustive

use of com.sri.ai.grinder.rewriter.core.Exhaustive 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 Exhaustive

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

the class ExhaustiveTest 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 exhaustive = new Exhaustive(rewriter);
    Expression solution = exhaustive.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) Exhaustive(com.sri.ai.grinder.rewriter.core.Exhaustive) 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) TrueContext(com.sri.ai.grinder.core.TrueContext)

Example 5 with Exhaustive

use of com.sri.ai.grinder.rewriter.core.Exhaustive 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");
}
Also used : PrettySimplifier(com.sri.ai.grinder.library.pretty.PrettySimplifier) Expression(com.sri.ai.expresso.api.Expression) Exhaustive(com.sri.ai.grinder.rewriter.core.Exhaustive) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) FirstOf(com.sri.ai.grinder.rewriter.core.FirstOf) Recursive(com.sri.ai.grinder.rewriter.core.Recursive)

Aggregations

Exhaustive (com.sri.ai.grinder.rewriter.core.Exhaustive)7 Recursive (com.sri.ai.grinder.rewriter.core.Recursive)6 Rewriter (com.sri.ai.grinder.rewriter.api.Rewriter)4 Expression (com.sri.ai.expresso.api.Expression)3 TrueContext (com.sri.ai.grinder.core.TrueContext)2 TopRewriter (com.sri.ai.grinder.rewriter.api.TopRewriter)2 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)2 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)2 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)2 Context (com.sri.ai.grinder.api.Context)1 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 ProceduralAttachments.getProceduralAttachmentsTopRewriter (com.sri.ai.grinder.library.proceduralattachment.ProceduralAttachments.getProceduralAttachmentsTopRewriter)1