theory_array.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file theory_array.h
00004  * 
00005  * Author: Clark Barrett
00006  * 
00007  * Created: Wed Feb 26 18:32:06 2003
00008  *
00009  * <hr>
00010  * Copyright (C) 2003 by the Board of Trustees of Leland Stanford
00011  * Junior University and by New York University. 
00012  *
00013  * License to use, copy, modify, sell and/or distribute this software
00014  * and its documentation for any purpose is hereby granted without
00015  * royalty, subject to the terms and conditions defined in the \ref
00016  * LICENSE file provided with this distribution.  In particular:
00017  *
00018  * - The above copyright notice and this permission notice must appear
00019  * in all copies of the software and related documentation.
00020  *
00021  * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
00022  * EXPRESSED OR IMPLIED.  USE IT AT YOUR OWN RISK.
00023  * 
00024  * <hr>
00025  * 
00026  */
00027 /*****************************************************************************/
00028 
00029 #ifndef _cvcl__include__theory_array_h_
00030 #define _cvcl__include__theory_array_h_
00031 
00032 #include "theory.h"
00033 
00034 namespace CVCL {
00035 
00036 class ArrayProofRules;
00037 
00038  typedef enum {
00039    ARRAY = 2000,
00040    READ,
00041    WRITE,
00042    // Array literal [ [type] e ]; creates a constant array holding 'e'
00043    // in all elements: (CONST_ARRAY type e)
00044    ARRAY_LITERAL
00045  } ArrayKinds;
00046 
00047 /*****************************************************************************/
00048 /*!
00049  *\class TheoryArray
00050  *\ingroup Theories
00051  *\brief This theory handles arrays.
00052  *
00053  * Author: Clark Barrett
00054  *
00055  * Created: Thu Feb 27 00:38:20 2003
00056  */
00057 /*****************************************************************************/
00058 class TheoryArray :public Theory {
00059   ArrayProofRules* d_rules;
00060 
00061   //! Backtracking list of array reads, for building concrete models.
00062   CDList<Expr> d_reads;
00063   //! Set of renaming theorems \f$\exists x. t = x\f$ indexed by t
00064   ExprMap<Theorem> d_renameThms;
00065   //! Flag to include array reads to the concrete model
00066   const bool& d_applicationsInModel;
00067 
00068   // Private methods
00069   Theorem renameExpr(const Expr& e);
00070 
00071 public:
00072   TheoryArray(TheoryCore* core);
00073   ~TheoryArray();
00074 
00075   // Trusted method that creates the proof rules class (used in constructor).
00076   // Implemented in array_theorem_producer.cpp
00077   ArrayProofRules* createProofRules();
00078 
00079   // Theory interface
00080   void addSharedTerm(const Expr& e) {}
00081   void assertFact(const Theorem& e) {}
00082   void checkSat(bool fullEffort) {}
00083   Theorem rewrite(const Expr& e);
00084   IF_DEBUG(Theorem rewriteDebug(const Expr& e));
00085   void setup(const Expr& e);
00086   void update(const Theorem& e, const Expr& d);
00087   Theorem solve(const Theorem& e);
00088   void checkType(const Expr& e);
00089   void computeType(const Expr& e);
00090   Type computeBaseType(const Type& t);
00091   void computeModelTerm(const Expr& e, std::vector<Expr>& v);
00092   void computeModel(const Expr& e, std::vector<Expr>& v);
00093   Expr computeTCC(const Expr& e);
00094   virtual Expr parseExprOp(const Expr& e);
00095   ExprStream& print(ExprStream& os, const Expr& e);
00096 };
00097 
00098 // Array testers
00099 inline bool isArray(const Type& t) { return t.getExpr().getKind() == ARRAY; }
00100 inline bool isRead(const Expr& e) { return e.getKind() == READ; }
00101 inline bool isWrite(const Expr& e) { return e.getKind() == WRITE; }
00102 inline bool isArrayLiteral(const Expr& e)
00103   { return (e.isClosure() && e.getKind() == ARRAY_LITERAL); }
00104 
00105 // Array constructors
00106 inline Type arrayType(const Type& type1, const Type& type2)
00107   { return Type(Expr(ARRAY, type1.getExpr(), type2.getExpr())); }
00108 
00109 // Expr read(const Expr& arr, const Expr& index);
00110 // Expr write(const Expr& arr, const Expr& index, const Expr& value);
00111 Expr arrayLiteral(const Expr& ind, const Expr& body);
00112 } // end of namespace CVCL
00113 
00114 #endif

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