Logic.py: Bridging the Gap between LLMs and Constraint Solvers
Pascal Kesseli, Peter W. O'Hearn, Ricardo Silveira Cabral
Abstract
We present a novel approach to formalise and solve search-based problems using large language models, which significantly improves upon previous state-of-theart results. We demonstrate the efficacy of this approach on benchmarks like the logic puzzles tasks in ZebraLogicBench. Instead of letting the LLM attempt to directly solve the puzzles, our method prompts the model to formalise the problem in a logic-focused, human-readable, domain-specific language (DSL) called Logic.py. This formalised representation is then solved using a constraint solver, leveraging the strengths of both the language model and the solver. Our approach achieves a remarkable 65% absolute improvement over the baseline performance of Llama 3.1 70B on ZebraLogicBench, increasing its accuracy to over 90%. This significant advancement demonstrates the potential of combining language models with domain-specific languages and auxiliary tools on traditionally challenging tasks for LLMs.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
2 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning cites FOLIO: Natural Language Reasoning with First-Order Logic
- FOLIO: Natural Language Reasoning with First-Order Logic cites Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning
- LLM-Guided Quantified SMT Solving over Uninterpreted Functions cites Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning
- Open-World LLM Logical Reasoning cites Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical Reasoning
- Open-World LLM Logical Reasoning cites SatLM: Satisfiability-Aided Language Models Using Declarative Prompting
- Open-World LLM Logical Reasoning cites FOLIO: Natural Language Reasoning with First-Order Logic
Cited by top-tier papers2
Builds on3
- Logic-LM: Empowering Large Language Models with Symbolic Solvers for Faithful Logical ReasoningLiangming Pan, Alon Albalak, Xinyi Wang, William Yang WangEMNLP Findings 2023 · 145 citations
- SatLM: Satisfiability-Aided Language Models Using Declarative PromptingXi Ye, Qiaochu Chen, Isil Dillig, Greg DurrettNeurIPS 2023 · 126 citations
- FOLIO: Natural Language Reasoning with First-Order LogicSimeng Han, Hailey Schoelkopf, Yilun Zhao, Zhenting Qi et al.EMNLP 2024 · 18 citations
Related papers
- ZebraLogic: On the Scaling Limits of LLMs for Logical ReasoningBill Yuchen Lin, Ronan Le Bras, Kyle Richardson, Ashish Sabharwal et al.ICML 2025
- DiLA: Enhancing LLM Tool Learning with Differential Logic LayerYu Zhang, Hui-Ling Zhen, Zehua Pei, Yingzhao Lian et al.KDD 2026 · 6 citations
- SATBench: Benchmarking LLMs' Logical Reasoning via Automated Puzzle Generation from SAT FormulasAnjiang Wei, Yuheng Wu, Yingjia Wan, Tarun Suresh et al.EMNLP 2025 · 1 citation
- A Balanced Neuro-Symbolic Approach for Commonsense Abductive LogicJoseph Cotnareanu, Didier Chételat, Yingxue Zhang, Mark CoatesICLR 2026 · 3 citations
- Lexical Recall or Logical Reasoning: Probing the Limits of Reasoning Abilities in Large Language ModelsHenrike Beyer, Chris ReedACL 2025
