TL;DR
This paper introduces a novel approach to automatically finding effective program abstractions for static analysis. By learning a probabilistic model of analysis behavior, the system can intelligently guide the abstraction refinement process, balancing the need for precision with computational cost. This leads to more efficient and effective static analyses.
What Problem Does This Paper Address?
Static program analysis aims to determine properties of programs without actually running them. A key challenge is finding the right "abstraction" – a simplified representation of the program that retains enough detail to answer a specific query (e.g., "is this variable ever null?") but is simple enough for the analysis to complete in a reasonable time. Traditional methods often rely on manually designed heuristics to guide this abstraction refinement process, which can be suboptimal and difficult to transfer across different analyses. This paper tackles the problem of automatically discovering good abstractions by learning from past analysis runs.
Methods
The core of the paper is a counterexample-guided abstraction refinement (CEGAR) approach enhanced with a learnt probabilistic model.
- Parametric Datalog Analyses: The approach targets static analyses implemented in Datalog, which are inherently parametric (meaning their behavior can be tuned by parameters). An abstraction is essentially a setting of these parameters.
- Probabilistic Model: The authors propose a probabilistic model that predicts how a program's analysis behavior (represented as a hypergraph of derived facts) would change when moving to a more precise parameter setting. This model is a variant of the Erdős-Rényi random graph model and is tuned by "hyperparameters."
- Learning Hyperparameters: Crucially, the system learns the values of these hyperparameters by observing past analysis runs on a codebase. This allows the model to adapt to the specific characteristics of the programs and the analysis.
- Refinement Algorithm: The learned probabilistic model is used to guide the refinement process. Instead of blindly trying new abstractions, the algorithm intelligently selects the next abstraction by balancing two factors:
- Probability of Success: How likely is this abstraction to lead to a definitive answer (either proving the query false or showing it's unavoidable)?
- Estimated Cost: How expensive will it be to run the analysis with this abstraction?
- MAXSAT Encoding: To efficiently search for the best next abstraction among a vast number of possibilities, the problem is encoded as a MAXSAT problem, which is then solved using a MAXSAT solver.
Datasets
- Training Data: The learning of hyperparameters is performed on a set of programs. For evaluation, the authors used 8 Java programs, totaling 0.45 MiB of application bytecode plus 1 MiB of library bytecode.
- Evaluation Data: The evaluation also uses the same 8 Java programs. The authors specifically mention using queries from both the PolySite and Downcast analyses.
Key Insights and Ideas
- Learning from Experience: The core idea that an analysis can "learn" from its past runs to improve future performance is powerful. This moves beyond static, hand-tuned heuristics.
- Probabilistic Prediction of Abstraction Behavior: Instead of just trying abstractions, predicting their effectiveness probabilistically allows for a more informed search. This is a significant departure from traditional CEGAR.
- Balancing Precision and Cost: The explicit modeling of both the probability of finding an answer and the computational cost is key to making the refinement efficient. This is framed as an "Action Scheduling Problem."
- Hyperparameters as Analysis Insights: The learned hyperparameters can reveal which parts of an analysis are most critical for approximation, offering insights into the analysis's design.
- MAXSAT for Efficient Search: Encoding the complex search for the optimal next abstraction into a MAXSAT problem is an elegant way to leverage existing solvers for this combinatorial challenge.
Key Results
- Improved Query Solving: The probabilistic strategy, especially when combined with an approximate MAXSAT solver, solved more queries than optimistic or pessimistic strategies in their experiments.
- Runtime Efficiency: The probabilistic and pessimistic strategies generally showed better runtime performance compared to the optimistic strategy.
- Identification of Critical Rules: The learned hyperparameters successfully identified a small subset of Datalog rules that were most involved in approximations, providing valuable insights into the aliasing analysis.
- Comparison to Prior Work: The authors' approach showed promise compared to previous work on abstraction refinement, though direct quantitative comparisons are nuanced due to differences in experimental setups.
Limitations and Future Work
- MAXSAT Solver Performance: The performance of the MAXSAT solver was a bottleneck. The authors note that their approximate MAXSAT solver was "dumb" and that better solvers could improve results.
- Learned vs. All-One Hyperparameters: In their experiments, setting all hyperparameters to 1 (effectively a pessimistic strategy) performed as well as or better than using learned hyperparameters. The authors believe this is due to the simplicity of their learned model and suggest that more sophisticated models or larger training sets might yield better results.
- Future Work:
- Investigating better approximate MAXSAT solvers.
- Applying the approach to more analyses implemented in Datalog.
- Exploring combinations of optimistic and pessimistic strategies.
- Further characterizing the theoretical properties of the refinement algorithm, especially in the context of abstract interpretation.
Summary updated