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.10+.

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).
  • Differentially tested against Z3 on 2000+ random QF_UF programs per deep run; model validation is on by default in check().

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

Two entry points.

run(text) — execute an SMT-LIB 2 string:

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"

check(*assertions) — programmatic API returning a Result:

from minismt import check

r = check("(= x y)", "(not (= y x))", declarations=("x", "y"))
print(r.sat)    # False
print(r.model)  # None

r = check("(= x y)", declarations=("x", "y"))
print(r.sat)    # True
print(r.model)  # {'x': 'x', 'y': 'x'}

check() validates the returned model against every assertion by default. If the solver ever returns an unsound sat, it raises UnsoundSatError instead of returning a wrong answer.

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.

Testing

pytest                                            # 29 tests, ~15s
pytest --hypothesis-profile=deep                  # + 2000 fuzz cases, ~3min
pytest --hypothesis-profile=soak                  # + 20k fuzz cases, ~30min

The fuzzer generates random QF_UF programs, runs them through both minismt and Z3, and fails on any disagreement. It also validates every sat model. Three soundness bugs in v0.2.0 were found this way — see the git log for v0.3.0.

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 — differential fuzzing vs Z3, model validation, check() API
  • v0.4 — incremental congruence closure (push/pop on the trail) + multiple (check-sat)
  • v0.5 — let, ite in the parser
  • v0.6 — (get-unsat-core)
  • v0.7 — Linear Real Arithmetic via Simplex-for-DPLL(T)
  • v0.8 — Bit-vectors via bit-blasting
  • v1.0 — pass a meaningful subset of the SMT-LIB QF_UF benchmark suite

References

License

MIT. See LICENSE.

Metadata

Release files for minismt 0.3.1

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.3.1
File Size Uploaded Provenance Actions
minismt-0.3.1.tar.gz 15.4 kB With provenance Details for minismt-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 27.8 kB

Release files / minismt-0.3.1.tar.gz

Download URL minismt-0.3.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0b9c1aa1593f63d9ce8731639c8416167363d517bbf23f64b210557a9dae44b2
BLAKE2b-256 checksum
How to use checksums
76724133b63e5cad8c42f42bdc1c4f6462d61aff8fdf42752417cd6b12a99ed0
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 25, 2026.

Transparency log

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

Download URL minismt-0.3.1-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8223a3b0fc075bc884b8614bbc7dbda9a8f924e3d0dcd28c32995a3932fb3a7
BLAKE2b-256 checksum
How to use checksums
2f79dd70ac0f92416afff3df1d1ee5e3895b6c6184d9d4e539d93b41bd2f0d34
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 25, 2026.

Transparency log

Security for minismt 0.3.1

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.3.1.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 25, 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.3.1 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