mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-06 11:15:43 -05:00
5 lines
No EOL
23 KiB
HTML
5 lines
No EOL
23 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Solver (sidekick-bin.Sidekick_smtlib.Process.Solver)</title><link rel="stylesheet" href="../../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.0.2"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../../index.html">sidekick-bin</a> » <a href="../../index.html">Sidekick_smtlib</a> » <a href="../index.html">Process</a> » Solver</nav><header class="odoc-preamble"><h1>Module <code><span>Process.Solver</span></code></h1></header><nav class="odoc-toc"><ul><li><a href="#main-api">Main API</a></li></ul></nav><div class="odoc-content"><div class="odoc-spec"><div class="spec module" id="module-T" class="anchored"><a href="#module-T" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="T/index.html">T</a></span><span> : <a href="../../../../sidekick/Sidekick_core/module-type-TERM/index.html">Sidekick_core.TERM</a> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-TERM/Term/index.html#type-t">Term.t</a> = <a href="../../../../sidekick-base/Sidekick_base/Base_types/Term/index.html#type-t">Sidekick_base.Term.t</a></span> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-TERM/Term/index.html#type-store">Term.store</a> = <a href="../../../../sidekick-base/Sidekick_base/Base_types/Term/index.html#type-store">Sidekick_base.Term.store</a></span> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-TERM/Ty/index.html#type-t">Ty.t</a> = <a href="../../../../sidekick-base/Sidekick_base/Base_types/Ty/index.html#type-t">Sidekick_base.Ty.t</a></span> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-TERM/Ty/index.html#type-store">Ty.store</a> = <a href="../../../../sidekick-base/Sidekick_base/Base_types/Ty/index.html#type-store">Sidekick_base.Ty.store</a></span></span></code></div></div><div class="odoc-spec"><div class="spec module" id="module-Lit" class="anchored"><a href="#module-Lit" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="Lit/index.html">Lit</a></span><span> : <a href="../../../../sidekick/Sidekick_core/module-type-LIT/index.html">Sidekick_core.LIT</a> <span class="keyword">with</span> <span><span class="keyword">module</span> <a href="../../../../sidekick/Sidekick_core/module-type-LIT/T/index.html">T</a> = <a href="T/index.html">T</a></span></span></code></div></div><div class="odoc-spec"><div class="spec type" id="type-proof" class="anchored"><a href="#type-proof" class="anchor"></a><code><span><span class="keyword">type</span> proof</span><span> = <a href="../../../../sidekick-base/Sidekick_base/Proof/index.html#type-t">Sidekick_base.Proof.t</a></span></code></div></div><div class="odoc-spec"><div class="spec type" id="type-proof_step" class="anchored"><a href="#type-proof_step" class="anchor"></a><code><span><span class="keyword">type</span> proof_step</span></code></div></div><div class="odoc-spec"><div class="spec module" id="module-P" class="anchored"><a href="#module-P" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="P/index.html">P</a></span><span> : <a href="../../../../sidekick/Sidekick_core/module-type-PROOF/index.html">Sidekick_core.PROOF</a> <span class="keyword">with</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-PROOF/index.html#type-lit">lit</a> = <a href="Lit/index.html#type-t">Lit.t</a></span> <span class="keyword">and</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-PROOF/index.html#type-t">t</a> = <a href="#type-proof">proof</a></span> <span class="keyword">and</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-PROOF/index.html#type-proof_step">proof_step</a> = <a href="#type-proof_step">proof_step</a></span> <span class="keyword">and</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-PROOF/index.html#type-term">term</a> = <a href="T/Term/index.html#type-t">T.Term.t</a></span></span></code></div></div><div class="odoc-spec"><div class="spec module" id="module-Solver_internal" class="anchored"><a href="#module-Solver_internal" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="Solver_internal/index.html">Solver_internal</a></span><span> : <a href="../../../../sidekick/Sidekick_core/module-type-SOLVER_INTERNAL/index.html">Sidekick_core.SOLVER_INTERNAL</a> <span class="keyword">with</span> <span><span class="keyword">module</span> <a href="../../../../sidekick/Sidekick_core/module-type-SOLVER_INTERNAL/T/index.html">T</a> = <a href="T/index.html">T</a></span> <span class="keyword">and</span> <span><span class="keyword">module</span> <a href="../../../../sidekick/Sidekick_core/module-type-SOLVER_INTERNAL/Lit/index.html">Lit</a> = <a href="Lit/index.html">Lit</a></span> <span class="keyword">and</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-SOLVER_INTERNAL/index.html#type-proof">proof</a> = <a href="#type-proof">proof</a></span> <span class="keyword">and</span> <span><span class="keyword">type</span> <a href="../../../../sidekick/Sidekick_core/module-type-SOLVER_INTERNAL/index.html#type-proof_step">proof_step</a> = <a href="#type-proof_step">proof_step</a></span> <span class="keyword">and</span> <span><span class="keyword">module</span> <a href="../../../../sidekick/Sidekick_core/module-type-SOLVER_INTERNAL/P/index.html">P</a> = <a href="P/index.html">P</a></span></span></code></div><div class="spec-doc"><p>Internal solver, available to theories.</p></div></div><div class="odoc-spec"><div class="spec type" id="type-t" class="anchored"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> t</span></code></div><div class="spec-doc"><p>The solver's state.</p></div></div><div class="odoc-spec"><div class="spec type" id="type-solver" class="anchored"><a href="#type-solver" class="anchor"></a><code><span><span class="keyword">type</span> solver</span><span> = <a href="#type-t">t</a></span></code></div></div><div class="odoc-spec"><div class="spec type" id="type-term" class="anchored"><a href="#type-term" class="anchor"></a><code><span><span class="keyword">type</span> term</span><span> = <a href="T/Term/index.html#type-t">T.Term.t</a></span></code></div></div><div class="odoc-spec"><div class="spec type" id="type-ty" class="anchored"><a href="#type-ty" class="anchor"></a><code><span><span class="keyword">type</span> ty</span><span> = <a href="T/Ty/index.html#type-t">T.Ty.t</a></span></code></div></div><div class="odoc-spec"><div class="spec type" id="type-lit" class="anchored"><a href="#type-lit" class="anchor"></a><code><span><span class="keyword">type</span> lit</span><span> = <a href="Lit/index.html#type-t">Lit.t</a></span></code></div></div><div class="odoc-spec"><div class="spec module-type" id="module-type-THEORY" class="anchored"><a href="#module-type-THEORY" class="anchor"></a><code><span><span class="keyword">module</span> <span class="keyword">type</span> </span><span><a href="module-type-THEORY/index.html">THEORY</a></span><span> = <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div><div class="odoc-spec"><div class="spec type" id="type-theory" class="anchored"><a href="#type-theory" class="anchor"></a><code><span><span class="keyword">type</span> theory</span><span> = <span>(<span class="keyword">module</span> <a href="module-type-THEORY/index.html">THEORY</a>)</span></span></code></div><div class="spec-doc"><p>A theory that can be used for this particular solver.</p></div></div><div class="odoc-spec"><div class="spec type" id="type-theory_p" class="anchored"><a href="#type-theory_p" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a theory_p</span></span><span> = <span>(<span class="keyword">module</span> <a href="module-type-THEORY/index.html">THEORY</a> <span class="keyword">with</span> <span class="keyword">type</span> <a href="module-type-THEORY/index.html#type-t">t</a> = <span class="type-var">'a</span>)</span></span></code></div><div class="spec-doc"><p>A theory that can be used for this particular solver, with state of type <code>'a</code>.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-mk_theory" class="anchored"><a href="#val-mk_theory" class="anchor"></a><code><span><span class="keyword">val</span> mk_theory : <span>name:string <span class="arrow">-></span></span> <span>create_and_setup:<span>(<span><a href="Solver_internal/index.html#type-t">Solver_internal.t</a> <span class="arrow">-></span></span> <span class="type-var">'th</span>)</span> <span class="arrow">-></span></span>
|
||
<span>?push_level:<span>(<span><span class="type-var">'th</span> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> <span>?pop_levels:<span>(<span><span class="type-var">'th</span> <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span> <span>unit <span class="arrow">-></span></span> <a href="#type-theory">theory</a></span></code></div><div class="spec-doc"><p>Helper to create a theory.</p></div></div><div class="odoc-spec"><div class="spec module" id="module-Model" class="anchored"><a href="#module-Model" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="Model/index.html">Model</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Models</p></div></div><div class="odoc-spec"><div class="spec module" id="module-Unknown" class="anchored"><a href="#module-Unknown" class="anchor"></a><code><span><span class="keyword">module</span> </span><span><a href="Unknown/index.html">Unknown</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div></div><h4 id="main-api"><a href="#main-api" class="anchor"></a>Main API</h4><div class="odoc-spec"><div class="spec value" id="val-stats" class="anchored"><a href="#val-stats" class="anchor"></a><code><span><span class="keyword">val</span> stats : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="../../../../sidekick/Sidekick_util/Stat/index.html#type-t">Sidekick_util.Stat.t</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-tst" class="anchored"><a href="#val-tst" class="anchor"></a><code><span><span class="keyword">val</span> tst : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="T/Term/index.html#type-store">T.Term.store</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-ty_st" class="anchored"><a href="#val-ty_st" class="anchor"></a><code><span><span class="keyword">val</span> ty_st : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="T/Ty/index.html#type-store">T.Ty.store</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-proof" class="anchored"><a href="#val-proof" class="anchor"></a><code><span><span class="keyword">val</span> proof : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-proof">proof</a></span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-create" class="anchored"><a href="#val-create" class="anchor"></a><code><span><span class="keyword">val</span> create : <span>?stat:<a href="../../../../sidekick/Sidekick_util/Stat/index.html#type-t">Sidekick_util.Stat.t</a> <span class="arrow">-></span></span> <span>?size:<span>[ `Big <span>| `Tiny</span> <span>| `Small</span> ]</span> <span class="arrow">-></span></span> <span>proof:<a href="#type-proof">proof</a> <span class="arrow">-></span></span> <span>theories:<span><a href="#type-theory">theory</a> list</span> <span class="arrow">-></span></span>
|
||
<span><a href="T/Term/index.html#type-store">T.Term.store</a> <span class="arrow">-></span></span> <span><a href="T/Ty/index.html#type-store">T.Ty.store</a> <span class="arrow">-></span></span> <span>unit <span class="arrow">-></span></span> <a href="#type-t">t</a></span></code></div><div class="spec-doc"><p>Create a new solver.</p><p>It needs a term state and a type state to manipulate terms and types. All terms and types interacting with this solver will need to come from these exact states.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">store_proof</span> <p>if true, proofs from the SAT solver and theories are retained and potentially accessible after <code>solve</code> returns UNSAT.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">size</span> <p>influences the size of initial allocations.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">theories</span> <p>theories to load from the start. Other theories can be added using <code>add_theory</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value" id="val-add_theory" class="anchored"><a href="#val-add_theory" class="anchor"></a><code><span><span class="keyword">val</span> add_theory : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-theory">theory</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Add a theory to the solver. This should be called before any call to <a href="#val-solve"><code>solve</code></a> or to <a href="#val-add_clause"><code>add_clause</code></a> and the likes (otherwise the theory will have a partial view of the problem).</p></div></div><div class="odoc-spec"><div class="spec value" id="val-add_theory_p" class="anchored"><a href="#val-add_theory_p" class="anchor"></a><code><span><span class="keyword">val</span> add_theory_p : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span><span class="type-var">'a</span> <a href="#type-theory_p">theory_p</a></span> <span class="arrow">-></span></span> <span class="type-var">'a</span></span></code></div><div class="spec-doc"><p>Add the given theory and obtain its state</p></div></div><div class="odoc-spec"><div class="spec value" id="val-add_theory_l" class="anchored"><a href="#val-add_theory_l" class="anchor"></a><code><span><span class="keyword">val</span> add_theory_l : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span><a href="#type-theory">theory</a> list</span> <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec value" id="val-mk_lit_t" class="anchored"><a href="#val-mk_lit_t" class="anchor"></a><code><span><span class="keyword">val</span> mk_lit_t : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span>?sign:bool <span class="arrow">-></span></span> <span><a href="#type-term">term</a> <span class="arrow">-></span></span> <a href="#type-lit">lit</a></span></code></div><div class="spec-doc"><p><code>mk_lit_t _ ~sign t</code> returns <code>lit'</code>, where <code>lit'</code> is <code>preprocess(lit)</code> and <code>lit</code> is an internal representation of <code>± t</code>.</p><p>The proof of <code>|- lit = lit'</code> is directly added to the solver's proof.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-add_clause" class="anchored"><a href="#val-add_clause" class="anchor"></a><code><span><span class="keyword">val</span> add_clause : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span><a href="#type-lit">lit</a> <a href="../../../../sidekick/Sidekick_util/IArray/index.html#type-t">Sidekick_util.IArray.t</a></span> <span class="arrow">-></span></span> <span><a href="#type-proof_step">proof_step</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p><code>add_clause solver cs</code> adds a boolean clause to the solver. Subsequent calls to <a href="#val-solve"><code>solve</code></a> will need to satisfy this clause.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-add_clause_l" class="anchored"><a href="#val-add_clause_l" class="anchor"></a><code><span><span class="keyword">val</span> add_clause_l : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span><a href="#type-lit">lit</a> list</span> <span class="arrow">-></span></span> <span><a href="#type-proof_step">proof_step</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Add a clause to the solver, given as a list.</p></div></div><div class="odoc-spec"><div class="spec value" id="val-assert_terms" class="anchored"><a href="#val-assert_terms" class="anchor"></a><code><span><span class="keyword">val</span> assert_terms : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><span><a href="#type-term">term</a> list</span> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Helper that turns each term into an atom, before adding the result to the solver as an assertion</p></div></div><div class="odoc-spec"><div class="spec value" id="val-assert_term" class="anchored"><a href="#val-assert_term" class="anchor"></a><code><span><span class="keyword">val</span> assert_term : <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <span><a href="#type-term">term</a> <span class="arrow">-></span></span> unit</span></code></div><div class="spec-doc"><p>Helper that turns the term into an atom, before adding the result to the solver as a unit clause assertion</p></div></div><div class="odoc-spec"><div class="spec type" id="type-res" class="anchored"><a href="#type-res" class="anchor"></a><code><span><span class="keyword">type</span> res</span><span> = </span></code><table><tr id="type-res.Sat" class="anchored"><td class="def variant constructor"><a href="#type-res.Sat" class="anchor"></a><code><span>| </span><span><span class="constructor">Sat</span> <span class="keyword">of</span> <a href="Model/index.html#type-t">Model.t</a></span></code></td><td class="def-doc"><span class="comment-delim">(*</span><p>Satisfiable</p><span class="comment-delim">*)</span></td></tr><tr id="type-res.Unsat" class="anchored"><td class="def variant constructor"><a href="#type-res.Unsat" class="anchor"></a><code><span>| </span><span><span class="constructor">Unsat</span> <span class="keyword">of</span> </span><span>{</span></code><table><tr id="type-res.unsat_core" class="anchored"><td class="def record field"><a href="#type-res.unsat_core" class="anchor"></a><code><span>unsat_core : <span>unit <span class="arrow">-></span></span> <span><a href="#type-lit">lit</a> <span class="xref-unresolved">Iter</span>.t</span>;</span></code></td><td class="def-doc"><span class="comment-delim">(*</span><p>Unsat core (subset of assumptions), or empty</p><span class="comment-delim">*)</span></td></tr><tr id="type-res.unsat_proof_step" class="anchored"><td class="def record field"><a href="#type-res.unsat_proof_step" class="anchor"></a><code><span>unsat_proof_step : <span>unit <span class="arrow">-></span></span> <span><a href="#type-proof_step">proof_step</a> option</span>;</span></code></td><td class="def-doc"><span class="comment-delim">(*</span><p>Proof step for the empty clause</p><span class="comment-delim">*)</span></td></tr></table><code><span>}</span></code></td><td class="def-doc"><span class="comment-delim">(*</span><p>Unsatisfiable</p><span class="comment-delim">*)</span></td></tr><tr id="type-res.Unknown" class="anchored"><td class="def variant constructor"><a href="#type-res.Unknown" class="anchor"></a><code><span>| </span><span><span class="constructor">Unknown</span> <span class="keyword">of</span> <a href="Unknown/index.html#type-t">Unknown.t</a></span></code></td><td class="def-doc"><span class="comment-delim">(*</span><p>Unknown, obtained after a timeout, memory limit, etc.</p><span class="comment-delim">*)</span></td></tr></table></div><div class="spec-doc"><p>Result of solving for the current set of clauses</p></div></div><div class="odoc-spec"><div class="spec value" id="val-solve" class="anchored"><a href="#val-solve" class="anchor"></a><code><span><span class="keyword">val</span> solve : <span>?on_exit:<span><span>(<span>unit <span class="arrow">-></span></span> unit)</span> list</span> <span class="arrow">-></span></span> <span>?check:bool <span class="arrow">-></span></span> <span>?on_progress:<span>(<span><a href="#type-t">t</a> <span class="arrow">-></span></span> unit)</span> <span class="arrow">-></span></span>
|
||
<span>assumptions:<span><a href="#type-lit">lit</a> list</span> <span class="arrow">-></span></span> <span><a href="#type-t">t</a> <span class="arrow">-></span></span> <a href="#type-res">res</a></span></code></div><div class="spec-doc"><p><code>solve s</code> checks the satisfiability of the clauses added so far to <code>s</code>.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">check</span> <p>if true, the model is checked before returning.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">on_progress</span> <p>called regularly during solving.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">assumptions</span> <p>a set of atoms held to be true. The unsat core, if any, will be a subset of <code>assumptions</code>.</p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">on_exit</span> <p>functions to be run before this returns</p></li></ul></div></div><div class="odoc-spec"><div class="spec value" id="val-pp_stats" class="anchored"><a href="#val-pp_stats" class="anchor"></a><code><span><span class="keyword">val</span> pp_stats : <span><a href="#type-t">t</a> <span class="xref-unresolved">CCFormat</span>.printer</span></span></code></div><div class="spec-doc"><p>Print some statistics. What it prints exactly is unspecified.</p></div></div></div></body></html> |