Research / Compiler, backends and verification

P48 · empirical · draft

Six Backends, One Semantics: A Conformance Matrix, Authored-Probe Differential Execution and a Cross-Tier Agreement Theorem

shipped evidence empirical Compiler, backends and verification

State of the work. The generated matrix, executor, drift gate and Lean theorem are on main; execution covers 19 of 61 constructs on three default tiers (rust and java behind a switch), the theorem is not yet bridged to the matrix, stream exit discipline is partial, and no divergence statistics exist.

This is a draft, not peer reviewed. Repository references link to revl at commit 45bec431f.

Planned to be combined with P49 (Type-Directed Cross-Tier Fuzzing With a Reference Oracle, an Honesty Classifier and a Delta-Debug Shrinker), P50 (Pinning the Semantics a Six-Target Compiler Silently Inherits: String Units, Sized and Trapping Integers, Total Division, Iteration Order and Injective Mangling) into a single paper.

Pitch

For a language that emits to six host runtimes, "the emitter did not raise" and "the output typechecks" both passed while tiers disagreed on values, so we state conformance as three questions, answer the third by running each executing tier (python, TypeScript and Go by default; rust and java behind a switch) against one authored literal, and prove under two named hypotheses when agreement must hold.

Abstract

A compiler that targets several host languages usually reports portability as a table of constructs that compile on each target. We show, from a six-target compiler (Python, TypeScript, Rust, Java, WebAssembly, Go), that this table certifies the wrong thing. We separate three questions: did the emitter produce code, does the code pass the target's real toolchain, and do the targets agree on what it evaluates to. For the third we give each executable case one authored answer written as a source literal and run it on each executing tier whose runtime is present (python, TypeScript and Go by default; rust and java behind a switch), so that three tiers agreeing on a wrong value also fails; a negative control shows a wrong literal is rejected. Today the generated matrix covers 61 constructs across six emitters plus the self-host column, 19 executed with a declared answer and 42 compile-only, each row labelled with its claim strength; a drift gate fails CI if the committed matrix is stale. A larger executed suite covers rust and java behind a slow-test switch, now set in one CI job. We log the semantic divergences found by execution (structural equality on three tiers, integer division on Java, among others), close them, and pin the remainder so a pinned case that starts to agree also fails. Finally we give a Lean proof that any two runtimes meeting two conditions lower a well-annotated IR to the same value, show the annotation hypothesis is necessary, and state that whether the real emitters meet the conditions is the matrix's empirical obligation.

Problem and claim

Compile-depth checks cannot see value divergence. In this project tsc --noEmit covered a TypeScript demo the whole time its runtime assertions failed, and Java typechecked Int / Int cleanly while answering 3 where every other tier answered 3.5 (docs/conformance.md, "The third question"). The spec said "no backend can diverge" on equality while two tiers did (docs/contract-errata.md:203-215).

Claim: cross-backend agreement is a testable contract with three levels of evidence, and each level must be reported separately: emitted, validates in toolchain, agrees on execution. Agreement must be anchored to an authored literal, because agreement among tiers is not correctness. A skipped test must never render as a pass, because the executing tiers in CI were, for a long period, empty.

Contributions

  1. A generated construct-by-tier matrix (61 constructs, six emitters plus the self-host column) with a CI drift gate and a per-row claim column (exec / compile-only with reason) (docs/conformance.md:96-120; tests/test_conformance_matrix.py).
  2. The three-question conformance model with explicit unavailable for a missing toolchain, never ok (docs/conformance.md, "Three questions, not one").
  3. Differential execution against an authored probe literal: 19 of 61 cases executed on Python, TypeScript and Go through tools/conformance.py --execute, plus the rust/java suite behind a switch; a negative control, which runs on the Python executor only (tests/test_conformance_execution.py:131).
  4. A Lean theorem: any two Conformant profiles lower a WellAnnotated IR to the same value, with annotation_necessary showing the hypothesis is load-bearing (formal/RevL/Theorems/CrossTier.lean:197-203, theorem at 203).
  5. A divergence discipline: semantic divergences found by execution are closed and logged; remaining ones are pinned and a pinned case that meets the ideal fails (docs/contract-errata.md:203; tests/test_cross_tier_execution.py:757,932; tck/README.md, "Pinned divergences").
  6. Stream surfaces lower or refuse by name on each tier (partial; see "Evidence on main").

Evidence on main

Claimpath:line or testStatusNote
Generated matrix, six emitters + revl column, drift gatedocs/conformance.md:1-40, docs/conformance.md:96-120; tests/test_conformance_matrix.pyshipped61 constructs emitted, 1 rejected by frontend
Per tier results: py/ts/rust 61 ok, java 60, go 60, wasm 51 (10 deliberate limits), revl 59; 0 real gapsdocs/conformance.md:96-108shippedGenerated block
Three-question model; unavailable not okdocs/conformance.md:288-310 (section "Three questions, not one")shipped
19 executed on py, ts, go with one authored literaldocs/conformance.md:110-115, docs/conformance.md:175-200; tools/conformance.py:347 (PROBES); tests/test_conformance_execution.py:65shippedThe executor table lists three tiers, not six
Negative controltests/test_conformance_execution.py:131-145shippedThe test runs the control on the Python executor only
rust and java execution behind REVL_CROSS_TIER_SLOWtests/test_cross_tier_execution.py:1-60; .github/workflows/ci.yml:2262-2292shippedSet in the conformance job
Silent skips guardedtests/test_env_gated_skips_run_somewhere.py:10-30,792shipped
Divergences closed and pinneddocs/contract-errata.md:203-260; tests/test_cross_tier_execution.py:757-800, tests/test_cross_tier_execution.py:932-960shipped (closure); pinning is empty hereThe DIVERGENCES table is empty after #549 per its own comment (tests/test_cross_tier_execution.py:778-782), so the pinned-case drift test has no cases; pinned divergences are described in tck/README.md
TCK with R1-R5, A1/A5/A8, G7 cases and pinned divergencestck/README.md:1-60shipped (doc read; runner not opened)A2-A4, A6-A7 listed as pending, never green
Cross-tier agreement theoremformal/RevL/Theorems/CrossTier.lean:203 (cross_tier_agreement), formal/RevL/Theorems/CrossTier.lean:252 (six_tier_agreement), formal/RevL/Theorems/CrossTier.lean:262 (annotation_necessary); formal/STATUS.md:597-615, formal/STATUS.md:299-302shippedNo sorry (formal/STATUS.md:597-615). Per formal/STATUS.md:299-302, cross_tier_agreement, six_tier_agreement and conformance_hypotheses_are_inhabited use propext, and annotation_necessary uses no axioms; map values one level deep
Stream surfaces lower or refuse by namedocs/v2.0-roadmap.md:1374 (item 130); backends/rust/emit.py:4259 (_refuse_unlowered_stream_surface); tests/test_stream_reactive.pypartialItem 130 says a pull request lowers the last-n replay backlog on ts, go and java with the durable cursor still refused by name there, and that rust refuses both replay forms. No test lists every stream surface per tier
Backend IR errata: ship order, normative lowering strategydocs/contract-errata.md:1-28shipped

Numbers that exist

Paper outline

  1. Introduction: portability claims that pass while values differ.
  2. The architecture: one IR, six emitters, host runtimes.
  3. Three questions and the generated matrix, claim column, unavailable.
  4. Authored-probe differential execution; the unanimous-wrong case; the negative control.
  5. What execution found: equality, integer division, float edges; closure and pinning discipline.
  6. Making skips visible: the gates that executed nowhere.
  7. A cross-tier agreement theorem and its two hypotheses; what stays empirical.
  8. Evaluation: divergence count by mechanism, counterfactual mutants.
  9. Limits, related work.

Threats to validity and limits

Fact-check

Claims in this draft were checked against revl main at commit 45bec431f: about 45 checked, 9 corrected.

Cite this draft

@misc{revlp48,
  author       = {Thomas Moussajee},
  title        = {Six Backends, One Semantics: A Conformance Matrix, Authored-Probe Differential Execution and a Cross-Tier Agreement Theorem},
  year         = {2026},
  howpublished = {\url{https://inso1337.github.io/revl/research/P48.html}},
  note         = {Research draft, not peer reviewed. Written against revl commit 45bec431f. Licensed CC BY 4.0.}
}

Text licensed CC BY 4.0, author Thomas Moussajee.

← All research drafts