NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Certified Deductive Reasoning with Language Models

Gabriel Poesia, Kanishk Gandhi, Eric Zelikman, Noah Goodman

Abstract

Language models often achieve higher accuracy when reasoning step-by-step in complex tasks. However, even when arriving at a correct final answer, their rationales are often logically unsound or inconsistent. This is a major issue when reliable reasoning traces are needed, such as when fine-tuning on model-generated reasoning for self-improvement. To tackle these issues, we introduce a class of tools for language models called guides, that use state and incremental constraints to guide generation. A guide can be invoked by the model to constrain its own generation to a set of valid statements given by the tool. In turn, the model’s choices can change the guide’s state. We show how a general system for logical reasoning can be used as a guide, which we call LogicGuide. Given a reasoning problem in natural language, a model can formalize its assumptions for LogicGuide and guarantee that its step-by-step reasoning is sound. In experiments on PrOntoQA, ProofWriter and Syllogism Validity datasets, LogicGuide significantly improves the performance of GPT-3, GPT-3.5 Turbo and LLaMA (accuracy gains up to 35%), while drastically reducing content effects — the interference between unwanted prior assumptions and reasoning, which humans and language models suffer from. We then explore bootstrapping GPT-3.5 Turbo and LLaMA using their own reasoning traces. We find that LogicGuide is critical: by training only on certified self-generated reasoning, models can self-improve, avoiding learning from their own hallucinations. Moreover, bootstrapped models enjoy significant boosts on ReClor, a challenging real-world reasoning dataset, even when not relying on formalization at inference time.

Introduction

While Large Language Models (LLMs) have demonstrated impressive capabilities in "Chain-of-Thought" (CoT) reasoning, they are notorious for "hallucinating" logical steps. A model might provide the correct final answer but arrive there through a series of nonsensical or contradictory arguments. This creates two major hurdles: first, we cannot trust the model's "rationale" as an interpretable window into its decision-making; second, common self-improvement techniques like STaR (Self-Taught Reasoner) fail because fine-tuning on "lucky guesses" teaches the model flawed logic. Furthermore, LLMs suffer from "content effects"—the tendency for prior biases (e.g., "all cats are mammals") to override specific logical rules provided in a prompt.

Methodology: LogicGuide

To address these challenges, we introduce LogicGuide, a tool that restricts an LM's generation to a space of valid next steps defined by an external theorem prover.

Overview of LogicGuide: The Language Model formalizes statements which are then verified by the LogicGuide system to ensure sound reasoning.

The system operates through Constrained Semantic Decoding (CSD), an algorithm that filters the model's output token-by-token. When the LM initiates a logical deduction via an [[infer:]] block, LogicGuide ensures that only mathematically provable statements—based on previously established facts—are generated.

A key feature of LogicGuide is the "Nothing" signal. When the guide determines that no further valid inferences can be made, it forces the model to generate "nothing." This acts as a signal for the model to stop and realize it cannot prove the goal, preventing the "unjustified guess" behavior common in vanilla LLMs. While the guide guarantees the deduction is sound, it relies on the model to correctly formalize natural language into logic. Interestingly, formalization errors usually lead to the model being "stuck" rather than reaching a wrong conclusion.

Experimental Evaluation

We evaluated LogicGuide across several logical benchmarks, including PrOntoQA and ProofWriter for multi-hop reasoning, and Syllogism Validity to measure prior bias interference. We also introduced DeontiQA, a dataset focusing on deontic logic (reasoning about permissions and obligations) in the context of a virtual assistant.

Accuracy comparison across PrOntoQA and ProofWriter datasets. LogicGuide (solid lines) consistently improves performance over unguided models (faded lines) as the number of reasoning hops increases.

Key Results

  • Accuracy Boosts: LogicGuide improved the accuracy of GPT-3 and LLaMA by up to 35% on multi-hop reasoning tasks. Guided versions of older models (like text-davinci-003) often matched or exceeded the performance of unguided GPT-4.
  • Solving the STaR Failure: On PrOntoQA, standard bootstrapping failed to improve LLaMA 13B because the model learned from its own hallucinations. Using "Strict Guided" bootstrapping (only certified traces), accuracy jumped from 72% to 86%.
  • Real-world Transfer: Perhaps the most striking finding is that models fine-tuned on synthetic certified logic traces improved on real-world reasoning tasks like ReClor (LSAT/GMAT questions). GPT-3.5 Turbo's ReClor accuracy rose from 52.5% to 65% without using the guide during the final test, suggesting that learning the "rhythm" of sound reasoning generalizes.

Discussion and Conclusion

LogicGuide demonstrates that formalizing the deduction process can significantly enhance the reliability and reasoning capabilities of LLMs. While formalization remains a bottleneck, the resulting deductions are guaranteed to be sound. This approach also mitigates content effects, reducing the interference between prior assumptions and logical rules. Future work will explore expanding the "guide" framework to other domains, such as memory guides to prevent long-context hallucinations or specialized algebra guides for mathematical problem-solving.

Summary updated

BibTeX
@article{poesia2024certified,
  author = {Gabriel Poesia and Kanishk Gandhi and Eric Zelikman and Noah Goodman},
  title = {{Certified Deductive Reasoning with Language Models}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=yXnwrs2Tl6},
}
Figure