Search in sources :

Example 1 with TupleEqualityTopRewriter

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

the class TupleRewriterTest method testTupleEqualityTopRewriter.

@Test
public void testTupleEqualityTopRewriter() {
    TopRewriter tupleEqualityTopRewriter = new TupleEqualityTopRewriter();
    Assert.assertEquals(parse("A1 = B1 and A2 = B2 and A3 = B3"), tupleEqualityTopRewriter.apply(parse("(A1, A2, A3) = (B1, B2, B3)"), context));
    Assert.assertEquals(parse("(A1_1, A1_2, A1_3) = (B1_1, B1_2, B1_3) and A2 = B2 and A3 = B3"), tupleEqualityTopRewriter.apply(parse("((A1_1, A1_2, A1_3), A2, A3) = ((B1_1, B1_2, B1_3), B2, B3)"), context));
    Assert.assertEquals(parse("A1 != B1 or A2 != B2 or A3 != B3"), tupleEqualityTopRewriter.apply(parse("(A1, A2, A3) != (B1, B2, B3)"), context));
    Assert.assertEquals(parse("(A1_1, A1_2, A1_3) != (B1_1, B1_2, B1_3) or A2 != B2 or A3 != B3"), tupleEqualityTopRewriter.apply(parse("((A1_1, A1_2, A1_3), A2, A3) != ((B1_1, B1_2, B1_3), B2, B3)"), context));
    Expression expr = parse("(A1, A2) = (B1, B2, B3)");
    Assert.assertTrue(expr == tupleEqualityTopRewriter.apply(expr, context));
    expr = parse("A1 = B1");
    Assert.assertTrue(expr == tupleEqualityTopRewriter.apply(expr, context));
    expr = parse("(A1, A2) != (B1, B2, B3)");
    Assert.assertTrue(expr == tupleEqualityTopRewriter.apply(expr, context));
    expr = parse("A1 != B1");
    Assert.assertTrue(expr == tupleEqualityTopRewriter.apply(expr, context));
}
Also used : TupleEqualityTopRewriter(com.sri.ai.grinder.theory.tuple.rewriter.TupleEqualityTopRewriter) Expression(com.sri.ai.expresso.api.Expression) TupleEqualityTopRewriter(com.sri.ai.grinder.theory.tuple.rewriter.TupleEqualityTopRewriter) TupleGetSetTopRewriter(com.sri.ai.grinder.theory.tuple.rewriter.TupleGetSetTopRewriter) TopRewriter(com.sri.ai.grinder.rewriter.api.TopRewriter) Test(org.junit.Test)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)1 TopRewriter (com.sri.ai.grinder.rewriter.api.TopRewriter)1 TupleEqualityTopRewriter (com.sri.ai.grinder.theory.tuple.rewriter.TupleEqualityTopRewriter)1 TupleGetSetTopRewriter (com.sri.ai.grinder.theory.tuple.rewriter.TupleGetSetTopRewriter)1 Test (org.junit.Test)1