Search in sources :

Example 46 with TheoryTestingSupport

use of com.sri.ai.grinder.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testDifferenceArithmeticTheoryWithPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.

@Test
public void testDifferenceArithmeticTheoryWithPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
    extendTestingVariables("K", theoryTestingSupport, "L", "M", "N", "O", "P");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Test(org.junit.Test)

Example 47 with TheoryTestingSupport

use of com.sri.ai.grinder.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testDifferenceArithmeticTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.

@Test
public void testDifferenceArithmeticTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, false));
    extendTestingVariables("K", theoryTestingSupport, "L", "M", "N", "O", "P");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Test(org.junit.Test)

Example 48 with TheoryTestingSupport

use of com.sri.ai.grinder.tester.TheoryTestingSupport 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.api.Context) Expression(com.sri.ai.expresso.api.Expression) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Test(org.junit.Test)

Example 49 with TheoryTestingSupport

use of com.sri.ai.grinder.tester.TheoryTestingSupport 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.api.Context) Expression(com.sri.ai.expresso.api.Expression) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) Test(org.junit.Test)

Aggregations

TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)49 Test (org.junit.Test)42 Context (com.sri.ai.grinder.api.Context)36 Expression (com.sri.ai.expresso.api.Expression)26 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)22 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)20 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)17 FunctionType (com.sri.ai.expresso.type.FunctionType)13 Type (com.sri.ai.expresso.api.Type)12 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)11 StepSolver (com.sri.ai.grinder.api.StepSolver)10 UnificationStepSolver (com.sri.ai.grinder.theory.base.UnificationStepSolver)10 AbstractTheoryTestingSupport (com.sri.ai.grinder.core.constraint.AbstractTheoryTestingSupport)9 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)9 LinkedHashMap (java.util.LinkedHashMap)7 Constraint (com.sri.ai.grinder.api.Constraint)6 CompleteMultiVariableContext (com.sri.ai.grinder.core.constraint.CompleteMultiVariableContext)6 Ignore (org.junit.Ignore)5 Categorical (com.sri.ai.expresso.type.Categorical)4 TrueContext (com.sri.ai.grinder.core.TrueContext)4