Learning to Reason via Program Generation, Emulation, and Search
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
Program synthesis with language models (LMs) has unlocked a large set of reasoning abilities; code-tuned LMs have proven adept at generating programs that solve a wide variety of algorithmic symbolic manipulation tasks (e.g. word concatenation). However, not all reasoning tasks are easily expressible as code, e.g. tasks involving commonsense reasoning, moral decision-making, and sarcasm understanding. Our goal is to extend an LM's program synthesis skills to such tasks and evaluate the results via pseudo-programs, namely Python programs where some leaf function calls are left undefined. To that end, we propose, Code Generation and Emulated EXecution (CoGEX). CoGEX works by (1) training LMs to generate pseudo-programs, (2) teaching them to emulate their generated program's execution, including those leaf functions, allowing the LM's knowledge to fill in the execution gaps; and (3) using them to search over many programs to find an optimal one. To adapt the CoGEX model to a new task, we introduce a method for performing program search to find a single program whose pseudo-execution yields optimal performance when applied to all the instances of a given dataset. We show that our approach yields large improvements compared to standard in-context learning approaches on a battery of tasks, both algorithmic and soft reasoning. This result thus demonstrates that code synthesis can be applied to a much broader class of problems than previously considered. Our released dataset, fine-tuned models, and implementation can be found at urlhttps://github.com/nweir127/CoGEX.
Key facts. Cited by 9 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 37 of its 45 references that are in the map. First posted on arXiv 25 May 2024.
Builds on
37 of 45 references.
Closest ancestors · 2
Same direction, newest first
- 2024Language Models as Compilers: Simulating Pseudocode Execution Improves Algorithmic Reasoning in Language Models3 Apr
- 2023Chain of Code: Reasoning with a Language Model-Augmented Code Emulator7 Dec
Other references · 35
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,084
- 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
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,970
- 2018CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledgecited by 1,793
- 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,767
- 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,057
- 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
- 2018Neural Network Acceptability Judgmentscited by 952
23 more
- 2022STaR: Bootstrapping Reasoning With Reasoningcited by 895
- 2021Are NLP Models really able to Solve Simple Math Word Problems?cited by 861
- 2023Large Language Models as Optimizerscited by 830
- 2023Instruction Tuning with GPT-4cited by 676
- 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
- 2023Automatic Prompt Optimization with "Gradient Descent" and Beam Searchcited by 628
- 2022RLPrompt: Optimizing Discrete Text Prompts with Reinforcement Learningcited by 361
- 2023Hard Prompts Made Easy: Gradient-Based Discrete Optimization for Prompt Tuning and Discoverycited by 329
- 2022Active Example Selection for In-Context Learningcited by 195
- 2022Instruction Induction: From Few Examples to Natural Language Task Descriptionscited by 152
- 2023Compositional Exemplars for In-context Learningcited by 143
- 2022GrIPS: Gradient-free, Edit-based Instruction Search for Prompting Large Language Modelscited by 127
- 2023InstructZero: Efficient Instruction Optimization for Black-Box Large Language Modelscited by 68
- 2023Coverage-based Example Selection for In-Context Learningcited by 58
- 2023Prompt Engineering a Prompt Engineercited by 53
- 2022Few-shot Reranking for Multi-hop QA via Language Model Promptingcited by 19
- 2022NELLIE: A Neuro-Symbolic Inference Engine for Grounded, Compositional, and Explainable Reasoningcited by 16
- 2023Natural Language Embedded Programs for Hybrid Language Symbolic Reasoningcited by 15
- 2023Prompting with Pseudo-Code Instructionscited by 13
- 2020Braid: Weaving Symbolic and Neural Knowledge into Coherent Logical Explanationscited by 11
- 2023Exploring Demonstration Ensembling for In-context Learningcited by 8
- 2022One-Shot Learning from a Demonstration with Hierarchical Latent Languagecited by 6
- 2023Exploring the Curious Case of Code Promptscited by 6
Built on by
Citing papers per year: 2024: 2; 2025: 7.
9 papers.
- 2025A Survey of Frontiers in LLM Reasoning: Inference Scaling, Learning to Reason, and Agentic Systemscited by 108
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2025ARM: Adaptive Reasoning Modelcited by 38
- 2024Steering Large Language Models between Code Execution and Textual Reasoningcited by 24
- 2025R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learningcited by 15
- 2025TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixturecited by 13
- 2025CodeSteer: Symbolic-Augmented Language Models via Code/Text Guidancecited by 11
- 2024Watch Your Steps: Observable and Modular Chains of Thoughtcited by 3
- 2025Semi-structured LLM Reasoners Can Be Rigorously Auditedcited by 2
- 2025TUMIX: Multi-Agent Test-Time Scaling with Tool-Use Mixture30 Sep 2025
- 2025Semi-structured LLM Reasoners Can Be Rigorously Audited30 May 2025
- 2025R1-Code-Interpreter: LLMs Reason with Code via Supervised and Multi-stage Reinforcement Learning27 May 2025
- 2025ARM: Adaptive Reasoning Model26 May 2025
- 2025A Survey of Frontiers in LLM Reasoning: Inference Scaling, Learning to Reason, and Agentic Systems12 Apr 2025
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMs26 Feb 2025
- 2025CodeSteer: Symbolic-Augmented Language Models via Code/Text Guidance4 Feb 2025
- 2024Steering Large Language Models between Code Execution and Textual Reasoning4 Oct 2024
- 2024Watch Your Steps: Observable and Modular Chains of Thought17 Sep 2024
Similar, not cited
Close in wording, no citation either way
- 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Execution
- 2026The Imitation Game: When LLMs Learn to Reason Like Programs via Code-Centric Reasoning Data Synthesis
- 2026EsoLang-Bench: Evaluating Genuine Reasoning in Large Language Models via Esoteric Programming Languages
- 2022Parsel: Algorithmic Reasoning with Language Models by Composing Decompositions
- 2025Generating Verifiable Chain of Thoughts from Exection-Traces
- 2026CodeEval: A pedagogical approach for targeted evaluation of code-trained Large Language Models
- 2025Code-enabled language models can outperform reasoning models on diverse tasks
- 2026Is Code Better Than Language for Algorithmic Reasoning