use of com.sri.ai.grinder.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.
the class CompoundTheoryTestingSupport method getTheoryTestingSupport.
private TheoryTestingSupport getTheoryTestingSupport(String variable) {
Type variableType = getTestingVariableType(variable);
Theory subConstraintTheory = getTheory().getTheory(parse(variable), variableType);
check(() -> subConstraintTheory != null, () -> "There is no sub-theory suitable for " + variable + ", which has type " + variableType);
TheoryTestingSupport result = getTheoryToTestingSupport().get(subConstraintTheory);
return result;
}
use of com.sri.ai.grinder.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.
the class CompoundTheoryTestingSupport method makeRandomAtomOn.
@Override
public Expression makeRandomAtomOn(String variable, Context context) {
TheoryTestingSupport theoryTestingSupport = getTheoryTestingSupport(variable);
Expression result = theoryTestingSupport.makeRandomAtomOn(variable, context);
return result;
}
use of com.sri.ai.grinder.tester.TheoryTestingSupport 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);
}
use of com.sri.ai.grinder.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.
the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testPropositionalTheoryWithFixedDisjunctiveFormulas.
@Test
public void testPropositionalTheoryWithFixedDisjunctiveFormulas() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new PropositionalTheory());
extendTestingVariables("P", theoryTestingSupport, "S", "T");
Context context = theoryTestingSupport.makeContextWithTestingInformation();
runTest(theoryTestingSupport, new GeneralFormulaExpressionTestStepSolver(Expressions.parse("P"), Expressions.parse("Q")), Expressions.parse("if P then if Q then P and Q else P and not Q else if Q then not P and Q else not P and not Q"), context);
runTest(theoryTestingSupport, new GeneralFormulaExpressionTestStepSolver(Expressions.parse("P or Q"), Expressions.parse("R or Q")), Expressions.parse("if P then if R then (P or Q) and (R or Q) else if Q then (P or Q) and (R or Q) else (P or Q) and not (R or Q) else if Q then (P or Q) and (R or Q) else if R then not (P or Q) and (R or Q) else not (P or Q) and not (R or Q)"), context);
runTest(theoryTestingSupport, new GeneralFormulaExpressionTestStepSolver(Expressions.parse("P or Q"), Expressions.parse("R or S")), Expressions.parse("if P then if R then (P or Q) and (R or S) else if S then (P or Q) and (R or S) else (P or Q) and not (R or S) else if Q then if R then (P or Q) and (R or S) else if S then (P or Q) and (R or S) else (P or Q) and not (R or S) else if R then not (P or Q) and (R or S) else if S then not (P or Q) and (R or S) else not (P or Q) and not (R or S)"), context);
}
use of com.sri.ai.grinder.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.
the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testCompoundTheoryWithDifferenceArithmeticWithRandomDisjunctiveFormulas.
@Test
public void testCompoundTheoryWithDifferenceArithmeticWithRandomDisjunctiveFormulas() {
TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new CompoundTheory(new EqualityTheory(false, true), new DifferenceArithmeticTheory(false, true), new PropositionalTheory()));
// using different testing variables and types to test distribution of testing information
// to sub constraint theories.
Categorical booleanType = BOOLEAN_TYPE;
Categorical dogsType = new Categorical("Dogs", 4, arrayList(parse("fido"), parse("rex")));
IntegerInterval oneTwoThree = new IntegerInterval(1, 3);
Map<String, Type> variablesAndTypes = map("F", booleanType, "G", booleanType, "R", dogsType, "S", dogsType, "T", oneTwoThree, "U", oneTwoThree);
theoryTestingSupport.setVariableNamesAndTypesForTesting(variablesAndTypes);
runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Aggregations