Static Value-Flow Analysis
Loading...
Searching...
No Matches
SymblicAbstractionTest Class Reference

Public Member Functions

 SymblicAbstractionTest ()=default
 ~SymblicAbstractionTest ()=default
void test_print ()
AbstractState RSY_time (AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
AbstractState Bilateral_time (AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
AbstractState BS_time (AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
void testRelExeState1_1 ()
void testRelExeState1_2 ()
void testRelExeState2_1 ()
void testRelExeState2_2 ()
void testRelExeState2_3 ()
void testRelExeState2_4 ()
void testRelExeState2_5 ()
void testRelExeState3_1 ()
void testRelExeState3_2 ()
void testRelExeState3_3 ()
void testRelExeState3_4 ()
void testRelExeState4_1 ()
void testsValidation ()

Static Public Member Functions

static z3::context & getContext ()

Detailed Description

Definition at line 56 of file ae.cpp.

Constructor & Destructor Documentation

◆ SymblicAbstractionTest()

SymblicAbstractionTest::SymblicAbstractionTest ( )
default

◆ ~SymblicAbstractionTest()

SymblicAbstractionTest::~SymblicAbstractionTest ( )
default

Member Function Documentation

◆ Bilateral_time()

AbstractState SymblicAbstractionTest::Bilateral_time ( AbstractState & inv,
const Z3Expr & phi,
RelationSolver & rs )
inline

Definition at line 85 of file ae.cpp.

87 {
88 auto start_time = std::chrono::high_resolution_clock::now();
89 AbstractState resBilateral = rs.bilateral(inv, phi);
90 auto end_time = std::chrono::high_resolution_clock::now();
91 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
92 end_time - start_time);
93 outs() << "running time of Bilateral: " << duration.count()
94 << " microseconds\n";
95 return resBilateral;
96 }
AbstractState bilateral(const AbstractState &domain, const Z3Expr &phi, u32_t descend_check=0)
std::ostream & outs()
Overwrite llvm::outs().
Definition SVFUtil.h:58

◆ BS_time()

AbstractState SymblicAbstractionTest::BS_time ( AbstractState & inv,
const Z3Expr & phi,
RelationSolver & rs )
inline

Definition at line 97 of file ae.cpp.

99 {
100 auto start_time = std::chrono::high_resolution_clock::now();
101 AbstractState resBS = rs.BS(inv, phi);
102 auto end_time = std::chrono::high_resolution_clock::now();
103 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
104 end_time - start_time);
105 outs() << "running time of BS : " << duration.count()
106 << " microseconds\n";
107 return resBS;
108 }
AbstractState BS(const AbstractState &domain, const Z3Expr &phi)

◆ getContext()

z3::context & SymblicAbstractionTest::getContext ( )
inlinestatic

Definition at line 63 of file ae.cpp.

64 {
65 return Z3Expr::getContext();
66 }
static z3::context & getContext()
Get z3 context, singleton design here to make sure we only have one context.
Definition Z3Expr.cpp:66

◆ RSY_time()

AbstractState SymblicAbstractionTest::RSY_time ( AbstractState & inv,
const Z3Expr & phi,
RelationSolver & rs )
inline

Definition at line 73 of file ae.cpp.

75 {
76 auto start_time = std::chrono::high_resolution_clock::now();
77 AbstractState resRSY = rs.RSY(inv, phi);
78 auto end_time = std::chrono::high_resolution_clock::now();
79 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(
80 end_time - start_time);
81 outs() << "running time of RSY : " << duration.count()
82 << " microseconds\n";
83 return resRSY;
84 }
AbstractState RSY(const AbstractState &domain, const Z3Expr &phi)

◆ test_print()

void SymblicAbstractionTest::test_print ( )
inline

Definition at line 68 of file ae.cpp.

69 {
70 outs() << "hello print\n";
71 }

◆ testRelExeState1_1()

void SymblicAbstractionTest::testRelExeState1_1 ( )
inline

Definition at line 110 of file ae.cpp.

111 {
112 outs() << sucMsg("\t SUCCESS :") << "test1_1 start\n";
113 AbstractState itv;
114 RelExeState relation;
115 // var0 := [0, 1];
116 itv[0] = IntervalValue(0, 1);
117 relation[0] = getContext().int_const("0");
118 // var1 := var0 + 1;
119 relation[1] =
120 getContext().int_const("1") == getContext().int_const("0") + 1;
121 itv[1] = itv[0].getInterval() + IntervalValue(1);
122 // Test extract sub vars
123 Set<u32_t> res;
124 relation.extractSubVars(relation[1], res);
125 assert(res == Set<u32_t>({0, 1}) && "inconsistency occurs");
126 AbstractState inv = itv.sliceState(res);
127 RelationSolver rs;
128 const Z3Expr& relExpr = relation[1];
129 const Z3Expr& initExpr = rs.gamma_hat(inv);
130 const Z3Expr& phi = (relExpr && initExpr).simplify();
131 AbstractState resRSY = rs.RSY(inv, phi);
132 AbstractState resBilateral = rs.bilateral(inv, phi);
133 AbstractState resBS = rs.BS(inv, phi);
134 // 0:[0,1] 1:[1,2]
135 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
136 for (auto r : resRSY.getVarToVal())
137 {
138 outs() << r.first << " " << r.second.getInterval() << "\n";
139 }
140 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 1)}, {1, IntervalValue(1, 2)}};
141 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
142 }
const VarToAbsValMap & getVarToVal() const
get var2val map
bool eqVarToValMap(const VarToAbsValMap &lhs, const VarToAbsValMap &rhs) const
Map< u32_t, AbstractValue > VarToAbsValMap
AbstractState sliceState(Set< u32_t > &sl)
Copy some values and return a new IntervalExeState.
void extractSubVars(const Z3Expr &expr, Set< u32_t > &res)
Extract sub SVFVar IDs of a Z3Expr.
Z3Expr gamma_hat(const AbstractState &exeState) const
Return Z3Expr according to valToValMap.
static z3::context & getContext()
Definition ae.cpp:63
std::string sucMsg(const std::string &msg)
Returns successful message by converting a string into green string output.
Definition SVFUtil.cpp:75
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition GeneralType.h:51

◆ testRelExeState1_2()

void SymblicAbstractionTest::testRelExeState1_2 ( )
inline

Definition at line 144 of file ae.cpp.

145 {
146 outs() << "test1_2 start\n";
147 AbstractState itv;
148 RelExeState relation;
149 // var0 := [0, 1];
150 relation[0] = getContext().int_const("0");
151 itv[0] = IntervalValue(0, 1);
152 // var1 := var0 + 1;
153 relation[1] =
154 getContext().int_const("1") == getContext().int_const("0") * 2;
155 itv[1] = itv[0].getInterval() * IntervalValue(2);
156
157 // Test extract sub vars
158 Set<u32_t> res;
159 relation.extractSubVars(relation[1], res);
160 assert(res == Set<u32_t>({0, 1}) && "inconsistency occurs");
161 AbstractState inv = itv.sliceState(res);
162 RelationSolver rs;
163 const Z3Expr& relExpr = relation[1];
164 const Z3Expr& initExpr = rs.gamma_hat(inv);
165 const Z3Expr& phi = (relExpr && initExpr).simplify();
166 AbstractState resRSY = rs.RSY(inv, phi);
167 AbstractState resBilateral = rs.bilateral(inv, phi);
168 AbstractState resBS = rs.BS(inv, phi);
169 // 0:[0,1] 1:[0,2]
170 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
171 for (auto r : resRSY.getVarToVal())
172 {
173 outs() << r.first << " " << r.second.getInterval() << "\n";
174 }
175 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 1)}, {1, IntervalValue(0, 2)}};
176 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
177 }

◆ testRelExeState2_1()

void SymblicAbstractionTest::testRelExeState2_1 ( )
inline

Definition at line 179 of file ae.cpp.

180 {
181 outs() << "test2_1 start\n";
182 AbstractState itv;
183 RelExeState relation;
184 // var0 := [0, 10];
185 relation[0] = getContext().int_const("0");
186 itv[0] = IntervalValue(0, 10);
187 // var1 := var0;
188 relation[1] =
189 getContext().int_const("1") == getContext().int_const("0");
190 itv[1] = itv[0];
191 // var2 := var1 - var0;
192 relation[2] = getContext().int_const("2") ==
193 getContext().int_const("1") - getContext().int_const("0");
194 itv[2] = itv[1].getInterval() - itv[0].getInterval();
195 // Test extract sub vars
196 Set<u32_t> res;
197 relation.extractSubVars(relation[2], res);
198 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
199 AbstractState inv = itv.sliceState(res);
200 RelationSolver rs;
201 const Z3Expr& relExpr = relation[2] && relation[1];
202 const Z3Expr& initExpr = rs.gamma_hat(inv);
203 const Z3Expr& phi = (relExpr && initExpr).simplify();
204 AbstractState resRSY = rs.RSY(inv, phi);
205 AbstractState resBilateral = rs.bilateral(inv, phi);
206 AbstractState resBS = rs.BS(inv, phi);
207 // 0:[0,10] 1:[0,10] 2:[0,0]
208 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
209 for (auto r : resRSY.getVarToVal())
210 {
211 outs() << r.first << " " << r.second.getInterval() << "\n";
212 }
213 // ground truth
214 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 10)},
215 {1, IntervalValue(0, 10)},
216 {2, IntervalValue(0, 0)}
217 };
218 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
219 }

◆ testRelExeState2_2()

void SymblicAbstractionTest::testRelExeState2_2 ( )
inline

Definition at line 221 of file ae.cpp.

222 {
223 outs() << "test2_2 start\n";
224 AbstractState itv;
225 RelExeState relation;
226 // var0 := [0, 100];
227 relation[0] = getContext().int_const("0");
228 itv[0] = IntervalValue(0, 100);
229 // var1 := var0;
230 relation[1] =
231 getContext().int_const("1") == getContext().int_const("0");
232 itv[1] = itv[0];
233 // var2 := var1 - var0;
234 relation[2] = getContext().int_const("2") ==
235 getContext().int_const("1") - getContext().int_const("0");
236 itv[2] = itv[1].getInterval() - itv[0].getInterval();
237
238 // Test extract sub vars
239 Set<u32_t> res;
240 relation.extractSubVars(relation[2], res);
241 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
242 AbstractState inv = itv.sliceState(res);
243 RelationSolver rs;
244 const Z3Expr& relExpr = relation[2] && relation[1];
245 const Z3Expr& initExpr = rs.gamma_hat(inv);
246 const Z3Expr& phi = (relExpr && initExpr).simplify();
247 AbstractState resRSY = rs.RSY(inv, phi);
248 AbstractState resBilateral = rs.bilateral(inv, phi);
249 AbstractState resBS = rs.BS(inv, phi);
250 // 0:[0,100] 1:[0,100] 2:[0,0]
251 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
252 for (auto r : resRSY.getVarToVal())
253 {
254 outs() << r.first << " " << r.second.getInterval() << "\n";
255 }
256 // ground truth
257 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 100)},
258 {1, IntervalValue(0, 100)},
259 {2, IntervalValue(0, 0)}
260 };
261 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
262 }

◆ testRelExeState2_3()

void SymblicAbstractionTest::testRelExeState2_3 ( )
inline

Definition at line 264 of file ae.cpp.

265 {
266 outs() << "test2_3 start\n";
267 AbstractState itv;
268 RelExeState relation;
269 // var0 := [0, 1000];
270 relation[0] = getContext().int_const("0");
271 itv[0] = IntervalValue(0, 1000);
272 // var1 := var0;
273 relation[1] =
274 getContext().int_const("1") == getContext().int_const("0");
275 itv[1] = itv[0];
276 // var2 := var1 - var0;
277 relation[2] = getContext().int_const("2") ==
278 getContext().int_const("1") - getContext().int_const("0");
279 itv[2] = itv[1].getInterval() - itv[0].getInterval();
280
281 // Test extract sub vars
282 Set<u32_t> res;
283 relation.extractSubVars(relation[2], res);
284 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
285 AbstractState inv = itv.sliceState(res);
286 RelationSolver rs;
287 const Z3Expr& relExpr = relation[2] && relation[1];
288 const Z3Expr& initExpr = rs.gamma_hat(inv);
289 const Z3Expr& phi = (relExpr && initExpr).simplify();
290 AbstractState resRSY = rs.RSY(inv, phi);
291 AbstractState resBilateral = rs.bilateral(inv, phi);
292 AbstractState resBS = rs.BS(inv, phi);
293 // 0:[0,1000] 1:[0,1000] 2:[0,0]
294 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
295 for (auto r : resRSY.getVarToVal())
296 {
297 outs() << r.first << " " << r.second.getInterval() << "\n";
298 }
299 // ground truth
300 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 1000)},
301 {1, IntervalValue(0, 1000)},
302 {2, IntervalValue(0, 0)}
303 };
304 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
305 }

◆ testRelExeState2_4()

void SymblicAbstractionTest::testRelExeState2_4 ( )
inline

Definition at line 307 of file ae.cpp.

308 {
309 outs() << "test2_4 start\n";
310 AbstractState itv;
311 RelExeState relation;
312 // var0 := [0, 10000];
313 relation[0] = getContext().int_const("0");
314 itv[0] = IntervalValue(0, 10000);
315 // var1 := var0;
316 relation[1] =
317 getContext().int_const("1") == getContext().int_const("0");
318 itv[1] = itv[0];
319 // var2 := var1 - var0;
320 relation[2] = getContext().int_const("2") ==
321 getContext().int_const("1") - getContext().int_const("0");
322 itv[2] = itv[1].getInterval() - itv[0].getInterval();
323
324 // Test extract sub vars
325 Set<u32_t> res;
326 relation.extractSubVars(relation[2], res);
327 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
328 AbstractState inv = itv.sliceState(res);
329 RelationSolver rs;
330 const Z3Expr& relExpr = relation[2] && relation[1];
331 const Z3Expr& initExpr = rs.gamma_hat(inv);
332 const Z3Expr& phi = (relExpr && initExpr).simplify();
333 AbstractState resRSY = RSY_time(inv, phi, rs);
334 AbstractState resBilateral = Bilateral_time(inv, phi, rs);
335 AbstractState resBS = BS_time(inv, phi, rs);
336 // 0:[0,10000] 1:[0,10000] 2:[0,0]
337 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
338 for (auto r : resRSY.getVarToVal())
339 {
340 outs() << r.first << " " << r.second.getInterval() << "\n";
341 }
342 // ground truth
343 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 10000)},
344 {1, IntervalValue(0, 10000)},
345 {2, IntervalValue(0, 0)}
346 };
347 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
348 }
AbstractState BS_time(AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
Definition ae.cpp:97
AbstractState RSY_time(AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
Definition ae.cpp:73
AbstractState Bilateral_time(AbstractState &inv, const Z3Expr &phi, RelationSolver &rs)
Definition ae.cpp:85

◆ testRelExeState2_5()

void SymblicAbstractionTest::testRelExeState2_5 ( )
inline

Definition at line 350 of file ae.cpp.

351 {
352 outs() << "test2_5 start\n";
353 AbstractState itv;
354 RelExeState relation;
355 // var0 := [0, 100000];
356 relation[0] = getContext().int_const("0");
357 itv[0] = IntervalValue(0, 100000);
358 // var1 := var0;
359 relation[1] =
360 getContext().int_const("1") == getContext().int_const("0");
361 itv[1] = itv[0];
362 // var2 := var1 - var0;
363 relation[2] = getContext().int_const("2") ==
364 getContext().int_const("1") - getContext().int_const("0");
365 itv[2] = itv[1].getInterval() - itv[0].getInterval();
366
367 // Test extract sub vars
368 Set<u32_t> res;
369 relation.extractSubVars(relation[2], res);
370 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
371 AbstractState inv = itv.sliceState(res);
372 RelationSolver rs;
373 const Z3Expr& relExpr = relation[2] && relation[1];
374 const Z3Expr& initExpr = rs.gamma_hat(inv);
375 const Z3Expr& phi = (relExpr && initExpr).simplify();
376 AbstractState resRSY = RSY_time(inv, phi, rs);
377 AbstractState resBilateral = Bilateral_time(inv, phi, rs);
378 AbstractState resBS = BS_time(inv, phi, rs);
379 // 0:[0,100000] 1:[0,100000] 2:[0,0]
380 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
381 for (auto r : resRSY.getVarToVal())
382 {
383 outs() << r.first << " " << r.second.getInterval() << "\n";
384 }
385 // ground truth
386 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 100000)},
387 {1, IntervalValue(0, 100000)},
388 {2, IntervalValue(0, 0)}
389 };
390 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
391 }

◆ testRelExeState3_1()

void SymblicAbstractionTest::testRelExeState3_1 ( )
inline

Definition at line 393 of file ae.cpp.

394 {
395 outs() << "test3_1 start\n";
396 AbstractState itv;
397 RelExeState relation;
398 // var0 := [1, 10];
399 relation[0] = getContext().int_const("0");
400 itv[0] = IntervalValue(1, 10);
401 // var1 := var0;
402 relation[1] =
403 getContext().int_const("1") == getContext().int_const("0");
404 itv[1] = itv[0];
405 // var2 := var1 / var0;
406 relation[2] = getContext().int_const("2") ==
407 getContext().int_const("1") / getContext().int_const("0");
408 itv[2] = itv[1].getInterval() / itv[0].getInterval();
409 // Test extract sub vars
410 Set<u32_t> res;
411 relation.extractSubVars(relation[2], res);
412 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
413 AbstractState inv = itv.sliceState(res);
414 RelationSolver rs;
415 const Z3Expr& relExpr = relation[2] && relation[1];
416 const Z3Expr& initExpr = rs.gamma_hat(inv);
417 const Z3Expr& phi = (relExpr && initExpr).simplify();
418 AbstractState resRSY = rs.RSY(inv, phi);
419 AbstractState resBilateral = rs.bilateral(inv, phi);
420 AbstractState resBS = rs.BS(inv, phi);
421 // 0:[1,10] 1:[1,10] 2:[1,1]
422 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
423 for (auto r : resRSY.getVarToVal())
424 {
425 outs() << r.first << " " << r.second.getInterval() << "\n";
426 }
427 // ground truth
428 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(1, 10)},
429 {1, IntervalValue(1, 10)},
430 {2, IntervalValue(1, 1)}
431 };
432 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
433 }

◆ testRelExeState3_2()

void SymblicAbstractionTest::testRelExeState3_2 ( )
inline

Definition at line 435 of file ae.cpp.

436 {
437 outs() << "test3_2 start\n";
438 AbstractState itv;
439 RelExeState relation;
440 // var0 := [1, 1000];
441 relation[0] = getContext().int_const("0");
442 itv[0] = IntervalValue(1, 1000);
443 // var1 := var0;
444 relation[1] =
445 getContext().int_const("1") == getContext().int_const("0");
446 itv[1] = itv[0];
447 // var2 := var1 / var0;
448 relation[2] = getContext().int_const("2") ==
449 getContext().int_const("1") / getContext().int_const("0");
450 itv[2] = itv[1].getInterval() / itv[0].getInterval();
451 // Test extract sub vars
452 Set<u32_t> res;
453 relation.extractSubVars(relation[2], res);
454 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
455 AbstractState inv = itv.sliceState(res);
456 RelationSolver rs;
457 const Z3Expr& relExpr = relation[2] && relation[1];
458 const Z3Expr& initExpr = rs.gamma_hat(inv);
459 const Z3Expr& phi = (relExpr && initExpr).simplify();
460 AbstractState resRSY = rs.RSY(inv, phi);
461 AbstractState resBilateral = rs.bilateral(inv, phi);
462 AbstractState resBS = rs.BS(inv, phi);
463 // 0:[1,1000] 1:[1,1000] 2:[1,1]
464 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
465 for (auto r : resRSY.getVarToVal())
466 {
467 outs() << r.first << " " << r.second.getInterval() << "\n";
468 }
469 // ground truth
470 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(1, 1000)},
471 {1, IntervalValue(1, 1000)},
472 {2, IntervalValue(1, 1)}
473 };
474 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
475 }

◆ testRelExeState3_3()

void SymblicAbstractionTest::testRelExeState3_3 ( )
inline

Definition at line 477 of file ae.cpp.

478 {
479 outs() << "test3_3 start\n";
480 AbstractState itv;
481 RelExeState relation;
482 // var0 := [1, 10000];
483 relation[0] = getContext().int_const("0");
484 itv[0] = IntervalValue(1, 10000);
485 // var1 := var0;
486 relation[1] =
487 getContext().int_const("1") == getContext().int_const("0");
488 itv[1] = itv[0];
489 // var2 := var1 / var0;
490 relation[2] = getContext().int_const("2") ==
491 getContext().int_const("1") / getContext().int_const("0");
492 itv[2] = itv[1].getInterval() / itv[0].getInterval();
493 // Test extract sub vars
494 Set<u32_t> res;
495 relation.extractSubVars(relation[2], res);
496 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
497 AbstractState inv = itv.sliceState(res);
498 RelationSolver rs;
499 const Z3Expr& relExpr = relation[2] && relation[1];
500 const Z3Expr& initExpr = rs.gamma_hat(inv);
501 const Z3Expr& phi = (relExpr && initExpr).simplify();
502 AbstractState resRSY = RSY_time(inv, phi, rs);
503 AbstractState resBilateral = Bilateral_time(inv, phi, rs);
504 AbstractState resBS = BS_time(inv, phi, rs);
505 // 0:[1,10000] 1:[1,10000] 2:[1,1]
506 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
507 for (auto r : resRSY.getVarToVal())
508 {
509 outs() << r.first << " " << r.second.getInterval() << "\n";
510 }
511 // ground truth
512 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(1, 10000)},
513 {1, IntervalValue(1, 10000)},
514 {2, IntervalValue(1, 1)}
515 };
516 }

◆ testRelExeState3_4()

void SymblicAbstractionTest::testRelExeState3_4 ( )
inline

Definition at line 518 of file ae.cpp.

519 {
520 outs() << "test3_4 start\n";
521 AbstractState itv;
522 RelExeState relation;
523 // var0 := [1, 100000];
524 relation[0] = getContext().int_const("0");
525 itv[0] = IntervalValue(1, 100000);
526 // var1 := var0;
527 relation[1] =
528 getContext().int_const("1") == getContext().int_const("0");
529 itv[1] = itv[0];
530 // var2 := var1 / var0;
531 relation[2] = getContext().int_const("2") ==
532 getContext().int_const("1") / getContext().int_const("0");
533 itv[2] = itv[1].getInterval() / itv[0].getInterval();
534 // Test extract sub vars
535 Set<u32_t> res;
536 relation.extractSubVars(relation[2], res);
537 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
538 AbstractState inv = itv.sliceState(res);
539 RelationSolver rs;
540 const Z3Expr& relExpr = relation[2] && relation[1];
541 const Z3Expr& initExpr = rs.gamma_hat(inv);
542 const Z3Expr& phi = (relExpr && initExpr).simplify();
543 AbstractState resRSY = RSY_time(inv, phi, rs);
544 AbstractState resBilateral = Bilateral_time(inv, phi, rs);
545 AbstractState resBS = BS_time(inv, phi, rs);
546 // 0:[1,100000] 1:[1,100000] 2:[1,1]
547 assert(resRSY == resBS && resBS == resBilateral && "inconsistency occurs");
548 for (auto r : resRSY.getVarToVal())
549 {
550 outs() << r.first << " " << r.second.getInterval() << "\n";
551 }
552 // ground truth
553 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(1, 100000)},
554 {1, IntervalValue(1, 100000)},
555 {2, IntervalValue(1, 1)}
556 };
557 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
558 }

◆ testRelExeState4_1()

void SymblicAbstractionTest::testRelExeState4_1 ( )
inline

Definition at line 560 of file ae.cpp.

561 {
562 outs() << "test4_1 start\n";
563 AbstractState itv;
564 RelExeState relation;
565 // var0 := [0, 10];
566 relation[0] = getContext().int_const("0");
567 itv[0] = IntervalValue(0, 10);
568 // var1 := var0;
569 relation[1] =
570 getContext().int_const("1") == getContext().int_const("0");
571 itv[1] = itv[0];
572 // var2 := var1 / var0;
573 relation[2] = getContext().int_const("2") ==
574 getContext().int_const("1") / getContext().int_const("0");
575 itv[2] = itv[1].getInterval() / itv[0].getInterval();
576 // Test extract sub vars
577 Set<u32_t> res;
578 relation.extractSubVars(relation[2], res);
579 assert(res == Set<u32_t>({0, 1, 2}) && "inconsistency occurs");
580 AbstractState inv = itv.sliceState(res);
581 RelationSolver rs;
582 const Z3Expr& relExpr = relation[2] && relation[1];
583 const Z3Expr& initExpr = rs.gamma_hat(inv);
584 const Z3Expr& phi = (relExpr && initExpr).simplify();
585 // IntervalExeState resRSY = rs.RSY(inv, phi);
586 outs() << "rsy done\n";
587 // IntervalExeState resBilateral = rs.bilateral(inv, phi);
588 outs() << "bilateral done\n";
589 AbstractState resBS = rs.BS(inv, phi);
590 outs() << "bs done\n";
591 // 0:[0,10] 1:[0,10] 2:[-00,+00]
592 // assert(resRSY == resBS && resBS == resBilateral);
593 for (auto r : resBS.getVarToVal())
594 {
595 outs() << r.first << " " << r.second.getInterval() << "\n";
596 }
597 // ground truth
598 AbstractState::VarToAbsValMap intendedRes = {{0, IntervalValue(0, 10)},
599 {1, IntervalValue(0, 10)},
600 {2, IntervalValue(0, 10)}
601 };
602 assert(resBS.eqVarToValMap(resBS.getVarToVal(), intendedRes) && "inconsistency occurs");
603 }

◆ testsValidation()

void SymblicAbstractionTest::testsValidation ( )
inline

top

Definition at line 605 of file ae.cpp.

606 {
608 saTest.testRelExeState1_1();
609 saTest.testRelExeState1_2();
610
611 saTest.testRelExeState2_1();
612 saTest.testRelExeState2_2();
613 saTest.testRelExeState2_3();
614 // saTest.testRelExeState2_4(); /// 10000
615 // saTest.testRelExeState2_5(); /// 100000
616
617 saTest.testRelExeState3_1();
618 saTest.testRelExeState3_2();
619 // saTest.testRelExeState3_3(); /// 10000
620 // saTest.testRelExeState3_4(); /// 100000
621
622 outs() << "start top\n";
623 saTest.testRelExeState4_1();
624 }
void testRelExeState1_2()
Definition ae.cpp:144
SymblicAbstractionTest()=default
void testRelExeState2_1()
Definition ae.cpp:179
void testRelExeState2_2()
Definition ae.cpp:221
void testRelExeState3_2()
Definition ae.cpp:435
void testRelExeState2_3()
Definition ae.cpp:264
void testRelExeState4_1()
Definition ae.cpp:560
void testRelExeState3_1()
Definition ae.cpp:393
void testRelExeState1_1()
Definition ae.cpp:110

The documentation for this class was generated from the following file: