Document Open Access Logo

A Machine-Checked Proof of Birkhoff’s Variety Theorem in Martin-Löf Type Theory

Authors William DeMeo , Jacques Carette

Thumbnail PDF


  • Filesize: 463 kB
  • 21 pages

Document Identifiers

Author Details

William DeMeo
  • New Jersey Institute of Technology, Newark, NJ, USA
Jacques Carette
  • McMaster University, Hamilton, Canada


This work would not have been possible without the wonderful language and the, developed and maintained by The Agda Team [The Agda Team, 2021]. We thank the three anonymous referees for carefully reading the manuscript and offering many excellent suggestions which resulted in a vast improvement in the overall presentation. One referee went above and beyond and provided us with a simpler formalization of free algebras which led to simplifications of the proof of the main theorem. We are extremely grateful for this.

Cite AsGet BibTex

William DeMeo and Jacques Carette. A Machine-Checked Proof of Birkhoff’s Variety Theorem in Martin-Löf Type Theory. In 27th International Conference on Types for Proofs and Programs (TYPES 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 239, pp. 4:1-4:21, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2022)


The Agda Universal Algebra Library is a project aimed at formalizing the foundations of universal algebra, equational logic and model theory in dependent type theory using Agda. In this paper we draw from many components of the library to present a self-contained, formal, constructive proof of Birkhoff’s HSP theorem in Martin-Löf dependent type theory. This achieves one of the project’s initial goals: to demonstrate the expressive power of inductive and dependent types for representing and reasoning about general algebraic and relational structures by using them to formalize a significant theorem in the field.

Subject Classification

ACM Subject Classification
  • Theory of computation → Logic and verification
  • Computing methodologies → Representation of mathematical objects
  • Theory of computation → Type theory
  • Agda
  • constructive mathematics
  • dependent types
  • equational logic
  • formal verification
  • Martin-Löf type theory
  • model theory
  • universal algebra


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Andreas Abel. Birkhoff’s Completeness Theorem for multi-sorted algebras formalized in Agda. CoRR, abs/2111.07936, 2021. URL:
  2. Gianluca Amato, Marco Maggesi, and Cosimo Perini Brogi. Universal Algebra in UniMath. CoRR, abs/2102.05952, 2021. URL:
  3. Clifford Bergman. Universal Algebra: fundamentals and selected topics, volume 301 of Pure and Applied Mathematics (Boca Raton). CRC Press, Boca Raton, FL, 2012. Google Scholar
  4. G Birkhoff. On the structure of abstract algebras. Proceedings of the Cambridge Philosophical Society, 31(4):433-454, October 1935. Google Scholar
  5. Venanzio Capretta. Universal Algebra in Type Theory. In Theorem proving in higher order logics (Nice, 1999), volume 1690 of Lecture Notes in Comput. Sci., pages 131-148. Springer, Berlin, 1999. URL:
  6. William DeMeo. The Agda Universal Algebra Library., 2020. Ver. 1.0.0. Source code: URL:
  7. William DeMeo and Jacques Carette. A Machine-checked Proof of Birkhoff’s Variety Theorem in Martin-Löf Type Theory. CoRR, abs/2101.10166, 2021. Source code: URL:
  8. William DeMeo and Jacques Carette. The Agda Universal Algebra Library (agda-algebras)., 2021. Ver. 2.0.1. Source code: Documentation: GitHub repo: URL:
  9. Martín Hötzel Escardó. Introduction to Univalent Foundations of mathematics with Agda., May 2019. Accessed on 30 Nov 2021.
  10. Martín Hötzel Escardó. Introduction to Univalent Foundations of mathematics with Agda. CoRR, abs/1911.00580, 2019. URL:
  11. Emmanuel Gunther, Alejandro Gadea, and Miguel Pagano. Formalization of Universal Algebra in Agda. Electronic Notes in Theoretical Computer Science, 338:147-166, 2018. The 12th Workshop on Logical and Semantic Frameworks, with Applications (LSFA 2017). URL:
  12. Jason Z. S. Hu and Jacques Carette. Formalizing Category Theory in Agda. In Proceedings of the 10th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2021, pages 327-342, New York, NY, USA, 2021. Association for Computing Machinery. URL:
  13. Artur Korniłowicz. Birkhoff theorem for many sorted algebras, 1999. Google Scholar
  14. Andreas Lynge and Bas Spitters. Universal Algebra in HoTT. In Proceedings of the 25th International Conference on Types for Proofs and Programs (TYPES 2019), 2019. URL:
  15. Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Department of Computer Science and Engineering, Chalmers University of Technology, SE-412 96 Göteborg, Sweden, September 2007. Google Scholar
  16. The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations of Mathematics. Lulu and The Univalent Foundations Program, Institute for Advanced Study, 2013. URL:
  17. Bas Spitters and Eelis Van der Weegen. Type classes for mathematics in type theory. CoRR, abs/1102.1323, 2011. URL:
  18. The Agda Team. Agda Language Reference, 2021. URL:
  19. The Agda Team. Agda Language Reference section on Axiom K, 2021. URL:
  20. The Agda Team. Agda Language Reference section on Safe Agda, 2021. URL:
  21. The Agda Team. The Agda Standard Library, 2021. URL:
  22. The Agda Team. Agda Tools Documentation section on Pattern matching and equality, 2021. URL:
  23. The Coq Development Team. The Coq proof assistant reference manual. LogiCal Project, 2004. Version 8.0. URL:
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail