Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -19,153 +19,166 @@ size_categories:
|
|
| 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 |
-
|
|
| 34 |
|
| 35 |
## Files
|
| 36 |
|
| 37 |
-
### Raw
|
| 38 |
|
| 39 |
| File | Rows | Description |
|
| 40 |
|------|------|-------------|
|
| 41 |
-
| `
|
| 42 |
-
| `
|
| 43 |
-
| `nodes.csv` |
|
| 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 |
-
###
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|------|------|-------------|
|
| 52 |
-
| `v2/mathlib_module_nodes.csv` | 7,564 | Module (source file) list with decl_count |
|
| 53 |
-
| `v2/mathlib_module_edges.csv` | 20,881 | Module import edges (source, target) |
|
| 54 |
-
| `v2/mathlib_namespace_nodes_k2.csv` | 10,097 | Depth-2 namespace list with decl_count |
|
| 55 |
-
| `v2/mathlib_namespace_edges_k2.csv` | 332,081 | Namespace edges with weight (aggregated from declaration edges) |
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|------|------|---------|-------------|
|
| 61 |
-
| `v2/mathlib_nodes_enriched.csv` | 308,129 | 11 | Deduplicated declarations with network metrics |
|
| 62 |
-
| `v2/mathlib_modules.csv` | 7,564 | 10 | Per-module precomputed metrics |
|
| 63 |
-
| `v2/mathlib_namespaces_k2.csv` | 10,097 | 9 | Per-namespace precomputed metrics |
|
| 64 |
-
| `v2/mathlib_summary.json` | — | — | Headline statistics for all three graph levels |
|
| 65 |
|
| 66 |
## Quick Start
|
| 67 |
|
| 68 |
```python
|
| 69 |
from datasets import load_dataset
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
edges = load_dataset("MathNetwork/MathlibGraph",
|
| 74 |
data_files="mathlib_edges.csv", split="train").to_pandas()
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
```
|
| 79 |
|
| 80 |
## Schema
|
| 81 |
|
| 82 |
-
### v2/
|
| 83 |
-
|
| 84 |
-
| Column | Type | Description |
|
| 85 |
-
|--------|------|-------------|
|
| 86 |
-
| module | str | Dotted module name (e.g., `Mathlib.Algebra.Group.Defs`) |
|
| 87 |
-
| decl_count | int | Number of declarations defined in this module |
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
| Column | Type | Description |
|
| 92 |
|--------|------|-------------|
|
| 93 |
-
|
|
| 94 |
-
|
|
|
|
|
| 95 |
|
| 96 |
-
### v2/
|
|
|
|
|
|
|
| 97 |
|
| 98 |
| Column | Type | Description |
|
| 99 |
|--------|------|-------------|
|
| 100 |
-
|
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
### v2/
|
| 104 |
|
| 105 |
| Column | Type | Description |
|
| 106 |
|--------|------|-------------|
|
| 107 |
-
|
|
| 108 |
-
|
|
| 109 |
-
| weight | int | Number of declaration-level edges between these namespaces |
|
| 110 |
|
| 111 |
-
### v2/
|
| 112 |
|
| 113 |
| Column | Type | Description |
|
| 114 |
|--------|------|-------------|
|
| 115 |
-
|
|
| 116 |
-
|
|
| 117 |
-
| module | str | Parent namespace of the declaration (null for 30,944 Lean core declarations) |
|
| 118 |
-
| namespace_depth2 | str | First 2 dot-separated name components (e.g., `Mathlib.Algebra`) |
|
| 119 |
-
| namespace_depth3 | str | First 3 dot-separated name components |
|
| 120 |
-
| in_degree | int | Declarations that depend on this one |
|
| 121 |
-
| out_degree | int | Declarations this one depends on |
|
| 122 |
-
| pagerank | float | PageRank (alpha=0.85) |
|
| 123 |
-
| betweenness | float | Betweenness centrality (sampled, k=500, seed=42) |
|
| 124 |
-
| community_id | int | Louvain community assignment |
|
| 125 |
-
| dag_layer | int | Topological depth; -1 for 5,732 nodes in cycles |
|
| 126 |
|
| 127 |
-
### v2/
|
| 128 |
|
| 129 |
| Column | Type | Description |
|
| 130 |
|--------|------|-------------|
|
| 131 |
-
| module | str |
|
| 132 |
-
| decl_count | int | Declarations
|
| 133 |
| in_degree | int | Modules that import this one |
|
| 134 |
| out_degree | int | Modules this one imports |
|
| 135 |
| pagerank | float | PageRank on module import graph |
|
| 136 |
-
| betweenness | float | Betweenness centrality (exact
|
| 137 |
| dag_layer | int | Topological depth in module DAG |
|
| 138 |
-
| community_id | int | Louvain community
|
| 139 |
-
| cohesion | float | Fraction of edges
|
| 140 |
-
| import_utilization_median | float | Median fraction of imported declarations
|
| 141 |
|
| 142 |
-
### v2/
|
| 143 |
|
| 144 |
| Column | Type | Description |
|
| 145 |
|--------|------|-------------|
|
| 146 |
| namespace | str | Depth-2 namespace (e.g., `Mathlib.Algebra`) |
|
| 147 |
| decl_count | int | Declarations in this namespace |
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
| out_degree | int | Unweighted out-degree |
|
| 150 |
-
| edge_weight_sum | int |
|
| 151 |
| pagerank | float | Weighted PageRank (alpha=0.85) |
|
| 152 |
| betweenness | float | Weighted betweenness (k=300, seed=42) |
|
| 153 |
-
| community_id | int | Louvain community
|
| 154 |
| cross_ns_ratio | float | Fraction of edges crossing namespace boundaries |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
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`.
|
| 159 |
|
| 160 |
## Methodology
|
| 161 |
|
| 162 |
-
- **Extraction**: lean4export (nodes) + lean-training-data (edges) + importGraph (module graph) + jixia (
|
| 163 |
-
- **Deduplication**: by name, 317,655 to 308,129 rows (9,526 `@[to_additive]` mirrors
|
| 164 |
-
- **Self-loops**: 4,755 constructor self-references filtered
|
| 165 |
- **PageRank**: alpha=0.85, max_iter=100, tol=1e-6
|
| 166 |
-
- **Betweenness**: declaration k=500, namespace k=300, module exact;
|
| 167 |
-
- **Communities**: Louvain
|
| 168 |
-
- **DAG layers**: Kahn's algorithm;
|
|
|
|
| 169 |
|
| 170 |
## License
|
| 171 |
|
|
|
|
| 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), each with nodes, edges, and 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 (weighted) |
|
| 30 |
+
| DAG depth | 83 | 154 | 7 (after SCC condensation) |
|
| 31 |
| Louvain modularity | 0.478 | 0.610 | 0.270 |
|
| 32 |
| Synthesized edges | 74.2% | — | — |
|
| 33 |
+
| In cycles | 5,732 nodes | 0 (DAG) | 6,055 nodes (38 SCCs) |
|
| 34 |
|
| 35 |
## Files
|
| 36 |
|
| 37 |
+
### Raw Data (v1)
|
| 38 |
|
| 39 |
| File | Rows | Description |
|
| 40 |
|------|------|-------------|
|
| 41 |
+
| `mathlib_edges.csv` | 8,436,366 | Declaration dependency edges |
|
| 42 |
+
| `mathlib_nodes.csv` | 317,655 | Declarations before deduplication |
|
| 43 |
+
| `nodes.csv` / `edges.csv` | 633K / 10.9M | Full environment (Lean + Std + Mathlib) |
|
|
|
|
| 44 |
| `mechanisms.ndjson` | — | Lean language mechanism extractions |
|
| 45 |
| `tactic_usage.ndjson` | — | Per-declaration tactic usage profiles |
|
| 46 |
|
| 47 |
+
### Three-Layer Graphs (v2)
|
| 48 |
|
| 49 |
+
Each layer has `nodes.csv`, `edges.csv`, and `metrics.csv`:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
| Folder | Nodes | Edges | Metrics | Description |
|
| 52 |
+
|--------|-------|-------|---------|-------------|
|
| 53 |
+
| `v2/declaration/` | 308,129 | (use root `mathlib_edges.csv`) | 308,129 x 11 | Theorems, definitions, and other named constants |
|
| 54 |
+
| `v2/module/` | 7,564 | 20,881 | 7,564 x 10 | Source files linked by `import` statements |
|
| 55 |
+
| `v2/namespace/` | 10,097 | 332,081 | 10,097 x 11 | Depth-2 dotted-name prefixes, weighted edges |
|
| 56 |
|
| 57 |
+
`v2/summary.json` contains headline statistics for all three levels.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
## Quick Start
|
| 60 |
|
| 61 |
```python
|
| 62 |
from datasets import load_dataset
|
| 63 |
|
| 64 |
+
# Declaration level
|
| 65 |
+
decl = load_dataset("MathNetwork/MathlibGraph",
|
| 66 |
+
data_files="v2/declaration/metrics.csv", split="train").to_pandas()
|
| 67 |
edges = load_dataset("MathNetwork/MathlibGraph",
|
| 68 |
data_files="mathlib_edges.csv", split="train").to_pandas()
|
| 69 |
|
| 70 |
+
# Module level
|
| 71 |
+
mod_nodes = load_dataset("MathNetwork/MathlibGraph",
|
| 72 |
+
data_files="v2/module/nodes.csv", split="train").to_pandas()
|
| 73 |
+
mod_edges = load_dataset("MathNetwork/MathlibGraph",
|
| 74 |
+
data_files="v2/module/edges.csv", split="train").to_pandas()
|
| 75 |
+
|
| 76 |
+
# Namespace level
|
| 77 |
+
ns_nodes = load_dataset("MathNetwork/MathlibGraph",
|
| 78 |
+
data_files="v2/namespace/nodes.csv", split="train").to_pandas()
|
| 79 |
+
ns_edges = load_dataset("MathNetwork/MathlibGraph",
|
| 80 |
+
data_files="v2/namespace/edges.csv", split="train").to_pandas()
|
| 81 |
```
|
| 82 |
|
| 83 |
## Schema
|
| 84 |
|
| 85 |
+
### v2/declaration/nodes.csv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
+
Deduplicated from `mathlib_nodes.csv` (317,655 to 308,129 rows; 9,526 `@[to_additive]` mirrors removed).
|
| 88 |
|
| 89 |
| Column | Type | Description |
|
| 90 |
|--------|------|-------------|
|
| 91 |
+
| name | str | Fully qualified declaration name |
|
| 92 |
+
| kind | str | theorem, definition, abbrev, inductive, constructor, opaque, axiom, or quotient |
|
| 93 |
+
| module | str | Parent namespace (null for 30,944 Lean core declarations) |
|
| 94 |
|
| 95 |
+
### v2/declaration/metrics.csv
|
| 96 |
+
|
| 97 |
+
All columns from `nodes.csv` plus:
|
| 98 |
|
| 99 |
| Column | Type | Description |
|
| 100 |
|--------|------|-------------|
|
| 101 |
+
| namespace_depth2 | str | First 2 dot-separated components (e.g., `Mathlib.Algebra`) |
|
| 102 |
+
| namespace_depth3 | str | First 3 dot-separated components |
|
| 103 |
+
| in_degree | int | Declarations that depend on this one |
|
| 104 |
+
| out_degree | int | Declarations this one depends on |
|
| 105 |
+
| pagerank | float | PageRank (alpha=0.85) |
|
| 106 |
+
| betweenness | float | Betweenness centrality (k=500, seed=42) |
|
| 107 |
+
| community_id | int | Louvain community |
|
| 108 |
+
| dag_layer | int | Topological depth; -1 for 5,732 nodes in cycles |
|
| 109 |
|
| 110 |
+
### v2/module/nodes.csv
|
| 111 |
|
| 112 |
| Column | Type | Description |
|
| 113 |
|--------|------|-------------|
|
| 114 |
+
| module | str | Dotted module name (e.g., `Mathlib.Algebra.Group.Defs`) |
|
| 115 |
+
| decl_count | int | Declarations defined in this source file |
|
|
|
|
| 116 |
|
| 117 |
+
### v2/module/edges.csv
|
| 118 |
|
| 119 |
| Column | Type | Description |
|
| 120 |
|--------|------|-------------|
|
| 121 |
+
| source | str | Importing module |
|
| 122 |
+
| target | str | Imported module |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
|
| 124 |
+
### v2/module/metrics.csv
|
| 125 |
|
| 126 |
| Column | Type | Description |
|
| 127 |
|--------|------|-------------|
|
| 128 |
+
| module | str | Module name |
|
| 129 |
+
| decl_count | int | Declarations (235K jixia coverage) |
|
| 130 |
| in_degree | int | Modules that import this one |
|
| 131 |
| out_degree | int | Modules this one imports |
|
| 132 |
| pagerank | float | PageRank on module import graph |
|
| 133 |
+
| betweenness | float | Betweenness centrality (exact) |
|
| 134 |
| dag_layer | int | Topological depth in module DAG |
|
| 135 |
+
| community_id | int | Louvain community |
|
| 136 |
+
| cohesion | float | Fraction of declaration edges staying within module |
|
| 137 |
+
| import_utilization_median | float | Median fraction of imported declarations used |
|
| 138 |
|
| 139 |
+
### v2/namespace/nodes.csv
|
| 140 |
|
| 141 |
| Column | Type | Description |
|
| 142 |
|--------|------|-------------|
|
| 143 |
| namespace | str | Depth-2 namespace (e.g., `Mathlib.Algebra`) |
|
| 144 |
| decl_count | int | Declarations in this namespace |
|
| 145 |
+
| in_cycle | bool | True if this namespace is in a strongly connected component |
|
| 146 |
+
| scc_id | int | SCC identifier (-1 if not in a cycle) |
|
| 147 |
+
|
| 148 |
+
### v2/namespace/edges.csv
|
| 149 |
+
|
| 150 |
+
| Column | Type | Description |
|
| 151 |
+
|--------|------|-------------|
|
| 152 |
+
| source | str | Source namespace |
|
| 153 |
+
| target | str | Target namespace |
|
| 154 |
+
| weight | int | Number of declaration-level edges between these namespaces |
|
| 155 |
+
|
| 156 |
+
### v2/namespace/metrics.csv
|
| 157 |
+
|
| 158 |
+
| Column | Type | Description |
|
| 159 |
+
|--------|------|-------------|
|
| 160 |
+
| namespace | str | Depth-2 namespace |
|
| 161 |
+
| decl_count | int | Declarations in this namespace |
|
| 162 |
+
| in_degree | int | Unweighted in-degree |
|
| 163 |
| out_degree | int | Unweighted out-degree |
|
| 164 |
+
| edge_weight_sum | int | Total declaration edges involving this namespace |
|
| 165 |
| pagerank | float | Weighted PageRank (alpha=0.85) |
|
| 166 |
| betweenness | float | Weighted betweenness (k=300, seed=42) |
|
| 167 |
+
| community_id | int | Louvain community (weighted undirected) |
|
| 168 |
| cross_ns_ratio | float | Fraction of edges crossing namespace boundaries |
|
| 169 |
+
| in_cycle | bool | In a strongly connected component (6,055 of 10,097) |
|
| 170 |
+
| scc_id | int | SCC identifier (-1 if acyclic) |
|
|
|
|
|
|
|
| 171 |
|
| 172 |
## Methodology
|
| 173 |
|
| 174 |
+
- **Extraction**: lean4export (nodes) + lean-training-data (edges) + importGraph (module graph) + jixia (metadata)
|
| 175 |
+
- **Deduplication**: by name, 317,655 to 308,129 rows (9,526 `@[to_additive]` mirrors)
|
| 176 |
+
- **Self-loops**: 4,755 constructor self-references filtered
|
| 177 |
- **PageRank**: alpha=0.85, max_iter=100, tol=1e-6
|
| 178 |
+
- **Betweenness**: declaration k=500, namespace k=300, module exact; seed=42
|
| 179 |
+
- **Communities**: Louvain, resolution=1.0, random_state=42, undirected projection
|
| 180 |
+
- **DAG layers**: Kahn's algorithm; cycle nodes get layer=-1; namespace graph condensed via SCC
|
| 181 |
+
- **Namespace cycles**: 6,055 of 10,097 namespaces in 38 SCCs (largest: 5,899 nodes)
|
| 182 |
|
| 183 |
## License
|
| 184 |
|