Search in sources :

Example 1 with TupleQuantifierSimplifier

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

the class TupleRewriterTest method testTupleQuantifierSimplification.

@Test
public void testTupleQuantifierSimplification() {
    Simplifier tupleQuantifierSimplifier = new TupleQuantifierSimplifier();
    Assert.assertEquals(parse("for all X_1 in Boolean : for all X_2 in Integer : (X_1, X_2) = (true, 1)"), tupleQuantifierSimplifier.apply(parse("for all X in (Boolean x Integer) : X = (true, 1)"), context));
    Assert.assertEquals(parse("there exists X_1 in Boolean : there exists X_2 in Integer : (X_1, X_2) = (true, 1)"), tupleQuantifierSimplifier.apply(parse("there exists X in (Boolean x Integer) : X = (true, 1)"), context));
    Assert.assertEquals(parse("| X_1 in Boolean, X_2 in Integer : (X_1, X_2) = (true, 1) |"), tupleQuantifierSimplifier.apply(parse("| X in (Boolean x Integer) : X = (true, 1) |"), context));
    Assert.assertEquals(parse("lambda X_1 in Boolean, X_2 in Integer : (X_1, X_2) = (true, 1)"), tupleQuantifierSimplifier.apply(parse("lambda X in (Boolean x Integer) : X = (true, 1)"), context));
    Assert.assertEquals(parse("{ (on X_1 in Boolean, X_2 in Integer) (X_1, X_2) }"), tupleQuantifierSimplifier.apply(parse("{ (on X in (Boolean x Integer)) X }"), context));
    Assert.assertEquals(parse("{ (on X_1 in Boolean, X_2 in Integer) (X_1, X_2) : (X_1, X_2) != (true, 1) }"), tupleQuantifierSimplifier.apply(parse("{ (on X in (Boolean x Integer)) X : X != (true, 1) }"), context));
    Assert.assertEquals(parse("{{ (on X_1 in Boolean, X_2 in Integer) (X_1, X_2) }}"), tupleQuantifierSimplifier.apply(parse("{{ (on X in (Boolean x Integer)) X }}"), context));
    Assert.assertEquals(parse("{{ (on X_1 in Boolean, X_2 in Integer) (X_1, X_2) : (X_1, X_2) != (true, 1) }}"), tupleQuantifierSimplifier.apply(parse("{{ (on X in (Boolean x Integer)) X : X != (true, 1) }}"), context));
    // 
    // Ensure Introduced Variables are Unique
    Assert.assertEquals(parse("lambda X_1' in Boolean, X_2' in Integer, X_1 in Boolean, X_2 in Boolean : (X_1', X_2') = (true, 1) and X_1 = X_2"), tupleQuantifierSimplifier.apply(parse("lambda X in (Boolean x Integer), X_1 in Boolean, X_2 in Boolean : X = (true, 1) and X_1 = X_2"), context));
    // 
    // Ensure we don't introduce undeclared types
    Assert.assertEquals(parse("lambda X_1 in Boolean, X_2 in Integer, Y, Z : (X_1, X_2) = (true, 1) and Y = Z"), tupleQuantifierSimplifier.apply(parse("lambda X in (Boolean x Integer), Y, Z : X = (true, 1) and Y = Z"), context));
}
Also used : TupleGetSimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleGetSimplifier) TupleQuantifierSimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleQuantifierSimplifier) TupleEqualitySimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleEqualitySimplifier) TupleSetSimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleSetSimplifier) TupleDisequalitySimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleDisequalitySimplifier) TupleValuedFreeVariablesSimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleValuedFreeVariablesSimplifier) Simplifier(com.sri.ai.grinder.rewriter.api.Simplifier) TupleQuantifierSimplifier(com.sri.ai.grinder.theory.tuple.rewriter.TupleQuantifierSimplifier) Test(org.junit.Test)

Aggregations

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