kodkod.engine
Class Solver

java.lang.Object
  extended by kodkod.engine.Solver

public final class Solver
extends java.lang.Object

A computational engine for solving relational formulae. A formula is solved with respect to given bounds and options.

Author:
Emina Torlak
specfield:
options: Options

Constructor Summary
Solver()
          Constructs a new Solver with the default options.
Solver(Options options)
          Constructs a new Solver with the given options.
 
Method Summary
 Options options()
          Returns the Options object used by this Solver to guide translation of formulas from first-order logic to cnf.
 Solution solve(Formula formula, Bounds bounds)
          Attempts to satisfy the given formula with respect to the specified bounds or prove the formula's unsatisfiability.
 Solution solve(Formula formula, Bounds bounds, Cost cost)
          Attempts to satisfy the given formula with respect to the specified bounds, while minimizing the specified cost function.
 java.util.Iterator<Solution> solveAll(Formula formula, Bounds bounds)
          Attempts to find all solutions to the given formula with respect to the specified bounds or to prove the formula's unsatisfiability.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Solver

public Solver()
Constructs a new Solver with the default options.

effects:
this.options' = new Options()

Solver

public Solver(Options options)
Constructs a new Solver with the given options.

Throws:
java.lang.NullPointerException - - options = null
effects:
this.options' = options
Method Detail

options

public Options options()
Returns the Options object used by this Solver to guide translation of formulas from first-order logic to cnf.

Returns:
this.options

solve

public Solution solve(Formula formula,
                      Bounds bounds,
                      Cost cost)
               throws HigherOrderDeclException,
                      UnboundLeafException,
                      AbortedException
Attempts to satisfy the given formula with respect to the specified bounds, while minimizing the specified cost function. If the operation is successful, the method returns a Solution that contains either a minimal-cost instance of the formula or a proof of unsatisfiability. The latter is generated iff the SAT solver generated by this.options.solver() is a SATProver in addition to being a SATMinSolver.

Returns:
Solution to the formula with respect to the given bounds and cost
Throws:
java.lang.NullPointerException - - formula = null || bounds = null || cost = null
UnboundLeafException - - the formula contains an undeclared variable or a relation not mapped by the given bounds
HigherOrderDeclException - - the formula contains a higher order declaration that cannot be skolemized, or it can be skolemized but this.options.skolemize is false.
AbortedException - - this solving task was interrupted with a call to Thread.interrupt on this thread
java.lang.IllegalArgumentException - - some (formula.^children & Relation) - cost.relations
java.lang.IllegalStateException - - !this.options.solver.minimizer || this.options.logTranslation
See Also:
Solution, Options, Cost
requires:
!this.options.logTranslation && this.options.solver.minimizer

solve

public Solution solve(Formula formula,
                      Bounds bounds)
               throws HigherOrderDeclException,
                      UnboundLeafException,
                      AbortedException
Attempts to satisfy the given formula with respect to the specified bounds or prove the formula's unsatisfiability. If the operation is successful, the method returns a Solution that contains either an instance of the formula or an unsatisfiability proof. Note that an unsatisfiability proof will be constructed 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 translation logging enabled. Translation logging also requires that there are no subnodes in the given formula that are both syntactically shared and contain free variables.

Returns:
Solution to the formula with respect to the given bounds
Throws:
java.lang.NullPointerException - - formula = null || bounds = null
UnboundLeafException - - the formula contains an undeclared variable or a relation not mapped by the given bounds
HigherOrderDeclException - - the formula contains a higher order declaration that cannot be skolemized, or it can be skolemized but this.options.skolemize is false.
AbortedException - - this solving task was interrupted with a call to Thread.interrupt on this thread
See Also:
Solution, Options, Proof
requires:
this.options.logTranslation => (all n: formula.*children | #n.~children > 1 => no freeVariables(n))

solveAll

public java.util.Iterator<Solution> solveAll(Formula formula,
                                             Bounds bounds)
                                      throws HigherOrderDeclException,
                                             UnboundLeafException,
                                             AbortedException
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.

Returns:
an iterator over all the Solutions to the formula with respect to the given bounds
Throws:
java.lang.NullPointerException - - formula = null || bounds = null
UnboundLeafException - - the formula contains an undeclared variable or a relation not mapped by the given bounds
HigherOrderDeclException - - the formula contains a higher order declaration that cannot be skolemized, or it can be skolemized but this.options.skolemize is false.
AbortedException - - this solving task was interrupted with a call to Thread.interrupt on this thread
java.lang.IllegalStateException - - !this.options.solver().incremental()
See Also:
Solution, Options, Proof
requires:
this.options.logTranslation => (all n: formula.*children | #n.~children > 1 => no freeVariables(n))

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()