TL;DR
The HoTT Library is a comprehensive formalization of Homotopy Type Theory (HoTT) within the Coq proof assistant. It provides a robust, "univalent" foundation for mathematics, successfully implementing complex concepts like higher inductive types and universe polymorphism while pushing the boundaries of Coq’s own kernel and automation capabilities.
What Problem Does This Paper Address?
Traditional formalizations of mathematics often struggle with the concept of "equality." In standard Martin-Löf type theory, equality is rigid. Homotopy Type Theory (HoTT) proposes a more flexible approach where types are treated as spaces and equalities as paths, allowing for the "Univalence Axiom"—the idea that equivalent types are equal.
However, implementing HoTT in existing proof assistants like Coq is challenging. Coq’s standard library is incompatible with HoTT’s axioms, and native support for "Higher Inductive Types" (HITs)—which allow users to define equalities between elements of a type—is missing. Previous efforts, like the UniMath project, avoided many of Coq’s advanced features to maintain simplicity. The authors of this paper sought to build a library that embraces Coq's modern features (like universe polymorphism) to create a more powerful and maintainable framework for univalent mathematics.
Methods
The authors built the library from the ground up, replacing the Coq standard library entirely with a "minimal core" compatible with HoTT. Key technical approaches include:
- Universe Polymorphism: Unlike earlier libraries that used inconsistent shortcuts (like
Type:Type), this library uses Coq’s universe polymorphism to handle the infinite hierarchy of types correctly and safely. - Licata’s Trick: To simulate Higher Inductive Types (HITs) without native support, they used "private inductive types." This allows them to define types where the constructors are hidden outside a specific module, effectively letting them "freely generate" equalities (like the path in a circle type).
- Half-Adjoint Equivalences: The library defines type equivalence using "half-adjoint equivalences" rather than simple isomorphisms. This choice provides better mathematical properties for formalization, specifically regarding "coherence" (ensuring that various paths and proofs play nicely together).
- Tactics and Automation: They developed custom tactics, such as
issig, which automatically translates between record types and nested Sigma-types, significantly reducing the manual labor required for proofs.
Datasets
As a software and logic project, this paper does not use traditional training datasets. Instead, the "data" consists of the library itself and its relationship to the "HoTT Book" (Homotopy Type Theory: Univalent Foundations of Mathematics).
- The library contains approximately 16,800 lines of specifications, 13,000 lines of proofs, and 4,500 lines of comments.
- It includes an automatically generated file linking constructions in the HoTT Book directly to the corresponding Coq code.
Key Insights and Ideas
- The "Incoherent" is Useful: When constructing equivalences, it is often easier to start with "incoherent" data (two functions and two homotopies) and then apply a "coherence" result. The library is designed to store this data efficiently.
- Pushing the Kernel: The project acted as a "stress test" for Coq. The authors collaborated closely with Coq developers to fix bugs and implement features like the
indices-matteroption, which allows the identity type to reside inTyperather thanProp. - Modality via Modules: The authors found that Coq’s module system—originally intended for software engineering—was the only way to correctly implement "modalities" (a generalization of $n$-truncations) while maintaining the necessary universe polymorphism.
- Type Classes for Logic: They used Coq’s type class system specifically for "mere propositions" (types with at most one element), which simplifies the search for proofs that don't carry computational weight.
Key Results
- Comprehensive Coverage: The library formalizes most of the foundational material in the HoTT Book, including category theory, structural induction, and synthetic homotopy theory (e.g., proving the fundamental group of the circle is the integers).
- Performance Gains: By switching to "primitive projections" for record types, the authors reduced the compilation time of the entire library by a factor of two.
- Ecosystem Impact: The library has already served as a foundation for independent projects, such as HoTTSQL (a formalization of SQL semantics) and research into probabilistic computation.
Limitations and Future Work
- Universe Management: Despite using universe polymorphism, the authors describe "battling" Coq’s universe heuristics. Manual intervention and explicit annotations are still frequently required to avoid inconsistencies.
- Computational Content: Because univalence and function extensionality are currently implemented as axioms, they "block" computation. A proof involving these axioms won't "run" to a simple value.
- Cubical Type Theory: The authors point toward "Cubical Type Theory" as a promising future direction that could provide a computational interpretation of univalence, potentially solving the "blocking" issue mentioned above.
- Native HITs: While "Licata's trick" works, the authors express a desire for native support for higher inductive types in future versions of Coq to simplify the code further.
Summary updated