1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//! 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
//! (every `Unsat` verdict carries an LRAT proof validated by the trusted
//! `ordeal-lrat` checker). No C++ toolchain required.
//! - **Differential oracle** (feature `z3-solver`): Z3, the former engine.
//! With both backends compiled in and `SYNTH_SOLVER_DIFF=1`, every query
//! runs through both — a verdict disagreement is a hard error; an ordeal
//! `Unknown` falls 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)
// Solver-agnostic terms + the thin solver trait (always available)
// Trap-preservation obligations over `ordeal::trap` (VCR-VER-002, #166): maps
// WASM partial ops (div/rem, load/store, call_indirect, unreachable,
// float→int trunc) to trap
// conditions and gates a lowering on preserving them. Backend-agnostic (builds
// on `term`), so always available like `wasm_semantics`.
// Static-data addressing validation (VCR-VER-003, #777 / #757): per-compilation
// concrete byte-equality that every static-data reloc resolves to the
// runtime-correct byte (active segments applied in declaration order,
// later-wins). Catches the overlapping-segment wrong-segment miscompile at
// compile time. Backend-agnostic concrete checking, so always available.
// Verification traits (always available)
// WASM semantics — source language for all backends (always available)
// Proof-carrying specialization (VCR-PERF-002 / #494 Phase 2): value-range
// facts ⇒ dead conditional-branch elision, each site behind a per-elision
// ordeal obligation. Backend-agnostic (rewrites the WasmOp stream), so it is
// always available like `wasm_semantics`.
// ARM semantics (behind the arm feature)
// Translation validator (requires arm for the existing concrete implementation)
// Validator-pattern prototype (issue #76 — CompCert-style certifying
// validator scaffolding; see docs/validator-pattern.md).
// Expansion-level certifying validation for the i64 pseudo-ops (#667 move 2):
// decodes the SHIPPED encoder's emitted Thumb-2 bytes and proves them
// equivalent to the WASM op — see docs/validator-pattern.md.
// Property-based testing (requires arm: exercises the ARM synthesis rules)
pub use CompilerProperties;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use WasmSemantics;
/// Run verification operations in a configured context.
///
/// With the default (ordeal) engine this is a plain call — the pure-Rust
/// solver needs no global context. With the `z3-solver` feature compiled in,
/// it additionally configures the Z3 thread-local context (30-second timeout,
/// model generation) so the differential oracle is ready.
/// Run verification operations with a configured Z3 context.
///
/// Z3 0.19 uses thread-local context — this function configures it
/// with a 30-second timeout and model generation enabled.
/// Create a Z3 solver with default configuration (differential-oracle use)