Predicting Program Exit Code with LLMs and Programming Language Semantics
作者: Lara Marinov, Aditya Thimmaiah, Jayanth Srinivasa, Junyi Jessy Li, Milos Gligoric
分类: cs.PL, cs.AI, cs.CL, cs.SE
发布日期: 2026-09-01
备注: Accepted at LMPL 2026
🔗 代码/项目: GITHUB
💡 一句话要点
提出程序可执行性预测方法以解决LLM理解语义不足问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 程序可执行性 大型语言模型 编程语言语义 软件工程 模型评估
📋 核心要点
- 现有LLMs在理解编程语言语义方面存在不足,导致其在程序可执行性判断上表现不佳。
- 本文提出程序可执行性预测(PrEx)任务,通过系统生成无效程序来评估LLMs对语义规则的应用能力。
- 实验结果显示,LLMs更倾向于依赖预训练知识,尤其在复杂程序和修改语义的情况下表现显著下降。
📝 摘要(中文)
大型语言模型(LLMs)在软件工程任务中表现出色,但在理解编程语言语义方面存在局限。本文提出了一项新任务——程序可执行性预测(PrEx),旨在判断程序的语义有效性,并识别无效程序违反的具体规则。通过构建包含有效和无效程序的数据集,评估开源编码LLMs在不同语义形式下的表现,结果表明LLMs更依赖于预训练的先验知识,而非系统性地应用给定的语义规则,尤其在程序复杂性增加时表现更差。PrEx数据集已公开发布。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在程序可执行性预测中的表现不足,尤其是它们对编程语言语义的理解和应用能力。现有方法未能有效评估LLMs在给定语义规则下的表现,导致其在复杂程序中的判断失误。
核心思路:通过引入程序可执行性预测(PrEx)任务,研究LLMs在判断程序语义有效性时是否依赖于预训练知识或给定的语义规则。该方法通过构建包含有效和无效程序的数据集,系统性地评估模型的表现。
技术框架:整体流程包括数据集构建、模型评估和结果分析。数据集由有效程序及其系统生成的无效变体组成,模型在不同语义形式和程序复杂度下进行评估。
关键创新:本文的创新在于提出了PrEx任务,并通过系统生成的无效程序来测试LLMs对语义规则的应用能力,揭示了它们在复杂场景下的局限性。
关键设计:在实验中,使用了两种语义形式和两种语义转变,评估了人类编写、LLM翻译和模糊生成的程序分割,关注模型在不同条件下的表现差异。实验设计强调了程序复杂性对LLMs性能的影响。
🖼️ 关键图片
📊 实验亮点
实验结果表明,LLMs在处理修改语义和复杂程序时表现显著下降,尤其是在系统生成的无效程序上,准确率降低至30%以下。这一发现强调了LLMs在应用给定语义规则时的不足,尤其是在复杂场景中。
🎯 应用场景
该研究的潜在应用领域包括自动代码审查、智能编程助手和软件验证工具。通过提高LLMs对程序语义的理解能力,可以显著提升软件开发的效率和质量,减少潜在的错误和漏洞。未来,PrEx任务及其数据集可为进一步研究提供基础,推动LLMs在编程语言理解方面的进步。
📄 摘要(原文)
Large language models (LLMs) have shown proficiency in various software engineering tasks, such as code generation and translation. However, a key limitation in their performance may be their (lack of) understanding of programming-language semantics. Even when explicit semantics are given, it remains unclear whether LLMs apply those rules or lean on priors learned during pre-training instead. We study if LLMs lean on priors or given semantics with a novel task--Program Executability Prediction (PrEx)--that asks models to predict whether a program is semantically valid or invalid (and, if invalid, which formal rule it violates) given the program's syntax and operational semantics. Because PrEx requires both valid and invalid programs, we build a dataset with systematically generated invalid transformations derived from valid programs. We evaluate open-source coding LLMs under two semantic formalisms and two semantic shifts across Human-Written, LLM-Translated, and Fuzzer-Generated program splits. Our findings show that LLMs lean on pre-training priors rather than systematically applying the given rules, performing especially poorly on modified semantics and degrading further as program complexity increases. PrEx is available at https://github.com/EngineeringSoftware/prex.