use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class PropositionalTheory method getSingleVariableConstraintQuantifierEliminatorStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver getSingleVariableConstraintQuantifierEliminatorStepSolver(AssociativeCommutativeGroup group, SingleVariableConstraint constraintForThisIndex, Expression body, Context context) {
ExpressionStepSolver formulaSplitterStepSolver = new QuantifierEliminationOnBodyInWhichIndexOnlyOccursInsideLiteralsStepSolver(group, constraintForThisIndex, body);
ExpressionLiteralSplitterStepSolver result = new ExpressionStepSolverToLiteralSplitterStepSolverAdapter(formulaSplitterStepSolver);
return result;
}
use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class EqualityTheory method getSingleVariableConstraintQuantifierEliminatorStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver getSingleVariableConstraintQuantifierEliminatorStepSolver(AssociativeCommutativeGroup group, SingleVariableConstraint constraint, Expression body, Context context) {
ExpressionStepSolver formulaSplitterStepSolver = new QuantifierEliminationOnBodyInWhichIndexOnlyOccursInsideLiteralsStepSolver(group, constraint, body);
ExpressionLiteralSplitterStepSolver result = new ExpressionStepSolverToLiteralSplitterStepSolverAdapter(formulaSplitterStepSolver);
return result;
}
use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class AbstractModelCountingWithPropagatedLiteralsImportedFromSatisfiabilityStepSolver method getPropagatedCNF.
/**
* This is overridden to re-use satisfiability's propagated CNF.
* It overrides caching done by overridden method, but that's fine since satisfiability should be doing that already.
*/
@Override
protected ArrayList<ArrayList<Expression>> getPropagatedCNF(Context context) {
Theory theory = getConstraint().getTheory();
ExpressionStepSolver satisfiability = theory.getSingleVariableConstraintSatisfiabilityStepSolver(getConstraint(), context);
if (satisfiability == null) {
throw new Error("No solver present for solving satisfiability of " + getConstraint().getVariable());
}
AbstractExpressionWithPropagatedLiteralsStepSolver satisfiabilityWithPropagatedLiterals;
try {
satisfiabilityWithPropagatedLiterals = (AbstractExpressionWithPropagatedLiteralsStepSolver) satisfiability;
} catch (ClassCastException e) {
throw new Error(this.getClass() + " can only be used with theories providing satisfiability context-dependent step solvers" + " that are extensions of " + AbstractExpressionWithPropagatedLiteralsStepSolver.class + ", but theory " + theory.getClass() + " provided instead an instance of" + satisfiability.getClass());
}
return satisfiabilityWithPropagatedLiterals.getPropagatedCNF(context);
}
use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class DifferenceArithmeticTheory method getSingleVariableConstraintQuantifierEliminatorStepSolver.
@Override
public ExpressionLiteralSplitterStepSolver getSingleVariableConstraintQuantifierEliminatorStepSolver(AssociativeCommutativeGroup group, SingleVariableConstraint constraint, Expression body, Context context) {
ExpressionStepSolver formulaSplitterStepSolver;
if (group instanceof Sum) {
formulaSplitterStepSolver = new SummationOnDifferenceArithmeticAndPolynomialStepSolver(constraint, body);
} else {
formulaSplitterStepSolver = new QuantifierEliminationOnBodyInWhichIndexOnlyOccursInsideLiteralsStepSolver(group, constraint, body);
}
ExpressionLiteralSplitterStepSolver result = new ExpressionStepSolverToLiteralSplitterStepSolverAdapter(formulaSplitterStepSolver);
;
return result;
}
use of com.sri.ai.grinder.sgdpllt.api.ExpressionStepSolver in project aic-expresso by aic-sri-international.
the class SummationOnDifferenceArithmeticAndPolynomialStepSolverTest method runTest.
private void runTest(Expression variable, String constraintString, Expression body, Expression expected, Context context) {
Theory theory = context.getTheory();
Constraint constraint = new SingleVariableDifferenceArithmeticConstraint(variable, true, theory);
constraint = constraint.conjoin(parse(constraintString), context);
ExpressionStepSolver stepSolver = new SummationOnDifferenceArithmeticAndPolynomialStepSolver((SingleVariableDifferenceArithmeticConstraint) constraint, body);
Expression actual = stepSolver.solve(context);
expected = simplify(expected, context);
System.out.println("sum({{ (on " + variable + " in " + GrinderUtil.getTypeExpression(variable, context) + ") " + body + " : " + constraintString + " }} = " + actual + "\n");
if (!expected.equals(actual)) {
Expression difference = apply(MINUS, expected, actual);
Expression differenceResult = simplify(difference, context);
if (!differenceResult.equals(ZERO)) {
System.err.println("Expressions are not equal and even difference is not zero");
System.err.println("Expected: " + expected);
System.err.println("Actual: " + actual);
System.err.println("Difference: " + differenceResult);
fail("Expressions are not equal and even difference is not zero");
}
}
// TODO: correctness test against grounding
}
Aggregations