mlsanityData to 7 Oct 2026

Learning to Reason via Program Generation, Emulation, and Search

arXiv 2405.16337 ↗First posted 25 May 2024cs.CL cs.AIcited by 9

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

  1. 2024Language Models as Compilers: Simulating Pseudocode Execution Improves Algorithmic Reasoning in Language Models3 Apr
  2. 2023Chain of Code: Reasoning with a Language Model-Augmented Code Emulator7 Dec

Other references · 35

  1. 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 14,084
  2. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
  3. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  4. 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,601
  5. 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
  6. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  7. 2022Beyond the Imitation Game: Quantifying and extrapolating the capabilities of language modelscited by 1,970
  8. 2018CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledgecited by 1,793
  9. 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,767
  10. 2022Program of Thoughts Prompting: Disentangling Computation from Reasoning for Numerical Reasoning Taskscited by 1,057
  11. 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,020
  12. 2018Neural Network Acceptability Judgmentscited by 952
23 more
  1. 2022STaR: Bootstrapping Reasoning With Reasoningcited by 895
  2. 2021Are NLP Models really able to Solve Simple Math Word Problems?cited by 861
  3. 2023Large Language Models as Optimizerscited by 830
  4. 2023Instruction Tuning with GPT-4cited by 676
  5. 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
  6. 2023Automatic Prompt Optimization with "Gradient Descent" and Beam Searchcited by 628
  7. 2022RLPrompt: Optimizing Discrete Text Prompts with Reinforcement Learningcited by 361
  8. 2023Hard Prompts Made Easy: Gradient-Based Discrete Optimization for Prompt Tuning and Discoverycited by 329
  9. 2022Active Example Selection for In-Context Learningcited by 195
  10. 2022Instruction Induction: From Few Examples to Natural Language Task Descriptionscited by 152
  11. 2023Compositional Exemplars for In-context Learningcited by 143
  12. 2022GrIPS: Gradient-free, Edit-based Instruction Search for Prompting Large Language Modelscited by 127
  13. 2023InstructZero: Efficient Instruction Optimization for Black-Box Large Language Modelscited by 68
  14. 2023Coverage-based Example Selection for In-Context Learningcited by 58
  15. 2023Prompt Engineering a Prompt Engineercited by 53
  16. 2022Few-shot Reranking for Multi-hop QA via Language Model Promptingcited by 19
  17. 2022NELLIE: A Neuro-Symbolic Inference Engine for Grounded, Compositional, and Explainable Reasoningcited by 16
  18. 2023Natural Language Embedded Programs for Hybrid Language Symbolic Reasoningcited by 15
  19. 2023Prompting with Pseudo-Code Instructionscited by 13
  20. 2020Braid: Weaving Symbolic and Neural Knowledge into Coherent Logical Explanationscited by 11
  21. 2023Exploring Demonstration Ensembling for In-context Learningcited by 8
  22. 2022One-Shot Learning from a Demonstration with Hierarchical Latent Languagecited by 6
  23. 2023Exploring the Curious Case of Code Promptscited by 6

Built on by

Cited by year

Citing papers per year: 2024: 2; 2025: 7.

9 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025L0-Reasoning Bench: Evaluating Procedural Correctness in Language Models via Simple Program Execution
  2. 2026The Imitation Game: When LLMs Learn to Reason Like Programs via Code-Centric Reasoning Data Synthesis
  3. 2026EsoLang-Bench: Evaluating Genuine Reasoning in Large Language Models via Esoteric Programming Languages
  4. 2022Parsel: Algorithmic Reasoning with Language Models by Composing Decompositions
  5. 2025Generating Verifiable Chain of Thoughts from Exection-Traces
  6. 2026CodeEval: A pedagogical approach for targeted evaluation of code-trained Large Language Models
  7. 2025Code-enabled language models can outperform reasoning models on diverse tasks
  8. 2026Is Code Better Than Language for Algorithmic Reasoning