Hostname: page-component-6766d58669-r8qmj Total loading time: 0 Render date: 2026-05-14T22:00:58.758Z Has data issue: false hasContentIssue false

ANF preserves dependent types up to extensional equality

Published online by Cambridge University Press:  16 September 2022

PAULETTE KORONKEVICH
Affiliation:
University of British Columbia, Vancouver, British Columbia, Canada (e-mail: pletrec@cs.ubc.ca)
RAMON RAKOW
Affiliation:
University of British Columbia, Vancouver, British Columbia, Canada (e-mail: ramon.rakow@alumni.ubc.ca)
AMAL AHMED
Affiliation:
Northeastern University, Boston, MA 02115, USA (e-mail: amal@ccs.neu.edu)
WILLIAM J. BOWMAN
Affiliation:
University of British Columbia, Vancouver, British Columbia, Canada (e-mail: wjb@williamjbowman.com)
Rights & Permissions [Opens in a new window]

Abstract

Many programmers use dependently typed languages such as Coq to machine-verify high-assurance software. However, existing compilers for these languages provide no guarantees after compiling, nor when linking after compilation. Type-preserving compilers preserve guarantees encoded in types and then use type checking to verify compiled code and ensure safe linking with external code. Unfortunately, standard compiler passes do not preserve the dependent typing of commonly used (intensional) type theories. This is because assumptions valid in simpler type systems no longer hold, and intensional dependent type systems are highly sensitive to syntactic changes, including compilation. We develop an A-normal form (ANF) translation with join-point optimization—a standard translation for making control flow explicit in functional languages—from the Extended Calculus of Constructions (ECC) with dependent elimination of booleans and natural numbers (a representative subset of Coq). Our dependently typed target language has equality reflection, allowing the type system to encode semantic equality of terms. This is key to proving type preservation and correctness of separate compilation for this translation. This is the first ANF translation for dependent types. Unlike related translations, it supports the universe hierarchy, and does not rely on parametricity or impredicativity.

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 in any medium, provided the original work is properly cited.
Copyright
© The Author(s), 2022. Published by Cambridge University Press
Figure 0

Fig. 1: ECC syntax.

Figure 1

Fig. 2: ECC dynamic semantics (excerpt).

Figure 2

Fig. 3: ECC equivalence and subtyping (excerpt).

Figure 3

Fig. 4: ECC typing (excerpt).

Figure 4

Fig. 5: $\mathrm{CC}_{e}^{A}$ syntax.

Figure 5

Fig. 6: $\mathrm{CC}_{e}^{A}$ typing (excerpt).

Figure 6

Fig. 7: $\mathrm{CC}_{e}^{A}$ equivalence (excerpt).

Figure 7

Fig. 8: Composition of configurations.

Figure 8

Fig. 9: $\mathrm{CC}_{e}^{A}$ evaluation.

Figure 9

Fig. 10: $\mathrm{CC}_{e}^{A}$ continuation typing.

Figure 10

Fig. 11: $\mathrm{CC}_{e}^{A}$ model in eCIC (excerpt).

Figure 11

Fig. 12: Naïve ANF translation.

Figure 12

Fig. 13: Separate compilation definitions.

Figure 13

Fig. 14: Join-point optimized ANF translation.

Figure 14

Fig. A15: ECC syntax.

Figure 15

Fig. A16: ECC dynamic semantics (excerpt).

Figure 16

Fig. A17: ECC congruence conversion rules.

Figure 17

Fig. A18: ECC equivalence and subtyping

Figure 18

Fig. A19: ECC typing

Figure 19

Fig. A20: ECC well-formed environments.

Figure 20

Fig. A21: $\mathrm{CC}_{e}^{A}$ syntax.

Figure 21

Fig. A22: $\mathrm{CC}_{e}^{A}$ equivalence

Figure 22

Fig. A23: $\mathrm{CC}_{e}^{A}$ evaluation.

Figure 23

Fig. A24: Composition of configurations.

Figure 24

Fig. A25: $\mathrm{CC}_{e}^{A}$ continuation typing.

Figure 25

Fig. A26: $\mathrm{CC}_{e}^{A}$ typing

Submit a response

Discussions

No Discussions have been published for this article.