return arraywrite_axiom;
}//end of Create_ArrayWriteAxioms()
- // static void ReplaceOrAddToMap(ASTNodeMap * VarToConstMap,
- // const ASTNode& key, const ASTNode& value)
- // {
- // ASTNodeMap::iterator it = VarToConstMap->find(key);
- // if(it != VarToConstMap->end())
- // {
- // VarToConstMap->erase(it);
- // }
-
- // (*VarToConstMap)[key] = value;
- // return;
- // }
-
-
- // /******************************************************************
- // * FINITE FORLOOP ABSTRACTION REFINEMENT
- // *
- // * For each 'finiteloop' in the list 'GlobalList_Of_FiniteLoops'
- // *
- // * Expand_FiniteLoop(finiteloop);
- // *
- // * The 'Expand_FiniteLoop' function expands the 'finiteloop' in a
- // * counterexample-guided refinement fashion
- // *
- // * Once all the finiteloops have been expanded, we need to go back
- // * and recheck that every discarded constraint is true with the
- // * final model. A flag 'done' is set to false if atleast one
- // * constraint is false during model-check, and is set to true if all
- // * constraints are true during model-check.
- // *
- // * if the 'done' flag is true, then we terminate this refinement
- // * loop.
- // *****************************************************************/
- // SOLVER_RETURN_TYPE
- // AbsRefine_CounterExample::
- // SATBased_AllFiniteLoops_Refinement(SATSolver& SatSolver,
- // const ASTNode& original_input)
- // {
- // cout << "The number of abs-refinement limit is "
- // << num_absrefine << endl;
- // for(int absrefine_count=0;
- // absrefine_count < num_absrefine; absrefine_count++)
- // {
- // ASTVec Allretvec0;
- // Allretvec0.push_back(ASTTrue);
- // SOLVER_RETURN_TYPE res = SOLVER_UNDECIDED;
- // for(ASTVec::iterator i = GlobalList_Of_FiniteLoops.begin(),
- // iend=GlobalList_Of_FiniteLoops.end(); i!=iend; i++)
- // {
- // ASTVec retvec;
- // ASTNodeMap ParamToCurrentValMap;
- // retvec = SATBased_FiniteLoop_Refinement(SatSolver,
- // original_input,
- // *i,
- // &ParamToCurrentValMap,
- // true); //absrefine flag
-
- // for(ASTVec::iterator j=retvec.begin(),jend=retvec.end();
- // j!=jend;j++)
- // {
- // Allretvec0.push_back(*j);
- // }
- // //Allretvec0.(Allretvec0.end(),retvec.begin(),retvec.end());
- // } //End of For
-
- // ASTNode retformula =
- // (Allretvec0.size() == 1) ?
- // Allretvec0[0] : bm->CreateNode(AND,Allretvec0);
- // retformula = TransformFormula_TopLevel(retformula);
-
- // //Add the return value of all loops to the SAT Solver
- // res =
- // CallSAT_ResultCheck(SatSolver, retformula, original_input);
- // if(SOLVER_UNDECIDED != res)
- // {
- // return res;
- // }
- // } //end of absrefine count
-
- // ASTVec Allretvec1;
- // Allretvec1.push_back(ASTTrue);
- // SOLVER_RETURN_TYPE res = SOLVER_UNDECIDED;
- // for(ASTVec::iterator i = GlobalList_Of_FiniteLoops.begin(),
- // iend=GlobalList_Of_FiniteLoops.end(); i!=iend; i++)
- // {
- // //cout << "The abs-refine didn't finish the job. "\
- // "Add the remaining formulas\n";
- // ASTNodeMap ParamToCurrentValMap;
- // ASTVec retvec;
- // retvec = SATBased_FiniteLoop_Refinement(SatSolver,
- // original_input,
- // *i,
- // &ParamToCurrentValMap,
- // false); //absrefine flag
- // for(ASTVec::iterator j=retvec.begin(),jend=retvec.end();j!=jend;j++)
- // {
- // Allretvec1.push_back(*j);
- // }
- // } //End of For
-
- // ASTNode retformula =
- // (Allretvec1.size() == 1) ?
- // Allretvec1[0] : bm->CreateNode(AND,Allretvec1);
- // retformula = TransformFormula_TopLevel(retformula);
- // //Add the return value of all loops to the SAT Solver
- // res = CallSAT_ResultCheck(SatSolver, retformula, original_input);
- // return res;
- // } //end of SATBased_AllFiniteLoops_Refinement()
-
-
- // /*****************************************************************
- // * SATBased_FiniteLoop_Refinement
- // *
- // * 'finiteloop' is the finite loop to be expanded
- // * Every finiteloop has three parts:
- // * 0) Parameter Name
- // * 1) Parameter initialization
- // * 2) Parameter limit value
- // * 3) Increment formula
- // * 4) Formula Body
- // *
- // * ParamToCurrentValMap contains a map from parameters to their
- // * current values in the recursion
- // *
- // * Nested FORs are allowed, but only the innermost loop can have a
- // * formula in it
- // *****************************************************************/
- // //SATBased_FiniteLoop_Refinement
- // //
- // //Expand the finite loop, check against model, and add false
- // //formulas to the SAT solver
- // ASTVec
- // AbsRefine_CounterExample::
- // SATBased_FiniteLoop_Refinement(SATSolver& SatSolver,
- // const ASTNode& original_input,
- // const ASTNode& finiteloop,
- // ASTNodeMap* ParamToCurrentValMap,
- // bool absrefine_flag)
- // {
- // //BVTypeCheck should have already checked the sanity of the input
- // //FOR-formula
- // ASTNode parameter = finiteloop[0];
- // int paramInit = GetUnsignedConst(finiteloop[1]);
- // int paramLimit = GetUnsignedConst(finiteloop[2]);
- // int paramIncrement = GetUnsignedConst(finiteloop[3]);
- // ASTNode exceptFormula = finiteloop[4];
- // ASTNode formulabody = finiteloop[5];
- // int paramCurrentValue = paramInit;
- // int width = finiteloop[1].GetValueWidth();
-
- // //Update ParamToCurrentValMap with parameter and its current
- // //value. Here paramCurrentValue is the initial value
- // ASTNode value =
- // bm->CreateBVConst(width,paramCurrentValue);
- // ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
-
- // //Go recursively thru' all the FOR-constructs.
- // if(FOR == formulabody.GetKind())
- // {
- // ASTVec retvec;
- // ASTVec retvec_innerfor;
- // retvec.push_back(ASTTrue);
- // while(paramCurrentValue < paramLimit)
- // {
- // retvec_innerfor =
- // SATBased_FiniteLoop_Refinement(SatSolver,
- // original_input,
- // formulabody,
- // ParamToCurrentValMap,
- // absrefine_flag);
-
- // for(ASTVec::iterator i=retvec_innerfor.begin(),
- // iend=retvec_innerfor.end();i!=iend;i++)
- // {
- // retvec.push_back(*i);
- // }
-
- // //Update ParamToCurrentValMap with parameter and its
- // //current value.
- // paramCurrentValue = paramCurrentValue + paramIncrement;
- // value = bm->CreateTerm(BVPLUS,
- // width,
- // (*ParamToCurrentValMap)[parameter],
- // bm->CreateOneConst(width));
- // ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
- // } //end of While
-
- // return retvec;
- // } //end of recursion FORs
-
- // //Expand the leaf level FOR-construct completely
- // //increment of paramCurrentValue done inside loop
- // int ThisForLoopAllTrue = 0;
- // ASTVec ForloopVec;
- // ForloopVec.push_back(ASTTrue);
- // for(;paramCurrentValue < paramLimit;)
- // {
- // ASTNode currentFormula;
- // ASTNode currentExceptFormula = exceptFormula;
- // currentExceptFormula =
- // SimplifyFormula(exceptFormula, false, ParamToCurrentValMap);
- // if(ASTTrue == currentExceptFormula)
- // {
- // currentFormula = ASTTrue;
- // }
- // else
- // {
- // currentFormula =
- // SimplifyFormula(formulabody, false, ParamToCurrentValMap);
- // }
-
- // //Check the currentformula against the model, and add it to the
- // //SAT solver if it is false against the model
- // if(absrefine_flag
- // &&
- // ASTFalse == ComputeFormulaUsingModel(currentFormula)
- // )
- // {
- // ForloopVec.push_back(currentFormula);
- // }
- // else
- // {
- // if(ASTTrue != currentFormula)
- // {
- // ForloopVec.push_back(currentFormula);
- // }
- // if(ASTFalse == currentFormula)
- // {
- // ForloopVec.push_back(ASTFalse);
- // return ForloopVec;
- // }
- // }
-
- // //Update ParamToCurrentValMap with parameter and its current
- // //value.
- // paramCurrentValue = paramCurrentValue + paramIncrement;
- // value = bm->CreateTerm(BVPLUS,
- // width,
- // (*ParamToCurrentValMap)[parameter],
- // bm->CreateOneConst(width));
- // ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
- // } //end of expanding the FOR loop
-
- // return ForloopVec;
- // } //end of the SATBased_FiniteLoop_Refinement()
-
- // //SATBased_FiniteLoop_Refinement_UsingModel(). Expand the finite
- // //loop, check against model
- // ASTNode
- // AbsRefine_CounterExample::
- // Check_FiniteLoop_UsingModel(const ASTNode& finiteloop,
- // ASTNodeMap* ParamToCurrentValMap,
- // bool checkusingmodel_flag = true)
- // {
- // /*
- // * 'finiteloop' is the finite loop to be expanded
- // * Every finiteloop has three parts:
- // * 0) Parameter Name
- // * 1) Parameter initialization
- // * 2) Parameter limit value
- // * 3) Increment formula
- // * 4) Formula Body
- // *
- // * ParamToCurrentValMap contains a map from parameters to their
- // * current values in the recursion
- // *
- // * Nested FORs are allowed, but only the innermost loop can have a
- // * formula in it
- // */
-
- // //BVTypeCheck should have already checked the sanity of the input
- // //FOR-formula
- // ASTNode parameter = finiteloop[0];
- // int paramInit = GetUnsignedConst(finiteloop[1]);
- // int paramLimit = GetUnsignedConst(finiteloop[2]);
- // int paramIncrement = GetUnsignedConst(finiteloop[3]);
- // ASTNode exceptFormula = finiteloop[4];
- // ASTNode formulabody = finiteloop[5];
- // int paramCurrentValue = paramInit;
- // int width = finiteloop[1].GetValueWidth();
-
- // //Update ParamToCurrentValMap with parameter and its current
- // //value. Here paramCurrentValue is the initial value
- // ASTNode value =
- // bm->CreateBVConst(width,paramCurrentValue);
- // ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
-
- // ASTNode ret = ASTTrue;
- // ASTVec returnVec;
- // //Go recursively thru' all the FOR-constructs.
- // if(FOR == formulabody.GetKind())
- // {
- // while(paramCurrentValue < paramLimit)
- // {
- // ret = Check_FiniteLoop_UsingModel(formulabody,
- // ParamToCurrentValMap,
- // checkusingmodel_flag);
- // if(ASTFalse == ret)
- // {
- // //no more expansion needed. Return immediately
- // return ret;
- // }
- // else
- // {
- // returnVec.push_back(ret);
- // }
-
- // //Update ParamToCurrentValMap with parameter and its
- // //current value.
- // paramCurrentValue = paramCurrentValue + paramIncrement;
- // value = bm->CreateTerm(BVPLUS,
- // width,
- // (*ParamToCurrentValMap)[parameter],
- // bm->CreateOneConst(width));
- // ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
- // } //end of While
-
- // ASTNode retFormula =
- // (returnVec.size() > 1) ?
- // bm->CreateNode(AND, returnVec) :
- // (returnVec.size() == 1) ?
- // returnVec[0] :
- // ASTTrue;
- // return retFormula;
- // }
-
- // ASTVec forloopFormulaVector;
- // //Expand the leaf level FOR-construct completely
- // //incrementing of paramCurrentValue is done inside loop
- // for(;paramCurrentValue < paramLimit;)
- // {
- // ASTNode currentFormula;
-
- // ASTNode currentExceptFormula = exceptFormula;
- // currentExceptFormula =
- // SimplifyFormula(exceptFormula, false, ParamToCurrentValMap);
- // if(ASTTrue == currentExceptFormula)
- // {
- // currentFormula = ASTTrue;
- // //continue;
- // }
- // else
- // {
- // currentFormula =
- // SimplifyFormula(formulabody, false, ParamToCurrentValMap);
- // }
-
- // if(checkusingmodel_flag)
- // {
- // //Check the currentformula against the model, and return
- // //immediately
- // //cout << "Printing current Formula: " << currentFormula << "\n";
- // ASTNode computedForm = ComputeFormulaUsingModel(currentFormula);
- // //cout << "Printing computed Formula: " << computedForm << "\n";
- // if(ASTFalse == computedForm)
- // {
- // return ASTFalse;
- // }
- // }
- // else
- // {
- // if(ASTTrue != currentFormula)
- // {
- // forloopFormulaVector.push_back(currentFormula);
- // }
- // }
-
- // //Update ParamToCurrentValMap with parameter and its current
- // //value
- // paramCurrentValue = paramCurrentValue + paramIncrement;
- // value = bm->CreateTerm(BVPLUS,
- // width,
- // (*ParamToCurrentValMap)[parameter],
- // bm->CreateOneConst(width));
- // ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
- // } //end of For
-
- // if(checkusingmodel_flag)
- // {
- // return ASTTrue;
- // }
- // else
- // {
- // ASTNode retFormula =
- // (forloopFormulaVector.size() > 1) ?
- // bm->CreateNode(AND, forloopFormulaVector) :
- // (forloopFormulaVector.size() == 1) ?
- // forloopFormulaVector[0] :
- // ASTTrue;
- // return retFormula;
- // }
- // } //end of the Check_FiniteLoop_UsingModel()
-
-
- // //Expand_FiniteLoop_For_ModelCheck
- // ASTNode
- // AbsRefine_CounterExample::
- // Expand_FiniteLoop_TopLevel(const ASTNode& finiteloop)
- // {
- // ASTNodeMap ParamToCurrentValMap;
- // return Check_FiniteLoop_UsingModel(finiteloop,
- // &ParamToCurrentValMap, false);
- // } //end of Expand_FiniteLoop_TopLevel()
-
- // ASTNode
- // AbsRefine_CounterExample::
- // Check_FiniteLoop_UsingModel(const ASTNode& finiteloop)
- // {
- // ASTNodeMap ParamToCurrentValMap;
- // return Check_FiniteLoop_UsingModel(finiteloop,
- // &ParamToCurrentValMap, true);
- // } //end of Check_FiniteLoop_UsingModel
};// end of namespace BEEV