<!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: records_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">records_theorem_producer.cpp</div> </div> </div> <div class="contents"> <a href="records__theorem__producer_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00002"></a>00002 <span class="comment">/*****************************************************************************/</span><span class="comment"></span> <a name="l00003"></a>00003 <span class="comment">/*!</span> <a name="l00004"></a>00004 <span class="comment"> * \file records_theorem_producer.cpp</span> <a name="l00005"></a>00005 <span class="comment"> * </span> <a name="l00006"></a>00006 <span class="comment"> * Author: Daniel Wichs</span> <a name="l00007"></a>00007 <span class="comment"> * </span> <a name="l00008"></a>00008 <span class="comment"> * Created: Jul 22 22:59:07 GMT 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><a class="code" href="records__theorem__producer_8cpp.html#a8663c36bbf15bb5a0dcb01b97897fa95">00021</a> <span class="preprocessor">#define _CVC3_TRUSTED_</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="records__theorem__producer_8h.html">records_theorem_producer.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="theory__records_8h.html">theory_records.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="theory__core_8h.html">theory_core.h</a>"</span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="keyword">using namespace </span>std; <a name="l00029"></a>00029 <span class="keyword">using namespace </span>CVC3; <a name="l00030"></a>00030 <a name="l00031"></a>00031 <a name="l00032"></a><a class="code" href="classCVC3_1_1TheoryRecords.html#acefe38731a5693d2c2b7d630088ee708">00032</a> <a class="code" href="classCVC3_1_1RecordsProofRules.html">RecordsProofRules</a>* TheoryRecords::createProofRules() { <a name="l00033"></a>00033 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classCVC3_1_1RecordsTheoremProducer.html">RecordsTheoremProducer</a>(theoryCore()->getTM(), <span class="keyword">this</span>); <a name="l00034"></a>00034 } <a name="l00035"></a>00035 <a name="l00036"></a>00036 <a name="l00037"></a><a class="code" href="records__theorem__producer_8cpp.html#a79f2713d570c7065f61a160134ea765b">00037</a> <span class="preprocessor">#define CLASS_NAME "CVC3::RecordsTheoremProducer"</span> <a name="l00038"></a>00038 <span class="preprocessor"></span><span class="comment"></span> <a name="l00039"></a>00039 <span class="comment">//! ==> (SELECT (LITERAL v1 ... vi ...) fi) = vi</span> <a name="l00040"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#a6daf5a4886315133bf830d52c6fb010d">00040</a> <span class="comment"></span><a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::rewriteLitSelect(<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="l00041"></a>00041 <a name="l00042"></a>00042 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00043"></a>00043 <span class="keywordflow">if</span>(withProof()) <a name="l00044"></a>00044 pf = newPf(<span class="stringliteral">"rewrite_record_literal_select"</span>, e); <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keywordtype">int</span> index=0; <a name="l00047"></a>00047 <span class="keywordflow">switch</span>(e.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>()) <a name="l00048"></a>00048 { <a name="l00049"></a>00049 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aa9efca25c90a81dcfde159d13a86d9f77">RECORD_SELECT</a>: { <a name="l00050"></a>00050 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00051"></a>00051 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e[0].getOpKind()==<a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aadba2f0df8bf015c12bca0efbd077db7d">RECORD</a>, <a name="l00052"></a>00052 <span class="stringliteral">"expected RECORD child:\n"</span> <a name="l00053"></a>00053 +e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00054"></a>00054 } <a name="l00055"></a>00055 index = getFieldIndex(e[0], getField(e)); <a name="l00056"></a>00056 <span class="keywordflow">break</span>; <a name="l00057"></a>00057 } <a name="l00058"></a>00058 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aae26285c151f7ee2c084c68848a88dde0">TUPLE_SELECT</a>: { <a name="l00059"></a>00059 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00060"></a>00060 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e[0].getOpKind()==<a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aade6582602ff5a8d049aa0dd26e50a30e">TUPLE</a>, <a name="l00061"></a>00061 <span class="stringliteral">"expected TUPLE child:\n"</span> <a name="l00062"></a>00062 +e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00063"></a>00063 } <a name="l00064"></a>00064 index = getIndex(e); <a name="l00065"></a>00065 <span class="keywordflow">break</span>; <a name="l00066"></a>00066 } <a name="l00067"></a>00067 <span class="keywordflow">default</span>: { <a name="l00068"></a>00068 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00069"></a>00069 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(<span class="keyword">false</span>, <span class="stringliteral">"expected TUPLE_SELECT or RECORD_SELECT kind"</span> <a name="l00070"></a>00070 + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00071"></a>00071 } <a name="l00072"></a>00072 } <a name="l00073"></a>00073 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00074"></a>00074 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(index!=-1 && index<e[0].arity(), <a name="l00075"></a>00075 <span class="stringliteral">"selected field did not appear in literal"</span> + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00076"></a>00076 } <a name="l00077"></a>00077 <span class="keywordflow">return</span> newRWTheorem(e, e[0][index], Assumptions::emptyAssump(), pf); <a name="l00078"></a>00078 }<span class="comment"></span> <a name="l00079"></a>00079 <span class="comment">//! ==> (RECORD_SELECT (RECORD_UPDATE r fi vi) fj) = vi</span> <a name="l00080"></a>00080 <span class="comment"></span><span class="comment">//iff j=i, r.fj otherwise (and same for tuples)</span> <a name="l00081"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#aa5d335a5684178e3553a9ce69a265046">00081</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::rewriteUpdateSelect(<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="l00082"></a>00082 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00083"></a>00083 <span class="keywordflow">switch</span>(e.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>()) { <a name="l00084"></a>00084 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aa9efca25c90a81dcfde159d13a86d9f77">RECORD_SELECT</a>: { <a name="l00085"></a>00085 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00086"></a>00086 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e[0].getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aac6dfe36442cddb6cb993669fec8a51c5">RECORD_UPDATE</a>, <a name="l00087"></a>00087 <span class="stringliteral">"expected RECORD_UPDATE child"</span> + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00088"></a>00088 <span class="keywordflow">if</span>(withProof()) <a name="l00089"></a>00089 pf = newPf(<span class="stringliteral">"rewrite_record_update_and_select"</span>, e); <a name="l00090"></a>00090 <span class="keywordflow">if</span>(getField(e) == getField(e[0])) <a name="l00091"></a>00091 <span class="keywordflow">return</span> newRWTheorem(e, e[0][1], Assumptions::emptyAssump(), pf); <a name="l00092"></a>00092 <span class="keywordflow">else</span> <a name="l00093"></a>00093 <span class="keywordflow">return</span> newRWTheorem(e, recordSelect(e[0][0], getField(e)), Assumptions::emptyAssump(), pf); <a name="l00094"></a>00094 <span class="keywordflow">break</span>; <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aae26285c151f7ee2c084c68848a88dde0">TUPLE_SELECT</a>: { <a name="l00097"></a>00097 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00098"></a>00098 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e[0].getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aab6ace4f4d51d446b07d2f6f486f5aef8">TUPLE_UPDATE</a>, <a name="l00099"></a>00099 <span class="stringliteral">"expected TUPLE_UPDATE child"</span> + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00100"></a>00100 <span class="keywordflow">if</span>(withProof()) <a name="l00101"></a>00101 pf = newPf(<span class="stringliteral">"rewrite_record_update_and_select"</span>, e); <a name="l00102"></a>00102 <span class="keywordflow">if</span>(getIndex(e) == getIndex(e[0])) <a name="l00103"></a>00103 <span class="keywordflow">return</span> newRWTheorem(e, e[0][1], Assumptions::emptyAssump(), pf); <a name="l00104"></a>00104 <span class="keywordflow">else</span> <a name="l00105"></a>00105 <span class="keywordflow">return</span> newRWTheorem(e, tupleSelect(e[0][0], getIndex(e)), Assumptions::emptyAssump(), pf); <a name="l00106"></a>00106 <span class="keywordflow">break</span>; <a name="l00107"></a>00107 } <a name="l00108"></a>00108 <span class="keywordflow">default</span>: <a name="l00109"></a>00109 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00110"></a>00110 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(<span class="keyword">false</span>, <span class="stringliteral">"expected RECORD_SELECT or TUPLE_SELECT kind"</span> <a name="l00111"></a>00111 + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00112"></a>00112 <span class="keywordflow">break</span>; <a name="l00113"></a>00113 } <a name="l00114"></a>00114 <span class="comment">//to avoid warnings</span> <a name="l00115"></a>00115 <span class="keywordflow">return</span> newRWTheorem(e, e, Assumptions::emptyAssump(), pf); <a name="l00116"></a>00116 } <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="comment"></span> <a name="l00119"></a>00119 <span class="comment">//! ==> (RECORD_UPDATE (RECORD (f1 v1) ... (fi vi) ...) fi v') =(RECORD (f1 v1) ... (fi v') ...) and same for tuples.</span> <a name="l00120"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#ae794bafd39256699bda95e85e01ffd39">00120</a> <span class="comment"></span><a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::rewriteLitUpdate(<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="l00121"></a>00121 <span class="keywordtype">int</span> index =0; <a name="l00122"></a>00122 <span class="keywordflow">switch</span>(e.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>()) { <a name="l00123"></a>00123 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aac6dfe36442cddb6cb993669fec8a51c5">RECORD_UPDATE</a>: { <a name="l00124"></a>00124 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00125"></a>00125 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e[0].getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aadba2f0df8bf015c12bca0efbd077db7d">RECORD</a>, <a name="l00126"></a>00126 <span class="stringliteral">"expected a RECORD: e = "</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00127"></a>00127 index = getFieldIndex(e[0], getField(e)); <a name="l00128"></a>00128 <span class="keywordflow">break</span>; <a name="l00129"></a>00129 } <a name="l00130"></a>00130 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aab6ace4f4d51d446b07d2f6f486f5aef8">TUPLE_UPDATE</a>: { <a name="l00131"></a>00131 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00132"></a>00132 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e[0].getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aade6582602ff5a8d049aa0dd26e50a30e">TUPLE</a>, <a name="l00133"></a>00133 <span class="stringliteral">"expected a TUPLE: e = "</span>+ e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00134"></a>00134 index = getIndex(e); <a name="l00135"></a>00135 <span class="keywordflow">break</span>; <a name="l00136"></a>00136 } <a name="l00137"></a>00137 <span class="keywordflow">default</span>: <a name="l00138"></a>00138 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00139"></a>00139 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(<span class="keyword">false</span>, <span class="stringliteral">"expected RECORD_UPDATE or TUPLE_UPDATE kind"</span> <a name="l00140"></a>00140 + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00141"></a>00141 } <a name="l00142"></a>00142 <a name="l00143"></a>00143 vector<Expr> fieldVals= e[0].<a class="code" href="group__ExprPkg.html#ga1e18ae89889e781591eb2874a4196b73">getKids</a>(); <a name="l00144"></a>00144 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00145"></a>00145 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(index!=-1 && index<e[0].arity(), <a name="l00146"></a>00146 <span class="stringliteral">"update field does not appear in literal"</span> <a name="l00147"></a>00147 + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00148"></a>00148 fieldVals[index] = e[1]; <a name="l00149"></a>00149 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00150"></a>00150 <span class="keywordflow">if</span>(withProof()) <a name="l00151"></a>00151 pf= newPf(<span class="stringliteral">"rewrite record_literal_update"</span>, e); <a name="l00152"></a>00152 <span class="keywordflow">if</span>(e.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aac6dfe36442cddb6cb993669fec8a51c5">RECORD_UPDATE</a>) <a name="l00153"></a>00153 <span class="keywordflow">return</span> newRWTheorem(e, recordExpr(getFields(e[0]), fieldVals), Assumptions::emptyAssump(), pf); <a name="l00154"></a>00154 <span class="keywordflow">else</span> <a name="l00155"></a>00155 <span class="keywordflow">return</span> newRWTheorem(e, tupleExpr(fieldVals), Assumptions::emptyAssump(), pf); <a name="l00156"></a>00156 } <a name="l00157"></a>00157 <a name="l00158"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#abf649085219bc8a7d787cb6dff3faa02">00158</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::expandNeq(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>& neqThrm) <a name="l00159"></a>00159 { <a name="l00160"></a>00160 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e = neqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>(); <a name="l00161"></a>00161 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00162"></a>00162 <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="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba0378ebc895849163b249d0b330257dd6">NOT</a>, <span class="stringliteral">"expected not expression"</span> + e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00163"></a>00163 e=e[0]; <a name="l00164"></a>00164 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> e0 = e[0].<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#a0bc1eebf8dbd9d2880e1f18d7804e5c2">getExpr</a>() , e1 = e[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#a0bc1eebf8dbd9d2880e1f18d7804e5c2">getExpr</a>(); <a name="l00165"></a>00165 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00166"></a>00166 { <a name="l00167"></a>00167 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e.getKind() == <a class="code" href="kinds_8h.html#aa10c9e8951b8ccf714a59ec321bdac5ba9efdc855f3c1477957fb50affec07f8f">EQ</a>, <a name="l00168"></a>00168 <span class="stringliteral">"equation expression expected \n"</span> + e.toString()); <a name="l00169"></a>00169 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e0.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>()==e1.arity() && e0.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>() == e1.getOpKind(), <a name="l00170"></a>00170 <span class="stringliteral">"equation types mismatch \n"</span> + e.toString()); <a name="l00171"></a>00171 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e0.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aa5b98e4e73895afeec2e8904eb5c3effa">RECORD_TYPE</a> || e0.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aaabdfca29cc90169c7689e6a05e5cc316">TUPLE_TYPE</a>, <a name="l00172"></a>00172 <span class="stringliteral">"expected TUPLES or RECORDS \n"</span> + e.toString()); <a name="l00173"></a>00173 } <a name="l00174"></a>00174 std::vector<Expr> orChildren; <a name="l00175"></a>00175 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i<e0.<a class="code" href="group__ExprPkg.html#ga28b901d05e52a5c646f83a95cc74f94b">arity</a>();i++) <a name="l00176"></a>00176 { <a name="l00177"></a>00177 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> lhs, rhs; <a name="l00178"></a>00178 <span class="keywordflow">switch</span>(e0.<a class="code" href="group__ExprPkg.html#gad036a3a3597d590ca6ee694505c6e1cd" title="Get kind of operator (for APPLY Exprs only)">getOpKind</a>()) { <a name="l00179"></a>00179 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aa5b98e4e73895afeec2e8904eb5c3effa">RECORD_TYPE</a>: { <a name="l00180"></a>00180 <span class="keyword">const</span> <span class="keywordtype">string</span>& field(getField(e0, i)); <a name="l00181"></a>00181 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(field == getField(e1, i), <a name="l00182"></a>00182 <span class="stringliteral">"equation types mismatch \n"</span> + neqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>().<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00183"></a>00183 lhs = recordSelect(e[0], field); <a name="l00184"></a>00184 rhs = recordSelect(e[1], field); <a name="l00185"></a>00185 <span class="keywordflow">break</span>; <a name="l00186"></a>00186 } <a name="l00187"></a>00187 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aaabdfca29cc90169c7689e6a05e5cc316">TUPLE_TYPE</a>: { <a name="l00188"></a>00188 lhs = tupleSelect(e[0], i); <a name="l00189"></a>00189 rhs = tupleSelect(e[1], i); <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 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<span class="keyword">false</span>, <span class="stringliteral">"RecordsTheoremProducer::expandNeq: "</span> <a name="l00194"></a>00194 <span class="stringliteral">"Type must be TUPLE or RECORD: "</span>+e0.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00195"></a>00195 } <a name="l00196"></a>00196 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> eq = lhs.<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>()? lhs.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(rhs) : lhs.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(rhs); <a name="l00197"></a>00197 orChildren.push_back(!eq); <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00200"></a>00200 <span class="keywordflow">if</span>(withProof()) <a name="l00201"></a>00201 pf= newPf(<span class="stringliteral">"rewrite_record_literal_update"</span>, e, neqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a2d8352c07a756c3837683a27a1e659ef">getProof</a>()); <a name="l00202"></a>00202 <span class="keywordflow">return</span> newTheorem(<a class="code" href="namespaceCVC3.html#a30f30b6e20c174f21ae63acea8618294">orExpr</a>(orChildren), neqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a5e9ab00a613df15cc02f55edb55a67b3">getAssumptionsRef</a>(), pf); <a name="l00203"></a>00203 } <a name="l00204"></a>00204 <a name="l00205"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#ab544bdb188ab71aee6632e22cd1e1384">00205</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::expandEq(<span class="keyword">const</span> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a>& eqThrm) <a name="l00206"></a>00206 { <a name="l00207"></a>00207 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> lhs(eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a206c04f39fbbcacef2337148675553f4">getLHS</a>()), e0 = lhs.<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#a0bc1eebf8dbd9d2880e1f18d7804e5c2">getExpr</a>(); <a name="l00208"></a>00208 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> rhs(eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a97d957fcbf9094480851b1d2e5d3729f">getRHS</a>()), e1 = rhs.<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#a0bc1eebf8dbd9d2880e1f18d7804e5c2">getExpr</a>(); <a name="l00209"></a>00209 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) <a name="l00210"></a>00210 { <a name="l00211"></a>00211 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a362c1d70e03803d804bbe300e5f6dc87">isRewrite</a>(), <a name="l00212"></a>00212 <span class="stringliteral">"equation expression expected \n"</span> <a name="l00213"></a>00213 + eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>().<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00214"></a>00214 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e0.arity() == e1.arity() && e0.getOpKind() == e1.getOpKind(), <a name="l00215"></a>00215 <span class="stringliteral">"equation types mismatch \n"</span> + eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>().<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00216"></a>00216 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(e0.getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aa5b98e4e73895afeec2e8904eb5c3effa">RECORD_TYPE</a> || e0.getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aaabdfca29cc90169c7689e6a05e5cc316">TUPLE_TYPE</a>, <a name="l00217"></a>00217 <span class="stringliteral">"expected TUPLES or RECORDS \n"</span> + eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>().<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00218"></a>00218 } <a name="l00219"></a>00219 std::vector<Expr> andChildren; <a name="l00220"></a>00220 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i<e0.arity();i++) <a name="l00221"></a>00221 { <a name="l00222"></a>00222 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> lhs1, rhs1; <a name="l00223"></a>00223 <span class="keywordflow">switch</span>(e0.getOpKind()) { <a name="l00224"></a>00224 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aa5b98e4e73895afeec2e8904eb5c3effa">RECORD_TYPE</a>: { <a name="l00225"></a>00225 <span class="keyword">const</span> vector<Expr>& fields(getFields(e0)); <a name="l00226"></a>00226 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(fields[i].getString() == getField(e1, i), <a name="l00227"></a>00227 <span class="stringliteral">"equation types mismatch \n"</span> + eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>().<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()); <a name="l00228"></a>00228 lhs1 = recordSelect(lhs, fields[i].getString()); <a name="l00229"></a>00229 rhs1 = recordSelect(rhs, fields[i].getString()); <a name="l00230"></a>00230 <span class="keywordflow">break</span>; <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <span class="keywordflow">case</span> <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aaabdfca29cc90169c7689e6a05e5cc316">TUPLE_TYPE</a>: { <a name="l00233"></a>00233 lhs1 = tupleSelect(lhs, i); <a name="l00234"></a>00234 rhs1 = tupleSelect(rhs, i); <a name="l00235"></a>00235 <span class="keywordflow">break</span>; <a name="l00236"></a>00236 } <a name="l00237"></a>00237 <span class="keywordflow">default</span>: <a name="l00238"></a>00238 <a class="code" href="debug_8h.html#a40dac3bdb2166ffc852ee8b1489d2b56">DebugAssert</a>(<span class="keyword">false</span>, <span class="stringliteral">"RecordsTheoremProducer::expandEq(): "</span> <a name="l00239"></a>00239 <span class="stringliteral">"Type must be TUPLE or RECORD: "</span>+e0.toString()); <a name="l00240"></a>00240 } <a name="l00241"></a>00241 <a class="code" href="classCVC3_1_1Expr.html" title="Data structure of expressions in CVC3.">Expr</a> eq = lhs1.<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>()? lhs1.<a class="code" href="group__ExprPkg.html#gaae017ca8e68af655ba285c985dd9fba5">iffExpr</a>(rhs1) : lhs1.<a class="code" href="group__ExprPkg.html#gacb48495ca445c895f95d0c3c1ae2070b">eqExpr</a>(rhs1); <a name="l00242"></a>00242 andChildren.push_back(eq); <a name="l00243"></a>00243 } <a name="l00244"></a>00244 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00245"></a>00245 <span class="keywordflow">if</span>(withProof()) <a name="l00246"></a>00246 pf= newPf(<span class="stringliteral">"rewrite record_literal_update"</span>, <a name="l00247"></a>00247 eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#af2b97ae5d270ddf1013bf4f3867a7e5d">getExpr</a>(), eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a2d8352c07a756c3837683a27a1e659ef">getProof</a>()); <a name="l00248"></a>00248 <span class="keywordflow">return</span> newTheorem(<a class="code" href="namespaceCVC3.html#ad4258158bba138eb54b9080af7f8223a">andExpr</a>(andChildren), eqThrm.<a class="code" href="classCVC3_1_1Theorem.html#a5e9ab00a613df15cc02f55edb55a67b3">getAssumptionsRef</a>() , pf); <a name="l00249"></a>00249 } <a name="l00250"></a>00250 <a name="l00251"></a>00251 <a name="l00252"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#af56c2526f560cb39a139abe6cf2ac695">00252</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::expandRecord(<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="l00253"></a>00253 <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a> tp(d_theoryRecords->getBaseType(e)); <a name="l00254"></a>00254 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00255"></a>00255 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(isRecordType(tp), <a name="l00256"></a>00256 <span class="stringliteral">"expandRecord("</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()+<span class="stringliteral">"): not a record type"</span>); <a name="l00257"></a>00257 } <a name="l00258"></a>00258 <span class="keyword">const</span> vector<Expr>& fields = getFields(tp.getExpr()); <a name="l00259"></a>00259 vector<Expr> kids; <a name="l00260"></a>00260 <span class="keywordflow">for</span>(vector<Expr>::const_iterator i=fields.begin(), iend=fields.end(); <a name="l00261"></a>00261 i!=iend; ++i) <a name="l00262"></a>00262 kids.push_back(recordSelect(e, (*i).<a class="code" href="group__ExprPkg.html#ga5e679ab39ad8166c3c027afee9004c26">getString</a>())); <a name="l00263"></a>00263 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00264"></a>00264 <span class="keywordflow">if</span>(withProof()) pf = newPf(<span class="stringliteral">"expand_record"</span>, e); <a name="l00265"></a>00265 <span class="keywordflow">return</span> newRWTheorem(e, recordExpr(fields, kids), Assumptions::emptyAssump(), pf); <a name="l00266"></a>00266 } <a name="l00267"></a>00267 <a name="l00268"></a>00268 <a name="l00269"></a><a class="code" href="classCVC3_1_1RecordsTheoremProducer.html#a01aaea1cec3e1ccdbbdf15b597d966f4">00269</a> <a class="code" href="classCVC3_1_1Theorem.html">Theorem</a> RecordsTheoremProducer::expandTuple(<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="l00270"></a>00270 <a class="code" href="classCVC3_1_1Type.html" title="MS C++ specific settings.">Type</a> tp(d_theoryRecords->getBaseType(e)); <a name="l00271"></a>00271 <span class="keywordflow">if</span>(<a class="code" href="theorem__producer_8h.html#a74a97b789e1a9e6c016291960c657445">CHECK_PROOFS</a>) { <a name="l00272"></a>00272 <a class="code" href="theorem__producer_8h.html#a03dbe872f723d32fd975528f811d646e">CHECK_SOUND</a>(tp.getExpr().getOpKind() == <a class="code" href="namespaceCVC3.html#ad12649859b64bd3aed25985b147c078aaabdfca29cc90169c7689e6a05e5cc316">TUPLE_TYPE</a>, <a name="l00273"></a>00273 <span class="stringliteral">"expandTuple("</span>+e.<a class="code" href="group__ExprPkg.html#gaf3028bb1619f8cc69b66ec712e1adb54" title="Print the expression to a string.">toString</a>()+<span class="stringliteral">"): not a tuple type"</span>); <a name="l00274"></a>00274 } <a name="l00275"></a>00275 <span class="keywordtype">int</span> size(tp.arity()); <a name="l00276"></a>00276 vector<Expr> kids; <a name="l00277"></a>00277 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i<size; ++i) <a name="l00278"></a>00278 kids.push_back(tupleSelect(e, i)); <a name="l00279"></a>00279 <a class="code" href="classCVC3_1_1Proof.html">Proof</a> pf; <a name="l00280"></a>00280 <span class="keywordflow">if</span>(withProof()) pf = newPf(<span class="stringliteral">"expand_tuple"</span>, e); <a name="l00281"></a>00281 <span class="keywordflow">return</span> newRWTheorem(e, tupleExpr(kids), Assumptions::emptyAssump(), pf); <a name="l00282"></a>00282 } </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>