A Lean 4 / Mathlib formalization of the Yoneda lemma for bicategories.
The classical Yoneda lemma identifies natural transformations out of a representable functor with elements of the represented set. In the bicategorical setting this bijection upgrades to a natural equivalence of categories: for a bicategory
natural in
Rather than constructing this equivalence object-by-object, the formalization expresses it as a biequivalence of pseudofunctors
on the product bicategory
| Lean name | Mathematical meaning |
|---|---|
yonedaPairing |
Pseudofunctor |
yonedaEvaluation |
Pseudofunctor |
yonedaLemmaForwards |
Strong transformation |
yonedaLemmaBackwards |
Strong transformation |
yonedaHomInvId |
Unit isomorphism |
yonedaInvHomId |
Counit isomorphism |
yonedaLemma |
The assembled BiEquiv witnessing the equivalence |
catPseudoULift |
Universe-lifting pseudofunctor needed to type-match the two sides |
biyoneda/
├── Biyoneda/
│ ├── Basic.lean # All definitions and proofs
│ └── ForMathlib.lean # General Cat/bicategory lemmas staged for upstreaming
├── paper/
│ ├── Biyoneda.tex # Paper source
│ ├── preamble.tex # LaTeX packages and macros
│ └── references.bib # Bibliography
├── Biyoneda.pdf # Compiled paper (built by CI)
├── Makefile # `make` to compile the paper locally
├── lakefile.toml
└── lean-toolchain # Lean 4 v4.29.0 / Mathlib v4.29.0
A write-up of the formalization is in paper/Biyoneda.tex.
The compiled PDF is kept up to date by CI and can be read directly on GitHub: Biyoneda.pdf.
To compile the paper locally (requires a TeX Live installation):
makePrerequisites: Lean 4 with elan (the Lean version manager). The correct toolchain is pinned in lean-toolchain and will be fetched automatically.
lake exe cache get # download prebuilt Mathlib artifacts
lake build # build the projectThe first lake exe cache get step downloads compiled Mathlib oleans so you do not need to rebuild Mathlib from scratch (~20 min without cache).
Specifically, the formalization builds on:
Mathlib.CategoryTheory.Bicategory.YonedaMathlib.CategoryTheory.Category.ULift
I have been experimenting with use of AI in formalization. I have had some limited success with it writing the lean code succses but I have used it for comments, documentation, and setting up the git actions in the repo. I have given a cursory look at all of the things it has written and corrected any small errors I have found. I plan to give a more detailed look at it in the future. Please be warned to take these things with a grain of salt.
Released under the Apache License 2.0, matching the Mathlib ecosystem. See LICENSE.