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 reference implementation of DPLL(T) + congruence closure, split across sat.py, cc.py, dpllt.py, parser.py.
  • 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 incremental solving.
  • Not covering the full SMT-LIB standard. See Limitations.

Install

pip install minismt

From source:

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

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"

Getting a model

result = run("""
(set-logic QF_UF)
(declare-fun x () U)(declare-fun y () U)(declare-fun z () U)
(assert (= x y))(assert (not (= x z)))
(check-sat)(get-model)
""")
print(result)
# sat
# (
#   (define-fun x () U x)
#   (define-fun y () U x)
#   (define-fun z () U z)
# )

get-model prints one define-fun per variable, mapping each to its equivalence-class representative.

Tests

pytest

Supported SMT-LIB subset

Construct Status
set-logic, set-info, declare-sort parsed, ignored (no sort checking)
declare-fun, declare-const parsed, tracked for get-model
assert supported
check-sat supported
get-model supported
exit supported
=, not, and, or, =>, distinct supported
Function application (f x y) supported
let, ite, forall, exists not supported
push, pop, 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/ — sat.py (CDCL), cc.py (congruence closure), dpllt.py (driver), parser.py (SMT-LIB).

Limitations

  • QF_UF only. No arithmetic, arrays, or bit-vectors.
  • No incremental solving. (check-sat)(get-model) is supported, but calling (check-sat) twice in one file re-runs the search and is not guaranteed correct after new assertions.
  • 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 proofs or unsat cores.
  • Parser is minimal. No let, no ite, no nested distinct, no SMT-LIB round-tripping.

Roadmap

  • v0.2 — module split + (get-model) printing equivalence classes
  • v0.3 — incremental congruence closure (push/pop on the trail) + multiple (check-sat)
  • v0.4 — let, ite in the parser
  • v0.5 — (get-unsat-core)
  • v0.6 — Linear Real Arithmetic via Simplex-for-DPLL(T)
  • v0.7 — 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.2.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.2.0
File Size Uploaded Provenance Actions
minismt-0.2.0.tar.gz 11.3 kB With provenance Details for minismt-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 21.4 kB

Release files / minismt-0.2.0.tar.gz

Download URL minismt-0.2.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
413b8fee3b215ad0d0e48e1e340e33238d6e00277b6ae82f1ab98ab26fa980d8
BLAKE2b-256 checksum
How to use checksums
dabe3e3203113eee3aa913a53e96ab3db005dbbf3db863e81157393a6771d46d
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.2.0-py3-none-any.whl

Download URL minismt-0.2.0-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a30b56bf08384e583bafacdd8f7770ca083d86ebeeea14f45b547731acf7830d
BLAKE2b-256 checksum
How to use checksums
c2ebb6398f0a66a1021df05af344fb23b39e96e11afd32dcb1357c9cf1eeb92c
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.2.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.2.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.2.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