#include <RelationSolver.h>
|
| RelationSolver ()=default |
|
Z3Expr | gamma_hat (const AbstractState &exeState) const |
| Return Z3Expr according to valToValMap.
|
|
Z3Expr | gamma_hat (const AbstractState &alpha, const AbstractState &exeState) const |
| Return Z3Expr according to another valToValMap.
|
|
Z3Expr | gamma_hat (u32_t id, const AbstractState &exeState) const |
| Return Z3Expr from a NodeID.
|
|
AbstractState | abstract_consequence (const AbstractState &lower, const AbstractState &upper, const AbstractState &domain) const |
|
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.
|
|
Z3Expr | toIntVal (s32_t f) const |
|
Z3Expr | toRealVal (BoundedDouble f) const |
|
AbstractState | bilateral (const AbstractState &domain, const Z3Expr &phi, u32_t descend_check=0) |
|
AbstractState | RSY (const AbstractState &domain, const Z3Expr &phi) |
|
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 | BS (const AbstractState &domain, const Z3Expr &phi) |
|
void | updateMap (Map< u32_t, s32_t > &map, u32_t key, const s32_t &value) |
|
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 > &) |
|
Definition at line 38 of file RelationSolver.h.
◆ RelationSolver()
SVF::RelationSolver::RelationSolver |
( |
| ) |
|
|
default |
◆ abstract_consequence()
for variable in self.variables:
proposed = self.top.copy()
proposed.set_interval(variable, lower.interval_of(variable)) proposed._locToItvVal
if not proposed >= upper:
return proposed
return lower.copy()
Definition at line 170 of file RelationSolver.cpp.
172{
173
174
175
176
177
178
179
180
181
182
183 for (
auto it =
domain.getVarToVal().begin();
186 {
192 {
194 }
195 }
197}
AbstractState top() const
Set all value top.
llvm::IRBuilder IRBuilder
◆ beta()
◆ bilateral()
init variables
TODO: add option for timeout
start processing
compute domain.model_and(phi, domain.logic_not(domain.gamma_hat(consequence)))
find any solution, which is sat
unknown or unsat
for timeout reason return upper
Definition at line 36 of file RelationSolver.cpp.
38{
46 p.set(
":timeout",
static_cast<unsigned>(600));
49
52 {
54 {
56 }
57 else
58 {
60 }
63 solver.push();
64 solver.add(
phi.getExpr() &&
rhs.getExpr());
66 z3::check_result
checkRes = solver.check();
69 {
70 z3::model
m = solver.get_model();
72 {
73 z3::func_decl
v =
m[
i];
74
76 continue;
77 solution.emplace(std::stoi(
v.name().str()),
78 m.get_const_interp(
v).get_numeral_int());
79 }
81 {
83 {
85 }
86 }
87 solver.pop();
94 }
95 else
96 {
97 solver.pop();
99 {
101 if (solver.reason_unknown() == "timeout")
103 }
109 }
110 }
112}
AbstractState bottom() const
Set all value bottom.
void joinWith(const AbstractState &other)
domain join with other, important! other widen this.
void meetWith(const AbstractState &other)
domain meet with other, important! other widen this.
Z3Expr gamma_hat(const AbstractState &exeState) const
Return Z3Expr according to valToValMap.
AbstractState beta(const Map< u32_t, s32_t > &sigma, const AbstractState &exeState) const
AbstractState abstract_consequence(const AbstractState &lower, const AbstractState &upper, const AbstractState &domain) 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.
◆ BoxedOptSolver()
this is the S in the original paper
Definition at line 345 of file RelationSolver.cpp.
346{
350 while (1)
351 {
353 for (
const auto&
item : ret)
354 {
357 {
362 }
363 }
365 break;
366 else
368 }
369 return ret;
370}
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)
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 > &)
Z3Expr toIntVal(s32_t f) const
◆ BS()
because key of _varToItvVal is u32_t, -key may out of range for int so we do key + bias for -key
init low, ret, high
init objects -x
add a relation that x == -(x+bias)
optimize each object
fill in the return values
Definition at line 270 of file RelationSolver.cpp.
271{
276
277
278
284 {
289 else
293 else
297 }
299 {
306 else
310 else
314 }
319 for (
const auto&
item: ret)
320 {
322 {
325
329 else
331
332 }
333 else
334 {
338 else
340 }
341 }
343}
static BoundedInt plus_infinity()
bool is_minus_infinity() const
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.
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)
◆ decide_cpa_ext()
void RelationSolver::decide_cpa_ext |
( |
const Z3Expr & |
phi, |
|
|
Map< u32_t, Z3Expr > & |
L_phi, |
|
|
Map< u32_t, s32_t > & |
mid_values, |
|
|
Map< u32_t, s32_t > & |
ret, |
|
|
Map< u32_t, s32_t > & |
low_values, |
|
|
Map< u32_t, s32_t > & |
high_values |
|
) |
| |
find any solution, which is sat
id is the var id, value is the solution found for var_id add a relation to check if the solution meets phi_id
unknown or unsat, we consider unknown as unsat
Definition at line 373 of file RelationSolver.cpp.
379{
380 while (1)
381 {
387 solver.push();
390 z3::check_result
checkRes = solver.check();
393 {
394 z3::model
m = solver.get_model();
395 solver.pop();
397 {
399 int value =
m.eval(
toIntZ3Expr(
id).getExpr()).get_numeral_int();
400
404 solver.push();
405 solver.add(
expr.getExpr());
406
407 if (solver.check() == z3::sat)
408 {
411
415
418 }
419 solver.pop();
420 }
421 }
422 else
423 {
424 solver.pop();
427 return;
428 }
429 }
430
431}
◆ gamma_hat() [1/3]
Return Z3Expr according to another valToValMap.
Definition at line 216 of file RelationSolver.cpp.
218{
221 {
225 if (interval.
isTop())
226 continue;
230 }
231 return res;
232}
s64_t getNumeral() const
Retrieves the numeral value of the BoundedInt object.
◆ gamma_hat() [2/3]
Return Z3Expr according to valToValMap.
Definition at line 199 of file RelationSolver.cpp.
200{
203 {
207 if (interval.
isTop())
208 continue;
212 }
213 return res;
214}
◆ gamma_hat() [3/3]
Return Z3Expr from a NodeID.
Definition at line 234 of file RelationSolver.cpp.
235{
239
240 Z3Expr res = (
v >= (
int)
it->second.getInterval().lb().getNumeral() &&
241 v <= (
int)
it->second.getInterval().ub().getNumeral());
242 return res;
243}
◆ RSY()
TODO: add option for timeout
find any solution, which is sat
unknown or unsat
for timeout reason return upper
Definition at line 114 of file RelationSolver.cpp.
115{
120 p.set(
":timeout",
static_cast<unsigned>(600));
122 while (1)
123 {
125 solver.push();
126 solver.add(
phi.getExpr() &&
rhs.getExpr());
128 z3::check_result
checkRes = solver.check();
131 {
132 z3::model
m = solver.get_model();
134 {
135 z3::func_decl
v =
m[
i];
137 continue;
138
139 solution.emplace(std::stoi(
v.name().str()),
140 m.get_const_interp(
v).get_numeral_int());
141 }
143 {
145 {
147 }
148 }
149 solver.pop();
154 }
155 else
156 {
157 solver.pop();
159 {
161 if (solver.reason_unknown() == "timeout")
163 }
164 break;
165 }
166 }
168}
◆ toIntVal()
◆ toIntZ3Expr()
◆ toRealVal()
◆ updateMap()
The documentation for this class was generated from the following files: