Lean4-Mathlib / README.md
phanerozoic's picture
Fix: remove type keyword from fact field
5a04812 verified
metadata
license: apache-2.0
task_categories:
  - text-generation
  - feature-extraction
language:
  - en
tags:
  - theorem-proving
  - formal-methods
  - lean4
  - mathlib
  - mathematics
size_categories:
  - 100K<n<1M
dataset_info:
  features:
    - name: fact
      dtype: string
    - name: type
      dtype: string
    - name: library
      dtype: string
    - name: imports
      list: string
    - name: filename
      dtype: string
    - name: symbolic_name
      dtype: string
    - name: docstring
      dtype: string
  splits:
    - name: train
      num_bytes: 110117432
      num_examples: 193047
  download_size: 26646919
  dataset_size: 110117432
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*

Mathlib4

Structured dataset of mathematical formalizations from the Mathlib4 library for Lean 4.

Dataset Description

Schema

Column Type Description
fact string Full declaration body
type string theorem, lemma, def, class, structure, instance, inductive, abbrev, axiom
library string Top-level Mathlib module (Algebra, Analysis, Topology, etc.)
imports list Import statements from source file
filename string Source file path within Mathlib
symbolic_name string Declaration identifier
docstring string Documentation comment (30% coverage)

Statistics

By Type

Type Count Percentage
theorem 111,804 57%
lemma 36,970 19%
def 27,965 14%
instance 10,322 5%
abbrev 2,570 1%
class 1,710 1%
structure 1,387 1%
inductive 310 <1%

By Library (Top 10)

Library Count
Algebra 30,936
Analysis 20,343
Data 20,327
CategoryTheory 18,553
Topology 16,800
Order 13,686
RingTheory 12,566
LinearAlgebra 9,279
MeasureTheory 8,927
Combinatorics 4,949

Docstring Coverage

Type With Docstring
def 98%
class 98%
structure 93%
theorem 15%
lemma 14%

Use Cases

  • Retrieval / RAG for Lean 4 theorem proving
  • Mathematical content search and exploration
  • Training embeddings for formal mathematics
  • Documentation generation
  • Semantic search over mathematical definitions

Example Entry

Citation

If you use this dataset, please cite Mathlib: