Table of Contents
Fetching ...

Reasoning-as-Logic-Units: Scaling Test-Time Reasoning in Large Language Models Through Logic Unit Alignment

Cheryl Li, Tianyuan Xu, Yiwen Guo

TL;DR

Reasoning-as-Logic-Units (RaLU) addresses reasoning hallucinations in large language models by aligning natural-language reasoning with executable code units extracted from an initial program. It decomposes the program into logic units via a CFG, then uses iterative self-judgment, self-correction, and explanations to refine each unit before synthesizing a final solution from the aligned units. Across math and code benchmarks (GSM8K, MATH-np, HumanEval, MbPP and their plus variants) and multiple open-source LLM backbones, RaLU demonstrates consistent improvements over strong baselines, while also providing enhanced interpretability through unit-level traceability. The framework achieves robust generalization without fine-tuning, offering a scalable path to more reliable and transparent LLM reasoning in both mathematical and coding domains.

Abstract

Chain-of-Thought (CoT) prompting has shown promise in enhancing the reasoning capabilities of large language models (LLMs) by generating natural language (NL) rationales that lead to the final answer. However, it struggles with numerical computation, which has somehow led to the development of program-aided techniques. Despite their potential, a persistent challenge remains: inconsistencies between LLM-reported reasoning steps and the logic in generated programs, which we term ``reasoning hallucinations." This stems from the inherent ambiguities of NL and the statistical nature of LLMs, which often lack rigorous logical coherence. To address this challenge, we propose a novel test-time scaling framework, Reasoning-as-Logic-Units (RaLU), which constructs a more reliable reasoning path by aligning logical units between the generated program and their corresponding NL descriptions. By decomposing the initially generated program into discrete units using static analysis, RaLU engages in an iterative dialogue with the LLM to judge, refine, and explain each unit. A rewind-and-correct mechanism ensures alignment between code statements and task requirements in each unit, ultimately forming a cohesive reasoning path under the program's logic, from which the model reaches a final solution. Our experiments demonstrate that RaLU significantly outperforms existing baselines in mathematical reasoning (GSM8K, MATH) and algorithmic reasoning (HumanEval+, MBPP+), underscoring its potential to advance LLM reasoning and programming by offering enhanced accuracy and interpretability.

Reasoning-as-Logic-Units: Scaling Test-Time Reasoning in Large Language Models Through Logic Unit Alignment

TL;DR

Reasoning-as-Logic-Units (RaLU) addresses reasoning hallucinations in large language models by aligning natural-language reasoning with executable code units extracted from an initial program. It decomposes the program into logic units via a CFG, then uses iterative self-judgment, self-correction, and explanations to refine each unit before synthesizing a final solution from the aligned units. Across math and code benchmarks (GSM8K, MATH-np, HumanEval, MbPP and their plus variants) and multiple open-source LLM backbones, RaLU demonstrates consistent improvements over strong baselines, while also providing enhanced interpretability through unit-level traceability. The framework achieves robust generalization without fine-tuning, offering a scalable path to more reliable and transparent LLM reasoning in both mathematical and coding domains.

Abstract

Chain-of-Thought (CoT) prompting has shown promise in enhancing the reasoning capabilities of large language models (LLMs) by generating natural language (NL) rationales that lead to the final answer. However, it struggles with numerical computation, which has somehow led to the development of program-aided techniques. Despite their potential, a persistent challenge remains: inconsistencies between LLM-reported reasoning steps and the logic in generated programs, which we term ``reasoning hallucinations." This stems from the inherent ambiguities of NL and the statistical nature of LLMs, which often lack rigorous logical coherence. To address this challenge, we propose a novel test-time scaling framework, Reasoning-as-Logic-Units (RaLU), which constructs a more reliable reasoning path by aligning logical units between the generated program and their corresponding NL descriptions. By decomposing the initially generated program into discrete units using static analysis, RaLU engages in an iterative dialogue with the LLM to judge, refine, and explain each unit. A rewind-and-correct mechanism ensures alignment between code statements and task requirements in each unit, ultimately forming a cohesive reasoning path under the program's logic, from which the model reaches a final solution. Our experiments demonstrate that RaLU significantly outperforms existing baselines in mathematical reasoning (GSM8K, MATH) and algorithmic reasoning (HumanEval+, MBPP+), underscoring its potential to advance LLM reasoning and programming by offering enhanced accuracy and interpretability.

Paper Structure

This paper contains 27 sections, 15 equations, 6 figures, 2 tables.

Figures (6)

  • Figure 1: Motivating examples reflecting the reasoning hallucinations: In Example 1, the LLM attempts to factor out the negative sign as stated yet wrongly neglects to reverse the positions of $x$ and $y$ in the expression. In Example 2, the LLM overlooks the NL step that indicates using the leftover to calculate the money earned; instead, it is misled by the question description to sell all the sets, thus omitting this crucial step. In Example 3, the LLM incorrectly places the loop termination conditions after operating on both odd- and even-numbered rows, which should be positioned individually.
  • Figure 2: Schematic depicting multiple strategies for test-time scaling frameworks with LLMs. Each rectangular shape symbolizes a distinct thought (aka. step/unit), a self-contained text sequence crucial as an intermediate stage in the reasoning process. In previous studies, all the thoughts are natural language-based, while our RaLU uses logic units consisting of code statements and NL descriptions.
  • Figure 3: Illustrating the three-stage process of RaLU: Logic Unit Extraction, Logic Unit Alignment, and Solution Synthesis for operationalizing synergy in reasoning tasks.
  • Figure 4: Ablation study of logic unit granularity: line-by-line decomposition causes 7.04% performance decline and 37.7% more token overhead compared to the CFG method (Llama3.3). Performance degradation reflects contextual fragmentation and error propagation in atomic units, while increased token costs are attributed to redundant context re-verification.
  • Figure 5: Ablation on unit abstraction: 5.52% accuracy drop (Math) and 4.35% score decline (Code) when replacing program-guided logic units with NL steps. Performance deterioration stems from reasoning hallucinations exacerbated by NL's lack of operational specificity and weak causal dependency constraints.
  • ...and 1 more figures