Search in sources :

Example 6 with Recursive

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

the class AbstractTheory method setTopRewriter.

/**
	 * Sets the theory's rewriter.
	 * @param topRewriter
	 */
protected void setTopRewriter(TopRewriter topRewriter) {
    this.topRewriter = topRewriter;
    this.cachedRecursiveExhaustiveTopRewriter = new Recursive(new Exhaustive(topRewriter));
}
Also used : Exhaustive(com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive) Recursive(com.sri.ai.grinder.sgdpllt.rewriter.core.Recursive)

Example 7 with Recursive

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

the class SetDNFRewriter method createBaseRewriter.

private static Rewriter createBaseRewriter() {
    // Original Rewriters		
    TopRewriter topRewriter = new DefaultTopRewriter(new IntensionalUnionToUnionsOfIntensionalSetsOfBaseTypeTopRewriter(), // NOTE: added to simplify expressions like `if true then { (2, 2) } else {  }', which are common in this setup
    new BooleanSimplifier(), new UnionEmptySetTopRewriter(), new IntersectionEmptySetTopRewriter(), new IntensionalSetToConditionalTopRewriter(), new IntersectionIntensionalSetsTopRewriter(), new IntersectionExtensionalSetTopRewriter(), new DistributeIntersectionOverUnionTopRewriter());
    // Rewriters based on UAI 2017 Paper
    //		TopRewriter topRewriter = new DefaultTopRewriter(
    //			new TupleEqualityTopRewriter(),                               // Rule 1		
    //			new ElementOfExtensionalSetTopRewriter(),                     // Rule 2
    //			new ElementOfIntensionalUnionTopRewriter(),                   // Rule 3
    //			new IntensionalUnionEqualToEmptySetTopRewriter(),             // Rule 4
    //			new IntersectionEmptySetTopRewriter(),                        // Rule 5			
    //			new UnionEmptySetTopRewriter(),                               // Rule 6			
    //			new SetIntersectExtensionalSetEqualToEmptySetTopRewriter(),   // Rule 7
    //			new IntensionalUnionIntersectionEqualToEmptySetTopRewriter(), // Rule 8
    //			new DistributeIntersectionOverUnionTopRewriter(),             // Rule 9
    //			new UnionOfSetsEqualEmptySetTopRewriter(),                    // Rule 10
    //			new ExtensionalSetEqualEmptySetTopRewriter(),                 // Rule 11
    //			new BooleanSimplifier() // NOTE: added to simplify expressions like `if true then { (2, 2) } else {  }', which are common in this setup
    //			);		
    Rewriter literalExternalizer = new LiteralRewriter(new Recursive(new Exhaustive(topRewriter)));
    Rewriter result = new Exhaustive(new FirstOf(topRewriter, literalExternalizer));
    return result;
}
Also used : DefaultTopRewriter(com.sri.ai.grinder.sgdpllt.rewriter.core.DefaultTopRewriter) Exhaustive(com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive) DefaultTopRewriter(com.sri.ai.grinder.sgdpllt.rewriter.core.DefaultTopRewriter) TupleEqualityTopRewriter(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleEqualityTopRewriter) TopRewriter(com.sri.ai.grinder.sgdpllt.rewriter.api.TopRewriter) BooleanSimplifier(com.sri.ai.grinder.sgdpllt.library.boole.BooleanSimplifier) LiteralRewriter(com.sri.ai.grinder.sgdpllt.library.boole.LiteralRewriter) Rewriter(com.sri.ai.grinder.sgdpllt.rewriter.api.Rewriter) LiteralRewriter(com.sri.ai.grinder.sgdpllt.library.boole.LiteralRewriter) DefaultTopRewriter(com.sri.ai.grinder.sgdpllt.rewriter.core.DefaultTopRewriter) TupleEqualityTopRewriter(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleEqualityTopRewriter) TopRewriter(com.sri.ai.grinder.sgdpllt.rewriter.api.TopRewriter) FirstOf(com.sri.ai.grinder.sgdpllt.rewriter.core.FirstOf) Recursive(com.sri.ai.grinder.sgdpllt.rewriter.core.Recursive)

Example 8 with Recursive

use of com.sri.ai.grinder.sgdpllt.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.registerAdditionalSymbolsAndTypes(symbolsAndTypes);
    Rewriter recursive = new Recursive(rewriter);
    Expression solution = recursive.apply(initial, context);
    System.out.println("Solution: " + solution);
    assertEquals(expected, solution);
}
Also used : Context(com.sri.ai.grinder.sgdpllt.api.Context) TrueContext(com.sri.ai.grinder.sgdpllt.core.TrueContext) Expression(com.sri.ai.expresso.api.Expression) DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) Rewriter(com.sri.ai.grinder.sgdpllt.rewriter.api.Rewriter) PropositionalTheory(com.sri.ai.grinder.sgdpllt.theory.propositional.PropositionalTheory) CompoundTheory(com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory) Recursive(com.sri.ai.grinder.sgdpllt.rewriter.core.Recursive) TrueContext(com.sri.ai.grinder.sgdpllt.core.TrueContext)

Aggregations

Recursive (com.sri.ai.grinder.sgdpllt.rewriter.core.Recursive)8 Rewriter (com.sri.ai.grinder.sgdpllt.rewriter.api.Rewriter)7 TopRewriter (com.sri.ai.grinder.sgdpllt.rewriter.api.TopRewriter)6 Exhaustive (com.sri.ai.grinder.sgdpllt.rewriter.core.Exhaustive)6 Expression (com.sri.ai.expresso.api.Expression)3 Context (com.sri.ai.grinder.sgdpllt.api.Context)3 LiteralRewriter (com.sri.ai.grinder.sgdpllt.library.boole.LiteralRewriter)3 FirstOf (com.sri.ai.grinder.sgdpllt.rewriter.core.FirstOf)3 ExpressionLiteralSplitterStepSolver (com.sri.ai.grinder.sgdpllt.api.ExpressionLiteralSplitterStepSolver)2 TrueContext (com.sri.ai.grinder.sgdpllt.core.TrueContext)2 ForAllRewriter (com.sri.ai.grinder.sgdpllt.library.boole.ForAllRewriter)2 ThereExistsRewriter (com.sri.ai.grinder.sgdpllt.library.boole.ThereExistsRewriter)2 MaxRewriter (com.sri.ai.grinder.sgdpllt.library.number.MaxRewriter)2 ProductRewriter (com.sri.ai.grinder.sgdpllt.library.number.ProductRewriter)2 SummationRewriter (com.sri.ai.grinder.sgdpllt.library.number.SummationRewriter)2 DefaultTopRewriter (com.sri.ai.grinder.sgdpllt.rewriter.core.DefaultTopRewriter)2 CompoundTheory (com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory)2 DifferenceArithmeticTheory (com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory)2 PropositionalTheory (com.sri.ai.grinder.sgdpllt.theory.propositional.PropositionalTheory)2 BooleanSimplifier (com.sri.ai.grinder.sgdpllt.library.boole.BooleanSimplifier)1