Repository navigation
TG-6: WASM compilation preserves semantics (compiler-correctness theorem) #27
Copy link
Copy link
Open
Labels
bindingsABI, FFI, WASM, and cross-language interop surfacesABI, FFI, WASM, and cross-language interop surfacesenhancementNew capability or improvement to existing behaviourNew capability or improvement to existing behaviourfeeds:valence-shellFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes thereFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes therepriority:p3Low - nice to haveLow - nice to haveproofsFormal verification: Agda, Coq, Idris, Lean, Z3/SMT, axiom debtFormal verification: Agda, Coq, Idris, Lean, Z3/SMT, axiom debtscope:repoConfined to this repositoryConfined to this repository
Description
Source: PROOF-NARRATIVE.md §3 TG-6.
Claim
For every closed well-typed e, the source-level evaluation of e and the WASM execution of compile_to_wasm(e) agree on the observable result.
Why valuable
This is the compiler-correctness theorem for the WASM backend. Without it, the structural reasoning Tangle claims means "something" on the runtime is unverified. Currently a trust-us claim.
Aligns with the broader estate typed-wasm proof-debt arc (project_typed_wasm_proof_debt_post_a10) and the WasmCert-Isabelle tie-back referenced there.
Assumptions
[[A-TG-6.1]]Standard WASM small-step semantics is well-defined (wasm-spec / WasmCert-Isabelle).[[A-TG-6.2]]Source semantics has no floating-point non-determinism (Tangle has onlyIntcurrently).
Acceptance criteria (research-grade; expect multiple PRs)
- Mechanise (in Lean) a small-step semantics for the WASM subset emitted by
compile_to_wasm— or reuse WasmCert if it can be imported. - State the bisimulation invariant:
R(e, w)holds iff WASM statewrepresents source expressione. - Prove forward bisimulation:
R(e, w) ∧ e ⟶ e' ⟹ ∃ w'. w ⟶* w' ∧ R(e', w'). - Prove backward bisimulation:
R(e, w) ∧ w ⟶ w' ⟹ ∃ e'. e ⟶* e' ∧ R(e', w'). - Corollary: observable equality.
- No new
axiom/sorry/postulate.
Effort
3+ weeks (research-grade). Comparable to CompCert's WASM backend work. Should be staged:
- State of the art audit (1w): see WasmCert-Isabelle, typed-wasm a13+ proofs.
- Subset selection (1w): which WASM subset is actually emitted; restrict bisimulation accordingly.
- Mechanisation (2-3w per phase).
Suggested phasing
- Phase A: Pure arithmetic (no braids). Prove that
AddandEqlower correctly. - Phase B:
BraidLitlowering. Bytewise equality between source AST and the WASM-emitted braid representation. - Phase C:
ComposeandTensorlowering. Algebraic equivalence using T-WidthAppend and T-WidthShift. - Phase D:
Close. The semantic move fromword ntoword 0.
Relationship to other obligations
- Depends on TG-2 (decidability of type checking) for the source-side termination of evaluation.
- Independent of TG-1 (let-binding) but the lowering should be extended in lockstep.
Out of scope
- WASM cross-platform determinism (covered by the WASM spec itself).
- Linking-level correctness (this is a single-module property).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bindingsABI, FFI, WASM, and cross-language interop surfacesABI, FFI, WASM, and cross-language interop surfacesenhancementNew capability or improvement to existing behaviourNew capability or improvement to existing behaviourfeeds:valence-shellFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes thereFeeds valence-shell's proofs/engineering (D127): judge progress by what it contributes therepriority:p3Low - nice to haveLow - nice to haveproofsFormal verification: Agda, Coq, Idris, Lean, Z3/SMT, axiom debtFormal verification: Agda, Coq, Idris, Lean, Z3/SMT, axiom debtscope:repoConfined to this repositoryConfined to this repository
Activity