arXiv:2506.13804cs.SEcs.AI2025-06

用指令和解的概率缩小编程搜索空间,提升效率。

Instruction and Solution Probabilities as Heuristics for Inductive Programming

  • 基于代码频次计算指令出现概率,作为搜索指引
  • 结合已有启发式,搜索空间缩小超100个数量级
  • 适用于未见过的代码,适合自动化编程研究者

指令子集(IS)可将归纳编程(IP)的搜索空间缩小数十个数量级。本文引入指令概率和解概率作为新启发式:指令概率基于大量代码样本中指令出现频率,反映其在解中出现的期望;解概率为构成程序各指令概率的乘积(含重复)。我们以不同规模程序单元中观测到的最小解概率作为阈值,在构建部分解时进行剪枝,剔除不可能的指令组合。实验使用大规模人工代码样本验证,两种指令概率设定(全局与按IS分组)均实现显著压缩,根据解大小可进一步减少数十个数量级。结合原有IS,总压缩超过100个数量级。交叉验证表明该方法对未知代码仍有效。论文讨论了方法细节及未来方向。

原文摘要 · Abstract (English)

Instruction subsets (ISs) are heuristics that can shrink the size of the inductive programming (IP) search space by tens of orders of magnitude. Here, we extend the IS approach by introducing instruction and solution probabilities as additional heuristics. Instruction probability reflects the expectation of an instruction occurring in a solution, based on the frequency of instruction occurrence in a large code sample. The solution probability for a partial or complete program is simply the product of all constituent instruction probabilities, including duplicates. We treat the minimum solution probabilities observed in code sample program units of different sizes as solution probability thresholds. These thresholds are used to prune the search space as partial solutions are constructed, thereby eliminating any branches containing unlikely combinations of instructions. The new approach has been evaluated using a large sample of human code. We tested two formulations of instruction probability: one based on instruction occurrence across the entire code sample and another that measured the distribution separately for each IS. Our results show that both variants produce substantial further reductions in the IP search space size of up to tens of orders of magnitude, depending on solution size. In combination with IS, reductions of over 100 orders of magnitude can be achieved. We also carried out cross-validation testing to show that the heuristics should work effectively with unseen code. The approach is described and the results and some ideas for future work are discussed.

归纳编程搜索优化代码生成

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。