Language Models as Compilers: Simulating Pseudocode Execution Improves Algorithmic Reasoning in Language Models
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
Algorithmic reasoning refers to the ability to understand the complex patterns behind the problem and decompose them into a sequence of reasoning steps towards the solution. Such nature of algorithmic reasoning makes it a challenge for large language models (LLMs), even though they have demonstrated promising performance in other reasoning tasks. Within this context, some recent studies use programming languages (e.g., Python) to express the necessary logic for solving a given instance/question (e.g., Program-of-Thought) as inspired by their strict and precise syntaxes. However, it is non-trivial to write an executable code that expresses the correct logic on the fly within a single inference call. Also, the code generated specifically for an instance cannot be reused for others, even if they are from the same task and might require identical logic to solve. This paper presents Think-and-Execute, a novel framework that decomposes the reasoning process of language models into two steps. (1) In Think, we discover a task-level logic that is shared across all instances for solving a given task and then express the logic with pseudocode; (2) In Execute, we further tailor the generated pseudocode to each instance and simulate the execution of the code. With extensive experiments on seven algorithmic reasoning tasks, we demonstrate the effectiveness of Think-and-Execute. Our approach better improves LMs' reasoning compared to several strong baselines performing instance-specific reasoning (e.g., CoT and PoT), suggesting the helpfulness of discovering task-level logic. Also, we show that compared to natural language, pseudocode can better guide the reasoning of LMs, even though they are trained to follow natural language instructions.
Key facts. Cited by 20 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 20 of its 23 references that are in the map. First posted on arXiv 3 Apr 2024.
Builds on
20 of 23 references.
Closest ancestors · 1
Same direction, newest first
Other references · 19
- 2023GPT-4 Technical Reportcited by 18,132
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Training Verifiers to Solve Math Word Problemscited by 9,743
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,601
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
- 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,018
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,767
- 2022Least-to-Most Prompting Enables Complex Reasoning in Large Language Modelscited by 1,397
- 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,057
- 2022PAL: Program-aided Language Modelscited by 635
- 2023Plan-and-Solve Prompting: Improving Zero-Shot Chain-of-Thought Reasoning by Large Language Modelscited by 550
7 more
- 2023Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoningcited by 379
- 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
- 2022Text and Patterns: For Effective Chain of Thought, It Takes Two to Tangocited by 128
- 2022Teaching Algorithmic Reasoning via In-context Learningcited by 111
- 2024Self-Discover: Large Language Models Self-Compose Reasoning Structurescited by 108
- 2020Language Generation with Multi-Hop Reasoning on Commonsense Knowledge Graphcited by 57
- 2023Chain of Thought Prompting Elicits Knowledge Augmentationcited by 21
Built on by
Citing papers per year: 2024: 9; 2025: 8; 2026: 3.
20 papers.
Sort:
By area:
- 2024To CoT or not to CoT? Chain-of-thought helps mainly on math and symbolic reasoningcited by 257
- 2025When Thinking Fails: The Pitfalls of Reasoning for Instruction-Following in LLMscited by 51
- 2025Linguistic Generalizability of Test-Time Scaling in Mathematical Reasoningcited by 33
- 2024Automatically Generating UI Code from Screenshot: A Divide-and-Conquer-Based Approachcited by 24
- 2024MRWeb: An Exploration of Generating Multi-Page Resource-Aware Web Code from UI Designscited by 23
- 2025Incentivizing Reasoning for Advanced Instruction-Following of Large Language Modelscited by 17
- 2024Meta-Designing Quantum Experiments with Language Modelscited by 12
- 2025Unlocking the Power of Multi-Agent LLM for Reasoning: From Lazy Agents to Deliberationcited by 11
- 2024Learning to Reason via Program Generation, Emulation, and Searchcited by 9
- 2025CodeAgents: A Token-Efficient Framework for Codified Multi-Agent Reasoning in LLMscited by 9
- 2024FLARE: Faithful Logic-Aided Reasoning and Explorationcited by 7
- 2024Semantic Graphs for Syntactic Simplification: A Revisit from the Age of LLMcited by 4
8 more
- 2025Token Signature: Predicting Chain-of-Thought Gains with Token Decoding Feature in Large Language Modelscited by 4
- 2024Watch Your Steps: Observable and Modular Chains of Thoughtcited by 3
- 2025Abductive Logical Rule Induction by Bridging Inductive Logic Programming and Multimodal Large Language Modelscited by 3
- 2025Semi-structured LLM Reasoners Can Be Rigorously Auditedcited by 2
- 2026Exploration of Fast-Slow Latent Recurrence for Train-Short, Test-Long Generalizationcited by 2
- 2024Large Language Models Are Self-Taught Reasoners: Enhancing LLM Applications via Tailored Problem-Solving Demonstrationscited by 1
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expandingcited by 1
- 2026The Periodic Table of LLM Reasoning: A Structured Survey of Reasoning Paradigms, Methods, and Failure Modescited by 0
- 2026The Periodic Table of LLM Reasoning: A Structured Survey of Reasoning Paradigms, Methods, and Failure Modes9 Jun 2026
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expanding10 May 2026
- 2026Exploration of Fast-Slow Latent Recurrence for Train-Short, Test-Long Generalization2 Apr 2026
- 2025Unlocking the Power of Multi-Agent LLM for Reasoning: From Lazy Agents to Deliberation4 Nov 2025
- 2025Abductive Logical Rule Induction by Bridging Inductive Logic Programming and Multimodal Large Language Models26 Sep 2025
- 2025CodeAgents: A Token-Efficient Framework for Codified Multi-Agent Reasoning in LLMs4 Jul 2025
- 2025Token Signature: Predicting Chain-of-Thought Gains with Token Decoding Feature in Large Language Models6 Jun 2025
- 2025Incentivizing Reasoning for Advanced Instruction-Following of Large Language Models2 Jun 2025
- 2025Semi-structured LLM Reasoners Can Be Rigorously Audited30 May 2025
- 2025When Thinking Fails: The Pitfalls of Reasoning for Instruction-Following in LLMs16 May 2025
- 2025Linguistic Generalizability of Test-Time Scaling in Mathematical Reasoning24 Feb 2025
- 2024MRWeb: An Exploration of Generating Multi-Page Resource-Aware Web Code from UI Designs19 Dec 2024
8 more
- 2024FLARE: Faithful Logic-Aided Reasoning and Exploration14 Oct 2024
- 2024To CoT or not to CoT? Chain-of-thought helps mainly on math and symbolic reasoning18 Sep 2024
- 2024Watch Your Steps: Observable and Modular Chains of Thought17 Sep 2024
- 2024Large Language Models Are Self-Taught Reasoners: Enhancing LLM Applications via Tailored Problem-Solving Demonstrations22 Aug 2024
- 2024Semantic Graphs for Syntactic Simplification: A Revisit from the Age of LLM4 Jul 2024
- 2024Automatically Generating UI Code from Screenshot: A Divide-and-Conquer-Based Approach24 Jun 2024
- 2024Meta-Designing Quantum Experiments with Language Models4 Jun 2024
- 2024Learning to Reason via Program Generation, Emulation, and Search25 May 2024
- 2024To CoT or not to CoT? Chain-of-thought helps mainly on math and symbolic reasoningcited by 257
- 2025When Thinking Fails: The Pitfalls of Reasoning for Instruction-Following in LLMscited by 51
- 2025Linguistic Generalizability of Test-Time Scaling in Mathematical Reasoningcited by 33
- 2025Incentivizing Reasoning for Advanced Instruction-Following of Large Language Modelscited by 17
- 2025Unlocking the Power of Multi-Agent LLM for Reasoning: From Lazy Agents to Deliberationcited by 11
- 2024Learning to Reason via Program Generation, Emulation, and Searchcited by 9
- 2025CodeAgents: A Token-Efficient Framework for Codified Multi-Agent Reasoning in LLMscited by 9
- 2024FLARE: Faithful Logic-Aided Reasoning and Explorationcited by 7
- 2025Token Signature: Predicting Chain-of-Thought Gains with Token Decoding Feature in Large Language Modelscited by 4
- 2024Watch Your Steps: Observable and Modular Chains of Thoughtcited by 3
- 2025Semi-structured LLM Reasoners Can Be Rigorously Auditedcited by 2
- 2024Large Language Models Are Self-Taught Reasoners: Enhancing LLM Applications via Tailored Problem-Solving Demonstrationscited by 1
12 most cited of 13 All 13 (JSON)
- 2026The Periodic Table of LLM Reasoning: A Structured Survey of Reasoning Paradigms, Methods, and Failure Modes9 Jun 2026
- 2025Unlocking the Power of Multi-Agent LLM for Reasoning: From Lazy Agents to Deliberation4 Nov 2025
- 2025CodeAgents: A Token-Efficient Framework for Codified Multi-Agent Reasoning in LLMs4 Jul 2025
- 2025Token Signature: Predicting Chain-of-Thought Gains with Token Decoding Feature in Large Language Models6 Jun 2025
- 2025Incentivizing Reasoning for Advanced Instruction-Following of Large Language Models2 Jun 2025
- 2025Semi-structured LLM Reasoners Can Be Rigorously Audited30 May 2025
- 2025When Thinking Fails: The Pitfalls of Reasoning for Instruction-Following in LLMs16 May 2025
- 2025Linguistic Generalizability of Test-Time Scaling in Mathematical Reasoning24 Feb 2025
- 2024FLARE: Faithful Logic-Aided Reasoning and Exploration14 Oct 2024
- 2024To CoT or not to CoT? Chain-of-thought helps mainly on math and symbolic reasoning18 Sep 2024
- 2024Watch Your Steps: Observable and Modular Chains of Thought17 Sep 2024
- 2024Large Language Models Are Self-Taught Reasoners: Enhancing LLM Applications via Tailored Problem-Solving Demonstrations22 Aug 2024
12 newest of 13 All 13 (JSON)
- 2024Automatically Generating UI Code from Screenshot: A Divide-and-Conquer-Based Approachcited by 24
- 2024MRWeb: An Exploration of Generating Multi-Page Resource-Aware Web Code from UI Designscited by 23
- 2024Meta-Designing Quantum Experiments with Language Modelscited by 12
- 2024Semantic Graphs for Syntactic Simplification: A Revisit from the Age of LLMcited by 4
- 2026Exploration of Fast-Slow Latent Recurrence for Train-Short, Test-Long Generalizationcited by 2
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expandingcited by 1
- 2026Shaping Schema via Language Representation as the Next Frontier for LLM Intelligence Expanding10 May 2026
- 2026Exploration of Fast-Slow Latent Recurrence for Train-Short, Test-Long Generalization2 Apr 2026
- 2024MRWeb: An Exploration of Generating Multi-Page Resource-Aware Web Code from UI Designs19 Dec 2024
- 2024Semantic Graphs for Syntactic Simplification: A Revisit from the Age of LLM4 Jul 2024
- 2024Automatically Generating UI Code from Screenshot: A Divide-and-Conquer-Based Approach24 Jun 2024
- 2024Meta-Designing Quantum Experiments with Language Models4 Jun 2024
Similar, not cited
Close in wording, no citation either way
- 2026Is Code Better Than Language for Algorithmic Reasoning
- 2026Pseudo2CodeQA: A Benchmark for LLM-Based Structured Algorithmic Reasoning in Code Generation
- 2025Code Simulation as a Proxy for High-order Tasks in Large Language Models
- 2024Distilling Algorithmic Reasoning from LLMs via Explaining Solution Programs
- 2025Can Language Models Falsify? Evaluating Algorithmic Reasoning with Counterexample Creation
- 2025An Empirical Study of Reasoning Steps in Thinking Code LLMs
- 2025Chain of Execution Supervision Promotes General Reasoning in Large Language Models
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Execution