Bounded Exhaustive Search of Alloy Specification Repairs

Simón Gutiérrez Brida, Germán Regis, Guolong Zheng, Hamid Bagheri, ThanhVu Nguyen, Nazareno Aguirre, Marcelo F. Frias

Abstract

The rising popularity of declarative languages and the hard to debug nature thereof have motivated the need for applicable, automated repair techniques for such languages. However, despite significant advances in the program repair of imperative languages, there is a dearth of repair techniques for declarative languages. This paper presents BeAFix, an automated repair technique for faulty models written in Alloy, a declarative language based on first-order relational logic. BeAFix is backed with a novel strategy for bounded exhaustive, yet scalable, exploration of the spaces of fix candidates and a formally rigorous, sound pruning of such spaces. Moreover, different from the state-of-the-art in Alloy automated repair, that relies on the availability of unit tests, BeAFix does not require tests and can work with assertions that are naturally used in formal declarative languages. Our experience with using BeAFix to repair thousands of real-world faulty models, collected by other researchers, corroborates its ability to effectively generate correct repairs and outperform the state-of-the-art.

Introduction

In the field of software engineering, automated program repair has seen significant progress, primarily targeting imperative languages like Java or C++. However, declarative languages such as Alloy—used for high-level system design via relational logic—present unique challenges. Specification repair is difficult because models are concise and lack redundancy, there is a scarcity of large-scale training data for learning-based approaches, and traditional unit tests are often replaced by formal assertions, creating an "oracle problem" for standard repair tools.

Methodology: The BeAFix Approach

BeAFix introduces a Bounded Exhaustive Search method to systematically explore mutations within a defined complexity depth. To make this search computationally feasible, the authors developed two key pruning strategies:

  • Partial Repair Checking: A syntactic analysis that skips modifications to model components that do not affect the specific oracle being checked.
  • Variabilization: A semantic check that uses placeholders to determine if any possible value could satisfy the model. If no such value exists, the entire search branch is pruned.

Evaluation Benchmarks

The tool was evaluated against two primary datasets:

  1. ARepair Benchmark: 38 models, including linked lists and binary search trees, previously used to benchmark the ARepair tool.
  2. Alloy4Fun Dataset: A collection of 2,209 faulty models created by students, representing a diverse set of real-world logic errors.

Key Results and Insights

Experimental results demonstrate that formal assertions are a superior oracle for repair compared to unit tests. While tests often lead to "overfitting"—patches that pass tests but fail to fix the underlying logic—assertions capture the model's intent more accurately.

Efficiency and Repairability

The pruning strategies are vital for the tool's performance. As shown in the experimental data, enabling pruning significantly increases the number of cases repaired within a time limit while drastically reducing the average time required per repair.

Table 1: Comparison of repair performance with pruning enabled versus disabled across ARepair and Alloy4Fun benchmarks.

Key performance metrics include:

  • Efficiency Gains: Pruning reduced repair time by an average of 62x on the ARepair benchmark and 85x on the Alloy4Fun benchmark.
  • Increased Repairability: Within a one-hour window, BeAFix more than doubled the successful repairs compared to the unoptimized version.
  • Correctness: BeAFix achieved a 47% correct repair rate on the Alloy4Fun dataset using assertions, far outperforming the 9% rate achieved by test-based tools which suffered from high overfitting.
  • Speed: In one instance, BeAFix resolved a bug in 3 seconds that took a human student 49 minutes to fix.

Conclusion and Future Work

BeAFix demonstrates that exhaustive search is a viable strategy for declarative specification repair when coupled with effective pruning and assertion-based oracles. Future research will focus on reducing dependency on the quality of user-provided assertions and exploring higher-order logic solvers to further enhance the variabilization check.

Summary updated

BibTeX
@inproceedings{brida2021bounded,
  author = {Simón Gutiérrez Brida and Germán Regis and Guolong Zheng and Hamid Bagheri and ThanhVu Nguyen and Nazareno Aguirre and Marcelo F. Frias},
  title = {{Bounded Exhaustive Search of Alloy Specification Repairs}},
  booktitle = {ICSE},
  year = {2021},
  url = {https://openreview.net/forum?id=BGsfvtI12U},
}
Figure