Skip to main content

cdclkit

A conflict-driven clause-learning SAT solver, a preprocessor, an encoding library and a modelling layer — written from scratch in readable Python.

Every answer comes with a certificate, and the certificate gets checked.

pip install cdclkit
python3 -m cdclkit solve instance.cnf --self-check --check-model
  • SAT → the model is re-evaluated against the input formula, clause by clause.
  • UNSAT → the solver emits a DRAT proof and dratify replays it, confirming every derived clause really follows and the empty clause is reached.

A solver that says "unsatisfiable" and offers nothing else is asking to be trusted. This one hands you the proof — and the checker that reads it shares no code with the solver that wrote it.

Quick start

from cdclkit import parse_dimacs, solve

formula = parse_dimacs("p cnf 2 4\n1 2 0\n1 -2 0\n-1 2 0\n-1 -2 0\n")
sat, model = solve(formula)
print(sat)          # False -- and `solve` returns (False, None)

Note the shape: solve() returns a tuple, so if solve(f): is always true. Unpack it.

Worked examples live in examples/ — Sudoku with a uniqueness proof, the zebra puzzle, graph colouring, bounded model checking, circuit equivalence.

What's in it

module what it does
solver CDCL: two watched literals, first-UIP learning, LBD, Luby restarts, phase saving, target phases, probSAT rephasing
preprocess subsumption, self-subsumption, blocked-clause elimination, pure literals, bounded variable elimination with model reconstruction
encodings at-most-one (pairwise, binary, commander), cardinality (sequential, totalizer), pseudo-Boolean
model a modelling layer — integer variables, all-different, differential encoding
mus minimal unsatisfiable subsets, deletion-based and QuickXplain
portfolio parallel configurations
pyeq experimental — bounded equivalence of two Python integer functions

An optional Rust engine (pip install cdclkit[native]) is roughly 18x faster and bit-exact with the Python one: identical conflicts, decisions and propagations on every instance. The pure-Python path has zero third-party dependencies and is the one that must never break.

Relationship to dratify

Proof checking lives in a separate package, dratify, which cdclkit depends on. That split is deliberate:

  • You should not have to install a SAT solver to verify a proof someone else produced.
  • The checker stays small enough to audit, which is the point of a checker.
  • cdclkit exercises it on every test run, so the checker is dogfooded by the solver rather than only by its own suite.

dratify has no dependencies of its own, so installing cdclkit pulls in no third-party code.

Performance

See BENCHMARKS.md. Read the caveats there before quoting any number — in particular, all figures come from a single machine, and the comparison against kissat is against its default configuration on a public benchmark suite whose instances are small enough that process startup is part of what is being measured.

If you need raw speed, install PySAT: it ships kissat, CaDiCaL and Glucose as binary wheels on every platform. This project is not trying to beat them. It is trying to be a complete, readable, self-checking implementation you can audit.

Honest limitations

  • No Windows. Never tested; the classifiers say so rather than implying support.
  • Pure Python is ~18x slower than its own Rust port, which is itself far from kissat. Not a tool for competition-scale instances.
  • No inprocessing, no XOR/Gaussian reasoning. Parity families are a known weakness and bench/ includes one to keep that visible.
  • pyeq models a small subset of Python and is experimental. Measured against CrossHair on a 48-function corpus it found nothing CrossHair missed (0 of 105). See experiments/pyeq-llm-refactor/report.md for the full negative result.
  • Every performance figure comes from one machine.

Documentation

  • docs/ALGORITHMS.md — the mathematics, from resolution through first-UIP, LBD, DRAT, encodings and preprocessing, including a section on what is deliberately absent.
  • docs/ROADMAP.md — what is planned, in sprints.
  • docs/RELEASING.md — the release checklist.

Licence

Apache-2.0. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdclkit-0.1.1.tar.gz (119.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdclkit-0.1.1-py3-none-any.whl (83.7 kB view details)

Uploaded Python 3

File details

Details for the file cdclkit-0.1.1.tar.gz.

File metadata

  • Download URL: cdclkit-0.1.1.tar.gz
  • Upload date:
  • Size: 119.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cdclkit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa3c8610ae942456a77472215626b4301e6f3ecd810eb14b69a311a9a81729e8
MD5 f12e0593138bd24cf0d5cfc5c7c0cc3b
BLAKE2b-256 4c3a3914da6a81224f6c0f7d5fcbe1f47aec1f9140554b249920db035e029804

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdclkit-0.1.1.tar.gz:

Publisher: release.yml on carlok/cdclkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cdclkit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cdclkit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 83.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cdclkit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fea5cb217c456a8faf9b85414b6897279c642c3c3c9ce3edcf287023de3deefc
MD5 39e42951603f7c0b6ece5bdd6d62993a
BLAKE2b-256 146a93b5911ba92b3a783d293a1a325971b0d076233b42bf2cdfea4175b3c522

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdclkit-0.1.1-py3-none-any.whl:

Publisher: release.yml on carlok/cdclkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

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