Search in sources :

Example 1 with TheoryTestingSupport

use of com.sri.ai.grinder.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(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();
        Type type = variableNameAndType.getValue();
        for (Theory subTheory : getTheory().getSubTheories()) {
            if (subTheory.isSuitableFor(type) || (type instanceof FunctionType && subTheory.isSuitableFor(((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.api.Theory) AbstractTheoryTestingSupport(com.sri.ai.grinder.core.constraint.AbstractTheoryTestingSupport) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) FunctionType(com.sri.ai.expresso.type.FunctionType) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with TheoryTestingSupport

use of com.sri.ai.grinder.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));
    extendTestingVariables("X", theoryTestingSupport, "S", "T", "U", "V", "W");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) LinearRealArithmeticTheory(com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with TheoryTestingSupport

use of com.sri.ai.grinder.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));
    extendTestingVariables("X", theoryTestingSupport, "S", "T", "U", "V", "W");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : EqualityTheory(com.sri.ai.grinder.theory.equality.EqualityTheory) TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) Test(org.junit.Test)

Example 4 with TheoryTestingSupport

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

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testPropositionalTheoryWithRandomDisjunctiveFormulas.

@Test
public void testPropositionalTheoryWithRandomDisjunctiveFormulas() {
    TheoryTestingSupport theoryTestingSupport = TheoryTestingSupport.make(makeRandom(), new PropositionalTheory());
    extendTestingVariables("P", theoryTestingSupport, "S", "T", "U", "V", "W", "X", "Y", "Z");
    runRandomDisjunctiveFormulasTest(theoryTestingSupport);
}
Also used : TheoryTestingSupport(com.sri.ai.grinder.tester.TheoryTestingSupport) PropositionalTheory(com.sri.ai.grinder.theory.propositional.PropositionalTheory) Test(org.junit.Test)

Example 5 with TheoryTestingSupport

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

the class ExpressionStepSolverToLiteralSplitterStepSolverAdapterTest method testEqualityTheoryWithPropagationOfAllLiteralsWhenBoundWithRandomDisjunctiveFormulas.

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

Aggregations

TheoryTestingSupport (com.sri.ai.grinder.tester.TheoryTestingSupport)49 Test (org.junit.Test)42 Context (com.sri.ai.grinder.api.Context)36 Expression (com.sri.ai.expresso.api.Expression)26 DifferenceArithmeticTheory (com.sri.ai.grinder.theory.differencearithmetic.DifferenceArithmeticTheory)22 EqualityTheory (com.sri.ai.grinder.theory.equality.EqualityTheory)20 PropositionalTheory (com.sri.ai.grinder.theory.propositional.PropositionalTheory)17 FunctionType (com.sri.ai.expresso.type.FunctionType)13 Type (com.sri.ai.expresso.api.Type)12 CompoundTheory (com.sri.ai.grinder.theory.compound.CompoundTheory)11 StepSolver (com.sri.ai.grinder.api.StepSolver)10 UnificationStepSolver (com.sri.ai.grinder.theory.base.UnificationStepSolver)10 AbstractTheoryTestingSupport (com.sri.ai.grinder.core.constraint.AbstractTheoryTestingSupport)9 LinearRealArithmeticTheory (com.sri.ai.grinder.theory.linearrealarithmetic.LinearRealArithmeticTheory)9 LinkedHashMap (java.util.LinkedHashMap)7 Constraint (com.sri.ai.grinder.api.Constraint)6 CompleteMultiVariableContext (com.sri.ai.grinder.core.constraint.CompleteMultiVariableContext)6 Ignore (org.junit.Ignore)5 Categorical (com.sri.ai.expresso.type.Categorical)4 TrueContext (com.sri.ai.grinder.core.TrueContext)4