Are Large Language Models Robust in Understanding Code Against Semantics-Preserving Mutations?
Not on the map. Why?
Abstract (arXiv)
With the widespread adoption of vibe coding, understanding the reasoning and robustness of Large Language Models (LLMs) is critical for their reliable use in programming tasks. While recent studies assess LLMs' ability to predict program outputs, most focus on accuracy alone, without evaluating the underlying reasoning. Moreover, it has been observed on mathematical reasoning tasks that LLMs can arrive at correct answers through flawed logic, raising concerns about similar issues in code understanding. In this paper we assess whether state-of-the-art LLMs can reason about Python programs or are simply guessing. We apply five semantics-preserving code mutations: renaming variables, mirroring comparison expressions, swapping if-else branches, converting for loops to while, and loop unrolling. These mutations maintain program semantics while altering its syntax. We evaluated nine LLMs, including both open-source and closed-access models, and performed a human expert analysis using LiveCodeBench to assess whether correct predictions are based on sound reasoning. We also evaluated prediction stability across different code mutations on LiveCodeBench and CruxEval. While proprietary models achieve the strongest predictive accuracy and reasoning quality in the expert evaluation, our robustness analysis reveals substantial fragility under semantics-preserving transformations. Our findings show that LLMs trained for code produce correct predictions based on flawed reasoning in between 10% and 50% of cases. Furthermore, LLMs often change predictions in response to our code mutations, with performance drops reaching up to 70%, indicating that they do not yet exhibit stable, semantically grounded reasoning, even when initial accuracy is high.
Key facts. Cited by 7 papers in the map (data through 14 Oct 2026). Builds on 16 of its 30 references that are in the map. First posted on arXiv 15 May 2025.
Builds on
16 of 30 references.
References · 16
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 331
- 2024CRUXEval: A Benchmark for Code Reasoning, Understanding and Executioncited by 300
- 2024CodeGemma: Open Code Models Based on Gemmacited by 150
- 2024Granite Code Models: A Family of Open Foundation Models for Code Intelligencecited by 117
- 2022ReCode: Robustness Evaluation of Code Generation Modelscited by 103
- 2023A Large-Scale Survey on the Usability of AI Programming Assistants: Successes and Challengescited by 75
- 2025Proof or Bluff? Evaluating LLMs on 2025 USA Math Olympiadcited by 74
- 2021Self-Supervised Bug Detection and Repaircited by 59
- 2020Semantic Robustness of Models of Source Codecited by 45
- 2024Logically Consistent Language Models via Neuro-Symbolic Integrationcited by 30
4 more
- 2023The Larger They Are, the Harder They Fail: Language Models do not Recognize Identifier Swaps in Pythoncited by 29
- 2024The Counterfeit Conundrum: Can Code Language Models Grasp the Nuances of Their Incorrect Generations?cited by 20
- 2023Poisoned ChatGPT Finds Work for Idle Hands: Exploring Developers' Coding Practices with Insecure Suggestions from Poisoned AI Modelscited by 17
- 2024Counterexample Guided Program Repair Using Zero-Shot Learning and MaxSAT-based Fault Localizationcited by 8
Built on by
Citing papers per year: 2025: 2; 2026: 5.
7 papers.
- 2025LLMs Lean on Priors, Not Programming Language Semanticscited by 6
- 2026RepoMirage: Probing Repository Context Reasoning in Code Agents with Perturbationscited by 3
- 2026Names Don't Matter: Symbol-Invariant Transformer for Open-Vocabulary Learningcited by 1
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectorscited by 1
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?cited by 0
- 2026Evolutionary Task Discovery: Advancing Reasoning Frontiers via Skill Composition and Complexity Scalingcited by 0
- 2026From Brewing to Resolution: Tracing the Internal Lifecycle of Code Reasoning in LLMscited by 0
- 2026From Brewing to Resolution: Tracing the Internal Lifecycle of Code Reasoning in LLMs16 Jun 2026
- 2026RepoMirage: Probing Repository Context Reasoning in Code Agents with Perturbations25 May 2026
- 2026Evolutionary Task Discovery: Advancing Reasoning Frontiers via Skill Composition and Complexity Scaling12 May 2026
- 2026Syntax- and Compilation-Preserving Evasion of LLM Vulnerability Detectors30 Jan 2026
- 2026Names Don't Matter: Symbol-Invariant Transformer for Open-Vocabulary Learning30 Jan 2026
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?17 Dec 2025
- 2025LLMs Lean on Priors, Not Programming Language Semantics3 Oct 2025
Similar, not cited
Close in wording, no citation either way
- 2025On Code-Induced Reasoning in LLMs
- 2026How Robustly do LLMs Understand Execution Semantics?
- 2026CodeEval: A pedagogical approach for targeted evaluation of code-trained Large Language Models
- 2025code_transformed: The Influence of Large Language Models on Code
- 2026Evaluating LLMs Code Reasoning Under Real-World Context
- 2024Assessing, Exploiting, and Mitigating Syntactic Robustness Failures in LLM-Based Code Generation
- 2025CodeCrash: Exposing LLM Fragility to Misleading Natural Language in Code Reasoning
- 2025Evaluating Code Reasoning Abilities of Large Language Models Under Real-World Settings