return super::insert(v, v);
}
+ void insertAtContextLevelZero(const V& v) {
+ return super::insertAtContextLevelZero(v, v);
+ }
+
bool contains(const V& v) {
return find(v) != end();
}
delete d_context;
}
-void DeclarationScope::bind(const std::string& name, Expr obj) throw(AssertionException) {
+void DeclarationScope::bind(const std::string& name, Expr obj,
+ bool levelZero) throw(AssertionException) {
CheckArgument(!obj.isNull(), obj, "cannot bind to a null Expr");
ExprManagerScope ems(obj);
- d_exprMap->insert(name, obj);
+ if(levelZero) d_exprMap->insertAtContextLevelZero(name, obj);
+ else d_exprMap->insert(name, obj);
}
-void DeclarationScope::bindDefinedFunction(const std::string& name, Expr obj) throw(AssertionException) {
+void DeclarationScope::bindDefinedFunction(const std::string& name, Expr obj,
+ bool levelZero) throw(AssertionException) {
CheckArgument(!obj.isNull(), obj, "cannot bind to a null Expr");
ExprManagerScope ems(obj);
- d_exprMap->insert(name, obj);
- d_functions->insert(obj);
+ if(levelZero){
+ d_exprMap->insertAtContextLevelZero(name, obj);
+ d_functions->insertAtContextLevelZero(obj);
+ } else {
+ d_exprMap->insert(name, obj);
+ d_functions->insert(obj);
+ }
}
bool DeclarationScope::isBound(const std::string& name) const throw() {
return (*d_exprMap->find(name)).second;
}
-void DeclarationScope::bindType(const std::string& name, Type t) throw() {
- d_typeMap->insert(name, make_pair(vector<Type>(), t));
+void DeclarationScope::bindType(const std::string& name, Type t,
+ bool levelZero) throw() {
+ if(levelZero){
+ d_typeMap->insertAtContextLevelZero(name, make_pair(vector<Type>(), t));
+ }else{
+ d_typeMap->insert(name, make_pair(vector<Type>(), t));
+ }
}
void DeclarationScope::bindType(const std::string& name,
const std::vector<Type>& params,
- Type t) throw() {
+ Type t,
+ bool levelZero) throw() {
if(Debug.isOn("sort")) {
Debug("sort") << "bindType(" << name << ", [";
if(params.size() > 0) {
}
Debug("sort") << "], " << t << ")" << endl;
}
- d_typeMap->insert(name, make_pair(params, t));
+ if(levelZero){
+ d_typeMap->insertAtContextLevelZero(name, make_pair(params, t));
+ } else {
+ d_typeMap->insert(name, make_pair(params, t));
+ }
}
bool DeclarationScope::isBoundType(const std::string& name) const throw() {
* <code>name</code> is already bound to an expression in the current
* level, then the binding is replaced. If <code>name</code> is bound
* in a previous level, then the binding is "covered" by this one
- * until the current scope is popped.
+ * until the current scope is popped. If levelZero is true the name
+ * shouldn't be already bound.
*
* @param name an identifier
* @param obj the expression to bind to <code>name</code>
+ * @param levelZero set if the binding must be done at level 0
*/
- void bind(const std::string& name, Expr obj) throw(AssertionException);
+ void bind(const std::string& name, Expr obj, bool levelZero = false) throw(AssertionException);
/**
* Bind a function body to a name in the current scope. If
*
* @param name an identifier
* @param obj the expression to bind to <code>name</code>
+ * @param levelZero set if the binding must be done at level 0
*/
- void bindDefinedFunction(const std::string& name, Expr obj) throw(AssertionException);
+ void bindDefinedFunction(const std::string& name, Expr obj, bool levelZero = false) throw(AssertionException);
/**
* Bind a type to a name in the current scope. If <code>name</code>
*
* @param name an identifier
* @param t the type to bind to <code>name</code>
+ * @param levelZero set if the binding must be done at level 0
*/
- void bindType(const std::string& name, Type t) throw();
+ void bindType(const std::string& name, Type t, bool levelZero = false) throw();
/**
* Bind a type to a name in the current scope. If <code>name</code>
*/
void bindType(const std::string& name,
const std::vector<Type>& params,
- Type t) throw();
+ Type t, bool levelZero = false) throw();
/**
* Check whether a name is bound to an expression with either bind()
}
Expr
-Parser::mkVar(const std::string& name, const Type& type) {
+Parser::mkVar(const std::string& name, const Type& type,
+ bool levelZero) {
Debug("parser") << "mkVar(" << name << ", " << type << ")" << std::endl;
Expr expr = d_exprManager->mkVar(name, type);
- defineVar(name, expr);
+ defineVar(name, expr, levelZero);
return expr;
}
Expr
-Parser::mkFunction(const std::string& name, const Type& type) {
+Parser::mkFunction(const std::string& name, const Type& type,
+ bool levelZero) {
Debug("parser") << "mkVar(" << name << ", " << type << ")" << std::endl;
Expr expr = d_exprManager->mkVar(name, type);
- defineFunction(name, expr);
+ defineFunction(name, expr, levelZero);
return expr;
}
std::vector<Expr>
Parser::mkVars(const std::vector<std::string> names,
- const Type& type) {
+ const Type& type,
+ bool levelZero) {
std::vector<Expr> vars;
for(unsigned i = 0; i < names.size(); ++i) {
- vars.push_back(mkVar(names[i], type));
+ vars.push_back(mkVar(names[i], type, levelZero));
}
return vars;
}
void
-Parser::defineVar(const std::string& name, const Expr& val) {
- d_declScope->bind(name, val);
+Parser::defineVar(const std::string& name, const Expr& val,
+ bool levelZero) {
+ d_declScope->bind(name, val, levelZero);
Assert( isDeclared(name) );
}
void
-Parser::defineFunction(const std::string& name, const Expr& val) {
- d_declScope->bindDefinedFunction(name, val);
+Parser::defineFunction(const std::string& name, const Expr& val,
+ bool levelZero) {
+ d_declScope->bindDefinedFunction(name, val, levelZero);
Assert( isDeclared(name) );
}
Type getType(const std::string& var_name, SymbolType type = SYM_VARIABLE);
/** Create a new CVC4 variable expression of the given type. */
- Expr mkVar(const std::string& name, const Type& type);
+ Expr mkVar(const std::string& name, const Type& type,
+ bool levelZero = false);
/**
* Create a set of new CVC4 variable expressions of the given type.
*/
std::vector<Expr>
- mkVars(const std::vector<std::string> names, const Type& type);
+ mkVars(const std::vector<std::string> names, const Type& type,
+ bool levelZero = false);
/** Create a new CVC4 function expression of the given type. */
- Expr mkFunction(const std::string& name, const Type& type);
+ Expr mkFunction(const std::string& name, const Type& type,
+ bool levelZero = false);
/**
* Create a new CVC4 function expression of the given type,
Expr mkAnonymousFunction(const std::string& prefix, const Type& type);
/** Create a new variable definition (e.g., from a let binding). */
- void defineVar(const std::string& name, const Expr& val);
+ void defineVar(const std::string& name, const Expr& val,
+ bool levelZero = false);
/** Create a new function definition (e.g., from a define-fun). */
- void defineFunction(const std::string& name, const Expr& val);
+ void defineFunction(const std::string& name, const Expr& val,
+ bool levelZero = false);
/** Create a new type definition. */
void defineType(const std::string& name, const Type& type);
/**
* Preempt the next returned command with other ones; used to
* support the :named attribute in SMT-LIBv2, which implicitly
- * inserts a new command before the current one.
+ * inserts a new command before the current one. Also used in TPTP
+ * because function and predicate symbols are implicitly declared.
*/
void preemptCommand(Command* cmd);