docs.rs failed to build synth-verify-0.7.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
synth-verify - Formal Verification for Synth Compiler
Formal verification infrastructure for the Synth WebAssembly-to-ARM compiler using SMT-based translation validation.
Overview
This crate provides:
- SMT-based translation validation using Z3 SMT solver
- Formal semantics for WebAssembly and ARM operations
- Property-based testing framework with proptest
- Automated verification of synthesis rules
Architecture
synth-verify/
├── wasm_semantics.rs # WASM → SMT encoding (25+ operations)
├── arm_semantics.rs # ARM → SMT encoding (processor state model)
├── translation_validator.rs # Equivalence prover (Alive2-inspired)
└── properties.rs # Property-based tests (50+ properties)
Usage
Verifying a Synthesis Rule
use ;
use ;
// Create Z3 context
let ctx = create_z3_context;
let validator = new;
// Define a synthesis rule
let rule = SynthesisRule ;
// Verify the rule
match validator.verify_rule
Batch Verification
// Verify multiple rules
let rules = vec!;
let results = validator.verify_rules;
for in results
Property-Based Testing
use CompilerProperties;
use *;
proptest!
Verification Approach
Translation Validation
For each synthesis rule WASM_OP → ARM_OPS, we prove:
∀inputs. ⟦WASM_OP⟧(inputs) = ⟦ARM_OPS⟧(inputs)
Using SMT solver:
- Create symbolic inputs
- Encode WASM semantics:
φ_wasm - Encode ARM semantics:
φ_arm - Assert:
φ_wasm ≠ φ_arm - Check satisfiability:
- UNSAT → Proven correct
- SAT → Counterexample found
- UNKNOWN → Timeout
Example: ADD Verification
; Symbolic inputs
(declare-const a (_ BitVec 32))
(declare-const b (_ BitVec 32))
; WASM: i32.add
(define-fun wasm-add () (_ BitVec 32)
(bvadd a b))
; ARM: ADD R0, R0, R1
(define-fun arm-add () (_ BitVec 32)
(bvadd a b))
; Prove equivalence
(assert (not (= wasm-add arm-add)))
(check-sat) ; Returns: unsat → Proven!
Verified Operations
| Operation | Status | Method |
|---|---|---|
| i32.add | ✓ Proven | SMT |
| i32.sub | ✓ Proven | SMT |
| i32.mul | ✓ Proven | SMT |
| i32.div_s | ✓ Proven | SMT |
| i32.div_u | ✓ Proven | SMT |
| i32.and | ✓ Proven | SMT |
| i32.or | ✓ Proven | SMT |
| i32.xor | ✓ Proven | SMT |
| i32.shl | ⚠ Partial | Complex |
| i32.shr_u | ⚠ Partial | Complex |
| i32.shr_s | ⚠ Partial | Complex |
Dependencies
Required
- z3 - Z3 SMT solver Rust bindings (v0.12)
- synth-synthesis - Synthesis rules and operations
- proptest - Property-based testing
System Requirements
Z3 requires either:
- System installation:
libz3-devorz3package - Static linking: Built automatically (requires C++ compiler)
For development without Z3:
# Skip tests that require Z3
Testing
# Run all tests (requires Z3)
# Run specific test suites
# Property-based testing with more cases
PROPTEST_CASES=10000
Performance
- Verification time: 50-500ms per rule (SMT solving)
- Memory usage: ~50MB (Z3 context)
- Scalability: Linear in number of rules
Limitations
- Shift operations: Modulo handling complex for SMT
- Control flow: Branch verification requires extended modeling
- Memory operations: Requires memory model formalization
- Floating point: Not yet supported
Future Work
Phase 1: Complete SMT Coverage
- Shift operation verification
- Control flow (branches, conditions)
- Memory operations (load/store)
Phase 2: Optimization Verification
- DCE, constant folding, CSE correctness
- Loop optimization soundness
- Register allocation preservation
Phase 3: Mechanized Proofs
- Port to Coq proof assistant
- Machine-checked correctness
- Certified synthesis rule library
References
- Alive2: Automated LLVM verification (Lopes et al., PLDI 2021)
- CompCert: Verified C compiler (Leroy, POPL 2006)
- VeriISLE: Verified instruction selection (Nandi et al., PLDI 2020)
- Z3: Efficient SMT solver (de Moura & Bjørner, TACAS 2008)
License
Dual-licensed under Apache-2.0 OR MIT
Authors
PulseEngine Team