//UserGuided abstraction refinement SOLVER_RETURN_TYPE STP:: UserGuided_AbsRefine(SATSolver& 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); if(SOLVER_UNDECIDED != res) { return res; } FatalError("TopLevelSTPAux: reached the end without proper conclusion:" "either a divide by zero in the input or a bug in STP"); return SOLVER_ERROR; } //End of UserGuided_AbsRefine()
int Main::main(int argc, char** argv) { unique_ptr<SimplifyingNodeFactory> simplifyingNF( new SimplifyingNodeFactory(*bm->hashingNodeFactory, *bm)); bm->defaultNodeFactory = simplifyingNF.get(); unique_ptr<Simplifier> simp(new Simplifier(bm)); unique_ptr<ArrayTransformer> arrayTransformer( new ArrayTransformer(bm, simp.get())); unique_ptr<ToSAT> tosat(new ToSAT(bm)); unique_ptr<AbsRefine_CounterExample> Ctr_Example( new AbsRefine_CounterExample(bm, simp.get(), arrayTransformer.get())); int ret = create_and_parse_options(argc, argv); if (ret != 0) { return ret; } STP* stp = new STP(bm, simp.get(), arrayTransformer.get(), tosat.get(), Ctr_Example.get()); GlobalSTP = stp; // If we're not reading the file from stdin. if (!infile.empty()) read_file(); // want to print the output always from the commandline. bm->UserFlags.print_output_flag = true; ASTVec* AssertsQuery = new ASTVec; bm->GetRunTimes()->start(RunTimes::Parsing); parse_file(AssertsQuery); bm->GetRunTimes()->stop(RunTimes::Parsing); GlobalSTP = NULL; /* The SMTLIB2 has a command language. The parser calls all the functions, * so when we get to here the parser has already called "exit". i.e. if the * language is smt2 then all the work has already been done, and all we need * to do is cleanup... * */ if (!bm->UserFlags.smtlib2_parser_flag) { if (AssertsQuery->empty()) FatalError("Input is Empty. Please enter some asserts and query\n"); if (AssertsQuery->size() != 2) FatalError("Input must contain a query\n"); ASTNode asserts = (*AssertsQuery)[0]; ASTNode query = (*AssertsQuery)[1]; if (onePrintBack) { print_back(query, asserts); } else { SOLVER_RETURN_TYPE ret = stp->TopLevelSTP(asserts, query); if (bm->UserFlags.quick_statistics_flag) { bm->GetRunTimes()->print(); } stp->tosat->PrintOutput(ret); } asserts = ASTNode(); query = ASTNode(); } // Previously we used fast-exit to avoid destroying lots of objects, for example in the node manager. // We use unique_ptr now on lots of stuff, so there seems little difference in the time it takes to // exit normally vs. not. //if (bm->UserFlags.isSet("fast-exit", "0")) // exit(0); //Cleanup AssertsQuery->clear(); delete AssertsQuery; _empty_ASTVec.clear(); delete stp; CNFClearMemory(); return 0; }