diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2020-11-18 08:34:12 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-18 08:34:12 -0600 |
commit | 3c246952ce90ae7c27b4c0646fce05bc69037f46 (patch) | |
tree | abb7ef449ad0329157a5e5188a7500e8ea1d55c6 /src/parser/smt2 | |
parent | 8cdef42785fd294d1727ce1df1b11d754c9bb3d1 (diff) |
Use symbol manager for get assignment (#5451)
This replaces the previous methods for get-assignment which involving making a DefinedNamedFunctIonCommand and storing the expression names map in the SmtEngine.
Note: we now limit :named terms to those not beneath quantifiers and let-bindings.
Diffstat (limited to 'src/parser/smt2')
-rw-r--r-- | src/parser/smt2/Smt2.g | 14 | ||||
-rw-r--r-- | src/parser/smt2/smt2.cpp | 26 | ||||
-rw-r--r-- | src/parser/smt2/smt2.h | 14 |
3 files changed, 13 insertions, 41 deletions
diff --git a/src/parser/smt2/Smt2.g b/src/parser/smt2/Smt2.g index 916e20d9b..2b32afa15 100644 --- a/src/parser/smt2/Smt2.g +++ b/src/parser/smt2/Smt2.g @@ -1841,18 +1841,8 @@ attribute[CVC4::api::Term& expr, CVC4::api::Term& retExpr, std::string& attr] | ATTRIBUTE_NAMED_TOK symbolicExpr[sexpr] { attr = std::string(":named"); - api::Term func = PARSER_STATE->setNamedAttribute(expr, sexpr); - std::string name = sexpr.getValue(); - // bind name to expr with define-fun - // TODO (projects-248) SYM_MAN->setExpressionName(func, name, false); - Command* c = - new DefineNamedFunctionCommand(name, - func, - std::vector<api::Term>(), - expr, - SYM_MAN->getGlobalDeclarations()); - c->setMuted(true); - PARSER_STATE->preemptCommand(c); + // notify that expression was given a name + PARSER_STATE->notifyNamedExpression(expr, sexpr.getValue()); } ; diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp index 892c628dc..b9279fcb0 100644 --- a/src/parser/smt2/smt2.cpp +++ b/src/parser/smt2/smt2.cpp @@ -1218,28 +1218,16 @@ api::Term Smt2::applyParseOp(ParseOp& p, std::vector<api::Term>& args) return ret; } -api::Term Smt2::setNamedAttribute(api::Term& expr, const SExpr& sexpr) +void Smt2::notifyNamedExpression(api::Term& expr, std::string name) { - if (!sexpr.isKeyword()) - { - parseError("improperly formed :named annotation"); - } - std::string name = sexpr.getValue(); checkUserSymbol(name); - // ensure expr is a closed subterm - if (expr.getExpr().hasFreeVariable()) - { - std::stringstream ss; - ss << ":named annotations can only name terms that are closed"; - parseError(ss.str()); - } - // check that sexpr is a fresh function symbol, and reserve it - reserveSymbolAtAssertionLevel(name); - // define it - api::Term func = bindVar(name, expr.getSort(), ExprManager::VAR_FLAG_DEFINED); - // remember the last term to have been given a :named attribute + // remember the expression name in the symbol manager + getSymbolManager()->setExpressionName(expr, name, false); + // define the variable + defineVar(name, expr); + // set the last named term, which ensures that we catch when assertions are + // named setLastNamedTerm(expr, name); - return func; } api::Term Smt2::mkAnd(const std::vector<api::Term>& es) diff --git a/src/parser/smt2/smt2.h b/src/parser/smt2/smt2.h index 734b00f92..fd08ab241 100644 --- a/src/parser/smt2/smt2.h +++ b/src/parser/smt2/smt2.h @@ -343,17 +343,11 @@ class Smt2 : public Parser } this->Parser::checkDeclaration(name, check, type, notes); } - /** Set named attribute - * - * This is called when expression expr is annotated with a name, i.e. - * (! expr :named sexpr). It sets up the necessary information to process - * this naming, including marking that expr is the last named term. - * - * We construct an expression symbol whose name is the name of s-expression - * which is used later for tracking assertions in unsat cores. This - * symbol is returned by this method. + /** + * Notify that expression expr was given name std::string via a :named + * attribute. */ - api::Term setNamedAttribute(api::Term& expr, const SExpr& sexpr); + void notifyNamedExpression(api::Term& expr, std::string name); // Throw a ParserException with msg appended with the current logic. inline void parseErrorLogic(const std::string& msg) |