Skip to main content

Crate ordeal

Crate ordeal 

Source
Expand description

§Ordeal

ordeal (meaning “verdict / judgment”) is a specialized, certificate-checked QF_BV SMT solver for the PulseEngine toolchain. It exists to replace the Z3 static-link build pain that loom (verified WASM optimizer) and synth (verified WASM→ARM codegen) carry today — grounding: loom issue #246.

§Design in one paragraph

An untrusted solver emits a machine-checkable LRAT UNSAT certificate; a small formally-verified checker validates it. Only the checker is trusted (the CompCert certifying-algorithm pattern; blueprint = Lean 4 bv_decide, OOPSLA 2025). Z3 is demoted to a differential oracle and benchmark rival, not the production engine. The pipeline is: term graph → bit-blast → AIG → CNF (Tseitin) → SAT → LRAT → verified checker.

§Modules

  • term — the closed QF_BV fragment (the exact loom #246 op set).
  • lowering — blessed derived-op constructors (bvnot, bvneg, bvrotl, bvurem, bvsdiv, bvsrem) built over the closed core, for the ops synth-verify emits but the fragment omits (DES-018).
  • solver — the one-shot check-sat interface and result types.
  • eval — the concrete evaluator (executable SMT-LIB semantics; the test oracle for every blasting rule and the SAT-model self-check).
  • aig — the And-Inverter Graph arena (structural hashing, folding).
  • blast — per-op-family bit-blasting rules (term → AIG).
  • cnf — CNF types and the Tseitin encoder (AIG → CNF).
  • sat — the pure-Rust CDCL core (primary engine on every target).
  • lrat — LRAT certificate emission from the CDCL proof trace; the ordeal-lrat crate (the sole trusted component) validates it before any Unsat is returned.
  • [oracle] — the Z3 differential oracle (behind the oracle feature).
  • smtlib — a minimal QF_BV SMT-LIB2 reader for the standalone CLI / differential harness (not the production interface; that stays the API).

Re-exports§

pub use query::QueryCheckResult;
pub use query::SliverCheckResult;
pub use query::TermCheckResult;
pub use solver::CheckResult;
pub use solver::Solver;
pub use term::BoolTerm;
pub use term::BvTerm;
pub use term::Sort;
pub use witness::WitnessCheckResult;

Modules§

aig
And-Inverter Graph with structural hashing and constant folding (DES-002).
blast
Bit-blasting (DES-005..DES-009): the per-rule bridge to the Lean-proven rules — since issue #192 phase 3 a TEST harness, not the production path.
canon
Semantics-preserving canonicalization above the AIG (issue #35 / TR-009).
cnf
CNF representation and the Tseitin encoder (DES-003).
echo
The certified query echo in a certificate (#281 E2, ordeal-cert/v5): re-exported from the solver-free ordeal-cert crate. The certified query echo a v5 bundle carries (#281 E2): EchoCertificate, printed and re-derived by the trusted printer. The certified query echo in a certificate (issue #281, phase E2): the SMT-LIB text the trusted printer (ordeal_lrat::echo_term / echo_ext, proven in lean/Echo.lean) makes of a bundle’s term or ext block, carried next to the certificate so a consumer can compare it with its own input (ordeal-cert/v5, crate::cert_bundle).
eval
Concrete evaluator for the closed QF_BV fragment — the executable SMT-LIB semantics (DES-001).
layout
Byte-layout helpers (TR-021): split a bitvector into little-endian bytes and reassemble it, as pure extract/concat compositions over the closed fragment — no new operations.
lowering
The formerly derived ops: constructors and the core-fragment REWRITE (DES-018 / TR-015; proven DAG constructs since #192 phase 5, TR-064).
lrat
LRAT certificate emission from the CDCL proof trace (DES-013).
mirror
The copy of the caller’s trees into the kernel’s tree type (TR-073): the one trusted step of the term direction, a bijection. The copy of the caller’s trees into the kernel’s tree type (TR-073).
query
The certificate-carried query (#192 phase 4, ordeal-cert/v2) — always compiled; the JSON envelope is in cert_bundle. The certificate-carried query (issue #192 phase 4, ordeal-cert/v2): the term DAG the solver lowered, kept next to the certificate so that a consumer re-checks the QUERY, not a CNF it has to take on faith.
sat
The pure-Rust CDCL SAT core (DES-004) — primary engine on every target.
sha256
In-tree SHA-256 for ordeal-cert/v1 content hashes (#162 / TR-045): integrity only, never part of the soundness argument. SHA-256 (FIPS 180-4), in-tree and dependency-free (#162 / TR-045). Since TR-075 the implementation lives in the solver-free ordeal-cert crate (ordeal_cert::sha256), re-exported here unchanged; the known-answer tests stay here.
sliver
The loom array/UF sliver (P3) — an extended query layer that is preprocessed away into the closed QF_BV core before bit-blasting.
smtlib
A minimal QF_BV SMT-LIB2 front end (FEAT-006 / loom field-report #34).
solver
The one-shot solver interface and the P1 pipeline dispatcher (DES-012).
term
The ordeal term language: the closed QF_BV fragment from loom issue #246.
trap
WASM trap / partiality semantics (issue #59 / TR-019).
verus
Verus VC ingestion: lift by (bit_vector) obligations out of a Verus SMT log so the obligation Verus actually checked is discharged with a re-checkable certificate (TR-023 / FEAT-009, issue #65).
witness
The re-checkable SAT witness (TR-038) — always compiled. The independently re-checkable SAT witness (TR-038 / #133). Since TR-075 the witness type and its trusted recheck live in the solver-free ordeal-cert crate (ordeal_cert::witness), re-exported here unchanged; the solver’s verdict type stays.

Structs§

Certificate
A machine-checkable UNSAT certificate — a self-contained, portable proof object.
EchoCertificate
A term-carrying certificate together with the certified echo of its question (#281 E2, ordeal-cert/v5).
Model
A satisfying assignment (counterexample) for a SAT query.
QueryCertificate
A certificate together with the query it certifies (issue #192 phase 4): the v1 pair (certificate.cnf, certificate.lrat) plus the lowered QueryDag. QueryCertificate::recheck is the stronger re-check: the trusted crate re-encodes the DAG itself and checks the proof against the CNF it produced, so an accepted re-check proves the DAG unsatisfiable — kernel.spec.check_query_sound.
QueryDag
The lowered query: exactly the inputs the proven lowering (and the trusted re-check) consumes.
QueryEcho
The echo block of an ordeal-cert/v5 bundle: the printed text and the logic its first line declares.
QueryInputs
The DAG’s primary-input assignment a SAT verdict is re-checked with (issue #192 phase 6, TR-065): what the trusted ordeal_lrat::check_query_model consumes, plus the untrusted map from the model’s named variables to the Var nodes that read those bits.
QuerySatCertificate
A SAT witness together with the query it satisfies (issue #192 phase 6): the v1 SatCertificate (model, CNF, assignment, bit map) plus the lowered QueryDag and the DAG’s input assignment (QueryInputs). QuerySatCertificate::recheck is the stronger re-check: the trusted crate evaluates the DAG itself under the inputs (ordeal_lrat::check_query_model), so an accepted re-check proves the DAG satisfiable — kernel.spec.check_query_model_sound, in the same semantics check_query_sound negates. The SAT twin of QueryCertificate.
QueryTerm
The term a v3 certificate is about (#192 phase 7): what the caller asserted, flattened, plus the untrusted index map from its nodes to the lowered QueryDag’s. The trusted ordeal_lrat::check_term_dag verifies, node by node along the map, that the DAG is a semantics-preserving rewrite of this term — the two rewrites canonicalization makes (a commutative swap, a comparison mirror), a constant fold (evaluated by the proven encoder and simulator) and hash-consing (the map itself) — so a consumer that compares this block with its own query certifies the QUESTION, not the solver’s DAG.
SatCertificate
An independently re-checkable SAT verdict — the SAT twin of Certificate (TR-038 / #133, docs/design/sat-witness.md): the model, the CNF it satisfies, the FULL satisfying assignment (inputs and Tseitin auxiliaries), and the map from each model variable’s bits to signed CNF literals. SatCertificate::recheck re-establishes the verdict via the trusted ordeal-lrat crate with zero solver trust: every clause is checked satisfied, and every advertised model binding is checked consistent with the assignment.
SliverBlock
The ext block of an ordeal-cert/v4 bundle (TR-072): the extended query as asked (ExtQuery) plus the untrusted map from its nodes to the lowered core’s (QueryTerm with TERM_ENCODING_V2) and the untrusted read and call tables — everything ordeal_lrat::check_sliver_lowering verifies.
SliverCertificate
An UNSAT certificate about an EXTENDED query (TR-072, ordeal-cert/v4): the v3 term certificate about the lowered core, plus the ext block relating that core to the query as asked. SliverCertificate::recheck is the strongest re-check: the trusted crate relates the extended query to the core (check_sliver_lowering), the core to the DAG (check_term_dag) and refutes the DAG (check_query), so an accepted re-check proves the EXTENDED query unsatisfiable under every array and UF interpretation — kernel.spec.check_sliver_unsat_sound.
SliverSatCertificate
A SAT witness about an EXTENDED query (TR-072, ordeal-cert/v4): the v3 SAT certificate about the lowered core, the ext block, and the extended model the core model pulls back to (SliverBlock::pullback_model). An accepted SliverSatCertificate::recheck proves the EXTENDED query satisfied by an interpretation built from the model — kernel.spec.check_sliver_model_sound.
TermCertificate
An UNSAT certificate together with the query it refutes AND the term that query was lowered from (#192 phase 7, ordeal-cert/v3). TermCertificate::recheck is the strongest re-check: the trusted crate relates the term to the DAG (check_term_dag) and refutes the DAG (check_query), so an accepted re-check proves the TERM unsatisfiable — kernel.spec.check_term_unsat_sound.
TermSatCertificate
A SAT witness together with the query it satisfies AND the term that query was lowered from (#192 phase 7, ordeal-cert/v3). TermSatCertificate::recheck relates the term to the DAG (check_term_dag), evaluates the DAG under the inputs (check_query_model) and, new, ties every advertised model value to the inputs with the proven var_offset / check_input_value through the term’s own variable map — so an accepted re-check proves the TERM satisfied by the advertised model (check_term_model_sound, and the only untrusted step left is the variable’s name).

Enums§

CertificateError
Why an independent Certificate::recheck could not confirm the proof.
EchoRecheckError
Why an EchoCertificate::recheck did not accept.
EchoSubject
The certificate an ordeal-cert/v5 bundle carries the echo of: one of the four term-carrying kinds, told apart by verdict and by whether an ext block is present.
QueryModelRecheckError
Why a QuerySatCertificate::recheck could not confirm the model.
QueryRecheckError
Why a QueryCertificate::recheck could not confirm the proof.
SatRecheckError
Why a SAT witness recheck failed.
SliverModelRecheckError
Why a SliverSatCertificate::recheck could not confirm the model.
SliverRecheckError
Why a SliverCertificate::recheck could not confirm the proof.
TermModelRecheckError
Why a TermSatCertificate::recheck could not confirm the model.
TermRecheckError
Why a TermCertificate::recheck could not confirm the proof.