bool isAtomic(Kind k);
bool isCommutative(const Kind k);
-
// If (a > b) in the termorder, then return 1 elseif (a < b) in the
// termorder, then return -1 else return 0
int TermOrder(const ASTNode& a, const ASTNode& b);
// Function to dump contents of ASTNodeMap
ostream &operator<<(ostream &os, const ASTNodeMap &nmap);
+
+ void buildListOfSymbols(const ASTNode& n, ASTNodeSet& visited,ASTNodeSet& symbols);
}; // end namespace BEEV
#endif
return true;
}
+ void buildListOfSymbols(const ASTNode& n, ASTNodeSet& visited,
+ ASTNodeSet& symbols)
+ {
+ if (visited.find(n) != visited.end())
+ return; // already visited.
+
+ visited.insert(n);
+
+ if (n.GetKind() == SYMBOL)
+ {
+ symbols.insert(n);
+ }
+
+ for (unsigned i = 0; i < n.GetChildren().size(); i++)
+ buildListOfSymbols(n[i], visited, symbols);
+ }
/* FUNCTION: Typechecker for terms and formulas
void ASTNodeStats(const char * c, const ASTNode& a);
// Print variable to the input stream
- void printVarDeclsToStream(ostream &os);
+ void printVarDeclsToStream(ostream &os, ASTNodeSet& symbols);
// Print assertions to the input stream
void printAssertsToStream(ostream &os, int simplify);
if (onePrintBack)
{
+ ASTNode original_input = bm->CreateNode(AND,
+ bm->CreateNode(NOT, query),
+ asserts);
+
+
if(bm->UserFlags.print_STPinput_back_flag)
{
if(bm->UserFlags.smtlib_parser_flag)
if (bm->UserFlags.print_STPinput_back_CVC_flag)
{
+ //needs just the query. Reads the asserts out of the data structure.
print_STPInput_Back(query);
}
if (bm->UserFlags.print_STPinput_back_SMTLIB_flag)
{
- printer::SMTLIB_PrintBack(cout, asserts);
+ printer::SMTLIB_PrintBack(cout, original_input);
}
if (bm->UserFlags.print_STPinput_back_C_flag)
{
- printer::C_Print(cout, asserts);
+ printer::C_Print(cout, original_input);
}
if (bm->UserFlags.print_STPinput_back_GDL_flag)
{
- printer::GDL_Print(cout, asserts);
+ printer::GDL_Print(cout, original_input);
}
if (bm->UserFlags.print_STPinput_back_dot_flag)
{
- printer::Dot_Print(cout, asserts);
+ printer::Dot_Print(cout, original_input);
}
return 0;
// cout << endl;
// } //end of Convert_MINISATVar_To_ASTNode_Print()
- void STPMgr::printVarDeclsToStream(ostream &os) {
- for(ASTVec::iterator
+ void STPMgr::printVarDeclsToStream(ostream &os, ASTNodeSet& ListOfDeclaredVars) {
+ for(ASTNodeSet::iterator
i = ListOfDeclaredVars.begin(),iend=ListOfDeclaredVars.end();
i!=iend;i++)
{
}
} //printVarDeclsToStream
-
-
void STPMgr::printAssertsToStream(ostream &os, int simplify_print) {
ASTVec v = GetAsserts();
for(ASTVec::iterator i=v.begin(),iend=v.end();i!=iend;i++) {
}
void print_STPInput_Back(const ASTNode& query) {
- (BEEV::GlobalSTP->bm)->printVarDeclsToStream(cout);
+
+ // Determine the symbols in the query and asserts.
+ ASTNodeSet visited;
+ ASTNodeSet symbols;
+ buildListOfSymbols(query, visited, symbols);
+ ASTVec v = (BEEV::GlobalSTP->bm)->GetAsserts();
+ for(ASTVec::iterator i=v.begin(),iend=v.end();i!=iend;i++)
+ buildListOfSymbols(*i, visited, symbols);
+
+ (BEEV::GlobalSTP->bm)->printVarDeclsToStream(cout, symbols);
(BEEV::GlobalSTP->bm)->printAssertsToStream(cout,0);
cout << "QUERY(";
query.PL_Print(cout);
os << "\"}" << endl;
// print the edges to each child.
- ASTVec ch = n.GetChildren();
- ASTVec::iterator itend = ch.end();
+ const ASTVec ch = n.GetChildren();
+ const ASTVec::const_iterator itend = ch.end();
//If a node has the child 'TRUE' twice, we only want to output one TRUE node.
ASTNodeSet constantOutput;
int i =0;
- for (ASTVec::iterator it = ch.begin(); it < itend; it++)
+ for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
{
std::stringstream label;
}
// print each of the children.
- for (ASTVec::iterator it = ch.begin(); it < itend; it++)
+ for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
{
if (!it->isConstant())
GDL_Print1(os, *it, alreadyOutput,annotate);
//correctly print shared subterms inside the LET itself
ASTNodeMap NodeLetVarMap1;
-void buildListOfSymbols(const ASTNode& n, ASTNodeSet& visited,
- ASTNodeSet& symbols)
-{
- if (visited.find(n) != visited.end())
- return; // already visited.
-
- visited.insert(n);
-
- if (n.GetKind() == SYMBOL)
- {
- symbols.insert(n);
- }
-
- for (unsigned i = 0; i < n.GetChildren().size(); i++)
- buildListOfSymbols(n[i], visited, symbols);
-}
-
// Initial version intended to print the whole thing back.
void SMTLIB_PrintBack(ostream &os, const ASTNode& n)
{
os << ":" << a.GetValueWidth() << "] ))" << endl;
break;
case BEEV::BOOLEAN_TYPE:
- os << ":extrapred (( ";
+ os << ":extrapreds (( ";
a.nodeprint(os);
os << "))" << endl;
break;
case FALSE:
os << "false";
break;
+ case NAND: // No NAND in smtlib format.
+ assert(c.size() ==2);
+ os << "(" << "not ";
+ os << "(" << "and ";
+ SMTLIB_Print1(os, c[0], 0, letize);
+ os << " " ;
+ SMTLIB_Print1(os, c[1], 0, letize);
+ os << "))";
+ break;
case TRUE:
os << "true";
break;
os << ")";
}
break;
- default:
- {
- os << "(" << functionToSMTLIBName(kind);
-
- ASTVec::const_iterator iend = c.end();
- for (ASTVec::const_iterator i = c.begin(); i != iend; i++)
- {
- os << " ";
- SMTLIB_Print1(os, *i, 0, letize);
- }
-
- os << ")";
- }
+ default:
+ {
+ // SMT-LIB only allows arithmetic functions to have two parameters.
+ if (BVPLUS == kind && n.Degree() > 2)
+ {
+ string close = "";
+
+ for (int i =0; i < c.size()-1; i++)
+ {
+ os << "(" << functionToSMTLIBName(kind);
+ os << " ";
+ SMTLIB_Print1(os, c[i], 0, letize);
+ os << " ";
+ close += ")";
+ }
+ SMTLIB_Print1(os, c[c.size()-1], 0, letize);
+ os << close;
+ }
+ else
+ {
+ os << "(" << functionToSMTLIBName(kind);
+
+ ASTVec::const_iterator iend = c.end();
+ for (ASTVec::const_iterator i = c.begin(); i != iend; i++)
+ {
+ os << " ";
+ SMTLIB_Print1(os, *i, 0, letize);
+ }
+
+ os << ")";
+ }
+ }
}
}