AI 中文总结
研究提出源代码代数方法,通过逻辑代数操作修改代码库,概述其操作属性。实验表明大语言模型代理用此方法完成代码更改成功率更高、令牌数更少,为代码编辑提供新方向,推动相关研究。
AI 中文摘要
源代码几乎普遍被作为纯文本进行编辑。然而,有效且正确代码的句法和语义要求与试图生成它的无约束文本编辑过程之间的不匹配,带来了降低编程任务效率的摩擦。在基于大语言模型的编码代理时代,这一成本也越来越高。我们提出了源代码代数这一新颖的替代方法,通过应用一系列逻辑代数操作来修改代码库。每个操作实现单个语义变化所需的全部更改。我们概述了此类操作的初始属性,包括组合性、幂零性和交换性。可行性探测表明,相对于基于文本的基线,大语言模型代理使用源代码代数完成非局部、跨文件代码更改的成功率更高,令牌数少一到两个数量级。这支持了让大语言模型发出代数操作而非重写代码是代码编辑的一个有前途的方向这一假设,并推动对源代码代数进行更广泛的未来研究。
英文摘要
Source code is almost universally edited as plain text. However, the mismatch between the syntactic and semantic requirements of valid and correct code, and the unconstrained text editing process trying to produce it, introduces friction that degrades the programming task. It is also increasingly costly in the era of LLM-based coding agents, which must materialize their high-level plan of intended changes as low-level text edits dispersed throughout the codebase, often requiring them to re-read large portions of code. We propose the novel alternative approach of source code algebra, where the codebase is modified by applying to it a sequence of logical algebraic operations. Each operation makes the full set of changes necessary for a single semantic change, analogous to mathematical equation rewriting. We sketch initial properties of such operations - including composition, nullipotency, and commutativity - that distinguish this approach from text editing, and make it well-suited as a substrate for agentic code editing. A feasibility probe with our proof-of-concept implementation (SCAS) suggests that LLM agents can use source code algebra to complete a non-local, cross-file code change with both higher success rates and one to two orders of magnitude fewer tokens, relative to text-based baselines. While preliminary, this is consistent with the hypothesis that having LLMs emit algebraic operations, rather than rewritten code, is a promising direction for code editing - and motivates broader future research into source code algebra, such as comprehensive operator libraries, formal properties, and human-facing tooling.
CommentsAccepted for publication in the Visions and Emerging Results Track of the 42nd IEEE International Conference on Software Maintenance and Evolution (ICSME 2026), 14-18 September 2026, Benevento, Italy