// Usual constructor.
ASTNode(ASTInternal *in);
+ //Integer that helps sort the ASTNodes. This sorting is different
+ //from the sorting based on NodeNum. This is used as a way of
+ //achieving abstraction-refinement.
+ unsigned int _sort_for_absrefine;
+
//Equal iff ASTIntNode pointers are the same.
friend bool operator==(const ASTNode node1, const ASTNode node2)
{
}
public:
+ //Set the sorting integer for abstraction refinement
+ void SetAbsRefineInt(unsigned int a) {_sort_for_absrefine = a;}
+
+ //Get the sorting integer for abstraction refinement
+ unsigned int GetAbsRefineInt(void) {return _sort_for_absrefine;}
+
+ //Compare two ASTNodes based on their abstraction refinement
+ //number
+ bool CmpAbsRefine(const ASTNode node1, const ASTNode node2) {
+ return (node1._sort_for_absrefine < node2._sort_for_absrefine);
+ }
+
//Check if it points to a null node
bool IsNull() const
{
ASTNode() :
_int_node_ptr(NULL)
{
+ _sort_for_absrefine=0;
}
;
ASTNode::ASTNodeHasher,
ASTNode::ASTNodeEqual> ASTNodeCountMap;
+// typedef hash_map<int32_t,
+// ASTVec,
+// hash(int32_t)> IntToASTVecMap;
// Function to dump contents of ASTNodeMap
ostream &operator<<(ostream &os, const ASTNodeMap &nmap);
//by PUSH/POP
std::vector<ASTVec *> _asserts;
//The query for the current logical context.
- ASTNode _current_query;
+ ASTNode _current_query;
//this flag, when true, indicates that counterexample is being
//checked by the counterexample checker
void vc_setFlags(char c) {
std::string helpstring = "Usage: stp [-option] [infile]\n\n";
- helpstring += "-r : switch refinement off (optimizations are ON by default)\n";
- helpstring += "-w : switch wordlevel solver off (optimizations are ON by default)\n";
+ helpstring += "STP version: " + BEEV::version + "\n\n";
helpstring += "-a : switch optimizations off (optimizations are ON by default)\n";
- helpstring += "-s : print function statistics\n";
- helpstring += "-v : print nodes \n";
helpstring += "-c : construct counterexample\n";
helpstring += "-d : check counterexample\n";
- helpstring += "-p : print counterexample\n";
- helpstring += "-y : print counterexample in binary\n";
- helpstring += "-b : print STP input back to cout\n";
- helpstring += "-x : flatten nested XORs\n";
+ helpstring += "-e : expand finite-for construct\n";
+ helpstring += "-f : number of abstraction-refinement loops\n";
helpstring += "-h : help\n";
helpstring += "-m : use the SMTLIB parser\n";
-
+ helpstring += "-p : print counterexample\n";
+ helpstring += "-r : switch refinement off (optimizations are ON by default)\n";
+ helpstring += "-s : print function statistics\n";
+ helpstring += "-v : print nodes \n";
+ helpstring += "-w : switch wordlevel solver off (optimizations are ON by default)\n";
+ helpstring += "-x : flatten nested XORs\n";
+ helpstring += "-y : print counterexample in binary\n";
+
switch(c) {
case 'a' :
BEEV::optimize_flag = false;
- BEEV::wordlevel_solve_flag = false;
- break;
- case 'b':
- BEEV::print_STPinput_back_flag = true;
break;
case 'c':
BEEV::construct_counterexample_flag = true;
BEEV::construct_counterexample_flag = true;
BEEV::check_counterexample_flag = true;
break;
+ case 'e':
+ BEEV::expand_finitefor_flag = true;
+ break;
+ case 'f':
+ BEEV::num_absrefine_flag = true;
+ //BEEV::num_absrefine = atoi(argv[++i]);
+ break;
case 'h':
+ BEEV::fprintf(stderr,BEEV::usage,BEEV::prog);
cout << helpstring;
- BEEV::FatalError("");
+ //FatalError("");
+ //return -1;
break;
case 'n':
BEEV::print_output_flag = true;
break;
+ case 'm':
+ BEEV::smtlib_parser_flag=true;
+ BEEV::division_by_zero_returns_one = true;
+ break;
case 'p':
BEEV::print_counterexample_flag = true;
break;
BEEV::stats_flag = true;
break;
case 'u':
- BEEV::arraywrite_refinement_flag = true;
- break;
+ BEEV::arraywrite_refinement_flag = false;
+ break;
case 'v' :
BEEV::print_nodes_flag = true;
break;
BEEV::wordlevel_solve_flag = false;
break;
case 'x':
- cinterface_exprdelete_on_flag = true;
+ BEEV::xor_flatten_flag = true;
+ break;
+ case 'y':
+ BEEV::print_binary_flag = true;
break;
case 'z':
BEEV::print_sat_varorder_flag = true;
- break;
+ break;
default:
std::string s = "C_interface: vc_setFlags: Unrecognized commandline flag:\n";
s += helpstring;
BEEV::FatalError(s.c_str());
break;
}
+
+
}
//Create a validity Checker. This is the global BeevMgr
/////////////////////////////////////////////////////////////////////////////
//! Assert a new formula in the current context.
/*! The formula must have Boolean type. */
-void vc_assertFormula(VC vc, Expr e) {
+void vc_assertFormula(VC vc, Expr e, int absrefine_num) {
nodestar a = (nodestar)e;
bmstar b = (bmstar)vc;
BEEV::FatalError("Trying to assert a NON formula: ",*a);
b->BVTypeCheck(*a);
+ a->SetAbsRefineInt(absrefine_num);
b->AddAssert(*a);
}
if(!BEEV::is_Form_kind(a->GetKind()))
BEEV::FatalError("CInterface: Trying to QUERY a NON formula: ",*a);
- //printf("kill all humans\n");
//a->LispPrint(cout, 0);
//printf("##################################################\n");
b->BVTypeCheck(*a);
b->AddQuery(*a);
- const BEEV::ASTVec v = b->GetAsserts();
+ const BEEV::ASTVec v = b->GetAsserts();
node o;
if(!v.empty()) {
if(v.size()==1)
return output;
}
+Expr vc_bvPlusExprN(VC vc, int n_bits, Expr* cc, int n) {
+ bmstar b = (bmstar)vc;
+ nodestar * c = (nodestar *)cc;
+ nodelist d;
+
+ for(int i =0; i < n; i++)
+ d.push_back(*c[i]);
+
+ node o = b->CreateTerm(BEEV::BVPLUS, n_bits, d);
+ b->BVTypeCheck(o);
+
+ nodestar output = new node(o);
+ //if(cinterface_exprdelete_on) created_exprs.push_back(output);
+ return output;
+}
+
+
Expr vc_iteExpr(VC vc, Expr cond, Expr thenpart, Expr elsepart){
bmstar b = (bmstar)vc;
nodestar c = (nodestar)cond;
return output;
}
+Expr vc_paramBoolExpr(VC vc, Expr boolvar, Expr parameter){
+ bmstar b = (bmstar)vc;
+ nodestar c = (nodestar)boolvar;
+ nodestar t = (nodestar)parameter;
+
+ b->BVTypeCheck(*c);
+ b->BVTypeCheck(*t);
+ node o;
+
+ o = b->CreateNode(BEEV::PARAMBOOL,*c,*t);
+ //b->BVTypeCheck(o);
+ nodestar output = new node(o);
+ //if(cinterface_exprdelete_on) created_exprs.push_back(output);
+ return output;
+}
+
+
/////////////////////////////////////////////////////////////////////////////
// BITVECTOR EXPR Creation methods //
/////////////////////////////////////////////////////////////////////////////
//Boolean to single bit BV Expression
Expr vc_boolToBVExpr(VC vc, Expr form);
+ //Parameterized Boolean Expression (PARAMBOOL, Boolean_Var, parameter)
+ Expr vc_paramBoolExpr(VC vc, Expr var, Expr param);
+
// Arrays
//! Create an expression for the value of array at the given index
//! Assert a new formula in the current context.
/*! The formula must have Boolean type. */
- void vc_assertFormula(VC vc, Expr e);
+ void vc_assertFormula(VC vc, Expr e, int absrefine_num=0);
//! Simplify e with respect to the current context
Expr vc_simplify(VC vc, Expr e);
Expr vc_bvConcatExpr(VC vc, Expr left, Expr right);
Expr vc_bvPlusExpr(VC vc, int n_bits, Expr left, Expr right);
+ Expr vc_bvPlusExprN(VC vc, int n_bits, Expr* children, int numOfChildNodes);
Expr vc_bv32PlusExpr(VC vc, Expr left, Expr right);
Expr vc_bvMinusExpr(VC vc, int n_bits, Expr left, Expr right);
Expr vc_bv32MinusExpr(VC vc, Expr left, Expr right);