This paper describes mathlib, a community-driven effort to build a unified
library of mathematics formalized in the Lean proof assistant. Among proof
assistant libraries, it is distinguished by its dependently typed foundations,
focus on classical mathematics, extensive hierarchy of structures, use of
large- and small-scale automation, and distributed organization. We explain the
architecture and design decisions of the library and the social organization
that has led us here