Search in sources :

Example 1 with Options

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 };
}
Also used : Options(kodkod.engine.config.Options) Solver(kodkod.engine.Solver) Solution(kodkod.engine.Solution)

Example 2 with Options

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());
}
Also used : Options(kodkod.engine.config.Options) Relation(kodkod.ast.Relation) HOLTranslation(kodkod.engine.hol.HOLTranslation) Bounds(kodkod.instance.Bounds)

Example 3 with Options

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);
    }
}
Also used : Options(kodkod.engine.config.Options) IntExpression(kodkod.ast.IntExpression) IntRange(kodkod.util.ints.IntRange)

Example 4 with Options

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);
}
Also used : Options(kodkod.engine.config.Options)

Example 5 with Options

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Options(kodkod.engine.config.Options) BooleanFormula(kodkod.engine.bool.BooleanFormula) Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) Bounds(kodkod.instance.Bounds) BooleanValue(kodkod.engine.bool.BooleanValue) BooleanFormula(kodkod.engine.bool.BooleanFormula)

Aggregations

Options (kodkod.engine.config.Options)13 IntExpression (kodkod.ast.IntExpression)5 IntRange (kodkod.util.ints.IntRange)5 Relation (kodkod.ast.Relation)3 Bounds (kodkod.instance.Bounds)3 Formula (kodkod.ast.Formula)2 Solution (kodkod.engine.Solution)2 TupleFactory (kodkod.instance.TupleFactory)2 LinkedHashSet (java.util.LinkedHashSet)1 Variable (kodkod.ast.Variable)1 IncrementalSolver (kodkod.engine.IncrementalSolver)1 Solver (kodkod.engine.Solver)1 BooleanFormula (kodkod.engine.bool.BooleanFormula)1 BooleanValue (kodkod.engine.bool.BooleanValue)1 HOLTranslation (kodkod.engine.hol.HOLTranslation)1 TupleSet (kodkod.instance.TupleSet)1 Universe (kodkod.instance.Universe)1 Test (org.junit.Test)1