Manuscript Offprint

arXiv:2609.00579

Predicting Program Exit Code with LLMs and Programming Language Semantics

Lara Marinov, Aditya Thimmaiah, Jayanth Srinivasa, Junyi Jessy Li, Milos Gligoric

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Lara Marinov

The University of Texas at Austin

Austin, USA

marinov@utexas.edu

Aditya Thimmaiah

The University of Texas at Austin

Austin, USA

auditt@utexas.edu

Jayanth Srinivasa

Cisco Research

San Francisco, USA

jasriniv@cisco.com

Junyi Jessy Li

The University of Texas at Austin

Austin, USA

jessy@utexas.edu

Milos Gligoric

The University of Texas at Austin

Austin, USA

gligoric@utexas.edu

Abstract

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.

CCS Concepts: • General and reference → Empirical studies; • Theory of computation → Operational semantics; • Computing methodologies → Machine learning.

Keywords: Operational Semantics, K Framework, Program Executability Prediction, Large Language Models

ACM Reference Format:

Lara Marinov, Aditya Thimmaiah, Jayanth Srinivasa, Junyi Jessy Li, and Milos Gligoric. 2026. Predicting Program Exit Code with

LLMs and Programming Language Semantics. In Proceedings of the 2nd ACM SIGPLAN International Workshop on Language Models and Programming Languages (LMPL '26), October 4–9, 2026, Oakland, CA, USA. ACM, New York, NY, USA, 12 pages. https://doi.org/10.1145/3843750.3843842

1 Introduction

LLMs have become widely used in software engineering, demonstrating remarkable proficiency in tasks like code generation [11, 24, 31], code translation [26, 43], bug fixing [15, 22], and summarizing complex codebases [23, 27, 38]. However, despite their practical success, it remains unclear to what extent these models truly comprehend the underlying semantics of the programs they process.

Much of an LLM’s apparent coding ability seems to come from sophisticated pattern matching and the memorization of vast amounts of training data, rather than an inherent ability to logically simulate program execution [29, 44]. For example, consider a scenario where an LLM is presented with a standard sorting algorithm. Because the model has previously encountered this exact structure many times, it can easily summarize its purpose, generate missing lines of code, or predict the final outcome [8, 36]. However, if we introduce a subtle change to the program, such as slightly modifying the loop bounds, obfuscating variable names, or redefining how the comparison operator works, and ask the model to predict the result, it frequently fails [41]. Instead of systematically tracing the data flow step-by-step as an interpreter would, the model often falls back on its priors and simply guesses the standard sorted output [4, 28]. Such a situation clearly reveals a gap between rote memorization and genuine, systematic semantic reasoning.

Recent work introduced PLSEMANTICSBENCH [39] and established a framework for evaluating LLMs' semantic understanding through three tasks: predicting final variable states (PredState), identifying the formal semantic rules applied during execution (PredRule), and generating step-by-step execution traces (PredTrace) [39]. Evaluations revealed

Figure

This work is licensed under a Creative Commons Attribution 4.0 International License.

LMPL '26, Oakland, CA, USA

© 2026 Copyright held by the owner/author(s).

ACM ISBN 979-8-4007-2986-7/2026/10

https://doi.org/10.1145/3843750.3843842

Lara Marinov, Aditya Thimmaiah, Jayanth Srinivasa, Junyi Jessy Li, and Milos Gligoric

that current LLMs struggle significantly across all three of these tasks. Because PLSEMANTICSBENCH presented a set of complex evaluations where models needed to articulate intermediate steps and output long execution traces, the models' uniformly low performance leaves an open question regarding exactly where their capability threshold is. To determine whether these failures are in-part due to the natural multi-step complexity of the tasks presented in PLSEMANTICSBENCH or a fundamental inability to reason about semantics, we establish a more foundational baseline that separates trace generation from semantic judgment. Building on this premise, we present PrEx: a task that asks models, given a program and formal programming language semantics, to predict whether execution succeeds or halts with a semantic error—and, when it fails, which rule was violated. The required output is deliberately small with just a discrete executability verdict rather than a long trace but the evaluation is not: we pair each valid program with invalid counterparts produced by semantics-aware invalid transformations, vary program source and structural complexity across three splits, and probe rule-following under alternate semantic formalisms and shifts. This design lets us ask whether models systematically apply the supplied rules or instead continue to rely on memorized priors.

Dataset. We build on the valid C* programs from PLSEMANTICSBENCH and extend them with semantically invalid transformations required by PrEx. Invalid programs are generated from valid programs using a semantics-aware transformation procedure that applies one of five errors: break-outside-loop, continue-outside-loop, divide-by-zero, modulo-by-zero, and variable-use-before-declare. Each valid program has a matched invalid counterpart in every error category. Programs come from three splits—Human-Written, LLM-Translated, and Fuzzer-Generated—with average length and complexity increasing across splits. Together, these design choices let us test whether semantic reasoning generalizes across program sources and complexity levels, not just memorized coding patterns.

Semantic formalisms. We evaluate models under two semantic formalisms: small-step operational semantics (S) and the K-framework (K). S defines execution through finer granularity inference rules, where each rule represents one atomic computation step [34]. K instead uses coarser rewriting rules that transform program configurations in larger chunks, relying on built-in rewriting to handle intermediate expression reduction [35]. We include both to test whether an LLM's ability to apply provided semantics depends on rule granularity or persists across formalisms.

Semantic shifts. We also evaluate models under two semantic shifts, KeywordSwap and KeywordObf, that alter the meaning of selected symbols while keeping execution defined by the provided formal rules. KeywordSwap interchanges

Figure

(a) Valid program

(b) Invalid program

Figure 1. Valid and invalid PrEx task examples.

the meanings of familiar operator symbols (e.g., + denotes subtraction), requiring models to override pre-trained associations and follow the supplied semantics. KeywordObf replaces standard operators and keywords with novel single-token symbols, removing recognizable cues from pre-training while preserving the same underlying rules. Together, these conditions test whether LLMs can reason from explicitly provided semantics rather than from their prior knowledge.

We evaluate open-source LLMs designed for coding tasks and enhanced reasoning using both non-chain-of-thought and chain-of-thought (CoT) reasoning. Our findings indicate that even on the simpler task (PrEx) of predicting program exit codes, LLMs continue to lean on priors learned during pre-training rather than systematically applying the supplied formal rules. Performance is especially poor under KeywordSwap and KeywordObf, where models must override familiar symbol meanings to follow the provided semantics. Accuracy also degrades significantly on the LLM-Translated and Fuzzer-Generated splits compared to Human-Written, indicating that semantic reasoning does not generalize well as structural complexity increases.

References (33)