Expand description
Formal Verification for Synth Compiler
This crate provides SMT-based translation validation and property-based testing to formally verify the correctness of WebAssembly-to-native synthesis.
§Architecture
The verification system proves that synthesized native code has
semantically equivalent behavior to the input WASM code, discharging the
QF_BV queries through a thin solver trait (solver::BvSolver, #553):
- Default engine:
ordeal— pure Rust, certificate-checked (everyUnsatverdict carries an LRAT proof validated by the trustedordeal-lratchecker). No C++ toolchain required. - Differential oracle (feature
z3-solver): Z3, the former engine. With both backends compiled in andSYNTH_SOLVER_DIFF=1, every query runs through both — a verdict disagreement is a hard error; an ordealUnknownfalls through to Z3’s verdict.
§Backend-Agnostic Traits
SourceSemantics and TargetSemantics traits allow any backend to provide
SMT semantics. The ARM semantics are one implementation, behind the arm
feature. All semantics encode into the solver-agnostic term::BV /
term::Bool terms.
§Translation Validation
For each synthesis rule WASM → target, we construct SMT formulas:
- φ_wasm: Semantics of WASM operations
- φ_target: Semantics of generated target operations
- Prove: ∀inputs. φ_wasm(inputs) ⟺ φ_target(inputs)
Re-exports§
pub use properties::CompilerProperties;pub use arm_semantics::ArmSemantics;pub use arm_semantics::ArmState;pub use expansion_validator::ExpansionError;pub use expansion_validator::ExpansionWitness;pub use expansion_validator::covered_i64_pseudo_selections;pub use expansion_validator::validate_expansion;pub use fact_spec::FactSpecResult;pub use fact_spec::specialize_function;pub use solver::BvSolver;pub use solver::CheckOutcome;pub use solver::OrdealSolver;pub use solver::new_solver;pub use term::BV;pub use term::Bool;pub use translation_validator::CallIndirectSpec;pub use translation_validator::TranslationValidator;pub use translation_validator::ValidationResult;pub use translation_validator::VerificationError;pub use validator_pattern::CertifiedSelection;pub use validator_pattern::SolverResultKind;pub use validator_pattern::ValidationError as PatternValidationError;pub use validator_pattern::Validator;pub use validator_pattern::Witness;pub use validator_pattern::Z3ArmValidator;pub use wasm_semantics::WasmSemantics;
Modules§
- addr
- Static-data addressing validation (VCR-VER-003, synth #777 / #757).
- arm_
semantics - ARM Semantics Encoding to SMT
- expansion_
validator - Expansion-level certifying validation for the i64 pseudo-ops (#667 move 2).
- fact_
spec - Proof-carrying specialization — VCR-PERF-002 / #494 Phase 2: the
single-elision prototype (value-range facts ⇒ dead conditional-branch
elision, the
gust_mixclamp shape). - properties
- Property-Based Testing for Compiler Correctness
- solver
- The thin solver trait behind which the SMT engines sit (#553).
- term
- Solver-agnostic bitvector / boolean term types (#553).
- traits
- Verification traits for backend-agnostic translation validation
- translation_
validator - Translation Validator - Proves equivalence between WASM and ARM code
- trap
- Trap-preservation obligations (VCR-VER-002, synth #166 / ordeal#59).
- validator_
pattern - Validator-Pattern Verification (Issue #76)
- wasm_
semantics - WASM Semantics Encoding to SMT
Structs§
- Addr
Mismatch - A single reloc that reads the wrong byte.
- Data
Segment - One active WASM data segment: its linear-memory offset and its bytes, in
declaration order. The packed
.datablob stores these bytes verbatim (4-aligned per segment) under__synth_wasm_seg_K; indexKin the segment list is theKin the symbol name. - Reloc
Resolution - The retargeting the compiler emitted for one static-data relocation: it now
points at
__synth_wasm_seg_{seg_index} + addend.seg_indexis theKfrom the emitted symbol name;addendis the emitted in-place REL addend (= original_access_addr - seg[K].linmem_off). This is the value read back from what the compiler produced — NEVER recomputed by the validator (that would mirror-pin the check and make it vacuous).
Enums§
- Addr
Verdict - The verdict of the addressing gate.
Functions§
- resolve_
owner - Resolve an access address
cto its owning segment index under a chosen tie-break policy, mirroring main.rs’s.rposition()/.position()search.last_wins = trueis the CORRECT WASM overwrite semantics (.rposition());last_wins = falseis the #757 miscompile (.position()). Returns the segment index and the addendc - seg.linmem_off, orNoneifcis in no segment. Exposed so the red-first gate can toggle the policy as an argument (no source revert), and so callers can build resolutions the same way the compiler does. - validate_
reloc_ resolutions - The per-compilation addressing gate. For every emitted
RelocResolution, assert the packed byte it serves equals the runtime-image byte at the original access address. See the module docs for the invariant. - with_
verification_ context - Run verification operations in a configured context.