- The paper presents a type-preserving closure conversion approach that maintains source-level correctness proofs by transforming CC functions into CC-CC closures.
- It details the design of CC-CC, using dependent pairs and environment construction to preserve free variables and function semantics during translation.
- Rigorous soundness and correctness proofs, along with compositional substitution, validate the reliability of preserving type invariants post-compilation.
Typed Closure Conversion for the Calculus of Constructions
Introduction
The study focuses on developing a type-preserving closure conversion for the Calculus of Constructions (CC), which is the core language of Coq, a dependently typed language. Dependently typed languages like Coq enable full functional correctness verification of source programs. However, these proofs often pertain solely to source programs, and guarantees are required for the compiled target programs. Type-preserving compilation aims to maintain specifications and proofs of correctness during the compilation, ensuring that linked target programs respect original source invariants.
Core Challenge
The main challenge in type-preserving closure conversion for dependent types lies in the high-level abstractions interfered by compilation. Specifically, converting functions with free variables into closures disrupts the base type-system rules. In CC, functions and Î types, which are proofs of universal properties, are central. Translating functions into closures requires new type-system rules and equivalences to ensure type preservation.
Key Contributions and Methodology
- Design of CC-CC: The paper presents CC-CC, a dependently typed compiler intermediate language supporting closure conversion. It ensures type safety and allows reasoning about closures. Importantly, it does not assume impredicativity, maintaining consistency across various universe hierarchies.
- Typed Closure Conversion Translation: The translation involves converting CC functions into CC-CC closures, preserving function semantics and types. This transformation uses dependent pairs to create environments for closures by collecting free variables, ensuring that environments remain hidden at the type level.
- Soundness and Correctness Proofs: A model of CC-CC in CC proves type safety and consistency. A translation that respects terms, types, and reductions underpins correctness. Furthermore, compositionality ensures substitution reliability, which is pivotal for maintaining typing invariants.
Technical Approach
The approach relies on preserving free variables through environment construction during translation. Equivalences, including η-equivalence, are redefined to account for closures. A syntactic sugar defines environments as tuples, and a projection mechanism supports type annotations that depend on these environments.
Implications and Future Work
The research indicates pathways to type-preserving compilation in broader contexts, such as extending these principles to the Calculus of Inductive Constructions (CIC) and, eventually, to a dependently typed assembly language. This facilitates safe linking, ensuring that machine-level code adheres to high-level language specifications.
Future expansions could include handling recursive functions and integrating computational relevance directly in source languages. The paper suggests that strategies like sized types or inductive eliminators could address recursion challenges, especially in ensuring sound recursion within CIC.
Conclusion
The paper delineates a fundamental advance in type-preserving compilation, applicable to dependently typed languages. It provides a blueprint for ensuring that source code specifications can be reliably translated and preserved in compiled artifacts, setting the groundwork for building secure and verifiable systems from high-level specifications to lower-level code executions.