@@ -10,12 +10,21 @@ This takes a goto-program and translates it to an equation system by
10
10
traversing the program, branching and merging and unwinding loops and recursion
11
11
as needed.
12
12
13
- The output of the symbolic execution is a system of equations; an object
14
- containing a list of \ref symex_target_equationt::SSA_stept structures, each of
15
- which are equalities between \ref exprt expressions.
16
- The output is in static, single assignment (SSA) form, which is * not*
17
- the case for goto-programs.
13
+ The output of symbolic execution is a system of equations, asserations and
14
+ assumptions; an object of type ` symex_target_equationt ` , containing a list of
15
+ ` symex_target_equationt::SSA_stept ` , each of which are equalities between
16
+ ` exprt ` expressions. This list is constructed incrementally as the symbolic
17
+ execution engine walks through the goto-program using the ` symex_targett `
18
+ interface. This interface (implemented by ` symex_target_equationt ` ) exposes
19
+ functions that append SSA steps into the aforementioned list while transforming
20
+ expressions into Static Single Assignment (SSA) form. For more details on this
21
+ process see ` symex_target_equation.h ` , for an overview of SSA see \ref
22
+ static-single-assignment.
23
+
24
+ At a later stage, BMC will convert the generated SSA steps into an
25
+ equation that can be passed to the solver.
18
26
27
+ ---
19
28
\section symbolic-execution Symbolic Execution
20
29
21
30
In the \ref goto-symex directory.
@@ -135,47 +144,80 @@ execution run does not add any paths to the workqueue but rather merges
135
144
all the paths together, so the additional path-exploration loop is
136
145
skipped over.
137
146
138
- \subsection ssa-renaming SSA renaming levels
139
-
140
- In goto-programs, variable names get a prefix to indicate their scope
141
- (like ` main::1::%foo ` or whatever). At symbolic execution level, variables
142
- also get a _ suffix_ because we’re doing single-static assignment. There
143
- are three “levels” of renaming. At Level 2, variables are renamed every
144
- time they are encountered in a function. At Level 1, variables are
145
- renamed every time the functions that contain those variables are
146
- called. At Level 0, variables are renamed every time a new thread
147
- containing those variables are spawned. We can inspect the renamed
148
- variable names with the –show-vcc flag, which prints a string with the
149
- following format: ` %%s!%%d@%%d#%%d ` . The string field is the variable name,
150
- and the numbers after the !, @, and # are the L0, L1, and L2 suffixes
151
- respectively. The following examples illustrate Level 1 and 2 renaming:
147
+ ---
148
+ \section static-single-assignment Static Single Assignment (SSA) Form
149
+
150
+ ** Key classes:**
151
+ * \ref symex_targett
152
+ * \ref symex_target_equationt
153
+
154
+ * Static Single Assignment (SSA)* form is an intermediate
155
+ representation that satisfies the following properties:
156
+
157
+ 1 . Every variable is * assigned exactly once* .
158
+ 2 . Every variable must be * defined* before use.
159
+
160
+ In-order to convert a goto-program to SSA form all variables are
161
+ indexed (renamed) through the addition of a _ suffix_ .
162
+
163
+ There are three “levels” of indexing:
164
+
165
+ ** Level 2 (L2):** variables are indexed every time they are
166
+ encountered in a function.
167
+
168
+ ** Level 1 (L1):** variables are indexed every time the functions that
169
+ contain those variables are called.
170
+
171
+ ** Level 0 (L0):** variables are indexed every time a new thread
172
+ containing those variables are spawned.
173
+
174
+ We can inspect the indexed variable names with the ** --show-vcc** or
175
+ ** --program-only** flags. Variables in SSA form are printed in the
176
+ following format: ` %%s!%%d@%%d#%%d ` . Where the string field is the
177
+ variable name, and the numbers after the !, @, and # are the L0, L1,
178
+ and L2 suffixes respectively.
179
+
180
+ > Note: ** --program-only** prints all the SSA steps in-order. In
181
+ > contrast, ** --show-vcc** will for each assertion print the SSA steps
182
+ > (assumes, assignments and constraints only) that synthetically
183
+ > precede the assertion. In the presence of multiple threads it will
184
+ > also print SSA steps that succeed the assertion.
185
+
186
+ \subsection L1-L2 Level 1 and level 2 indexing
187
+
188
+ The following examples illustrate Level 1 and 2 indexing.
152
189
153
190
$ cat l1.c
154
- int main() {
191
+ int main()
192
+ {
155
193
int x=7;
156
194
x=8;
157
195
assert(0);
158
196
}
197
+
159
198
$ cbmc --show-vcc l1.c
160
199
...
161
200
{-12} x!0@1#2 == 7
162
201
{-13} x!0@1#3 == 8
163
202
164
- That is, the L0 names for both xs are 0; the L1 names for both xs are 1;
165
- but each occurrence of x within main() gets a fresh L2 suffix (2 and 3,
166
- respectively).
203
+ That is, the L0 names for both x's are 0; the L1 names for both x's
204
+ are 1; but each occurrence of x within main() gets a fresh L2 suffix
205
+ (2 and 3, respectively).
167
206
168
207
$ cat l2.c
169
- void foo(){
208
+ void foo()
209
+ {
170
210
int x=7;
171
211
x=8;
172
212
x=9;
173
213
}
174
- int main(){
214
+ int main()
215
+ {
175
216
foo();
176
217
foo();
177
218
assert(0);
178
219
}
220
+
179
221
$ cbmc --show-vcc l2.c
180
222
...
181
223
{-12} x!0@1#2 == 7
@@ -186,23 +228,42 @@ respectively).
186
228
{-17} x!0@2#4 == 9
187
229
188
230
That is, every time we enter function foo, the L1 counter of x is
189
- incremented (from 1 to 2) and the L0 counter is reset (back to 2, after
190
- having been incremented up to 4). The L0 counter then increases every
191
- time we access x as we walk through the function.
231
+ incremented (from 1 to 2) and the L2 counter is reset (back to 2,
232
+ after having been incremented up to 4). The L2 counter then increases
233
+ every time we access x as we walk through the function.
234
+
235
+ \subsection L0 Level 0 indexing (threads only)
236
+
237
+ TODO: describe and give a concrete example
238
+
239
+ \subsection PL Relevant Primary Literature
240
+
241
+ Thread indexing is based on the following paper:
242
+
243
+ > Lee, J., Midkiff, S.P. and Padua, D.A., 1997, August. Concurrent
244
+ > static single assignment form and constant propagation for
245
+ > explicitly parallel programs. In International Workshop on Languages
246
+ > and Compilers for Parallel Computing (pp. 114-130). Springer,
247
+ > Berlin, Heidelberg.
248
+
249
+ Seminal paper on SSA:
250
+
251
+ > Rosen, B.K., Wegman, M.N. and Zadeck, F.K., 1988, January. Global
252
+ > value numbers and redundant computations. In Proceedings of the 15th
253
+ > ACM SIGPLAN-SIGACT symposium on Principles of programming languages
254
+ > (pp. 12-27). ACM.
192
255
193
256
---
194
257
\section counter-example-production Counter Example Production
195
258
196
259
In the \ref goto-symex directory.
197
260
198
-
199
-
200
261
** Key classes:**
201
- * symex_target_equationt
202
- * prop_convt
262
+ * \ref symex_target_equationt
263
+ * \ref prop_convt
203
264
* \ref bmct
204
- * fault_localizationt
205
- * counterexample_beautificationt
265
+ * \ref fault_localizationt
266
+ * \ref counterexample_beautificationt
206
267
207
268
\dot
208
269
digraph G {
0 commit comments