@@ -76,51 +76,71 @@ void symex_transition(goto_symext::statet &state)
76
76
symex_transition (state, next, false );
77
77
}
78
78
79
- void goto_symext::vcc (
80
- const exprt &vcc_expr,
81
- const std::string &msg,
79
+ void goto_symext::symex_assert (
80
+ const goto_programt::instructiont &instruction,
82
81
statet &state)
83
82
{
84
- state.total_vccs ++;
85
- path_segment_vccs++;
86
-
87
- exprt expr=vcc_expr;
83
+ exprt condition = instruction.get_condition ();
84
+ clean_expr (condition, state, false );
88
85
89
86
// we are willing to re-write some quantified expressions
90
- if (has_subexpr (expr , ID_exists) || has_subexpr (expr , ID_forall))
87
+ if (has_subexpr (condition , ID_exists) || has_subexpr (condition , ID_forall))
91
88
{
92
89
// have negation pushed inwards as far as possible
93
- do_simplify (expr );
94
- rewrite_quantifiers (expr , state);
90
+ do_simplify (condition );
91
+ rewrite_quantifiers (condition , state);
95
92
}
96
93
97
94
// now rename, enables propagation
98
- exprt l2_expr = state.rename (std::move (expr ), ns);
95
+ exprt l2_condition = state.rename (std::move (condition ), ns);
99
96
100
97
// now try simplifier on it
101
- do_simplify (l2_expr );
98
+ do_simplify (l2_condition );
102
99
103
- if (l2_expr.is_true ())
100
+ std::string msg = id2string (instruction.source_location .get_comment ());
101
+ if (msg == " " )
102
+ msg = " assertion" ;
103
+
104
+ vcc (l2_condition, msg, state);
105
+ }
106
+
107
+ void goto_symext::vcc (
108
+ const exprt &condition,
109
+ const std::string &msg,
110
+ statet &state)
111
+ {
112
+ state.total_vccs ++;
113
+ path_segment_vccs++;
114
+
115
+ if (condition.is_true ())
104
116
return ;
105
117
106
- state.guard .guard_expr (l2_expr);
118
+ exprt guarded_condition = condition;
119
+ state.guard .guard_expr (guarded_condition);
107
120
108
121
state.remaining_vccs ++;
109
- target.assertion (state.guard .as_expr (), l2_expr , msg, state.source );
122
+ target.assertion (state.guard .as_expr (), guarded_condition , msg, state.source );
110
123
}
111
124
112
125
void goto_symext::symex_assume (statet &state, const exprt &cond)
113
126
{
114
127
exprt simplified_cond=cond;
115
128
129
+ clean_expr (simplified_cond, state, false );
130
+ simplified_cond = state.rename (std::move (simplified_cond), ns);
116
131
do_simplify (simplified_cond);
117
132
118
- if (simplified_cond.is_true ())
133
+ symex_assume_l2 (state, simplified_cond);
134
+ }
135
+
136
+ void goto_symext::symex_assume_l2 (statet &state, const exprt &cond)
137
+ {
138
+ if (cond.is_true ())
119
139
return ;
120
140
121
141
if (state.threads .size ()==1 )
122
142
{
123
- exprt tmp=simplified_cond ;
143
+ exprt tmp = cond ;
124
144
state.guard .guard_expr (tmp);
125
145
target.assumption (state.guard .as_expr (), tmp, state.source );
126
146
}
@@ -131,7 +151,7 @@ void goto_symext::symex_assume(statet &state, const exprt &cond)
131
151
// x=0; assume(x==1);
132
152
// assert(x!=42); x=42;
133
153
else
134
- state.guard .add (simplified_cond );
154
+ state.guard .add (cond );
135
155
136
156
if (state.atomic_section_id !=0 &&
137
157
state.guard .is_false ())
@@ -402,31 +422,21 @@ void goto_symext::symex_step(
402
422
break ;
403
423
404
424
case GOTO:
405
- symex_goto (state);
425
+ if (!state.guard .is_false ())
426
+ symex_goto (state);
427
+ else
428
+ symex_transition (state);
406
429
break ;
407
430
408
431
case ASSUME:
409
432
if (!state.guard .is_false ())
410
- {
411
- exprt tmp = instruction.get_condition ();
412
- clean_expr (tmp, state, false );
413
- symex_assume (state, state.rename (std::move (tmp), ns));
414
- }
415
-
433
+ symex_assume (state, instruction.get_condition ());
416
434
symex_transition (state);
417
435
break ;
418
436
419
437
case ASSERT:
420
438
if (!state.guard .is_false ())
421
- {
422
- std::string msg=id2string (state.source .pc ->source_location .get_comment ());
423
- if (msg==" " )
424
- msg=" assertion" ;
425
- exprt tmp (instruction.get_condition ());
426
- clean_expr (tmp, state, false );
427
- vcc (tmp, msg, state);
428
- }
429
-
439
+ symex_assert (instruction, state);
430
440
symex_transition (state);
431
441
break ;
432
442
@@ -445,17 +455,8 @@ void goto_symext::symex_step(
445
455
case FUNCTION_CALL:
446
456
if (!state.guard .is_false ())
447
457
{
448
- code_function_callt deref_code = instruction.get_function_call ();
449
-
450
- if (deref_code.lhs ().is_not_nil ())
451
- clean_expr (deref_code.lhs (), state, true );
452
-
453
- clean_expr (deref_code.function (), state, false );
454
-
455
- Forall_expr (it, deref_code.arguments ())
456
- clean_expr (*it, state, false );
457
-
458
- symex_function_call (get_goto_function, state, deref_code);
458
+ symex_function_call (
459
+ get_goto_function, state, instruction.get_function_call ());
459
460
}
460
461
else
461
462
symex_transition (state);
@@ -464,14 +465,12 @@ void goto_symext::symex_step(
464
465
case OTHER:
465
466
if (!state.guard .is_false ())
466
467
symex_other (state);
467
-
468
468
symex_transition (state);
469
469
break ;
470
470
471
471
case DECL:
472
472
if (!state.guard .is_false ())
473
473
symex_decl (state);
474
-
475
474
symex_transition (state);
476
475
break ;
477
476
0 commit comments