File size: 9,213 Bytes
941c12c 483e70f 941c12c 483e70f 8e549a6 483e70f 91823ad 483e70f 91823ad 8e549a6 483e70f 221a9e5 483e70f 510e96a f553c04 | 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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | ---
license: mit
configs:
- config_name: default
data_files:
- split: train
path: data/train/*.parquet
- split: dev
path: data/dev/*.parquet
- split: internal_test
path: data/internal_test/*.parquet
---
# LeanTransitionCorpus
> **Status: incremental upload in progress.** This repository is useful now, but
> it is not the complete planned corpus. Counts, source coverage, and shard
> inventory will grow as verified batches are added.
LeanTransitionCorpus is a dataset for training and studying automated theorem
proving systems in Lean. Its unit of data is one tactic transition: the proof state
before a tactic, the tactic that was executed, and the resulting state. This makes
it suitable for tactic prediction, proof-state representation learning, premise
selection, retrieval, verification, and trajectory-level training.
Many Lean datasets expose a theorem, tactic, and pretty-printed goal strings. This
corpus retains those human-readable views, but also preserves richer information
from Lean's elaborator: the tactic `Syntax` tree, resolved identifiers, recursive
Lean `Expr` trees, local context, metavariables, universe metavariables, source
ranges, and premise/context information. The extra representations make it
possible to investigate models that use Lean's internal structure rather than
recovering it from printed text.
Original source and environment provenance are retained per row. The repository's
MIT metadata applies to this packaging; source corpus licenses and restrictions
remain applicable and are not replaced by this card.
## Source datasets
The extraction pipeline draws from pinned snapshots of the following Lean sources.
Rows identify their origin in `source_dataset`, `source_url`, `repo_commit`, and
toolchain columns. Coverage is incremental: a source listed here may have less
published coverage than another at any point in time.
| Source | Role in the corpus |
|---|---|
| NuminaMath-CoT | Lean formalizations from the Numina mathematical reasoning corpus. This is the source of the initial uploaded seed. |
| DeepSeek-Prover | Lean proof data used to broaden theorem and tactic coverage. |
| Goedel Lean Workbook | Lean workbook proofs, retained as a separately attributable source. |
| Mathlib | The pinned Mathlib snapshot supplies the theorem-proving environment and contributes directly extracted Mathlib theorems. |
## How the data is produced
For each selected theorem, the extractor runs the matching pinned Lean and Mathlib
environment, records the sequence of tactic-state transitions, and canonicalizes
the result into one row per transition. It validates internal-state structure and
continuity between adjacent transitions, assigns deterministic splits, and keeps
provenance needed to trace a row back to its source theorem and environment.
Rows are written as Parquet shards. Before publication, every shard is checked
against its source rows; uploaded bytes are read back and verified at an immutable
Hugging Face revision. Batch manifests record shard hashes, source-batch identity,
and extraction evidence. A `replay_status` value records whether an additional
replay check was performed; publication alone does not mean replay certification.
## Format
Zstandard-compressed Parquet shards, one row per transition, schema version 2.
The physical encoding is `leangpt-parquet-v2`: all 40 columns are retained.
`schema_version` and `step_index` are int64; `terminal` is boolean;
`imports`, `atomic_tactics`, `used_premises`, and `available_context` are lists of
strings. Other columns are nullable strings.
The following recursive/object columns contain lossless JSON text (parse with
`json.loads` when non-null): `provenance`, `source_start`, `source_end`,
`state_before_structured`, `state_after_structured`, `state_before_internal`,
`state_after_internal`, and `tactic_internal`. This prevents inference from
truncating recursive Lean trees or creating incompatible schemas between shards.
Null stays null; an empty object stays the JSON string `{}`.
`example_id` is globally unique and deterministic. It is the versioned SHA-256
identity of the provenance-based proof key plus `step_index`, prefixed by
`ltc-v2:`. The earlier colliding source IDs are not retained in another column.
## Schema in plain language
Each row is a single ordered step within a proof. The fields fall into these groups:
| Fields | Meaning |
|---|---|
| `example_id`, `proof_id`, `step_index`, `split`, `schema_version` | Stable identity, position in the proof, dataset split, and format version. `example_id` is globally unique; `proof_id` alone may not be. |
| `source_dataset`, `source_url`, `repo_commit`, `file_path`, `lean_version`, `mathlib_version`, `extractor_version`, `pantograph_version`, `provenance` | Where the theorem came from and the exact environment and extraction provenance needed to reproduce or audit it. |
| `theorem_name`, `theorem_statement_raw`, `theorem_source_raw`, `namespace`, `imports` | The theorem and its surrounding Lean source context. |
| `state_before_raw`, `tactic_raw`, `state_after_raw` | The familiar human-readable goal display and tactic text for the transition. |
| `state_before_structured`, `state_after_structured` | Parsed versions of the displayed proof states. |
| `state_before_internal`, `state_after_internal` | Lean's detailed elaborator state: active goals, local declarations, targets, metavariables, universe metavariables, and recursive expressions. |
| `atomic_tactics`, `tactic_internal` | The tactic's atomic view and its full Lean `Syntax` representation, including identifier resolution, premise references, and nested tactic structure when available. |
| `used_premises`, `available_context`, `source_start`, `source_end` | Referenced declarations, candidate context, and the tactic's source span. |
| `terminal`, `terminal_marker`, `terminal_raw` | Whether this step closes the proof and the source/display marker associated with closure. |
| `theorem_fingerprint`, `state_fingerprint`, `transition_fingerprint` | Deterministic hashes useful for deduplication, grouping, and integrity checks. |
| `replay_status`, `replay_error` | Result of optional replay validation; `not_run` means no independent replay was attempted. |
The recursive structures are stored as lossless JSON strings in Parquet. Parse them
with `json.loads` when you need their tree structure; leave them as strings for
text-only training baselines.
Each shard is round-trip compared against every original JSON row before upload.
Remote bytes are streamed back and checked for SHA-256 and size at a pinned commit.
`manifests/batches/` records verified shard hashes/revisions, original batch
fingerprints, extraction evidence, and retained proof IDs plus provenance-based proof keys. A batch manifest exists
only after all of its split shards are verified. Failed attempts are described in
batch evidence and must not be mistaken for successfully extracted proofs.
Quarantine artifacts, when present under `data/quarantine/`, are excluded from the
default configuration. They are archival evidence, not clean training examples.
Splits are inherited from the frozen extractor, not recomputed by the publisher.
Replay status is recorded per row; publication does not imply replay verification.
Frozen extraction inputs under `sources/` are also excluded from the default
configuration. They allow scratch-only workers to range-read deterministic chunks
when an original upstream revision is no longer available. Their paths, immutable
revisions, sizes, and SHA-256 digests are recorded by the extraction runner.
## Read
```python
from datasets import load_dataset
import json
data = load_dataset(
"HyperCactus0/LeanTransitionCorpus",
revision="<immutable commit SHA>",
split="train",
streaming=True,
)
row = next(iter(data))
state = json.loads(row["state_before_internal"]) if row["state_before_internal"] else None
```
Use an immutable revision for experiments. The repository grows over time.
## Local seed snapshot
The imported seed contains 285 completed Numina batches: 1,425 attempted proofs,
1,378 extracted proofs, and 1,374 source-distinct proofs retained as 13,105
transition rows. Four extracted proofs failed internal-state validation during
canonicalization; the batch evidence records these exclusions.
| Split | Transition rows | Source-distinct proofs |
|---|---:|---:|
| train | 11,182 | 1,159 |
| dev | 654 | 65 |
| internal_test | 1,269 | 150 |
No quarantine transition rows are present in this seed. All transition rows have
`replay_status=not_run`. The local audit found no duplicate provenance-based
transition keys or theorem-fingerprint conflicts across splits. These checks do
not constitute independent Lean replay validation.
## Identity
`example_id` is globally unique and deterministic. `proof_id` retains the source
identifier and may be reused by distinct Numina selections. Identify a proof by
`(source_dataset, repo_commit, file_path, provenance.source_sha256,
provenance.theorem_ordinal, theorem_name)`. Batch manifests expose these tuples as
JSON-encoded `proof_keys`, and the versioned `example_id` hashes that proof key plus
`step_index`.
|