Source-to-Source Encoding Correctness
The central correctness statement (2026-06-04) for the double-vision elaboration: a single-vision source-to-source encoding faithfully captures the double-vision rule.
The core claim
For a double-vision recursive module accepted by
E-Typ-Rec-Double-Rec, the generated single-vision source encoding typechecks iff the two remaining double-vision obligations are satisfied: premise (5) is exactly the typing of the generated functor bodiesF1/F2under the strengthened internal view; premise (6) is exactly the final ascription/subtyping check when exportingI.X1/I.X2back to the external signaturesS1/S2. The intermediate recursive packageI : Stris intentionally transparent; the abstraction boundary is restored only by the finalmodule rec X1 : S1 = I.X1 and X2 : S2 = I.X2export.
Proof-sketch skeleton
- Translation invariant.
Stris the transparent internal recursive signature from the static pass + locator anchoring; generatedF_ipackage component bodies behind functor arguments, so each body sees its own strengthened internal view and only the external view of siblings. - Premise (5) ⇒ functor-body typing. By thm:locator-anchor, each
anchor_L(τ_k)elaborates to the same canonical substitution as the lookup equations in premises (3)–(4); so checkingsM_iin the double-vision rule is the same derivation as checkingF_i’s body byE-Typ-Mod-AppFct. Iis not where sealing happens.I = rec I : Str { X1=F1(I); X2=F2(I) }checks by single vision becauseStrexposes all witnesses; the argument coercion is a refinement check.- Premise (6) ⇒ final export. Projection
I.X1has transparent signatureCup;E-Typ-Mod-AscragainstS1requires exactly the subtyping judgment of premise (6). Symmetric forX2/S2. - Conservativity / abstraction.
Strexposes the internal view only insideI; generated functors stop components observing siblings’ private strengthening; final ascription hides the concrete view externally.
Open framing choices
- iff vs preservation-reflection for encoding correctness — call the result an iff/equivalence, or only preservation + reflection of obligations?
- Applicative vs generative encoding barrier — the
()barrier for the generative variant.
Proofs (draft, for review)
Case-by-case proof attempt: the Modrec Proof Dossier —
specifically Proof - Encoding adequacy iff (the iff above, with the two
null-check lemmas), consuming Proof - Locator anchoring roundtrip and
Proof - Double vision elaboration soundness. Caveat surfaced by the proof:
the iff holds only on the double-vision fragment (where the static pass
leaves Str fully transparent); this precondition needs adding to
manual.tex:4956.
Related
Double-Vision Recursive Modules · Locator-Anchored Signatures · Partial Recursive Signatures · project notes Source-to-source Encoding Examples Audit, Recursive Modules Paper Writing Log