Skip to main content

dratify

Check a DRAT/DRUP proof of unsatisfiability, inside your Python process.

A SAT solver that answers "unsatisfiable" is asking to be trusted. A DRAT proof is how it stops asking: the solver logs every clause it derives, and a checker that shares no code with it replays the log and confirms the empty clause really follows.

Emitting those proofs is routine. PySAT exposes them from six solver families with with_proof=True / get_proof(). Checking them from Python has not been practical: drat-trim is C you compile and shell out to, and the only checker on PyPI installs on Linux x86-64 under Python ≤ 3.10 alone.

pip install dratify              # pure Python, zero dependencies

A Rust implementation of the same checker is published separately as the dratify crate. Python bindings for it are not packaged yet; engine="native" is wired up and will pick them up when they are.

Check a proof from PySAT

from pysat.formula import CNF as PyCNF
from pysat.solvers import Glucose42
from dratify import parse_dimacs, check_proof

cnf = PyCNF(from_file="problem.cnf")
with Glucose42(bootstrap_with=cnf, with_proof=True) as s:
    assert not s.solve()
    proof = s.get_proof()

result = check_proof(parse_dimacs(cnf.to_dimacs()), "\n".join(proof))
print(result.ok)          # True -- the refutation is genuine

No subprocess, no compiler, no temporary files.

Two engines, and that is the point

Proof checking is the one domain where two independent implementations agreeing is the evidence. This ships both:

Pure Python zero dependencies, runs anywhere Python does
Rust (crates.io) ~18x faster; Python bindings not yet packaged

Neither is the "real" one. They have been differentially tested against each other on acceptances and on rejections, and they agree.

check_proof(formula, proof, engine="python")   # always available
check_proof(formula, proof, engine="native")   # when bindings are installed
check_proof(formula, proof, engine="auto")     # default: native when present

What it checks

  • RUP (reverse unit propagation) — the common case.
  • RAT (resolution asymmetric tautology) — the "A" in DRAT, checked properly: pivot on the first literal, resolvent against every clause containing its negation, RUP on each.
  • Deletion, applied by default. Deletion is monotone-safe for RUP; RAT is not monotone, so RAT steps are checked against exactly the clauses present.

Checking is forward: every step is verified, rather than working backwards from the empty clause as drat-trim does. That makes it slower on large proofs and means a corrupted step is caught where it occurs.

Speed

Measured against drat-trim (which does backward checking by default):

proof steps pure Python Rust drat-trim
uuf100-01 774 0.01s 0.01s 0.05s
uuf100-010 1,103 0.05s 0.00s 0.06s
uuf250-01 209,367 41.47s 2.27s 1.30s

Rust wins on small proofs — drat-trim pays process startup and cannot be called in-process — and loses 1.75x on the large one, while checking forward.

On 10 proofs from two solvers, dratify and drat-trim agreed on every case, including four rejections.

Honest limitations

  • Forward checking only. Backward checking would close the large-proof gap.
  • No binary DRAT format yet; text proofs only.
  • Not formally verified. It is carefully written, differentially tested against a second implementation, and cross-validated against drat-trim — which is not the same thing as a machine-checked proof of the checker itself. If you need that, cake_lpr is CakeML-verified and consumes LRAT.

Related

cdclkit is a from-scratch CDCL SAT solver by the same author that uses this package to check its own refutations. You do not need it to use dratify — checking a proof should never require installing a solver, which is why these are separate packages.

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

dratify-0.1.0.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

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

dratify-0.1.0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file dratify-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for dratify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c02af324853e3f313518e70f4cd2e888fd06dcddbad2964afc47aed0837d74c
MD5 94be19966ba36e3150c57ab0095d4ad8
BLAKE2b-256 d88da35f373ee9375e9252459544de9bb4beecd2e3ba66d7f362258bcb39ea8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dratify-0.1.0.tar.gz:

Publisher: release.yml on carlok/dratify

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

File details

Details for the file dratify-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for dratify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db2fed5324124fe71fe25c6a3237d3577c57d5ae9b0549083b282f3b6fc4c59e
MD5 eeb4dfd7ba65e1ffeda57d70b5dcd61e
BLAKE2b-256 e3569577ce67a2165883d1b36594589cb7935850ba2632c3ad05b2918c0b78a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dratify-0.1.0-py3-none-any.whl:

Publisher: release.yml on carlok/dratify

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

0.1.1

2 files

This release

0.1.0 This release

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