Assessing Coherency and Consistency of Code Execution Reasoning by Large Language Models
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
This paper proposes CES, a task to evaluate the abilities of LLMs in simulating program execution and using that reasoning in programming tasks. Besides measuring the correctness of variable predictions during execution simulation, CES introduces the notion of coherence to determine whether the simulation complies with commonsense execution logic, even if the predicted values along the simulations are incorrect. This enables CES to rule out suspiciously correct output predictions due to reasoning shortcuts, hallucinations, or potential data leakage. CES also introduces a novel metric to measure reasoning consistency across tests with the same or different prime path coverage in a spectrum: strong, weak, and random. Evaluating 16 LLMs (including three reasoning LLMs) using CES indicates 81.42% coherent execution simulation on HumanEval, 46.92% and 53.08% of which result in correct and incorrect output predictions. Frontier LLMs such as GPT-4 and DeepSeek-R1 have the most incoherent execution reasoning, mostly due to natural language shortcuts. Despite relatively coherent execution simulation, LLMs' reasoning performance across different tests is inconsistent, mostly random (48.87%) or weak (45.37%), potentially explaining their weakness in programming tasks that require path-sensitive program analysis to succeed. We also compare CES with bug prediction/localization/repair, which intuitively requires control- and data-flow awareness. We observe that LLMs barely incorporate execution reasoning into their analysis for bug-related tasks, and their success is primarily due to inherent abilities in pattern matching or natural language shortcuts, if not data leakage. Without reasoning, there is a threat to the generalizability of LLMs in dealing with unseen bugs or patterns in different contexts. CES can be used to vet the suspicious success of LLMs in these tasks systematically.
Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 23 of its 50 references that are in the map. First posted on arXiv 16 Oct 2025.
Builds on
23 of 50 references.
Closest ancestors · 5
Same direction, newest first
- 2025CoRe: Benchmarking LLMs Code Reasoning Capabilities through Static Analysis Tasks3 Jul
- 2025CodeSense: a Real-World Benchmark and Dataset for Code Semantic Reasoning31 May
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Models30 Jan
- 2024CodeMind: Evaluating Large Language Models for Code Reasoning15 Feb
- 2023Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChain21 Oct
Other references · 18
- 2023GPT-4 Technical Reportcited by 18,132
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2025DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learningcited by 6,146
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,579
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2023Gemini: A Family of Highly Capable Multimodal Modelscited by 810
- 2023Siren's Song in the AI Ocean: A Survey on Hallucination in Large Language Modelscited by 695
- 2024DeepSeek LLM: Scaling Open-Source Language Models with Longtermismcited by 621
- 2023WizardMath: Empowering Mathematical Reasoning for Large Language Models via Reinforced Evol-Instructcited by 618
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 484
- 2023Magicoder: Empowering Code Generation with OSS-Instructcited by 251
- 2023MathPrompter: Mathematical Reasoning using Large Language Modelscited by 236
6 more
- 2022Active Example Selection for In-Context Learningcited by 195
- 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
- 2023MathCoder: Seamless Code Integration in LLMs for Enhanced Mathematical Reasoningcited by 155
- 2024Efficient Prompting Methods for Large Language Models: A Surveycited by 46
- 2024Break the Chain: Large Language Models Can be Shortcut Reasonerscited by 32
- 2023Predicting Code Coverage without Executioncited by 9
Built on by
Citing papers per year: 2025: 1; 2026: 4.
5 papers.
- 2026Can LLMs Compress (and Decompress)? Evaluating Code Understanding and Execution via Invertibilitycited by 4
- 2025Evaluating Code Reasoning Abilities of Large Language Models Under Real-World Settingscited by 3
- 2026Evaluating LLMs Code Reasoning Under Real-World Contextcited by 0
- 2026The Path Not Taken: Duality in Reasoning about Program Executioncited by 0
- 2026Can LLMs Reason About Runtime Behavior? A Repository-Level Dynamic Benchmarkcited by 0
- 2026Can LLMs Reason About Runtime Behavior? A Repository-Level Dynamic Benchmark23 Sep 2026
- 2026The Path Not Taken: Duality in Reasoning about Program Execution22 Apr 2026
- 2026Evaluating LLMs Code Reasoning Under Real-World Context14 Apr 2026
- 2026Can LLMs Compress (and Decompress)? Evaluating Code Understanding and Execution via Invertibility19 Jan 2026
- 2025Evaluating Code Reasoning Abilities of Large Language Models Under Real-World Settings16 Dec 2025
Similar, not cited
Close in wording, no citation either way
- 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?
- 2026How Robustly do LLMs Understand Execution Semantics?
- 2026CoRE: A Fine-Grained Code Reasoning Benchmark Beyond Output Prediction
- 2025On Code-Induced Reasoning in LLMs
- 2026Teaching LLMs Program Semantics via Symbolic Execution Traces
- 2025Can LLMs Reason About Program Semantics? A Comprehensive Evaluation of LLMs on Formal Specification Inference
- 2026EsoLang-Bench: Evaluating Genuine Reasoning in Large Language Models via Esoteric Programming Languages