kodkod.engine.fol2sat.UnboundLeafException Java Examples
The following examples show how to use
kodkod.engine.fol2sat.UnboundLeafException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HOLSolver.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
@Override public Iterator<Solution> solveAll(final Formula formula, final Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { return new Iterator<Solution>() { private Solution lastSol = null; @Override public boolean hasNext() { return lastSol == null || lastSol.sat(); } @Override public Solution next() { if (!hasNext()) throw new NoSuchElementException(); lastSol = (lastSol == null) ? solve(formula, bounds) : solveNext(); return lastSol; } @Override public void remove() { throw new IllegalStateException("can't remove solution"); } }; }
Example #2
Source File: Solver.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** * Attempts to satisfy the given {@code formula} and {@code bounds} with respect * to {@code this.options} or, optionally, prove the problem's unsatisfiability. * If the method completes normally, the result is a {@linkplain Solution * solution} containing either an {@linkplain Instance instance} of the given * problem or, optionally, a {@linkplain Proof proof} of its unsatisfiability. * An unsatisfiability proof will be constructed iff {@code this.options.solver} * specifies a {@linkplain SATProver} and * {@code this.options.logTranslation > 0}. * * @return some sol: {@link Solution} | some sol.instance() => sol.instance() in * MODELS(formula, bounds, this.options) else UNSAT(formula, bound, * this.options) * @throws NullPointerException formula = null || bounds = null * @throws UnboundLeafException the formula contains an undeclared variable or a * relation not mapped by the given bounds * @throws HigherOrderDeclException the formula contains a higher order * declaration that cannot be skolemized, or it can be skolemized * but {@code this.options.skolemDepth} is insufficiently large * @throws AbortedException this solving task was aborted * @see Options * @see Solution * @see Instance * @see Proof */ @Override public Solution solve(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { final long startTransl = System.currentTimeMillis(); try { final Translation.Whole translation = Translator.translate(formula, bounds, options); final long endTransl = System.currentTimeMillis(); if (translation.trivial()) return trivial(translation, endTransl - startTransl); final SATSolver cnf = translation.cnf(); options.reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses()); final long startSolve = System.currentTimeMillis(); final boolean isSat = cnf.solve(); final long endSolve = System.currentTimeMillis(); final Statistics stats = new Statistics(translation, endTransl - startTransl, endSolve - startSolve); return isSat ? sat(translation, stats) : unsat(translation, stats); } catch (SATAbortedException sae) { throw new AbortedException(sae); } }
Example #3
Source File: Solver.java From kodkod with MIT License | 6 votes |
/** * Attempts to satisfy the given {@code formula} and {@code bounds} with respect to * {@code this.options} or, optionally, prove the problem's unsatisfiability. If the method * completes normally, the result is a {@linkplain Solution solution} containing either an * {@linkplain Instance instance} of the given problem or, optionally, a {@linkplain Proof proof} of * its unsatisfiability. An unsatisfiability * proof will be constructed iff {@code this.options.solver} specifies a {@linkplain SATProver} and * {@code this.options.logTranslation > 0}. * * @return some sol: {@link Solution} | * some sol.instance() => * sol.instance() in MODELS(formula, bounds, this.options) else * UNSAT(formula, bound, this.options) * * @throws NullPointerException formula = null || bounds = null * @throws UnboundLeafException the formula contains an undeclared variable or a relation not mapped by the given bounds * @throws HigherOrderDeclException the formula contains a higher order declaration that cannot * be skolemized, or it can be skolemized but {@code this.options.skolemDepth} is insufficiently large * @throws AbortedException this solving task was aborted * @see Options * @see Solution * @see Instance * @see Proof */ public Solution solve(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { final long startTransl = System.currentTimeMillis(); try { final Translation.Whole translation = Translator.translate(formula, bounds, options); final long endTransl = System.currentTimeMillis(); if (translation.trivial()) return trivial(translation, endTransl - startTransl); final SATSolver cnf = translation.cnf(); options.reporter().solvingCNF(translation.numPrimaryVariables(), cnf.numberOfVariables(), cnf.numberOfClauses()); final long startSolve = System.currentTimeMillis(); final boolean isSat = cnf.solve(); final long endSolve = System.currentTimeMillis(); final Statistics stats = new Statistics(translation, endTransl - startTransl, endSolve - startSolve); return isSat ? sat(translation, stats) : unsat(translation, stats); } catch (SATAbortedException sae) { throw new AbortedException(sae); } }
Example #4
Source File: IncrementalSolver.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Iterator<Solution> solveAll(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { throw new RuntimeException("not implemented"); }
Example #5
Source File: HOLSolver.java From org.alloytools.alloy with Apache License 2.0 | 3 votes |
/** * 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(); // final long startTransl = System.currentTimeMillis(); // translation = Translator.translateHOL(f, b, 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; } }
Example #6
Source File: Solver.java From org.alloytools.alloy with Apache License 2.0 | 3 votes |
/** * Attempts to find all solutions to the given formula with respect to the * specified bounds or to prove the formula's unsatisfiability. If the operation * is successful, the method returns an iterator over n Solution objects. The * outcome of the first n-1 solutions is SAT or trivially SAT, and the outcome * of the nth solution is UNSAT or tirivally UNSAT. Note that an * unsatisfiability proof will be constructed for the last solution iff * this.options specifies the use of a core extracting SATSolver. Additionally, * the CNF variables in the proof can be related back to the nodes in the given * formula iff this.options has variable tracking enabled. Translation logging * also requires that there are no subnodes in the given formula that are both * syntactically shared and contain free variables. * * @return an iterator over all the Solutions to the formula with respect to the * given bounds * @throws NullPointerException formula = null || bounds = null * @throws kodkod.engine.fol2sat.UnboundLeafException the formula contains an * undeclared variable or a relation not mapped by the given bounds * @throws kodkod.engine.fol2sat.HigherOrderDeclException the formula contains a * higher order declaration that cannot be skolemized, or it can be * skolemized but this.options.skolemize is false. * @throws AbortedException this solving task was interrupted with a call to * Thread.interrupt on this thread * @throws IllegalStateException !this.options.solver().incremental() * @see Solution * @see Options * @see Proof */ @Override public Iterator<Solution> solveAll(final Formula formula, final Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { // if (Options.isDebug()) flushFormula(formula, bounds); //[AM] if (!options.solver().incremental()) throw new IllegalArgumentException("cannot enumerate solutions without an incremental solver."); return new SolutionIterator(formula, bounds, options); }
Example #7
Source File: KodkodSolver.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Attempts to satisfy the given {@code formula} and {@code bounds} with respect * to {@code this.options} or, optionally, prove the problem's unsatisfiability. * If the method completes normally, the result is a {@linkplain Solution * solution} containing either an {@linkplain Instance instance} of the given * problem or, optionally, a {@linkplain Proof proof} of its unsatisfiability. * * @return some sol: {@link Solution} | sol.satisfiable() => sol.instance() in * MODELS(formula, bounds, this.options) else UNSAT(formula, bound, * this.options) * @throws NullPointerException formula = null || bounds = null * @throws UnboundLeafException the formula contains an undeclared variable or a * relation not mapped by the given bounds * @throws HigherOrderDeclException the formula contains a higher order * declaration that cannot be skolemized, or it can be skolemized * but {@code this.options.skolemDepth} is insufficiently large * @throws AbortedException this solving task was aborted */ public Solution solve(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException;
Example #8
Source File: KodkodSolver.java From kodkod with MIT License | 2 votes |
/** * Attempts to satisfy the given {@code formula} and {@code bounds} with respect to * {@code this.options} or, optionally, prove the problem's unsatisfiability. If the method * completes normally, the result is a {@linkplain Solution solution} containing either an * {@linkplain Instance instance} of the given problem or, optionally, a {@linkplain Proof proof} of * its unsatisfiability. * * @return some sol: {@link Solution} | * sol.satisfiable() => sol.instance() in MODELS(formula, bounds, this.options) else UNSAT(formula, bound, this.options) * * @throws NullPointerException formula = null || bounds = null * @throws UnboundLeafException the formula contains an undeclared variable or a relation not mapped by the given bounds * @throws HigherOrderDeclException the formula contains a higher order declaration that cannot * be skolemized, or it can be skolemized but {@code this.options.skolemDepth} is insufficiently large * @throws AbortedException this solving task was aborted */ public Solution solve(Formula formula, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException;
Example #9
Source File: Solver.java From kodkod with MIT License | 1 votes |
/** * Attempts to find all solutions to the given formula with respect to the specified bounds or * to prove the formula's unsatisfiability. * If the operation is successful, the method returns an iterator over n Solution objects. The outcome * of the first n-1 solutions is SAT or trivially SAT, and the outcome of the nth solution is UNSAT * or trivially UNSAT. Note that an unsatisfiability * proof will be constructed for the last solution iff this.options specifies the use of a core extracting SATSolver. * Additionally, the CNF variables in the proof can be related back to the nodes in the given formula * iff this.options has variable tracking enabled. Translation logging also requires that * there are no subnodes in the given formula that are both syntactically shared and contain free variables. * * @return an iterator over all the Solutions to the formula with respect to the given bounds * @throws NullPointerException formula = null || bounds = null * @throws kodkod.engine.fol2sat.UnboundLeafException the formula contains an undeclared variable or * a relation not mapped by the given bounds * @throws kodkod.engine.fol2sat.HigherOrderDeclException the formula contains a higher order declaration that cannot * be skolemized, or it can be skolemized but this.options.skolemize is false. * @throws AbortedException this solving task was interrupted with a call to Thread.interrupt on this thread * @throws IllegalStateException !this.options.solver().incremental() * @see Solution * @see Options * @see Proof */ public Iterator<Solution> solveAll(final Formula formula, final Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException { if (!options.solver().incremental()) throw new IllegalArgumentException("cannot enumerate solutions without an incremental solver."); return new SolutionIterator(formula, bounds, options); }
Example #10
Source File: KodkodSolver.java From org.alloytools.alloy with Apache License 2.0 | votes |
public Iterator<Solution> solveAll(Formula fgoal, Bounds bounds) throws HigherOrderDeclException, UnboundLeafException, AbortedException;