76 research outputs found
The Lean mathematical library
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
LLMSTEP: LLM proofstep suggestions in Lean
We present LLMSTEP, a tool for integrating a language model into the Lean
proof assistant. LLMSTEP is a Lean 4 tactic that sends a user's proof state to
a server hosting a language model. The language model generates suggestions,
which are checked in Lean and displayed to a user in their development
environment. We provide a baseline language model, along with code for
fine-tuning and evaluation to support further development. We provide server
implementations that run on CPU, a CUDA GPU, or a Google Colab notebook, as a
step towards fast, effective language model suggestions for any user
Scalar actions in Lean's mathlib
Scalar actions are ubiquitous in mathematics, and therefore it is valuable to
be able to write them succinctly when formalizing. In this paper we explore how
Lean 3's typeclasses are used by mathlib for scalar actions with examples,
illustrate some of the problems which come up when using them such as
compatibility of actions and non-definitionally-equal diamonds, and note how
these problems can be solved. We outline where more work is needed in mathlib
in this area.Comment: 6 pages, 2 figures. For associated conference presentation slides,
see https://eric-wieser.github.io/fmm-202
The Lean 4 Theorem Prover and Programming Language
Lean 4 is a reimplementation of the Lean interactive theorem prover (ITP) in Lean itself. It addresses many shortcomings of the previous versions and contains many new features. Lean 4 is fully extensible: users can modify and extend the parser, elaborator, tactics, decision procedures, pretty printer, and code generator. The new system has a hygienic macro system custom-built for ITPs. It contains a new typeclass resolution procedure based on tabled resolution, addressing significant performance problems reported by the growing user base. Lean 4 is also an efficient functional programming language based on a novel programming paradigm called functional but in-place. Efficient code generation is crucial for Lean users because many write custom proof automation procedures in Lean itself
Multiple inheritance hazards in algebraic typeclass hierarchies
Abstract algebra provides a large hierarchy of properties that a collection
of objects can satisfy, such as forming an abelian group or a semiring. These
classifications can arranged into a broad and typically acyclic directed graph.
This graph perspective encodes naturally in the typeclass system of theorem
provers such as Lean, where nodes can be represented as structures (or records)
containing the requisite axioms. This design inevitably needs some form of
multiple inheritance; a ring is both a semiring and an abelian group.
In the presence of dependently-typed typeclasses that themselves consume
typeclasses as type-parameters, such as a vector space typeclass which assumes
the presence of an existing additive structure, the implementation details of
structure multiple inheritance matter. The type of the outer typeclass is
influenced by the path taken to resolve the typeclasses it consumes. Unless all
these paths are considered judgmentally equal, this is a recipe for disaster.
This paper provide a concrete explanation of how these situations arise
(reduced from real examples in mathlib), compares implementation approaches for
multiple inheritance by whether judgmental equality is preserved, and outlines
solutions to the problems discovered.Comment: 11 pages, 3 figure
- …