DebarghaG/proofofthought

Proof of thought : LLM-based reasoning using Z3 theorem proving with multiple backend support (SMT2 and JSON DSL)

What it solves

Large language models often give confident but unverifiable answers, especially on logical or multi-step reasoning questions. ProofOfThought addresses this by combining an LLM with the Z3 theorem prover: instead of just generating text, the model formulates reasoning as a formal SMT-LIB program that Z3 can check, so the final answer comes with a machine-verifiable proof (or a counterexample). This makes the reasoning process transparent and auditable.

How it works

The default workflow is an agentic loop: the LLM interacts with an "SMT-LIB scratchpad" by calling a z3_solve tool, then reads Z3's verdict (sat, unsat, or an error), repairs or strengthens its logical encoding based on that feedback, and repeats until it terminates with a decisive proof. The canonical method is proof by contradiction: encode the negation of the candidate answer, and if Z3 returns unsat, the proof is validated. Every result includes a proof_status (proof_by_contradiction, sat_witness, or unverified) and the full trajectory of SMT programs and Z3 verdicts that back it. For simpler cases, two single-shot backends (SMT2 and JSON) are also available, along with postprocessing techniques like Self-Refine and Self-Consistency to improve reliability.

Who it's for

Developers and researchers who want LLM-based reasoning with formal guarantees — for example, building question-answering systems that need verifiable logic, or benchmarking LLM+solver pipelines. It requires a Python environment, an OpenAI or Azure OpenAI API key, and works with local vLLM/sglang endpoints too.

Highlights

  • Agentic SMT-LIB scratchpad loop: the model iteratively refines its logical encoding with Z3 as a checker.
  • Triple backend support: agentic (default), SMT2, and JSON execution modes.
  • Machine-checkable proofs: every answer carries a proof_status and the full SMT trajectory can be re-verified independently.
  • Evaluated on 5 reasoning datasets (ProntoQA, FOLIO, ProofWriter, ConditionalQA, StrategyQA) with detailed benchmark tables.

Related

  • Project
  • Project
  • Project
  • Project