跳到正文
arXiv cs.AI· Nicolas Menet, Michael Hersche, Andreas Krause, Abbas Rahimi·· 12 小时前AI 评分33

测试驱动代码生成的理论分析:环境交互策略的概率框架与遗憾界

A Theoretical Analysis of Test-Driven Code Generation

AI 导读

研究为测试驱动代码生成提出概率框架,分析"先生成后按执行环境选择"与"基于环境反馈生成"两种范式。理论证明基于模糊功能相似性的估计器在信噪比上严格优于功能等价估计器,并将 backprompting 建模为 Thompson sampling 的上下文近似,推导出含不可观测成分奖励函数的新遗憾界,指出其效果受非正式任务描述歧义限制。

正文 · 原文

View PDF HTML (experimental)

Abstract:Code assistants are increasingly utilized in test-driven software development, yet the theoretical mechanisms behind their environment-interaction strategies remain underexplored. We provide a probabilistic framework for two dominant paradigms: code selection after generation using the execution environment, and code generation conditioned on environment feedback. First, we formalize several well-established selection heuristics as environment-aware estimators of code correctness. We theoretically prove that estimators based on fuzzy functional similarity add an inductive bias and strictly dominate estimators based on functional equivalence in terms of signal-to-noise ratio. Second, we frame backprompting as an in-context approximation of Thompson sampling. We derive a novel regret bound for reward functions with unobservable components, theoretically explaining why the effectiveness of backprompting is limited by the ambiguity of the informal task description (an irreducible regret). Using seven state-of-the-art open weight models, we corroborate these findings across BigCodeBenchHard, LeetCodeDataset, QiskitHumanEvalSim, and SWE-bench Verified. Our formalization also suggests how to improve task descriptions effectively, leading to an improved benchmark for LLM-assisted quantum programming, QiskitHumanEvalSimX.
Comments: Accepted at NeurIPS 2026 as a spotlight paper
Subjects: Software Engineering (cs.SE); Artificial Intelligence (cs.AI); Machine Learning (cs.LG)
Cite as: arXiv:2602.06098 [cs.SE]
  (or arXiv:2602.06098v4 [cs.SE] for this version)
  https://doi.org/10.48550/arXiv.2602.06098

arXiv-issued DOI via DataCite

Submission history

From: Nicolas Menet [view email]
[v1] Thu, 5 Feb 2026 13:49:42 UTC (635 KB)
[v2] Sun, 29 Mar 2026 15:10:52 UTC (637 KB)
[v3] Thu, 7 May 2026 12:50:23 UTC (703 KB)
[v4] Fri, 16 Oct 2026 09:26:12 UTC (736 KB)

来源:arXiv cs.AI · arxiv.org