一句话:提出基于CEGIS的自动化语义重构方法,为ADT数据表示变更生成语义等价的实现。
当抽象数据类型的表示发生变化时,代码常需大规模语义重构。本文提出自动化重构方法:输入原ADT实现、新数据表示和关联新旧表示的关系表示不变式,自动生成语义等价的新ADT实现。方法基于反例引导归纳合成(CEGIS),并利用三项技术:将关系合成归约为每个方法对应的编程示例(PBE)问题;用逻辑溯因推导重构代码片段;以部分等价提升归纳合成效果。作者实现Revamp重构Java类,在30个GitHub Java类上评估,97%的ADT被正确重构,146个需修改方法中成功重实现144个。
Modifications to the data representation of an abstract data type (ADT) can require significant semantic refactoring of the code. Motivated by this observation, this paper presents a new method to automate semantic code refactoring tasks. Our method takes as input the original ADT implementation, a new data representation, and a so-called relational representation invariant (relating the old and new data representations), and automatically generates a new ADT implementation that is semantically equivalent to the original version. Our method is based on counterexample-guided inductive synthesis (CEGIS) but leverages three key ideas that allow it to handle real-world refactoring tasks. First, our approach reduces the underlying relational synthesis problem to a set of (simpler) programming-by-example problems, one for each method in the ADT. Second, it leverages symbolic reasoning techniques, based on logical abduction, to deduce code snippets that should occur in the refactored version. Finally, it utilizes a notion of partial equivalence to make inductive synthesis much more effective in this setting. We have implemented the proposed approach in a new tool called Revamp for automatically refactoring Java classes and evaluated it on 30 Java class mined from Github. Our evaluation shows that Revamp can correctly refactor the entire ADT in 97% of the cases and that it can successfully re-implement 144 out of the 146 methods that require modifications.
@article{paperbot2609,
title = {Semantic Code Refactoring for Abstract Data Types},
author = {Shankara Pailoor and Yuepeng Wang and Işıl Dillig},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {POPL},
year = {2024},
doi = {10.1145/3632870}
}