Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 583ffa4ba069126c3ba0bc565dc0485a > files > 1418

cvc3-doc-2.4.1-1.fc15.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>CVC3: minisat_derivation.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">CVC3&#160;<span id="projectnumber">2.4.1</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">minisat_derivation.cpp</div>  </div>
</div>
<div class="contents">
<a href="minisat__derivation_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*****************************************************************************/</span><span class="comment"></span>
<a name="l00002"></a>00002 <span class="comment">/*!</span>
<a name="l00003"></a>00003 <span class="comment"> *\file minisat_derivation.cpp</span>
<a name="l00004"></a>00004 <span class="comment"> *\brief MiniSat proof logging</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * Author: Alexander Fuchs</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * Created: Sun Dec 07 11:09:00 2007</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * &lt;hr&gt;</span>
<a name="l00011"></a>00011 <span class="comment"> *</span>
<a name="l00012"></a>00012 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span>
<a name="l00013"></a>00013 <span class="comment"> * and its documentation for any purpose is hereby granted without</span>
<a name="l00014"></a>00014 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span>
<a name="l00015"></a>00015 <span class="comment"> * LICENSE file provided with this distribution.</span>
<a name="l00016"></a>00016 <span class="comment"> * </span>
<a name="l00017"></a>00017 <span class="comment"> * &lt;hr&gt;</span>
<a name="l00018"></a>00018 <span class="comment"> */</span>
<a name="l00019"></a>00019 <span class="comment">/*****************************************************************************/</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="minisat__derivation_8h.html" title="MiniSat proof logging.">minisat_derivation.h</a>&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="minisat__solver_8h.html" title="Adaptation of MiniSat to DPLL(T)">minisat_solver.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="sat__proof_8h.html" title="Sat solver proof representation.">sat_proof.h</a>&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;set&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="keyword">using namespace </span>MiniSat;
<a name="l00029"></a>00029 <span class="keyword">using namespace </span>std;
<a name="l00030"></a>00030 
<a name="l00031"></a><a class="code" href="classMiniSat_1_1Inference.html#aacd9c375bc7b8b0d87a15bcd9b5d35ce">00031</a> std::string <a class="code" href="classMiniSat_1_1Inference.html#aacd9c375bc7b8b0d87a15bcd9b5d35ce">Inference::toString</a>()<span class="keyword"> const </span>{
<a name="l00032"></a>00032   ostringstream buffer;
<a name="l00033"></a>00033   buffer &lt;&lt; getStart();
<a name="l00034"></a>00034   <span class="keywordflow">for</span> (Inference::TSteps::const_iterator step = d_steps.begin(); step != d_steps.end(); ++step) {
<a name="l00035"></a>00035     buffer &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; step-&gt;first.toString() &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt; step-&gt;second;
<a name="l00036"></a>00036   }
<a name="l00037"></a>00037   <span class="keywordflow">return</span> buffer.str();
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 
<a name="l00044"></a><a class="code" href="classMiniSat_1_1Derivation.html#a72d5632fb889b903e8f88891943e5562">00044</a> <a class="code" href="classMiniSat_1_1Derivation.html#a72d5632fb889b903e8f88891943e5562">Derivation::~Derivation</a>() {
<a name="l00045"></a>00045   <span class="comment">// deallocate generated unit clauses</span>
<a name="l00046"></a>00046   <span class="keywordflow">for</span> (<a class="code" href="classHash_1_1hash__map.html#a0fae180472ddfd8822c881caf23c11a9">TClauses::iterator</a> i = d_unitClauses.begin(); i != d_unitClauses.end(); ++i) {
<a name="l00047"></a>00047     <a class="code" href="namespaceMiniSat.html#acbe7b3fac8ab3909327207b0fea1f4d8">xfree</a>(i-&gt;second);
<a name="l00048"></a>00048   }
<a name="l00049"></a>00049   
<a name="l00050"></a>00050   <span class="comment">// deallocate removed clauses</span>
<a name="l00051"></a>00051   <span class="keywordflow">for</span> (std::deque&lt;Clause*&gt;::iterator i = d_removedClauses.begin(); i != d_removedClauses.end(); ++i) {
<a name="l00052"></a>00052     <a class="code" href="namespaceMiniSat.html#acbe7b3fac8ab3909327207b0fea1f4d8">xfree</a>(*i);
<a name="l00053"></a>00053   }
<a name="l00054"></a>00054   
<a name="l00055"></a>00055   <span class="comment">// deallocate inferences</span>
<a name="l00056"></a>00056   <span class="keywordflow">for</span> (<a class="code" href="classHash_1_1hash__map.html#a0fae180472ddfd8822c881caf23c11a9">TInferences::iterator</a> i = d_inferences.begin(); i != d_inferences.end(); ++i) {
<a name="l00057"></a>00057     <span class="keyword">delete</span> i-&gt;second;
<a name="l00058"></a>00058   }
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 
<a name="l00062"></a><a class="code" href="classMiniSat_1_1Derivation.html#ac5cf738303de9c9c2b15d7d9e0b44cce">00062</a> <span class="keywordtype">int</span> <a class="code" href="classMiniSat_1_1Derivation.html#ac5cf738303de9c9c2b15d7d9e0b44cce">Derivation::computeRootReason</a>(<a class="code" href="classMiniSat_1_1Lit.html">Lit</a> implied, <a class="code" href="classMiniSat_1_1Solver.html">Solver</a>* solver) {
<a name="l00063"></a>00063   <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* reason = solver-&gt;<a class="code" href="classMiniSat_1_1Solver.html#a8660c6ceafa236f5533e432bb859aeba">getReason</a>(implied);
<a name="l00064"></a>00064   <span class="comment">//  cout &lt;&lt; &quot;computeRootReason &quot; &lt;&lt; reason-&gt;id() &lt;&lt; endl;</span>
<a name="l00065"></a>00065   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_clauses.find(reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>()) != d_clauses.end(),
<a name="l00066"></a>00066         <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: implied reason not registered&quot;</span>);
<a name="l00067"></a>00067   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(reason == d_clauses.find(reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>())-&gt;second,
<a name="l00068"></a>00068         <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: implied reason not same as registered&quot;</span>);
<a name="l00069"></a>00069   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(reason != NULL, <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: implied reason is NULL&quot;</span>);
<a name="l00070"></a>00070   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(reason != <a class="code" href="classMiniSat_1_1Clause.html#a9a00e9c7831cc291c83d54bf4188e830">Clause::Decision</a>(), <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: implied is a decision&quot;</span>);
<a name="l00071"></a>00071   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>((*reason)[0] == implied, <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: implied is not in its reason&quot;</span>);
<a name="l00072"></a>00072   <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a> (
<a name="l00073"></a>00073     <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(solver-&gt;<a class="code" href="classMiniSat_1_1Solver.html#adc9d01899ff6c1eefea8749a1a97309b" title="clauses / assignment">getValue</a>((*reason)[0]) == <a class="code" href="namespaceMiniSat.html#ad0b6e52186f3374f569c4de9db621be1">l_True</a>,
<a name="l00074"></a>00074     <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: literal not implied (TRUE)&quot;</span>);
<a name="l00075"></a>00075     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#adf5aa50a639b4b5bb71e5ea76d45b8e2">size</a>(); ++i) {
<a name="l00076"></a>00076       <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(solver-&gt;<a class="code" href="classMiniSat_1_1Solver.html#adc9d01899ff6c1eefea8749a1a97309b" title="clauses / assignment">getValue</a>((*reason)[i]) == <a class="code" href="namespaceMiniSat.html#a810166165364a8a8262d24b13d7b1da9">l_False</a>,
<a name="l00077"></a>00077       <span class="stringliteral">&quot;MiniSat::Derivation::computeRootReason: literal not implied (FALSE)&quot;</span>);
<a name="l00078"></a>00078     }
<a name="l00079"></a>00079   )
<a name="l00080"></a>00080 
<a name="l00081"></a>00081   <span class="comment">// already a unit clause, so done</span>
<a name="l00082"></a>00082   <span class="keywordflow">if</span> (reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#adf5aa50a639b4b5bb71e5ea76d45b8e2">size</a>() == 1) {
<a name="l00083"></a>00083     <span class="keywordflow">return</span> reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>();
<a name="l00084"></a>00084   }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086   <span class="comment">// already derived the unit clause internally</span>
<a name="l00087"></a>00087   <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TClauses::const_iterator</a> iter = d_unitClauses.find(implied.<a class="code" href="classMiniSat_1_1Lit.html#a91d2d44275fe1e43cee4ce673b2ab41d">index</a>());
<a name="l00088"></a>00088   <span class="keywordflow">if</span> (iter != d_unitClauses.end()) {
<a name="l00089"></a>00089     <span class="keywordflow">return</span> iter-&gt;second-&gt;id();
<a name="l00090"></a>00090   }
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 
<a name="l00093"></a>00093   <span class="comment">// otherwise resolve the reason ...</span>
<a name="l00094"></a>00094   <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = <span class="keyword">new</span> <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>(reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>());
<a name="l00095"></a>00095   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; reason-&gt;<a class="code" href="classMiniSat_1_1Clause.html#adf5aa50a639b4b5bb71e5ea76d45b8e2">size</a>(); ++i) {
<a name="l00096"></a>00096     <a class="code" href="classMiniSat_1_1Lit.html">Lit</a> lit((*reason)[i]);
<a name="l00097"></a>00097     inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a61184032373fe3049198f8e3a71e436f">add</a>(lit, computeRootReason(~lit, solver));
<a name="l00098"></a>00098   }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100   <span class="comment">// and create the new unit clause</span>
<a name="l00101"></a>00101   <span class="comment">// (after resolve, so that clause ids are chronological wrt. inference)</span>
<a name="l00102"></a>00102   vector&lt;Lit&gt; literals;
<a name="l00103"></a>00103   literals.push_back(implied);
<a name="l00104"></a>00104   <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* unit = <a class="code" href="namespaceMiniSat.html#a9a3ff2cc55978ca3a973861cad2814e2">Clause_new</a>(literals, <a class="code" href="classCVC3_1_1Theorem.html">CVC3::Theorem</a>(), solver-&gt;<a class="code" href="classMiniSat_1_1Solver.html#a7323aff4aaa93c01e6008e8e033d2b8f">nextClauseID</a>());
<a name="l00105"></a>00105 
<a name="l00106"></a>00106   d_unitClauses[implied.<a class="code" href="classMiniSat_1_1Lit.html#a91d2d44275fe1e43cee4ce673b2ab41d">index</a>()] = unit;
<a name="l00107"></a>00107   <span class="comment">//    cout &lt;&lt; &quot;compute root reason : &quot; &lt;&lt; unit-&gt;id() &lt;&lt; endl;</span>
<a name="l00108"></a>00108   registerClause(unit);
<a name="l00109"></a>00109   registerInference(unit-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>(), inference);
<a name="l00110"></a>00110 
<a name="l00111"></a>00111   <span class="keywordflow">return</span> unit-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>();
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 
<a name="l00114"></a>00114 
<a name="l00115"></a><a class="code" href="classMiniSat_1_1Derivation.html#ad17e91fe3a421ef68df9463710c5fdc9">00115</a> <span class="keywordtype">void</span> <a class="code" href="classMiniSat_1_1Derivation.html#ad17e91fe3a421ef68df9463710c5fdc9">Derivation::finish</a>(<a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause, <a class="code" href="classMiniSat_1_1Solver.html">Solver</a>* solver) {
<a name="l00116"></a>00116   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(clause != NULL, <span class="stringliteral">&quot;MiniSat::derivation:finish:&quot;</span>);
<a name="l00117"></a>00117 
<a name="l00118"></a>00118   <span class="comment">// already the empty clause</span>
<a name="l00119"></a>00119   <span class="keywordflow">if</span> (clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#adf5aa50a639b4b5bb71e5ea76d45b8e2">size</a>() == 0) {
<a name="l00120"></a>00120     d_emptyClause = clause;
<a name="l00121"></a>00121   }
<a name="l00122"></a>00122   <span class="comment">// derive the empty clause</span>
<a name="l00123"></a>00123   <span class="keywordflow">else</span> {
<a name="l00124"></a>00124     <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = <span class="keyword">new</span> <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>(clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>());
<a name="l00125"></a>00125     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#adf5aa50a639b4b5bb71e5ea76d45b8e2">size</a>(); ++i) {
<a name="l00126"></a>00126       <a class="code" href="classMiniSat_1_1Lit.html">Lit</a> lit((*clause)[i]);
<a name="l00127"></a>00127       inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a61184032373fe3049198f8e3a71e436f">add</a>(lit, computeRootReason(~lit, solver));
<a name="l00128"></a>00128     }
<a name="l00129"></a>00129     vector&lt;Lit&gt; literals;
<a name="l00130"></a>00130     <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* empty = <a class="code" href="namespaceMiniSat.html#a9a3ff2cc55978ca3a973861cad2814e2">Clause_new</a>(literals, <a class="code" href="classCVC3_1_1Theorem.html">CVC3::Theorem</a>(), solver-&gt;<a class="code" href="classMiniSat_1_1Solver.html#a7323aff4aaa93c01e6008e8e033d2b8f">nextClauseID</a>());
<a name="l00131"></a>00131     removedClause(empty);
<a name="l00132"></a>00132     d_emptyClause = empty;
<a name="l00133"></a>00133     registerClause(empty);
<a name="l00134"></a>00134     registerInference(empty-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>(), inference);
<a name="l00135"></a>00135   }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137   checkDerivation(clause);
<a name="l00138"></a>00138   <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a> (checkDerivation(clause));
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 <span class="comment">//   cout &lt;&lt; &quot;PROOF_START&quot; &lt;&lt; endl;</span>
<a name="l00141"></a>00141 <span class="comment">//   printDerivation();</span>
<a name="l00142"></a>00142 <span class="comment">//   cout &lt;&lt; &quot;PROOF_END&quot; &lt;&lt; endl;</span>
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="classMiniSat_1_1Derivation.html#ac419e5de02d38bdc729487c82fa93de2">00148</a> <span class="keywordtype">void</span> <a class="code" href="classMiniSat_1_1Derivation.html#ac419e5de02d38bdc729487c82fa93de2">Derivation::checkDerivation</a>(<a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause) {
<a name="l00149"></a>00149   <span class="comment">// find all relevant clauses</span>
<a name="l00150"></a>00150 
<a name="l00151"></a>00151   <span class="comment">// - relevant: set clauses used in derivation</span>
<a name="l00152"></a>00152   <span class="comment">// - regress: relevant clauses whose antecedents have to be checked</span>
<a name="l00153"></a>00153   std::set&lt;int&gt; relevant;
<a name="l00154"></a>00154   std::set&lt;int&gt; regress;
<a name="l00155"></a>00155 
<a name="l00156"></a>00156   regress.insert(clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>());
<a name="l00157"></a>00157   <span class="keywordflow">while</span> (!regress.empty()) {
<a name="l00158"></a>00158     <span class="comment">// pick next clause to derive - start from bottom, i.e. latest derived clause</span>
<a name="l00159"></a>00159     <span class="keywordtype">int</span> clauseID = *(regress.rbegin());
<a name="l00160"></a>00160     regress.erase(clauseID);
<a name="l00161"></a>00161 
<a name="l00162"></a>00162     <span class="comment">// move to clauses relevant for the derivation</span>
<a name="l00163"></a>00163     <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(relevant.count(clauseID) == 0, <span class="stringliteral">&quot;Solver::printProof: already in relevant&quot;</span>);
<a name="l00164"></a>00164     relevant.insert(clauseID);
<a name="l00165"></a>00165 
<a name="l00166"></a>00166     <span class="comment">// process antecedents</span>
<a name="l00167"></a>00167     <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TInferences::const_iterator</a> iter = d_inferences.find(clauseID);
<a name="l00168"></a>00168     <span class="comment">// input clause</span>
<a name="l00169"></a>00169     <span class="keywordflow">if</span> (iter == d_inferences.end()) {
<a name="l00170"></a>00170       <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_inputClauses.contains(clauseID),
<a name="l00171"></a>00171       <span class="stringliteral">&quot;Solver::printProof: clause without antecedents is not marked as input clause&quot;</span>);
<a name="l00172"></a>00172     }
<a name="l00173"></a>00173 
<a name="l00174"></a>00174     <span class="keywordflow">else</span> {
<a name="l00175"></a>00175       <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = iter-&gt;second;
<a name="l00176"></a>00176       regress.insert(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>());
<a name="l00177"></a>00177       <span class="keyword">const</span> <a class="code" href="classMiniSat_1_1Inference.html#a0eef845f209a9bc406fe887c34f82553">Inference::TSteps</a>&amp; steps = inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a4111b13d1401b38cbe749357793883fa">getSteps</a>();
<a name="l00178"></a>00178       <span class="keywordflow">for</span> (Inference::TSteps::const_iterator step = steps.begin(); step != steps.end(); ++step) {
<a name="l00179"></a>00179   regress.insert(step-&gt;second);
<a name="l00180"></a>00180       }
<a name="l00181"></a>00181     }
<a name="l00182"></a>00182   }
<a name="l00183"></a>00183 
<a name="l00184"></a>00184 
<a name="l00185"></a>00185   <span class="comment">// check derivation</span>
<a name="l00186"></a>00186   <span class="keywordflow">for</span> (std::set&lt;int&gt;::iterator i = relevant.begin(); i != relevant.end(); ++i) {
<a name="l00187"></a>00187     <span class="keywordtype">int</span> clauseID = *i;
<a name="l00188"></a>00188     <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_clauses.contains(clauseID),
<a name="l00189"></a>00189     <span class="stringliteral">&quot;MiniSat::Derivation::printProof: clause id in proof is not in clauses&quot;</span>);
<a name="l00190"></a>00190     <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause = d_clauses.find(clauseID)-&gt;second;
<a name="l00191"></a>00191 
<a name="l00192"></a>00192     <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = NULL;
<a name="l00193"></a>00193     <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TInferences::const_iterator</a> j = d_inferences.find(clauseID);
<a name="l00194"></a>00194     <span class="keywordflow">if</span> (j != d_inferences.end()) {
<a name="l00195"></a>00195       inference = j-&gt;second;
<a name="l00196"></a>00196     }
<a name="l00197"></a>00197 
<a name="l00198"></a>00198     <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(inference != NULL || d_inputClauses.contains(clauseID),
<a name="l00199"></a>00199     <span class="stringliteral">&quot;MiniSat::Derivation::printProof: derivation of input clause&quot;</span>);
<a name="l00200"></a>00200     <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(inference == NULL || !d_inputClauses.contains(clauseID),
<a name="l00201"></a>00201     <span class="stringliteral">&quot;MiniSat::Derivation::printProof: no derivation for derived clause&quot;</span>);
<a name="l00202"></a>00202 
<a name="l00203"></a>00203     <span class="keywordflow">if</span> (inference != NULL) {
<a name="l00204"></a>00204       <span class="comment">//      cout &lt;&lt; &quot;Regress: &quot; &lt;&lt; clause-&gt;id() &lt;&lt; &quot; : &quot; &lt;&lt; clause-&gt;toString() &lt;&lt; endl;</span>
<a name="l00205"></a>00205       <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_clauses.find(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>()) != d_clauses.end(),
<a name="l00206"></a>00206         <span class="stringliteral">&quot;MiniSat::Derivation::printProof: first not in clauses&quot;</span>);
<a name="l00207"></a>00207 
<a name="l00208"></a>00208       <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* first = d_clauses.find(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>())-&gt;second;
<a name="l00209"></a>00209       <span class="comment">//      cout &lt;&lt; &quot;Derived from : &quot; &lt;&lt; first-&gt;id() &lt;&lt; &quot; : &quot; &lt;&lt; first-&gt;toString() &lt;&lt; endl;</span>
<a name="l00210"></a>00210 
<a name="l00211"></a>00211       set&lt;Lit&gt; derived;
<a name="l00212"></a>00212       <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; first-&gt;size(); ++i) {
<a name="l00213"></a>00213   derived.insert((*first)[i]);
<a name="l00214"></a>00214       }
<a name="l00215"></a>00215 
<a name="l00216"></a>00216       <span class="comment">// retrace derivation</span>
<a name="l00217"></a>00217       <span class="keywordflow">for</span> (Inference::TSteps::const_iterator step = inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a4111b13d1401b38cbe749357793883fa">getSteps</a>().begin();
<a name="l00218"></a>00218      step != inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a4111b13d1401b38cbe749357793883fa">getSteps</a>().end(); ++step) {
<a name="l00219"></a>00219   <a class="code" href="classMiniSat_1_1Lit.html">Lit</a> lit = step-&gt;first;
<a name="l00220"></a>00220   <span class="comment">//  cout &lt;&lt; &quot; over &quot; &lt;&lt; lit.toString() &lt;&lt; endl;</span>
<a name="l00221"></a>00221   <span class="comment">//  cout &lt;&lt; &quot;Derived from ... : &quot; &lt;&lt; step-&gt;second &lt;&lt; &quot; : &quot; &lt;&lt; d_clauses.find(step-&gt;second)-&gt;second-&gt;toString() &lt;&lt; endl;</span>
<a name="l00222"></a>00222 
<a name="l00223"></a>00223         <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_clauses.find(step-&gt;second) != d_clauses.end(),
<a name="l00224"></a>00224         <span class="stringliteral">&quot;MiniSat::Derivation::printProof: next not in clauses&quot;</span>);
<a name="l00225"></a>00225   <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* next = d_clauses.find(step-&gt;second)-&gt;second;
<a name="l00226"></a>00226 
<a name="l00227"></a>00227   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(derived.find(lit) != derived.end(),
<a name="l00228"></a>00228         <span class="stringliteral">&quot;MiniSat::Derivation::printProof: lit not in derived&quot;</span>);
<a name="l00229"></a>00229   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(next-&gt;contains(~lit),
<a name="l00230"></a>00230         <span class="stringliteral">&quot;MiniSat::Derivation::printProof: ~lit not in next&quot;</span>);
<a name="l00231"></a>00231 
<a name="l00232"></a>00232   derived.erase(lit);
<a name="l00233"></a>00233   <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; next-&gt;size(); ++i) {
<a name="l00234"></a>00234     <span class="keywordflow">if</span> ((*next)[i] != ~lit) {
<a name="l00235"></a>00235       derived.insert((*next)[i]);
<a name="l00236"></a>00236     }
<a name="l00237"></a>00237   }
<a name="l00238"></a>00238       }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240       <span class="comment">// check that we got the expected clause</span>
<a name="l00241"></a>00241       <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; clause-&gt;size(); ++i) {
<a name="l00242"></a>00242   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(derived.find((*clause)[i]) != derived.end(),
<a name="l00243"></a>00243         <span class="stringliteral">&quot;MiniSat::Derivation::printProof: didn&#39;t derive expected clause&quot;</span>);
<a name="l00244"></a>00244   derived.erase((*clause)[i]);
<a name="l00245"></a>00245       }
<a name="l00246"></a>00246       <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(derived.empty(),
<a name="l00247"></a>00247       <span class="stringliteral">&quot;MiniSat::Derivation::printProof: didn&#39;t derive expected clause 2&quot;</span>);
<a name="l00248"></a>00248     };
<a name="l00249"></a>00249   }
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 
<a name="l00253"></a><a class="code" href="classMiniSat_1_1Derivation.html#a5436a42caaab1bf37d9355c5bd43d251">00253</a> <a class="code" href="classSAT_1_1SatProof.html">SAT::SatProof</a>* <a class="code" href="classMiniSat_1_1Derivation.html#a5436a42caaab1bf37d9355c5bd43d251">Derivation::createProof</a>() {
<a name="l00254"></a>00254   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_emptyClause != NULL, <span class="stringliteral">&quot;MiniSat::Derivation:createProof: no empty clause&quot;</span>);
<a name="l00255"></a>00255   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_emptyClause-&gt;size() == 0,
<a name="l00256"></a>00256         <span class="stringliteral">&quot;MiniSat::Derivation:createProof: empty clause is not empty&quot;</span>);
<a name="l00257"></a>00257   <span class="keywordflow">return</span> createProof(d_emptyClause);
<a name="l00258"></a>00258 }
<a name="l00259"></a>00259 
<a name="l00260"></a><a class="code" href="classMiniSat_1_1Derivation.html#ad10061dacbd2acbcbd3c777f9fe3707b">00260</a> <a class="code" href="classSAT_1_1SatProof.html">SAT::SatProof</a>* <a class="code" href="classMiniSat_1_1Derivation.html#a5436a42caaab1bf37d9355c5bd43d251">Derivation::createProof</a>(<a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause) {
<a name="l00261"></a>00261   checkDerivation(clause);
<a name="l00262"></a>00262   <span class="comment">//  IF_DEBUG (checkDerivation(clause));</span>
<a name="l00263"></a>00263 
<a name="l00264"></a>00264   <span class="comment">// find all relevant clauses</span>
<a name="l00265"></a>00265 
<a name="l00266"></a>00266   <span class="comment">// - relevant: set clauses used in derivation</span>
<a name="l00267"></a>00267   <span class="comment">// - regress: relevant clauses whose antecedents have to be checked</span>
<a name="l00268"></a>00268   std::set&lt;int&gt; relevant;
<a name="l00269"></a>00269   std::set&lt;int&gt; regress;
<a name="l00270"></a>00270   regress.insert(clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>());
<a name="l00271"></a>00271   <span class="keywordflow">while</span> (!regress.empty()) {
<a name="l00272"></a>00272     <span class="comment">// pick next clause to derive - start from bottom, i.e. latest derived clause</span>
<a name="l00273"></a>00273     <span class="keywordtype">int</span> clauseID = *(regress.rbegin());
<a name="l00274"></a>00274     regress.erase(clauseID);
<a name="l00275"></a>00275     relevant.insert(clauseID);
<a name="l00276"></a>00276 
<a name="l00277"></a>00277     <span class="comment">// process antecedents</span>
<a name="l00278"></a>00278     <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TInferences::const_iterator</a> iter = d_inferences.find(clauseID);
<a name="l00279"></a>00279     <span class="comment">// input clause</span>
<a name="l00280"></a>00280     <span class="keywordflow">if</span> (iter != d_inferences.end()) {
<a name="l00281"></a>00281       <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = iter-&gt;second;
<a name="l00282"></a>00282       regress.insert(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>());
<a name="l00283"></a>00283       <span class="keyword">const</span> <a class="code" href="classMiniSat_1_1Inference.html#a0eef845f209a9bc406fe887c34f82553">Inference::TSteps</a>&amp; steps = inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a4111b13d1401b38cbe749357793883fa">getSteps</a>();
<a name="l00284"></a>00284       <span class="keywordflow">for</span> (Inference::TSteps::const_iterator step = steps.begin(); step != steps.end(); ++step) {
<a name="l00285"></a>00285   regress.insert(step-&gt;second);
<a name="l00286"></a>00286       }
<a name="l00287"></a>00287     }
<a name="l00288"></a>00288   }
<a name="l00289"></a>00289 
<a name="l00290"></a>00290   <span class="comment">// create proof</span>
<a name="l00291"></a>00291   <a class="code" href="classSAT_1_1SatProof.html">SAT::SatProof</a>* proof = <span class="keyword">new</span> <a class="code" href="classSAT_1_1SatProof.html">SAT::SatProof</a>();
<a name="l00292"></a>00292   <a class="code" href="classHash_1_1hash__map.html">std::hash_map&lt;int, SAT::SatProofNode*&gt;</a> proofNodes;
<a name="l00293"></a>00293 
<a name="l00294"></a>00294   <span class="keywordflow">for</span> (std::set&lt;int&gt;::iterator i = relevant.begin(); i != relevant.end(); ++i) {
<a name="l00295"></a>00295     <span class="keywordtype">int</span> clauseID = *i;
<a name="l00296"></a>00296     <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause = d_clauses.find(clauseID)-&gt;second;
<a name="l00297"></a>00297 
<a name="l00298"></a>00298     <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = NULL;
<a name="l00299"></a>00299     <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TInferences::const_iterator</a> j = d_inferences.find(clauseID);
<a name="l00300"></a>00300     <span class="keywordflow">if</span> (j == d_inferences.end()) {
<a name="l00301"></a>00301       <span class="comment">/*</span>
<a name="l00302"></a>00302 <span class="comment">&lt;&lt;&lt;&lt;&lt;&lt;&lt; minisat_derivation.cpp</span>
<a name="l00303"></a>00303 <span class="comment">      FatalAssert(clause-&gt;getCvcClause() != NULL, &quot;createProof: leaf without clause&quot;);</span>
<a name="l00304"></a>00304 <span class="comment">      FatalAssert(clause-&gt;getCvcClause() != NULL, &quot;createProof: leaf without clause&quot;);</span>
<a name="l00305"></a>00305 <span class="comment">      proofNodes[clause-&gt;id()] = proof-&gt;registerLeaf(clause-&gt;getCvcClause());</span>
<a name="l00306"></a>00306 <span class="comment">      //      cout&lt;&lt;&quot;cluase with :&quot;  &lt;&lt; clause-&gt;id() &lt;&lt; &quot; ---&gt; &quot; ;</span>
<a name="l00307"></a>00307 <span class="comment">      //      clause-&gt;getCvcClause()-&gt;print();</span>
<a name="l00308"></a>00308 <span class="comment">      //      cout &lt;&lt; endl;</span>
<a name="l00309"></a>00309 <span class="comment">=======</span>
<a name="l00310"></a>00310 <span class="comment">      */</span>
<a name="l00311"></a>00311       <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(!clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#a16f3db82b77ca7e28752602bf1dc8177">getTheorem</a>().<a class="code" href="classCVC3_1_1Theorem.html#afc6fdb0507eb3669e28d9be5ed0bd333">isNull</a>(), <span class="stringliteral">&quot;createProof: leaf without clause&quot;</span>);
<a name="l00312"></a>00312       proofNodes[clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>()] = proof-&gt;<a class="code" href="classSAT_1_1SatProof.html#a36554406554d1f6ea793c98b104bd071">registerLeaf</a>(clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#a16f3db82b77ca7e28752602bf1dc8177">getTheorem</a>());
<a name="l00313"></a>00313       <span class="comment">/*</span>
<a name="l00314"></a>00314 <span class="comment">&gt;&gt;&gt;&gt;&gt;&gt;&gt; 1.9</span>
<a name="l00315"></a>00315 <span class="comment">      */</span>
<a name="l00316"></a>00316     }
<a name="l00317"></a>00317 
<a name="l00318"></a>00318     <span class="keywordflow">else</span> {
<a name="l00319"></a>00319       inference = j-&gt;second;
<a name="l00320"></a>00320       <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(proofNodes.<a class="code" href="classHash_1_1hash__map.html#a48feee7c5690c9cd9ba1b0817ca3ae9f" title="status">contains</a>(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>()), <span class="stringliteral">&quot;createProof: contains inference start&quot;</span>);
<a name="l00321"></a>00321       <a class="code" href="classSAT_1_1SatProofNode.html">SAT::SatProofNode</a>* <a class="code" href="namespaceMiniSat.html#ad93cb56673487974071ed3b75bf4ea83">left</a> = proofNodes.<a class="code" href="classHash_1_1hash__map.html#af3317f9087a35d09985b6513c45d2ab8" title="operations">find</a>(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>())-&gt;second;
<a name="l00322"></a>00322       <span class="keyword">const</span> <a class="code" href="classMiniSat_1_1Inference.html#a0eef845f209a9bc406fe887c34f82553">Inference::TSteps</a>&amp; steps = inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a4111b13d1401b38cbe749357793883fa">getSteps</a>();
<a name="l00323"></a>00323       <span class="keywordflow">for</span> (Inference::TSteps::const_iterator step = steps.begin(); step != steps.end(); ++step) {
<a name="l00324"></a>00324   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(proofNodes.<a class="code" href="classHash_1_1hash__map.html#a48feee7c5690c9cd9ba1b0817ca3ae9f" title="status">contains</a>(step-&gt;second), <span class="stringliteral">&quot;createProof: contains inference start&quot;</span>);
<a name="l00325"></a>00325   <a class="code" href="classSAT_1_1SatProofNode.html">SAT::SatProofNode</a>* <a class="code" href="namespaceMiniSat.html#a82558b7a36c52f5d3211d5d14bed99d4">right</a> = proofNodes.<a class="code" href="classHash_1_1hash__map.html#af3317f9087a35d09985b6513c45d2ab8" title="operations">find</a>(step-&gt;second)-&gt;second;
<a name="l00326"></a>00326   left = proof-&gt;<a class="code" href="classSAT_1_1SatProof.html#a95ddb594997f8a50a62b277f1db6c1aa">registerNode</a>(left, right, <a class="code" href="namespaceMiniSat.html#a72756c106b9bd53cf77c2aab214e7cf5">miniSatToCVC</a>(step-&gt;first));
<a name="l00327"></a>00327       }
<a name="l00328"></a>00328       proofNodes[clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>()] = <a class="code" href="namespaceMiniSat.html#ad93cb56673487974071ed3b75bf4ea83">left</a>;
<a name="l00329"></a>00329     }
<a name="l00330"></a>00330   }
<a name="l00331"></a>00331   proof-&gt;<a class="code" href="classSAT_1_1SatProof.html#a0eba2c0baf1019cef7b96b5af3e2aa5c">setRoot</a>(proofNodes[clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>()]);
<a name="l00332"></a>00332   <span class="keywordflow">return</span> proof;
<a name="l00333"></a>00333 }
<a name="l00334"></a>00334 
<a name="l00335"></a>00335 
<a name="l00336"></a><a class="code" href="classMiniSat_1_1Derivation.html#aec406575f21e97084cffa7c05b566833">00336</a> <span class="keywordtype">void</span> <a class="code" href="classMiniSat_1_1Derivation.html#aec406575f21e97084cffa7c05b566833">Derivation::printDerivation</a>() {
<a name="l00337"></a>00337   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_emptyClause != NULL, <span class="stringliteral">&quot;MiniSat::Derivation:printDerivation: no empty clause&quot;</span>);
<a name="l00338"></a>00338   <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(d_emptyClause-&gt;size() == 0,
<a name="l00339"></a>00339         <span class="stringliteral">&quot;MiniSat::Derivation:printDerivation: empty clause is not empty&quot;</span>);
<a name="l00340"></a>00340   printDerivation(d_emptyClause);
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342 
<a name="l00343"></a><a class="code" href="classMiniSat_1_1Derivation.html#a8bb228e6baaead5ff5122a65fa64b123">00343</a> <span class="keywordtype">void</span> <a class="code" href="classMiniSat_1_1Derivation.html#aec406575f21e97084cffa7c05b566833">Derivation::printDerivation</a>(<a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause) {
<a name="l00344"></a>00344   <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a> (checkDerivation(clause));
<a name="l00345"></a>00345 
<a name="l00346"></a>00346   <span class="comment">// find all relevant clauses</span>
<a name="l00347"></a>00347 
<a name="l00348"></a>00348   <span class="comment">// - relevant: set clauses used in derivation</span>
<a name="l00349"></a>00349   <span class="comment">// - regress: relevant clauses whose antecedents have to be checked</span>
<a name="l00350"></a>00350   std::set&lt;int&gt; relevant;
<a name="l00351"></a>00351   std::set&lt;int&gt; regress;
<a name="l00352"></a>00352 
<a name="l00353"></a>00353   regress.insert(clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>());
<a name="l00354"></a>00354   <span class="keywordflow">while</span> (!regress.empty()) {
<a name="l00355"></a>00355     <span class="comment">// pick next clause to derive - start from bottom, i.e. latest derived clause</span>
<a name="l00356"></a>00356     <span class="keywordtype">int</span> clauseID = *(regress.rbegin());
<a name="l00357"></a>00357     regress.erase(clauseID);
<a name="l00358"></a>00358 
<a name="l00359"></a>00359     <span class="comment">// move to clauses relevant for the derivation</span>
<a name="l00360"></a>00360     relevant.insert(clauseID);
<a name="l00361"></a>00361 
<a name="l00362"></a>00362     <span class="comment">// process antecedents</span>
<a name="l00363"></a>00363     <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TInferences::const_iterator</a> iter = d_inferences.find(clauseID);
<a name="l00364"></a>00364     <span class="comment">// input clause</span>
<a name="l00365"></a>00365     <span class="keywordflow">if</span> (iter != d_inferences.end()) {
<a name="l00366"></a>00366       <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = iter-&gt;second;
<a name="l00367"></a>00367       regress.insert(inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a932d4071d9f794757ad9db27cb3fd1a3">getStart</a>());
<a name="l00368"></a>00368       <span class="keyword">const</span> <a class="code" href="classMiniSat_1_1Inference.html#a0eef845f209a9bc406fe887c34f82553">Inference::TSteps</a>&amp; steps = inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#a4111b13d1401b38cbe749357793883fa">getSteps</a>();
<a name="l00369"></a>00369       <span class="keywordflow">for</span> (Inference::TSteps::const_iterator step = steps.begin(); step != steps.end(); ++step) {
<a name="l00370"></a>00370   regress.insert(step-&gt;second);
<a name="l00371"></a>00371       }
<a name="l00372"></a>00372     }
<a name="l00373"></a>00373   }
<a name="l00374"></a>00374 
<a name="l00375"></a>00375 
<a name="l00376"></a>00376   <span class="comment">// print proof</span>
<a name="l00377"></a>00377   <span class="keywordflow">for</span> (std::set&lt;int&gt;::iterator i = relevant.begin(); i != relevant.end(); ++i) {
<a name="l00378"></a>00378     <span class="keywordtype">int</span> clauseID = *i;
<a name="l00379"></a>00379     <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause = d_clauses.find(clauseID)-&gt;second;
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     <a class="code" href="classMiniSat_1_1Inference.html">Inference</a>* inference = NULL;
<a name="l00382"></a>00382     <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TInferences::const_iterator</a> j = d_inferences.find(clauseID);
<a name="l00383"></a>00383     <span class="keywordflow">if</span> (j != d_inferences.end()) {
<a name="l00384"></a>00384       inference = j-&gt;second;
<a name="l00385"></a>00385     }
<a name="l00386"></a>00386 
<a name="l00387"></a>00387     <span class="comment">// ID D : L1 ... Ln : C1 K1 C2 K2 ... Cm</span>
<a name="l00388"></a>00388     cout &lt;&lt; clauseID;
<a name="l00389"></a>00389     <span class="comment">// input clause or derived clause?</span>
<a name="l00390"></a>00390     <span class="keywordflow">if</span> (d_inputClauses.contains(clauseID)) {
<a name="l00391"></a>00391       cout &lt;&lt; <span class="stringliteral">&quot; I &quot;</span>;
<a name="l00392"></a>00392     } <span class="keywordflow">else</span> {
<a name="l00393"></a>00393       cout &lt;&lt; <span class="stringliteral">&quot; D &quot;</span>;
<a name="l00394"></a>00394     }
<a name="l00395"></a>00395     cout &lt;&lt; <span class="stringliteral">&quot;: &quot;</span> &lt;&lt; clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#a8c3dce1547e9734868eef94f91f978e1">toString</a>() &lt;&lt; <span class="stringliteral">&quot; : &quot;</span>;
<a name="l00396"></a>00396     <span class="keywordflow">if</span> (inference != NULL) cout &lt;&lt; inference-&gt;<a class="code" href="classMiniSat_1_1Inference.html#aacd9c375bc7b8b0d87a15bcd9b5d35ce">toString</a>();
<a name="l00397"></a>00397     cout &lt;&lt; <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>;    
<a name="l00398"></a>00398   }
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400 
<a name="l00401"></a>00401 
<a name="l00402"></a><a class="code" href="classMiniSat_1_1Derivation.html#a9b35e97fb7ff5de171eeb68bfe4dda6b">00402</a> <span class="keywordtype">void</span> <a class="code" href="group__ExprStream__Manip.html#ga2a0348c6d3f94f2f8febc6dd0a9c3218" title="Set the indentation to the current position.">Derivation::push</a>(<span class="keywordtype">int</span> clauseID) {
<a name="l00403"></a>00403   <span class="comment">//  cout &lt;&lt; &quot;derivation push: &quot; &lt;&lt; clauseID &lt;&lt; endl;</span>
<a name="l00404"></a>00404 }
<a name="l00405"></a>00405 
<a name="l00406"></a><a class="code" href="classMiniSat_1_1Derivation.html#af3782033a2412734e9a018877f71ce5d">00406</a> <span class="keywordtype">void</span> <a class="code" href="group__ExprStream__Manip.html#gaddb050a787be87116afc51791293d3be" title="Restore the indentation.">Derivation::pop</a>(<span class="keywordtype">int</span> clauseID) {
<a name="l00407"></a>00407   <span class="comment">//  cout &lt;&lt; &quot;derivation pop: &quot; &lt;&lt; clauseID &lt;&lt; endl;</span>
<a name="l00408"></a>00408   <span class="comment">// remove all popped clauses</span>
<a name="l00409"></a>00409   <a class="code" href="classHash_1_1hash__map.html#a34789fb591a84314e78bd17b69aa6065">TClauses::const_iterator</a> i = d_clauses.begin();
<a name="l00410"></a>00410   <span class="keywordflow">while</span> (i != d_clauses.end()) {
<a name="l00411"></a>00411     <a class="code" href="classMiniSat_1_1Clause.html">Clause</a>* clause = (*i).second;
<a name="l00412"></a>00412     <span class="keywordflow">if</span> (
<a name="l00413"></a>00413   <span class="comment">// Warning: clause removal needs to be done</span>
<a name="l00414"></a>00414   <span class="comment">// exactly the same way in minisat_solver!!!</span>
<a name="l00415"></a>00415 
<a name="l00416"></a>00416   <span class="comment">// remove theory lemmas</span>
<a name="l00417"></a>00417   <span class="comment">// :TODO: can&#39;t do that: kept lemmas might depend on them </span>
<a name="l00418"></a>00418   <span class="comment">//  (!clause-&gt;learnt() &amp;&amp; clause-&gt;pushID() &lt; 0)</span>
<a name="l00419"></a>00419   <span class="comment">//  ||</span>
<a name="l00420"></a>00420   <span class="comment">// remove clauses added after the last push</span>
<a name="l00421"></a>00421   clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#ad5cd6daece979cb23f3c52ee0df63a0b">pushID</a>() &gt; clauseID) {
<a name="l00422"></a>00422       <span class="keywordtype">int</span> <span class="keywordtype">id</span> = clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#aeb8881da1f982f5bc58bac190ab2f2a4">id</a>();
<a name="l00423"></a>00423       <span class="comment">//      cout &lt;&lt; &quot;derivation pop now: &quot; &lt;&lt; id &lt;&lt; endl;</span>
<a name="l00424"></a>00424       d_inputClauses.erase(<span class="keywordtype">id</span>);
<a name="l00425"></a>00425       d_inferences.erase(<span class="keywordtype">id</span>);
<a name="l00426"></a>00426 
<a name="l00427"></a>00427       <span class="keywordflow">if</span> (clause-&gt;<a class="code" href="classMiniSat_1_1Clause.html#adf5aa50a639b4b5bb71e5ea76d45b8e2">size</a>() == 1) {
<a name="l00428"></a>00428   <span class="keywordtype">int</span> index = (*clause)[0].index();
<a name="l00429"></a>00429   <span class="keywordflow">if</span> (d_unitClauses.contains(index) &amp;&amp; d_unitClauses[index] == clause) {
<a name="l00430"></a>00430     d_unitClauses.erase(index);
<a name="l00431"></a>00431     <a class="code" href="debug_8h.html#a2637b2fffa22e3c9fad40cda8fcc3bce" title="If something goes horribly wrong, print a message and abort immediately with exit(1).">FatalAssert</a>(!d_unitClauses.contains(index), <span class="stringliteral">&quot;AHA&quot;</span>);
<a name="l00432"></a>00432   }
<a name="l00433"></a>00433       }
<a name="l00434"></a>00434 
<a name="l00435"></a>00435       i = d_clauses.erase(i);
<a name="l00436"></a>00436     }
<a name="l00437"></a>00437     <span class="keywordflow">else</span> {
<a name="l00438"></a>00438       ++i;
<a name="l00439"></a>00439     }
<a name="l00440"></a>00440   }
<a name="l00441"></a>00441 
<a name="l00442"></a>00442   <span class="comment">// undo conflicting clause</span>
<a name="l00443"></a>00443   <span class="keywordflow">if</span> (d_emptyClause != NULL &amp;&amp; d_emptyClause-&gt;pushID() &gt; clauseID)
<a name="l00444"></a>00444     d_emptyClause = NULL;
<a name="l00445"></a>00445 
<a name="l00446"></a>00446   <span class="comment">// delete popped and removed clauses</span>
<a name="l00447"></a>00447   std::deque&lt;Clause*&gt;::iterator j = d_removedClauses.begin();
<a name="l00448"></a>00448   <span class="keywordflow">while</span> (j != d_removedClauses.end()) {
<a name="l00449"></a>00449     <span class="keywordflow">if</span> ((*j)-&gt;pushID() &gt; clauseID) {
<a name="l00450"></a>00450       <a class="code" href="namespaceMiniSat.html#acbe7b3fac8ab3909327207b0fea1f4d8">xfree</a>(*j);
<a name="l00451"></a>00451       j = d_removedClauses.erase(j);
<a name="l00452"></a>00452     } <span class="keywordflow">else</span> {
<a name="l00453"></a>00453       ++j;
<a name="l00454"></a>00454     }
<a name="l00455"></a>00455   }
<a name="l00456"></a>00456 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Sep 7 2011 for CVC3 by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>