Search in sources :

Example 1 with SamplingProceduralAttachmentSingleQuantifierEliminator

use of com.sri.ai.grinder.interpreter.SamplingProceduralAttachmentSingleQuantifierEliminator in project aic-expresso by aic-sri-international.

the class SamplingProceduralAttachmentSingleQuantifierEliminatorTest method test.

@Test
public void test() {
    String intervalString = "0..10";
    Context context = new TrueContext(new DifferenceArithmeticTheory(true, true));
    MultiQuantifierEliminationProblem problem = new DefaultMultiQuantifierEliminationProblem(new Sum(), list(parse("I")), list(parse(intervalString)), parse("I != 3"), parse("I^2"));
    SamplingProceduralAttachmentSingleQuantifierEliminator eliminator = new SamplingProceduralAttachmentSingleQuantifierEliminator(new CommonSimplifier(), new Random());
    // SHOULD NOT HAVE TO
    context = problem.extend(context);
    Expression sampler = eliminator.solve(problem, context);
    println(sampler);
    Rewriter rewriter = new CombiningTopRewriter(new CommonSimplifier(), ProceduralAttachments.getProceduralAttachmentsTopRewriter(context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
    println(rewriter.apply(sampler, context));
}
Also used : TrueContext(com.sri.ai.grinder.core.TrueContext) Context(com.sri.ai.grinder.api.Context) CommonSimplifier(com.sri.ai.grinder.library.commonrewriters.CommonSimplifier) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Sum(com.sri.ai.grinder.group.Sum) TrueContext(com.sri.ai.grinder.core.TrueContext) SamplingProceduralAttachmentSingleQuantifierEliminator(com.sri.ai.grinder.interpreter.SamplingProceduralAttachmentSingleQuantifierEliminator) Random(java.util.Random) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) Expression(com.sri.ai.expresso.api.Expression) DefaultMultiQuantifierEliminationProblem(com.sri.ai.grinder.core.solver.DefaultMultiQuantifierEliminationProblem) MultiQuantifierEliminationProblem(com.sri.ai.grinder.api.MultiQuantifierEliminationProblem) DefaultMultiQuantifierEliminationProblem(com.sri.ai.grinder.core.solver.DefaultMultiQuantifierEliminationProblem) CombiningTopRewriter(com.sri.ai.grinder.rewriter.core.CombiningTopRewriter) Rewriter(com.sri.ai.grinder.rewriter.api.Rewriter) Test(org.junit.Test)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)1 Context (com.sri.ai.grinder.api.Context)1 MultiQuantifierEliminationProblem (com.sri.ai.grinder.api.MultiQuantifierEliminationProblem)1 TrueContext (com.sri.ai.grinder.core.TrueContext)1 DefaultMultiQuantifierEliminationProblem (com.sri.ai.grinder.core.solver.DefaultMultiQuantifierEliminationProblem)1 Sum (com.sri.ai.grinder.group.Sum)1 SamplingProceduralAttachmentSingleQuantifierEliminator (com.sri.ai.grinder.interpreter.SamplingProceduralAttachmentSingleQuantifierEliminator)1 CommonSimplifier (com.sri.ai.grinder.library.commonrewriters.CommonSimplifier)1 Rewriter (com.sri.ai.grinder.rewriter.api.Rewriter)1 CombiningTopRewriter (com.sri.ai.grinder.rewriter.core.CombiningTopRewriter)1 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)1 Random (java.util.Random)1 Test (org.junit.Test)1