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
*
BeevMgr::SATBased_AllFiniteLoops_Refinement(MINISAT::Solver& SatSolver,
const ASTNode& original_input)
{
- //cout << "The number of abs-refinement limit is " << num_absrefine << endl;
+ cout << "The number of abs-refinement limit is " << num_absrefine << endl;
for(int absrefine_count=0;absrefine_count < num_absrefine; absrefine_count++)
{
ASTVec Allretvec0;
return res;
}
} //end of absrefine count
-
+
ASTVec Allretvec1;
Allretvec1.push_back(ASTTrue);
SOLVER_RETURN_TYPE res = SOLVER_UNDECIDED;
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
- (*ParamToCurrentValMap)[parameter] =
- CreateBVConst(finiteloop[1].GetValueWidth(),paramCurrentValue);
+ ASTNode value =
+ CreateBVConst(width,paramCurrentValue);
+ ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
//Go recursively thru' all the FOR-constructs.
if(FOR == formulabody.GetKind())
}
//Update ParamToCurrentValMap with parameter and its
- //current value. FIXME: Possible leak since I am not
- //freeing the previous 'value' for the same 'key'
- paramCurrentValue = paramCurrentValue + paramIncrement;
- (*ParamToCurrentValMap)[parameter] =
- CreateBVConst(finiteloop[1].GetValueWidth(),paramCurrentValue);
+ //current value.
+ paramCurrentValue = paramCurrentValue + paramIncrement;
+ value = CreateTerm(BVPLUS,
+ width,
+ (*ParamToCurrentValMap)[parameter],
+ CreateOneConst(width));
+ ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
} //end of While
return retvec;
//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))
+ if(absrefine_flag
+ &&
+ ASTFalse == ComputeFormulaUsingModel(currentFormula)
+ )
{
ForloopVec.push_back(currentFormula);
}
}
//Update ParamToCurrentValMap with parameter and its current
- //value. FIXME: Possible leak since I am not freeing the
- //previous 'value' for the same 'key'
+ //value.
paramCurrentValue = paramCurrentValue + paramIncrement;
- (*ParamToCurrentValMap)[parameter] =
- CreateBVConst(finiteloop[1].GetValueWidth(),paramCurrentValue);
+ value = CreateTerm(BVPLUS,
+ width,
+ (*ParamToCurrentValMap)[parameter],
+ CreateOneConst(width));
+ ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
} //end of expanding the FOR loop
return ForloopVec;
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
- (*ParamToCurrentValMap)[parameter] =
- CreateBVConst(finiteloop[1].GetValueWidth(),paramCurrentValue);
-
+ ASTNode value =
+ CreateBVConst(width,paramCurrentValue);
+ ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
+
ASTNode ret = ASTTrue;
ASTVec returnVec;
//Go recursively thru' all the FOR-constructs.
}
//Update ParamToCurrentValMap with parameter and its
- //current value. FIXME: Possible leak since I am not
- //freeing the previous 'value' for the same 'key'
+ //current value.
paramCurrentValue = paramCurrentValue + paramIncrement;
- (*ParamToCurrentValMap)[parameter] =
- CreateBVConst(finiteloop[1].GetValueWidth(),paramCurrentValue);
+ value = CreateTerm(BVPLUS,
+ width,
+ (*ParamToCurrentValMap)[parameter],
+ CreateOneConst(width));
+ ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
} //end of While
ASTNode retFormula =
- (returnVec.size() != 1) ?
- CreateNode(AND, returnVec) : returnVec[0];
+ (returnVec.size() > 1) ?
+ CreateNode(AND, returnVec) :
+ (returnVec.size() == 1) ?
+ returnVec[0] :
+ ASTTrue;
return retFormula;
}
//Update ParamToCurrentValMap with parameter and its current
//value
- //FIXME: Possible leak since I am not freeing the previous
- //'value' for the same 'key'
paramCurrentValue = paramCurrentValue + paramIncrement;
- (*ParamToCurrentValMap)[parameter] =
- CreateBVConst(finiteloop[1].GetValueWidth(),paramCurrentValue);
- //cout << (*ParamToCurrentValMap)[parameter];
+ value = CreateTerm(BVPLUS,
+ width,
+ (*ParamToCurrentValMap)[parameter],
+ CreateOneConst(width));
+ ReplaceOrAddToMap(ParamToCurrentValMap, parameter, value);
} //end of For
if(checkusingmodel_flag)
else
{
ASTNode retFormula =
- (forloopFormulaVector.size() != 1) ?
- CreateNode(AND, forloopFormulaVector) :
- forloopFormulaVector[0];
+ (forloopFormulaVector.size() > 1) ?
+ CreateNode(AND, forloopFormulaVector) :
+ (forloopFormulaVector.size() == 1) ?
+ forloopFormulaVector[0] :
+ ASTTrue;
return retFormula;
}
} //end of the Check_FiniteLoop_UsingModel()
} //end of Check_FiniteLoop_UsingModel
-
// /******************************************************************
// * FINITE FORLOOP ABSTRACTION REFINEMENT
// *
output = ComputeFormulaUsingModel(output);
break;
case FOR:
- output = Check_FiniteLoop_UsingModel(form);
+ output = Check_FiniteLoop_UsingModel(form);
break;
default:
FatalError(" ComputeFormulaUsingModel: "\
}
TermsAlreadySeenMap.clear();
- // do
-// {
-// inputToSAT = simplified_solved_InputToSAT;
-
-// if(optimize_flag)
-// {
-// //simplified_solved_InputToSAT =
-// //CreateSubstitutionMap(simplified_solved_InputToSAT);
-// //Begin_RemoveWrites = true; ASTNodeStats("after pure
-// //substitution: ", simplified_solved_InputToSAT);
-// simplified_solved_InputToSAT =
-// SimplifyFormula_TopLevel(simplified_solved_InputToSAT, false);
-// //ASTNodeStats("after simplification: ",
-// //simplified_solved_InputToSAT);
-// //
-// }
-
-// if(wordlevel_solve_flag)
-// {
-// simplified_solved_InputToSAT
-// = bvsolver.TopLevelBVSolve(simplified_solved_InputToSAT);
-// ASTNodeStats("after solving: ",
-// simplified_solved_InputToSAT);
-// }
-// } while (inputToSAT != simplified_solved_InputToSAT);
if (start_abstracting)
{
}
res = CallSAT_ResultCheck(newS, simplified_solved_InputToSAT, orig_input);
-
if (SOLVER_UNDECIDED != res)
{
CountersAndStats("print_func_stats");