Papers
Topics
Authors
Recent
Search
2000 character limit reached

Convertibility Soundness Theorem

Updated 6 April 2026
  • Convertibility Soundness Theorem is a formal framework that rigorously defines reliable type conversions across languages using well-defined conversion rules.
  • It specifies declarative convertibility judgments and target-level glue code to mediate cross-language type conversions, handling dynamic conversion errors.
  • The theorem is validated with a step-indexed logical relation, establishing foundational semantic soundness for interoperable multi-language systems.

The Convertibility Soundness Theorem provides a rigorous basis for reasoning about type soundness when multiple programming languages interoperate after compilation to a shared, untyped target. The theorem formalizes the reliability of type conversions across language boundaries, ensuring that target-level glue code correctly mediates types as specified by an interoperability relation, and that any dynamic errors are well-defined. Originally introduced in the context of the semantic framework for language interoperability, the theorem establishes that for any pair of source types declared convertible, the realized conversions preserve intended behaviors and invariants up to dynamically signaled conversion errors, providing the foundation for semantic type soundness of multi-language systems (Patterson et al., 2022).

1. Declarative Convertibility Judgment

Type conversions across language boundaries are formalized by a declarative convertibility judgment. Given two types, τA\tau_A and τB\tau_B, the relation τAτB\tau_A \sim \tau_B specifies they are mutually convertible, possibly with certain well-defined dynamic failures. Typing rules for conversion are:

  • If Γe:τA\Gamma \vdash e : \tau_A and τAτB\tau_A \sim \tau_B, then ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B.
  • The symmetric rule holds for conversion from τB\tau_B to τA\tau_A.

The specific convertibility rules are defined by the interoperator and depend on the types and languages. In the shared-memory case study—using RefHL and RefLL, both compiling to StackLang—examples include:

Convertibility Rule Description Special Notes
Bool \sim Int Boolean \leftrightarrow Integer Same representation
Ref Bool τB\tau_B0 Ref Int Reference to Bool τB\tau_B1 Reference to Int Identical pointers
τB\tau_B2 Sums τB\tau_B3 2-tagged Int arrays Requires payload conversion

All such rules are made explicit in the system [(Patterson et al., 2022), Fig. 4].

2. Target-Level Glue Code

For every declarative convertibility rule τB\tau_B4, a pair of target-level glue-code sequences τB\tau_B5 and τB\tau_B6 implement the actual conversions in the compiled, untyped target language. Representative glue-code implementations in the shared-memory case study include:

  • τB\tau_B7 (no-op, as Bool and Int are identical),
  • τB\tau_B8 (identical pointers),
  • τB\tau_B9 involves tagging arrays and recursively converting payloads,
  • τAτB\tau_A \sim \tau_B0 performs tag inspection, array length checks, payload conversion, or issues a dynamic error fail Conv on out-of-range cases.

These glue-code mappings constitute the operational mechanism for cross-language type conversions at the target level (Patterson et al., 2022).

3. Semantic/Realizability Model

Type soundness is justified by interpreting source types and terms semantically over target terms using a step-indexed logical relation.

  • Worlds τAτB\tau_A \sim \tau_B1 pair a step-budget τAτB\tau_A \sim \tau_B2 with a heap typing τAτB\tau_A \sim \tau_B3, allowing for resource-aware semantics.
  • Value interpretation τAτB\tau_A \sim \tau_B4 defines the set of target representations of source type τAτB\tau_A \sim \tau_B5 in world τAτB\tau_A \sim \tau_B6. For example:
    • τAτB\tau_A \sim \tau_B7,
    • τAτB\tau_A \sim \tau_B8,
    • τAτB\tau_A \sim \tau_B9.
  • Expression interpretation Γe:τA\Gamma \vdash e : \tau_A0 comprises pairs Γe:τA\Gamma \vdash e : \tau_A1 such that running program Γe:τA\Gamma \vdash e : \tau_A2 in any heap Γe:τA\Gamma \vdash e : \tau_A3 either diverges safely or terminates within Γe:τA\Gamma \vdash e : \tau_A4 steps, carrying a value in Γe:τA\Gamma \vdash e : \tau_A5 or a conversion error.

The Fundamental Property states that any well-typed source-term Γe:τA\Gamma \vdash e : \tau_A6 compiles to Γe:τA\Gamma \vdash e : \tau_A7 with Γe:τA\Gamma \vdash e : \tau_A8.

4. Statement and Proof of Convertibility Soundness Theorem

The Convertibility Soundness Theorem asserts the semantic validity of all specified conversions:

Theorem (Convertibility Soundness):

If Γe:τA\Gamma \vdash e : \tau_A9 then:

  • For all τAτB\tau_A \sim \tau_B0, τAτB\tau_A \sim \tau_B1;
  • For all τAτB\tau_A \sim \tau_B2, τAτB\tau_A \sim \tau_B3.

Formally,

τAτB\tau_A \sim \tau_B4

Proof is by induction on the derivation of τAτB\tau_A \sim \tau_B5, proceeding case-by-case over the conversion rules. Each case uses the correctness of glue-code, the realizability model, and often the monotonicity of interpretations under world extension. A critical case is τAτB\tau_A \sim \tau_B6, justifying the correctness of the no-op glue-code for references since τAτB\tau_A \sim \tau_B7.

5. Illustrative Examples

The Shared-Memory case study concretely demonstrates the theorem's operation:

  • Sums and Arrays: For τAτB\tau_A \sim \tau_B8, execution yields either τAτB\tau_A \sim \tau_B9 with ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B0 or ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B1 with ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B2. The glue-code ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B3 ensures correct tagging and recursive payload conversion, so the final result is a valid ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B4 in ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B5.
  • References: If ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B6, the pointer ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B7 satisfies ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B8; since ΓτBτA(e):τB\Gamma \vdash \llbracket \tau_B \leftarrow \tau_A \rrbracket(e) : \tau_B9, the same pointer is valid for τB\tau_B0. No-op glue-code suffices for correctness.
  • Dynamic Failures: If a value is not convertible (e.g., out-of-range array), the glue-code triggers the dynamic error fail Conv. The model explicitly allows for such failures, maintaining the soundness property.

6. Corollary: Full Semantic Soundness of the Multi-Language

Upon establishing Convertibility Soundness, compatibility lemmas for all typing rules—especially boundaries and conversions—yield full semantic soundness for AB-programs: every well-typed program τB\tau_B1 compiles to τB\tau_B2. Consequently, execution of multi-language systems cannot “go wrong” except through conversion errors that are precisely specified by the declared convertibility relation. This constraint provides robust guarantees about the safe composition of multi-language systems, as validated semantically via the logical relation (Patterson et al., 2022).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Convertibility Soundness Theorem.