Imperative Compositional Programming: Type Sound Distributive Intersection Subtyping with References via Bidirectional Typing

Compositional programming is a programming paradigm that emphasizes modularity and is implemented in the CP programming language. The foundations for compositional programming are based on a purely functional variant of System F with intersection types, called <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline"> <mml:msubsup> <mml:mi>F</mml:mi> <mml:mi mathvariant="normal">i</mml:mi> <mml:mo>+</mml:mo> </mml:msubsup> </mml:math> , which includes distributivity rules for subtyping. This paper shows how to extend compositional programming and CP with mutable references, enabling a modular, imperative compositional programming style. A technical obstacle solved in our work is the interaction between distributive intersection subtyping and mutable references. Davies and Pfenning [2000] studied this problem in standard formulations of intersection type systems and argued that, when combined with references, distributive subtyping rules lead to type unsoundness. To recover type soundness, they proposed dropping distributivity rules in subtyping. CP cannot adopt this solution, since it fundamentally relies on distributivity for modularity. Therefore, we revisit the problem and show that, by adopting bidirectional typing , a more lightweight and type sound restriction is possible: we can simply restrict the typing rule for references. This solution retains distributivity and an unrestricted intersection introduction rule. We present a first calculus, based on Davies and Pfenning ’s work, which illustrates the generality of our solution. Then we present an extension of <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline"> <mml:msubsup> <mml:mi>F</mml:mi> <mml:mi>i</mml:mi> <mml:mo>+</mml:mo> </mml:msubsup> </mml:math> with references, which adopts our restriction and enables imperative compositional programming. We implement an extension of CP with references and show how to model a modular live-variable analysis in CP. Both calculi and their proofs are formalized in the Coq proof assistant.

Authors

Institutions

Publication Details

Journal
Proceedings of the ACM on Programming Languages
Published
2024-10-08
DOI
https://doi.org/10.1145/3689782
Citations
1
Primary Topic
Logic, programming, and type systems
Type
article
Field-Weighted Citation Impact
0.35
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Imperative Compositional Programming: Type Sound Distributive Intersection Subtyping with References via Bidirectional Typing

Wenjia Ye, Yaozhu Sun, Bruno C. d. S. Oliveira
1 citations
Proceedings of the ACM on Programming Languages
Logic, programming, and type systems
0.35
article

Imperative Compositional Programming: Type Sound Distributive Intersection Subtyping with References via Bidirectional Typing

Wenjia Ye, Yaozhu Sun, Bruno C. d. S. Oliveira
article en
1 citations

Abstract

Compositional programming is a programming paradigm that emphasizes modularity and is implemented in the CP programming language. The foundations for compositional programming are based on a purely functional variant of System F with intersection types, called <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline"> <mml:msubsup> <mml:mi>F</mml:mi> <mml:mi mathvariant="normal">i</mml:mi> <mml:mo>+</mml:mo> </mml:msubsup> </mml:math> , which includes distributivity rules for subtyping. This paper shows how to extend compositional programming and CP with mutable references, enabling a modular, imperative compositional programming style. A technical obstacle solved in our work is the interaction between distributive intersection subtyping and mutable references. Davies and Pfenning [2000] studied this problem in standard formulations of intersection type systems and argued that, when combined with references, distributive subtyping rules lead to type unsoundness. To recover type soundness, they proposed dropping distributivity rules in subtyping. CP cannot adopt this solution, since it fundamentally relies on distributivity for modularity. Therefore, we revisit the problem and show that, by adopting bidirectional typing , a more lightweight and type sound restriction is possible: we can simply restrict the typing rule for references. This solution retains distributivity and an unrestricted intersection introduction rule. We present a first calculus, based on Davies and Pfenning ’s work, which illustrates the generality of our solution. Then we present an extension of <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" display="inline"> <mml:msubsup> <mml:mi>F</mml:mi> <mml:mi>i</mml:mi> <mml:mo>+</mml:mo> </mml:msubsup> </mml:math> with references, which adopts our restriction and enables imperative compositional programming. We implement an extension of CP with references and show how to model a modular live-variable analysis in CP. Both calculi and their proofs are formalized in the Coq proof assistant.

Proceedings of the ACM on Programming LanguagesVol. 8(OOPSLA2)
University of Hong Kong (HK)
Peace, Justice and strong institutions
Openalex Percentile: Top 33%
Logic, programming, and type systems
0.35
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.