Search in sources :

Example 21 with IntegerInterval

use of com.sri.ai.expresso.type.IntegerInterval in project aic-expresso by aic-sri-international.

the class IntensionalSetToConditionalSimplifierTest 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 IntensionalSetToConditionalSimplifier();
}
Also used : DifferenceArithmeticTheory(com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) IntensionalSetToConditionalSimplifier(com.sri.ai.grinder.library.set.invsupport.IntensionalSetToConditionalSimplifier) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) Before(org.junit.Before)

Example 22 with IntegerInterval

use of com.sri.ai.expresso.type.IntegerInterval 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.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) CompoundTheory(com.sri.ai.grinder.theory.compound.CompoundTheory) TrueContext(com.sri.ai.grinder.core.TrueContext) TupleTheory(com.sri.ai.grinder.theory.tuple.TupleTheory) IntensionalSetFalseConditionToEmptySetSimplifier(com.sri.ai.grinder.library.set.IntensionalSetFalseConditionToEmptySetSimplifier) Before(org.junit.Before)

Example 23 with IntegerInterval

use of com.sri.ai.expresso.type.IntegerInterval in project aic-expresso by aic-sri-international.

the class IntersectionExtensionalSetSimplifierTest method setUp.

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

Example 24 with IntegerInterval

use of com.sri.ai.expresso.type.IntegerInterval in project aic-expresso by aic-sri-international.

the class CompoundTheoryWithDifferenceArithmeticTest method makeTheoryTestingSupport.

@Override
protected TheoryTestingSupport makeTheoryTestingSupport() {
    TheoryTestingSupport result = 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);
    result.setVariableNamesAndTypesForTesting(variablesAndTypes);
    return result;
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) Type(com.sri.ai.expresso.api.Type) AbstractTheoryTestingSupport(com.sri.ai.grinder.core.constraint.AbstractTheoryTestingSupport) 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)

Example 25 with IntegerInterval

use of com.sri.ai.expresso.type.IntegerInterval in project aic-expresso by aic-sri-international.

the class ValuesOfSingleVariableDifferenceArithmeticConstraintStepSolverTest method test.

@Test
public void test() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
    theoryTestingSupport.setVariableNamesAndTypesForTesting(map("I", new IntegerInterval(0, 4), "J", new IntegerInterval(0, 4), "K", new IntegerInterval(0, 4)));
    Context context = theoryTestingSupport.makeContextWithTestingInformation();
    Expression variable;
    String constraintString;
    Expression expected;
    variable = parse("I");
    constraintString = "true";
    expected = parse("aboveAndUpTo(-1, 4)");
    runTest(variable, constraintString, expected, context);
    variable = parse("I");
    constraintString = "false";
    expected = parse("{}");
    runTest(variable, constraintString, expected, context);
    variable = parse("I");
    constraintString = "I < 3 and J > I";
    expected = parse("if 3 > J then if 0 < J then aboveAndUpTo(-1, J - 1) else {} else aboveAndUpTo(-1, 2)");
    runTest(variable, constraintString, expected, context);
    variable = parse("I");
    constraintString = "I < 3 and J > I and I != 2";
    expected = parse("if 3 > J then if 0 < J then aboveAndUpTo(-1, J - 1) else {} else aboveAndUpTo(-1, 2) - { 2 }");
    runTest(variable, constraintString, expected, context);
    variable = parse("I");
    constraintString = "I < 3 and J > I and I != 2 and I != K";
    expected = parse("if 3 > J then if 0 < J then if K + 1 <= J then aboveAndUpTo(-1, J - 1) - { K } else aboveAndUpTo(-1, J - 1) else {} else if K <= 2 then if 2 = K then aboveAndUpTo(-1, 2) - { K } else aboveAndUpTo(-1, 2) - { 2, K } else aboveAndUpTo(-1, 2) - { 2 }");
    runTest(variable, constraintString, 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) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) Test(org.junit.Test)

Aggregations

IntegerInterval (com.sri.ai.expresso.type.IntegerInterval)62 Expression (com.sri.ai.expresso.api.Expression)24 Before (org.junit.Before)20 FunctionType (com.sri.ai.expresso.type.FunctionType)18 Test (org.junit.Test)18 Type (com.sri.ai.expresso.api.Type)16 DifferenceArithmeticTheory (com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory)15 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)15 RealInterval (com.sri.ai.expresso.type.RealInterval)14 TrueContext (com.sri.ai.grinder.core.TrueContext)14 IntegerExpressoType (com.sri.ai.expresso.type.IntegerExpressoType)13 CompoundTheory (com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory)13 Categorical (com.sri.ai.expresso.type.Categorical)12 TupleType (com.sri.ai.expresso.type.TupleType)12 TrueContext (com.sri.ai.grinder.sgdpllt.core.TrueContext)12 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)12 RealExpressoType (com.sri.ai.expresso.type.RealExpressoType)10 TupleTheory (com.sri.ai.grinder.theory.tuple.TupleTheory)10 TupleTheory (com.sri.ai.grinder.sgdpllt.theory.tuple.TupleTheory)8 Context (com.sri.ai.grinder.api.Context)7