use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class SummationOnDifferenceArithmeticAndPolynomialStepSolverTest method polynomialBodyWithADifferentVariableTest.
@Test
public void polynomialBodyWithADifferentVariableTest() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
Context context = theoryTestingSupport.makeContextWithTestingInformation();
Expression variable;
String constraintString;
Expression body;
Expression expected;
variable = parse("I");
body = parse("I^2 - J + 1");
constraintString = "true";
expected = parse("-(5*J) + 35");
runTest(variable, constraintString, body, expected, context);
constraintString = "I != 3";
expected = parse("-(4*J) + 25");
runTest(variable, constraintString, body, expected, context);
constraintString = "I < 3";
expected = parse("-(3*J) + 8");
runTest(variable, constraintString, body, expected, context);
constraintString = "false";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
constraintString = "I > 3 and I < 3";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
constraintString = "I > 1 and I < 3 and I != 2";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
}
use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class SummationOnDifferenceArithmeticAndPolynomialStepSolverTest method polynomialBodyAndConstraintWithADifferentVariableTest.
@Test
public void polynomialBodyAndConstraintWithADifferentVariableTest() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new DifferenceArithmeticTheory(true, true));
Context context = theoryTestingSupport.makeContextWithTestingInformation();
Expression variable;
String constraintString;
Expression body;
Expression expected;
variable = parse("I");
body = parse("I^2 - J + 1");
constraintString = "I != J";
expected = parse("-(J^2) -(4*J) + 34");
runTest(variable, constraintString, body, expected, context);
constraintString = "I <= J and I != J";
expected = parse("(1/3 * J ^ 3 - 1.5 * J ^ 2) + 7/6 * J");
runTest(variable, constraintString, body, expected, context);
constraintString = "I < J and I > J";
expected = parse("0");
runTest(variable, constraintString, body, expected, context);
}
use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory 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);
}
use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class SymbolicShell method makeTheory.
private static Theory makeTheory() {
Theory theory = new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, false), new LinearRealArithmeticTheory(false, false), new TupleTheory(), new PropositionalTheory(), new BruteForceFunctionTheory());
theory = new BruteForceFallbackTheory(theory);
return theory;
}
use of com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory in project aic-expresso by aic-sri-international.
the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testCompoundTheoryWithoutDifferenceArithmeticWithRandomDisjunctiveFormulas.
@Test
public void testCompoundTheoryWithoutDifferenceArithmeticWithRandomDisjunctiveFormulas() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, true), new PropositionalTheory()));
runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Aggregations