Search in sources :

Example 1 with IncompleteMultiVariableConstraint

use of com.sri.ai.grinder.core.constraint.IncompleteMultiVariableConstraint in project aic-expresso by aic-sri-international.

the class SGDPLLTTester method testIncompleteMultiVariableConstraints.

/**
 * Given a theory and a number <code>n</code> of multi-variable constraint tests,
 * generates <code>n</code> formulas in the theory
 * and see if those detected as unsatisfiable by the corresponding incomplete solver
 * are indeed unsatisfiable (checked by brute force).
 * Note that we do not test if all unsatisfiable formulas are detected as such, because the solver is assumed to be incomplete.
 * Throws an {@link Error} with the failure description if a test fails.
 * @param theoryTestingSupport
 * @param numberOfTests
 * @param maxNumberOfLiterals
 * @param outputCount
 */
public static void testIncompleteMultiVariableConstraints(boolean testAgainstBruteForce, TheoryTestingSupport theoryTestingSupport, long numberOfTests, int maxNumberOfLiterals, boolean outputCount) {
    NullaryFunction<Constraint> makeInitialConstraint = () -> new IncompleteMultiVariableConstraint(theoryTestingSupport.getTheory());
    Context context = theoryTestingSupport.makeContextWithTestingInformation();
    Function<Constraint, Expression> makeRandomLiteral = c -> theoryTestingSupport.makeRandomLiteral(context);
    // {@link IncompleteMultiVariableConstraint} is incomplete
    TestRunner tester = SGDPLLTTester::testIncompleteSatisfiability;
    runTesterGivenOnSuccessiveConjunctionsOfLiterals("incomplete satisfiability", tester, numberOfTests, maxNumberOfLiterals, testAgainstBruteForce, theoryTestingSupport, makeInitialConstraint, makeRandomLiteral, outputCount, context);
}
Also used : Context(com.sri.ai.grinder.api.Context) BinaryFunction(com.sri.ai.util.base.BinaryFunction) Util.removeFromSetNonDestructively(com.sri.ai.util.Util.removeFromSetNonDestructively) SubExpressionsDepthFirstIterator(com.sri.ai.expresso.helper.SubExpressionsDepthFirstIterator) Expression(com.sri.ai.expresso.api.Expression) Sets(com.sri.ai.grinder.library.set.Sets) Function(java.util.function.Function) GrinderUtil(com.sri.ai.grinder.helper.GrinderUtil) And(com.sri.ai.grinder.library.boole.And) Util.in(com.sri.ai.util.Util.in) AssociativeCommutativeGroup(com.sri.ai.grinder.group.AssociativeCommutativeGroup) BruteForceCommonInterpreter(com.sri.ai.grinder.interpreter.BruteForceCommonInterpreter) IndexExpressions(com.sri.ai.grinder.library.indexexpression.IndexExpressions) Expressions.parse(com.sri.ai.expresso.helper.Expressions.parse) Map(java.util.Map) ThereExists(com.sri.ai.grinder.library.boole.ThereExists) Context(com.sri.ai.grinder.api.Context) ZERO(com.sri.ai.expresso.helper.Expressions.ZERO) SingleQuantifierEliminationProblem(com.sri.ai.grinder.api.SingleQuantifierEliminationProblem) LinkedHashSet(java.util.LinkedHashSet) Type(com.sri.ai.expresso.api.Type) DefaultSingleQuantifierEliminationProblem(com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem) NullaryFunction(com.sri.ai.util.base.NullaryFunction) Util.join(com.sri.ai.util.Util.join) Expressions.getVariablesBeingReferenced(com.sri.ai.expresso.helper.Expressions.getVariablesBeingReferenced) Collection(java.util.Collection) Util.list(com.sri.ai.util.Util.list) Set(java.util.Set) IncompleteMultiVariableConstraint(com.sri.ai.grinder.core.constraint.IncompleteMultiVariableConstraint) QuantifiedExpression(com.sri.ai.expresso.api.QuantifiedExpression) AssignmentMapsIterator(com.sri.ai.grinder.helper.AssignmentMapsIterator) Assignment(com.sri.ai.grinder.interpreter.Assignment) Beta(com.google.common.annotations.Beta) Theory(com.sri.ai.grinder.api.Theory) Expressions.makeSymbol(com.sri.ai.expresso.helper.Expressions.makeSymbol) SingleVariableConstraint(com.sri.ai.grinder.api.SingleVariableConstraint) Simplifier(com.sri.ai.grinder.rewriter.api.Simplifier) Util(com.sri.ai.util.Util) Util.pickKElementsWithoutReplacement(com.sri.ai.util.Util.pickKElementsWithoutReplacement) TRUE(com.sri.ai.expresso.helper.Expressions.TRUE) Constraint(com.sri.ai.grinder.api.Constraint) IncompleteMultiVariableConstraint(com.sri.ai.grinder.core.constraint.IncompleteMultiVariableConstraint) SingleVariableConstraint(com.sri.ai.grinder.api.SingleVariableConstraint) Constraint(com.sri.ai.grinder.api.Constraint) Expression(com.sri.ai.expresso.api.Expression) QuantifiedExpression(com.sri.ai.expresso.api.QuantifiedExpression) IncompleteMultiVariableConstraint(com.sri.ai.grinder.core.constraint.IncompleteMultiVariableConstraint)

Aggregations

Beta (com.google.common.annotations.Beta)1 Expression (com.sri.ai.expresso.api.Expression)1 QuantifiedExpression (com.sri.ai.expresso.api.QuantifiedExpression)1 Type (com.sri.ai.expresso.api.Type)1 TRUE (com.sri.ai.expresso.helper.Expressions.TRUE)1 ZERO (com.sri.ai.expresso.helper.Expressions.ZERO)1 Expressions.getVariablesBeingReferenced (com.sri.ai.expresso.helper.Expressions.getVariablesBeingReferenced)1 Expressions.makeSymbol (com.sri.ai.expresso.helper.Expressions.makeSymbol)1 Expressions.parse (com.sri.ai.expresso.helper.Expressions.parse)1 SubExpressionsDepthFirstIterator (com.sri.ai.expresso.helper.SubExpressionsDepthFirstIterator)1 Constraint (com.sri.ai.grinder.api.Constraint)1 Context (com.sri.ai.grinder.api.Context)1 SingleQuantifierEliminationProblem (com.sri.ai.grinder.api.SingleQuantifierEliminationProblem)1 SingleVariableConstraint (com.sri.ai.grinder.api.SingleVariableConstraint)1 Theory (com.sri.ai.grinder.api.Theory)1 IncompleteMultiVariableConstraint (com.sri.ai.grinder.core.constraint.IncompleteMultiVariableConstraint)1 DefaultSingleQuantifierEliminationProblem (com.sri.ai.grinder.core.solver.DefaultSingleQuantifierEliminationProblem)1 AssociativeCommutativeGroup (com.sri.ai.grinder.group.AssociativeCommutativeGroup)1 AssignmentMapsIterator (com.sri.ai.grinder.helper.AssignmentMapsIterator)1 GrinderUtil (com.sri.ai.grinder.helper.GrinderUtil)1