Search in sources :

Example 16 with TheoryTestingSupport

use of com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testEqualityTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.

@Test
public void testEqualityTheoryWithoutPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new EqualityTheory(true, false));
    extendTestingVaribles("X", theoryTestingSupport, "S", "T", "U", "V", "W");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : EqualityTheory(com.sri.ai.grinder.sgdpllt.theory.equality.EqualityTheory) TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport) Test(org.junit.Test)

Example 17 with TheoryTestingSupport

use of com.sri.ai.grinder.sgdpllt.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);
}
Also used : EqualityTheory(com.sri.ai.grinder.sgdpllt.theory.equality.EqualityTheory) Type(com.sri.ai.expresso.api.Type) TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport) DifferenceArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory) IntegerInterval(com.sri.ai.expresso.type.IntegerInterval) PropositionalTheory(com.sri.ai.grinder.sgdpllt.theory.propositional.PropositionalTheory) Categorical(com.sri.ai.expresso.type.Categorical) CompoundTheory(com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory) Test(org.junit.Test)

Example 18 with TheoryTestingSupport

use of com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testLinearRealArithmeticTheoryWithRandomDisjunctiveFormulas.

@Ignore("Random generation of linear real arithmetic not yet implemented")
@Test
public void testLinearRealArithmeticTheoryWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new LinearRealArithmeticTheory(true, true));
    extendTestingVaribles("X", theoryTestingSupport, "S", "T", "U", "V", "W");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport) LinearRealArithmeticTheory(com.sri.ai.grinder.sgdpllt.theory.linearrealarithmetic.LinearRealArithmeticTheory) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with TheoryTestingSupport

use of com.sri.ai.grinder.sgdpllt.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;
}
Also used : Expression(com.sri.ai.expresso.api.Expression) AbstractTheoryTestingSupport(com.sri.ai.grinder.sgdpllt.core.constraint.AbstractTheoryTestingSupport) TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport)

Example 20 with TheoryTestingSupport

use of com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport in project aic-expresso by aic-sri-international.

the class CompoundTheoryTestingSupport method setVariableNamesAndTypesForTesting.

/**
	 * This is overridden so that given variables and types for testing are distributed to their
	 * respective theories according to {@link #isSuitableFor(Expression, Type)}.
	 */
@Override
public void setVariableNamesAndTypesForTesting(Map<String, Type> variableNamesAndTypesForTesting) {
    // First ensure the compound set of variables names and type information is setup correctly
    super.setVariableNamesAndTypesForTesting(variableNamesAndTypesForTesting);
    // Then update the sub-theories so that they share appropriate subsets of this information
    Map<Theory, Map<String, Type>> mapForSubTheory = map();
    for (Theory subTheory : getTheory().getSubTheories()) {
        mapForSubTheory.put(subTheory, map());
    }
    for (Map.Entry<String, Type> variableNameAndType : getVariableNamesAndTypesForTesting().entrySet()) {
        String variableName = variableNameAndType.getKey();
        Expression variable = Expressions.parse(variableName);
        Type type = variableNameAndType.getValue();
        for (Theory subTheory : getTheory().getSubTheories()) {
            if (subTheory.isSuitableFor(variable, type) || (type instanceof FunctionType && subTheory.isSuitableFor(variable, ((FunctionType) type).getCodomain()))) {
                mapForSubTheory.get(subTheory).put(variableName, type);
            }
        }
    }
    for (Map.Entry<Theory, TheoryTestingSupport> entry : getTheoryToTestingSupport().entrySet()) {
        Map<String, Type> forThisSubTheory = mapForSubTheory.get(entry.getKey());
        entry.getValue().setVariableNamesAndTypesForTesting(forThisSubTheory);
    }
}
Also used : Type(com.sri.ai.expresso.api.Type) FunctionType(com.sri.ai.expresso.type.FunctionType) Theory(com.sri.ai.grinder.sgdpllt.api.Theory) Expression(com.sri.ai.expresso.api.Expression) AbstractTheoryTestingSupport(com.sri.ai.grinder.sgdpllt.core.constraint.AbstractTheoryTestingSupport) TheoryTestingSupport(com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport) FunctionType(com.sri.ai.expresso.type.FunctionType) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

TheoryTestingSupport (com.sri.ai.grinder.sgdpllt.tester.TheoryTestingSupport)50 Test (org.junit.Test)42 Context (com.sri.ai.grinder.sgdpllt.api.Context)36 Expression (com.sri.ai.expresso.api.Expression)27 DifferenceArithmeticTheory (com.sri.ai.grinder.sgdpllt.theory.differencearithmetic.DifferenceArithmeticTheory)23 EqualityTheory (com.sri.ai.grinder.sgdpllt.theory.equality.EqualityTheory)21 PropositionalTheory (com.sri.ai.grinder.sgdpllt.theory.propositional.PropositionalTheory)18 FunctionType (com.sri.ai.expresso.type.FunctionType)13 Type (com.sri.ai.expresso.api.Type)12 CompoundTheory (com.sri.ai.grinder.sgdpllt.theory.compound.CompoundTheory)12 StepSolver (com.sri.ai.grinder.sgdpllt.api.StepSolver)10 UnificationStepSolver (com.sri.ai.grinder.sgdpllt.theory.base.UnificationStepSolver)10 AbstractTheoryTestingSupport (com.sri.ai.grinder.sgdpllt.core.constraint.AbstractTheoryTestingSupport)9 LinearRealArithmeticTheory (com.sri.ai.grinder.sgdpllt.theory.linearrealarithmetic.LinearRealArithmeticTheory)9 Constraint (com.sri.ai.grinder.sgdpllt.api.Constraint)7 LinkedHashMap (java.util.LinkedHashMap)7 CompleteMultiVariableContext (com.sri.ai.grinder.sgdpllt.core.constraint.CompleteMultiVariableContext)6 Ignore (org.junit.Ignore)6 Categorical (com.sri.ai.expresso.type.Categorical)4 Theory (com.sri.ai.grinder.sgdpllt.api.Theory)4