Fix printing issue related to nested quotes (#3154)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Sat, 3 Aug 2019 16:56:51 +0000 (11:56 -0500)
committerGitHub <noreply@github.com>
Sat, 3 Aug 2019 16:56:51 +0000 (11:56 -0500)
src/expr/uninterpreted_constant.cpp
src/printer/smt2/smt2_printer.cpp
src/theory/theory_model_builder.cpp

index 5c9daf7849dd9e025892128c65916747413cabe3..64180c377c2b504748ed359713b309269b363307 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "expr/uninterpreted_constant.h"
 
+#include <algorithm>
 #include <iostream>
 #include <sstream>
 #include <string>
@@ -34,7 +35,18 @@ UninterpretedConstant::UninterpretedConstant(Type type, Integer index)
 }
 
 std::ostream& operator<<(std::ostream& out, const UninterpretedConstant& uc) {
-  return out << "uc_" << uc.getType() << '_' << uc.getIndex();
+  std::stringstream ss;
+  ss << uc.getType();
+  std::string st(ss.str());
+  // must remove delimiting quotes from the name of the type
+  // this prevents us from printing symbols like |@uc_|T|_n|
+  std::string q("|");
+  size_t pos;
+  while ((pos = st.find(q)) != std::string::npos)
+  {
+    st.replace(pos, 1, "");
+  }
+  return out << "uc_" << st.c_str() << "_" << uc.getIndex();
 }
 
 }/* CVC4 namespace */
index fd8b4ce85f862a1f7c7248d15ca9187c956d0464..dbb89d8575537b3d2158dcda384e3f61f90685bd 100644 (file)
@@ -1760,7 +1760,8 @@ static void toStreamRational(std::ostream& out,
 
 static void toStream(std::ostream& out, const DeclareTypeCommand* c)
 {
-  out << "(declare-sort " << c->getSymbol() << " " << c->getArity() << ")";
+  out << "(declare-sort " << maybeQuoteSymbol(c->getSymbol()) << " "
+      << c->getArity() << ")";
 }
 
 static void toStream(std::ostream& out, const DefineTypeCommand* c)
index b032dfec4386d928179cbbbb6e8f1d9eabff79a1..c4be410843efa7df6358a6f689ea78019dd39fb1 100644 (file)
@@ -1005,7 +1005,7 @@ void TheoryEngineModelBuilder::assignFunction(TheoryModel* m, Node f)
     ufmt.simplify();
   }
   std::stringstream ss;
-  ss << "_arg_" << f << "_";
+  ss << "_arg_";
   Node val = ufmt.getFunctionValue(ss.str().c_str(), condenseFuncValues);
   m->assignFunctionDefinition(f, val);
   // ufmt.debugPrint( std::cout, m );