Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash 99 tok/s
Gemini 2.5 Pro 48 tok/s Pro
GPT-5 Medium 40 tok/s
GPT-5 High 38 tok/s Pro
GPT-4o 101 tok/s
GPT OSS 120B 470 tok/s Pro
Kimi K2 161 tok/s Pro
2000 character limit reached

Flattening Subtyping via Eta Expansion

Updated 27 August 2025
  • Flattening subtyping by η-expansion is a method that converts deep, structure-sensitive subtyping into a shallow relation using explicit η-expansion of terms.
  • This technique shifts complexity from recursive type inspection to term syntax, simplifying metatheoretic proofs and type-checking implementations.
  • Rooted in foundational intersection type work, this approach has influenced modern programming language design by streamlining subtyping relations.

Flattening subtyping by eta expansion refers to a technique in type system design and metatheory in which the use of deep, structure-sensitive subtyping—where type comparison recursively inspects constituents such as function argument and result types—is systematically replaced by a shallower subtyping relation paired with explicit η-expansion of terms. This approach leverages the expansion of terms into η-long normal form to expose the structure required for establishing subsumption relations, thereby transferring complexity from the subtyping relation into term syntax and thereby simplifying the subtyping relation itself.

1. Deep Versus Shallow Subtyping: Fundamental Trade-Offs

Type systems supporting subtyping must balance expressiveness and tractability. Deep subtyping inspects the full structure of types, with rules such as

(Arr)B1<:A1A2<:B2A1A2<:B1B2\text{(Arr)}\quad\frac{B_1\,{<:}\,A_1 \quad A_2\,{<:}\,B_2}{A_1 \to A_2\,{<:}\,B_1 \to B_2}

and analogous rules for products. This expressiveness allows, for example, the derivation of subtyping relationships arbitrarily deep within nested function or tuple types. However, deep subtyping increases the complexity of metatheoretic arguments—especially induction principles for properties such as substitution—and complicates subtyping algorithms, potentially impacting decidability and practical implementation.

Shallow subtyping restricts attention to the "surface" of types and typically consists only of reflexivity and a small set of base conversions (e.g., int<:rat\mathtt{int}\,{<:}\,\mathtt{rat}, A<:AA\,{<:}\,A). This constraint facilitates reasoning and enables simpler, more direct type-checking procedures, but is not, on its own, as expressive as deep subtyping.

2. Eta Expansion as a Bridge: The Shallow Expansion Lemma

The central insight is that η-expansion of terms can recover the expressive power of deep subtyping in a system equipped only with shallow subtyping. Given any use of deep subtyping in a typing derivation, it is possible (constructively, and with guaranteed completeness) to insert η-expansions into terms as needed, so that the transformed term typechecks under the corresponding shallow subtyping rules.

Formally, the core metatheorem is encapsulated in the following lemma: Lemma (Shallow expansion): If A<:B and Γe:A, then there exists e with ee and Γe:B.\textbf{Lemma (Shallow expansion): If } A <: B \textbf{ and } \Gamma \vdash e : A \textbf{, then there exists } e' \textbf{ with } e' \rightsquigarrow^* e \textbf{ and } \Gamma \vdash e' : B. where \rightsquigarrow^* denotes a sequence of η-expansion steps. Notably, in the case of function types, if A=A1A2A = A_1 \to A_2 and B=B1B2B = B_1 \to B_2 with B1<:A1B_1 <: A_1 and A2<:B2A_2 <: B_2, we obtain e=λx.e1e' = \lambda x. e_1, where e1e_1 is constructed inductively and ee' is η-convertible to ee.

The η-expansion rule for functions takes the form: $\frac{x \notin \mathit{FV}(e)}{\lambda x.\,(e\, x) \;\eredArr\; e}$ This strategy generalizes: for every deep subtyping step, an appropriate η-expansion at the term level can simulate the effect.

3. Historical Motivation: Barendregt et al. (1983)

In foundational work on intersection type systems, Barendregt, Coppo, and Dezani-Ciancaglini introduced two closely related systems. The first included a deep subsumption rule with a rich subtyping relation, while the second eliminated subsumption entirely and instead included a rule that permitted typing of η-expansions: ΓM:σMβηNΓN:σ\frac{\Gamma \vdash M : \sigma \qquad M \rightsquigarrow_{\beta\eta} N}{\Gamma \vdash N : \sigma} The completeness proof for the second (shallow) system constructs, when required, an η-expansion of the subject term during derivations that simulate applications of the omitted deep subsumption rule. As a consequence, the role of η-expansion as a technique to obviate deep subtyping is historically rooted in this semantic analysis of intersection types.

4. Detailed Proof Structure for Shallow Expansion

The proof of the Shallow Expansion Lemma proceeds by structural induction on the derivation of the deep subtyping A<:BA <: B. The base cases (reflexivity, atomic type conversions such as int<:rat\mathtt{int}\,{<:}\,\mathtt{rat}) map directly to shallow subtyping derivations, so e=ee' = e.

In the function case, with A1A2<:B1B2A_1 \to A_2 <: B_1 \to B_2, one introduces a fresh variable x:B1x : B_1 into the context, η-expands xx as needed to ex:A1e_x' : A_1, applies ee to exe_x', obtains e1e_1 of type A2A_2, then uses the inductive hypothesis to obtain e2e_2' of type B2B_2 η-expanding as needed, finally abstracting over xx to form e=λx.e2e' = \lambda x.\,e_2'. Compositionality of η-conversion guarantees that eee' \rightsquigarrow^* e.

A similar case analysis applies for product types, again with possible η-expansion of the term to expose or supply required projections.

5. Practical Significance for Type System Design

Flattening subtyping by η-expansion yields two key benefits:

  • Simplification of Subtyping Relations: Type systems can restrict subtyping to the shallow fragment, dispensing with the extra machinery (and implementation complexity) required by deep structural rules without a loss of expressive power in programs, provided suitable term elaboration is permitted.
  • Conceptual and Algorithmic Clarity: By shifting complexity into η-expansion at the syntactic (term) level, the structure of the subtyping relation is dramatically simplified, allowing for more modular type system definitions and tractable type-checker implementations.

This approach generalizes beyond simple types to systems with intersection and union types, datasort refinements, and systems with polymorphic components. The meta-theoretic clarity afforded by the Shallow Expansion Lemma also elucidates the connection between type theory (subsumption) and term rewriting (η-expansion), enabling compositional metatheory and soundness proofs.

6. Broader Context and Subsequent Developments

Related research has further clarified, refined, and leveraged the principle of flattening subtyping via η-expansion. For example, in session type theories for concurrent computation, "flattening" mechanisms—sometimes conceptually equivalent to η-expansion—are leveraged to characterize preciseness and completeness of subtyping relations, particularly in asynchronous communication settings, where the structure of session types can be exposed or normalized by suitable expansions (Chen et al., 2016).

Moreover, in the paper of type isomorphisms and normalization, the systematic use of type-directed conversions (often relying on normalization/η-long forms) parallels the flattening process described here (Ilik, 2015). Categorical models of subtyping have incorporated η-expansion in the context of flattening the structure of morphisms and making coercion witnesses canonical (Coraglia et al., 2023). In programming languages with first-class subtypes, explicit construction of coercion proofs (often via η-expanded witnesses) further demonstrates the practical value of this principle (Yallop et al., 2019).

7. Conclusion

Flattening subtyping by eta expansion is a principled approach for replacing complex, deep subtyping with a combination of explicit η-expanded terms and shallow, surface-level subtyping. The completeness of this approach is established by a direct inductive argument demonstrating that any typing derivation employing deep subtyping can be transformed into one relying only on shallow subtyping with sufficient η-expansion. Originally inspired by the completeness proof for intersection types by Barendregt et al. (1983), this methodology has proven to be a general and robust technique in the theory and implementation of modern type systems, striking an effective balance between expressiveness and simplicity (Dunfield, 26 Dec 2024).

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