- 2067 Ashadh (old course) · 4 marks
Symbolic execution
Short answer
Symbolic execution is a static verification technique where a program is executed with symbolic inputs instead of concrete values. Variables hold algebraic expressions, and at each branch a path condition is recorded. It is used to generate test inputs, find error paths, and verify path correctness, but suffers from path explosion.
Define symbolic execution in the context of software engineering.
Symbolic execution is a static verification technique in which a program is "executed" with symbols (such as X and Y) as inputs instead of actual values. Variables then hold algebraic expressions of the inputs, and at each branch the condition on the inputs is recorded as a path condition. The result for each path is the output expressed as a formula in terms of the inputs, together with the condition under which that path is taken.
How it works
- Assign symbolic values to all inputs.
- Execute statements, updating variables with symbolic expressions.
- At each
ifor loop, split into two paths and add the condition (or its negation) to the path condition. - A path whose condition cannot be satisfied is infeasible and is dropped.
- For each feasible path, solve the path condition to get concrete test inputs, or check that the output meets the specification.
Example
int f(int x, int y) {
int z = 2 * y;
if (z == x)
if (x > y + 10)
error();
return 0;
}
With x = X, y = Y, we get z = 2Y:
| Path | Path condition | Result |
|---|---|---|
| 1 | 2Y != X | returns 0 |
| 2 | 2Y == X and X <= Y + 10 | returns 0 |
| 3 | 2Y == X and X > Y + 10 | error() |
Solving path 3 gives Y > 10, for example Y = 11, X = 22. A random test would rarely find these values, but symbolic execution finds them directly.
Uses and limits
- Uses: verifying that each path meets its specification, automatic test case generation, finding unreachable code and error paths. Tools such as KLEE and Java PathFinder use it.
- Limits: the number of paths grows very fast with loops and branches (path explosion); loops with unknown bounds, pointers and complex arithmetic make expressions hard to solve.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Short note: component-based software engineering · Software Engineering, chapter 6
- Objectives of FTR; cleanroom software engineering · Software Engineering, chapter 9
- Software errors and their impact on cost · Software Engineering, chapter 7 · asked 2×
- Software reliability and reliability models · Software Engineering, chapter 9 · asked 2×
- Software crisis · Software Engineering, chapter 1
- Short note: software safety · Software Engineering, chapter 7
- Process vs thread; context switching · Operating System, chapter 2
- Why estimate before execution (water supply) · Estimating and Costing, chapter 1
- Short note: Planning software, MS Project · Project Engineering, chapter 3 · asked 2×
- Software used for FEM and FDM · Computational Techniques in Civil Engineering, chapter 1