The research described in my thesis involves the extension and maintenance of the library of formal mathematics Mathlib for the interactive theorem prover Lean. The process of mechanization that results in formal mathematics rests on a detailed, uniform and unambiguous translation of mathematical knowledge. Thus, it requires suitable design choices, which needs a thorough understanding of the functionality provided by Lean.
After giving a general overview of Lean and Mathlib, the thesis extensively covers a specific mechanism of Lean: the instance parameter. This makes possible the design pattern of typeclasses. Related mechanisms for organizing mathematical structures can be found in many other interactive theorem provers. Based on characteristic practical examples, I describe a variety of design choices that help in applying this functionality. Based on this research, changes and additions were made to Mathlib, also on fundamental levels. Many of the design choices are also applied in the subsequent chapters.
After this follows a part of the thesis with the emphasis on formal mathematics, beginning with an overview of the mathematics that is covered. As part of a dynamically changing group of contributors, I worked on formalizing subjects that lie at the basis of algebraic number theory, and these formalizations have since been added to Mathlib. An important theme of this chapter is that it becomes possible to treat different occurences of the same situation in an equal manner, if the right formulation is chosen.
Next, we apply the previous work to the solution of concrete problems, namely the formal computation of class numbers and a formal description of all integer solutions to certain Diophantine equations. This required us to face the challenge of writing down definitions that are useful both in the case of high abstraction, and when very specific objects are involved. Computing the desired properties for now remains a matter of manually applying calculation steps, although computer algebra systems can supply the outcome (without a formal proof) within mere moments.
Finally, I describe proof tactics I developed, that make it possible to automatically prove certain classes of equalities in the study of rings. By applying these, many manual and tedious calculation steps can be left to the computer.
The outcome of this research was not merely to extend the list of theorems available in Mathlib, but to enrich the possibilities of effectively formalizing mathematics.