use of com.sri.ai.grinder.application.CommonTheory in project aic-expresso by aic-sri-international.
the class AssociativeCommutativeGroupOperationApplicationStepSolverTest method numericGroupTest04.
@Test
public void numericGroupTest04() {
// get method name as string
String testName = new Object() {
}.getClass().getEnclosingMethod().getName();
Theory theory = new CommonTheory();
String[] symbolsAndTypes = { "X", "0..2", "Y", "0..2" };
Context context = new TrueContext(theory).extendWithSymbolsAndTypes(symbolsAndTypes);
Expression[] operandExpressions = { parse("if X = 1 then 2 else 3"), parse("if Y != 2 then 4 else 5") };
Expression[] expectedResultPerGroup = { parse("if Y != 2 then 4 else 5"), parse("if X = 1 then if Y != 2 then 8 else 10 else if Y != 2 then 12 else 15"), parse("if X = 1 then if Y != 2 then 6 else 7 else if Y != 2 then 7 else 8") };
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 numericGroupTest00.
@Test
public void numericGroupTest00() {
// 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("sum({{(on I in 1..5) if I != 3 then 30 else 40 }})"), parse("sum({{(on J in 10..13) if J != 5 then J else 40 }})") };
Expression[] expectedResultPerGroup = { parse("160"), parse("7360"), parse("206") };
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 quantifierBasedGroupTest02.
@Test
public void quantifierBasedGroupTest02() {
// 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("true"), parse("false") };
Expression[] expectedResultPerGroup = { parse("false"), parse("true") };
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 numericGroupTestMaxOperandsWithFreeVariables.
// @Test
public void numericGroupTestMaxOperandsWithFreeVariables() {
// 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("max({{(on I in 3..5) if I != 4 and K != 2 then X else 1 }})"), parse("max({{(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(max(X, 1), 5), 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(max(X, 1), max(max(max(max(Y, Y), 1), Y), Y)), max(max(Z, J), J / 2)) " + "else max(5, max(max(Z, J), J / 2))"), parse("if K != 2 then if K != 3 then max(X, 1) * 5 * 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(X, 1) * " + "max(max(max(max(Y, Y), 1), Y), Y) * max(max(Z, J), J / 2) else 5 * max(max(Z, J), J / 2)"), parse("if K != 2 then if K != 3 then max(X, 1) + 5 + 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(X, 1) + " + "max(max(max(max(Y, Y), 1), Y), Y) + max(max(Z, J), J / 2) else 6 + 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 quantifierBasedGroupTest01.
// / QUANTIFIER-BASED GROUP TESTS //////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void quantifierBasedGroupTest01() {
// 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("true"), parse("true") };
Expression[] expectedResultPerGroup = { parse("true"), parse("true") };
repeatTestForEachRespectiveGroup(testName, theory, context, operandExpressions, expectedResultPerGroup, QUANTIFIER_BASED_GROUPS);
println();
}
Aggregations