File size: 2,573 Bytes
63f14c3
eb8bc8a
 
5a04812
 
eb8bc8a
5a04812
eb8bc8a
5a04812
 
 
 
 
eb8bc8a
5a04812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63f14c3
eb8bc8a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
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

- **Source:** [leanprover-community/mathlib4](https://github.com/leanprover-community/mathlib4)
- **Entries:** 193,047
- **Files processed:** 6,943
- **License:** Apache 2.0

## 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: