Hostname: page-component-89b8bd64d-x2lbr Total loading time: 0 Render date: 2026-05-07T03:12:58.915Z Has data issue: false hasContentIssue false

Recursive subtyping for all

Part of: POPL 23

Published online by Cambridge University Press:  26 February 2025

LITAO ZHOU
Affiliation:
The University of Hong Kong, Pokfulam, Hong Kong (e-mail: ltzhou@cs.hku.hk)
YAODA ZHOU
Affiliation:
The University of Hong Kong, Pokfulam, Hong Kong (e-mail: ydzhou@cs.hku.hk)
QIANYONG WAN
Affiliation:
The University of Hong Kong, Pokfulam, Hong Kong (e-mail: qywan@cs.hku.hk)
BRUNO C. D. S. OLIVEIRA
Affiliation:
The University of Hong Kong, Pokfulam, Hong Kong (e-mail: bruno@cs.hku.hk)
Rights & Permissions [Opens in a new window]

Abstract

Recursive types and bounded quantification are prominent features in many modern programming languages, such as Java, C#, Scala, or TypeScript. Unfortunately, the interaction between recursive types, bounded quantification, and subtyping has shown to be problematic in the past. Consequently, defining a simple foundational calculus that combines those features and has desirable properties, such as decidability, transitivity of subtyping, conservativity, and a sound and complete algorithmic formulation, has been a long-time challenge.

This paper shows how to extend $F_{\le}$ with iso-recursive types in a new calculus called $F_{\le}^{\mu}$. $F_{\le}$ is a well-known polymorphic calculus with bounded quantification. In $F_{\le}^{\mu}$, we add iso-recursive types and correspondingly extend the subtyping relation with iso-recursive subtyping using the recently proposed nominal unfolding rules. In addition, we use so-called structural folding/unfolding rules for typing iso-recursive expressions, inspired by the structural unfolding rule proposed by Abadi et al. (1996). The structural rules add expressive power to the more conventional folding/unfolding rules in the literature, and they enable additional applications. We present several results, including: type soundness; transitivity; the conservativity of $F_{\le}^{\mu}$ over $F_{\le}$; and a sound and complete algorithmic formulation of $F_{\le}^{\mu}$. We study two variants of $F_{\le}^{\mu}$. The first one uses an extension of the $\textrm{kernel}~F_{\le}$ (a well-known decidable variant of $F_{\le}$). This extension accepts equivalent rather than equal bounds and is shown to preserve decidable subtyping. The second variant employs the $\textrm{full}~F_{\le}$ rule for bounded quantification and has undecidable subtyping. Moreover, we also study an extension of the kernel version of $F_{\le}^{\mu}$, called $F_{\le\ge}^{\mu\wedge}$, with a form of intersection types and lower bounded quantification. All the properties from the kernel version of $F_{\le}^{\mu}$ are preserved in $F_{\le\ge}^{\mu\wedge}$. All the results in this paper have been formalized in the Coq theorem prover.

Information

Type
Research Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2025. Published by Cambridge University Press
Figure 0

Table 1. Comparison among different works

Figure 1

Fig. 1. Syntax of $F_{\le}^{\mu}$.

Figure 2

Fig. 2. Well-formedness and subtyping rules for kernel $F_{\le}^{\mu}$.

Figure 3

Fig. 3. Typing and reduction rules.

Figure 4

Fig. 4. Structural unfolding derivation.

Figure 5

Fig. 5. Algorithmic typing.

Figure 6

Fig. 6. Additional well-formedness and subtyping rules for $F_{\le\ge}^{\mu\wedge}$ with respect to $F_{\le}^{\mu}$.

Figure 7

Fig. 7. Additional typing and reduction rules for $F_{\le\ge}^{\mu\wedge}$ with respect to $F_{\le}^{\mu}$.

Figure 8

Fig. 8. The additional algorithmic typing rules for $F_{\le\ge}^{\mu\wedge}$.

Figure 9

Fig. 9. The new exposure functions for $F_{\le\ge}^{\mu\wedge}$.

Figure 10

Fig. 10. The measures for the decidability of $F_{\le\ge}^{\mu\wedge}$.

Figure 11

Table 2. Paper-to-proofs correspondence guide for $\textrm{kernel}~F_{\le}^{\mu}$ (in kernel_fsub_main/ directory)

Figure 12

Table 3. Paper-to-proofs correspondence guide for $\textrm{full}~F_{\le}^{\mu}$ (in full_fsub_main/ directory). Definitions that are the same as $\textrm{kernel}~F_{\le}^{\mu}$ are omitted

Figure 13

Table 4. Paper-to-proofs correspondence guide for $F_{\le\ge}^{\mu\wedge}$ (in kernel_fsub_ext/ directory)

Figure 14

Table 5. Descriptions for the proof scripts for $\textrm{kernel}~F_{\le}^{\mu}$ (in kernel_fsub_main/ directory)

Figure 15

Table 6. Descriptions for the proof scripts for $\textrm{full}~F_{\le}^{\mu}$ (in full_fsub_main/ directory)

Figure 16

Table 7. Descriptions for the proof scripts for $F_{\le\ge}^{\mu\wedge}$ (in kernel_fsub_ext/ directory)

Figure 17

Table 8. Comparison $F_{\le\ge}^{\mu\wedge}$ with DOT and its variants

Supplementary material: File

Zhou et al. supplementary material

Zhou et al. supplementary material
Download Zhou et al. supplementary material(File)
File 376.5 KB
Submit a response

Discussions

No Discussions have been published for this article.