jajostrains commited on
Commit
700c48c
·
verified ·
1 Parent(s): 53ccfea

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +123 -0
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: pytorch
4
+ tags:
5
+ - lean-4
6
+ - mathlib
7
+ - theorem-proving
8
+ - tactic-prediction
9
+ - gnn
10
+ - graph-neural-network
11
+ datasets:
12
+ - jajostrains/Mathlib-Normalized-Sexpr
13
+ language:
14
+ - en
15
+ ---
16
+
17
+ # Mathlib-Sexpr-GNN — GNN tactic and argument prediction for Lean 4
18
+
19
+ Graph neural networks that predict **which tactic to apply** to a Lean 4 proof
20
+ goal, and **which arguments** (local hypotheses or library lemmas) to give it.
21
+ Trained on 250,814 tactic steps from Mathlib, represented as S-expression
22
+ goal-state DAGs from [jajostrains/Mathlib-Normalized-Sexpr](https://huggingface.co/datasets/jajostrains/Mathlib-Normalized-Sexpr).
23
+
24
+ Two bundles are published here, each a self-contained directory verified by
25
+ content hashes (weights, node vocabulary, tactic vocabulary):
26
+
27
+ | Directory | Model | What it predicts |
28
+ |---|---|---|
29
+ | `tactic-baseline-gat/` | GATv2 encoder + classifier | tactic family only (e.g. `rw`, `apply`, `simp`) |
30
+ | `pointer-gat-gru/` | GATv2 encoder + GRU pointer decoder + stop head, with a premise scorer | tactic family **and** its ordered argument sequence, plus a premise scorer for library-lemma retrieval |
31
+
32
+ ## How the models work
33
+
34
+ - **Goal representation.** Each proof state (goal + local context) is parsed
35
+ into a directed acyclic graph: expression nodes, hypothesis nodes with
36
+ binder annotations, and a State root. A GATv2 encoder (4 layers, 8 heads,
37
+ hidden 128, state+mean-attention readout) produces node embeddings.
38
+ - **Tactic head.** A classifier over the state embedding predicts one of 228
39
+ tactic families.
40
+ - **Argument decoder (pointer bundle).** A GRU recurrent decoder runs up to 3
41
+ decode steps. At each step it scores every premise-selectable DAG node
42
+ (pointer attention over node embeddings), picks one, and feeds it back into
43
+ the recurrence. A **stop head** decides when the argument sequence ends —
44
+ the count is learned, not taken from a static arity table. Already-selected
45
+ nodes are masked so no argument repeats.
46
+ - **Premise scorer.** A dot-product scorer over a unified candidate pool
47
+ (local DAG nodes + FAISS-retrieved library lemmas), for tactics that cite
48
+ Mathlib lemmas (`exact`, `apply`, `rw`).
49
+
50
+ ## Metrics
51
+
52
+ Validation split (4,260 tactic steps), pointer bundle:
53
+
54
+ | Metric | Value |
55
+ |---|---|
56
+ | Tactic top-1 / top-5 | 0.320 / 0.711 |
57
+ | Argument top-1 / top-5 (position-level) | 0.433 / 0.779 |
58
+ | Exact argument-sequence match | 0.037 |
59
+ | Stop-decision accuracy | 0.789 |
60
+ | Premise scorer top-1 / top-5 / MRR | 0.481 / 0.806 / 0.618 |
61
+
62
+ Test split: tactic top-1 0.315, premise top-1 0.468, premise MRR 0.600.
63
+
64
+ Baseline bundle: validation tactic top-1 0.327 / top-5 0.701; test top-1 0.311.
65
+
66
+ Caveat on the argument metrics: they are computed over the positions a
67
+ DAG-pointer can physically select — local-context targets within the 3-step
68
+ decode budget. Library-lemma citations are the premise scorer's task and are
69
+ excluded from the pointer's accuracy; longer argument lists (the corpus
70
+ median exceeds 3 for `rw`-family chains) are truncated at the budget and
71
+ reported separately.
72
+
73
+ ## Usage
74
+
75
+ Each bundle directory holds `bundle.json` (manifest with hashes and
76
+ metadata), `model.safetensors`, `config.json`, and the scorer (pointer
77
+ bundle only). The shared `vocab/` directory at the repo root holds the
78
+ canonical node and tactic vocabularies both bundles were trained against;
79
+ the manifests hash-bind the weights to them.
80
+
81
+ Loading with the project's API:
82
+
83
+ ```python
84
+ from maths_ai.gnn_inference.atp_lean_gnn.bundle import load_pointer_bundle
85
+
86
+ loaded = load_pointer_bundle("pointer-gat-gru", device="cpu")
87
+ # loaded.model — TacticWithArgsClassifier (GATv2 + GRU pointer decoder)
88
+ # loaded.scorer — PremiseScorer (dot mode)
89
+ ```
90
+
91
+ Bundle invariants enforced on load: weight and vocabulary hashes are
92
+ re-verified against `bundle.json`; a `pointer_gru` bundle cannot be loaded
93
+ as a legacy pointer or vice versa; a vocabulary of the same size but
94
+ different content is rejected (IDs are position-assigned, so a renumbered
95
+ vocabulary would silently mislabel every prediction otherwise).
96
+
97
+ ## Training data and provenance
98
+
99
+ - 250,814 train / 4,260 val / 4,506 test tactic steps from the LeanDojo
100
+ Mathlib 4 benchmark split (row selection, splits, and row indices inherited
101
+ unchanged from the upstream benchmark).
102
+ - Goal states elaborated with a pinned Pantograph REPL against Mathlib at the
103
+ benchmark's commit; S-expressions and per-position argument traces extracted
104
+ per row.
105
+ - Trained from a baseline-initialized checkpoint (tactic head warm-started
106
+ from `tactic-baseline-gat`'s encoder), 30 epochs, bfloat16 AMP.
107
+
108
+ ## Limitations
109
+
110
+ - Argument sequences are capped at 3 steps; longer `rw` chains are truncated.
111
+ - The premise scorer's FAISS index (318,953 Mathlib declarations) is **not**
112
+ published with this model — it is not yet hash-bound to the encoder that
113
+ produced its vectors, so serving it risks confidently wrong retrieval. It
114
+ will follow once that binding is enforced at load time.
115
+ - Closed-loop proof search (running the model against Lean) is not yet
116
+ evaluated; these are per-state prediction metrics.
117
+
118
+ ## License
119
+
120
+ Apache-2.0, inherited from Mathlib. The dataset carries the LeanDojo MIT
121
+ notice for the benchmark's row selection and split structure; see the
122
+ dataset card for details.
123
+