Search in sources :

Example 41 with DifferenceArithmeticTheory

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

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testCompoundTheoryWithDifferenceArithmeticWithRandomDisjunctiveFormulas.

@Test
public void testCompoundTheoryWithDifferenceArithmeticWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, true), new PropositionalTheory()));
    // using different testing variables and types to test distribution of testing information
    // to sub constraint theories.
    Categorical booleanType = BOOLEAN_TYPE;
    Categorical dogsType = new Categorical("Dogs", 4, arrayList(parse("fido"), parse("rex")));
    IntegerInterval oneTwoThree = new IntegerInterval(1, 3);
    Map<String, Type> variablesAndTypes = map("F", booleanType, "G", booleanType, "R", dogsType, "S", dogsType, "T", oneTwoThree, "U", oneTwoThree);
    theoryTestingSupport.setVariableNamesAndTypesForTesting(variablesAndTypes);
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) Type(com.sri.ai.expresso.api.Type) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) Categorical(com.sri.ai.expresso.type.Categorical) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) Test(org.junit.Test)

Example 42 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory 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 43 with DifferenceArithmeticTheory

use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory 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 44 with DifferenceArithmeticTheory

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

the class AssignmentsSamplingIteratorTest method setUp.

@Before
public void setUp() {
    // Make tests repeatable
    random = new Random(1);
    conditionRewriter = new Recursive(new Exhaustive(new BruteForceCommonInterpreter()));
    context = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new LinearRealArithmeticTheory(false, false), new EqualityTheory(false, false), new PropositionalTheory()));
}
Also used : BruteForceCommonInterpreter(com.sri.ai.grinder.interpreter.BruteForceCommonInterpreter) EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) Random(java.util.Random) Exhaustive(com.sri.ai.grinder.rewriter.core.Exhaustive) DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) LinearRealArithmeticTheory(com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) Recursive(com.sri.ai.grinder.rewriter.core.Recursive) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) Before(org.junit.Before)

Example 45 with DifferenceArithmeticTheory

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

DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)53 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)36 Context (com.sri.ai.grinder.api.Context)31 TrueContext (com.sri.ai.grinder.core.TrueContext)28 Expression (com.sri.ai.expresso.api.Expression)27 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)26 Test (org.junit.Test)23 TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)22 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)22 TupleTheory (com.sri.ai.grinder.theory.tuple.TupleTheory)19 IntegerInterval (com.sri.ai.expresso.type.IntegerInterval)15 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)13 Before (org.junit.Before)12 Type (com.sri.ai.expresso.api.Type)10 Theory (com.sri.ai.grinder.api.Theory)7 FunctionType (com.sri.ai.expresso.type.FunctionType)6 Rewriter (com.sri.ai.grinder.rewriter.api.Rewriter)5 LinkedHashMap (java.util.LinkedHashMap)5 StepSolver (com.sri.ai.grinder.api.StepSolver)4 UnificationStepSolver (com.sri.ai.grinder.theory.base.UnificationStepSolver)4