Skip to main content

minismt

DPLL(T) SMT solver for QF_UF in Python: CDCL, congruence closure, SMT-LIB. Educational, zero deps.

minismt is an educational SMT solver. It implements the DPLL(T) architecture from scratch:

  • a CDCL SAT solver with two-watched literals, 1UIP clause learning, VSIDS, phase saving, and non-chronological backjumping;
  • a congruence closure theory solver with explanation tracking;
  • a DPLL(T) driver that feeds theory conflicts back into the SAT engine as learned clauses;
  • a small SMT-LIB v2 parser for the QF_UF subset.

Zero runtime dependencies. Pure Python 3.8+.

What it is

  • A readable, ~350-line reference implementation of DPLL(T) + congruence closure.
  • A working QF_UF solver that handles transitivity, symmetry, congruence, negation, and propositional combinations (and, or, =>, not, distinct).
  • A starting point for adding more theories (LRA, bit-vectors, arrays).

What it is not

  • Not a drop-in replacement for Z3 or cvc5. Not even close on performance.
  • Not production software. No proofs, no unsat cores, no get-model, no incremental solving.
  • Not covering the full SMT-LIB standard. See Limitations.

Install

git clone https://github.com/YOU/minismt.git
cd minismt
python -m pip install -e ".[dev]"

Or, no install, just run it:

python -m minismt tests/examples/congruence.smt2

Usage

CLI

$ minismt tests/examples/congruence.smt2
unsat

As a library

from minismt import run

result = run("""
(set-logic QF_UF)
(declare-fun x () U)
(declare-fun y () U)
(declare-fun f (U) U)
(assert (= x y))
(assert (not (= (f x) (f y))))
(check-sat)
""")
print(result)   # "unsat"

Tests

pytest

Supported SMT-LIB subset

Construct Status
set-logic, set-info, declare-sort, declare-fun, declare-const parsed, ignored (no sort checking)
assert supported
check-sat supported (one per file)
exit supported
=, not, and, or, =>, distinct supported
Function application (f x y) supported
let, ite, forall, exists not supported
push, pop, get-model, get-unsat-core not supported

How it works

The pipeline is the classic DPLL(T) loop:

SMT-LIB  ──parser──▶  AST  ──Tseitin──▶  CNF  ──CDCL──▶  Boolean model
                                                             │
                                                             ▼
                                                    ┌────────────────┐
                                                    │ Congruence     │
                                                    │ closure (EUF)  │
                                                    └────────────────┘
                                                             │
                                              conflict ◀─────┴─────▶ ok
                                                 │                   │
                                        learn + backjump       next decision
  1. Encode. Each theory atom (= a b) becomes a SAT variable. Boolean connectives are encoded into CNF with Tseitin-style clauses.
  2. Solve. The CDCL solver runs as normal.
  3. Check. After propagation settles, the congruence-closure solver processes all currently-true equalities (union) and all currently-false equalities (disequalities). It also propagates congruence: if a ≡ b then f(a) ≡ f(b) for every f.
  4. Explain. Every merge in the union-find carries the set of SAT literals that caused it. If a disequality is violated, that reason set plus the disequality itself forms a conflict clause.
  5. Learn. The conflict clause is fed to SAT.analyze() exactly like a SAT conflict. New clause learned, backjump, continue.

For the full breakdown, read the docstrings in src/minismt/solver.py — the three classes (SAT, CC, SMT) map 1:1 to the architecture.

Limitations

  • QF_UF only. No arithmetic, arrays, or bit-vectors.
  • One check-sat per file. No incremental solving.
  • theory_check() is non-incremental. It rebuilds the congruence-closure state on every call — correct but O(n²) per check.
  • CC.process() is O(n³) worst case on terms with large equivalence classes.
  • No model output. On sat, you get sat and nothing else.
  • No proofs or unsat cores.
  • Parser is minimal. No let, no ite, no nested distinct, no SMT-LIB round-tripping.

Roadmap

  • v0.2 — incremental congruence closure (push/pop on the trail)
  • v0.2 — (get-model) printing equivalence classes
  • v0.3 — split solver.py into sat.py, cc.py, dpllt.py, parser.py
  • v0.3 — let, ite, and multiple check-sat in the parser
  • v0.4 — (get-unsat-core)
  • v0.5 — Linear Real Arithmetic via Simplex-for-DPLL(T)
  • v0.6 — Bit-vectors via bit-blasting
  • v1.0 — pass a meaningful subset of the SMT-LIB QF_UF benchmark suite

References

  • Kroening & Strichman, Decision Procedures: An Algorithmic Point of View — the standard textbook.
  • Nieuwenhuis, Oliveras, Tinelli, Solving SAT and SAT Modulo Theories (2006) — the DPLL(T) paper.
  • Nelson & Oppen, Fast Decision Procedures Based on Congruence Closure (1980).
  • The "SAT / SMT 學習筆記" tutorial series — the best code-level walkthrough.

License

MIT. See LICENSE.

Metadata

Release files for minismt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minismt 0.1.0
File Size Uploaded Provenance Actions
minismt-0.1.0.tar.gz 10.6 kB With provenance Details for minismt-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minismt 0.1.0
File Interpreter ABI Platform Actions
minismt-0.1.0-py3-none-any.whl Python 3 none any Details for minismt-0.1.0-py3-none-any.whl

Total release size: 19.6 kB

Release files / minismt-0.1.0.tar.gz

Download URL minismt-0.1.0.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
161064df7096c1d5f32a1776a7a440204e8d524c81019c576543b9bdefa44a5e
BLAKE2b-256 checksum
How to use checksums
d33bb59e64d58abaad8358cfa62eaf1804448bff2d787e836e10c8f93de8118c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / minismt-0.1.0-py3-none-any.whl

Download URL minismt-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
288e92c4137a7f19cc7f7f9aa66bde03d109dcc77ad0ed5cdc50b21b5b3300c9
BLAKE2b-256 checksum
How to use checksums
f99baf1d018da98a08409fa553978b722e25d916e5514a6c97e44e51c3f9749a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for minismt 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for minismt-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page