use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class BasicTest method debug.
private void debug(Expression problem) {
Theory theory = new DifferenceArithmeticTheory(true, true);
Context context = new TrueContext(theory);
context = context.putGlobalObject(BRUTE_FORCE_CHECKING_OF_NON_CONDITIONAL_PROBLEMS, "Yes");
Expression symbolicSolution = theory.evaluate(problem, context);
println(symbolicSolution);
BruteForceInterpreter bruteForceInterpreter = new BruteForceCommonInterpreter();
Expression bruteForceSolution = bruteForceInterpreter.apply(problem, context);
println(bruteForceSolution);
Assert.assertEquals(bruteForceSolution, symbolicSolution);
}
use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class FirstOfTest method runTest.
private void runTest(List<Rewriter> rewriters, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
Rewriter firstOf = new FirstOf(rewriters);
Expression solution = firstOf.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class RecursiveTest method runTest.
private void runTest(Rewriter rewriter, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
Rewriter recursive = new Recursive(rewriter);
Expression solution = recursive.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class SwitchTest method runTest.
private void runTest(Rewriter rewriter, Expression initial, Expression expected, Map<Expression, Expression> symbolsAndTypes) {
CompoundTheory theory = new CompoundTheory(new PropositionalTheory(), new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.makeCloneWithAdditionalRegisteredSymbolsAndTypes(symbolsAndTypes);
Rewriter recursive = new Recursive(rewriter);
Expression solution = recursive.apply(initial, context);
System.out.println("Solution: " + solution);
assertEquals(expected, solution);
}
use of com.sri.ai.grinder.core.TrueContext in project aic-expresso by aic-sri-international.
the class BruteForceFallbackTheoryTest method runTest.
private static void runTest(String expressionString, String expectedString, String... symbolsAndTypes) {
Theory theory = new BruteForceFallbackTheory(new DifferenceArithmeticTheory(false, true));
Context context = new TrueContext(theory);
context = context.extendWithSymbolsAndTypes(symbolsAndTypes);
Expression expression = parse(expressionString);
Expression expected = parse(expectedString);
Expression actual = theory.evaluate(expression, context);
println(actual);
assertEquals(expected, actual);
}
Aggregations