use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method quantifierBasedGroupTestFreeVariableInsideSummations.
@Test
public void quantifierBasedGroupTestFreeVariableInsideSummations() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = { "K", "1..5", "X", "1..5" };
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("there exists I in Integer : I > 3 and I < K"), parse("for all J in Integer : if J > K and J < 10 then X else Y") };
Expression[] expectedResultPerGroup = { parse("if 4 < K then X and Y else false"), parse("if 4 < K then true else X and Y") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, QUANTIFIER_BASED_GROUPS);
println();
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupCombinedTest.
// @Test
public void numericGroupCombinedTest() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = { "K", "0..5" };
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("sum({{(on I in 3..5) if I != 4 and K != 2 then X else 1 }})"), parse("product({{(on J in 1..5) if J != 3 then if K != 3 then J else Y else 1 }})"), parse("max({{(on L in 0..2) if K != 0 then if L != 0 then J/L else Z else if L!=0 then 0 else 1 }})") };
Expression[] expectedResultPerGroup = { parse("if K != 2 then if K != 3 then max(max(2 * X + 1, 40), max({{ ( on L in 0..2 ) if K != 0 " + "then if L != 0 then J / L else Z else if L != 0 then 0 else 1 }})) else " + "max(max(2 * X + 1, Y * Y * Y * Y), max(max(Z, J), J / 2)) else max(40, max(max(Z, J), J / 2))"), parse("if K != 2 then if K != 3 then (2 * X + 1) * 40 * max({{ ( on L in 0..2 ) if K != 0 " + "then if L != 0 then J / L else Z else if L != 0 then 0 else 1 }}) " + "else (2 * X + 1) * Y * Y * Y * Y * max(max(Z, J), J / 2) else 120 * max(max(Z, J), J / 2)"), parse("if K != 2 then if K != 3 then 2 * X + 41 + max({{ ( on L in 0..2 ) if K != 0 " + "then if L != 0 then J / L else Z else if L != 0 then 0 else 1 }}) " + "else Y ^ 4 + 2 * X + 1 + max(max(Z, J), J / 2) else 43 + max(max(Z, J), J / 2)") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
println();
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTestFreeVariableInsideSummations.
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
// JUNIT TESTS ////////////////////////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
// / NUMERIC GROUP TESTS //////////////////////////////////////////////////////////////////////
// ////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void numericGroupTestFreeVariableInsideSummations() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = { "K", "1..5" };
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("sum({{(on I in 1..5) if I != 3 and K != 4 then 30 else 40 }})"), parse("sum({{(on J in 10..13) if J != 5 then if K != 3 then J else 0 else 40 }})") };
Expression[] expectedResultPerGroup = { parse("if K != 4 then 160 else 200"), parse("if K != 4 then if K != 3 then 7360 else 0 else 9200"), parse("if K != 4 then if K != 3 then 206 else 160 else 246") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
println();
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method quantifierBasedGroupTest04.
@Test
public void quantifierBasedGroupTest04() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = {};
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("false"), parse("false") };
Expression[] expectedResultPerGroup = { parse("false"), parse("false") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, QUANTIFIER_BASED_GROUPS);
println();
}
use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTestWithMaxOperandsWithFreeVariables.
@Test
public void numericGroupTestWithMaxOperandsWithFreeVariables() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = {};
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("max({{(on I in 0..5) if I < 2 then I*X else Y }})"), parse("max({{(on J in 10..20) if J < 10 then Y else J*Z }})") };
Expression[] expectedResultPerGroup = { parse("max(max(max(max(max(max(0, X), Y), Y), Y), Y), " + "max(max(max(max(max(max(max(max(max(max(10 * Z, 11 * Z), 12 * Z), 13 * Z), 14 * Z), " + "15 * Z), 16 * Z), 17 * Z), 18 * Z), 19 * Z), 20 * Z))"), parse("max(max(max(max(max(0, X), Y), Y), Y), Y) * " + "max(max(max(max(max(max(max(max(max(max(10 * Z, 11 * Z), 12 * Z), 13 * Z), 14 * Z), " + "15 * Z), 16 * Z), 17 * Z), 18 * Z), 19 * Z), 20 * Z)"), parse("max(max(max(max(max(0, X), Y), Y), Y), Y) + " + "max(max(max(max(max(max(max(max(max(max(10 * Z, 11 * Z), 12 * Z), 13 * Z), 14 * Z), " + "15 * Z), 16 * Z), 17 * Z), 18 * Z), 19 * Z), 20 * Z)") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, NUMERIC_GROUPS);
println();
}
Aggregations