<!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: array_theorem_producer.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 <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 Page</span></a></li> <li><a href="pages.html"><span>Related 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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">array_theorem_producer.cpp</div> </div> </div> <div class="contents"> <a href="array__theorem__producer_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 array_theorem_producer.cpp</span> <a name="l00004"></a>00004 <span class="comment"> * \brief Description: TRUSTED implementation of array proof rules.</span> <a name="l00005"></a>00005 <span class="comment"> * </span> <a name="l00006"></a>00006 <span class="comment"> * Author: Clark Barrett</span> <a name="l00007"></a>00007 <span class="comment"> * </span> <a name="l00008"></a>00008 <span class="comment"> * Created: Thu May 29 14:02:16 2003</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * <hr></span> <a name="l00011"></a>00011 <span class="comment"> *</span> <a name="l00012"></a>00012 <span class="comment"> * License to use, copy, modify, sell and/or distribute this software</span> <a name="l00013"></a>00013 <span class="comment"> * and its documentation for any purpose is hereby granted without</span> <a name="l00014"></a>00014 <span class="comment"> * royalty, subject to the terms and conditions defined in the \ref</span> <a name="l00015"></a>00015 <span class="comment"> * LICENSE file provided with this distribution.</span> <a name="l00016"></a>00016 <span class="comment"> * </span> <a name="l00017"></a>00017 <span class="comment"> * <hr></span> <a name="l00018"></a>00018 <span class="comment"> * </span> <a name="l00019"></a>00019 <span class="comment"> */</span> <a name="l00020"></a>00020 <span class="comment">/*****************************************************************************/</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="comment">// This code is trusted</span> <a name="l00024"></a><a class="code" href="array__theorem__producer_8cpp.html#a8663c36bbf15bb5a0dcb01b97897fa95">00024</a> <span class="preprocessor">#define _CVC3_TRUSTED_</span> <a name="l00025"></a>00025 <span class="preprocessor"></span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="array__theorem__producer_8h.html">array_theorem_producer.h</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="theory__array_8h.html">theory_array.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="theory__core_8h.html">theory_core.h</a>"</span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="keyword">using namespace </span>std; <a name="l00033"></a>00033 <span class="keyword">using namespace </span>CVC3; <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="comment"></span> <a name="l00036"></a>00036 <span class="comment">////////////////////////////////////////////////////////////////////</span> <a name="l00037"></a>00037 <span class="comment"></span><span class="comment">// TheoryArray: trusted method for creating ArrayTheoremProducer</span><span class="comment"></span> <a name="l00038"></a>00038 <span class="comment">////////////////////////////////////////////////////////////////////</span> <a name="l00039"></a>00039 <span class="comment"></span> <a name="l00040"></a>00040 <a name="l00041"></a><a class="code" href="classCVC3_1_1TheoryArray.html#a5b53e3f645da3208478edb182e8bcd8e">00041</a> <a class="code" href="classCVC3_1_1ArrayProofRules.html">ArrayProofRules</a>* TheoryArray::createProofRules() { <a name="l00042"></a>00042 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html">ArrayTheoremProducer</a>(<span class="keyword">this</span>); <a name="l00043"></a>00043 } <a name="l00044"></a>00044 <a name="l00045"></a>00045 <a name="l00046"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a8722003347f46425828e98393be8bb95">00046</a> ArrayTheoremProducer::ArrayTheoremProducer(<a class="code" href="classCVC3_1_1TheoryArray.html" title="This theory handles arrays.">TheoryArray</a>* theoryArray) <a name="l00047"></a>00047 : <a class="code" href="classCVC3_1_1TheoremProducer.html">TheoremProducer</a>(theoryArray->theoryCore()->getTM()), <a name="l00048"></a>00048 d_theoryArray(theoryArray) <a name="l00049"></a>00049 {} <a name="l00050"></a>00050 <a name="l00051"></a>00051 <span class="comment"></span> <a name="l00052"></a>00052 <span class="comment">////////////////////////////////////////////////////////////////////</span> <a name="l00053"></a>00053 <span class="comment"></span><span class="comment">// Proof rules</span><span class="comment"></span> <a name="l00054"></a>00054 <span class="comment">////////////////////////////////////////////////////////////////////</span> <a name="l00055"></a>00055 <span class="comment"></span> <a name="l00056"></a>00056 <a name="l00057"></a><a class="code" href="array__theorem__producer_8cpp.html#a79f2713d570c7065f61a160134ea765b">00057</a> <span class="preprocessor">#define CLASS_NAME "CVC3::ArrayTheoremProducer"</span> <a name="l00058"></a>00058 <span class="preprocessor"></span> <a name="l00059"></a>00059 <a name="l00060"></a>00060 <span class="comment">// ==></span> <a name="l00061"></a>00061 <span class="comment">// write(store, index_0, v_0, index_1, v_1, ..., index_n, v_n) = store IFF</span> <a name="l00062"></a>00062 <span class="comment">//</span> <a name="l00063"></a>00063 <span class="comment">// read(store, index_n) = v_n &</span> <a name="l00064"></a>00064 <span class="comment">// index_{n-1} != index_n -> read(store, index_{n-1}) = v_{n-1} &</span> <a name="l00065"></a>00065 <span class="comment">// (index_{n-2} != index_{n-1} & index_{n-2} != index_n) -> read(store, index_{n-2}) = v_{n-2} &</span> <a name="l00066"></a>00066 <span class="comment">// ...</span> <a name="l00067"></a>00067 <span class="comment">// (index_1 != index_2 & ... & index_1 != index_n) -> read(store, index_1) = v_1</span> <a name="l00068"></a>00068 <span class="comment">// (index_0 != index_1 & index_0 != index_2 & ... & index_0 != index_n) -> read(store, index_0) = v_0</span> <a name="l00069"></a>00069 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00070"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a0ab9aba97b1937710a9eba916ae02c05">00070</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a0ab9aba97b1937710a9eba916ae02c05">ArrayTheoremProducer::rewriteSameStore</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e, <span class="keywordtype">int</span> n) <a name="l00071"></a>00071 { <a name="l00072"></a>00072 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00073"></a>00073 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(e.<a class="code" href="group__ExprPkg.html#gac4af2026c180da0f18d66ac616f61f3a">isEq</a>(), <span class="stringliteral">"EQ expected"</span>); <a name="l00074"></a>00074 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e1 = e[0]; <a name="l00075"></a>00075 <span class="keywordtype">int</span> N = 0; <a name="l00076"></a>00076 <span class="keywordflow">while</span> (<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e1)) { N++; e1 = e1[0]; } <a name="l00077"></a>00077 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(N == n && n > 0, <span class="stringliteral">"Counting error"</span>); <a name="l00078"></a>00078 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(e1 == e[1], <span class="stringliteral">"Stores do not match"</span>); <a name="l00079"></a>00079 ) <a name="l00080"></a>00080 <a name="l00081"></a>00081 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00082"></a>00082 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> write_i, write_j, index_i, index_j, hyp, conc, result; <a name="l00083"></a>00083 <span class="keywordtype">int</span> i, j; <a name="l00084"></a>00084 <a name="l00085"></a>00085 write_i = e[0]; <a name="l00086"></a>00086 <span class="keywordflow">for</span> (i = n-1; i >= 0; --i) { <a name="l00087"></a>00087 index_i = write_i[1]; <a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="comment">// build: [index_i /= index_n && index_i /= index_(n-1) &&</span> <a name="l00090"></a>00090 <span class="comment">// ... && index_i /= index_(i+1)] -> read(store, index_i) = v_i</span> <a name="l00091"></a>00091 write_j = e[0]; <a name="l00092"></a>00092 <span class="keywordflow">for</span> (j = n - 1; j > i; --j) { <a name="l00093"></a>00093 index_j = write_j[1]; <a name="l00094"></a>00094 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> hyp2(!((index_i.getType().isBool())? <a name="l00095"></a>00095 index_i.iffExpr(index_j) : index_i.eqExpr(index_j))); <a name="l00096"></a>00096 <span class="keywordflow">if</span> (hyp.isNull()) hyp = hyp2; <a name="l00097"></a>00097 <span class="keywordflow">else</span> hyp = hyp && hyp2; <a name="l00098"></a>00098 write_j = write_j[0]; <a name="l00099"></a>00099 } <a name="l00100"></a>00100 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> r1(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, e[1], index_i)); <a name="l00101"></a>00101 conc = (r1.<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="l00102"></a>00102 r1.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(write_i[2]) : r1.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(write_i[2]); <a name="l00103"></a>00103 <span class="keywordflow">if</span> (!hyp.isNull()) conc = hyp.<a class="code" href="group__ExprPkg.html#ga8dd97bcdeb9d8870238f94a263fd083b">impExpr</a>(conc); <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment">// And into result</span> <a name="l00106"></a>00106 <span class="keywordflow">if</span> (result.isNull()) result = conc; <a name="l00107"></a>00107 <span class="keywordflow">else</span> result = result && conc; <a name="l00108"></a>00108 <a name="l00109"></a>00109 <span class="comment">// Prepare for next iteration</span> <a name="l00110"></a>00110 write_i = write_i[0]; <a name="l00111"></a>00111 hyp = <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(); <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"rewriteSameStore"</span>, e); <a name="l00114"></a>00114 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, result, <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00115"></a>00115 } <a name="l00116"></a>00116 <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="comment">// ==> write(store, index, value) = write(...) IFF</span> <a name="l00119"></a>00119 <span class="comment">// store = write(write(...), index, read(store, index)) &</span> <a name="l00120"></a>00120 <span class="comment">// value = read(write(...), index)</span> <a name="l00121"></a>00121 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00122"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a45d175085355a9ff4215371c08fae566">00122</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a45d175085355a9ff4215371c08fae566">ArrayTheoremProducer::rewriteWriteWrite</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) <a name="l00123"></a>00123 { <a name="l00124"></a>00124 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00125"></a>00125 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(e.<a class="code" href="group__ExprPkg.html#gac4af2026c180da0f18d66ac616f61f3a">isEq</a>(), <span class="stringliteral">"EQ expected"</span>); <a name="l00126"></a>00126 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e[0]) && <a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e[1]), <a name="l00127"></a>00127 <span class="stringliteral">"Expected WRITE = WRITE"</span>); <a name="l00128"></a>00128 ) <a name="l00129"></a>00129 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00130"></a>00130 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& <a class="code" href="namespaceMiniSat.html#ad93cb56673487974071ed3b75bf4ea83">left</a> = e[0]; <a name="l00131"></a>00131 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& <a class="code" href="namespaceMiniSat.html#a82558b7a36c52f5d3211d5d14bed99d4">right</a> = e[1]; <a name="l00132"></a>00132 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& store = left[0]; <a name="l00133"></a>00133 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& index = left[1]; <a name="l00134"></a>00134 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& value = left[2]; <a name="l00135"></a>00135 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e1 = (store.<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="l00136"></a>00136 store.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a33b0829ff24c1e0d27de00d675267297">WRITE</a>, right, index, <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, store, index))) <a name="l00137"></a>00137 : store.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a33b0829ff24c1e0d27de00d675267297">WRITE</a>, right, index, <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, store, index))); <a name="l00138"></a>00138 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e2 = (value.<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="l00139"></a>00139 value.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, right, index)) : <a name="l00140"></a>00140 value.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, right, index)); <a name="l00141"></a>00141 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"rewriteWriteWrite"</span>, e); <a name="l00142"></a>00142 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, e1.<a class="code" href="group__ExprPkg.html#ga6c3651465ce69ed5f4e6fd461b9acf3c">andExpr</a>(e2), <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00143"></a>00143 } <a name="l00144"></a>00144 <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="comment">// ==> read(write(store, index1, value), index2) =</span> <a name="l00147"></a>00147 <span class="comment">// ite(index1 = index2, value, read(store, index2))</span> <a name="l00148"></a>00148 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00149"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a508cb6e565c59ad0e91ee380774ea379">00149</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a508cb6e565c59ad0e91ee380774ea379">ArrayTheoremProducer::rewriteReadWrite</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) <a name="l00150"></a>00150 { <a name="l00151"></a>00151 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00152"></a>00152 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#a970e5543468dfa1fb19e6e256b022370">isRead</a>(e), <span class="stringliteral">"Read expected"</span>); <a name="l00153"></a>00153 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e[0]), <span class="stringliteral">"Expected Read(Write)"</span>); <a name="l00154"></a>00154 ) <a name="l00155"></a>00155 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00156"></a>00156 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& store = e[0][0]; <a name="l00157"></a>00157 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& index1 = e[0][1]; <a name="l00158"></a>00158 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& value = e[0][2]; <a name="l00159"></a>00159 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& index2 = e[1]; <a name="l00160"></a>00160 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> indexCond = (index1.<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="l00161"></a>00161 index1.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(index2) : index1.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(index2); <a name="l00162"></a>00162 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"rewriteReadWrite"</span>, e); <a name="l00163"></a>00163 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, indexCond.<a class="code" href="group__ExprPkg.html#ga5532cabad6f699c57da32a8db65a38da">iteExpr</a>(value, <a name="l00164"></a>00164 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, store, index2)), <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00165"></a>00165 } <a name="l00166"></a>00166 <a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="comment">// e = read(write(store, index1, value), index2):</span> <a name="l00169"></a>00169 <span class="comment">// ==> ite(index1 = index2,</span> <a name="l00170"></a>00170 <span class="comment">// read(write(store, index1, value), index2) = value,</span> <a name="l00171"></a>00171 <span class="comment">// read(write(store, index1, value), index2) = read(store, index2))</span> <a name="l00172"></a>00172 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00173"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a5b6d56f4f0f05cb3671b3c01b293d3bc">00173</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a5b6d56f4f0f05cb3671b3c01b293d3bc">ArrayTheoremProducer::rewriteReadWrite2</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) <a name="l00174"></a>00174 { <a name="l00175"></a>00175 <a class="code" href="debug_8h.html#a600cb2d68efe7cc413cccbb5714c7016">IF_DEBUG</a>( <a name="l00176"></a>00176 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#a970e5543468dfa1fb19e6e256b022370">isRead</a>(e), <span class="stringliteral">"Read expected"</span>); <a name="l00177"></a>00177 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e[0]), <span class="stringliteral">"Expected Read(Write)"</span>); <a name="l00178"></a>00178 ) <a name="l00179"></a>00179 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00180"></a>00180 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& store = e[0][0]; <a name="l00181"></a>00181 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& index1 = e[0][1]; <a name="l00182"></a>00182 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& value = e[0][2]; <a name="l00183"></a>00183 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& index2 = e[1]; <a name="l00184"></a>00184 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> indexCond = (index1.<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="l00185"></a>00185 index1.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(index2) : index1.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(index2); <a name="l00186"></a>00186 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"rewriteReadWrite2"</span>, e); <a name="l00187"></a>00187 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#ab3afa2471d244b129865548afe06ca89" title="Create a new theorem. See also newRWTheorem() and newReflTheorem()">newTheorem</a>(indexCond.<a class="code" href="group__ExprPkg.html#ga5532cabad6f699c57da32a8db65a38da">iteExpr</a>(e.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(value), <a name="l00188"></a>00188 e.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, store, index2))), <a name="l00189"></a>00189 <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00190"></a>00190 } <a name="l00191"></a>00191 <a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="comment">// read(store, index) = value ==></span> <a name="l00194"></a>00194 <span class="comment">// write(store, index, value) = store</span> <a name="l00195"></a>00195 <span class="comment">//</span> <a name="l00196"></a>00196 <span class="comment">// More general case:</span> <a name="l00197"></a>00197 <span class="comment">//</span> <a name="l00198"></a>00198 <span class="comment">// read(store, index_n) = value_n ==></span> <a name="l00199"></a>00199 <span class="comment">// write(store, index_0, v_0, index_1, v_1, ..., index_n, value_n) =</span> <a name="l00200"></a>00200 <span class="comment">// write(store, index_0, ite(index_n = index_0, value_n, v_0),</span> <a name="l00201"></a>00201 <span class="comment">// index_1, ite(index_n = index_1, value_n, v_1),</span> <a name="l00202"></a>00202 <span class="comment">// ...</span> <a name="l00203"></a>00203 <span class="comment">// index_{n-1}, ite(index_n = index_{n-1}, value_n, value_{n-1}))</span> <a name="l00204"></a>00204 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00205"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a1b4dd97c680555f98834c0c2eb63beca">00205</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a1b4dd97c680555f98834c0c2eb63beca">ArrayTheoremProducer::rewriteRedundantWrite1</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>& r_eq_v, <a name="l00206"></a>00206 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& write) <a name="l00207"></a>00207 { <a name="l00208"></a>00208 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a362c1d70e03803d804bbe300e5f6dc87">isRewrite</a>(), <span class="stringliteral">"Expected equation"</span>); <a name="l00209"></a>00209 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#a970e5543468dfa1fb19e6e256b022370">isRead</a>(r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a206c04f39fbbcacef2337148675553f4">getLHS</a>()), <span class="stringliteral">"Expected Read"</span>); <a name="l00210"></a>00210 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& index = r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a206c04f39fbbcacef2337148675553f4">getLHS</a>()[1]; <a name="l00211"></a>00211 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& value = r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>(); <a name="l00212"></a>00212 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(write) && <a name="l00213"></a>00213 index == write[1] && value == write[2], <a name="l00214"></a>00214 <span class="stringliteral">"Error in parameters to rewriteRedundantWrite1"</span>); <a name="l00215"></a>00215 <a name="l00216"></a>00216 vector<Expr> indices; <a name="l00217"></a>00217 vector<Expr> values; <a name="l00218"></a>00218 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> store = write[0]; <a name="l00219"></a>00219 <span class="keywordflow">while</span> (<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(store)) { <a name="l00220"></a>00220 indices.push_back(store[1]); <a name="l00221"></a>00221 values.push_back(store[2]); <a name="l00222"></a>00222 store = store[0]; <a name="l00223"></a>00223 } <a name="l00224"></a>00224 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(store == r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a206c04f39fbbcacef2337148675553f4">getLHS</a>()[0], <a name="l00225"></a>00225 <span class="stringliteral">"Store does not match in rewriteRedundantWrite"</span>); <a name="l00226"></a>00226 <span class="keywordflow">while</span> (!indices.empty()) { <a name="l00227"></a>00227 store = <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a33b0829ff24c1e0d27de00d675267297">WRITE</a>, store, indices.back(), <a name="l00228"></a>00228 index.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(indices.back()).iteExpr(value, values.back())); <a name="l00229"></a>00229 indices.pop_back(); <a name="l00230"></a>00230 values.pop_back(); <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <a name="l00233"></a>00233 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00234"></a>00234 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) { <a name="l00235"></a>00235 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"rewriteRedundantWrite1"</span>, write, r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a2d8352c07a756c3837683a27a1e659ef">getProof</a>()); <a name="l00236"></a>00236 } <a name="l00237"></a>00237 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(write, store, r_eq_v.<a class="code" href="classCVC3_1_1Theorem.html#a5e9ab00a613df15cc02f55edb55a67b3">getAssumptionsRef</a>(), pf); <a name="l00238"></a>00238 } <a name="l00239"></a>00239 <a name="l00240"></a>00240 <a name="l00241"></a>00241 <span class="comment">// ==></span> <a name="l00242"></a>00242 <span class="comment">// write(write(store, index, v1), index, v2) = write(store, index, v2)</span> <a name="l00243"></a>00243 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00244"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a4eb3fa026164aa36735dde9de93067e6">00244</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a4eb3fa026164aa36735dde9de93067e6">ArrayTheoremProducer::rewriteRedundantWrite2</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) <a name="l00245"></a>00245 { <a name="l00246"></a>00246 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e) && <a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e[0]) && <a name="l00247"></a>00247 e[0][1] == e[1], <a name="l00248"></a>00248 <span class="stringliteral">"Error in parameters to rewriteRedundantWrite2"</span>); <a name="l00249"></a>00249 <a name="l00250"></a>00250 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00251"></a>00251 <a name="l00252"></a>00252 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) { <a name="l00253"></a>00253 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"rewriteRedundantWrite2"</span>, e); <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a33b0829ff24c1e0d27de00d675267297">WRITE</a>, e[0][0], e[1], e[2]), <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00257"></a>00257 } <a name="l00258"></a>00258 <a name="l00259"></a>00259 <a name="l00260"></a>00260 <span class="comment">// ==></span> <a name="l00261"></a>00261 <span class="comment">// write(write(store, index1, v1), index2, v2) =</span> <a name="l00262"></a>00262 <span class="comment">// write(write(store, index2, v2), index1, ite(index1 = index2, v2, v1))</span> <a name="l00263"></a>00263 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00264"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a531007d953fd91a89f9d273cf04d2196">00264</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a531007d953fd91a89f9d273cf04d2196">ArrayTheoremProducer::interchangeIndices</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) <a name="l00265"></a>00265 { <a name="l00266"></a>00266 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e) && <a class="code" href="namespaceCVC3.html#abdc2f55e0df529954fc271499242351c">isWrite</a>(e[0]), <a name="l00267"></a>00267 <span class="stringliteral">"Error in parameters to interchangeIndices"</span>); <a name="l00268"></a>00268 <a name="l00269"></a>00269 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00270"></a>00270 <a name="l00271"></a>00271 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) { <a name="l00272"></a>00272 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"interchangeIndices"</span>, e); <a name="l00273"></a>00273 } <a name="l00274"></a>00274 <a name="l00275"></a>00275 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> w0 = <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a33b0829ff24c1e0d27de00d675267297">WRITE</a>, e[0][0], e[1], e[2]); <a name="l00276"></a>00276 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> indexCond = (e[0][1].<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="l00277"></a>00277 e[0][1].iffExpr(e[1]) : e[0][1].<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(e[1]); <a name="l00278"></a>00278 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> w2 = <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a33b0829ff24c1e0d27de00d675267297">WRITE</a>, w0, e[0][1], indexCond.<a class="code" href="group__ExprPkg.html#ga5532cabad6f699c57da32a8db65a38da">iteExpr</a>(e[2], e[0][2])); <a name="l00279"></a>00279 <a name="l00280"></a>00280 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, w2, <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00281"></a>00281 } <a name="l00282"></a>00282 <a name="l00283"></a>00283 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a name="l00284"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a8c0cbeb8e41da7e06528641cdf3be3fb">00284</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a8c0cbeb8e41da7e06528641cdf3be3fb" title="Beta reduction of array literal: |- (array x. f(x))[arg] = f(arg)">ArrayTheoremProducer::readArrayLiteral</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) { <a name="l00285"></a>00285 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00286"></a>00286 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e.<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>() == <a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, <a name="l00287"></a>00287 <span class="stringliteral">"ArrayTheoremProducer::readArrayLiteral("</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>() <a name="l00288"></a>00288 +<span class="stringliteral">"):\n\n expression is not a READ"</span>); <a name="l00289"></a>00289 } <a name="l00290"></a>00290 <a name="l00291"></a>00291 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> arrayLit(e[0]); <a name="l00292"></a>00292 <a name="l00293"></a>00293 <span class="keywordflow">if</span> (<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00294"></a>00294 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(arrayLit.<a class="code" href="group__ExprPkg.html#ga3127f52184d5bcb2d4056cb23f3a292b">isClosure</a>() && arrayLit.<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>()==<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781a9e6a1f69d18953ab05c21b660abbb0f0">ARRAY_LITERAL</a>, <a name="l00295"></a>00295 <span class="stringliteral">"ArrayTheoremProducer::readArrayLiteral("</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()+<span class="stringliteral">")"</span>); <a name="l00296"></a>00296 } <a name="l00297"></a>00297 <a name="l00298"></a>00298 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> body(arrayLit.<a class="code" href="group__ExprPkg.html#ga9060193194020fee3dac69ed1876a940" title="Get the body of the closure Expr.">getBody</a>()); <a name="l00299"></a>00299 <span class="keyword">const</span> vector<Expr>& vars = arrayLit.<a class="code" href="group__ExprPkg.html#gaad22e223d0e273780557aca9d87620cd" title="Get bound variables from a closure Expr.">getVars</a>(); <a name="l00300"></a>00300 <a name="l00301"></a>00301 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00302"></a>00302 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(vars.size() == 1, <a name="l00303"></a>00303 <span class="stringliteral">"ArrayTheoremProducer::readArrayLiteral("</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()+<span class="stringliteral">"):\n"</span> <a name="l00304"></a>00304 +<span class="stringliteral">"wrong number of bound variables"</span>); <a name="l00305"></a>00305 } <a name="l00306"></a>00306 <a name="l00307"></a>00307 <span class="comment">// Use the Expr's efficient substitution</span> <a name="l00308"></a>00308 vector<Expr> ind; <a name="l00309"></a>00309 ind.push_back(e[1]); <a name="l00310"></a>00310 body = body.substExpr(vars, ind); <a name="l00311"></a>00311 <a name="l00312"></a>00312 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00313"></a>00313 <span class="keywordflow">if</span>(<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) <a name="l00314"></a>00314 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"read_array_literal"</span>, e); <a name="l00315"></a>00315 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, body, <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00316"></a>00316 } <a name="l00317"></a>00317 <a name="l00318"></a>00318 <a name="l00319"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#ac8a296684897a290c2894d4e8fee962b">00319</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#ac8a296684897a290c2894d4e8fee962b" title="Lift ite over read.">ArrayTheoremProducer::liftReadIte</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& e) <a name="l00320"></a>00320 { <a name="l00321"></a>00321 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00322"></a>00322 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e.<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>() == <a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a> && e[0].<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>() == <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3a4cfaf3eae8eac1dc2fd27d9f0994dc">ITE</a>, <a name="l00323"></a>00323 <span class="stringliteral">"ArrayTheoremProducer::liftReadIte("</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>() <a name="l00324"></a>00324 +<span class="stringliteral">"):\n\n expression is not READ(ITE..."</span>); <a name="l00325"></a>00325 } <a name="l00326"></a>00326 <a name="l00327"></a>00327 <span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& ite = e[0]; <a name="l00328"></a>00328 <a name="l00329"></a>00329 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00330"></a>00330 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) <a name="l00331"></a>00331 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"lift_read_ite"</span>,e); <a name="l00332"></a>00332 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#a1b12639479f7d06736c643d43d714e90" title="Create a rewrite theorem: lhs = rhs.">newRWTheorem</a>(e, <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3a4cfaf3eae8eac1dc2fd27d9f0994dc">ITE</a>, ite[0], <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, ite[1], e[1]), <a name="l00333"></a>00333 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, ite[2], e[1])), <a name="l00334"></a>00334 <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00335"></a>00335 } <a name="l00336"></a>00336 <a name="l00337"></a>00337 <a name="l00338"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#ae644c310ea0d55518a2505acc4e3cc1d">00338</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#ae644c310ea0d55518a2505acc4e3cc1d" title="a /= b |- exists i. a[i] /= b[i]">ArrayTheoremProducer::arrayNotEq</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>& e) <a name="l00339"></a>00339 { <a name="l00340"></a>00340 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00341"></a>00341 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>().<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>() == <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a> && <a name="l00342"></a>00342 e.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>()[0].<a class="code" href="group__ExprPkg.html#ga7814e4f55f65c7ca860c637413df5f4d">getKind</a>() == <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9efdc855f3c1477957fb50affec07f8f">EQ</a> && <a name="l00343"></a>00343 <a class="code" href="namespaceCVC3.html#abb990c58eff7370233a56098a732fc46">isArray</a>(<a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#aa1f4b0ec8f008f77bff2bcfac4ce056d">d_theoryArray</a>-><a class="code" href="classCVC3_1_1Theory.html#aa408fe61c3d28f4333b78a3027606bb8" title="Compute (or look up in cache) the base type of e and return the result.">getBaseType</a>(e.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>()[0][0])), <a name="l00344"></a>00344 <span class="stringliteral">"ArrayTheoremProducer::arrayNotEq("</span>+e.<a class="code" href="classCVC3_1_1Theorem.html#ac4b1c9570ffb9cc901627ef2abb9ff77">toString</a>() <a name="l00345"></a>00345 +<span class="stringliteral">"):\n\n expression is ill-formed"</span>); <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <a name="l00348"></a>00348 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> eq = e.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>()[0]; <a name="l00349"></a>00349 <a name="l00350"></a>00350 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00351"></a>00351 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) <a name="l00352"></a>00352 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"array_not_eq"</span>, e.<a class="code" href="classCVC3_1_1Theorem.html#a2d8352c07a756c3837683a27a1e659ef">getProof</a>()); <a name="l00353"></a>00353 <a name="l00354"></a>00354 <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a> arrType = <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#aa1f4b0ec8f008f77bff2bcfac4ce056d">d_theoryArray</a>-><a class="code" href="classCVC3_1_1Theory.html#aa408fe61c3d28f4333b78a3027606bb8" title="Compute (or look up in cache) the base type of e and return the result.">getBaseType</a>(eq[0]); <a name="l00355"></a>00355 <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a> indType = <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a>(arrType.getExpr()[0]); <a name="l00356"></a>00356 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> var = <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#aa1f4b0ec8f008f77bff2bcfac4ce056d">d_theoryArray</a>-><a class="code" href="classCVC3_1_1Theory.html#abc2e30308c9e1f3cf752cfe8d939df1e" title="Access to ExprManager.">getEM</a>()-><a class="code" href="group__EM__Priv.html#ga22dbb23f716cc73378d4c69d564e38dd">newBoundVarExpr</a>(indType); <a name="l00357"></a>00357 eq = <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, eq[0], var).<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(<a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>(<a class="code" href="namespaceCVC3.html#a83fde65f6cf7f65c3e5c02c9a108d781ab012911c4fabb7b8556925a0d61e9c8c">READ</a>, eq[1], var)); <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#ab3afa2471d244b129865548afe06ca89" title="Create a new theorem. See also newRWTheorem() and newReflTheorem()">newTheorem</a>(<a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#aa1f4b0ec8f008f77bff2bcfac4ce056d">d_theoryArray</a>-><a class="code" href="classCVC3_1_1Theory.html#abc2e30308c9e1f3cf752cfe8d939df1e" title="Access to ExprManager.">getEM</a>()-><a class="code" href="group__EM__Priv.html#ga0d2ff7603a249b30b2df4e549607ad6e">newClosureExpr</a>(<a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba3197625a1bb2264943f5a95f236d9973">EXISTS</a>, var, !eq), <a name="l00360"></a>00360 <a class="code" href="classCVC3_1_1Assumptions.html">Assumptions</a>(e), pf); <a name="l00361"></a>00361 } <a name="l00362"></a>00362 <a name="l00363"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#adfcf46071d0e2a7544d76f8bdcba3cf7">00363</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#adfcf46071d0e2a7544d76f8bdcba3cf7">ArrayTheoremProducer::splitOnConstants</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a>& a, <span class="keyword">const</span> std::vector<Expr>& consts) { <a name="l00364"></a>00364 <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> res; <a name="l00365"></a>00365 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> result; <a name="l00366"></a>00366 <a name="l00367"></a>00367 vector<Expr> eq; <a name="l00368"></a>00368 vector<Expr> diseq; <a name="l00369"></a>00369 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < consts.size(); ++ i) { <a name="l00370"></a>00370 eq.push_back(a.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(consts[i])); <a name="l00371"></a>00371 diseq.push_back(a.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(consts[i]).<a class="code" href="group__ExprPkg.html#ga59d07586d68ba39eadd98c86492acdac">notExpr</a>()); <a name="l00372"></a>00372 } <a name="l00373"></a>00373 <a name="l00374"></a>00374 <span class="keywordflow">if</span> (eq.size() == 1) { <a name="l00375"></a>00375 result = eq[0].<a class="code" href="group__ExprPkg.html#gaf310870d783fff343e77ba9c2277c626">orExpr</a>(diseq[0]); <a name="l00376"></a>00376 } <span class="keywordflow">else</span> { <a name="l00377"></a>00377 eq.push_back(<a class="code" href="namespaceCVC3.html#ad4258158bba138eb54b9080af7f8223a">andExpr</a>(diseq)); <a name="l00378"></a>00378 result = <a class="code" href="namespaceCVC3.html#a30f30b6e20c174f21ae63acea8618294">orExpr</a>(eq); <a name="l00379"></a>00379 } <a name="l00380"></a>00380 <a name="l00381"></a>00381 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00382"></a>00382 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) <a name="l00383"></a>00383 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"splitOnConstants"</span>); <a name="l00384"></a>00384 <a name="l00385"></a>00385 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#ab3afa2471d244b129865548afe06ca89" title="Create a new theorem. See also newRWTheorem() and newReflTheorem()">newTheorem</a>(result, <a class="code" href="classCVC3_1_1Assumptions.html#af309a39e2e013cc62b6d94c5812ad86b">Assumptions::emptyAssump</a>(), pf); <a name="l00386"></a>00386 } <a name="l00387"></a>00387 <a name="l00388"></a><a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a845898b86bdae8fcee18b27d181e6bbd">00388</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> <a class="code" href="classCVC3_1_1ArrayTheoremProducer.html#a845898b86bdae8fcee18b27d181e6bbd">ArrayTheoremProducer::propagateIndexDiseq</a>(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>& read1eqread2isFalse) { <a name="l00389"></a>00389 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> read1eqread2 = read1eqread2isFalse.<a class="code" href="classCVC3_1_1Theorem.html#a206c04f39fbbcacef2337148675553f4">getLHS</a>(); <a name="l00390"></a>00390 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> read1 = read1eqread2[0]; <a name="l00391"></a>00391 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> read2 = read1eqread2[1]; <a name="l00392"></a>00392 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> i1 = read1[1]; <a name="l00393"></a>00393 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> i2 = read2[1]; <a name="l00394"></a>00394 <a name="l00395"></a>00395 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00396"></a>00396 <span class="keywordflow">if</span> (<a class="code" href="classCVC3_1_1TheoremProducer.html#aceb1eeebc6b491b3241f463488471f3a" title="Testing whether to generate proofs.">withProof</a>()) <a name="l00397"></a>00397 pf = <a class="code" href="classCVC3_1_1TheoremProducer.html#a9a8e67b1fb33d5dfe428a659d8c66651">newPf</a>(<span class="stringliteral">"propagateIndexDiseq"</span>, read1eqread2isFalse.<a class="code" href="classCVC3_1_1Theorem.html#a2d8352c07a756c3837683a27a1e659ef">getProof</a>()); <a name="l00398"></a>00398 <a name="l00399"></a>00399 <span class="keywordflow">return</span> <a class="code" href="classCVC3_1_1TheoremProducer.html#ab3afa2471d244b129865548afe06ca89" title="Create a new theorem. See also newRWTheorem() and newReflTheorem()">newTheorem</a>(i1.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(i2).<a class="code" href="group__ExprPkg.html#ga59d07586d68ba39eadd98c86492acdac">notExpr</a>(), <a class="code" href="classCVC3_1_1Assumptions.html">Assumptions</a>(read1eqread2isFalse), pf); <a name="l00400"></a>00400 } </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Sep 7 2011 for CVC3 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>