NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Predicting Program Exit Code with LLMs and Programming Language Semantics

Lara Marinov, Aditya Thimmaiah, Jayanth Srinivasa, Junyi Jessy Li, Milos GligoricarXiv 2026 · DOI

TL;DR

Do Large Language Models (LLMs) truly understand the logic of the code they read, or are they just incredibly sophisticated pattern matchers? This paper introduces PrEx (Program Executability Prediction), a benchmark designed to test whether LLMs can determine if a program is semantically valid when explicitly provided with the language's formal rules. The findings reveal a striking vulnerability: LLMs consistently ignore provided rules and fall back on pre-training shortcuts, especially when familiar symbols are given completely new meanings.

What Problem Does This Paper Address?

While LLMs excel at generating and translating code, researchers still debate whether these models possess genuine semantic reasoning or if they are merely relying on rote memorization. Introduce a subtle change to a standard algorithm—like changing a loop bound or redefining an operator—and LLMs frequently fail, defaulting to the standard output they memorized during pre-training.

Previous attempts to evaluate this, such as PLSemanticsBench, required LLMs to generate long, step-by-step execution traces. However, this made it difficult to isolate why the models failed: was it due to the multi-step complexity of generating long text, or a fundamental inability to reason about semantics?

This paper addresses this gap by isolating semantic judgment from trace generation. It introduces a simpler, discrete task: given a program and the formal rules of the language, can the LLM simply predict whether the program will execute successfully or crash with an error?

Methods

The authors introduce the Program Executability Prediction (PrEx) task. The model is supplied with three things:

  1. The EBNF grammar of a small imperative language ($C^*$).
  2. The formal operational semantics (the rules of execution).
  3. The target program.

The model must output a simple verdict: ##success## if the program runs without issues, or ##error## along with the specific formal rule that was violated.

Overview of the PrEx prompt structure.

To rigorously test whether models are actually following the provided rules or just guessing based on memory, the authors evaluate them under two distinct formalisms—Small-step operational semantics ($\mathbb{S}$) and the K-framework ($\mathbb{K}$)—and introduce two clever semantic shifts:

  • KeywordSwap: The meanings of standard operators are interchanged (e.g., + now means subtraction, and - means addition).
  • KeywordObf: Standard operators and keywords are replaced with entirely novel, single-token symbols (e.g., ★ represents addition).

Datasets

The authors built their dataset by taking valid $C^*$ programs from PLSemanticsBench and systematically generating invalid counterparts. They introduced five specific semantic errors: breaking outside a loop, continuing outside a loop, division by zero, modulo by zero, and using a variable before declaring it.

The final dataset consists of 2,946 programs split into three categories of increasing structural complexity:

  • Human-Written: Short, clean code snippets adapted from benchmarks like LeetCode and HumanEval.
  • LLM-Translated: Medium-length programs translated from C++ to $C^*$.
  • Fuzzer-Generated: Long, highly complex programs generated by a grammar-based fuzzer to minimize predictable coding patterns.
Figure 1. Valid and invalid PrEx task examples.

Key Insights and Ideas

  • Priors Trump Rules: LLMs suffer from a strong pre-training bias. When faced with KeywordSwap, they struggle immensely because they cannot override their deeply ingrained association that + means addition, even when explicitly told otherwise in the prompt.
  • The "Looks Good to Me" Bias: As programs grow longer and more complex (the Fuzzer-Generated split), the dominant failure mode becomes "false success." The models look at a complex block of code, see that it looks like valid syntax, and assume it will run fine, completely missing blatant semantic errors like a division by zero hidden inside.
  • Granularity is Not the Issue: The models struggled regardless of whether the rules were presented as hyper-detailed atomic steps ($\mathbb{S}$) or broader configuration rewrites ($\mathbb{K}$), proving that the bottleneck is the model's reasoning style, not how the rules are formatted.

Key Results

  • High Baseline, Fragile Core: On standard, unmodified human-written code, top models like DeepSeek-Qwen 32B and Qwen2.5-Coder 32B-CoT achieve near-perfect accuracy (~99%).
  • The Obfuscation Collapse: When the exact same human-written programs are subjected to the KeywordObf shift, the median accuracy across all evaluated models drops sharply by 32 percentage points.
  • Complexity Scaling Failure: On the complex Fuzzer-Generated split, performance plummets across the board. For example, Qwen2.5-Coder 14B-CoT drops from an accuracy of 78% on human code down to just 23% under the obfuscated $\mathbb{K}$-framework semantics.

Limitations and Future Work

The primary limitation is that the benchmark evaluates $C^*$, which is a stripped-down, toy imperative language. It also only tests for five specific types of semantic errors.

The authors suggest that future work should scale PrEx to full-scale production languages (like Python or full C++) and explore new training paradigms or fine-tuning datasets that explicitly reward LLMs for strict rule-following rather than surface-level pattern matching.

Summary updated

BibTeX
@misc{marinov2026predicting,
  author = {Lara Marinov and Aditya Thimmaiah and Jayanth Srinivasa and Junyi Jessy Li and Milos Gligoric},
  title = {{Predicting Program Exit Code with LLMs and Programming Language Semantics}},
  year = {2026},
  eprint = {2609.00579},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.00579},
}
Figure