use of com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleValuedFreeVariablesSimplifier in project aic-expresso by aic-sri-international.
the class TupleRewriterTest method testTupleValuedFreeVariablesSimplifier.
@Test
public void testTupleValuedFreeVariablesSimplifier() {
Context tupleTheoryContext = new TrueContext(new CompoundTheory(new DifferenceArithmeticTheory(false, false), new TupleTheory()));
TupleType nTupleType = new TupleType(new IntegerInterval(1, 10), new IntegerInterval(1, 10));
tupleTheoryContext = (Context) GrinderUtil.extendRegistryWith(map("N", nTupleType.toString()), Arrays.asList(nTupleType), tupleTheoryContext);
TupleValuedFreeVariablesSimplifier simplifier = new TupleValuedFreeVariablesSimplifier();
Expression expression = parse("sum( {{ (on X in 1..10) if N = (2, X) then 2 else 3 }} )");
Expression simplified = simplifier.apply(expression, tupleTheoryContext);
Assert.assertEquals(parse("if get(N, 1) = 2 then 29 else 30"), simplified);
}
Aggregations