Category theory library supports reusable programming language proofs
Logical Relations on Display
Programming LanguagesLogic in Computer Science
Summary
Programming language researchers often redo similar math work, making it hard to reuse their proofs and tools. This paper presents a library that uses category theory to capture key properties of programming languages and logical relations in a reusable way. The authors build this library inside a proof assistant, which checks the math details, and they use it to prove important results about simple programming language features. This approach could help developers and researchers avoid repetitive work by providing shared, composable building blocks.
What this means in practice
- •For programming language developers: Develop and verify new language features using reusable semantic components and proofs within a proof assistant.
- •For formal verification engineers: Build reliable software correctness proofs using modular logical relations and category-theoretic semantics.
Authors
Steven Schaefer, Johnson He, Max S. New
Abstract
The metatheory of programming languages suffers from a lack of reuse. Researchers develop individual calculi and prove standard properties, but very few results are truly reused across papers. The problem is worse in proof assistants, where developments routinely duplicate code from prior work or rebuild it from scratch. Category theory provides the most promising path toward reusable programming language semantics. Universal properties capture the type connectives---products, functions, sums---together with their $β$/$η$ laws. Free categorical structures identify syntactic calculi. \emph{Displayed} categories provide a uniform language for specifying logical relations, and general theorems about fibrations allow their structure to be assembled compositionally. In this work we develop a library of formalized category theory in the Cubical Agda proof assistant directly applicable to programming language metatheory. We develop theories of universal properties and free categorical structures, apply them to define denotational semantics and logical relations for simply typed calculi, and identify encodings of the categorical constructions that make typechecking them tractable. From the same categorical components, we construct several familiar results via a logical relations construction---canonicity,parametricity,conservativity---and provide a proof of coherence for monoidal categories.