Search in sources :

Example 1 with TupleGetSimplifier

use of com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleGetSimplifier in project aic-expresso by aic-sri-international.

the class TupleRewriterTest method testTupleGetSimplification.

@Test
public void testTupleGetSimplification() {
    Simplifier tupleGetSimplifier = new TupleGetSimplifier();
    Assert.assertEquals(parse("a"), tupleGetSimplifier.apply(parse("get((a,b,c),1)"), context));
    Assert.assertEquals(parse("b"), tupleGetSimplifier.apply(parse("get((a,b,c),2)"), context));
    Assert.assertEquals(parse("c"), tupleGetSimplifier.apply(parse("get((a,b,c),3)"), context));
    Assert.assertEquals(parse("a"), tupleGetSimplifier.apply(parse("get(tuple(a),I)"), context));
    Assert.assertEquals(parse("if I = 1 then a else b"), tupleGetSimplifier.apply(parse("get((a,b),I)"), context));
    Assert.assertEquals(parse("if I = 1 then a else if I = 2 then b else c"), tupleGetSimplifier.apply(parse("get((a,b,c),I)"), context));
    Expression expr = parse("get(I, (a,b,c))");
    Assert.assertTrue(expr == tupleGetSimplifier.apply(expr, context));
    expr = parse("get(N, 1)");
    Assert.assertTrue(expr == tupleGetSimplifier.apply(expr, context));
}
Also used : Expression(com.sri.ai.expresso.api.Expression) Simplifier(com.sri.ai.grinder.sgdpllt.rewriter.api.Simplifier) TupleEqualitySimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleEqualitySimplifier) TupleGetSimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleGetSimplifier) TupleQuantifierSimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleQuantifierSimplifier) TupleDisequalitySimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleDisequalitySimplifier) TupleValuedFreeVariablesSimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleValuedFreeVariablesSimplifier) TupleSetSimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleSetSimplifier) TupleGetSimplifier(com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleGetSimplifier) Test(org.junit.Test)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)1 Simplifier (com.sri.ai.grinder.sgdpllt.rewriter.api.Simplifier)1 TupleDisequalitySimplifier (com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleDisequalitySimplifier)1 TupleEqualitySimplifier (com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleEqualitySimplifier)1 TupleGetSimplifier (com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleGetSimplifier)1 TupleQuantifierSimplifier (com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleQuantifierSimplifier)1 TupleSetSimplifier (com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleSetSimplifier)1 TupleValuedFreeVariablesSimplifier (com.sri.ai.grinder.sgdpllt.theory.tuple.rewriter.TupleValuedFreeVariablesSimplifier)1 Test (org.junit.Test)1