Skip to main content
QUICK REVIEW

[Paper Review] Untangling Typechecking of Intersections and Unions

Jana Dunfield|Jan 24, 2011
Logic, programming, and type systemsComputer Science5 citations
TL;DR

This paper presents a practical typechecking strategy for union types in a bidirectional type system by transforming programs into let-normal form, drastically reducing the number of subterm choices during case analysis. The key contribution is proving soundness and completeness: a program has a valid type derivation if and only if its let-normalized version does, enabling efficient and correct union typechecking without sacrificing type safety.

ABSTRACT

Intersection and union types denote conjunctions and disjunctions of properties. Using bidirectional typechecking, intersection types are relatively straightforward, but union types present challenges. For union types, we can case-analyze a subterm of union type when it appears in evaluation position (replacing the subterm with a variable, and checking that term twice under appropriate assumptions). This technique preserves soundness in a call-by-value semantics. Sadly, there are so many choices of subterms that a direct implementation is not practical. But carefully transforming programs into let-normal form drastically reduces the number of choices. The key results are soundness and completeness: a typing derivation (in the system with too many subterm choices) exists for a program if and only if a derivation exists for the let-normalized program.

Motivation & Objective

  • To address the inefficiency of naive case analysis in union typechecking, where too many subterm choices hinder practical implementation.
  • To preserve type safety and soundness while reducing the search space for typechecking union types.
  • To establish a formal connection between full typechecking with arbitrary subterm choices and a normalized, efficient variant.
  • To provide a practical foundation for integrating union types into real programming languages with predictable performance.

Proposed method

  • Transforming programs into let-normal form to limit the number of subterms eligible for case analysis.
  • Using bidirectional typechecking to guide type inference and checking with separate rules for input and output contexts.
  • Applying case analysis only to let-bound variables, not arbitrary subterms, to reduce combinatorial explosion.
  • Proving that every valid typing derivation in the original system corresponds to a derivation in the let-normalized system.
  • Defining a type system with explicit rules for intersection and union types, where union types are handled via case analysis on bound variables.
  • Establishing a formal correspondence between derivations in the original and normalized systems via structural induction.

Experimental results

Research questions

  • RQ1Can union typechecking be made practical despite the exponential number of subterm choices in case analysis?
  • RQ2Is it possible to preserve soundness and completeness when restricting case analysis to let-bound variables?
  • RQ3Does let-normalization eliminate redundant typechecking choices without losing expressiveness?
  • RQ4Can a bidirectional type system efficiently support both intersection and union types?
  • RQ5What formal guarantees can be provided for a normalized typechecking procedure?

Key findings

  • The number of subterm choices for case analysis is drastically reduced by transforming programs into let-normal form.
  • Soundness and completeness are preserved: a program is well-typed in the original system if and only if its let-normalized version is.
  • Case analysis is restricted to let-bound variables, which simplifies typechecking and avoids combinatorial explosion.
  • The transformation to let-normal form is sufficient to capture all valid type derivations, making it a complete normalization.
  • The approach enables efficient, practical union typechecking in a bidirectional type system without sacrificing correctness.
  • The results are formally proven using structural induction on typing derivations, ensuring theoretical robustness.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.