Datasets:
Dataset Preview
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code: DatasetGenerationCastError
Exception: DatasetGenerationCastError
Message: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 3 new columns ({'name', 'kind', 'module'}) and 4 missing columns ({'source', 'is_simplifier', 'target', 'is_explicit'}).
This happened while the csv dataset builder was generating data using
hf://datasets/MathNetwork/MathlibGraph/mathlib_nodes.csv (at revision cd4ac7196953c9ef99a645181b2485f926b5b7a7), [/tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/edges.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/edges.csv), /tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_edges.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_edges.csv), /tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_nodes.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_nodes.csv), /tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/nodes.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/nodes.csv)]
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback: Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1890, in _prepare_split_single
writer.write_table(table)
File "/usr/local/lib/python3.12/site-packages/datasets/arrow_writer.py", line 760, in write_table
pa_table = table_cast(pa_table, self._schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2272, in table_cast
return cast_table_to_schema(table, schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2218, in cast_table_to_schema
raise CastError(
datasets.table.CastError: Couldn't cast
name: string
kind: string
module: string
-- schema metadata --
pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 591
to
{'source': Value('string'), 'target': Value('string'), 'is_explicit': Value('bool'), 'is_simplifier': Value('bool')}
because column names don't match
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1347, in compute_config_parquet_and_info_response
parquet_operations = convert_to_parquet(builder)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 980, in convert_to_parquet
builder.download_and_prepare(
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 884, in download_and_prepare
self._download_and_prepare(
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 947, in _download_and_prepare
self._prepare_split(split_generator, **prepare_split_kwargs)
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1739, in _prepare_split
for job_id, done, content in self._prepare_split_single(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1892, in _prepare_split_single
raise DatasetGenerationCastError.from_cast_error(
datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 3 new columns ({'name', 'kind', 'module'}) and 4 missing columns ({'source', 'is_simplifier', 'target', 'is_explicit'}).
This happened while the csv dataset builder was generating data using
hf://datasets/MathNetwork/MathlibGraph/mathlib_nodes.csv (at revision cd4ac7196953c9ef99a645181b2485f926b5b7a7), [/tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/edges.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/edges.csv), /tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_edges.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_edges.csv), /tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_nodes.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/mathlib_nodes.csv), /tmp/hf-datasets-cache/medium/datasets/36326968204766-config-parquet-and-info-MathNetwork-MathlibGraph-5c3a87fa/hub/datasets--MathNetwork--MathlibGraph/snapshots/cd4ac7196953c9ef99a645181b2485f926b5b7a7/nodes.csv (origin=hf://datasets/MathNetwork/MathlibGraph@cd4ac7196953c9ef99a645181b2485f926b5b7a7/nodes.csv)]
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
source string | target string | is_explicit bool | is_simplifier bool |
|---|---|---|---|
Commute.exp_right | Eq.mpr | true | false |
Commute.exp_right | Algebra.to_smulCommClass | false | false |
Commute.exp_right | instHSMul | false | false |
Commute.exp_right | IsScalarTower.right | false | false |
Commute.exp_right | DivisionCommMonoid.toDivisionMonoid | false | false |
Commute.exp_right | Commute.pow_right | true | false |
Commute.exp_right | DivInvOneMonoid.toInvOneClass | false | false |
Commute.exp_right | Ring.toNonAssocRing | false | false |
Commute.exp_right | IsTopologicalRing.toIsTopologicalSemiring | false | false |
Commute.exp_right | Monoid.toMulOneClass | false | false |
Commute.exp_right | congrArg | true | false |
Commute.exp_right | NormedSpace.exp_eq_tsum | true | false |
Commute.exp_right | NormedSpace.exp | false | false |
Commute.exp_right | Rat | true | false |
Commute.exp_right | AddGroupWithOne.toAddMonoidWithOne | false | false |
Commute.exp_right | Algebra | true | false |
Commute.exp_right | Classical.propDecidable | false | false |
Commute.exp_right | Commute | true | false |
Commute.exp_right | Rat.commSemiring | false | false |
Commute.exp_right | Algebra.toSMul | false | false |
Commute.exp_right | DivisionMonoid.toDivInvOneMonoid | false | false |
Commute.exp_right | Field.toDivisionRing | false | false |
Commute.exp_right | Monoid.toNatPow | false | false |
Commute.exp_right | Algebra.toModule | false | false |
Commute.exp_right | id | true | false |
Commute.exp_right | MulOne.toMul | false | false |
Commute.exp_right | NonUnitalNonAssocRing.toNonUnitalNonAssocSemiring | false | false |
Commute.exp_right | Nonempty.some | false | false |
Commute.exp_right | AddMonoidWithOne.toNatCast | false | false |
Commute.exp_right | Commute.tsum_right | true | false |
Commute.exp_right | DivisionRing.toRing | false | false |
Commute.exp_right | NonAssocSemiring.toMulZeroOneClass | false | false |
Commute.exp_right | dif_neg | true | false |
Commute.exp_right | Nat.cast | true | false |
Commute.exp_right | Field.toSemifield | false | false |
Commute.exp_right | NonAssocRing.toNonUnitalNonAssocRing | false | false |
Commute.exp_right | SummationFilter.instNeBotUnconditional | false | false |
Commute.exp_right | dite | true | false |
Commute.exp_right | MulZeroOneClass.toMulOneClass | false | false |
Commute.exp_right | IsTopologicalRing | false | false |
Commute.exp_right | NonUnitalNonAssocSemiring.toAddCommMonoid | false | false |
Commute.exp_right | AddMonoidWithOne.toOne | false | false |
Commute.exp_right | TopologicalSpace | false | false |
Commute.exp_right | MulOneClass.toMulOne | false | false |
Commute.exp_right | Commute.smul_right | true | false |
Commute.exp_right | NormedSpace.exp_def | true | false |
Commute.exp_right | Inv.inv | true | false |
Commute.exp_right | Semifield.toDivisionSemiring | false | false |
Commute.exp_right | Rat.instField | false | false |
Commute.exp_right | Rat.instCharZero | false | false |
Commute.exp_right | HPow.hPow | false | false |
Commute.exp_right | Distrib.toMul | false | false |
Commute.exp_right | Nat.factorial | true | false |
Commute.exp_right | tsum | false | false |
Commute.exp_right | NormedSpace.definition._proof_1._@.Mathlib.Analysis.Normed.Algebra.Exponential.267156490._hygCtx._hyg.8 | false | false |
Commute.exp_right | Nat | false | false |
Commute.exp_right | T2Space | false | false |
Commute.exp_right | Nonempty.casesOn | true | false |
Commute.exp_right | Semifield.toCommGroupWithZero | false | false |
Commute.exp_right | NormedSpace.definition._proof_2._@.Mathlib.Analysis.Normed.Algebra.Exponential.267156490._hygCtx._hyg.8 | false | false |
Commute.exp_right | DivisionSemiring.toSemiring | false | false |
Commute.exp_right | One.toOfNat1 | false | false |
Commute.exp_right | NonUnitalNonAssocSemiring.toDistrib | false | false |
Commute.exp_right | Nonempty | true | false |
Commute.exp_right | CommGroupWithZero.toDivisionCommMonoid | false | false |
Commute.exp_right | HSMul.hSMul | false | false |
Commute.exp_right | InvOneClass.toInv | false | false |
Commute.exp_right | Semifield.toCommSemiring | false | false |
Commute.exp_right | instHPow | false | false |
Commute.exp_right | NormedSpace.expSeries | false | false |
Commute.exp_right | OfNat.ofNat | false | false |
Commute.exp_right | Semiring.toNonAssocSemiring | false | false |
Commute.exp_right | Ring.toSemiring | false | false |
Commute.exp_right | Eq | false | false |
Commute.exp_right | Commute.one_right | true | false |
Commute.exp_right | Ring | false | false |
Commute.exp_right | Ring.toAddGroupWithOne | false | false |
Commute.exp_right | Not | false | false |
Commute.exp_right | MonoidWithZero.toMonoid | false | false |
Commute.exp_right | FormalMultilinearSeries.sum | false | false |
Commute.exp_right | SummationFilter.unconditional | false | false |
Commute.exp_right | Semiring.toMonoidWithZero | false | false |
AddGroupNorm.add_apply | Real | false | false |
AddGroupNorm.add_apply | Real.instAdd | false | false |
AddGroupNorm.add_apply | instHAdd | false | false |
AddGroupNorm.add_apply | AddGroup | false | false |
AddGroupNorm.add_apply | HAdd.hAdd | false | false |
AddGroupNorm.add_apply | AddGroupNorm.funLike | false | false |
AddGroupNorm.add_apply | AddGroupNorm.instAdd | false | false |
AddGroupNorm.add_apply | Eq | false | false |
AddGroupNorm.add_apply | DFunLike.coe | false | false |
AddGroupNorm.add_apply | AddGroupNorm | false | false |
AddGroupNorm.add_apply | rfl | true | false |
HahnModule.instBaseModule | DistribMulAction.toDistribSMul | false | false |
HahnModule.instBaseModule | inferInstanceAs | true | false |
HahnModule.instBaseModule | AddMonoid.toAddZeroClass | false | false |
HahnModule.instBaseModule | HahnModule | false | false |
HahnModule.instBaseModule | AddZeroClass.toAddZero | false | false |
HahnModule.instBaseModule | PartialOrder | false | false |
HahnModule.instBaseModule | HahnSeries.instAddCommMonoid | false | false |
End of preview.
MathlibGraph: Mathlib Dependency Graph Dataset
Dependency graph of Mathlib (commit 534cf0b, 2 Feb 2026), the largest formal mathematics library for Lean 4.
Files
| File | Rows | Unique entries | Description |
|---|---|---|---|
mathlib_nodes.csv |
317,655 | 308,129 declarations | Mathlib declarations (name, kind, module) |
mathlib_edges.csv |
8,436,366 | 8,436,366 edges | Mathlib dependencies (source, target, is_explicit) |
nodes.csv |
633,364 | — | Full environment (Lean + Std + Mathlib) |
edges.csv |
10,889,011 | — | Full environment edges |
Note:
mathlib_nodes.csvcontains 9,526 duplicate name rows produced by@[to_additive]mirroring. After deduplication, there are 308,129 unique declarations — the figure used throughout the paper.
Statistics (308,129 unique Mathlib declarations)
| Kind | Count | % |
|---|---|---|
| theorem | 243,725 | 79.1% |
| definition | 48,664 | 15.8% |
| abbrev | 6,667 | 2.2% |
| constructor | 4,755 | 1.5% |
| inductive | 3,813 | 1.2% |
| opaque | 499 | 0.2% |
| quotient | 3 | <0.1% |
| axiom | 3 | <0.1% |
Quick Start
from datasets import load_dataset
import pandas as pd
nodes = load_dataset("MathNetwork/MathlibGraph",
data_files="mathlib_nodes.csv", split="train").to_pandas()
edges = load_dataset("MathNetwork/MathlibGraph",
data_files="mathlib_edges.csv", split="train").to_pandas()
# Deduplicate nodes (9,526 @[to_additive] mirrors)
nodes = nodes.drop_duplicates(subset="name", keep="first")
print(f"Declarations: {len(nodes):,}, Edges: {len(edges):,}")
# Output: Declarations: 308,129, Edges: 8,436,366
Extraction Pipeline
- Nodes: lean4export (official leanprover tool)
- Edges: lean-training-data premises (Kim Morrison, Mathlib maintainer)
- Filtering: premises whitelist method —
lake exe premises Mathliboutputs only Mathlib declarations, which we use to filter the full lean4export output
Schema
mathlib_nodes.csv
| Column | Type | Description |
|---|---|---|
| name | string | Fully qualified declaration name (e.g., CategoryTheory.Functor.comp_id) |
| kind | string | theorem, definition, abbrev, inductive, constructor, opaque, axiom, quotient |
| module | string | Lean module (e.g., CategoryTheory.Functor) |
mathlib_edges.csv
| Column | Type | Description |
|---|---|---|
| source | string | Dependent declaration |
| target | string | Dependency (premise) |
| is_explicit | bool | Appears in explicit arguments |
| is_simplifier | bool | Used by simplifier |
Citation
Part of the MathlibGraph project — network analysis of formalized mathematics.
License
Apache 2.0
- Downloads last month
- 21