Papers
Topics
Authors
Recent
Search
2000 character limit reached

Typed Closure Conversion for the Calculus of Constructions

Published 12 Aug 2018 in cs.PL | (1808.04006v1)

Abstract: Dependently typed languages such as Coq are used to specify and verify the full functional correctness of source programs. Type-preserving compilation can be used to preserve these specifications and proofs of correctness through compilation into the generated target-language programs. Unfortunately, type-preserving compilation of dependent types is hard. In essence, the problem is that dependent type systems are designed around high-level compositional abstractions to decide type checking, but compilation interferes with the type-system rules for reasoning about run-time terms. We develop a type-preserving closure-conversion translation from the Calculus of Constructions (CC) with strong dependent pairs ($\Sigma$ types)---a subset of the core language of Coq---to a type-safe, dependently typed compiler intermediate language named CC-CC. The central challenge in this work is how to translate the source type-system rules for reasoning about functions into target type-system rules for reasoning about closures. To justify these rules, we prove soundness of CC-CC by giving a model in CC. In addition to type preservation, we prove correctness of separate compilation.

Citations (12)

Summary

  • 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 Π\Pi 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

  1. 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.
  2. 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.
  3. 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 η\eta-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.

Paper to Video (Beta)

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Authors (2)

Collections

Sign up for free to add this paper to one or more collections.