Automatic program repair seeks to generate correct code from buggy programs, with most approaches searching the correct program in a discrete, symbolic space of source code tokens. This symbolic search is fundamentally limited by its inability to directly reason about program behavior. We introduce Gradient-Based Program Repair (GBPR), a new approach that recasts program repair as continuous optimization in a differentiable numerical program space. Our core insight is to compile symbolic programs into differentiable numerical representations, enabling search in the numerical program space directly guided by program behavior. To evaluate GBPR, we present RaspBugs, a new benchmark of 1,466 buggy symbolic RASP programs and their respective numerical representations. Our experiments demonstrate that GBPR can effectively repair buggy symbolic programs by gradient-based optimization in the numerical program space, with convincing repair trajectories. To our knowledge, we are the first to state program repair as continuous optimization in a numerical program space. Our work demonstrates the feasibility of this direction for program repair research, bridging continuous optimization and program behavior.
翻译:自动程序修复旨在从有缺陷的程序中生成正确的代码,大多数方法在源代码标记的离散符号空间中搜索正确的程序。这种符号搜索因其无法直接推理程序行为而存在根本性限制。我们提出了基于梯度的程序修复(Gradient-Based Program Repair,GBPR),这是一种将程序修复重构为可微数值程序空间中的连续优化的新方法。我们的核心见解是将符号程序编译为可微数值表示,从而能够在由程序行为直接引导的数值程序空间中进行搜索。为评估GBPR,我们提出了RaspBugs,这是一个包含1,466个有缺陷的符号RASP程序及其对应数值表示的新基准。实验表明,GBPR能够通过在数值程序空间中进行基于梯度的优化有效修复有缺陷的符号程序,并展示出令人信服的修复轨迹。据我们所知,我们是首次将程序修复表述为数值程序空间中的连续优化。我们的工作证明了这一方向在程序修复研究中的可行性,架起了连续优化与程序行为之间的桥梁。