A certificate-checked QF_BV SMT solver for the PulseEngine toolchain
Ordeal answers one kind of question: are these two bit-vector computations the same for every input? It is the solver that loom and synth use to check that a WebAssembly optimisation or an ARM lowering does not change behaviour.
What makes it different from asking Z3: you don't have to trust ordeal's answer.
- "Equivalent" (UNSAT) comes with a proof certificate.
- "Different" (SAT) comes with a counterexample and a satisfying assignment.
Both are re-checked by a small checker whose soundness is machine-checked in Lean 4. The solver itself is untrusted.
Pure Rust, no external dependencies, and it runs as a wasm32-wasip2 component
as well as natively.
Pick the path that matches how you work:
| You are… | Use |
|---|---|
| Using the PulseEngine toolchain | the varve layer (below) |
| Calling it from Rust | cargo add ordeal |
| Wanting the command-line tool | cargo install ordeal, or a release binary |
| Building with Bazel | rules_ordeal |
varve. varve installs the whole
PulseEngine toolchain as one pinned, signed layer. Ordeal is one of the tools
in it. With a varve.toml pinning a layer (see varve's
Getting started):
varve install && varve shim install # then: . "$HOME/.varve/env"
ordeal --version # dispatched from the pinned layerRelease binaries. Each release
ships archives for Linux (glibc and static musl, x86_64 and aarch64) and macOS on Apple Silicon.
SHA256SUMS.txt is cosign-signed, and a CycloneDX SBOM and VEX are listed in it:
gh release download --repo pulseengine/ordeal -p 'ordeal-*-x86_64-unknown-linux-musl.tar.gz' -p 'SHA256SUMS.txt*'
cosign verify-blob --bundle SHA256SUMS.txt.cosign.bundle \
--certificate-identity-regexp '^https://github\.com/pulseengine/ordeal/\.github/workflows/release\.yml@' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com SHA256SUMS.txt
sha256sum -c --ignore-missing SHA256SUMS.txt # macOS: shasum -a 256 -c …Ordeal reads SMT-LIB2 (the QF_BV subset). Is x + x the same as x << 1?
Assert that they differ and ask. unsat means no difference exists:
$ printf '(declare-const x (_ BitVec 32))
(assert (distinct (bvadd x x) (bvshl x #x00000001)))
(check-sat)' | ordeal check -
unsat
; unsat certificate: 10 bytes of checker-validated LRATA satisfiable query prints the model:
$ echo '(declare-const x (_ BitVec 32))(assert (= x #x0000002a))(check-sat)' | ordeal check -
sat
((x #x0000002a))ordeal reads one query per script: a script with more than one check-sat before exit is
refused with exit 2 (unsupported: more than one check-sat), before anything is solved. Incremental
scripts that expect one answer per check-sat are out of scope (#321).
--format json prints one JSON object for the script's check-sat. It carries the full evidence
for either answer:
- the CNF and LRAT proof for
unsat; - the satisfying assignment, with its bit map and hashes, for
sat.
Anyone can re-check that object without trusting the ordeal binary, with a checker of their own. It is a
verdict report, not an ordeal-cert bundle, and ordeal-recheck rejects it (missing field format).
--cert-out PATH writes the bundle: the ordeal-cert/v3 file that ordeal-recheck re-checks with no solver in
its build. It works with or without --format json, which then still prints the report.
$ ordeal check query.smt2 --cert-out query.cert.json
unsat
$ ordeal-recheck query.cert.json
query.cert.json: accepted (ordeal-cert/v3, unsat)An unknown verdict has nothing to certify: no file is written and the exit code is 1.
With --echo as well, the bundle is ordeal-cert/v5: the v3 bundle plus the certified echo, the query as ordeal
read it, printed back as SMT-LIB by the proven printer in the trusted crate. ordeal-recheck prints it again from
the bundle's term and requires the same bytes. A quoted symbol is named by its content (|a b| is the name a b,
SMT-LIB 2.6 §3.1) and echoed quoted. If the printer refuses the term (an empty name ||, a byte outside printable
ASCII), the bundle is v3 and stderr says why. ordeal verus … --cert-out DIR --echo writes such a bundle beside each
.lrat.
$ ordeal check query.smt2 --cert-out query.cert.json --echo
unsat
$ ordeal-recheck query.cert.json
query.cert.json: accepted (ordeal-cert/v5, unsat)To check that the certificate is about your script, build with --features oracle,cert-bundle (it links Z3) and run
ordeal echo-check: it re-checks the bundle, then asks Z3 whether your script implies the certified echo (exit 0
implied, 1 not-implied, 3 cannot-compare). --script-out PATH keeps the comparison script for any solver. An
unsat script implies every echo, so on such a script Z3 may decide it by itself
(docs/consuming-ordeal.md).
$ ordeal echo-check query.smt2 query.cert.json
implied--timeout-ms N gives up after N milliseconds and answers unknown, which is always sound. Without it the
search runs until it decides, and some queries take minutes or longer (#314). An unknown option is a usage
error (exit 2).
use ordeal::{BvTerm, CheckResult, Solver, Sort};
// Is x * 2 the same as x << 1 for every 32-bit x?
let x = || Box::new(BvTerm::Var { name: "x".into(), sort: Sort::new(32) });
let c = |v| Box::new(BvTerm::Const { value: v, sort: Sort::new(32) });
match Solver::prove_equiv(BvTerm::Mul(x(), c(2)), BvTerm::Shl(x(), c(1))) {
CheckResult::Unsat(cert) => {
// Equivalent. recheck() re-validates the proof with the trusted checker.
cert.recheck().expect("certificate re-checks");
}
CheckResult::Sat(model) => println!("differ, e.g. at {:?}", model.assignments),
CheckResult::Unknown => { /* no claim: never treat as equivalent */ }
}The same program, runnable:
examples/quickstart.rs
(cargo run -p ordeal --example quickstart). CI runs it on every change. For the SAT witness, resource-bounded checks and more patterns, see
docs/consuming-ordeal.md.
A deliberately closed fragment of QF_BV, bit-widths 1 to 128 (SMT-LIB names):
- arithmetic:
bvadd bvsub bvmul bvudiv bvurem bvneg bvsdiv bvsrem(bvneg bvsdiv bvsremare DAG nodes with proven composite rules, lowered as nodes on every path since v0.28.0) - bitwise:
bvand bvor bvxor bvnot - shifts and rotation:
bvshl bvlshr bvashr rotate_right rotate_left - structure:
extract concat zero_extend sign_extend ite - comparisons:
= distinct bvult bvule bvugt bvuge bvslt bvsle bvsgt bvsge - the Boolean connectives
not and or
There is also a small preprocessed layer for byte arrays (select/store)
and uninterpreted pure calls.
Other constructs are rejected as unsupported (exit 2). A bit-width outside 1 to 128 is answered unknown. ordeal never guesses. Not
planned: quantifiers, floating point, optimisation, incremental push/pop.
Unknown is always a possible answer (for example on a resource limit), and
callers must treat it as "no claim".
formula → bit-blast → AIG → CNF → SAT solver ──unsat──▶ LRAT proof ─┐
└──sat───▶ assignment ─┤
▼
ordeal-lrat checker (trusted)
The only trusted crate is ordeal-lrat: dependency-free, and its checks
are translated to Lean 4 with Aeneas
and proven sound — an accepted LRAT proof refutes the CNF
(lrat_check_sound), an accepted assignment satisfies it
(check_sat_sound), and the proven lowering and the proven checks stacked
on them (next paragraph) carry both verdicts up to the query the caller
built. CI regenerates the Lean model from the Rust source before every
proof build, so the proofs cannot drift from the code.
What the proofs cover, and what they do not. The checker certifies the
CNF it is given, not your original query; a bug in the translation from
query to CNF would give a wrong answer with a valid certificate, and
#182 was such a bug.
That translation is now proven stage by stage
(#192), and the code the
proofs are about is the code every entry point runs: the lowering from the
term DAG to the CNF (dag_refuted, v0.26.0); the query re-check that
re-encodes the DAG inside the trusted crate and checks the proof against
the CNF it produced (check_query_sound, v0.27.0) and its SAT twin
(check_query_model_sound, v0.29.0); the term-to-DAG correspondence
(check_term_unsat_sound / check_term_model_sound, v0.31.0, on every
path since v0.32.0); the array / uninterpreted-function lowering
(check_sliver_unsat_sound / check_sliver_model_sound, v0.33.0); and
the flattening of the caller's trees — variables, arrays and functions by
name — into the node lists those checks are stated over
(tree_unsat_sound, ext_tree_unsat_sound, tree_model_sound,
ext_tree_model_sound, v0.34.0). Every one of these theorems is
sorry-free and pinned axiom-clean in lean/AxiomCheck.lean, and
whatever a trusted check rejects is answered Unknown, never a verdict.
What stays trusted, on every path, unless the consumer checks the echo
(next sentence): the SMT-LIB / Verus front ends, the 1:1 copy of the
trees into the kernel's mirror type (crates/ordeal/src/mirror.rs, one
match arm per constructor), and the toolchain — Lean's kernel with its
three standard axioms, the pinned Charon/Aeneas translation of the Rust
source, and rustc. A consumer who checks an unsat bundle's certified
echo against their own script (ordeal echo-check, ordeal-cert/v5)
trusts, instead of the front ends and the mirror copy, the solver and
parser that decide that comparison, the script echo-check writes, and
the Lean model of SMT-LIB meaning the printer is proven against
(lean/EchoSpec.lean). The two pieces of
Rust are defended by tests at every width and by the differential against
Z3, not by proof; the translation by the TR-035 differential against Lean
core's own LRAT checker; Lean's kernel and rustc are assumed. Exact scope,
theorem by theorem:
docs/formal-verification.md.
| docs/consuming-ordeal.md | Using ordeal from a tool: API patterns, SAT witness, SBOM/VEX |
| ARCHITECTURE.md | The pipeline and the trust boundary |
| docs/formal-verification.md | What is proven, how, and what is not |
| CHANGELOG.md | What changed in each release |
| ROADMAP.md | How the plan is tracked (rivet) |
Building from source:
cargo build && cargo test
cargo build --target wasm32-wasip2 --release # the WebAssembly componentThe Z3 cross-check used in development is behind the off-by-default oracle
feature.
The PulseEngine tools ordeal's own workflow uses (rivet) are pinned as a
varve layer in varve.toml: varve install gives you exactly
the versions CI and the release job use.
| Project | Role |
|---|---|
| Loom | WASM optimizer with SMT verification |
| Synth | WASM-to-ARM AOT compiler with Rocq proofs |
| Ordeal | Certificate-checked QF_BV SMT solver |
| Meld | WASM Component Model static fuser |
| Kiln | WASM runtime for safety-critical systems |
| Sigil | Supply chain attestation and signing |
| varve | Toolchain layer manager: pinned, signed bundles of the tools above |
Apache-2.0. See LICENSE.
Part of PulseEngine — a WebAssembly Component Model engine for safety-critical systems