Sophie

Sophie

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

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: expr_transform.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">expr_transform.cpp</div>  </div>
</div>
<div class="contents">
<a href="expr__transform_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 expr_transform.cpp</span>
<a name="l00004"></a>00004 <span class="comment"> * </span>
<a name="l00005"></a>00005 <span class="comment"> * Author: Ying Hu, Clark Barrett</span>
<a name="l00006"></a>00006 <span class="comment"> * </span>
<a name="l00007"></a>00007 <span class="comment"> * Created: Jun 05 2003</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * &lt;hr&gt;</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span>
<a name="l00012"></a>00012 <span class="comment"> * and its documentation for any purpose is hereby granted without</span>
<a name="l00013"></a>00013 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span>
<a name="l00014"></a>00014 <span class="comment"> * LICENSE file provided with this distribution.</span>
<a name="l00015"></a>00015 <span class="comment"> * </span>
<a name="l00016"></a>00016 <span class="comment"> * &lt;hr&gt;</span>
<a name="l00017"></a>00017 <span class="comment"> * </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="expr__transform_8h.html" title="Generally Useful Expression Transformations.">expr_transform.h</a>&quot;</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include &quot;<a class="code" href="theory__core_8h.html">theory_core.h</a>&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &quot;<a class="code" href="theory__arith_8h.html">theory_arith.h</a>&quot;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &quot;<a class="code" href="command__line__flags_8h.html">command_line_flags.h</a>&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &quot;<a class="code" href="core__proof__rules_8h.html" title="Proof rules used by theory_core.">core_proof_rules.h</a>&quot;</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;set&gt;</span>
<a name="l00028"></a>00028 
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="keyword">using namespace </span>std;
<a name="l00031"></a>00031 <span class="keyword">using namespace </span>CVC3;
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 
<a name="l00034"></a><a class="code" href="classCVC3_1_1ExprTransform.html#a7bf5ddc9291a65cc5fa55af9f3a7f338">00034</a> ExprTransform::ExprTransform(<a class="code" href="classCVC3_1_1TheoryCore.html" title="This theory handles the built-in logical connectives plus equality. It also handles the registration ...">TheoryCore</a>* core)
<a name="l00035"></a>00035   : d_core(core)
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037   <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a> = <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1Theory.html#a50802b148e8192178cf790e6c45ddff3" title="Get a pointer to common proof rules.">getCommonRules</a>();  
<a name="l00038"></a>00038   <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a> = <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a261880d3c6b9b852de5e1d146b9e1731">getCoreRules</a>();
<a name="l00039"></a>00039 }
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4">00042</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">ExprTransform::smartSimplify</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e, <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;bool&gt;</a>&amp; cache)
<a name="l00043"></a>00043 {
<a name="l00044"></a>00044   <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;bool&gt;::iterator</a> it;
<a name="l00045"></a>00045   vector&lt;Expr&gt; operatorStack;
<a name="l00046"></a>00046   vector&lt;int&gt; childStack;
<a name="l00047"></a>00047   <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e2;
<a name="l00048"></a>00048 
<a name="l00049"></a>00049   operatorStack.push_back(e);
<a name="l00050"></a>00050   childStack.push_back(0);
<a name="l00051"></a>00051 
<a name="l00052"></a>00052   <span class="keywordflow">while</span> (!operatorStack.empty()) {
<a name="l00053"></a>00053     <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(operatorStack.size() == childStack.size(), <span class="stringliteral">&quot;Invariant violated&quot;</span>);
<a name="l00054"></a>00054     <span class="keywordflow">if</span> (childStack.back() &lt; operatorStack.back().arity()) {
<a name="l00055"></a>00055       e2 = operatorStack.back()[childStack.back()++];
<a name="l00056"></a>00056       it = cache.<a class="code" href="classCVC3_1_1ExprMap.html#ae50ab1874dd63b575553e7db769abe28">find</a>(e2);
<a name="l00057"></a>00057       <span class="keywordflow">if</span> (it != cache.<a class="code" href="classCVC3_1_1ExprMap.html#a283ae6c44308cbdda0d82da5a16e52c8">end</a>() || e2.<a class="code" href="group__ExprPkg.html#ga4dc94c33ae308ff8d9d004f49df8f42b">hasFind</a>() ||
<a name="l00058"></a>00058           e2.<a class="code" href="group__ExprPkg.html#ga99348741c5062f8c8e62962b787a73fd" title="Return true if there is a valid cached value for calling simplify on this Expr.">validSimpCache</a>() || e2.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>() == 0) <span class="keywordflow">continue</span>;
<a name="l00059"></a>00059       <span class="keywordflow">if</span> (operatorStack.size() &gt;= 5000) {
<a name="l00060"></a>00060         <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">smartSimplify</a>(e2, cache);
<a name="l00061"></a>00061         cache[e2] = <span class="keyword">true</span>;
<a name="l00062"></a>00062       }
<a name="l00063"></a>00063       <span class="keywordflow">else</span> {
<a name="l00064"></a>00064         operatorStack.push_back(e2);
<a name="l00065"></a>00065         childStack.push_back(0);
<a name="l00066"></a>00066       }
<a name="l00067"></a>00067     }
<a name="l00068"></a>00068     <span class="keywordflow">else</span> {
<a name="l00069"></a>00069       cache[operatorStack.back()] = <span class="keyword">true</span>;
<a name="l00070"></a>00070       operatorStack.pop_back();
<a name="l00071"></a>00071       childStack.pop_back();
<a name="l00072"></a>00072     }
<a name="l00073"></a>00073   }
<a name="l00074"></a>00074   <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(childStack.empty(), <span class="stringliteral">&quot;Invariant violated&quot;</span>);
<a name="l00075"></a>00075   <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a8a66da5ca687474a3a725448a3be8c41" title="Top-level simplifier.">simplify</a>(e);
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 
<a name="l00079"></a><a class="code" href="classCVC3_1_1ExprTransform.html#a39652560061ab1172040113d9dfa25f6">00079</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a39652560061ab1172040113d9dfa25f6">ExprTransform::preprocess</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e)
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081   <span class="comment">// Force simplifier to run</span>
<a name="l00082"></a>00082   <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1Theory.html#abc2e30308c9e1f3cf752cfe8d939df1e" title="Access to ExprManager.">getEM</a>()-&gt;<a class="code" href="group__EM__Priv.html#gaba358e1731ad9309e52e64eb9ce60755" title="Invalidate the simplifier&#39;s cache tag.">invalidateSimpCache</a>();
<a name="l00083"></a>00083   <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a2e0118c395ece4dfcfae018628e3b08b" title="Set the flag for the preprocessor.">setInPP</a>();
<a name="l00084"></a>00084   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00085"></a>00085 
<a name="l00086"></a>00086   <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a46b2792a5c24f95ccfc3fbfc0456b09f">getFlags</a>()[<span class="stringliteral">&quot;preprocess&quot;</span>].getBool()) {
<a name="l00087"></a>00087     <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a46b2792a5c24f95ccfc3fbfc0456b09f">getFlags</a>()[<span class="stringliteral">&quot;pp-pushneg&quot;</span>].getBool()) {
<a name="l00088"></a>00088       res = <a class="code" href="classCVC3_1_1ExprTransform.html#ab2757afee881751f99c86499400aef44" title="Push all negations down to the leaves.">pushNegation</a>(e);
<a name="l00089"></a>00089     }
<a name="l00090"></a>00090     <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;bool&gt;</a> cache;
<a name="l00091"></a>00091     <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a46b2792a5c24f95ccfc3fbfc0456b09f">getFlags</a>()[<span class="stringliteral">&quot;pp-bryant&quot;</span>].getBool()) {
<a name="l00092"></a>00092       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">smartSimplify</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(), cache));
<a name="l00093"></a>00093       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#a4d3d970b0c48c6f5973fc150a8a63d5b">dobryant</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>()));
<a name="l00094"></a>00094     }
<a name="l00095"></a>00095     <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a46b2792a5c24f95ccfc3fbfc0456b09f">getFlags</a>()[<span class="stringliteral">&quot;pp-care&quot;</span>].getBool()) {
<a name="l00096"></a>00096       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">smartSimplify</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(), cache));
<a name="l00097"></a>00097       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#ad18b9697ac34575a40f106e48cfef5b4" title="ITE simplification from Burch paper.">simplifyWithCare</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>()));
<a name="l00098"></a>00098     }
<a name="l00099"></a>00099     <span class="keywordtype">int</span> budget = 0;
<a name="l00100"></a>00100     <a class="code" href="classCVC3_1_1ExprTransform.html#a4228c9a8ee02c424c35bbd4bf3733cb8" title="Budget limit for newPP.">d_budgetLimit</a> = <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a46b2792a5c24f95ccfc3fbfc0456b09f">getFlags</a>()[<span class="stringliteral">&quot;pp-budget&quot;</span>].getInt();
<a name="l00101"></a>00101     <span class="keywordflow">while</span> (budget &lt; <a class="code" href="classCVC3_1_1ExprTransform.html#a4228c9a8ee02c424c35bbd4bf3733cb8" title="Budget limit for newPP.">d_budgetLimit</a>) {
<a name="l00102"></a>00102       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">smartSimplify</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(), cache));
<a name="l00103"></a>00103       <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> ppRes = <a class="code" href="classCVC3_1_1ExprTransform.html#a10909e40663567172bcbf45bad521055" title="new preprocessing code">newPP</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(), budget);
<a name="l00104"></a>00104       <span class="keywordflow">if</span> (ppRes.<a class="code" href="classCVC3_1_1Theorem.html#a16f074e60b9e076187efb478889d2c47">isRefl</a>()) <span class="keywordflow">break</span>;
<a name="l00105"></a>00105       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, ppRes);
<a name="l00106"></a>00106       <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a46b2792a5c24f95ccfc3fbfc0456b09f">getFlags</a>()[<span class="stringliteral">&quot;pp-care&quot;</span>].getBool()) {
<a name="l00107"></a>00107         res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">smartSimplify</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(), cache));
<a name="l00108"></a>00108         res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#ad18b9697ac34575a40f106e48cfef5b4" title="ITE simplification from Burch paper.">simplifyWithCare</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>()));
<a name="l00109"></a>00109       }
<a name="l00110"></a>00110     }
<a name="l00111"></a>00111     res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aafc3b026dbacc81d82b75a45b702b0a4" title="Simplification that avoids stack overflow.">smartSimplify</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(), cache));
<a name="l00112"></a>00112     <span class="comment">// Make sure this call is last as it cleans up theory core</span>
<a name="l00113"></a>00113     res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a052424ef27a5042f6321db9a8d41bf82" title="Call theory-specific preprocess routines.">callTheoryPreprocess</a>(res.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>()));
<a name="l00114"></a>00114   }
<a name="l00115"></a>00115   <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#aeeb68f961407ee80a9762a95e6998cf2">clearInPP</a>();
<a name="l00116"></a>00116   <span class="keywordflow">return</span> res;
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119 
<a name="l00120"></a><a class="code" href="classCVC3_1_1ExprTransform.html#aeb0a695de12cfa208e39f0b5a4bdeb56">00120</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a39652560061ab1172040113d9dfa25f6">ExprTransform::preprocess</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>&amp; thm)
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122   <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#aebbcd4a194e4fdca0bcd16143fb03a75">iffMP</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#a39652560061ab1172040113d9dfa25f6">preprocess</a>(thm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>()));
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 
<a name="l00126"></a>00126 <span class="comment">// We assume that the cache is initially empty</span>
<a name="l00127"></a><a class="code" href="classCVC3_1_1ExprTransform.html#ab2757afee881751f99c86499400aef44">00127</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#ab2757afee881751f99c86499400aef44" title="Push all negations down to the leaves.">ExprTransform::pushNegation</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e) {
<a name="l00128"></a>00128   <span class="keywordflow">if</span>(e.<a class="code" href="group__ExprPkg.html#gad527acb49daef3591b78c748746e7eef" title="Test if e is a term (as opposed to a predicate/formula)">isTerm</a>()) <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00129"></a>00129   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res(<a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(e, <span class="keyword">false</span>));
<a name="l00130"></a>00130   <a class="code" href="classCVC3_1_1ExprTransform.html#a986331240196633d2d639867eb2b2850" title="Cache for pushNegation()">d_pushNegCache</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a173c2cf4753189d956073d74c36c7c58">clear</a>();
<a name="l00131"></a>00131   <span class="keywordflow">return</span> res;
<a name="l00132"></a>00132 }
<a name="l00133"></a>00133 
<a name="l00134"></a>00134 
<a name="l00135"></a>00135 <span class="comment">// Recursively descend into the expression e, keeping track of whether</span>
<a name="l00136"></a>00136 <span class="comment">// we are under even or odd number of negations (&#39;neg&#39; == true means</span>
<a name="l00137"></a>00137 <span class="comment">// odd, the context is &quot;negative&quot;).</span>
<a name="l00138"></a>00138 
<a name="l00139"></a>00139 <span class="comment">// Produce a proof of e &lt;==&gt; e&#39; or !e &lt;==&gt; e&#39;, depending on whether</span>
<a name="l00140"></a>00140 <span class="comment">// neg is false or true, respectively.</span>
<a name="l00141"></a><a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd">00141</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">ExprTransform::pushNegationRec</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e, <span class="keywordtype">bool</span> neg) {
<a name="l00142"></a>00142   <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">&quot;pushNegation&quot;</span>, <span class="stringliteral">&quot;pushNegationRec(&quot;</span>, e,
<a name="l00143"></a>00143   <span class="stringliteral">&quot;, neg=&quot;</span> + <span class="keywordtype">string</span>(neg? <span class="stringliteral">&quot;true&quot;</span>:<span class="stringliteral">&quot;false&quot;</span>) + <span class="stringliteral">&quot;) {&quot;</span>);
<a name="l00144"></a>00144   <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(!e.<a class="code" href="group__ExprPkg.html#gad527acb49daef3591b78c748746e7eef" title="Test if e is a term (as opposed to a predicate/formula)">isTerm</a>(), <span class="stringliteral">&quot;pushNegationRec: not boolean e = &quot;</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>());
<a name="l00145"></a>00145   <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;Theorem&gt;::iterator</a> i = <a class="code" href="classCVC3_1_1ExprTransform.html#a986331240196633d2d639867eb2b2850" title="Cache for pushNegation()">d_pushNegCache</a>.<a class="code" href="classCVC3_1_1ExprMap.html#ae50ab1874dd63b575553e7db769abe28">find</a>(neg? !e : e);
<a name="l00146"></a>00146   <span class="keywordflow">if</span>(i != <a class="code" href="classCVC3_1_1ExprTransform.html#a986331240196633d2d639867eb2b2850" title="Cache for pushNegation()">d_pushNegCache</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a283ae6c44308cbdda0d82da5a16e52c8">end</a>()) { <span class="comment">// Found cached result</span>
<a name="l00147"></a>00147     <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">&quot;pushNegation&quot;</span>, <span class="stringliteral">&quot;pushNegationRec [cached] =&gt; &quot;</span>, (*i).second, <span class="stringliteral">&quot;}&quot;</span>);
<a name="l00148"></a>00148     <span class="keywordflow">return</span> (*i).second;
<a name="l00149"></a>00149   }
<a name="l00150"></a>00150   <span class="comment">// By default, do not rewrite</span>
<a name="l00151"></a>00151   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res(<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1Theory.html#af860f5d5e01423628c97c399606916ff" title="==&gt; a == a">reflexivityRule</a>((neg)? !e : e));
<a name="l00152"></a>00152   <span class="keywordflow">if</span>(neg) {
<a name="l00153"></a>00153     <span class="keywordflow">switch</span>(e.getKind()) {
<a name="l00154"></a>00154       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba1fad76919fba496de21807e2beec533d">TRUE_EXPR</a>: res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#ad55b11590196fbd73d24daa1d0d6eeb1" title="==&gt; NOT TRUE IFF FALSE">rewriteNotTrue</a>(!e); <span class="keywordflow">break</span>;
<a name="l00155"></a>00155       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba5f71bd33a6528411ae681f5291de1d82">FALSE_EXPR</a>: res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a30fa79637f4308e8e733015624293775" title="==&gt; NOT FALSE IFF TRUE">rewriteNotFalse</a>(!e); <span class="keywordflow">break</span>;
<a name="l00156"></a>00156       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a>: 
<a name="l00157"></a>00157         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a8a04ff29591a019d4d4cf073c0987316" title="==&gt; NOT NOT e IFF e, takes !!e">rewriteNotNot</a>(!e), <span class="keyword">false</span>);
<a name="l00158"></a>00158         <span class="keywordflow">break</span>;
<a name="l00159"></a>00159       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba865555c9f2e0458a7078486aa1b3254f">AND</a>:
<a name="l00160"></a>00160         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#ade3007866410b6565ee0ea1ff4c49a99" title="==&gt; NOT (AND e1 ... en) IFF (OR !e1 ... !en), takes (AND ...)">rewriteNotAnd</a>(!e), <span class="keyword">false</span>);
<a name="l00161"></a>00161         <span class="keywordflow">break</span>;
<a name="l00162"></a>00162       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba96727447c0ad447987df1c6415aef074">OR</a>: 
<a name="l00163"></a>00163         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#aea875ee7355ae6aab01b84c176dbccf6" title="==&gt; NOT (OR e1 ... en) IFF (AND !e1 ... !en), takes (OR ...)">rewriteNotOr</a>(!e), <span class="keyword">false</span>);
<a name="l00164"></a>00164         <span class="keywordflow">break</span>;
<a name="l00165"></a>00165       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7338bb59b9aa936104a6d2f631d4d8db">IMPLIES</a>: {
<a name="l00166"></a>00166         vector&lt;Theorem&gt; thms;
<a name="l00167"></a>00167         thms.push_back(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a3389cd795acc4cee4b591c1488293963" title="==&gt; IMPLIES(e1,e2) IFF OR(!e1, e2)">rewriteImplies</a>(e));
<a name="l00168"></a>00168         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>
<a name="l00169"></a>00169           (<a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a>, thms), <span class="keyword">true</span>);
<a name="l00170"></a>00170         <span class="keywordflow">break</span>;
<a name="l00171"></a>00171       }
<a name="l00172"></a>00172 <span class="comment">//       case IFF:</span>
<a name="l00173"></a>00173 <span class="comment">//  // Preserve equivalences to explore structural similarities</span>
<a name="l00174"></a>00174 <span class="comment">//  if(e[0].getKind() == e[1].getKind())</span>
<a name="l00175"></a>00175 <span class="comment">//    res = d_commonRules-&gt;reflexivityRule(!e);</span>
<a name="l00176"></a>00176 <span class="comment">//  else</span>
<a name="l00177"></a>00177 <span class="comment">//    res = pushNegationRec(d_commonRules-&gt;rewriteNotIff(!e), false);</span>
<a name="l00178"></a>00178 <span class="comment">//         break;</span>
<a name="l00179"></a>00179       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3a4cfaf3eae8eac1dc2fd27d9f0994dc">ITE</a>:
<a name="l00180"></a>00180         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#ac68942cf0c21011f9429042e279b4a54" title="==&gt; NOT ITE(a,b,c) IFF ITE(a,NOT b,NOT c)">rewriteNotIte</a>(!e), <span class="keyword">false</span>);
<a name="l00181"></a>00181         <span class="keywordflow">break</span>;
<a name="l00182"></a>00182 
<a name="l00183"></a>00183       <span class="comment">// Replace LETDECL with its definition.  The</span>
<a name="l00184"></a>00184       <span class="comment">// typechecker makes sure it&#39;s type-safe to do so.</span>
<a name="l00185"></a>00185       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9508dd8c8e7db280a5dacc19bd74d92d">LETDECL</a>: {
<a name="l00186"></a>00186         vector&lt;Theorem&gt; thms;
<a name="l00187"></a>00187         thms.push_back(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#acad687c3e6faa5709961210637c260da" title="Replace LETDECL with its definition.">rewriteLetDecl</a>(e));
<a name="l00188"></a>00188         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>
<a name="l00189"></a>00189           (<a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a>, thms), <span class="keyword">true</span>);
<a name="l00190"></a>00190         <span class="keywordflow">break</span>;
<a name="l00191"></a>00191       }
<a name="l00192"></a>00192       <span class="keywordflow">default</span>:
<a name="l00193"></a>00193         res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(!e);
<a name="l00194"></a>00194     } <span class="comment">// end of switch(e.getKind())</span>
<a name="l00195"></a>00195   } <span class="keywordflow">else</span> { <span class="comment">// if(!neg)</span>
<a name="l00196"></a>00196     <span class="keywordflow">switch</span>(e.getKind()) {
<a name="l00197"></a>00197       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a>: res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(e[0], <span class="keyword">true</span>); <span class="keywordflow">break</span>;
<a name="l00198"></a>00198       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba865555c9f2e0458a7078486aa1b3254f">AND</a>:
<a name="l00199"></a>00199       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba96727447c0ad447987df1c6415aef074">OR</a>:
<a name="l00200"></a>00200       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba527cb185631442655c4486d51522b5a7">IFF</a>:
<a name="l00201"></a>00201       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3a4cfaf3eae8eac1dc2fd27d9f0994dc">ITE</a>: {
<a name="l00202"></a>00202         <a class="code" href="classCVC3_1_1Op.html">Op</a> op = e.getOp();
<a name="l00203"></a>00203         vector&lt;Theorem&gt; thms;
<a name="l00204"></a>00204         <span class="keywordflow">for</span>(<a class="code" href="classCVC3_1_1Expr_1_1iterator.html">Expr::iterator</a> i=e.begin(), iend=e.end(); i!=iend; ++i)
<a name="l00205"></a>00205           thms.push_back(<a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(*i, <span class="keyword">false</span>));
<a name="l00206"></a>00206         res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(op, thms);
<a name="l00207"></a>00207         <span class="keywordflow">break</span>;
<a name="l00208"></a>00208       }
<a name="l00209"></a>00209       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7338bb59b9aa936104a6d2f631d4d8db">IMPLIES</a>:
<a name="l00210"></a>00210         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a3389cd795acc4cee4b591c1488293963" title="==&gt; IMPLIES(e1,e2) IFF OR(!e1, e2)">rewriteImplies</a>(e), <span class="keyword">false</span>);
<a name="l00211"></a>00211         <span class="keywordflow">break</span>;
<a name="l00212"></a>00212       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9508dd8c8e7db280a5dacc19bd74d92d">LETDECL</a>:
<a name="l00213"></a>00213         res = <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#acad687c3e6faa5709961210637c260da" title="Replace LETDECL with its definition.">rewriteLetDecl</a>(e), <span class="keyword">false</span>);
<a name="l00214"></a>00214         <span class="keywordflow">break</span>;
<a name="l00215"></a>00215       <span class="keywordflow">default</span>:
<a name="l00216"></a>00216         res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00217"></a>00217     } <span class="comment">// end of switch(e.getKind())</span>
<a name="l00218"></a>00218   }
<a name="l00219"></a>00219   <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">&quot;pushNegation&quot;</span>, <span class="stringliteral">&quot;pushNegationRec =&gt; &quot;</span>, res, <span class="stringliteral">&quot;}&quot;</span>);
<a name="l00220"></a>00220   <a class="code" href="classCVC3_1_1ExprTransform.html#a986331240196633d2d639867eb2b2850" title="Cache for pushNegation()">d_pushNegCache</a>[neg? !e : e] = res;
<a name="l00221"></a>00221   <span class="keywordflow">return</span> res;
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223 
<a name="l00224"></a>00224 
<a name="l00225"></a><a class="code" href="classCVC3_1_1ExprTransform.html#aa247d13841a682165edb357895d78aa3">00225</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">ExprTransform::pushNegationRec</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>&amp; thm, <span class="keywordtype">bool</span> neg) {
<a name="l00226"></a>00226   <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(thm.<a class="code" href="classCVC3_1_1Theorem.html#a362c1d70e03803d804bbe300e5f6dc87">isRewrite</a>(), <span class="stringliteral">&quot;pushNegationRec(Theorem): bad theorem: &quot;</span>
<a name="l00227"></a>00227         + thm.<a class="code" href="classCVC3_1_1Theorem.html#ac4b1c9570ffb9cc901627ef2abb9ff77">toString</a>());
<a name="l00228"></a>00228   <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e(thm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>());
<a name="l00229"></a>00229   <span class="keywordflow">if</span>(neg) {
<a name="l00230"></a>00230     <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(e.isNot(), 
<a name="l00231"></a>00231     <span class="stringliteral">&quot;pushNegationRec(Theorem, neg = true): bad Theorem: &quot;</span>
<a name="l00232"></a>00232     + thm.<a class="code" href="classCVC3_1_1Theorem.html#ac4b1c9570ffb9cc901627ef2abb9ff77">toString</a>());
<a name="l00233"></a>00233     e = e[0];
<a name="l00234"></a>00234   }
<a name="l00235"></a>00235   <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#a8a34a76b702e026c8285f18893da7dbd" title="Auxiliary recursive function for pushNegation().">pushNegationRec</a>(e, neg));
<a name="l00236"></a>00236 }
<a name="l00237"></a>00237 
<a name="l00238"></a>00238 
<a name="l00239"></a><a class="code" href="classCVC3_1_1ExprTransform.html#a5daaef4e405ec8c9bb7f6e6adbde27fa">00239</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a5daaef4e405ec8c9bb7f6e6adbde27fa" title="Push negation one level down. Takes &#39;e&#39; which is &#39;NOT e[0]&#39;.">ExprTransform::pushNegation1</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e) {
<a name="l00240"></a>00240   <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">&quot;pushNegation1&quot;</span>, <span class="stringliteral">&quot;pushNegation1(&quot;</span>, e, <span class="stringliteral">&quot;) {&quot;</span>);
<a name="l00241"></a>00241   <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(e.<a class="code" href="group__ExprPkg.html#ga1a898858ccadce833df5a294c7740f11">isNot</a>(), <span class="stringliteral">&quot;pushNegation1(&quot;</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()+<span class="stringliteral">&quot;)&quot;</span>);
<a name="l00242"></a>00242   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res;
<a name="l00243"></a>00243   <span class="keywordflow">switch</span>(e[0].getKind()) {
<a name="l00244"></a>00244     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba1fad76919fba496de21807e2beec533d">TRUE_EXPR</a>: res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#ad55b11590196fbd73d24daa1d0d6eeb1" title="==&gt; NOT TRUE IFF FALSE">rewriteNotTrue</a>(e); <span class="keywordflow">break</span>;
<a name="l00245"></a>00245     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba5f71bd33a6528411ae681f5291de1d82">FALSE_EXPR</a>: res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a30fa79637f4308e8e733015624293775" title="==&gt; NOT FALSE IFF TRUE">rewriteNotFalse</a>(e); <span class="keywordflow">break</span>;
<a name="l00246"></a>00246     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a>: 
<a name="l00247"></a>00247       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a8a04ff29591a019d4d4cf073c0987316" title="==&gt; NOT NOT e IFF e, takes !!e">rewriteNotNot</a>(e);
<a name="l00248"></a>00248       <span class="keywordflow">break</span>;
<a name="l00249"></a>00249     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba865555c9f2e0458a7078486aa1b3254f">AND</a>:
<a name="l00250"></a>00250       res = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#ade3007866410b6565ee0ea1ff4c49a99" title="==&gt; NOT (AND e1 ... en) IFF (OR !e1 ... !en), takes (AND ...)">rewriteNotAnd</a>(e);
<a name="l00251"></a>00251       <span class="keywordflow">break</span>;
<a name="l00252"></a>00252     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba96727447c0ad447987df1c6415aef074">OR</a>: 
<a name="l00253"></a>00253       res = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#aea875ee7355ae6aab01b84c176dbccf6" title="==&gt; NOT (OR e1 ... en) IFF (AND !e1 ... !en), takes (OR ...)">rewriteNotOr</a>(e);
<a name="l00254"></a>00254       <span class="keywordflow">break</span>;
<a name="l00255"></a>00255     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7338bb59b9aa936104a6d2f631d4d8db">IMPLIES</a>: {
<a name="l00256"></a>00256       vector&lt;Theorem&gt; thms;
<a name="l00257"></a>00257       thms.push_back(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a3389cd795acc4cee4b591c1488293963" title="==&gt; IMPLIES(e1,e2) IFF OR(!e1, e2)">rewriteImplies</a>(e[0]));
<a name="l00258"></a>00258       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(e.<a class="code" href="group__ExprPkg.html#gace479f04faca399219496195152f7806" title="Get operator from expression.">getOp</a>(), thms);
<a name="l00259"></a>00259       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#aea875ee7355ae6aab01b84c176dbccf6" title="==&gt; NOT (OR e1 ... en) IFF (AND !e1 ... !en), takes (OR ...)">rewriteNotOr</a>(res.getRHS()));
<a name="l00260"></a>00260       <span class="keywordflow">break</span>;
<a name="l00261"></a>00261     }
<a name="l00262"></a>00262     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3a4cfaf3eae8eac1dc2fd27d9f0994dc">ITE</a>:
<a name="l00263"></a>00263       res = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#ac68942cf0c21011f9429042e279b4a54" title="==&gt; NOT ITE(a,b,c) IFF ITE(a,NOT b,NOT c)">rewriteNotIte</a>(e);
<a name="l00264"></a>00264       <span class="keywordflow">break</span>;
<a name="l00265"></a>00265       <span class="comment">// Replace LETDECL with its definition.  The</span>
<a name="l00266"></a>00266       <span class="comment">// typechecker makes sure it&#39;s type-safe to do so.</span>
<a name="l00267"></a>00267     <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9508dd8c8e7db280a5dacc19bd74d92d">LETDECL</a>: {
<a name="l00268"></a>00268       vector&lt;Theorem&gt; thms;
<a name="l00269"></a>00269       thms.push_back(<a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#acad687c3e6faa5709961210637c260da" title="Replace LETDECL with its definition.">rewriteLetDecl</a>(e[0]));
<a name="l00270"></a>00270       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(e.<a class="code" href="group__ExprPkg.html#gace479f04faca399219496195152f7806" title="Get operator from expression.">getOp</a>(), thms);
<a name="l00271"></a>00271       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#a5daaef4e405ec8c9bb7f6e6adbde27fa" title="Push negation one level down. Takes &#39;e&#39; which is &#39;NOT e[0]&#39;.">pushNegation1</a>(res.getRHS()));
<a name="l00272"></a>00272       <span class="keywordflow">break</span>;
<a name="l00273"></a>00273     }
<a name="l00274"></a>00274     <span class="keywordflow">default</span>:
<a name="l00275"></a>00275       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00276"></a>00276   }
<a name="l00277"></a>00277   <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba7fa27e82c6c4f69434225ed81e5d151e">TRACE</a>(<span class="stringliteral">&quot;pushNegation1&quot;</span>, <span class="stringliteral">&quot;pushNegation1 =&gt; &quot;</span>, res.getExpr(), <span class="stringliteral">&quot; }&quot;</span>);
<a name="l00278"></a>00278   <span class="keywordflow">return</span> res;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 
<a name="l00281"></a>00281 
<a name="l00282"></a><a class="code" href="classCVC3_1_1ExprTransform.html#a10909e40663567172bcbf45bad521055">00282</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a10909e40663567172bcbf45bad521055" title="new preprocessing code">ExprTransform::newPP</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e, <span class="keywordtype">int</span>&amp; budget)
<a name="l00283"></a>00283 {
<a name="l00284"></a>00284   <span class="keywordflow">if</span> (!e.<a class="code" href="group__ExprPkg.html#ga42929221eb172250697b72c28af6de07" title="Get the type. Recursively compute if necessary.">getType</a>().<a class="code" href="classCVC3_1_1Type.html#a38bba404056eadf3c283a67ab2347e02">isBool</a>()) <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00285"></a>00285   <a class="code" href="classCVC3_1_1ExprTransform.html#a574575f8c65c604d6904c4654f2e48d6" title="Cache for newPP.">d_newPPCache</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a173c2cf4753189d956073d74c36c7c58">clear</a>();
<a name="l00286"></a>00286   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> thm = <a class="code" href="classCVC3_1_1ExprTransform.html#a5817a5d8a33b01904fa7e06aa91061bb" title="main new preprocessing code">newPPrec</a>(e, budget);
<a name="l00287"></a>00287   <span class="comment">//  cout &lt;&lt; &quot;budget = &quot; &lt;&lt; budget &lt;&lt; endl;</span>
<a name="l00288"></a>00288   <span class="keywordflow">if</span> (budget &gt; <a class="code" href="classCVC3_1_1ExprTransform.html#a4228c9a8ee02c424c35bbd4bf3733cb8" title="Budget limit for newPP.">d_budgetLimit</a> ||
<a name="l00289"></a>00289       thm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>().<a class="code" href="group__ExprPkg.html#gad2f1fb7c447bcc3a7d352fd24a8f265a">getSize</a>() &gt; 2 * e.<a class="code" href="group__ExprPkg.html#gad2f1fb7c447bcc3a7d352fd24a8f265a">getSize</a>()) {
<a name="l00290"></a>00290     <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00291"></a>00291   }
<a name="l00292"></a>00292   <span class="keywordflow">return</span> thm;
<a name="l00293"></a>00293 }
<a name="l00294"></a>00294 
<a name="l00295"></a>00295 
<a name="l00296"></a><a class="code" href="classCVC3_1_1ExprTransform.html#ac16db941bec1cf4ecb888a8fc3f1a0e9">00296</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#ac16db941bec1cf4ecb888a8fc3f1a0e9" title="Helper for newPP.">ExprTransform::specialSimplify</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e, <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;</a>&amp; cache)
<a name="l00297"></a>00297 {
<a name="l00298"></a>00298   <span class="keywordflow">if</span> (e.<a class="code" href="group__ExprPkg.html#ga48a9219339b394280550069ac7b0474f" title="Test if e is atomic.">isAtomic</a>()) <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00299"></a>00299 
<a name="l00300"></a>00300   <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;::iterator</a> it = cache.<a class="code" href="classCVC3_1_1ExprHashMap.html#aeffd58f05fbeb8f381ba2050adef7a2d">find</a>(e);
<a name="l00301"></a>00301   <span class="keywordflow">if</span> (it != cache.<a class="code" href="classCVC3_1_1ExprHashMap.html#a0ea2aa250fd1431c311d83f32862bba7">end</a>()) <span class="keywordflow">return</span> (*it).second;
<a name="l00302"></a>00302 
<a name="l00303"></a>00303   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> thm;
<a name="l00304"></a>00304   if (e.<a class="code" href="group__ExprPkg.html#ga42929221eb172250697b72c28af6de07" title="Get the type. Recursively compute if necessary.">getType</a>().<a class="code" href="classCVC3_1_1Type.html#a38bba404056eadf3c283a67ab2347e02">isBool</a>()) {
<a name="l00305"></a>00305     thm = <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a8a66da5ca687474a3a725448a3be8c41" title="Top-level simplifier.">simplify</a>(e);
<a name="l00306"></a>00306     <span class="keywordflow">if</span> (thm.getRHS().isBoolConst()) {
<a name="l00307"></a>00307       cache[e] = thm;
<a name="l00308"></a>00308       <span class="keywordflow">return</span> thm;
<a name="l00309"></a>00309     }
<a name="l00310"></a>00310   }
<a name="l00311"></a>00311 
<a name="l00312"></a>00312   thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00313"></a>00313 
<a name="l00314"></a>00314   vector&lt;Theorem&gt; newChildrenThm;
<a name="l00315"></a>00315   vector&lt;unsigned&gt; changed;
<a name="l00316"></a>00316   <span class="keywordtype">int</span> ar = e.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>();
<a name="l00317"></a>00317   <span class="keywordflow">for</span>(<span class="keywordtype">int</span> k = 0; k &lt; ar; ++k) {
<a name="l00318"></a>00318     <span class="comment">// Recursively process the kids</span>
<a name="l00319"></a>00319     <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> thm2 = <a class="code" href="classCVC3_1_1ExprTransform.html#ac16db941bec1cf4ecb888a8fc3f1a0e9" title="Helper for newPP.">specialSimplify</a>(e[k], cache);
<a name="l00320"></a>00320     <span class="keywordflow">if</span> (!thm2.<a class="code" href="classCVC3_1_1Theorem.html#a16f074e60b9e076187efb478889d2c47">isRefl</a>()) {
<a name="l00321"></a>00321       newChildrenThm.push_back(thm2);
<a name="l00322"></a>00322       changed.push_back(k);
<a name="l00323"></a>00323     }
<a name="l00324"></a>00324   }
<a name="l00325"></a>00325   <span class="keywordflow">if</span>(changed.size() &gt; 0) {
<a name="l00326"></a>00326     thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(e, changed, newChildrenThm);
<a name="l00327"></a>00327   }
<a name="l00328"></a>00328 
<a name="l00329"></a>00329   cache[e] = thm;
<a name="l00330"></a>00330   <span class="keywordflow">return</span> thm;
<a name="l00331"></a>00331 }
<a name="l00332"></a>00332 
<a name="l00333"></a>00333 
<a name="l00334"></a><a class="code" href="classCVC3_1_1ExprTransform.html#a5817a5d8a33b01904fa7e06aa91061bb">00334</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#a5817a5d8a33b01904fa7e06aa91061bb" title="main new preprocessing code">ExprTransform::newPPrec</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e, <span class="keywordtype">int</span>&amp; budget)
<a name="l00335"></a>00335 {
<a name="l00336"></a>00336   <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(e.<a class="code" href="group__ExprPkg.html#ga42929221eb172250697b72c28af6de07" title="Get the type. Recursively compute if necessary.">getType</a>().<a class="code" href="classCVC3_1_1Type.html#a38bba404056eadf3c283a67ab2347e02">isBool</a>(), <span class="stringliteral">&quot;Expected Boolean expression&quot;</span>);
<a name="l00337"></a>00337   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00338"></a>00338 
<a name="l00339"></a>00339   <span class="keywordflow">if</span> (!e.<a class="code" href="group__ExprPkg.html#gaf53e6a6f9dc01481d2cf94673c5505ce" title="Return whether Expr contains a non-bool type ITE as a sub-term.">containsTermITE</a>()) <span class="keywordflow">return</span> res;
<a name="l00340"></a>00340 
<a name="l00341"></a>00341   <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;Theorem&gt;::iterator</a> i = <a class="code" href="classCVC3_1_1ExprTransform.html#a574575f8c65c604d6904c4654f2e48d6" title="Cache for newPP.">d_newPPCache</a>.<a class="code" href="classCVC3_1_1ExprMap.html#ae50ab1874dd63b575553e7db769abe28">find</a>(e);
<a name="l00342"></a>00342   <span class="keywordflow">if</span> (i != <a class="code" href="classCVC3_1_1ExprTransform.html#a574575f8c65c604d6904c4654f2e48d6" title="Cache for newPP.">d_newPPCache</a>.<a class="code" href="classCVC3_1_1ExprMap.html#a283ae6c44308cbdda0d82da5a16e52c8">end</a>()) { <span class="comment">// Found cached result</span>
<a name="l00343"></a>00343     res = (*i).second;
<a name="l00344"></a>00344     <span class="keywordflow">return</span> res;
<a name="l00345"></a>00345   }
<a name="l00346"></a>00346 
<a name="l00347"></a>00347   <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> current = e;
<a name="l00348"></a>00348   <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> newExpr;
<a name="l00349"></a>00349   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> thm, thm2;
<a name="l00350"></a>00350 
<a name="l00351"></a>00351   <span class="keywordflow">do</span> {
<a name="l00352"></a>00352 
<a name="l00353"></a>00353     <span class="keywordflow">if</span> (budget &gt; <a class="code" href="classCVC3_1_1ExprTransform.html#a4228c9a8ee02c424c35bbd4bf3733cb8" title="Budget limit for newPP.">d_budgetLimit</a>) <span class="keywordflow">break</span>;
<a name="l00354"></a>00354 
<a name="l00355"></a>00355     ++budget;
<a name="l00356"></a>00356     <span class="comment">// Recursive case</span>
<a name="l00357"></a>00357     <span class="keywordflow">if</span> (!current.<a class="code" href="group__ExprPkg.html#gad8c63abfec9cc4a8319f3df1b47eee45" title="True iff expr is not a Bool connective.">isPropAtom</a>()) {
<a name="l00358"></a>00358       vector&lt;Theorem&gt; newChildrenThm;
<a name="l00359"></a>00359       vector&lt;unsigned&gt; changed;
<a name="l00360"></a>00360       <span class="keywordtype">int</span> ar = current.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>();
<a name="l00361"></a>00361       <span class="keywordflow">for</span>(<span class="keywordtype">int</span> k = 0; k &lt; ar; ++k) {
<a name="l00362"></a>00362         <span class="comment">// Recursively process the kids</span>
<a name="l00363"></a>00363         thm = <a class="code" href="classCVC3_1_1ExprTransform.html#a5817a5d8a33b01904fa7e06aa91061bb" title="main new preprocessing code">newPPrec</a>(current[k], budget);
<a name="l00364"></a>00364         <span class="keywordflow">if</span> (!thm.<a class="code" href="classCVC3_1_1Theorem.html#a16f074e60b9e076187efb478889d2c47">isRefl</a>()) {
<a name="l00365"></a>00365           newChildrenThm.push_back(thm);
<a name="l00366"></a>00366           changed.push_back(k);
<a name="l00367"></a>00367         }
<a name="l00368"></a>00368       }
<a name="l00369"></a>00369       <span class="keywordflow">if</span>(changed.size() &gt; 0) {
<a name="l00370"></a>00370         thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(current, changed, newChildrenThm));
<a name="l00371"></a>00371         newExpr = thm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>();
<a name="l00372"></a>00372         res = thm;
<a name="l00373"></a>00373       }
<a name="l00374"></a>00374       <span class="keywordflow">break</span>;
<a name="l00375"></a>00375     }
<a name="l00376"></a>00376 
<a name="l00377"></a>00377 <span class="comment">//     if (current.getSize() &gt; 1000) {</span>
<a name="l00378"></a>00378 <span class="comment">//       break;</span>
<a name="l00379"></a>00379 <span class="comment">//     }</span>
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     <span class="comment">// Contains Term ITEs</span>
<a name="l00382"></a>00382 
<a name="l00383"></a>00383     thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(res, <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a893a258d9f7d49acb5c8a8b5b8ec39b0">liftOneITE</a>(current));
<a name="l00384"></a>00384     newExpr = thm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>();
<a name="l00385"></a>00385 
<a name="l00386"></a>00386     <span class="keywordflow">if</span> ((newExpr[0].isLiteral() || newExpr[0].isAnd())) {
<a name="l00387"></a>00387       <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a9377f423f4fd59fdac396794363733a6">getCM</a>()-&gt;<a class="code" href="classCVC3_1_1ContextManager.html#a90e301927cc935d561b81761d4ab2ee8">push</a>();
<a name="l00388"></a>00388       <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#aecef2465eb761f7f112ddce77f93d081" title="Add a new assertion to the core from the user or a SAT solver. Do NOT use it in a decision procedure;...">addFact</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#ab4527c48e9f88d94d7ca076757a6f3ba">assumpRule</a>(newExpr[0]));
<a name="l00389"></a>00389       thm2 = <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a8a66da5ca687474a3a725448a3be8c41" title="Top-level simplifier.">simplify</a>(newExpr[1]);
<a name="l00390"></a>00390       thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a8117a95eed02c35936f988d1c9c2bdab" title="a |- b == d ==&gt; ITE(a, b, c) == ITE(a, d, c)">rewriteIteThen</a>(newExpr, thm2));
<a name="l00391"></a>00391       <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a9377f423f4fd59fdac396794363733a6">getCM</a>()-&gt;<a class="code" href="classCVC3_1_1ContextManager.html#ae74b114a270baff44940a8916d958e9c">pop</a>();
<a name="l00392"></a>00392 
<a name="l00393"></a>00393       <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a9377f423f4fd59fdac396794363733a6">getCM</a>()-&gt;<a class="code" href="classCVC3_1_1ContextManager.html#a90e301927cc935d561b81761d4ab2ee8">push</a>();
<a name="l00394"></a>00394       <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#aecef2465eb761f7f112ddce77f93d081" title="Add a new assertion to the core from the user or a SAT solver. Do NOT use it in a decision procedure;...">addFact</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#ab4527c48e9f88d94d7ca076757a6f3ba">assumpRule</a>(newExpr[0].<a class="code" href="group__ExprPkg.html#gab1ce461dc931af73bf04e88c8d37dcbc">negate</a>()));
<a name="l00395"></a>00395 
<a name="l00396"></a>00396       thm2 = <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a8a66da5ca687474a3a725448a3be8c41" title="Top-level simplifier.">simplify</a>(newExpr[2]);
<a name="l00397"></a>00397       newExpr = thm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>();
<a name="l00398"></a>00398       thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a7912f66f5be7e05b0c85f15596747be4" title="!a |- c == d ==&gt; ITE(a, b, c) == ITE(a, b, d)">rewriteIteElse</a>(newExpr, thm2));
<a name="l00399"></a>00399       <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a9377f423f4fd59fdac396794363733a6">getCM</a>()-&gt;<a class="code" href="classCVC3_1_1ContextManager.html#ae74b114a270baff44940a8916d958e9c">pop</a>();
<a name="l00400"></a>00400       newExpr = thm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>();
<a name="l00401"></a>00401     }
<a name="l00402"></a>00402     res = thm;
<a name="l00403"></a>00403     current = newExpr;
<a name="l00404"></a>00404 
<a name="l00405"></a>00405   } <span class="keywordflow">while</span> (current.<a class="code" href="group__ExprPkg.html#gaf53e6a6f9dc01481d2cf94673c5505ce" title="Return whether Expr contains a non-bool type ITE as a sub-term.">containsTermITE</a>());
<a name="l00406"></a>00406 
<a name="l00407"></a>00407   <a class="code" href="classCVC3_1_1ExprTransform.html#a574575f8c65c604d6904c4654f2e48d6" title="Cache for newPP.">d_newPPCache</a>[e] = res;
<a name="l00408"></a>00408   <span class="keywordflow">return</span> res;
<a name="l00409"></a>00409   
<a name="l00410"></a>00410 }
<a name="l00411"></a>00411 
<a name="l00412"></a>00412 
<a name="l00413"></a><a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9">00413</a> <span class="keywordtype">void</span> <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">ExprTransform::updateQueue</a>(<a class="code" href="classCVC3_1_1ExprMap.html">ExprMap</a>&lt;set&lt;Expr&gt;* &gt;&amp; queue,
<a name="l00414"></a>00414                                 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e,
<a name="l00415"></a>00415                                 <span class="keyword">const</span> set&lt;Expr&gt;&amp; careSet)
<a name="l00416"></a>00416 {
<a name="l00417"></a>00417   <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;set&lt;Expr&gt;</a>* &gt;::iterator it = queue.<a class="code" href="classCVC3_1_1ExprMap.html#ae50ab1874dd63b575553e7db769abe28">find</a>(e), iend = queue.end();
<a name="l00418"></a>00418 
<a name="l00419"></a>00419   <span class="keywordflow">if</span> (it != iend) {
<a name="l00420"></a>00420 
<a name="l00421"></a>00421     set&lt;Expr&gt;* cs2 = (*it).second;
<a name="l00422"></a>00422     set&lt;Expr&gt;* csNew = <span class="keyword">new</span> set&lt;Expr&gt;;
<a name="l00423"></a>00423     set_intersection(careSet.begin(), careSet.end(), cs2-&gt;begin(), cs2-&gt;end(),
<a name="l00424"></a>00424                      inserter(*csNew, csNew-&gt;begin()));
<a name="l00425"></a>00425     (*it).second = csNew;
<a name="l00426"></a>00426     <span class="keyword">delete</span> cs2;
<a name="l00427"></a>00427   }
<a name="l00428"></a>00428   <span class="keywordflow">else</span> {
<a name="l00429"></a>00429     queue[e] = <span class="keyword">new</span> set&lt;Expr&gt;(careSet);
<a name="l00430"></a>00430   }
<a name="l00431"></a>00431 }
<a name="l00432"></a>00432 
<a name="l00433"></a>00433 
<a name="l00434"></a><a class="code" href="classCVC3_1_1ExprTransform.html#ae1f3a46b2e09495bb5afe3ac46f23c2b">00434</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#ae1f3a46b2e09495bb5afe3ac46f23c2b" title="Helper for simplifyWithCare.">ExprTransform::substitute</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e,
<a name="l00435"></a>00435                                   <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;</a>&amp; substTable,
<a name="l00436"></a>00436                                   <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;</a>&amp; cache)
<a name="l00437"></a>00437 {
<a name="l00438"></a>00438   <span class="keywordflow">if</span> (e.<a class="code" href="group__ExprPkg.html#ga48a9219339b394280550069ac7b0474f" title="Test if e is atomic.">isAtomic</a>()) <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00439"></a>00439 
<a name="l00440"></a>00440   <span class="comment">// check cache</span>
<a name="l00441"></a>00441 
<a name="l00442"></a>00442   <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;::iterator</a> it = cache.<a class="code" href="classCVC3_1_1ExprHashMap.html#aeffd58f05fbeb8f381ba2050adef7a2d">find</a>(e), iend = cache.<a class="code" href="classCVC3_1_1ExprHashMap.html#a0ea2aa250fd1431c311d83f32862bba7">end</a>();
<a name="l00443"></a>00443   <span class="keywordflow">if</span> (it != iend) {
<a name="l00444"></a>00444     <span class="keywordflow">return</span> it-&gt;second;
<a name="l00445"></a>00445   }
<a name="l00446"></a>00446 
<a name="l00447"></a>00447   <span class="comment">// do substitution?</span>
<a name="l00448"></a>00448 
<a name="l00449"></a>00449   it = substTable.<a class="code" href="classCVC3_1_1ExprHashMap.html#aeffd58f05fbeb8f381ba2050adef7a2d">find</a>(e);
<a name="l00450"></a>00450   iend = substTable.<a class="code" href="classCVC3_1_1ExprHashMap.html#a0ea2aa250fd1431c311d83f32862bba7">end</a>();
<a name="l00451"></a>00451   <span class="keywordflow">if</span> (it != iend) {
<a name="l00452"></a>00452     <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(it-&gt;second, <a class="code" href="classCVC3_1_1ExprTransform.html#ae1f3a46b2e09495bb5afe3ac46f23c2b" title="Helper for simplifyWithCare.">substitute</a>(it-&gt;second.getRHS(), substTable, cache));
<a name="l00453"></a>00453   }
<a name="l00454"></a>00454 
<a name="l00455"></a>00455   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(e);
<a name="l00456"></a>00456   <span class="keywordtype">int</span> ar = e.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>();
<a name="l00457"></a>00457   <span class="keywordflow">if</span> (ar &gt; 0) {
<a name="l00458"></a>00458     vector&lt;Theorem&gt; newChildrenThm;
<a name="l00459"></a>00459     vector&lt;unsigned&gt; changed;
<a name="l00460"></a>00460     <span class="keywordflow">for</span>(<span class="keywordtype">int</span> k = 0; k &lt; ar; ++k) {
<a name="l00461"></a>00461       <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> thm = <a class="code" href="classCVC3_1_1ExprTransform.html#ae1f3a46b2e09495bb5afe3ac46f23c2b" title="Helper for simplifyWithCare.">substitute</a>(e[k], substTable, cache);
<a name="l00462"></a>00462       <span class="keywordflow">if</span> (!thm.<a class="code" href="classCVC3_1_1Theorem.html#a16f074e60b9e076187efb478889d2c47">isRefl</a>()) {
<a name="l00463"></a>00463         newChildrenThm.push_back(thm);
<a name="l00464"></a>00464         changed.push_back(k);
<a name="l00465"></a>00465       }
<a name="l00466"></a>00466     }
<a name="l00467"></a>00467     <span class="keywordflow">if</span>(changed.size() &gt; 0) {
<a name="l00468"></a>00468       res = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a776c827bb6e3b889234429c49ae9ad6f" title="Optimized case for expr with one child.">substitutivityRule</a>(e, changed, newChildrenThm);
<a name="l00469"></a>00469     }
<a name="l00470"></a>00470   }
<a name="l00471"></a>00471   cache[e] = res;
<a name="l00472"></a>00472   <span class="keywordflow">return</span> res;
<a name="l00473"></a>00473 }
<a name="l00474"></a>00474 
<a name="l00475"></a>00475 
<a name="l00476"></a><a class="code" href="classCVC3_1_1ExprTransform.html#ad18b9697ac34575a40f106e48cfef5b4">00476</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ExprTransform.html#ad18b9697ac34575a40f106e48cfef5b4" title="ITE simplification from Burch paper.">ExprTransform::simplifyWithCare</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>&amp; e)
<a name="l00477"></a>00477 {
<a name="l00478"></a>00478   <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;</a> substTable;
<a name="l00479"></a>00479   <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;set&lt;Expr&gt;</a>* &gt; queue;
<a name="l00480"></a>00480   <a class="code" href="classCVC3_1_1ExprMap.html">ExprMap&lt;set&lt;Expr&gt;</a>* &gt;::iterator it;
<a name="l00481"></a>00481   set&lt;Expr&gt; cs;
<a name="l00482"></a>00482   <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, e, cs);
<a name="l00483"></a>00483 
<a name="l00484"></a>00484   <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> v;
<a name="l00485"></a>00485   <span class="keywordtype">bool</span> done;
<a name="l00486"></a>00486   <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> thm;
<a name="l00487"></a>00487   <span class="keywordtype">int</span> i;
<a name="l00488"></a>00488 
<a name="l00489"></a>00489   <span class="keywordflow">while</span> (!queue.<a class="code" href="classCVC3_1_1ExprMap.html#a292270a9283cbdcfd5a3ddccd4e33262">empty</a>()) {
<a name="l00490"></a>00490     it = queue.<a class="code" href="classCVC3_1_1ExprMap.html#a283ae6c44308cbdda0d82da5a16e52c8">end</a>();
<a name="l00491"></a>00491     --it;
<a name="l00492"></a>00492     v = it-&gt;first;
<a name="l00493"></a>00493     cs = *(it-&gt;second);
<a name="l00494"></a>00494     <span class="keyword">delete</span> it-&gt;second;
<a name="l00495"></a>00495     queue.<a class="code" href="classCVC3_1_1ExprMap.html#a2997aa3f20d09f6bf49b09da9a177003">erase</a>(v);
<a name="l00496"></a>00496 
<a name="l00497"></a>00497     <span class="keywordflow">if</span> (v.<a class="code" href="group__ExprPkg.html#ga48a9219339b394280550069ac7b0474f" title="Test if e is atomic.">isAtomic</a>() || v.<a class="code" href="group__ExprPkg.html#ga4b575e0a191cc42706ff5b5a169c3069" title="Test if e is an atomic formula.">isAtomicFormula</a>()) {
<a name="l00498"></a>00498 
<a name="l00499"></a>00499 <span class="comment">// Unfortunately, this can lead to incompleteness bugs</span>
<a name="l00500"></a>00500 
<a name="l00501"></a>00501 <span class="comment">//       d_core-&gt;getCM()-&gt;push();</span>
<a name="l00502"></a>00502 <span class="comment">//       set&lt;Expr&gt;::iterator iCare = cs.begin(), iCareEnd = cs.end();</span>
<a name="l00503"></a>00503 <span class="comment">//       for (; iCare != iCareEnd; ++iCare) {</span>
<a name="l00504"></a>00504 <span class="comment">//         d_core-&gt;addFact(d_commonRules-&gt;assumpRule((*iCare)));</span>
<a name="l00505"></a>00505 <span class="comment">//       }</span>
<a name="l00506"></a>00506 <span class="comment">//       thm = d_core-&gt;simplify(v);</span>
<a name="l00507"></a>00507 <span class="comment">//       if (!thm.isRefl()) {</span>
<a name="l00508"></a>00508 <span class="comment">//         substTable[v] = d_rules-&gt;dummyTheorem(thm.getExpr());</span>
<a name="l00509"></a>00509 <span class="comment">//       }</span>
<a name="l00510"></a>00510 <span class="comment">//       d_core-&gt;getCM()-&gt;pop();</span>
<a name="l00511"></a>00511       <span class="keywordflow">continue</span>;
<a name="l00512"></a>00512     }
<a name="l00513"></a>00513 
<a name="l00514"></a>00514     <span class="keywordflow">if</span> (<span class="keyword">false</span> &amp;&amp; v.<a class="code" href="group__ExprPkg.html#gad8c63abfec9cc4a8319f3df1b47eee45" title="True iff expr is not a Bool connective.">isPropAtom</a>() &amp;&amp; <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1Theory.html#a01fa8047ed1f649dc98831cb536187e4" title="Return the theory associated with a kind.">theoryOf</a>(v) == <a class="code" href="classCVC3_1_1ExprTransform.html#a741b9541234b906a8b74845e4c4d3c51">d_theoryArith</a> &amp;&amp;
<a name="l00515"></a>00515         <a class="code" href="classCVC3_1_1ExprTransform.html#a741b9541234b906a8b74845e4c4d3c51">d_theoryArith</a>-&gt;<a class="code" href="classCVC3_1_1TheoryArith.html#adcdf01dd1e0f78760fefc2a82b604098">leavesAreNumConst</a>(v)) {
<a name="l00516"></a>00516       <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> vNew = v;
<a name="l00517"></a>00517       thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a61c1fe56b4ed9744006883a7784ddb71">reflexivityRule</a>(vNew);
<a name="l00518"></a>00518       <span class="keywordflow">while</span> (vNew.<a class="code" href="group__ExprPkg.html#gaf53e6a6f9dc01481d2cf94673c5505ce" title="Return whether Expr contains a non-bool type ITE as a sub-term.">containsTermITE</a>()) {
<a name="l00519"></a>00519         thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a893a258d9f7d49acb5c8a8b5b8ec39b0">liftOneITE</a>(vNew));
<a name="l00520"></a>00520         <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(!thm.<a class="code" href="classCVC3_1_1Theorem.html#a16f074e60b9e076187efb478889d2c47">isRefl</a>(), <span class="stringliteral">&quot;Expected non-reflexive&quot;</span>);
<a name="l00521"></a>00521         thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a03f8a74b8b1b6d90ff23a0a6150c49d6" title="==&gt; ITE(a, b(a), c(a)) IFF ITE(a, b(TRUE), c(FALSE))">rewriteIteCond</a>(thm.getRHS()));
<a name="l00522"></a>00522         thm = <a class="code" href="classCVC3_1_1ExprTransform.html#aeea6bcb414f95c53d846ad7c684b1a5d">d_commonRules</a>-&gt;<a class="code" href="classCVC3_1_1CommonProofRules.html#a4a4e90cd69ce24e83ba2c217907c277a" title=" (same for IFF)">transitivityRule</a>(thm, <a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1TheoryCore.html#a8a66da5ca687474a3a725448a3be8c41" title="Top-level simplifier.">simplify</a>(thm.getRHS()));
<a name="l00523"></a>00523         vNew = thm.getRHS();
<a name="l00524"></a>00524       }
<a name="l00525"></a>00525       substTable[v] = thm;
<a name="l00526"></a>00526       <span class="keywordflow">continue</span>;
<a name="l00527"></a>00527     }
<a name="l00528"></a>00528 
<a name="l00529"></a>00529     done = <span class="keyword">false</span>;
<a name="l00530"></a>00530     set&lt;Expr&gt;::iterator iCare, iCareEnd = cs.end();
<a name="l00531"></a>00531 
<a name="l00532"></a>00532     <span class="keywordflow">switch</span> (v.<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>()) {
<a name="l00533"></a>00533       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3a4cfaf3eae8eac1dc2fd27d9f0994dc">ITE</a>: {
<a name="l00534"></a>00534         iCare = cs.find(v[0]);
<a name="l00535"></a>00535         <span class="keywordflow">if</span> (iCare != iCareEnd) {
<a name="l00536"></a>00536           <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> rewrite = v.<a class="code" href="group__ExprPkg.html#ga42929221eb172250697b72c28af6de07" title="Get the type. Recursively compute if necessary.">getType</a>().<a class="code" href="classCVC3_1_1Type.html#a38bba404056eadf3c283a67ab2347e02">isBool</a>() ? v.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(v[1]) : v.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(v[1]);
<a name="l00537"></a>00537           substTable[v] = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a9592705bbf82393b7f6500fa33ead252" title="Temporary cheat for building theorems.">dummyTheorem</a>(rewrite);
<a name="l00538"></a>00538           <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[1], cs);
<a name="l00539"></a>00539           done = <span class="keyword">true</span>;
<a name="l00540"></a>00540           <span class="keywordflow">break</span>;
<a name="l00541"></a>00541         }
<a name="l00542"></a>00542         <span class="keywordflow">else</span> {
<a name="l00543"></a>00543           iCare = cs.find(v[0].negate());
<a name="l00544"></a>00544           <span class="keywordflow">if</span> (iCare != iCareEnd) {
<a name="l00545"></a>00545             <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> rewrite = v.<a class="code" href="group__ExprPkg.html#ga42929221eb172250697b72c28af6de07" title="Get the type. Recursively compute if necessary.">getType</a>().<a class="code" href="classCVC3_1_1Type.html#a38bba404056eadf3c283a67ab2347e02">isBool</a>() ? v.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(v[2]) : v.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(v[2]);
<a name="l00546"></a>00546             substTable[v] = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a9592705bbf82393b7f6500fa33ead252" title="Temporary cheat for building theorems.">dummyTheorem</a>(rewrite);
<a name="l00547"></a>00547             <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[2], cs);
<a name="l00548"></a>00548             done = <span class="keyword">true</span>;
<a name="l00549"></a>00549             <span class="keywordflow">break</span>;
<a name="l00550"></a>00550           }
<a name="l00551"></a>00551         }
<a name="l00552"></a>00552         <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[0], cs);
<a name="l00553"></a>00553         cs.insert(v[0]);
<a name="l00554"></a>00554         <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[1], cs);
<a name="l00555"></a>00555         cs.erase(v[0]);
<a name="l00556"></a>00556         cs.insert(v[0].negate());
<a name="l00557"></a>00557         <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[2], cs);
<a name="l00558"></a>00558         done = <span class="keyword">true</span>;
<a name="l00559"></a>00559         <span class="keywordflow">break</span>;
<a name="l00560"></a>00560       }
<a name="l00561"></a>00561       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba865555c9f2e0458a7078486aa1b3254f">AND</a>: {
<a name="l00562"></a>00562         <span class="keywordflow">for</span> (i = 0; i &lt; v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>(); ++i) {
<a name="l00563"></a>00563           iCare = cs.find(v[i].negate());
<a name="l00564"></a>00564           <span class="keywordflow">if</span> (iCare != iCareEnd) {
<a name="l00565"></a>00565             <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> rewrite = v.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1Theory.html#abc2e30308c9e1f3cf752cfe8d939df1e" title="Access to ExprManager.">getEM</a>()-&gt;<a class="code" href="group__EM__Priv.html#gaae9db4c93c67cbf8bbf5d1e60e94f1ae" title="FALSE Expr.">falseExpr</a>());
<a name="l00566"></a>00566             substTable[v] = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a9592705bbf82393b7f6500fa33ead252" title="Temporary cheat for building theorems.">dummyTheorem</a>(rewrite);
<a name="l00567"></a>00567             done = <span class="keyword">true</span>;
<a name="l00568"></a>00568             <span class="keywordflow">break</span>;
<a name="l00569"></a>00569           }
<a name="l00570"></a>00570         }
<a name="l00571"></a>00571         <span class="keywordflow">if</span> (done) <span class="keywordflow">break</span>;
<a name="l00572"></a>00572 
<a name="l00573"></a>00573         <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>() &gt; 1, <span class="stringliteral">&quot;Expected arity &gt; 1&quot;</span>);
<a name="l00574"></a>00574         cs.insert(v[1]);
<a name="l00575"></a>00575         <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[0], cs);
<a name="l00576"></a>00576         cs.erase(v[1]);
<a name="l00577"></a>00577         cs.insert(v[0]);
<a name="l00578"></a>00578         <span class="keywordflow">for</span> (i = 1; i &lt; v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>(); ++i) {
<a name="l00579"></a>00579           <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[i], cs);
<a name="l00580"></a>00580         }
<a name="l00581"></a>00581         done = <span class="keyword">true</span>;
<a name="l00582"></a>00582         <span class="keywordflow">break</span>;
<a name="l00583"></a>00583       }
<a name="l00584"></a>00584       <span class="keywordflow">case</span> <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba96727447c0ad447987df1c6415aef074">OR</a>: {
<a name="l00585"></a>00585         <span class="keywordflow">for</span> (i = 0; i &lt; v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>(); ++i) {
<a name="l00586"></a>00586           iCare = cs.find(v[i]);
<a name="l00587"></a>00587           <span class="keywordflow">if</span> (iCare != iCareEnd) {
<a name="l00588"></a>00588             <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> rewrite = v.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(<a class="code" href="classCVC3_1_1ExprTransform.html#adf66a811cae797e64ae8ff25e922766a">d_core</a>-&gt;<a class="code" href="classCVC3_1_1Theory.html#abc2e30308c9e1f3cf752cfe8d939df1e" title="Access to ExprManager.">getEM</a>()-&gt;<a class="code" href="group__EM__Priv.html#ga4471fca49c2acbb7b4cf71e72bc55d6a" title="TRUE Expr.">trueExpr</a>());
<a name="l00589"></a>00589             substTable[v] = <a class="code" href="classCVC3_1_1ExprTransform.html#ae6bdbc5df7bd412e0594650d7ef02cc4">d_rules</a>-&gt;<a class="code" href="classCVC3_1_1CoreProofRules.html#a9592705bbf82393b7f6500fa33ead252" title="Temporary cheat for building theorems.">dummyTheorem</a>(rewrite);
<a name="l00590"></a>00590             done = <span class="keyword">true</span>;
<a name="l00591"></a>00591             <span class="keywordflow">break</span>;
<a name="l00592"></a>00592           }
<a name="l00593"></a>00593         }
<a name="l00594"></a>00594         <span class="keywordflow">if</span> (done) <span class="keywordflow">break</span>;
<a name="l00595"></a>00595         <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>() &gt; 1, <span class="stringliteral">&quot;Expected arity &gt; 1&quot;</span>);
<a name="l00596"></a>00596         cs.insert(v[1].negate());
<a name="l00597"></a>00597         <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[0], cs);
<a name="l00598"></a>00598         cs.erase(v[1].negate());
<a name="l00599"></a>00599         cs.insert(v[0].negate());
<a name="l00600"></a>00600         <span class="keywordflow">for</span> (i = 1; i &lt; v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>(); ++i) {
<a name="l00601"></a>00601           <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[i], cs);
<a name="l00602"></a>00602         }
<a name="l00603"></a>00603         done = <span class="keyword">true</span>;
<a name="l00604"></a>00604         <span class="keywordflow">break</span>;
<a name="l00605"></a>00605       }
<a name="l00606"></a>00606       <span class="keywordflow">default</span>:
<a name="l00607"></a>00607         <span class="keywordflow">break</span>;
<a name="l00608"></a>00608     }
<a name="l00609"></a>00609 
<a name="l00610"></a>00610     <span class="keywordflow">if</span> (done) <span class="keywordflow">continue</span>;
<a name="l00611"></a>00611 
<a name="l00612"></a>00612     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; v.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>(); ++i) {
<a name="l00613"></a>00613       <a class="code" href="classCVC3_1_1ExprTransform.html#ad12aee56d7dd01276af2d993ce4676c9" title="Helper for simplifyWithCare.">updateQueue</a>(queue, v[i], cs);
<a name="l00614"></a>00614     }
<a name="l00615"></a>00615   }
<a name="l00616"></a>00616   <a class="code" href="classCVC3_1_1ExprHashMap.html">ExprHashMap&lt;Theorem&gt;</a> cache;
<a name="l00617"></a>00617   <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1ExprTransform.html#ae1f3a46b2e09495bb5afe3ac46f23c2b" title="Helper for simplifyWithCare.">substitute</a>(e, substTable, cache);
<a name="l00618"></a>00618 }
<a name="l00619"></a>00619 
</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>