#ifndef AST_H
#define AST_H
-#include "TopLevel.h"
+#include "UsefulDefs.h"
#include "ASTNode.h"
#include "ASTInternal.h"
#include "ASTInterior.h"
#define ASTBVCONST_H
namespace BEEV
{
- class BeevMgr;
+ class STPMgr;
void FatalError(const char * str);
/******************************************************************
******************************************************************/
class ASTBVConst: public ASTInternal
{
- friend class BeevMgr;
+ friend class STPMgr;
friend class ASTNode;
friend class ASTNodeHasher;
friend class ASTNodeEqual;
#ifndef ASTINTERIOR_H
#define ASTINTERIOR_H
-#include "TopLevel.h"
+#include "UsefulDefs.h"
namespace BEEV
{
class ASTNode;
- class BeevMgr;
+ class STPMgr;
typedef vector<ASTNode> ASTVec;
/******************************************************************
class ASTInterior: public ASTInternal
{
- friend class BeevMgr;
+ friend class STPMgr;
friend class ASTNodeHasher;
friend class ASTNodeEqual;
}
} //End of Destructor()
- BeevMgr* ASTNode::GetBeevMgr() const
+ STPMgr* ASTNode::GetSTPMgr() const
{
return GlobalSTP->bm;
- } //End of GetBeevMgr()
+ } //End of GetSTPMgr()
// Checks if the node has alreadybeen printed or not
bool ASTNode::IsAlreadyPrinted() const
{
- BeevMgr * bm = GetBeevMgr();
+ STPMgr * bm = GetSTPMgr();
return (bm->AlreadyPrintedSet.find(*this) !=
bm->AlreadyPrintedSet.end());
} //End of IsAlreadyPrinted()
// Mark the node as printed if it has been already printed
void ASTNode::MarkAlreadyPrinted() const
{
- BeevMgr * bm = GetBeevMgr();
+ STPMgr * bm = GetSTPMgr();
bm->AlreadyPrintedSet.insert(*this);
} //End of MarkAlreadyPrinted()
return;
//FIXME: this is ugly.
- BeevMgr * bm = GetBeevMgr();
+ STPMgr * bm = GetSTPMgr();
const ASTVec &c = this->GetChildren();
for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend; it++)
{
******************************************************************/
class ASTNode
{
- friend class BeevMgr;
+ friend class STPMgr;
friend class CNFMgr;
friend class ASTInterior;
friend class vector<ASTNode>;
// Assignment (for ref counting)
ASTNode& operator=(const ASTNode& n);
- //Get the BeevMgr pointer. FIXME: Currently uses a global
+ //Get the STPMgr pointer. FIXME: Currently uses a global
//ptr. BAD!!
- BeevMgr* GetBeevMgr() const;
+ STPMgr* GetSTPMgr() const;
// Access node number
int GetNodeNum() const;
******************************************************************/
class ASTSymbol : public ASTInternal
{
- friend class BeevMgr;
+ friend class STPMgr;
friend class ASTNode;
friend class ASTNodeHasher;
friend class ASTNodeEqual;
********************************************************/
ASTNode ArrayTransformer::TransformFormula(const ASTNode& form)
{
- BeevMgr* bm = form.GetBeevMgr();
+ STPMgr* bm = form.GetSTPMgr();
assert(TransformMap != NULL);
{
assert(TransformMap != NULL);
- BeevMgr* bm = inputterm.GetBeevMgr();
-
ASTNode result;
ASTNode term = inputterm;
-
Kind k = term.GetKind();
if (!is_Term_kind(k))
FatalError("TransformTerm: Illegal kind: You have input a nonterm:", inputterm, k);
Simplifier * simp;
// Ptr to STPManager
- BeevMgr * bm;
+ STPMgr * bm;
// Ptr to class that records the runtimes for various parts of the
// code
****************************************************************/
// Constructor
- ArrayTransformer(BeevMgr * bm, Simplifier* s) :
+ ArrayTransformer(STPMgr * bm, Simplifier* s) :
Arrayread_SymbolMap(INITIAL_TABLE_SIZE),
Introduced_SymbolsSet(INITIAL_TABLE_SIZE),
bm(bm),
#include <algorithm>
#include <assert.h>
-#define INITIAL_TABLE_SIZE 100
+#define INITIAL_TABLE_SIZE 1000
#ifdef EXT_HASH_MAP
#include <ext/hash_set>
* Important classes declared as part of AST datastructures *
* *
******************************************************************/
- class BeevMgr;
+ class STPMgr;
class ASTNode;
class ASTInternal;
class ASTInterior;
//Acceps a query, calls the SAT solver and generates Valid/InValid.
//if returned 0 then input is INVALID if returned 1 then input is
//VALID if returned 2 then UNDECIDED
- SOLVER_RETURN_TYPE STP::TopLevelSATAux(const ASTNode& inputasserts_and_query)
+ SOLVER_RETURN_TYPE STP::TopLevelSTPAux(const ASTNode& inputasserts_and_query)
{
ASTNode inputToSAT = inputasserts_and_query;
ASTNode orig_input = inputToSAT;
return res;
}
- FatalError("TopLevelSATAux: reached the end without proper conclusion:"
+ FatalError("TopLevelSTPAux: reached the end without proper conclusion:"
"either a divide by zero in the input or a bug in STP");
//bogus return to make the compiler shut up
return SOLVER_ERROR;
- } //End of TopLevelSATAux
+ } //End of TopLevelSTPAux
+
+ void STP::ClearAllTables(void)
+ {
+// //Clear STPManager caches
+
+// //Clear ArrayTransformer caches
+
+// //Clear Simplifier caches
+
+// //Clear BVSolver caches
+
+// //Clear AbsRefine_CounterExample caches
+
+// //clear all tables before calling toplevelsat
+// //_ASTNode_to_SATVar.clear();
+// //_SATVar_to_AST.clear();
+
+// // for (ASTtoBitvectorMap::iterator it = _ASTNode_to_Bitvector.begin(),
+// // itend = _ASTNode_to_Bitvector.end(); it != itend; it++)
+// // {
+// // (it->second)->clear();
+// // delete (it->second);
+// // }
+// // _ASTNode_to_Bitvector.clear();
+
+// NodeLetVarMap.clear();
+// NodeLetVarMap1.clear();
+// PLPrintNodeSet.clear();
+// AlreadyPrintedSet.clear();
+// //ReferenceCount->clear();
+// //_arrayread_ite.clear();
+// //_introduced_symbols.clear();
+// //CounterExampleMap.clear();
+// //ComputeFormulaMap.clear();
+// StatInfoSet.clear();
+
+// _asserts.clear();
+
+// // for (ASTNodeToVecMap::iterator iset =
+// // _arrayname_readindices.begin(), iset_end =
+// // _arrayname_readindices.end(); iset != iset_end; iset++) {
+// // iset->second.clear(); }
+// // _arrayname_readindices.clear();
+
+// _interior_unique_table.clear();
+// _symbol_unique_table->clear();
+// _bvconst_unique_table.clear();
+ }
+
+ void STP::ClearAllCaches(void)
+ {
+// //clear all tables before calling toplevelsat
+// //_ASTNode_to_SATVar.clear();
+// //_SATVar_to_AST.clear();
+
+// // for (ASTtoBitvectorMap::iterator it = _ASTNode_to_Bitvector.begin(),
+// // itend = _ASTNode_to_Bitvector.end(); it != itend; it++)
+// // {
+// // (it->second)->clear();
+// // delete (it->second);
+// // }
+// // _ASTNode_to_Bitvector.clear();
+
+// NodeLetVarMap.clear();
+// NodeLetVarMap1.clear();
+// PLPrintNodeSet.clear();
+// AlreadyPrintedSet.clear();
+// // SimplifyMap->clear();
+// // SimplifyNegMap->clear();
+// // ReferenceCount->clear();
+// // SolverMap.clear();
+// //AlwaysTrueFormMap.clear();
+// //_arrayread_ite.clear();
+// //_arrayread_symbol.clear();
+// //_introduced_symbols.clear();
+// //CounterExampleMap.clear();
+// //ComputeFormulaMap.clear();
+// StatInfoSet.clear();
+
+// // for (ASTNodeToVecMap::iterator iset = _arrayname_readindices.begin(), iset_end = _arrayname_readindices.end(); iset != iset_end; iset++)
+// // {
+// // iset->second.clear();
+// // }
+
+// // _arrayname_readindices.clear();
+// //_interior_unique_table.clear();
+// //_symbol_unique_table.clear();
+// //_bvconst_unique_table.clear();
+ }
}; //end of namespace
{
class STP {
public:
- BeevMgr * bm;
+ STPMgr * bm;
Simplifier * simp;
BVSolver * bvsolver;
ArrayTransformer * arrayTransformer;
AbsRefine_CounterExample * Ctr_Example;
//Constructor
- STP(BeevMgr* b,
+ STP(STPMgr* b,
Simplifier* s,
BVSolver* bsolv,
ArrayTransformer * a,
Ctr_Example = ce;
}// End of constructor
- SOLVER_RETURN_TYPE TopLevelSAT(const ASTNode& inputasserts,
+ ~STP()
+ {
+ ClearAllTables();
+ }
+
+ // The absolute TopLevel function that invokes STP on the input
+ // formula
+ SOLVER_RETURN_TYPE TopLevelSTP(const ASTNode& inputasserts,
const ASTNode& query)
{
ASTNode q = bm->CreateNode(AND,
inputasserts,
bm->CreateNode(NOT, query));
- return TopLevelSATAux(q);
- } //End of TopLevelSAT()
+ return TopLevelSTPAux(q);
+ } //End of TopLevelSTP()
// Accepts query and returns the answer. if query is valid,
// returns VALID, else returns INVALID. Automatically constructs
// counterexample for invalid queries, and prints them upon
// request.
- SOLVER_RETURN_TYPE TopLevelSATAux(const ASTNode& inputasserts_and_query);
+ SOLVER_RETURN_TYPE TopLevelSTPAux(const ASTNode& inputasserts_and_query);
+
+ void ClearAllCaches(void);
+
+ void ClearAllTables(void);
}; //End of Class STP
};//end of namespace
#endif
namespace BEEV
{
- ASTInterior *BeevMgr::LookupOrCreateInterior(ASTInterior *n_ptr)
+ ASTInterior *STPMgr::LookupOrCreateInterior(ASTInterior *n_ptr)
{
ASTInteriorSet::iterator it = _interior_unique_table.find(n_ptr);
if (it == _interior_unique_table.end())
////////////////////////////////////////////////////////////////
- // BeevMgr members
+ // STPMgr members
////////////////////////////////////////////////////////////////
- ASTNode BeevMgr::CreateNode(Kind kind, const ASTVec & back_children)
+ ASTNode STPMgr::CreateNode(Kind kind, const ASTVec & back_children)
{
// create a new node. Children will be modified.
ASTInterior *n_ptr = new ASTInterior(kind);
return n;
}
- ASTNode BeevMgr::CreateNode(Kind kind,
+ ASTNode STPMgr::CreateNode(Kind kind,
const ASTNode& child0,
const ASTVec & back_children)
{
return n;
}
- ASTNode BeevMgr::CreateNode(Kind kind,
+ ASTNode STPMgr::CreateNode(Kind kind,
const ASTNode& child0,
const ASTNode& child1,
const ASTVec & back_children)
return n;
}
- ASTNode BeevMgr::CreateNode(Kind kind,
+ ASTNode STPMgr::CreateNode(Kind kind,
const ASTNode& child0,
const ASTNode& child1,
const ASTNode& child2,
return n;
}
- ASTInterior *BeevMgr::CreateInteriorNode(Kind kind,
+ ASTInterior *STPMgr::CreateInteriorNode(Kind kind,
// children array of this node will be modified.
ASTInterior *n_ptr,
const ASTVec & back_children)
}
////////////////////////////////////////////////////////////////
- // BeevMgr member functions to create ASTSymbol and ASTBVConst
+ // STPMgr member functions to create ASTSymbol and ASTBVConst
////////////////////////////////////////////////////////////////
- ASTNode BeevMgr::CreateSymbol(const char * const name)
+ ASTNode STPMgr::CreateSymbol(const char * const name)
{
ASTSymbol temp_sym(name);
ASTNode n(LookupOrCreateSymbol(temp_sym));
// inserted. FIXME: Is there a way to do this with insert? Need a
// function to make a new object in the middle of insert. Read STL
// documentation.
- ASTSymbol *BeevMgr::LookupOrCreateSymbol(ASTSymbol& s)
+ ASTSymbol *STPMgr::LookupOrCreateSymbol(ASTSymbol& s)
{
ASTSymbol *s_ptr = &s; // it's a temporary key.
}
} // End of LookupOrCreateSymbol
- bool BeevMgr::LookupSymbol(ASTSymbol& s)
+ bool STPMgr::LookupSymbol(ASTSymbol& s)
{
ASTSymbol* s_ptr = &s; // it's a temporary key.
}
//Create a ASTBVConst node
- ASTNode BeevMgr::CreateBVConst(unsigned int width, unsigned long long int bvconst)
+ ASTNode STPMgr::CreateBVConst(unsigned int width, unsigned long long int bvconst)
{
if (width > (sizeof(unsigned long long int) << 3) || width <= 0)
FatalError("CreateBVConst: "\
return CreateBVConst(bv, width);
}
- ASTNode BeevMgr::CreateBVConst(string*& strval, int base, int bit_width)
+ ASTNode STPMgr::CreateBVConst(string*& strval, int base, int bit_width)
{
if (bit_width <= 0)
}
//Create a ASTBVConst node from std::string
- ASTNode BeevMgr::CreateBVConst(const char* const strval, int base)
+ ASTNode STPMgr::CreateBVConst(const char* const strval, int base)
{
size_t width = strlen((const char *) strval);
if (!(2 == base || 10 == base || 16 == base))
}
//FIXME Code currently assumes that it will destroy the bitvector passed to it
- ASTNode BeevMgr::CreateBVConst(CBV bv, unsigned width)
+ ASTNode STPMgr::CreateBVConst(CBV bv, unsigned width)
{
ASTBVConst temp_bvconst(bv, width);
ASTNode n(LookupOrCreateBVConst(temp_bvconst));
return n;
}
- ASTNode BeevMgr::CreateZeroConst(unsigned width)
+ ASTNode STPMgr::CreateZeroConst(unsigned width)
{
CBV z = CONSTANTBV::BitVector_Create(width, true);
return CreateBVConst(z, width);
}
- ASTNode BeevMgr::CreateOneConst(unsigned width)
+ ASTNode STPMgr::CreateOneConst(unsigned width)
{
CBV o = CONSTANTBV::BitVector_Create(width, true);
CONSTANTBV::BitVector_increment(o);
return CreateBVConst(o, width);
}
- ASTNode BeevMgr::CreateTwoConst(unsigned width)
+ ASTNode STPMgr::CreateTwoConst(unsigned width)
{
CBV two = CONSTANTBV::BitVector_Create(width, true);
CONSTANTBV::BitVector_increment(two);
return CreateBVConst(two, width);
}
- ASTNode BeevMgr::CreateMaxConst(unsigned width)
+ ASTNode STPMgr::CreateMaxConst(unsigned width)
{
CBV max = CONSTANTBV::BitVector_Create(width, false);
CONSTANTBV::BitVector_Fill(max);
//To ensure unique BVConst nodes, lookup the node in unique-table
//before creating a new one.
- ASTBVConst *BeevMgr::LookupOrCreateBVConst(ASTBVConst &s)
+ ASTBVConst *STPMgr::LookupOrCreateBVConst(ASTBVConst &s)
{
ASTBVConst *s_ptr = &s; // it's a temporary key.
}
// Create and return an ASTNode for a term
- ASTNode BeevMgr::CreateTerm(Kind kind,
+ ASTNode STPMgr::CreateTerm(Kind kind,
unsigned int width,
const ASTVec &children)
{
return n;
}
- ASTNode BeevMgr::CreateTerm(Kind kind,
+ ASTNode STPMgr::CreateTerm(Kind kind,
unsigned int width,
const ASTNode& child0,
const ASTVec &children)
return n;
}
- ASTNode BeevMgr::CreateTerm(Kind kind,
+ ASTNode STPMgr::CreateTerm(Kind kind,
unsigned int width,
const ASTNode& child0,
const ASTNode& child1,
return n;
}
- ASTNode BeevMgr::CreateTerm(Kind kind,
+ ASTNode STPMgr::CreateTerm(Kind kind,
unsigned int width,
const ASTNode& child0,
const ASTNode& child1,
}
//add an assertion to the current logical context
- void BeevMgr::AddAssert(const ASTNode& assert)
+ void STPMgr::AddAssert(const ASTNode& assert)
{
if (!(is_Form_kind(assert.GetKind()) && BOOLEAN_TYPE == assert.GetType()))
{
}
}
- void BeevMgr::Push(void)
+ void STPMgr::Push(void)
{
ASTVec * v;
v = new ASTVec();
_asserts.push_back(v);
}
- void BeevMgr::Pop(void)
+ void STPMgr::Pop(void)
{
if (!_asserts.empty())
{
}
}
- void BeevMgr::AddQuery(const ASTNode& q)
+ void STPMgr::AddQuery(const ASTNode& q)
{
//_current_query = TransformFormula(q);
//cerr << "\nThe current query is: " << q << endl;
_current_query = q;
}
- const ASTNode BeevMgr::PopQuery()
+ const ASTNode STPMgr::PopQuery()
{
ASTNode q = _current_query;
_current_query = ASTTrue;
return q;
}
- const ASTNode BeevMgr::GetQuery()
+ const ASTNode STPMgr::GetQuery()
{
return _current_query;
}
- const ASTVec BeevMgr::GetAsserts(void)
+ const ASTVec STPMgr::GetAsserts(void)
{
vector<ASTVec *>::iterator it = _asserts.begin();
vector<ASTVec *>::iterator itend = _asserts.end();
}
// //Create a new variable of ValueWidth 'n'
-// ASTNode BeevMgr::NewArrayVar(unsigned int index, unsigned int value)
+// ASTNode STPMgr::NewArrayVar(unsigned int index, unsigned int value)
// {
// std::string c("v");
// char d[32];
// } //end of NewArrayVar()
//prints statistics for the ASTNode
- void BeevMgr::ASTNodeStats(const char * c, const ASTNode& a)
+ void STPMgr::ASTNodeStats(const char * c, const ASTNode& a)
{
if (!stats_flag)
return;
cout << NodeSize(a) << endl;
}
- unsigned int BeevMgr::NodeSize(const ASTNode& a, bool clearStatInfo)
+ unsigned int STPMgr::NodeSize(const ASTNode& a, bool clearStatInfo)
{
if (clearStatInfo)
StatInfoSet.clear();
return newn;
}
- void BeevMgr::ClearAllTables(void)
- {
-// //clear all tables before calling toplevelsat
-// //_ASTNode_to_SATVar.clear();
-// //_SATVar_to_AST.clear();
-
-// // for (ASTtoBitvectorMap::iterator it = _ASTNode_to_Bitvector.begin(),
-// // itend = _ASTNode_to_Bitvector.end(); it != itend; it++)
-// // {
-// // (it->second)->clear();
-// // delete (it->second);
-// // }
-// // _ASTNode_to_Bitvector.clear();
-
-// NodeLetVarMap.clear();
-// NodeLetVarMap1.clear();
-// PLPrintNodeSet.clear();
-// AlreadyPrintedSet.clear();
-// //ReferenceCount->clear();
-// //_arrayread_ite.clear();
-// //_introduced_symbols.clear();
-// //CounterExampleMap.clear();
-// //ComputeFormulaMap.clear();
-// StatInfoSet.clear();
-
-// _asserts.clear();
-
-// // for (ASTNodeToVecMap::iterator iset =
-// // _arrayname_readindices.begin(), iset_end =
-// // _arrayname_readindices.end(); iset != iset_end; iset++) {
-// // iset->second.clear(); }
-// // _arrayname_readindices.clear();
-
-// _interior_unique_table.clear();
-// _symbol_unique_table->clear();
-// _bvconst_unique_table.clear();
- }
-
- void BeevMgr::ClearAllCaches(void)
- {
- //clear all tables before calling toplevelsat
- //_ASTNode_to_SATVar.clear();
- //_SATVar_to_AST.clear();
-
- // for (ASTtoBitvectorMap::iterator it = _ASTNode_to_Bitvector.begin(),
- // itend = _ASTNode_to_Bitvector.end(); it != itend; it++)
- // {
- // (it->second)->clear();
- // delete (it->second);
- // }
- // _ASTNode_to_Bitvector.clear();
-
- NodeLetVarMap.clear();
- NodeLetVarMap1.clear();
- PLPrintNodeSet.clear();
- AlreadyPrintedSet.clear();
- // SimplifyMap->clear();
- // SimplifyNegMap->clear();
- // ReferenceCount->clear();
- // SolverMap.clear();
- //AlwaysTrueFormMap.clear();
- //_arrayread_ite.clear();
- //_arrayread_symbol.clear();
- //_introduced_symbols.clear();
- //CounterExampleMap.clear();
- //ComputeFormulaMap.clear();
- StatInfoSet.clear();
-
- // for (ASTNodeToVecMap::iterator iset = _arrayname_readindices.begin(), iset_end = _arrayname_readindices.end(); iset != iset_end; iset++)
- // {
- // iset->second.clear();
- // }
-
- // _arrayname_readindices.clear();
- //_interior_unique_table.clear();
- //_symbol_unique_table.clear();
- //_bvconst_unique_table.clear();
- }
-
- BeevMgr::~BeevMgr()
+ STPMgr::~STPMgr()
{
- ClearAllTables();
}
// GLOBAL FUNCTION: Prints statistics from the MINISAT Solver
- void BeevMgr::PrintStats(MINISAT::Solver& s)
+ void STPMgr::PrintStats(MINISAT::Solver& s)
{
if (!stats_flag)
return;
//Create a new variable of ValueWidth 'n'
- ASTNode BeevMgr::NewVar(unsigned int n)
+ ASTNode STPMgr::NewVar(unsigned int n)
{
std::string c("v");
char d[32];
return CurrentSymbol;
} //end of NewVar()
- bool BeevMgr::VarSeenInTerm(const ASTNode& var, const ASTNode& term)
+ bool STPMgr::VarSeenInTerm(const ASTNode& var, const ASTNode& term)
{
if (READ == term.GetKind()
&& WRITE == term[0].GetKind()
}//End of VarSeenInTerm
- ASTNode BeevMgr::NewParameterized_BooleanVar(const ASTNode& var,
+ ASTNode STPMgr::NewParameterized_BooleanVar(const ASTNode& var,
const ASTNode& constant)
{
ostringstream outVar;
namespace BEEV
{
/*****************************************************************
- * Class BeevMgr. This holds all "global" variables for the system,
+ * Class STPMgr. This holds all "global" variables for the system,
* such as unique tables for the various kinds of nodes.
*****************************************************************/
- class BeevMgr
+ class STPMgr
{
friend class ASTNode;
friend class ASTInterior;
****************************************************************/
// Constructor
- BeevMgr() :
+ STPMgr() :
_symbol_unique_table(INITIAL_TABLE_SIZE),
_bvconst_unique_table(INITIAL_TABLE_SIZE),
_interior_unique_table(INITIAL_TABLE_SIZE),
}
//destructor
- ~BeevMgr();
+ ~STPMgr();
//Return ptr to let-variables manager (see parser/let-funcs.h)
LETMgr * GetLetMgr(void)
//add an assertion to the current logical context
void AddAssert(const ASTNode& assert);
- void ClearAllTables(void);
- void ClearAllCaches(void);
-
/****************************************************************
* Toplevel printing and stats functions *
****************************************************************/
TermsAlreadySeenMap.clear();
}
- };//End of Class BeevMgr
+ };//End of Class STPMgr
};//end of namespace
#endif
ASTNodeMap ComputeFormulaMap;
// Ptr to STPManager
- BeevMgr * bm;
+ STPMgr * bm;
// Ptr to Simplifier
Simplifier * simp;
public:
// Constructor
- AbsRefine_CounterExample(BeevMgr * b,
+ AbsRefine_CounterExample(STPMgr * b,
Simplifier * s,
ArrayTransformer * at,
ToSAT * t) :
class CompleteCounterExample
{
ASTNodeMap counterexample;
- BeevMgr * bv;
+ STPMgr * bv;
public:
- CompleteCounterExample(ASTNodeMap a, BeevMgr* beev) :
+ CompleteCounterExample(ASTNodeMap a, STPMgr* beev) :
counterexample(a), bv(beev)
{
}
//many overloaded meanings of the word type)
typedef BEEV::ASTNode node;
typedef BEEV::ASTNode* nodestar;
-typedef BEEV::BeevMgr* bmstar;
+typedef BEEV::STPMgr* bmstar;
typedef BEEV::STP* stpstar;
typedef BEEV::Simplifier* simpstar;
typedef BEEV::BVSolver* bvsolverstar;
}
}
-//Create a validity Checker. This is the global BeevMgr
+//Create a validity Checker. This is the global STPMgr
VC vc_createValidityChecker(void) {
vc_setFlags('d');
CONSTANTBV::ErrCode c = CONSTANTBV::BitVector_Boot();
return 0;
}
- BEEV::BeevMgr * bm = new BEEV::BeevMgr();
+ BEEV::STPMgr * bm = new BEEV::STPMgr();
BEEV::Simplifier * simp = new BEEV::Simplifier(bm);
BEEV::BVSolver* bvsolver = new BEEV::BVSolver(bm, simp);
BEEV::ToSAT * tosat = new BEEV::ToSAT(bm, simp);
- BEEV::ArrayTransformer * arrayTransformer = new BEEV::ArrayTransformer(bm, simp);
+ BEEV::ArrayTransformer * arrayTransformer =
+ new BEEV::ArrayTransformer(bm, simp);
BEEV::AbsRefine_CounterExample * Ctr_Example =
- new BEEV::AbsRefine_CounterExample(bm, simp, arrayTransformer, tosat);
-
- BEEV::ParserBM = bm;
- stpstar stp = new BEEV::STP(bm, simp,
- bvsolver, arrayTransformer,
- tosat, Ctr_Example);
+ new BEEV::AbsRefine_CounterExample(bm, simp, arrayTransformer, tosat);
+
+ BEEV::ParserBM = bm;
+ stpstar stp =
+ new BEEV::STP(bm, simp,
+ bvsolver, arrayTransformer,
+ tosat, Ctr_Example);
BEEV::GlobalSTP = stp;
decls = new BEEV::ASTVec();
int output;
if(!v.empty()) {
if(v.size()==1) {
- output = stp->TopLevelSAT(v[0],*a);
+ output = stp->TopLevelSTP(v[0],*a);
}
else {
- output = stp->TopLevelSAT(b->CreateNode(BEEV::AND,v),*a);
+ output = stp->TopLevelSTP(b->CreateNode(BEEV::AND,v),*a);
}
}
else {
- output = stp->TopLevelSAT(b->CreateNode(BEEV::TRUE),*a);
+ output = stp->TopLevelSTP(b->CreateNode(BEEV::TRUE),*a);
}
return output;
} //end of vc_query
// node o;
// if(!v.empty()) {
// if(v.size()==1)
-// return b->TopLevelSAT(v[0],*a);
+// return b->TopLevelSTP(v[0],*a);
// else
-// return b->TopLevelSAT(b->CreateNode(BEEV::AND,v),*a);
+// return b->TopLevelSTP(b->CreateNode(BEEV::AND,v),*a);
// }
// else
-// return b->TopLevelSAT(b->CreateNode(BEEV::TRUE),*a);
+// return b->TopLevelSTP(b->CreateNode(BEEV::TRUE),*a);
// }
void vc_push(VC vc) {
bmstar b = (bmstar)(((stpstar)vc)->bm);
- b->ClearAllCaches();
+ ((stpstar)vc)->ClearAllCaches();
b->Push();
}
cvcparse((void*)AssertsQuery);
BEEV::ASTNode asserts = (*(BEEV::ASTVec*)AssertsQuery)[0];
BEEV::ASTNode query = (*(BEEV::ASTVec*)AssertsQuery)[1];
- //b->TopLevelSAT(asserts, query);
+ //b->TopLevelSTP(asserts, query);
node oo = b->CreateNode(BEEV::NOT,query);
node o = b->CreateNode(BEEV::AND,asserts,oo);
//global BEEVMGR for the parser. Use exclusively for parsing
STP * GlobalSTP;
- BeevMgr * ParserBM;
+ STPMgr * ParserBM;
void (*vc_error_hdlr)(const char* err_msg) = NULL;
/** This is reusable empty vector, for representing empty children
namespace BEEV
{
- class BeevMgr;
+ class STPMgr;
class ASTNode;
class ASTInternal;
class ASTInterior;
//Useful global variables. Use for parsing only
extern STP * GlobalSTP;
- extern BeevMgr * ParserBM;
+ extern STPMgr * ParserBM;
- //Empty vector
+ //Empty vector. Useful commonly used ASTNodes
extern std::vector<ASTNode> _empty_ASTVec;
extern ASTNode ASTFalse, ASTTrue, ASTUndefined;
}
- BeevMgr * bm = new BeevMgr();
+ STPMgr * bm = new STPMgr();
Simplifier * simp = new Simplifier(bm);
BVSolver* bvsolver = new BVSolver(bm, simp);
ArrayTransformer * arrayTransformer = new ArrayTransformer(bm, simp);
return 0;
} //end of PrintBack if
- SOLVER_RETURN_TYPE ret = GlobalSTP->TopLevelSAT(asserts, query);
+ SOLVER_RETURN_TYPE ret = GlobalSTP->TopLevelSTP(asserts, query);
if (quick_statistics_flag)
{
bm->GetRunTimes()->print();
#define YY_EXIT_FAILURE -1
#define YYPARSE_PARAM AssertsQuery
- //BeevMgr * ParserBM = GlobalSTP->bm;
-
extern int cvclex(void);
extern char* yytext;
extern int cvclineno;
void lpvec(const ASTVec &vec)
{
- (vec[0].GetBeevMgr())->AlreadyPrintedSet.clear();
+ (vec[0].GetSTPMgr())->AlreadyPrintedSet.clear();
LispPrintVec(cout, vec, 0);
cout << endl;
}
- // void BeevMgr::PrintClauseList(ostream& os, BeevMgr::ClauseList& cll)
+ // void STPMgr::PrintClauseList(ostream& os, STPMgr::ClauseList& cll)
// {
// int num_clauses = cll.size();
// os << "Clauses: " << endl << "=========================================" << endl;
// void Convert_MINISATVar_To_ASTNode_Print(int minisat_var,
// int decision_level, int polarity)
// {
- // BEEV::ASTNode vv = BEEV::GlobalBeevMgr->_SATVar_to_AST[minisat_var];
+ // BEEV::ASTNode vv = BEEV::GlobalSTPMgr->_SATVar_to_AST[minisat_var];
// cout << spaces(decision_level);
// if (polarity)
// {
// cout << endl;
// } //end of Convert_MINISATVar_To_ASTNode_Print()
- void BeevMgr::printVarDeclsToStream(ostream &os) {
+ void STPMgr::printVarDeclsToStream(ostream &os) {
for(ASTVec::iterator i = ListOfDeclaredVars.begin(),iend=ListOfDeclaredVars.end();i!=iend;i++) {
BEEV::ASTNode a = *i;
switch(a.GetType()) {
- void BeevMgr::printAssertsToStream(ostream &os, int simplify_print) {
+ void STPMgr::printAssertsToStream(ostream &os, int simplify_print) {
ASTVec v = GetAsserts();
for(ASTVec::iterator i=v.begin(),iend=v.end();i!=iend;i++) {
//Begin_RemoveWrites = true;
}
//if this node is present in the letvar Map, then print the letvar
- BeevMgr *bm = n.GetBeevMgr();
+ STPMgr *bm = n.GetSTPMgr();
//this is to print letvars for shared subterms inside the printing
//of "(LET v0 = term1, v1=term1@term2,...
ostream& C_Print(ostream &os, const ASTNode n, int indentation)
{
// Clear the PrintMap
- BeevMgr* bm = n.GetBeevMgr();
+ STPMgr* bm = n.GetSTPMgr();
bm->PLPrintNodeSet.clear();
bm->NodeLetVarMap.clear();
bm->NodeLetVarVec.clear();
ostream &Lisp_Print(ostream &os, const ASTNode& n, int indentation)
{
// Clear the PrintMap
- BeevMgr* bm = n.GetBeevMgr();
+ STPMgr* bm = n.GetSTPMgr();
bm->AlreadyPrintedSet.clear();
Lisp_Print_indent(os, n, indentation);
printf("\n");
}
//if this node is present in the letvar Map, then print the letvar
- BeevMgr *bm = n.GetBeevMgr();
+ STPMgr *bm = n.GetSTPMgr();
//this is to print letvars for shared subterms inside the printing
//of "(LET v0 = term1, v1=term1@term2,...
ostream& PL_Print(ostream &os, const ASTNode& n, int indentation)
{
// Clear the PrintMap
- BeevMgr* bm = n.GetBeevMgr();
+ STPMgr* bm = n.GetSTPMgr();
bm->PLPrintNodeSet.clear();
bm->NodeLetVarMap.clear();
bm->NodeLetVarVec.clear();
string functionToSMTLIBName(const BEEV::Kind k);
void SMTLIB_Print1(ostream& os, const BEEV::ASTNode n, int indentation, bool letize);
- void printVarDeclsToStream( const BeevMgr* mgr, ostream &os);
+ void printVarDeclsToStream( const STPMgr* mgr, ostream &os);
// Initial version intended to print the whole thing back.
void SMTLIB_PrintBack(ostream &os, const ASTNode& n) {
// need to add fake headers into here.
os << "(" << endl;
os << "benchmark blah" << endl;
- printVarDeclsToStream(n.GetBeevMgr(),os);
+ printVarDeclsToStream(n.GetSTPMgr(),os);
SMTLIB_Print(os, n, 0);
os << ")" << endl;
}
- void printVarDeclsToStream( const BeevMgr* mgr, ostream &os) {
+ void printVarDeclsToStream( const STPMgr* mgr, ostream &os) {
for(ASTVec::const_iterator i = mgr->ListOfDeclaredVars.begin(),
iend=mgr->ListOfDeclaredVars.end();i!=iend;i++) {
const BEEV::ASTNode& a = *i;
// Prepend with zero to convert to unsigned.
os << "bv";
- CBV unsign = CONSTANTBV::BitVector_Concat((n.GetBeevMgr())->CreateZeroConst(1).GetBVConst(), op.GetBVConst());
+ CBV unsign = CONSTANTBV::BitVector_Concat((n.GetSTPMgr())->CreateZeroConst(1).GetBVConst(), op.GetBVConst());
unsigned char * str = CONSTANTBV::BitVector_to_Dec(unsign);
CONSTANTBV::BitVector_Destroy(unsign);
os << str << "[" << op.GetValueWidth() << "]";
}
//if this node is present in the letvar Map, then print the letvar
- BeevMgr * bm = n.GetBeevMgr();
+ STPMgr * bm = n.GetSTPMgr();
//this is to print letvars for shared subterms inside the printing
//of "(LET v0 = term1, v1=term1@term2,...
ostream& SMTLIB_Print(ostream &os, const ASTNode n, const int indentation)
{
// Clear the PrintMap
- BeevMgr* bm = n.GetBeevMgr();
+ STPMgr* bm = n.GetSTPMgr();
bm->PLPrintNodeSet.clear();
bm->NodeLetVarMap.clear();
bm->NodeLetVarVec.clear();
// Ptr to toplevel manager that manages bit-vector expressions
// (i.e. construct various kinds of expressions), and also has
// member functions that simplify bit-vector expressions
- BeevMgr * _bm;
+ STPMgr * _bm;
// Ptr to Simplifier
Simplifier * _simp;
public:
//constructor
- BVSolver(BeevMgr * bm, Simplifier * simp) : _bm(bm), _simp(simp)
+ BVSolver(STPMgr * bm, Simplifier * simp) : _bm(bm), _simp(simp)
{
ASTTrue = _bm->CreateNode(TRUE);
ASTFalse = _bm->CreateNode(FALSE);
ASTNodeCountMap *ReferenceCount;
//Ptr to STP Manager
- BeevMgr * _bm;
+ STPMgr * _bm;
public:
/****************************************************************
* Public Member Functions *
****************************************************************/
- Simplifier(BeevMgr * bm) : _bm(bm)
+ Simplifier(STPMgr * bm) : _bm(bm)
{
SimplifyMap = new ASTNodeMap(INITIAL_TABLE_SIZE);
SimplifyNegMap = new ASTNodeMap(INITIAL_TABLE_SIZE);
/****************************************************************
* Private Data *
****************************************************************/
- BeevMgr * _bm;
+ STPMgr * _bm;
ASTNode ASTTrue, ASTFalse, ASTUndefined;
// Memo table for bit blasted terms. If a node has already been
* Public Member Functions *
****************************************************************/
- BitBlaster(BeevMgr * bm) : _bm(bm)
+ BitBlaster(STPMgr * bm) : _bm(bm)
{
ASTTrue = _bm->CreateNode(TRUE);
ASTFalse = _bm->CreateNode(FALSE);
namespace BEEV
{
- ASTNode BeevMgr::CreateSimpForm(Kind kind, ASTVec &children = _empty_ASTVec)
+ ASTNode STPMgr::CreateSimpForm(Kind kind, ASTVec &children = _empty_ASTVec)
{
if (_disable_simpbool)
{
// specialized versions
- ASTNode BeevMgr::CreateSimpForm(Kind kind, const ASTNode& child0)
+ ASTNode STPMgr::CreateSimpForm(Kind kind, const ASTNode& child0)
{
ASTVec children;
//child_stack.clear(); // could just reset top pointer.
//return CreateSimpForm(kind, child_stack);
}
- ASTNode BeevMgr::CreateSimpForm(Kind kind, const ASTNode& child0, const ASTNode& child1)
+ ASTNode STPMgr::CreateSimpForm(Kind kind, const ASTNode& child0, const ASTNode& child1)
{
ASTVec children;
//child_stack.clear(); // could just reset top pointer.
//return CreateSimpForm(kind, child_stack);
}
- ASTNode BeevMgr::CreateSimpForm(Kind kind, const ASTNode& child0, const ASTNode& child1, const ASTNode& child2)
+ ASTNode STPMgr::CreateSimpForm(Kind kind, const ASTNode& child0, const ASTNode& child1, const ASTNode& child2)
{
ASTVec children;
//child_stack.clear(); // could just reset top pointer.
//return CreateSimpForm(kind, child_stack);
}
- ASTNode BeevMgr::CreateSimpNot(const ASTNode& form)
+ ASTNode STPMgr::CreateSimpNot(const ASTNode& form)
{
Kind k = form.GetKind();
switch (k)
// CreateSimpAndOr instead of CreateSimpXor until 1/9/07 with no
// ill effects. Calls seem to go to the version that takes a vector
// of children.
- ASTNode BeevMgr::CreateSimpXor(const ASTNode& form1, const ASTNode& form2)
+ ASTNode STPMgr::CreateSimpXor(const ASTNode& form1, const ASTNode& form2)
{
ASTVec children;
children.push_back(form1);
return flat_children;
}
- ASTNode BeevMgr::CreateSimpAndOr(bool IsAnd, const ASTNode& form1, const ASTNode& form2)
+ ASTNode STPMgr::CreateSimpAndOr(bool IsAnd, const ASTNode& form1, const ASTNode& form2)
{
ASTVec children;
children.push_back(form1);
}
// FIXME: Could also handle (AND ... (NOT (OR ...) ...)
- ASTNode BeevMgr::CreateSimpAndOr(bool IsAnd, ASTVec &children)
+ ASTNode STPMgr::CreateSimpAndOr(bool IsAnd, ASTVec &children)
{
Kind k = IsAnd ? AND : OR;
}
// Constant children are accumulated in "accumconst".
- ASTNode BeevMgr::CreateSimpXor(ASTVec &children)
+ ASTNode STPMgr::CreateSimpXor(ASTVec &children)
{
if (_trace_simpbool)
}
// FIXME: How do I know whether ITE is a formula or not?
- ASTNode BeevMgr::CreateSimpFormITE(const ASTNode& child0, const ASTNode& child1, const ASTNode& child2)
+ ASTNode STPMgr::CreateSimpFormITE(const ASTNode& child0, const ASTNode& child1, const ASTNode& child2)
{
ASTNode retval;
//########################################
// constructor
- CNFMgr::CNFMgr(BeevMgr *bmgr)
+ CNFMgr::CNFMgr(STPMgr *bmgr)
{
bm = bmgr;
}
ClauseList* CNFMgr::convertToCNF(const ASTNode& varphi)
{
- varphi.GetBeevMgr()->GetRunTimes()->start(RunTimes::CNFConversion);
+ bm->GetRunTimes()->start(RunTimes::CNFConversion);
scanFormula(varphi, true);
ASTNode dummy_true_var = bm->CreateSymbol("*TrueDummy*");
ClauseList* defs = SINGLETON(dummy_true_var);
defs->insert(defs->begin() + 1, top->begin(), top->end());
cleanup(varphi);
- varphi.GetBeevMgr()->GetRunTimes()->stop(RunTimes::CNFConversion);
+ bm->GetRunTimes()->stop(RunTimes::CNFConversion);
return defs;
}//End of convertToCNF()
//########################################
// this is the data
- BeevMgr *bm;
+ STPMgr *bm;
ASTNodeToCNFInfoMap info;
ASTNodeToASTNodePtrMap store;
//########################################
//########################################
// constructor
- CNFMgr(BeevMgr *bmgr);
+ CNFMgr(STPMgr *bmgr);
//########################################
//########################################
vector<ASTNode> _SATVar_to_AST;
// Ptr to STPManager
- BeevMgr * bm;
+ STPMgr * bm;
// Ptr to Simplifier
Simplifier * simp;
****************************************************************/
// Constructor
- ToSAT(BeevMgr * bm, Simplifier * s) :
+ ToSAT(STPMgr * bm, Simplifier * s) :
bm(bm), simp(s)
{
ASTTrue = bm->CreateNode(TRUE);