Fix binding of quoted symbols in `define-fun` (#7655)
authorAndres Noetzli <andres.noetzli@gmail.com>
Wed, 17 Nov 2021 01:31:32 +0000 (17:31 -0800)
committerGitHub <noreply@github.com>
Wed, 17 Nov 2021 01:31:32 +0000 (01:31 +0000)
Our `DefineFunctionCommand` was binding the string representation of the
function symbol including the `|` quotes instead of the symbol without
the quotes. This commit fixes the issue.

src/parser/smt2/smt2.cpp
src/smt/command.cpp
test/regress/CMakeLists.txt
test/regress/regress0/parser/quoted-define-fun.smt2 [new file with mode: 0644]

index 3c423674a15a3009628ac2555f061261d6d4d759..ad380a31c730eec8320963f885d4f3699c19d262 100644 (file)
@@ -879,7 +879,7 @@ void Smt2::parseOpApplyTypeAscription(ParseOp& p, api::Sort type)
 
 api::Term Smt2::parseOpToExpr(ParseOp& p)
 {
-  Debug("parser") << "parseOpToExpr: " << p << std::endl;
+  Trace("parser") << "parseOpToExpr: " << p << std::endl;
   api::Term expr;
   if (p.d_kind != api::NULL_EXPR || !p.d_type.isNull())
   {
index 83f7614282629f58a5970558f436017a2775f91c..283925903269f1b2a9cc06ee6b77a9619e7f2245 100644 (file)
@@ -1340,7 +1340,7 @@ void DefineFunctionCommand::invoke(api::Solver* solver, SymbolManager* sm)
     bool global = sm->getGlobalDeclarations();
     api::Term fun =
         solver->defineFun(d_symbol, d_formals, d_sort, d_formula, global);
-    sm->getSymbolTable()->bind(fun.toString(), fun, global);
+    sm->getSymbolTable()->bind(d_symbol, fun, global);
     d_commandStatus = CommandSuccess::instance();
   }
   catch (exception& e)
index 4aae3899dc0e689a40bceff88b7332b766533952..7806eb308d9e07ba95cc4c24e369a1d74b97dd1c 100644 (file)
@@ -802,6 +802,7 @@ set(regress_0_tests
   regress0/parser/linear_arithmetic_err3.smt2
   regress0/parser/named-attr-error.smt2
   regress0/parser/named-attr.smt2
+  regress0/parser/quoted-define-fun.smt2
   regress0/parser/shadow_fun_symbol_all.smt2
   regress0/parser/shadow_fun_symbol_nirat.smt2
   regress0/parser/strings20.smt2
diff --git a/test/regress/regress0/parser/quoted-define-fun.smt2 b/test/regress/regress0/parser/quoted-define-fun.smt2
new file mode 100644 (file)
index 0000000..02c3e3d
--- /dev/null
@@ -0,0 +1,5 @@
+(set-logic QF_BV)
+(define-fun |def_B definitions| () Bool true)
+(assert |def_B definitions|)
+(set-info :status sat)
+(check-sat)