Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -10,156 +10,136 @@ tags:
|
|
| 10 |
- mathlib
|
| 11 |
- dependency-graph
|
| 12 |
- formal-verification
|
|
|
|
| 13 |
size_categories:
|
| 14 |
- 100K<n<1M
|
| 15 |
---
|
| 16 |
|
| 17 |
-
# MathlibGraph:
|
| 18 |
|
| 19 |
-
Dependency graph of [Mathlib](https://github.com/leanprover-community/mathlib4) (commit [`534cf0b`](https://github.com/leanprover-community/mathlib4/commit/534cf0b), 2 Feb 2026), the largest formal mathematics library for Lean 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
## Files
|
| 22 |
|
| 23 |
-
###
|
| 24 |
|
| 25 |
| File | Rows | Description |
|
| 26 |
|------|------|-------------|
|
| 27 |
-
| `mathlib_nodes.csv` | 317,655
|
| 28 |
-
| `mathlib_edges.csv` | 8,436,366 |
|
| 29 |
-
| `nodes.csv` | 633,364 | Full environment
|
| 30 |
| `edges.csv` | 10,889,011 | Full environment edges |
|
| 31 |
| `mechanisms.ndjson` | — | Lean language mechanism extractions |
|
| 32 |
-
| `tactic_usage.ndjson` | — |
|
| 33 |
|
| 34 |
-
### Enriched
|
| 35 |
|
| 36 |
-
| File | Rows | Description |
|
| 37 |
-
|------|------|-------------|
|
| 38 |
-
| `v2/mathlib_nodes_enriched.csv` | 308,129 | Deduplicated
|
| 39 |
-
| `v2/mathlib_modules.csv` | 7,564 | Per-module (source file) metrics |
|
| 40 |
-
| `v2/mathlib_namespaces_k2.csv` | 10,097 | Per-namespace (depth-2) metrics |
|
| 41 |
-
| `v2/mathlib_summary.json` | — | Headline statistics for all three graph levels |
|
| 42 |
-
|
| 43 |
-
> **Note:** `mathlib_nodes.csv` contains 9,526 duplicate name rows from `@[to_additive]` mirroring. The v2 enriched file is deduplicated to **308,129 unique declarations**.
|
| 44 |
-
|
| 45 |
-
## Statistics (308,129 unique Mathlib declarations)
|
| 46 |
-
|
| 47 |
-
| Kind | Count | % |
|
| 48 |
-
|------|-------|---|
|
| 49 |
-
| theorem | 251,642 | 79.2% |
|
| 50 |
-
| definition | 50,156 | 15.8% |
|
| 51 |
-
| abbrev | 6,784 | 2.1% |
|
| 52 |
-
| constructor | 4,755 | 1.5% |
|
| 53 |
-
| inductive | 3,813 | 1.2% |
|
| 54 |
-
| opaque | 499 | 0.2% |
|
| 55 |
-
| quotient | 3 | <0.1% |
|
| 56 |
-
| axiom | 3 | <0.1% |
|
| 57 |
|
| 58 |
## Quick Start
|
| 59 |
|
| 60 |
```python
|
| 61 |
from datasets import load_dataset
|
| 62 |
|
| 63 |
-
# Load enriched nodes (v2, deduplicated, with metrics)
|
| 64 |
nodes = load_dataset("MathNetwork/MathlibGraph",
|
| 65 |
data_files="v2/mathlib_nodes_enriched.csv", split="train").to_pandas()
|
| 66 |
edges = load_dataset("MathNetwork/MathlibGraph",
|
| 67 |
data_files="mathlib_edges.csv", split="train").to_pandas()
|
| 68 |
|
| 69 |
print(f"Declarations: {len(nodes):,}, Edges: {len(edges):,}")
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
# Top 10 by PageRank
|
| 73 |
-
print(nodes.nlargest(10, "pagerank")[["name", "kind", "in_degree", "pagerank"]])
|
| 74 |
-
|
| 75 |
-
# Load module-level data
|
| 76 |
-
modules = load_dataset("MathNetwork/MathlibGraph",
|
| 77 |
-
data_files="v2/mathlib_modules.csv", split="train").to_pandas()
|
| 78 |
-
print(f"Modules: {len(modules):,}")
|
| 79 |
```
|
| 80 |
|
| 81 |
## Schema
|
| 82 |
|
| 83 |
-
### mathlib_nodes.csv (v1)
|
| 84 |
-
|
| 85 |
-
| Column | Type | Description |
|
| 86 |
-
|--------|------|-------------|
|
| 87 |
-
| name | string | Fully qualified declaration name |
|
| 88 |
-
| kind | string | `theorem`, `definition`, `abbrev`, `inductive`, `constructor`, `opaque`, `axiom`, `quotient` |
|
| 89 |
-
| module | string | Parent namespace of the declaration |
|
| 90 |
-
|
| 91 |
-
### mathlib_edges.csv
|
| 92 |
-
|
| 93 |
-
| Column | Type | Description |
|
| 94 |
-
|--------|------|-------------|
|
| 95 |
-
| source | string | Dependent declaration |
|
| 96 |
-
| target | string | Dependency (premise) |
|
| 97 |
-
| is_explicit | bool | Appears in explicit arguments (25.8% of edges) |
|
| 98 |
-
| is_simplifier | bool | Used by simplifier |
|
| 99 |
-
|
| 100 |
### v2/mathlib_nodes_enriched.csv
|
| 101 |
|
| 102 |
-
All columns from `mathlib_nodes.csv` plus:
|
| 103 |
-
|
| 104 |
| Column | Type | Description |
|
| 105 |
|--------|------|-------------|
|
| 106 |
-
|
|
| 107 |
-
|
|
| 108 |
-
|
|
| 109 |
-
|
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
| 111 |
| betweenness | float | Betweenness centrality (sampled, k=500, seed=42) |
|
| 112 |
-
| community_id | int | Louvain community
|
| 113 |
-
| dag_layer | int | Topological depth
|
| 114 |
|
| 115 |
### v2/mathlib_modules.csv
|
| 116 |
|
| 117 |
-
One row per Mathlib source file (7,564 modules).
|
| 118 |
-
|
| 119 |
| Column | Type | Description |
|
| 120 |
|--------|------|-------------|
|
| 121 |
-
| module |
|
| 122 |
-
| decl_count | int | Declarations in this module (
|
| 123 |
-
| in_degree | int | Modules that import this
|
| 124 |
-
| out_degree | int | Modules this
|
| 125 |
| pagerank | float | PageRank on module import graph |
|
| 126 |
| betweenness | float | Betweenness centrality (exact, no sampling) |
|
| 127 |
| dag_layer | int | Topological depth in module DAG |
|
| 128 |
-
| community_id | int | Louvain community
|
| 129 |
-
| cohesion | float |
|
| 130 |
| import_utilization_median | float | Median fraction of imported declarations actually used |
|
| 131 |
|
| 132 |
### v2/mathlib_namespaces_k2.csv
|
| 133 |
|
| 134 |
-
One row per depth-2 namespace (10,097 namespaces).
|
| 135 |
-
|
| 136 |
| Column | Type | Description |
|
| 137 |
|--------|------|-------------|
|
| 138 |
-
| namespace |
|
| 139 |
| decl_count | int | Declarations in this namespace |
|
| 140 |
| in_degree | int | Unweighted in-degree in namespace graph |
|
| 141 |
-
| out_degree | int | Unweighted out-degree
|
| 142 |
-
| edge_weight_sum | int |
|
| 143 |
-
| pagerank | float | PageRank (
|
| 144 |
-
| betweenness | float |
|
| 145 |
-
| community_id | int | Louvain community
|
| 146 |
-
| cross_ns_ratio | float | Fraction of
|
| 147 |
|
| 148 |
### v2/mathlib_summary.json
|
| 149 |
|
| 150 |
-
|
| 151 |
|
| 152 |
-
##
|
| 153 |
|
| 154 |
-
- **
|
| 155 |
-
- **
|
| 156 |
-
- **
|
| 157 |
-
- **
|
| 158 |
-
- **
|
|
|
|
|
|
|
| 159 |
|
| 160 |
## Citation
|
| 161 |
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
## License
|
| 165 |
|
|
|
|
| 10 |
- mathlib
|
| 11 |
- dependency-graph
|
| 12 |
- formal-verification
|
| 13 |
+
- network-analysis
|
| 14 |
size_categories:
|
| 15 |
- 100K<n<1M
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# MathlibGraph: The Multinetwork of Mathlib
|
| 19 |
|
| 20 |
+
Dependency graph of [Mathlib](https://github.com/leanprover-community/mathlib4) (commit [`534cf0b`](https://github.com/leanprover-community/mathlib4/commit/534cf0b), 2 Feb 2026), the largest formal mathematics library for Lean 4 (`v4.28.0-rc1`).
|
| 21 |
+
|
| 22 |
+
Three dependency layers (declarations, modules, namespaces) with precomputed network metrics.
|
| 23 |
+
|
| 24 |
+
## Quick Stats
|
| 25 |
+
|
| 26 |
+
| | Declarations | Modules | Namespaces (k=2) |
|
| 27 |
+
|---|---|---|---|
|
| 28 |
+
| Nodes | 308,129 | 7,564 | 10,097 |
|
| 29 |
+
| Edges | 8,436,366 | 20,881 | 332,081 |
|
| 30 |
+
| DAG depth | 83 | 154 | 7 |
|
| 31 |
+
| Louvain modularity | 0.478 | 0.610 | 0.270 |
|
| 32 |
+
| Synthesized edges | 74.2% | — | — |
|
| 33 |
+
| Cross-namespace edges | — | — | 85.8% |
|
| 34 |
|
| 35 |
## Files
|
| 36 |
|
| 37 |
+
### Raw Graph Data
|
| 38 |
|
| 39 |
| File | Rows | Description |
|
| 40 |
|------|------|-------------|
|
| 41 |
+
| `mathlib_nodes.csv` | 317,655 | Declarations before deduplication (name, kind, module) |
|
| 42 |
+
| `mathlib_edges.csv` | 8,436,366 | Declaration dependencies (source, target, is_explicit, is_simplifier) |
|
| 43 |
+
| `nodes.csv` | 633,364 | Full environment including Lean core and Std |
|
| 44 |
| `edges.csv` | 10,889,011 | Full environment edges |
|
| 45 |
| `mechanisms.ndjson` | — | Lean language mechanism extractions |
|
| 46 |
+
| `tactic_usage.ndjson` | — | Per-declaration tactic usage profiles |
|
| 47 |
|
| 48 |
+
### Enriched Data (v2)
|
| 49 |
|
| 50 |
+
| File | Rows | Columns | Description |
|
| 51 |
+
|------|------|---------|-------------|
|
| 52 |
+
| `v2/mathlib_nodes_enriched.csv` | 308,129 | 11 | Deduplicated declarations with network metrics |
|
| 53 |
+
| `v2/mathlib_modules.csv` | 7,564 | 10 | Per-module (source file) metrics |
|
| 54 |
+
| `v2/mathlib_namespaces_k2.csv` | 10,097 | 9 | Per-namespace (depth-2) metrics |
|
| 55 |
+
| `v2/mathlib_summary.json` | — | — | Headline statistics for all three graph levels |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
## Quick Start
|
| 58 |
|
| 59 |
```python
|
| 60 |
from datasets import load_dataset
|
| 61 |
|
|
|
|
| 62 |
nodes = load_dataset("MathNetwork/MathlibGraph",
|
| 63 |
data_files="v2/mathlib_nodes_enriched.csv", split="train").to_pandas()
|
| 64 |
edges = load_dataset("MathNetwork/MathlibGraph",
|
| 65 |
data_files="mathlib_edges.csv", split="train").to_pandas()
|
| 66 |
|
| 67 |
print(f"Declarations: {len(nodes):,}, Edges: {len(edges):,}")
|
| 68 |
+
print(nodes.nlargest(5, "pagerank")[["name", "kind", "in_degree", "pagerank"]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
|
| 71 |
## Schema
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
### v2/mathlib_nodes_enriched.csv
|
| 74 |
|
|
|
|
|
|
|
| 75 |
| Column | Type | Description |
|
| 76 |
|--------|------|-------------|
|
| 77 |
+
| name | str | Fully qualified declaration name |
|
| 78 |
+
| kind | str | One of: theorem, definition, abbrev, inductive, constructor, opaque, axiom, quotient |
|
| 79 |
+
| module | str | Parent namespace of the declaration (null for 30,944 Lean core declarations) |
|
| 80 |
+
| namespace_depth2 | str | First 2 dot-separated name components (e.g., `Mathlib.Algebra`) |
|
| 81 |
+
| namespace_depth3 | str | First 3 dot-separated name components |
|
| 82 |
+
| in_degree | int | Declarations that depend on this one |
|
| 83 |
+
| out_degree | int | Declarations this one depends on |
|
| 84 |
+
| pagerank | float | PageRank (alpha=0.85) |
|
| 85 |
| betweenness | float | Betweenness centrality (sampled, k=500, seed=42) |
|
| 86 |
+
| community_id | int | Louvain community assignment |
|
| 87 |
+
| dag_layer | int | Topological depth; -1 for 5,732 nodes in cycles |
|
| 88 |
|
| 89 |
### v2/mathlib_modules.csv
|
| 90 |
|
|
|
|
|
|
|
| 91 |
| Column | Type | Description |
|
| 92 |
|--------|------|-------------|
|
| 93 |
+
| module | str | Dotted module name (e.g., `Mathlib.Algebra.Group.Defs`) |
|
| 94 |
+
| decl_count | int | Declarations in this module (235K jixia coverage) |
|
| 95 |
+
| in_degree | int | Modules that import this one |
|
| 96 |
+
| out_degree | int | Modules this one imports |
|
| 97 |
| pagerank | float | PageRank on module import graph |
|
| 98 |
| betweenness | float | Betweenness centrality (exact, no sampling) |
|
| 99 |
| dag_layer | int | Topological depth in module DAG |
|
| 100 |
+
| community_id | int | Louvain community assignment |
|
| 101 |
+
| cohesion | float | Fraction of edges that stay within the module |
|
| 102 |
| import_utilization_median | float | Median fraction of imported declarations actually used |
|
| 103 |
|
| 104 |
### v2/mathlib_namespaces_k2.csv
|
| 105 |
|
|
|
|
|
|
|
| 106 |
| Column | Type | Description |
|
| 107 |
|--------|------|-------------|
|
| 108 |
+
| namespace | str | Depth-2 namespace (e.g., `Mathlib.Algebra`) |
|
| 109 |
| decl_count | int | Declarations in this namespace |
|
| 110 |
| in_degree | int | Unweighted in-degree in namespace graph |
|
| 111 |
+
| out_degree | int | Unweighted out-degree |
|
| 112 |
+
| edge_weight_sum | int | Sum of declaration-level edges involving this namespace |
|
| 113 |
+
| pagerank | float | Weighted PageRank (alpha=0.85) |
|
| 114 |
+
| betweenness | float | Weighted betweenness (k=300, seed=42) |
|
| 115 |
+
| community_id | int | Louvain community on weighted undirected graph |
|
| 116 |
+
| cross_ns_ratio | float | Fraction of edges crossing namespace boundaries |
|
| 117 |
|
| 118 |
### v2/mathlib_summary.json
|
| 119 |
|
| 120 |
+
Top-level keys: `snapshot` (commit, date, Lean version), `declaration_graph`, `module_graph`, `namespace_graph_k2` (node/edge counts, modularity, NMI, DAG depth, power-law exponents), `edge_decompositions` (proof-only/statement-only ratios), `kind_distribution`.
|
| 121 |
|
| 122 |
+
## Methodology
|
| 123 |
|
| 124 |
+
- **Extraction**: lean4export (nodes) + lean-training-data (edges) + importGraph (module graph) + jixia (declaration metadata)
|
| 125 |
+
- **Deduplication**: by name, 317,655 to 308,129 rows (9,526 `@[to_additive]` mirrors removed)
|
| 126 |
+
- **Self-loops**: 4,755 constructor self-references filtered from graph construction
|
| 127 |
+
- **PageRank**: alpha=0.85, max_iter=100, tol=1e-6
|
| 128 |
+
- **Betweenness**: declaration k=500, namespace k=300, module exact; all with seed=42
|
| 129 |
+
- **Communities**: Louvain (python-louvain), resolution=1.0, random_state=42, on undirected projection
|
| 130 |
+
- **DAG layers**: Kahn's algorithm; 5,732 declaration nodes in cycles assigned layer=-1; namespace graph condensed via SCC
|
| 131 |
|
| 132 |
## Citation
|
| 133 |
|
| 134 |
+
```bibtex
|
| 135 |
+
@inproceedings{mathlibgraph2026,
|
| 136 |
+
title = {The Multinetwork of Mathlib},
|
| 137 |
+
author = {Li, Xinze and Shafto, Patrick},
|
| 138 |
+
booktitle = {NeurIPS 2026 Datasets and Benchmarks Track},
|
| 139 |
+
year = {2026},
|
| 140 |
+
note = {Under review}
|
| 141 |
+
}
|
| 142 |
+
```
|
| 143 |
|
| 144 |
## License
|
| 145 |
|