namespace BEEV {
+ // The absolute TopLevel function that invokes STP on the input
+ // formula
+ SOLVER_RETURN_TYPE STP::TopLevelSTP(const ASTNode& inputasserts,
+ const ASTNode& query)
+ {
+ ASTNode original_input = bm->CreateNode(AND,
+ inputasserts,
+ bm->CreateNode(NOT, query));
+ ASTNode modified_input = original_input;
+
+ //solver instantiated here
+#ifdef CORE
+ MINISAT::Solver NewSolver;
+#endif
+#ifdef CRYPTOMINISAT
+ MINISAT::Solver NewSolver;
+#endif
+#ifdef SIMP
+ MINISAT::SimpSolver NewSolver;
+#endif
+#ifdef UNSOUND
+ MINISAT::UnsoundSimpSolver NewSolver;
+#endif
+
+ if(bm->UserFlags.num_absrefine_flag)
+ {
+ return UserGuided_AbsRefine(NewSolver,
+ original_input);
+ }
+ else
+ {
+ return TopLevelSTPAux(NewSolver,
+ modified_input, original_input);
+ }
+ } //End of TopLevelSTP()
+
//Acceps a query, calls the SAT solver and generates Valid/InValid.
//if returned 0 then input is INVALID if returned 1 then input is
//VALID if returned 2 then UNDECIDED
- SOLVER_RETURN_TYPE STP::TopLevelSTPAux(const ASTNode& inputasserts_and_query)
+ SOLVER_RETURN_TYPE STP::TopLevelSTPAux(MINISAT::Solver& NewSolver,
+ const ASTNode& modified_input,
+ const ASTNode& original_input)
{
- ASTNode inputToSAT = inputasserts_and_query;
- ASTNode orig_input = inputToSAT;
+ ASTNode inputToSAT = modified_input;
+ ASTNode orig_input = original_input;
bm->ASTNodeStats("input asserts and query: ", inputToSAT);
ASTNode simplified_solved_InputToSAT = inputToSAT;
bm->TermsAlreadySeenMap_Clear();
SOLVER_RETURN_TYPE res;
-
- //solver instantiated here
-#ifdef CORE
- MINISAT::Solver newS;
-#endif
-#ifdef CRYPTOMINISAT
- MINISAT::Solver newS;
-#endif
-#ifdef SIMP
- MINISAT::SimpSolver newS;
-#endif
-#ifdef UNSOUND
- MINISAT::UnsoundSimpSolver newS;
-#endif
-
- if(bm->UserFlags.num_absrefine_flag
- && !bm->UserFlags.arrayread_refinement_flag)
- {
- res =
- Ctr_Example->UserGuided_AbsRefine(newS,
- orig_input);
- return res;
- }
-
if (bm->UserFlags.arrayread_refinement_flag)
{
bm->counterexample_checking_during_refinement = true;
}
res =
- Ctr_Example->CallSAT_ResultCheck(newS,
+ Ctr_Example->CallSAT_ResultCheck(NewSolver,
simplified_solved_InputToSAT,
orig_input);
if (SOLVER_UNDECIDED != res)
return res;
}
- // res = SATBased_AllFiniteLoops_Refinement(newS, orig_input);
+ // res = SATBased_AllFiniteLoops_Refinement(NewSolver, orig_input);
// if (SOLVER_UNDECIDED != res)
// {
// CountersAndStats("print_func_stats");
// }
res =
- Ctr_Example->SATBased_ArrayReadRefinement(newS,
+ Ctr_Example->SATBased_ArrayReadRefinement(NewSolver,
simplified_solved_InputToSAT,
orig_input);
if (SOLVER_UNDECIDED != res)
}
res =
- Ctr_Example->SATBased_ArrayWriteRefinement(newS, orig_input);
+ Ctr_Example->SATBased_ArrayWriteRefinement(NewSolver, orig_input);
if (SOLVER_UNDECIDED != res)
{
CountersAndStats("print_func_stats", bm);
}
res =
- Ctr_Example->SATBased_ArrayReadRefinement(newS,
+ Ctr_Example->SATBased_ArrayReadRefinement(NewSolver,
simplified_solved_InputToSAT,
orig_input);
if (SOLVER_UNDECIDED != res)
//bogus return to make the compiler shut up
return SOLVER_ERROR;
} //End of TopLevelSTPAux
+
+ //UserGuided abstraction refinement
+ SOLVER_RETURN_TYPE
+ STP::
+ UserGuided_AbsRefine(MINISAT::Solver& NewSolver,
+ const ASTNode& original_input)
+ {
+ ASTVec v = bm->GetAsserts_WithKey(0);
+ if(v.empty())
+ {
+ FatalError("UserGuided_AbsRefine: Something is seriously wrong."\
+ "The input set is empty");
+ }
+ ASTNode sureAddInput =
+ (v.size() == 1) ? v[0] : bm->CreateNode(AND, v);
+
+ SOLVER_RETURN_TYPE res = SOLVER_UNDECIDED;
+ res = TopLevelSTPAux(NewSolver, sureAddInput, original_input);
+ if(SOLVER_UNDECIDED != res)
+ {
+ return res;
+ }
+
+ //Do refinement here
+ if(AND != original_input.GetKind())
+ {
+ FatalError("UserGuided_AbsRefine: The input must be an AND");
+ }
+
+ ASTVec RefineFormulasVec;
+ ASTVec RemainingFormulasVec;
+ ASTNode asttrue = bm->CreateNode(TRUE);
+ ASTNode astfalse = bm->CreateNode(FALSE);
+ for(int count=0; count < bm->UserFlags.num_absrefine; count++)
+ {
+ RemainingFormulasVec.clear();
+ RemainingFormulasVec.push_back(asttrue);
+ RefineFormulasVec.clear();
+ RefineFormulasVec.push_back(asttrue);
+ ASTVec InputKids = original_input.GetChildren();
+ for(ASTVec::iterator it = InputKids.begin(), itend = InputKids.end();
+ it!=itend;it++)
+ {
+ Ctr_Example->ClearComputeFormulaMap();
+ if(astfalse == Ctr_Example->ComputeFormulaUsingModel(*it))
+ {
+ RefineFormulasVec.push_back(*it);
+ }
+ else
+ {
+ RemainingFormulasVec.push_back(*it);
+ }
+ }
+ ASTNode RefineFormulas =
+ (RefineFormulasVec.size() == 1) ?
+ RefineFormulasVec[0] : bm->CreateNode(AND, RefineFormulasVec);
+ res = TopLevelSTPAux(NewSolver, RefineFormulas, original_input);
+ if(SOLVER_UNDECIDED != res)
+ {
+ return res;
+ }
+ }
+
+ ASTNode RemainingFormulas =
+ (RemainingFormulasVec.size() == 1) ?
+ RemainingFormulasVec[0] : bm->CreateNode(AND, RemainingFormulasVec);
+ res = TopLevelSTPAux(NewSolver, RemainingFormulas, original_input);
+ return res;
+ } //End of UserGuided_AbsRefine()
}; //end of namespace
return arraywrite_axiom;
}//end of Create_ArrayWriteAxioms()
- //UserGuided abstraction refinement
- SOLVER_RETURN_TYPE
- AbsRefine_CounterExample::
- UserGuided_AbsRefine(MINISAT::Solver& SatSolver,
- //const ASTNode& modified_input,
- const ASTNode& original_input)
- {
- ASTVec v = bm->GetAsserts_WithKey(0);
- if(v.empty())
- {
- FatalError("UserGuided_AbsRefine: Something is seriously wrong."\
- "The input set is empty");
- }
- ASTNode sureAddInput =
- (v.size() == 1) ? v[0] : bm->CreateNode(AND, v);
-
- SOLVER_RETURN_TYPE res = SOLVER_UNDECIDED;
- res = CallSAT_ResultCheck(SatSolver, sureAddInput, original_input);
- if(SOLVER_UNDECIDED != res)
- {
- return res;
- }
-
- //Do refinement here
- if(AND != original_input.GetKind())
- {
- FatalError("UserGuided_AbsRefine: The input must be an AND");
- }
-
- ASTVec RefineFormulasVec;
- ASTVec RemainingFormulasVec;
- for(int count=0; count < bm->UserFlags.num_absrefine; count++)
- {
- RemainingFormulasVec.clear();
- RemainingFormulasVec.push_back(ASTTrue);
- RefineFormulasVec.clear();
- RefineFormulasVec.push_back(ASTTrue);
- ASTVec InputKids = original_input.GetChildren();
- for(ASTVec::iterator it = InputKids.begin(), itend = InputKids.end();
- it!=itend;it++)
- {
- ClearComputeFormulaMap();
- if(ASTFalse == ComputeFormulaUsingModel(*it))
- {
- RefineFormulasVec.push_back(*it);
- }
- else
- {
- RemainingFormulasVec.push_back(*it);
- }
- }
- ASTNode RefineFormulas =
- (RefineFormulasVec.size() == 1) ?
- RefineFormulasVec[0] : bm->CreateNode(AND, RefineFormulasVec);
- res = CallSAT_ResultCheck(SatSolver, RefineFormulas, original_input);
- if(SOLVER_UNDECIDED != res)
- {
- return res;
- }
- }
-
- ASTNode RemainingFormulas =
- (RemainingFormulasVec.size() == 1) ?
- RemainingFormulasVec[0] : bm->CreateNode(AND, RemainingFormulasVec);
- res = CallSAT_ResultCheck(SatSolver, RemainingFormulas, original_input);
- return res;
- } //End of UserGuided_AbsRefine()
-
// static void ReplaceOrAddToMap(ASTNodeMap * VarToConstMap,
// const ASTNode& key, const ASTNode& value)
// {