Code Simulation Challenges for Large Language Models
Not on the map. Why?
Abstract (arXiv)
Many reasoning, planning, and problem-solving tasks share an intrinsic algorithmic nature: correctly simulating each step is a sufficient condition to solve them correctly. This work studies to what extent Large Language Models (LLMs) can simulate coding and algorithmic tasks to provide insights into general capabilities in such algorithmic reasoning tasks. We introduce benchmarks for straight-line programs, code that contains critical paths, and approximate and redundant instructions. We further assess the simulation capabilities of LLMs with sorting algorithms and nested loops and show that a routine's computational complexity directly affects an LLM's ability to simulate its execution. While the most powerful LLMs exhibit relatively strong simulation capabilities, the process is fragile, seems to rely heavily on pattern recognition, and is affected by memorisation. We propose a novel off-the-shelf prompting method, Chain of Simulation (CoSm), which instructs LLMs to simulate code execution line by line/follow the computation pattern of compilers. CoSm efficiently helps LLMs reduce memorisation and shallow pattern recognition while improving simulation performance. We consider the success of CoSm in code simulation to be inspirational for other general routine simulation reasoning tasks.
Key facts. Cited by 15 papers in the map (data through 7 Oct 2026). Builds on 46 of its 78 references that are in the map. First posted on arXiv 17 Jan 2024.
Builds on
46 of 78 references.
References · 46
- 2017Attention Is All You Needcited by 59,932
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2023GPT-4 Technical Reportcited by 18,132
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,601
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
- 2020The Pile: An 800GB Dataset of Diverse Text for Language Modelingcited by 2,346
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022BLOOM: A 176B-Parameter Open-Access Multilingual Language Modelcited by 1,968
34 more
- 2022Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?cited by 1,413
- 2022Code as Policies: Language Model Programs for Embodied Controlcited by 1,172
- 2023Language Models Don't Always Say What They Think: Unfaithful Explanations in Chain-of-Thought Promptingcited by 1,081
- 2021Show Your Work: Scratchpads for Intermediate Computation with Language Modelscited by 871
- 2023Reasoning with Language Model is Planning with World Modelcited by 846
- 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 496
- 2023The Reversal Curse: LLMs trained on "A is B" fail to learn "B is A"cited by 399
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 389
- 2023Detecting Pretraining Data from Large Language Modelscited by 375
- 2023Who's Harry Potter? Approximate Unlearning in LLMscited by 366
- 2019Learning Deep Transformer Models for Machine Translationcited by 309
- 2023Mathematical Capabilities of ChatGPTcited by 263
- 2022Emergent Analogical Reasoning in Large Language Modelscited by 239
- 2023Looped Transformers as Programmable Computerscited by 224
- 2018Machine Theory of Mindcited by 222
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
- 2021Thinking Like Transformerscited by 182
- 2023Embers of Autoregression: Understanding Large Language Models Through the Problem They are Trained to Solvecited by 175
- 2022Talking About Large Language Modelscited by 174
- 2023Emergent and Predictable Memorization in Large Language Modelscited by 147
- 2022Large Language Models Meet NL2Code: A Surveycited by 135
- 2023How well do Large Language Models perform in Arithmetic tasks?cited by 130
- 2021How much do language models copy from their training data? Evaluating linguistic novelty in text generation using RAVENcited by 124
- 2021Position Information in Transformers: An Overviewcited by 103
- 2021Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformerscited by 101
- 2023The Generative AI Paradox: "What It Can Create, It May Not Understand"cited by 97
- 2023One Small Step for Generative AI, One Giant Leap for AGI: A Complete Survey on ChatGPT in AIGC Eracited by 55
- 2023Memory Augmented Large Language Models are Computationally Universalcited by 45
- 2023When Do Prompting and Prefix-Tuning Work? A Theory of Capabilities and Limitationscited by 41
- 2023Code Execution with Pre-trained Language Modelscited by 33
- 2023Can Transformers Learn to Solve Problems Recursively?cited by 17
- 2023GPT is becoming a Turing machine: Here are some ways to program itcited by 16
- 2023Predicting Code Coverage without Executioncited by 9
- 2023Addressing Compiler Errors: Stack Overflow or Large Language Models?cited by 5
Built on by
Citing papers per year: 2024: 3; 2025: 10; 2026: 2.
15 papers.
Sort:
By area:
- 2025The Landscape of Agentic Reinforcement Learning for LLMs: A Surveycited by 195
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?cited by 44
- 2024Graph-enhanced Large Language Models in Asynchronous Plan Reasoningcited by 37
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checkingcited by 23
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Modelscited by 6
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Modelscited by 6
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Executioncited by 5
- 2025Can LLMs Reason Structurally? Benchmarking via the Lens of Data Structurescited by 5
- 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulationcited by 5
- 2024Can Language Models Pretend Solvers? Logic Code Simulation with LLMscited by 4
- 2025Computational Reasoning of Large Language Modelscited by 1
- 2026Evaluating Exact Output and Checkpoint-State Prediction in Real Programs8 Oct 2026
- 2026Can Large Language Models Generalize Procedures Across Representations?3 Feb 2026
- 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation28 Nov 2025
- 2025The Landscape of Agentic Reinforcement Learning for LLMs: A Survey2 Sep 2025
- 2025LogicIF: Towards Complex Logic Instruction Following12 Aug 2025
- 2025Can LLMs Reason Structurally? Benchmarking via the Lens of Data Structures29 May 2025
- 2025Computational Reasoning of Large Language Models29 Apr 2025
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis29 Mar 2025
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Execution28 Mar 2025
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checking18 Feb 2025
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Models5 Feb 2025
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Models30 Jan 2025
3 more
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?cited by 44
- 2024Graph-enhanced Large Language Models in Asynchronous Plan Reasoningcited by 37
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checkingcited by 23
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesiscited by 15
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Modelscited by 6
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Executioncited by 5
- 2025Can LLMs Reason Structurally? Benchmarking via the Lens of Data Structurescited by 5
- 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulationcited by 5
- 2025Computational Reasoning of Large Language Modelscited by 1
- 2025Demystifying Errors in LLM Reasoning Traces: An Empirical Study of Code Execution Simulation28 Nov 2025
- 2025Can LLMs Reason Structurally? Benchmarking via the Lens of Data Structures29 May 2025
- 2025Computational Reasoning of Large Language Models29 Apr 2025
- 2025CodeARC: Benchmarking Reasoning Capabilities of LLM Agents for Inductive Program Synthesis29 Mar 2025
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Execution28 Mar 2025
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checking18 Feb 2025
- 2025A Tool for In-depth Analysis of Code Execution Reasoning of Large Language Models30 Jan 2025
- 2024Reasoning Runtime Behavior of a Program with LLM: How Far Are We?25 Mar 2024
- 2024Graph-enhanced Large Language Models in Asynchronous Plan Reasoning5 Feb 2024
- 2025The Landscape of Agentic Reinforcement Learning for LLMs: A Surveycited by 195
- 2025LogicIF: Towards Complex Logic Instruction Followingcited by 1
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Modelscited by 6
- 2024Can Language Models Pretend Solvers? Logic Code Simulation with LLMscited by 4
- 2026Can Large Language Models Generalize Procedures Across Representations?cited by 1
- 2026Evaluating Exact Output and Checkpoint-State Prediction in Real Programscited by 0
- 2026Evaluating Exact Output and Checkpoint-State Prediction in Real Programs8 Oct 2026
- 2026Can Large Language Models Generalize Procedures Across Representations?3 Feb 2026
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Models5 Feb 2025
- 2024Can Language Models Pretend Solvers? Logic Code Simulation with LLMs24 Mar 2024