Search in sources :

Example 1 with DefaultMultiVariableConstraint

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

the class SGDPLLTTester method testMultiVariableConstraints.

/**
	 * 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 solver
	 * are indeed unsatisfiable (checked by brute force).
	 * Throws an {@link Error} with the failure description if a test fails.
	 * @param theoryTestingSupport
	 * @param numberOfTests
	 * @param maxNumberOfLiterals
	 * @param outputCount
	 */
public static void testMultiVariableConstraints(boolean testAgainstBruteForce, TheoryTestingSupport theoryTestingSupport, long numberOfTests, int maxNumberOfLiterals, boolean outputCount) {
    NullaryFunction<Constraint> makeInitialConstraint = () -> new DefaultMultiVariableConstraint(theoryTestingSupport.getTheory());
    Context context = theoryTestingSupport.makeContextWithTestingInformation();
    Function<Constraint, Expression> makeRandomLiteral = c -> theoryTestingSupport.makeRandomLiteral(context);
    // DefaultMultiVariableConstraint is incomplete
    TestRunner tester = SGDPLLTTester::testIncompleteSatisfiability;
    runTesterGivenOnSuccessiveConjunctionsOfLiterals("incomplete satisfiability", tester, numberOfTests, maxNumberOfLiterals, testAgainstBruteForce, theoryTestingSupport, makeInitialConstraint, makeRandomLiteral, outputCount, context);
}
Also used : CompleteMultiVariableContext(com.sri.ai.grinder.sgdpllt.core.constraint.CompleteMultiVariableContext) Context(com.sri.ai.grinder.sgdpllt.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) Constraint(com.sri.ai.grinder.sgdpllt.api.Constraint) Function(java.util.function.Function) GrinderUtil(com.sri.ai.grinder.helper.GrinderUtil) Util.in(com.sri.ai.util.Util.in) ThereExists(com.sri.ai.grinder.sgdpllt.library.boole.ThereExists) AbstractIterativeMultiIndexQuantifierElimination(com.sri.ai.grinder.sgdpllt.interpreter.AbstractIterativeMultiIndexQuantifierElimination) Expressions.parse(com.sri.ai.expresso.helper.Expressions.parse) Map(java.util.Map) CompleteMultiVariableContext(com.sri.ai.grinder.sgdpllt.core.constraint.CompleteMultiVariableContext) And(com.sri.ai.grinder.sgdpllt.library.boole.And) DefaultMultiVariableConstraint(com.sri.ai.grinder.sgdpllt.core.constraint.DefaultMultiVariableConstraint) ZERO(com.sri.ai.expresso.helper.Expressions.ZERO) LinkedHashSet(java.util.LinkedHashSet) Sets(com.sri.ai.grinder.sgdpllt.library.set.Sets) Type(com.sri.ai.expresso.api.Type) NullaryFunction(com.sri.ai.util.base.NullaryFunction) Util.join(com.sri.ai.util.Util.join) SingleVariableConstraint(com.sri.ai.grinder.sgdpllt.api.SingleVariableConstraint) Simplifier(com.sri.ai.grinder.sgdpllt.rewriter.api.Simplifier) Collection(java.util.Collection) Util.list(com.sri.ai.util.Util.list) Set(java.util.Set) Expressions.getVariableReferences(com.sri.ai.expresso.helper.Expressions.getVariableReferences) Context(com.sri.ai.grinder.sgdpllt.api.Context) QuantifiedExpression(com.sri.ai.expresso.api.QuantifiedExpression) Theory(com.sri.ai.grinder.sgdpllt.api.Theory) Beta(com.google.common.annotations.Beta) IndexExpressions(com.sri.ai.grinder.sgdpllt.library.indexexpression.IndexExpressions) Expressions.makeSymbol(com.sri.ai.expresso.helper.Expressions.makeSymbol) Util(com.sri.ai.util.Util) AssociativeCommutativeGroup(com.sri.ai.grinder.sgdpllt.group.AssociativeCommutativeGroup) Util.pickKElementsWithoutReplacement(com.sri.ai.util.Util.pickKElementsWithoutReplacement) TRUE(com.sri.ai.expresso.helper.Expressions.TRUE) BruteForceCommonInterpreter(com.sri.ai.grinder.sgdpllt.interpreter.BruteForceCommonInterpreter) AssignmentsIterator(com.sri.ai.grinder.helper.AssignmentsIterator) Constraint(com.sri.ai.grinder.sgdpllt.api.Constraint) DefaultMultiVariableConstraint(com.sri.ai.grinder.sgdpllt.core.constraint.DefaultMultiVariableConstraint) SingleVariableConstraint(com.sri.ai.grinder.sgdpllt.api.SingleVariableConstraint) Expression(com.sri.ai.expresso.api.Expression) QuantifiedExpression(com.sri.ai.expresso.api.QuantifiedExpression) DefaultMultiVariableConstraint(com.sri.ai.grinder.sgdpllt.core.constraint.DefaultMultiVariableConstraint)

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.getVariableReferences (com.sri.ai.expresso.helper.Expressions.getVariableReferences)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 AssignmentsIterator (com.sri.ai.grinder.helper.AssignmentsIterator)1 GrinderUtil (com.sri.ai.grinder.helper.GrinderUtil)1 Constraint (com.sri.ai.grinder.sgdpllt.api.Constraint)1 Context (com.sri.ai.grinder.sgdpllt.api.Context)1 SingleVariableConstraint (com.sri.ai.grinder.sgdpllt.api.SingleVariableConstraint)1 Theory (com.sri.ai.grinder.sgdpllt.api.Theory)1 CompleteMultiVariableContext (com.sri.ai.grinder.sgdpllt.core.constraint.CompleteMultiVariableContext)1 DefaultMultiVariableConstraint (com.sri.ai.grinder.sgdpllt.core.constraint.DefaultMultiVariableConstraint)1 AssociativeCommutativeGroup (com.sri.ai.grinder.sgdpllt.group.AssociativeCommutativeGroup)1 AbstractIterativeMultiIndexQuantifierElimination (com.sri.ai.grinder.sgdpllt.interpreter.AbstractIterativeMultiIndexQuantifierElimination)1