Introduction
Modern software verification and program synthesis tools are increasingly dependent on Satisfiability Modulo Theories (SMT) solvers. To manage the complexity of the formulas passed to these solvers, a pre-processing step known as "simplification" is employed. Simplification aims to reduce the size and complexity of a formula before the solver begins its search, significantly impacting overall performance. Traditionally, these simplifiers are hand-coded by domain experts—a process that is not only error-prone and tedious but also results in general-purpose tools that fail to exploit the unique structures, or "textures," of specific problem domains.
This paper introduces SWAPPER, a framework designed to automate the creation of domain-specific formula simplifiers. By leveraging random sampling, program synthesis, and empirical autotuning, SWAPPER generates rewrite rules that outperform human-engineered baselines, offering a scalable solution to the bottleneck of manual simplifier maintenance.
The SWAPPER Framework
SWAPPER operates through a four-phase pipeline that transforms a corpus of domain-specific formulas into a high-performance, compiled simplifier.
1. Pattern Finding
The process begins with a novel random sampling algorithm. SWAPPER scans a provided corpus of formulas to identify "domain-significant" sub-graphs. These are patterns that appear frequently within a specific application (e.g., hardware synthesis or automated grading) but might be rare in general logic. Identifying these patterns allows the system to focus its synthesis efforts on the most impactful areas of the formula.
2. Rule Generation
For each identified pattern—the Left-Hand Side (LHS) of a potential rule—SWAPPER attempts to find a simpler, mathematically equivalent Right-Hand Side (RHS). This is achieved through a hybrid synthesis approach:
- Enumerative Search: Used to find simple boolean conditions (guards) under which a rewrite is valid.
- Symbolic Synthesis: Utilizing the Sketch tool to discover the replacement logic. This combination allows SWAPPER to find complex, conditional rules that would be difficult for either method to discover in isolation.
3. Code Generation
Once a set of valid rules is discovered, they are compiled into high-performance C++ code. The generated code is optimized for efficiency, utilizing shared pattern matching across multiple rules to ensure that the simplification process itself adds negligible overhead to the solver's total runtime.
4. Auto-tuning
Not all valid rewrites improve performance; some may increase formula complexity for the solver or prevent more beneficial rules from firing. SWAPPER employs OpenTuner to empirically test various combinations and orderings of rules against a training set. This phase ensures the final "recipe" is optimized for the specific solver and domain at hand.
Evaluation and Results
The authors evaluated SWAPPER using benchmarks from the Sketch synthesis system, focusing on four distinct domains: AutoGrader (student programming assignments), SyGuS (syntax-guided synthesis), Storyboard (programming-by-example), and QBS (SQL query inference). The primary evaluation focused on AutoGrader and SyGuS, where the complexity of formulas is highest.
Performance Gains
SWAPPER-generated simplifiers demonstrated substantial improvements over existing baselines. In the AutoGrader domain, the framework reduced formula sizes by an average of 13.8% more than the expert-written simplifier, which had been manually refined for eight years. More importantly, these reductions translated to a 30% to 50% improvement in the running time of the Sketch tool. For instance, average solve times in the AutoGrader benchmarks dropped from 20 seconds to just 13 seconds.
Domain Specificity and Cost
A key insight from the study was the necessity of domain-specific tuning. A simplifier optimized for the SyGuS domain actually degraded performance when applied to AutoGrader problems, confirming that formulas possess unique characteristics based on their source. Furthermore, the generation of these high-performance simplifiers is remarkably cost-effective, costing approximately $22–$24 in cloud computing resources—less than the hourly rate of a specialized developer.
Discussion and Limitations
While SWAPPER represents a significant step forward, it is not without limitations. The effectiveness of the generated simplifier is highly dependent on the quality of the training corpus; if the training data does not represent future problems, the rules may be ineffective. Additionally, the synthesis of the RHS is currently constrained by a predefined grammar, and the initial generation process requires approximately 20–22 hours of computation.
Despite these constraints, SWAPPER proves that empirical, automated methods can surpass human intuition in the complex landscape of logic simplification. By treating simplifier generation as a synthesis and tuning problem, the framework provides a path toward more efficient and specialized formal methods tools.
Summary updated