paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Semantic Code Refactoring for Abstract Data Types

抽象数据类型的语义代码重构
POPL 8(POPL)2024匹配度 2/10 · 论文属于程序合成与自动化语义重构,使用CEGIS和符号推理,但与用户核心关注的LLM/Agent与静态分析交叉、ML/Agentic程序分析、浮点程序分析或贝叶斯程序分析均无直接关系。引用 13 inbox
Shankara Pailoor, Yuepeng Wang, Işıl Dillig
crossref: 2026-09-10

AI 速览

一句话:提出基于CEGIS的自动化语义重构方法,为ADT数据表示变更生成语义等价的实现。

当抽象数据类型的表示发生变化时,代码常需大规模语义重构。本文提出自动化重构方法:输入原ADT实现、新数据表示和关联新旧表示的关系表示不变式,自动生成语义等价的新ADT实现。方法基于反例引导归纳合成(CEGIS),并利用三项技术:将关系合成归约为每个方法对应的编程示例(PBE)问题;用逻辑溯因推导重构代码片段;以部分等价提升归纳合成效果。作者实现Revamp重构Java类,在30个GitHub Java类上评估,97%的ADT被正确重构,146个需修改方法中成功重实现144个。

问题
抽象数据类型的数据表示修改往往需要大量手工语义重构,直接改写容易破坏原有语义。
方法
给定原ADT实现、新表示及关系表示不变式,采用CEGIS,并通过PBE分解、逻辑溯因和部分等价来合成与原实现语义等价的新实现。
评估
实现工具Revamp并在30个从GitHub挖掘的Java类上评估,97%的ADT被正确重构,146个需修改方法中成功重实现144个。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@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}
}