Search in sources :

Example 11 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.

the class MaximumExpressionStepSolverTest method test.

@Test
public void test() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
    Context context = theoryTestingSupport.makeContextWithTestingInformation();
    List<String> expressionStrings;
    String order;
    Expression orderMinimum;
    Expression orderMaximum;
    Expression expected;
    expressionStrings = list("I", "J");
    expected = parse("if I < J then J else I");
    order = LESS_THAN;
    orderMinimum = MINUS_INFINITY;
    orderMaximum = INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("I", "J");
    expected = parse("if I > J then J else I");
    order = GREATER_THAN;
    orderMinimum = INFINITY;
    orderMaximum = MINUS_INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("2", "3", "J");
    expected = parse("if 3 < J then J else 3");
    order = LESS_THAN;
    orderMinimum = MINUS_INFINITY;
    orderMaximum = INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("2", "I", "3", "J");
    expected = parse("if 2 < I then if I < J then J else I else if 3 < J then J else 3");
    order = LESS_THAN;
    orderMinimum = MINUS_INFINITY;
    orderMaximum = INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("1", "2");
    expected = parse("2");
    order = LESS_THAN;
    orderMinimum = MINUS_INFINITY;
    orderMaximum = INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("1", "2");
    expected = parse("1");
    order = GREATER_THAN;
    orderMinimum = INFINITY;
    orderMaximum = MINUS_INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("1", "-infinity");
    expected = parse("1");
    order = LESS_THAN;
    orderMinimum = MINUS_INFINITY;
    orderMaximum = INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
    expressionStrings = list("1", "infinity");
    expected = parse("infinity");
    order = LESS_THAN;
    orderMinimum = MINUS_INFINITY;
    orderMaximum = INFINITY;
    runTest(expressionStrings, order, orderMinimum, orderMaximum, expected, context);
}
Also used : Context(com.sri.ai.grinder.sgdpllt.api.Context) Expression(com.sri.ai.expresso.api.Expression) TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) Test(org.junit.Test)

Example 12 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.

the class SelectExpressionsSatisfyingComparisonStepSolverTest method test.

@Test
public void test() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
    Context context = theoryTestingSupport.makeContextWithTestingInformation();
    List<String> expressionStrings;
    Expression bound;
    Expression expected;
    expressionStrings = list("I", "J");
    bound = parse("J");
    expected = parse("if I < J then list(I) else list()");
    runTest(expressionStrings, bound, expected, context);
    expressionStrings = list("I", "2", "J");
    bound = parse("3");
    expected = parse("if I < 3 then if J < 3 then list(I, 2, J) else list(I, 2) else if J < 3 then list(2, J) else list(2)");
    runTest(expressionStrings, bound, expected, context);
    expressionStrings = list();
    bound = parse("3");
    expected = parse("list()");
    runTest(expressionStrings, bound, expected, context);
    expressionStrings = list("I", "2", "J");
    bound = parse("infinity");
    expected = parse("list(I, 2, J)");
    runTest(expressionStrings, bound, expected, context);
    expressionStrings = list("I", "2", "J");
    bound = parse("-infinity");
    expected = parse("list()");
    runTest(expressionStrings, bound, expected, context);
    expressionStrings = list("I", "2", "infinity");
    bound = parse("3");
    expected = parse("if I < 3 then list(I, 2) else list(2)");
    runTest(expressionStrings, bound, expected, context);
}
Also used : Context(com.sri.ai.grinder.sgdpllt.api.Context) Expression(com.sri.ai.expresso.api.Expression) TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) Test(org.junit.Test)

Example 13 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.

the class IntensionalSetConditionSimplifierTest method setUp.

@Before
public void setUp() {
    context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
    IntegerInterval nType = new IntegerInterval(1, 10);
    context = (Context) GrinderUtil.extendRegistryWith(map("N", nType.toString()), Arrays.asList(nType), context);
    simplifier = new IntensionalSetConditionSimplifier();
}
Also used : IntensionalSetConditionSimplifier(com.sri.ai.grinder.sgdpllt.library.set.IntensionalSetConditionSimplifier) DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) CompoundTheory(com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.sgdpllt.core.TrueContext) TupleTheory(com.sri.ai.grinder.sgdpllt.theory.tuple.TupleTheory) Before(org.junit.Before)

Example 14 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.

the class IntensionalSetFalseConditionToEmptySetSimplifierTest method setUp.

@Before
public void setUp() {
    context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
    IntegerInterval nType = new IntegerInterval(1, 10);
    context = (Context) GrinderUtil.extendRegistryWith(map("N", nType.toString()), Arrays.asList(nType), context);
    simplifier = new IntensionalSetFalseConditionToEmptySetSimplifier();
}
Also used : DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) CompoundTheory(com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.sgdpllt.core.TrueContext) TupleTheory(com.sri.ai.grinder.sgdpllt.theory.tuple.TupleTheory) IntensionalSetFalseConditionToEmptySetSimplifier(com.sri.ai.grinder.sgdpllt.library.set.IntensionalSetFalseConditionToEmptySetSimplifier) Before(org.junit.Before)

Example 15 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.

the class IntersectionIntensionalSetsSimplifierTest method setUp.

@Before
public void setUp() {
    context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
    IntegerInterval nType = new IntegerInterval(1, 10);
    context = (Context) GrinderUtil.extendRegistryWith(map("N", nType.toString()), Arrays.asList(nType), context);
    simplifier = new IntersectionIntensionalSetsSimplifier();
}
Also used : DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) IntersectionIntensionalSetsSimplifier(com.sri.ai.grinder.sgdpllt.library.set.invsupport.IntersectionIntensionalSetsSimplifier) CompoundTheory(com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.sgdpllt.core.TrueContext) TupleTheory(com.sri.ai.grinder.sgdpllt.theory.tuple.TupleTheory) Before(org.junit.Before)

Aggregations

DifferenceArithmeticTheory (com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory)46 CompoundTheory (com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory)34 Context (com.sri.ai.grinder.sgdpllt.api.Context)28 Expression (com.sri.ai.expresso.api.Expression)25 Test (org.junit.Test)25 PropositionalTheory (com.sri.ai.grinder.sgdpllt.theory.propositional.PropositionalTheory)24 TheoryTestingSupport (com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport)23 TrueContext (com.sri.ai.grinder.sgdpllt.core.TrueContext)22 EqualityTheory (com.sri.ai.grinder.sgdpllt.theory.equality.EqualityTheory)20 TupleTheory (com.sri.ai.grinder.sgdpllt.theory.tuple.TupleTheory)16 IntegerInterval (com.sri.ai.expresso.type.IntegerInterval)15 Before (org.junit.Before)11 Type (com.sri.ai.expresso.api.Type)8 LinearRealArithmeticTheory (com.sri.ai.grinder.sgdpllt.theory.linearrealarithmetic.LinearRealArithmeticTheory)8 Theory (com.sri.ai.grinder.sgdpllt.api.Theory)7 FunctionType (com.sri.ai.expresso.type.FunctionType)5 LinkedHashMap (java.util.LinkedHashMap)5 StepSolver (com.sri.ai.grinder.sgdpllt.api.StepSolver)4 Rewriter (com.sri.ai.grinder.sgdpllt.rewriter.api.Rewriter)4 Categorical (com.sri.ai.expresso.type.Categorical)3