TL;DR
Program trimming is a novel pre-processing technique that simplifies programs by semantically pruning execution paths that are guaranteed not to violate safety properties. By generating an "equi-safe" version of a program with significantly fewer paths, it dramatically improves the scalability of symbolic execution engines and the precision of abstract interpreters.
What Problem Does This Paper Address?
Safety checking—the process of proving a program is free of bugs like assertion violations—is plagued by the "state explosion" problem. Traditional program simplification, primarily program slicing, focuses on removing statements that don't affect the value of a variable at a specific location.
However, slicing is often too blunt an instrument for safety checking. A slice might retain a massive, complex loop because it modifies a variable involved in an assertion, even if that loop could never actually cause the assertion to fail. The authors argue that we need a "failure-directed" approach: instead of asking what statements affect a variable, we should ask which execution paths are even capable of reaching a failing state.
Methods
The authors introduce Program Trimming, a technique that transforms a program $P$ into a simpler, "equi-safe" program $P'$. $P'$ is guaranteed to have a bug if and only if $P$ does, but it contains far fewer execution paths.
The core of the approach is a two-phase lightweight static analysis:
- Safety Condition Inference: The tool, called Trimmer, performs a backward analysis to infer safety conditions—sufficient conditions for the rest of the program execution to be error-free. While calculating the most precise safety condition (the weakest precondition) is computationally expensive, Trimmer uses a modular, lightweight inference engine that sacrifices some precision for extreme speed. For example, it handles heap aliasing conservatively to avoid the exponential blow-up typical of precise pointer analysis.
- Program Instrumentation: Once safety conditions are inferred, Trimmer negates them to obtain trimming conditions (necessary conditions for failure). It then instruments the original code with
assumestatements based on these conditions. If a program path violates an assumption, it is semantically pruned, allowing downstream analyzers to ignore it entirely.
To handle procedure calls without losing soundness or modularity, Trimmer creates "safe" versions of functions where assertions are converted into assumptions, ensuring that the analysis remains property-directed even across function boundaries.
Datasets
The authors evaluated Trimmer on a suite of 439 C programs. The majority (92%) were drawn from the SV-COMP (Software Verification Competition) benchmarks, covering categories like ControlFlow, Loops, Recursive, and ArrayReach.
Because many standard benchmarks contain "shallow" bugs that are too easy to find, the researchers augmented the set with additional programs containing "deeper" bugs, either sourced elsewhere or manually injected, to better test the limits of the analysis tools.
Key Insights and Ideas
- Paths over Statements: Unlike slicing, which deletes lines of code, trimming prunes behaviors. It recognizes that a piece of code might be relevant to a variable's value but irrelevant to its failure.
- Equi-safety is the Goal: The transformation doesn't need to preserve every behavior of the program—only the existence (or absence) of bugs. This allows for much more aggressive simplification than general-purpose program reduction.
- Precision through Pruning: One of the most interesting findings is that trimming helps abstract interpreters (like Crab). These tools often lose precision at "join points" (where different execution paths meet). By pruning irrelevant paths before they reach a join point, Trimmer prevents this precision loss, allowing the analyzer to prove properties it otherwise couldn't.
- Modular Instrumentation: The use of "safe" procedure variants allows the tool to instrument programs procedurally without needing a global, whole-program analysis, keeping the pre-processing step extremely fast.
Key Results
The evaluation focused on two major types of analysis: Abstract Interpretation (using Crab) and Dynamic Symbolic Execution (using Klee).
- Speed and Efficiency: Trimming is incredibly fast, averaging only 11–20 milliseconds per benchmark. As shown in Table 1, the total pre-processing time for hundreds of benchmarks was negligible.
- Abstract Interpretation (Crab): Trimming improved Crab's precision by 23% to 54%. Notably, the "cheapest" configuration of Crab with trimming proved 21% more programs safe than the most expensive untrimmed configuration, while taking less than 70% of the time.
- Symbolic Execution (Klee): Trimming allowed Klee to find up to 30% more bugs and verify 18% more programs within a fixed resource limit. It also reduced the number of paths Klee had to explore by up to 38%, leading to a 30% reduction in total running time.
Limitations and Future Work
- Liveness Properties: Program trimming is designed for safety checking. It does not necessarily preserve liveness properties; for instance, a non-terminating execution in the original program might become a terminating (but non-failing) execution in the trimmed version.
- Language Scope: The current implementation and evaluation are focused on C/LLVM. The effectiveness of these specific lightweight heuristics on higher-level languages with different memory models remains to be seen.
- Future Directions: The authors suggest exploring the impact of trimming on other tools like bounded model checkers and investigating alternative, perhaps more aggressive, trimming algorithms.
Summary updated