48 u32_t meets_in_a_row = 0;
52 p.set(
":timeout",
static_cast<unsigned>(600));
57 while (lower != upper)
59 if (meets_in_a_row == descend_check)
72 z3::check_result checkRes = solver.check();
74 if (checkRes == z3::sat)
76 z3::model m = solver.get_model();
77 for (
u32_t i = 0; i < m.size(); i++)
79 z3::func_decl v = m[i];
83 solution.emplace(std::stoi(v.name().str()),
84 m.get_const_interp(v).get_numeral_int());
88 if (solution.find(
item.first) == solution.end())
90 solution.emplace(
item.first, 0);
104 if (checkRes == z3::unknown)
107 if (solver.reason_unknown() ==
"timeout")
126 p.set(
":timeout",
static_cast<unsigned>(600));
134 z3::check_result checkRes = solver.check();
136 if (checkRes == z3::sat)
138 z3::model m = solver.get_model();
139 for (
u32_t i = 0; i < m.size(); i++)
141 z3::func_decl v = m[i];
145 solution.emplace(std::stoi(v.name().str()),
146 m.get_const_interp(v).get_numeral_int());
150 if (solution.find(
item.first) == solution.end())
152 solution.emplace(
item.first, 0);
164 if (checkRes == z3::unknown)
167 if (solver.reason_unknown() ==
"timeout")
194 proposed[it->first] = lower[it->first].getInterval();
197 if (!(proposed >= upper))
213 if (interval.
isTop())
216 res = (res && v >= (int)interval.
lb().getNumeral() &&
231 if (interval.
isTop())
234 res = (res && v >= (int)interval.
lb().getNumeral() &&
243 assert(it != exeState.
getVarToVal().end() &&
"id not in varToVal?");
246 Z3Expr res = (v >= (int)it->second.getInterval().lb().getNumeral() &&
247 v <= (
int)it->second.getInterval().ub().getNumeral());
258 sigma.at(
item.first), sigma.at(
item.first));
265 auto it = map.find(key);
268 map.emplace(key, value);
281 s32_t infinity = INT32_MAX/2 - 1;
301 if (
item.first > bias)
302 bias =
item.first + 1;
311 updateMap(low_values, reverse_key, -infinity);
315 updateMap(high_values, reverse_key, infinity);
325 for (
const auto&
item: ret)
327 if (
item.first >= bias)
332 if (
item.second == (infinity))
334 retInv[
item.first - bias].getInterval().ub());
341 if (
item.second == (infinity))
359 for (
const auto&
item : ret)
362 if (low_values.at(
item.first) <= (high_values.at(
item.first)))
364 s32_t mid = (low_values.at(
item.first) + (high_values.at(
item.first) - low_values.at(
item.first)) / 2);
367 L_phi[
item.first] = expr;
373 decide_cpa_ext(phi, L_phi, mid_values, ret, low_values, high_values);
389 for (
const auto&
item : L_phi)
390 join_expr = (join_expr ||
item.second);
391 join_expr = (join_expr && phi).simplify();
394 solver.add(join_expr.
getExpr());
396 z3::check_result checkRes = solver.check();
398 if (checkRes == z3::sat)
400 z3::model m = solver.get_model();
402 for(
const auto &
item : L_phi)
405 int value = m.eval(
toIntZ3Expr(
id).getExpr()).get_numeral_int();
413 if (solver.check() == z3::sat)
416 updateMap(low_values,
id, ret.at(
id) + 1);
418 s32_t mid = (low_values.at(
id) + high_values.at(
id) + 1) / 2;
431 for (
const auto&
item : L_phi)
432 high_values.at(
item.first) = mid_values.at(
item.first) - 1;
const VarToAbsValMap & getVarToVal() const
get var2val map
AbstractState bottom() const
Set all value bottom.
void joinWith(const AbstractState &other)
domain join with other, important! other widen this.
virtual bool inVarToValTable(u32_t id) const
whether the variable is in varToVal table
AbstractState top() const
Set all value top.
void meetWith(const AbstractState &other)
domain meet with other, important! other widen this.
static BoundedInt plus_infinity()
bool is_minus_infinity() const
s64_t getNumeral() const
Retrieves the numeral value of the BoundedInt object.
bool is_plus_infinity() const
s64_t getIntNumeral() const
static BoundedInt minus_infinity()
const BoundedInt & ub() const
Return the upper bound.
static IntervalValue top()
Create the IntervalValue [-inf, +inf].
const BoundedInt & lb() const
Return the lower bound.
Z3Expr gamma_hat(const AbstractState &exeState) const
Return Z3Expr according to valToValMap.
AbstractState RSY(const AbstractState &domain, const Z3Expr &phi)
AbstractState bilateral(const AbstractState &domain, const Z3Expr &phi, u32_t descend_check=0)
Map< u32_t, s32_t > BoxedOptSolver(const Z3Expr &phi, Map< u32_t, s32_t > &ret, Map< u32_t, s32_t > &low_values, Map< u32_t, s32_t > &high_values)
AbstractState beta(const Map< u32_t, s32_t > &sigma, const AbstractState &exeState) const
virtual Z3Expr toIntZ3Expr(u32_t varId) const
Return Z3 expression lazily based on SVFVar ID.
void updateMap(Map< u32_t, s32_t > &map, u32_t key, const s32_t &value)
AbstractState abstract_consequence(const AbstractState &lower, const AbstractState &upper, const AbstractState &domain) const
void decide_cpa_ext(const Z3Expr &phi, Map< u32_t, Z3Expr > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &, Map< u32_t, s32_t > &)
AbstractState BS(const AbstractState &domain, const Z3Expr &phi)
Z3Expr toIntVal(s32_t f) const
const z3::expr & getExpr() const
static z3::solver & getSolver()
Get z3 solver, singleton design here to make sure we only have one context.
static z3::context & getContext()
Get z3 context, singleton design here to make sure we only have one context.
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map