Search in sources :

Example 6 with DefaultSingleQuantifierEliminationProblem

use of com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem in project aic-expresso by aic-sri-international.

the class MultiQuantifierEliminationProblemTest method regularCasesTest.

@Test
public void regularCasesTest() {
    MultiQuantifierEliminationProblem problem;
    Expression problemExpression;
    problem = new DefaultSingleQuantifierEliminationProblem(new Sum(), parse("I"), parse("Integer"), parse("I > 3 and I < 10"), parse("I"));
    problemExpression = parse("sum({{ (on I in Integer) I : I > 3 and I < 10 }})");
    assertEquals(problemExpression, problem.toExpression());
    problem = new DefaultSingleQuantifierEliminationProblem(new Disjunction(), parse("I"), parse("Integer"), parse("I > 3 and I < 10"), parse("true"));
    problemExpression = parse("there exists I in Integer : I > 3 and I < 10");
    assertEquals(problemExpression, problem.toExpression());
    problem = new DefaultSingleQuantifierEliminationProblem(new Conjunction(), parse("I"), parse("Integer"), parse("I > 3 and I < 10"), parse("true"));
    problemExpression = parse("for all I in Integer : if I > 3 and I < 10 then true else true");
    assertEquals(problemExpression, problem.toExpression());
    problem = new DefaultMultiQuantifierEliminationProblem(new Sum(), list(parse("I"), parse("J")), list(parse("Integer"), parse("Boolean")), parse("I > 3 and I < 10 and not J"), parse("I"));
    problemExpression = parse("sum({{ (on I in Integer, J in Boolean) I : I > 3 and I < 10 and not J }})");
    assertEquals(problemExpression, problem.toExpression());
    problem = new DefaultMultiQuantifierEliminationProblem(new Disjunction(), list(parse("I"), parse("J")), list(parse("Integer"), parse("Boolean")), parse("I > 3 and I < 10 and not J"), parse("true"));
    problemExpression = parse("there exists I in Integer : there exists J in Boolean : I > 3 and I < 10 and not J");
    assertEquals(problemExpression, problem.toExpression());
    problem = new DefaultMultiQuantifierEliminationProblem(new Conjunction(), list(parse("I"), parse("J")), list(parse("Integer"), parse("Boolean")), parse("I > 3 and I < 10 and not J"), parse("true"));
    problemExpression = parse("for all I in Integer : for all J in Boolean : if I > 3 and I < 10 and not J then true else true");
    assertEquals(problemExpression, problem.toExpression());
}
Also used : Disjunction(com.sri.ai.grinder.group.Disjunction) Expression(com.sri.ai.expresso.api.Expression) DefaultMultiQuantifierEliminationProblem(com.sri.ai.grinder.core.solver.DefaultMultiQuantifierEliminationProblem) MultiQuantifierEliminationProblem(com.sri.ai.grinder.api.MultiQuantifierEliminationProblem) Conjunction(com.sri.ai.grinder.group.Conjunction) DefaultMultiQuantifierEliminationProblem(com.sri.ai.grinder.core.solver.DefaultMultiQuantifierEliminationProblem) DefaultSingleQuantifierEliminationProblem(com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem) Sum(com.sri.ai.grinder.group.Sum) Test(org.junit.Test)

Aggregations

Expression (com.sri.ai.expresso.api.Expression)6 DefaultSingleQuantifierEliminationProblem (com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem)6 Sum (com.sri.ai.grinder.group.Sum)4 SingleQuantifierEliminationProblem (com.sri.ai.grinder.api.SingleQuantifierEliminationProblem)2 Disjunction (com.sri.ai.grinder.group.Disjunction)2 QuantifiedExpression (com.sri.ai.expresso.api.QuantifiedExpression)1 ExpressionStepSolver (com.sri.ai.grinder.api.ExpressionStepSolver)1 MultiQuantifierEliminationProblem (com.sri.ai.grinder.api.MultiQuantifierEliminationProblem)1 SingleVariableConstraint (com.sri.ai.grinder.api.SingleVariableConstraint)1 Theory (com.sri.ai.grinder.api.Theory)1 DefaultMultiQuantifierEliminationProblem (com.sri.ai.grinder.core.solver.DefaultMultiQuantifierEliminationProblem)1 Conjunction (com.sri.ai.grinder.group.Conjunction)1 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)1 SingleVariableDifferenceArithmeticConstraint (com.sri.ai.grinder.theory.differencearithmetic.SingleVariableDifferenceArithmeticConstraint)1 SummationOnDifferenceArithmeticAndPolynomialStepSolver (com.sri.ai.grinder.theory.differencearithmetic.SummationOnDifferenceArithmeticAndPolynomialStepSolver)1 SummationOnLinearRealArithmeticAndPolynomialStepSolver (com.sri.ai.grinder.theory.linearrealarithmetic.SummationOnLinearRealArithmeticAndPolynomialStepSolver)1 Test (org.junit.Test)1