use of com.sri.ai.expresso.api.Expression in project aic-expresso by aic-sri-international.
the class SummationOnDifferenceArithmeticAndPolynomialStepSolverTest method simpleBodyTest.
@Test
public void simpleBodyTest() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
Context context = theoryTestingSupport.makeContextWithTestingInformation();
Expression variable;
String constraintString;
Expression body;
Expression expected;
variable = parse("I");
body = parse("I");
constraintString = "true";
expected = parse("10");
runTest(variable, constraintString, body, expected, context);
constraintString = "I != 3";
expected = parse("7");
runTest(variable, constraintString, body, expected, context);
constraintString = "I < 3";
expected = parse("3");
runTest(variable, constraintString, body, expected, context);
constraintString = "false";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
constraintString = "I > 3 and I < 3";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
constraintString = "I > 1 and I < 3 and I != 2";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
}
use of com.sri.ai.expresso.api.Expression in project aic-expresso by aic-sri-international.
the class SetDNFRewriterTest method testBasicIntersectionCases.
@Test
public void testBasicIntersectionCases() {
Expression intersection = parse("{(2,2)} intersection ({(2,2)} union {(3,2)} union {(4,2)}) = {}");
Assert.assertEquals(parse("{(2,2)} = {}"), rewriter.apply(intersection, context));
intersection = parse("{(2,2)} intersection ({(3,2)} union {(4,2)}) = {}");
Assert.assertEquals(parse("true"), rewriter.apply(intersection, context));
intersection = parse("{(2,2)} intersection {(N,2)} = {}");
Assert.assertEquals(parse("if 2 = N then { (2, 2) } = {} else true"), rewriter.apply(intersection, context));
intersection = parse("{(1, 2)} intersection Union({{(on I in 1..10) {(I, 2)} : I != 5}}) = {}");
Assert.assertEquals(parse("{(1, 2)} = {}"), rewriter.apply(intersection, context));
}
use of com.sri.ai.expresso.api.Expression in project aic-expresso by aic-sri-international.
the class SetExpressionIsEqualToEmptySetTest method testIntensionalUnionSetBasicCases.
@Test
public void testIntensionalUnionSetBasicCases() {
Expression setEqualToEmptySet = parse("Union({{(on I in 1..10) {(I, 2)} : I > 10}}) = {}");
Assert.assertEquals(parse("true"), rewriter.apply(setEqualToEmptySet, context));
setEqualToEmptySet = parse("Union({{(on I in 1..10) {(I, 2)} : I != 5}}) = {}");
Assert.assertEquals(parse("false"), rewriter.apply(setEqualToEmptySet, context));
setEqualToEmptySet = parse("Union({{(on I in 1..10) {(I, 2)} : I != N}}) = {}");
Assert.assertEquals(parse("false"), rewriter.apply(setEqualToEmptySet, context));
}
use of com.sri.ai.expresso.api.Expression in project aic-expresso by aic-sri-international.
the class SetExpressionIsEqualToEmptySetTest method testExtensionalSetBasicCases.
@Test
public void testExtensionalSetBasicCases() {
Expression setEqualToEmptySet = parse("{} = {}");
Assert.assertEquals(parse("true"), rewriter.apply(setEqualToEmptySet, context));
setEqualToEmptySet = parse("{(2,2)} = {}");
Assert.assertEquals(parse("false"), rewriter.apply(setEqualToEmptySet, context));
setEqualToEmptySet = parse("{(N,2)} = {}");
Assert.assertEquals(parse("false"), rewriter.apply(setEqualToEmptySet, context));
}
use of com.sri.ai.expresso.api.Expression in project aic-expresso by aic-sri-international.
the class SetOfArgumentTuplesForFunctionOccurringInExpressionTest method testCase1.
// if E does not contain ƒ, oc<sub>ƒ</sub>[E] is ∅
@Test
public void testCase1() {
Expression e = parse("a");
Assert.assertEquals(Sets.EMPTY_SET, getSetOfArgumentTuples(e));
e = parse("if A = 1 then 4 else 5");
Assert.assertEquals(Sets.EMPTY_SET, getSetOfArgumentTuples(e));
}
Aggregations