Search in sources :

Example 1 with Proc

use of kodkod.engine.hol.Proc in project org.alloytools.alloy by AlloyTools.

the class HOLSolver method solve.

/**
 * Adds the specified formula and bounds to the solver's state, modifies the
 * current solution to reflect the updated state (if needed), and returns this
 * solver. This solver should not be used again if a call to this method results
 * in an exception.
 *
 * @requires this.{@link #usable() usable}()
 * @requires f.*components & Relation in (this.bounds + b).relations
 * @requires some this.bounds => this.bounds.universe = b.universe && no
 *           b.intBound && no (this.bounds.relations & b.relations)
 * @requires some this.bounds => all s:
 *           {@link SymmetryDetector#partition(Bounds) partition}(this.bounds) |
 *           some p: {@link SymmetryDetector#partition(Bounds) partition}(b) |
 *           s.elements in p.elements
 * @ensures this.formulas' = this.formulas + f
 * @ensures some this.bounds => (this.bounds.relations' = this.bounds.relations
 *          + b.relations && this.bounds.upperBound' = this.bounds.upperBound +
 *          b.upperBound && this.bounds.lowerBound' = this.bounds.lowerBound +
 *          b.lowerBound) else (this.bounds' = bounds)
 * @return some sol: Solution | sol.instance() = null => UNSAT(this.formulas',
 *         this.bounds', this.options) else sol.instance() in
 *         MODELS(Formula.and(this.formulas'), this.bounds', this.options)
 * @throws IllegalStateException a prior call returned an UNSAT solution or
 *             resulted in an exception
 * @throws NullPointerException any of the arguments are null
 * @throws UnboundLeafException the formula refers to an undeclared variable or
 *             a relation not mapped by this.bounds + b
 * @throws HigherOrderDeclException the formula contains a higher order
 *             declaration
 * @throws IllegalArgumentException any of the remaining preconditions on
 *             {@code f} and {@code b} are violated
 * @throws AbortedException this solving task has been aborted
 */
@Override
public Solution solve(Formula f, Bounds b) throws HigherOrderDeclException, UnboundLeafException, AbortedException {
    if (outcome == Boolean.FALSE)
        throw new IllegalStateException("Cannot use this solver since a prior call to solve(...) produced an UNSAT solution.");
    if (outcome != null && translation == null)
        throw new IllegalStateException("Cannot use this solver since a prior call to solve(...) resulted in an exception.");
    try {
        final long startProcTransl = System.currentTimeMillis();
        Proc proc = Translator.translate2proc(f, b, options);
        final long endProcTransl = System.currentTimeMillis();
        final long startTransl = System.currentTimeMillis();
        translation = HOLTranslator.proc2transl(proc, options);
        final long endTransl = System.currentTimeMillis();
        return toSolution(endProcTransl - startProcTransl, endTransl - startTransl, translation);
    } catch (SATAbortedException sae) {
        free();
        throw new AbortedException(sae);
    } catch (RuntimeException e) {
        free();
        throw e;
    }
}
Also used : Proc(kodkod.engine.hol.Proc) SATAbortedException(kodkod.engine.satlab.SATAbortedException) SATAbortedException(kodkod.engine.satlab.SATAbortedException)

Aggregations

Proc (kodkod.engine.hol.Proc)1 SATAbortedException (kodkod.engine.satlab.SATAbortedException)1