use of kodkod.engine.config.Options in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method solve.
protected Solution[] solve(Formula formula) {
Solution s1 = new Solver(options).solve(formula, bounds);
Options opt2 = options.clone();
opt2.setSkolemDepth(2);
// Solution s2 = new Solver(opt2).solve(formula, bounds);
return new Solution[] { s1 };
}
use of kodkod.engine.config.Options in project org.alloytools.alloy by AlloyTools.
the class Translator method translateIncrementalTrivial.
/**
* @requires checkIncrementalBounds(bounds, transl)
* @requires checkIncrementalOptions(transl.options)
* @requires transl.trivial()
* @requires transl.cnf.solve()
* @return see {@link #translateIncremental(Formula, Bounds, Options)}
*/
private static Translation.Incremental translateIncrementalTrivial(Formula formula, Bounds bounds, Translation.Incremental transl) {
if (!transl.cnf().solve())
throw new IllegalArgumentException("Expected a satisfiable translation, given " + transl);
// release the old empty solver since we are going
transl.cnf().free();
// to re-translate
final Options tOptions = transl.options();
final Bounds tBounds = transl.bounds();
// transl.originalFormula.
for (Relation r : bounds.relations()) {
tBounds.bound(r, bounds.lowerBound(r), bounds.upperBound(r));
}
// re-translate the given formula with respect to tBounds. note that we
// don't have to re-translate
// the conjunction of transl.formula and formula since transl.formula is
// guaranteed to evaluate to
// TRUE with respect to tBounds (since no bindings that were originally
// in tBounds were changed by the above loop).
final Translation.Incremental updated = translateIncremental(formula, tBounds, tOptions);
// due to symmetry breaking.
return new Translation.Incremental(updated.bounds(), tOptions, transl.symmetries(), updated.interpreter(), updated.incrementer());
}
use of kodkod.engine.config.Options in project org.alloytools.alloy by AlloyTools.
the class IntTest method test2sComplementUnOps.
private final void test2sComplementUnOps(IntExpression[] vals) {
final Options options = solver.options();
final IntRange range = options.integers();
final int min = range.min(), max = range.max();
final int mask = ~(-1 << options.bitwidth());
for (int i = min; i <= max; i++) {
IntExpression vi = vals[i - min];
testUnOp(IntOperator.NEG, vi, i, -i, mask);
testUnOp(IntOperator.NOT, vi, i, ~i, mask);
testUnOp(IntOperator.ABS, vi, i, Math.abs(i), mask);
testUnOp(IntOperator.SGN, vi, i, i < 0 ? -1 : i > 0 ? 1 : 0, mask);
}
}
use of kodkod.engine.config.Options in project org.alloytools.alloy by AlloyTools.
the class HOLSome4AllTest method setupOptions.
protected void setupOptions() {
options = new Options();
options.setNoOverflow(true);
options.setBitwidth(bw());
options.setSolver(SATFactory.MiniSat);
options.setAllowHOL(true);
}
use of kodkod.engine.config.Options in project org.alloytools.alloy by AlloyTools.
the class Translator method translateIncrementalNonTrivial.
/**
* @requires checkIncrementalBounds(bounds, transl)
* @requires checkIncrementalOptions(transl.options)
* @requires !transl.trivial()
* @return see {@link #translateIncremental(Formula, Bounds, Options)}
*/
private static Translation.Incremental translateIncrementalNonTrivial(Formula formula, Bounds bounds, Translation.Incremental transl) {
final Options tOptions = transl.options();
final Bounds tBounds = transl.bounds();
// save the set of relations bound in the pre-state
final Set<Relation> oldRelations = new LinkedHashSet<Relation>(tBounds.relations());
// skolemization (below) may also cause extra relations to be added.
for (Relation r : bounds.relations()) {
tBounds.bound(r, bounds.lowerBound(r), bounds.upperBound(r));
}
final AnnotatedNode<Formula> annotated = (transl.options().skolemDepth() < 0) ? annotate(formula) : skolemize(annotate(formula), tBounds, tOptions);
// extend the interpreter with variable allocations for new relations,
// either from given bounds
// or those introduced by skolemization
final LeafInterpreter interpreter = transl.interpreter();
interpreter.extend(setDifference(tBounds.relations(), oldRelations), tBounds.lowerBounds(), tBounds.upperBounds());
final BooleanValue circuit = FOL2BoolTranslator.translate(annotated, interpreter);
if (circuit == BooleanConstant.FALSE) {
// release the old solver and state, and return a fresh trivially
// false incremental translation.
transl.incrementer().solver().free();
return new Translation.Incremental(tBounds, tOptions, transl.symmetries(), LeafInterpreter.empty(tBounds.universe(), tOptions), Bool2CNFTranslator.translateIncremental(BooleanConstant.FALSE, tOptions.solver()));
} else if (circuit == BooleanConstant.TRUE) {
// must add any newly allocated primary variables to the solver for
// interpretation to work correctly
final int maxVar = interpreter.factory().maxVariable();
final int cnfVar = transl.cnf().numberOfVariables();
if (maxVar > cnfVar) {
transl.cnf().addVariables(maxVar - cnfVar);
}
} else {
// circuit is a formula; add its CNF representation to
// transl.incrementer.solver()
Bool2CNFTranslator.translateIncremental((BooleanFormula) circuit, interpreter.factory().maxVariable(), transl.incrementer());
}
return transl;
}
Aggregations