bitvector_theorem_producer.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file bitvector_theorem_producer.h
00004  * \brief TRUSTED implementation of bitvector proof rules
00005  * 
00006  * Author: Vijay Ganesh
00007  * 
00008  * Created: Wed May  5 16:10:28 PST 2004
00009  *
00010  * <hr>
00011  * Copyright (C) 2003 by the Board of Trustees of Leland Stanford
00012  * Junior University and by New York University. 
00013  *
00014  * License to use, copy, modify, sell and/or distribute this software
00015  * and its documentation for any purpose is hereby granted without
00016  * royalty, subject to the terms and conditions defined in the \ref
00017  * LICENSE file provided with this distribution.  In particular:
00018  *
00019  * - The above copyright notice and this permission notice must appear
00020  * in all copies of the software and related documentation.
00021  *
00022  * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
00023  * EXPRESSED OR IMPLIED.  USE IT AT YOUR OWN RISK.
00024  * 
00025  * <hr>
00026  * 
00027  */
00028 /*****************************************************************************/
00029 
00030 #ifndef _CVC_lite__bitvector_theorem_producer_h_
00031 #define _CVC_lite__bitvector_theorem_producer_h_
00032 
00033 #include "bitvector_proof_rules.h"
00034 #include "theorem_producer.h"
00035 
00036 namespace CVCL {
00037 
00038   class TheoryBitvector;
00039 
00040   /*! @brief This class implements proof rules for bitvector
00041    *  normalizers (concatenation normal form, bvplus normal form),
00042    *  bitblaster rules, other relevant rewrite rules for bv arithmetic
00043    *  and word-level operators
00044   */
00045   /*!
00046     Author: Vijay Ganesh, May-August, 2004
00047     
00048   */
00049   class BitvectorTheoremProducer: 
00050     public BitvectorProofRules, public TheoremProducer {
00051   private:
00052     TheoryBitvector* d_theoryBitvector; //! instance of bitvector DP
00053     //! Constant 1-bit bit-vector 0bin0
00054     Expr d_bvZero;
00055     //! Constant 1-bit bit-vector 0bin1
00056     Expr d_bvOne;
00057     //! Return cached constant 0bin0
00058     const Expr& bvZero() const { return d_bvZero; }
00059     //! Return cached constant 0bin1
00060     const Expr& bvOne() const { return d_bvOne; }
00061 
00062     //! Collect all of: a*x1+b*x1 + c*x2-x2 + d*x3 + ~x3 + ~x4 +e into
00063     //!  (a+b, x1) , (c-1 , x2), (d-1, x3), (-1, x4) and the constant e-2.
00064     //! The constant is calculated from the formula -x = ~x+1 (or -x-1=~x).
00065     void collectLikeTermsOfPlus(const Expr& e, 
00066                                 ExprMap<Rational> & likeTerms,
00067                                 Rational & plusConstant);
00068     
00069     //! Collect a single coefficient*var pair into likeTerms.
00070     //! Update the counter of likeTerms[var] += coefficient.
00071     //! Potentially update the constant additive plusConstant.
00072     void collectOneTermOfPlus(const Rational & coefficient,
00073                               const Expr& var,
00074                               ExprMap<Rational> & likeTerms,
00075                               Rational & plusConstant);
00076 
00077     //! Create a vector which will form the next PVPLUS.
00078     //! Use the colleciton of likeTerms, and the constant additive plusConstant
00079     void createNewPlusCollection(const Expr & e,
00080                                  const ExprMap<Rational> & likeTerms,
00081                                  Rational & plusConstant,
00082                                  std::vector<Expr> & result);
00083     
00084     //! Create expression by applying plus to all elements.
00085     //! All elements should be normalized and ready.
00086     //! If there are too few elements, a non BVPLUS expression will be created.
00087     Expr sumNormalizedElements(int bvplusLength,
00088                                const std::vector<Expr>& elements);
00089   public:
00090     //! Constructor: constructs an instance of bitvector DP
00091     BitvectorTheoremProducer(TheoryBitvector* theoryBitvector);
00092     ~BitvectorTheoremProducer() {}
00093 
00094     //ExprMap<Expr> d_bvPlusCarryCacheLeftBV;
00095     //ExprMap<Expr> d_bvPlusCarryCacheRightBV;
00096     
00097     ////////////////////////////////////////////////////////////////////
00098     // Partial Canonization rules
00099     ////////////////////////////////////////////////////////////////////
00100 
00101     ////////////////////////////////////////////////////////////////////
00102     // Bitblasting rules for equations
00103     ////////////////////////////////////////////////////////////////////    
00104     
00105     /*! \param thm input theorem: (e1[i]<=>e2[i])<=>false
00106      *  
00107      *  \result (e1=e2)<=>false
00108      */
00109     Theorem bitvectorFalseRule(const Theorem& thm);
00110 
00111     /*! \param thm input theorem: (~e1[i]<=>e2[i])<=>true
00112      *  
00113      *  \result (e1!=e2)<=>true
00114      */
00115     Theorem bitvectorTrueRule(const Theorem& thm);
00116 
00117     /*! \param e input equation: e1=e2 over bitvector terms 
00118      *  \param f formula over the bits of bitvector variables in e:
00119      *           
00120      *  \result \f[\frac{e_1 = e_2}{\bigwedge_{i=1}^n (e_{1}[i]
00121      *  \iff e_{2}[i]) } \f] where each of \f[ e_{1}[i], e{2}[i] \f] denotes a
00122      *  formula over variables in \f[ e_{1}, e_{2} \f] respectively
00123      */
00124     Theorem bitBlastEqnRule(const Expr& e, const Expr& f);
00125 
00126     /*! \param e : input disequality: e1 != e2 over bitvector terms
00127      *  \param f : formula over the bits of bitvector variables in e:
00128      *           
00129      *  \result \f[\frac{e_1 \not = e_2}{\bigwedge_{i=1}^n ((\neg e_{1}[i])
00130      *  \iff e_{2}[i]) } \f] where each of \f[ e_{1}[i], e{2}[i] \f] denotes a
00131      *  formula over variables in \f[ e_{1}, e_{2} \f] respectively
00132      */
00133     Theorem bitBlastDisEqnRule(const Theorem& e, const Expr& f);
00134 
00135 
00136     ////////////////////////////////////////////////////////////////////
00137     // Bitblasting and rewrite rules for Inequations
00138     ////////////////////////////////////////////////////////////////////
00139 
00140     //! sign extend the input SX(e) appropriately
00141     Theorem signExtendRule(const Expr& e);
00142  
00143     //! Pad the kids of BVLT/BVLE to make their length equal
00144     Theorem padBVLTRule(const Expr& e, int len);
00145  
00146     //! Sign Extend the kids of SBVLT/SBVLE to make their length equal
00147     Theorem padSBVLTRule(const Expr& e, int len);
00148 
00149     /*! input: e0 <=(s) e1. output depends on whether the topbits(MSB) of
00150      *  e0 and e1 are constants. If they are constants then optimizations
00151      *  are done, otherwise the following rule is implemented.
00152      *
00153      *  e0 <=(s) e1 <==> (e0[n-1] AND NOT e1[n-1]) OR 
00154      *                   (e0[n-1] AND e1[n-1] AND e1[n-2:0] <= e0[n-2:0]) OR 
00155      *                   (NOT e0[n-1] AND NOT e1[n-1] AND e0[n-2:0] <= e1[n-2:0])
00156      */
00157     Theorem signBVLTRule(const Expr& e, 
00158                          const Theorem& topBit0, 
00159                          const Theorem& topBit1);
00160 
00161     /*! NOT(e[0][0] < e[0][1]) <==> (e[0][1] <= e[0][0]), 
00162      *  NOT(e[0][0] <= e[0][1]) <==> (e[0][1] < e[0][0])
00163      */    
00164     Theorem notBVLTRule(const Expr& e, int Kind);
00165 
00166     //! if(lhs==rhs) then we have (lhs < rhs <==> false),(lhs <= rhs <==> true)
00167     Theorem lhsEqRhsIneqn(const Expr& e, int kind);
00168 
00169     Theorem bvConstIneqn(const Expr& e, int kind);
00170 
00171     Theorem generalIneqn(const Expr& e, 
00172                          const Theorem& lhs_i, 
00173                          const Theorem& rhs_i, int kind);
00174 
00175     ////////////////////////////////////////////////////////////////////
00176     // Bitblasting rules for terms
00177     ////////////////////////////////////////////////////////////////////
00178 
00179     //! t[i] ==> t[i:i] = 0bin1   or    NOT t[i] ==> t[i:i] = 0bin0
00180     Theorem bitExtractToExtract(const Theorem& thm);
00181     //! t[i] <=> t[i:i][0]   (to use rewriter for simplifying t[i:i])
00182     Theorem bitExtractRewrite(const Expr& x);
00183 
00184     /*! \param x : input1 is bitvector constant 
00185      *  \param i : input2 is extracted bitposition 
00186      *
00187      *  \result \f[ \frac{}{\mathrm{BOOLEXTRACT(x,i)} \iff
00188      *  \mathrm{TRUE}} \f], if bitposition has a 1; \f[
00189      *  \frac{}{\mathrm{BOOLEXTRACT(x,i)} \iff \mathrm{FALSE}} \f], if
00190      *  the bitposition has a 0
00191      */
00192     Theorem bitExtractConstant(const Expr & x, int i);
00193 
00194     /*! \param x : input1 is bitvector binary concatenation
00195      *  \param i : input2 is extracted bitposition
00196      *
00197      *  \result \f[ \frac{}{(t_{[m]}@q_{[n]})[i] \iff (q_{[n]})[i]}
00198      *  \f], where \f[ 0 \geq i \geq n-1 \f], another case of
00199      *  boolextract over concatenation is:
00200      *  \f[\frac{}{(t_{[m]}@q_{[n]})[i] \iff (t_{[m]})[i-n]} \f],
00201      *  where \f[ n \geq i \geq m+n-1 \f]
00202      */
00203     Theorem bitExtractConcatenation(const Expr & x, int i); 
00204 
00205     /*! \param t : input1 is bitvector binary BVMULT. x[0] must be BVCONST
00206      *  \param i : input2 is extracted bitposition
00207      *
00208      *  \result bitblast of BVMULT
00209      */
00210     Theorem bitExtractConstBVMult(const Expr& t, int i);
00211 
00212     /*! \param t : input1 is bitvector binary BVMULT. t[0] must not be BVCONST
00213      *  \param i : input2 is extracted bitposition
00214      *
00215      *  \result bitblast of BVMULT
00216      */
00217     Theorem bitExtractBVMult(const Expr& t, int i);
00218 
00219     /*! \param x : input1 is bitvector extraction [k:j]
00220      *  \param i : input2 is extracted bitposition
00221      *
00222      *  \result \f[ \frac{}{(t_{[n]}[k:j])[i] \iff (t_{[n]})[i+j]}
00223      *  \f], where \f[ 0 \geq j \geq k < n, 0 \geq i < k-j \f]
00224      */
00225     Theorem bitExtractExtraction(const Expr & x, int i);
00226 
00227     /*! \param t1 : input1 is vector of bitblasts of t, from bit i-1 to 0
00228      *  \param t2 : input2 is vector of bitblasts of q, from bit i-1 to 0
00229      *  \param bvPlusTerm : input3 is BVPLUS term: BVPLUS(n,t,q)
00230      *  \param i  : input4 is extracted bitposition
00231      *
00232      *  \result The base case is: \f[
00233      *  \frac{}{(\mathrm{BVPLUS}(n,t,q))[0] \iff t[0] \oplus q[0]}
00234      *  \f], when \f[ 0 < i \leq n-1 \f], we have \f[
00235      *  \frac{}{(\mathrm{BVPLUS}(n,t,q))[i] \iff t[i] \oplus q[i]
00236      *  \oplus c(t,q,i)} \f], where c(t,q,i) is the carry generated
00237      *  by the addition of bits from 0 to i-1
00238      */
00239     Theorem bitExtractBVPlus(const std::vector<Theorem>& t1, 
00240                              const std::vector<Theorem>& t2,
00241                              const Expr& bvPlusTerm, int i);
00242 
00243     Theorem bitExtractBVPlusPreComputed(const Theorem& t1_i, 
00244                                         const Theorem& t2_i,
00245                                         const Expr& bvPlusTerm, 
00246                                         int bitPos,
00247                                         int precomputed);
00248 
00249     /*! \param bvPlusTerm : input1 is bvPlusTerm, a BVPLUS term with
00250      *  arity > 2
00251      *
00252      *  \result : output is iff-Theorem: bvPlusTerm <==> outputTerm,
00253      *  where outputTerm is an equivalent BINARY bvplus.
00254      */
00255     Theorem bvPlusAssociativityRule(const Expr& bvPlusTerm);
00256 
00257     /*! \param x : input1 is bitwise NEGATION
00258      *  \param i : input2 is extracted bitposition
00259      *
00260      *  \result \f[ \frac{}{(\sim t_{[n]})[i] \iff \neg (t_{[n]}[i])}
00261      *  \f]
00262      */
00263     Theorem bitExtractNot(const Expr & x, int i);
00264 
00265     //! Auxiliary function for bitExtractAnd() and bitExtractOr()
00266     Theorem bitExtractBitwise(const Expr& x, int i, int kind);
00267 
00268     /*! \param x : input1 is bitwise AND
00269      *  \param i : input2 is extracted bitposition
00270      *
00271      *  \result \f[ \frac{}{(t_{[n]} \& q_{[n]})[i] \iff (t_{[n]}[i]
00272      *  \wedge q_{[n]}[i])} \f]
00273      */
00274     Theorem bitExtractAnd(const Expr & x, int i);   
00275 
00276     /*! \param x : input1 is bitwise OR
00277      *  \param i : input2 is extracted bitposition
00278      *
00279      *  \result \f[ \frac{}{(t_{[n]} \mid q_{[n]})[i] \iff (t_{[n]}[i]
00280      *  \vee q_{[n]}[i])} \f]
00281      */
00282     Theorem bitExtractOr(const Expr & x, int i);   
00283 
00284     /*! \param x : input1 is bitvector FIXED SHIFT \f[ e_{[n]} \ll k \f]
00285      *  \param i : input2 is extracted bitposition
00286      *
00287      *  \result \f[\frac{}{(e_{[n]} \ll k)[i] \iff \mathrm{FALSE}}
00288      *  \f], if 0 <= i < k. however, if k <= i < n then, result is
00289      *  \f[\frac{}{(e_{[n]} \ll k)[i] \iff e_{[n]}[i]} \f]
00290      */
00291     Theorem bitExtractFixedLeftShift(const Expr & x, int i);   
00292     
00293     Theorem bitExtractFixedRightShift(const Expr & x, int i);   
00294     /*! \param e : input1 is bitvector term
00295      *  \param r : input2 is extracted bitposition
00296      *
00297      *  \result we check if r > bvlength(e). if yes, then return
00298      *  BOOLEXTRACT(e,r) <==> FALSE; else raise soundness
00299      *  exception. (Note: this rule is used in BVPLUS bitblast
00300      *  function)
00301      */
00302     Theorem zeroPaddingRule(const Expr& e, int r);
00303 
00304     Theorem bitExtractSXRule(const Expr& e, int i);
00305 
00306     //! c1=c2 <=> TRUE/FALSE (equality of constant bitvectors)
00307     Theorem eqConst(const Expr& e);
00308     //! |- c1=c2 ==> |- AND(c1[i:i] = c2[i:i]) - expanding equalities into bits
00309     Theorem eqToBits(const Theorem& eq);
00310     //! t<<n = c @ 0bin00...00, takes e == (t<<n)
00311     Theorem leftShiftToConcat(const Expr& e);
00312     //! t>>m = 0bin00...00 @ t[bvlength-1:m], takes e == (t>>n)
00313     Theorem rightShiftToConcat(const Expr& e);
00314     //! k*t = BVPLUS(n, <sum of shifts of t>) -- translation of k*t to BVPLUS
00315     /*! If k = 2^m, return k*t = t\@0...0 */
00316     Theorem constMultToPlus(const Expr& e);
00317     //! 0bin0...0 @ BVPLUS(n, args) = BVPLUS(n+k, args)
00318     /*! where k is the size of the 0bin0...0 */
00319     Theorem bvplusZeroConcatRule(const Expr& e);
00320 
00321 
00322     ///////////////////////////////////////////////////////////////////
00323     /////  Bvplus Normal Form rules
00324     ///////////////////////////////////////////////////////////////////
00325     Theorem zeroCoeffBVMult(const Expr& e);
00326     Theorem oneCoeffBVMult(const Expr& e);
00327     Theorem flipBVMult(const Expr& e);
00328     //! converts e to a bitvector of length rat
00329     Expr pad(int rat, const Expr& e);
00330     Theorem padBVPlus(const Expr& e);
00331     Theorem padBVMult(const Expr& e);
00332     Theorem bvConstMultAssocRule(const Expr& e);
00333     Theorem bvMultAssocRule(const Expr& e);
00334     Theorem bvMultDistRule(const Expr& e);
00335     Theorem flattenBVPlus(const Expr& e);
00336     Theorem combineLikeTermsRule(const Expr& e);
00337     Theorem lhsMinusRhsRule(const Expr& e);
00338     Theorem extractBVMult(const Expr& e);
00339     Theorem extractBVPlus(const Expr& e);
00340     //! ite(c,t1,t2)[i:j] <=> ite(c,t1[i:j],t2[i:j])
00341     Theorem iteExtractRule(const Expr& e);
00342     //! ~ite(c,t1,t2) <=> ite(c,~t1,~t2)
00343     Theorem iteBVnegRule(const Expr& e);
00344 
00345     Theorem bvuminusBVConst(const Expr& e);
00346     Theorem bvuminusBVMult(const Expr& e);
00347     Theorem bvuminusBVUminus(const Expr& e);
00348     Theorem bvuminusVar(const Expr& e);
00349     Theorem bvmultBVUminus(const Expr& e);
00350     //! -t <==> ~t+1
00351     Theorem bvuminusToBVPlus(const Expr& e);
00352     //! -(c1*t1+...+cn*tn) <==> (-(c1*t1)+...+-(cn*tn))
00353     Theorem bvuminusBVPlus(const Expr& e);
00354 
00355 
00356     ///////////////////////////////////////////////////////////////////
00357     /////  Concatenation Normal Form rules
00358     ///////////////////////////////////////////////////////////////////
00359 
00360     // Extraction rules
00361 
00362     //! c1[i:j] = c  (extraction from a constant bitvector)
00363     Theorem extractConst(const Expr& e);
00364     //! t[n-1:0] = t  for n-bit t
00365     Theorem extractWhole(const Expr& e);
00366     //! t[i:j][k:l] = t[k+j:l+j]  (eliminate double extraction)
00367     Theorem extractExtract(const Expr& e);
00368     //! (t1 @ t2)[i:j] = t1[...] @ t2[...]  (push extraction through concat)
00369     Theorem extractConcat(const Expr& e);
00370 
00371     //! Auxiliary function: (t1 op t2)[i:j] = t1[i:j] op t2[i:j] 
00372     Theorem extractBitwise(const Expr& e, int kind, const std::string& name);
00373     //! (t1 & t2)[i:j] = t1[i:j] & t2[i:j]  (push extraction through OR)
00374     Theorem extractAnd(const Expr& e);
00375     //! (t1 | t2)[i:j] = t1[i:j] | t2[i:j]  (push extraction through AND)
00376     Theorem extractOr(const Expr& e);
00377     //! (~t)[i:j] = ~(t[i:j]) (push extraction through NEG)
00378     Theorem extractNeg(const Expr& e);
00379 
00380     // Negation rules
00381 
00382     //! ~c1 = c  (bit-wise negation of a constant bitvector)
00383     Theorem negConst(const Expr& e);
00384     //! ~(t1\@...\@tn) = (~t1)\@...\@(~tn) -- push negation through concat
00385     Theorem negConcat(const Expr& e);
00386     //! ~(~t) = t  -- eliminate double negation
00387     Theorem negNeg(const Expr& e);
00388     //! ~(t1 & t2) <=> ~t1 | ~t2 -- DeMorgan's Laws
00389     Theorem negBVand(const Expr& e);
00390     //! ~(t1 | t2) <=> ~t1 & ~t2 -- DeMorgan's Laws
00391     Theorem negBVor(const Expr& e);
00392 
00393     // Bit-wise AND rules
00394     //! Auxiliary method for andConst() and orConst()
00395     Theorem bitwiseConst(const Expr& e, const std::vector<int>& idxs,
00396                          bool isAnd);
00397     //! Auxiliary method for andConcat() and orConcat()
00398     Theorem bitwiseConcat(const Expr& e, int idx, bool isAnd);
00399     //! Auxiliary method for andFlatten() and orFlatten()
00400     Theorem bitwiseFlatten(const Expr& e, bool isAnd);
00401 
00402     //! c1&c2&t = c&t -- compute bit-wise AND of constant bitvector arguments
00403     /*!\param e is the bit-wise AND expression;
00404      *
00405      * \param idxs are the indices of the constant bitvectors.  There
00406      *  must be at least constant expressions in this rule.
00407      *
00408      * \return Theorem(e==e'), where e' is either a constant
00409      * bitvector, or is a bit-wise AND with a single constant
00410      * bitvector in e'[0].
00411      */
00412     Theorem andConst(const Expr& e, const std::vector<int>& idxs);
00413     //! 0bin0...0 & t = 0bin0...0  -- bit-wise AND with zero bitvector
00414     /*! \param e is the bit-wise AND expr
00415      *  \param idx is the index of the zero bitvector
00416      */
00417     Theorem andZero(const Expr& e, int idx);
00418     Theorem andOne(const Expr& e, const std::vector<int> idxs);
00419     //! ... & (t1\@...\@tk) & ... = (...& t1 &...)\@...\@(...& tk &...)
00420     /*!
00421      * Lifts concatenation to the top of bit-wise AND.  Takes the
00422      * bit-wise AND expression 'e' and the index 'i' of the
00423      * concatenation.
00424      */
00425     Theorem andConcat(const Expr& e, int idx);
00426     //! (t1 & (t2 & t3) & t4) = t1 & t2 & t3 & t4  -- flatten bit-wise AND
00427     /*! Also reorders the terms according to a fixed total ordering */
00428     Theorem andFlatten(const Expr& e);
00429 
00430     // Bit-wise OR rules
00431 
00432     //! c1|c2|t = c|t -- compute bit-wise OR of constant bitvector arguments
00433     /*!\param e is the bit-wise OR expression;
00434      *
00435      * \param idxs are the indices of the constant bitvectors.  There
00436      *  must be at least constant expressions in this rule.
00437      *
00438      * \return Theorem(e==e'), where e' is either a constant
00439      * bitvector, or is a bit-wise OR with a single constant
00440      * bitvector in e'[0].
00441      */
00442     Theorem orConst(const Expr& e, const std::vector<int>& idxs);
00443     //! 0bin1...1 | t = 0bin1...1  -- bit-wise OR with bitvector of 1's
00444     /*! \param e is the bit-wise OR expr
00445      *  \param idx is the index of the bitvector of 1's
00446      */
00447     Theorem orOne(const Expr& e, int idx);
00448     Theorem orZero(const Expr& e, const std::vector<int> idxs);
00449     //! ... | (t1\@...\@tk) | ... = (...| t1 |...)\@...\@(...| tk |...)
00450     /*!
00451      * Lifts concatenation to the top of bit-wise OR.  Takes the
00452      * bit-wise OR expression 'e' and the index 'i' of the
00453      * concatenation.
00454      */
00455     Theorem orConcat(const Expr& e, int idx);
00456     //! (t1 | (t2 | t3) | t4) = t1 | t2 | t3 | t4  -- flatten bit-wise OR
00457     /*! Also reorders the terms according to a fixed total ordering */
00458     Theorem orFlatten(const Expr& e);
00459 
00460     
00461     /*! checks if e is already present in likeTerms without conflicts. 
00462      *  if yes return 1, else{ if conflict return -1 else return 0 }
00463      *  we have conflict if 
00464      *          1. the kind of e is BVNEG, 
00465      *                 and e[0] is already present in likeTerms
00466      *          2. ~e is present in likeTerms already
00467      */
00468     int sameKidCheck(const Expr& e, ExprMap<int>& likeTerms);
00469 
00470     // Concatenation rules
00471 
00472     //! c1\@c2\@...\@cn = c  (concatenation of constant bitvectors)
00473     Theorem concatConst(const Expr& e);
00474     //! Flatten one level of nested concatenation, e.g.: x\@(y\@z)\@w = x\@y\@z\@w
00475     Theorem concatFlatten(const Expr& e);
00476     //! Merge n-ary concat. of adjacent extractions: x[15:8]\@x[7:0] = x[15:0]
00477     Theorem concatMergeExtract(const Expr& e);
00478 
00479     ///////////////////////////////////////////////////////////////////
00480     /////  Modulo arithmetic rules
00481     ///////////////////////////////////////////////////////////////////
00482 
00483     //! BVPLUS(n, c1,c2,...,cn) = c  (bit-vector plus of constant bitvectors)
00484     Theorem bvplusConst(const Expr& e);
00485     /*! @brief n*c1 = c, where n >= 0 (multiplication of a constant
00486      *  bitvector by a non-negative constant) */
00487     Theorem bvmultConst(const Expr& e);
00488 
00489     ///////////////////////////////////////////////////////////////////
00490     /////  Type predicate rules
00491     ///////////////////////////////////////////////////////////////////
00492 
00493     //! |- t=0 OR t=1  for any 1-bit bitvector t
00494     Theorem typePredBit(const Expr& e);
00495 
00496     //! Expand the type predicate wrapper (compute the actual type predicate)
00497     Theorem expandTypePred(const Theorem& tp);
00498 
00499     ////////////////////////////////////////////////////////////////////
00500     // Helper functions
00501     ////////////////////////////////////////////////////////////////////
00502     //! Create Expr from Rational (for convenience)
00503     Expr rat(const Rational& r) { return d_em->newRatExpr(r); }
00504     /*! \param t1BitExtractThms : input1 is vector of bitblasts of t1,
00505      *  from bit i-1 to 0
00506      *
00507      *  \param t2BitExtractThms : input2 is vector of bitblasts of t2,
00508      *  from bit i-1 to 0 
00509      *
00510      *  \param bitPos : input3 is extracted * bitposition
00511      *
00512      *  \result is the expression \f$t1[0] \wedge t2[0]\f$ if
00513      *  bitPos=0. this function is recursive; if bitPos > 0 then the
00514      *  output expression is
00515      *  \f[ (t1[i-1] \wedge t2[i-1])
00516      *     \vee (t1[i-1] \wedge computeCarry(t1,t2,i-1))
00517      *     \vee (t2[i-1] \wedge computeCarry(t1,t2,i-1))
00518      *  \f]
00519      */
00520     Expr computeCarry(const std::vector<Theorem>& t1BitExtractThms,
00521                       const std::vector<Theorem>& t2BitExtractThms,
00522                       int bitPos);
00523 
00524     Expr computeCarryPreComputed(const Theorem& t1_i,
00525                                  const Theorem& t2_i,
00526                                  int bitPos,
00527                                  int precomputedFlag);
00528 
00529     //ExprMap<Expr> carryCache(void);
00530   }; // end of class BitvectorTheoremProducer
00531 } // end of namespace CVCL
00532 
00533 #endif

Generated on Thu Apr 13 16:57:29 2006 for CVC Lite by  doxygen 1.4.4