MathlibGraph / README.md
Xinze-Li-Moqian's picture
Rename MathFactor to MathlibGraph
b905a79 verified
|
raw
history blame
2.58 kB
metadata
license: apache-2.0
task_categories:
  - graph-ml
language:
  - en
tags:
  - mathematics
  - lean4
  - mathlib
  - dependency-graph
  - formal-verification
size_categories:
  - 100K<n<1M

MathlibGraph: Mathlib Dependency Graph Dataset

Dependency graph of Mathlib (v4.28.0-rc1), the largest formal mathematics library for Lean 4.

Files

File Rows Description
mathlib_nodes.csv 347,356 Mathlib declarations (name, kind, module)
mathlib_edges.csv 10,417,589 Mathlib dependencies (source, target, is_explicit)
nodes.csv 633,364 Full environment (Lean + Std + Mathlib)
edges.csv 10,889,011 Full environment edges

Statistics (Mathlib only)

Kind Count %
theorem 273,767 78.8%
definition 55,671 16.0%
abbrev 7,490 2.2%
constructor 5,436 1.6%
inductive 4,297 1.2%
other 695 0.2%

Quick Start

from huggingface_hub import hf_hub_download
import pandas as pd

nodes = pd.read_csv(hf_hub_download("Xinze-Li-Moqian/MathlibGraph", "mathlib_nodes.csv", repo_type="dataset"))
edges = pd.read_csv(hf_hub_download("Xinze-Li-Moqian/MathlibGraph", "mathlib_edges.csv", repo_type="dataset"))

print(f"Nodes: {len(nodes)}, Edges: {len(edges)}")
# Output: Nodes: 347356, Edges: 10417589

Extraction Pipeline

  • Nodes: lean4export (official leanprover tool)
  • Edges: lean-training-data premises (Kim Morrison, Mathlib maintainer)
  • Filtering: premises whitelist method — lake exe premises Mathlib outputs only Mathlib declarations, which we use to filter the full lean4export output

Schema

mathlib_nodes.csv

Column Type Description
name string Declaration name (e.g., CategoryTheory.Functor.comp_id)
kind string theorem, definition, abbrev, inductive, constructor, etc.
module string Lean namespace (e.g., CategoryTheory.Functor)

mathlib_edges.csv

Column Type Description
source string Dependent declaration
target string Dependency
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