Modeling Tactics as Operators: Effect-Grounded Representations for Lean Theorem Proving

Elisaveta Samoylov, Soroush Vosoughi2025

Abstract: Interactive theorem provers (ITPs) such as Lean expose proof construction as a sequence of tactics applied to proof states. Existing machine learning approaches typically treat tactics either as surface tokens or as labels conditioned on the current state, eliding their operator-like semantics. This paper introduces a representation learning framework in which tactics are characterized by the changes they induce on proof states. Using a stepwise Lean proof corpus, we construct delta contexts—token-level additions/removals and typed structural edits—and train simple distributional models ($\Delta$-SGNS and CBOW-$\Delta$) to learn tactic embeddings grounded in these state transitions. Experiments on tactic retrieval and operator-style analogy tests show that $\Delta$-supervision yields more interpretable and generalizable embeddings than surface-only baselines. Our findings suggest that capturing the semantics of tactics requires modeling their state-transformational effects, rather than relying on distributional cooccurrence alone.

Introduction

In the domain of Interactive Theorem Proving (ITP), particularly within the Lean environment, a proof is constructed through a sequence of "tactics." These tactics serve as functional operators that transform an initial mathematical goal into a solved state. Despite this inherent functional nature, most current machine learning models treat tactics as simple text strings or categorical labels.

This shallow approach often fails to capture the core semantics of a tactic—what it actually does to the proof state. Consequently, models can become brittle, relying on surface-level patterns like specific variable names rather than the underlying logical transformation. If a model does not understand that a tactic's role is to "add a hypothesis" or "flip an inequality," it struggles to generalize to novel mathematical contexts.

Methodology: $\Delta$-Supervision

To address this, we propose a representation-learning framework grounded in $\Delta$-supervision. Instead of analyzing a proof state in isolation, our models learn from the transition: $(s_{before}, t, s_{after})$.

Example of Lean proof states and tactics used for delta-supervision.

We construct $\Delta$-contexts to capture these transitions through two primary lenses:

  1. Token-level deltas: Tracking the specific mathematical tokens added to or removed from the state.
  2. Typed structural edits: Utilizing regex-based rules to identify high-level logical changes, such as adding a hypothesis ($\Delta\_ADD\_HYP$) or solving a goal ($\Delta\_GOAL\_SOLVED$).

We utilize two minimalist distributional models based on the Word2Vec architecture to evaluate this approach: $\Delta$-SGNS (Skip-Gram), which predicts state changes given a tactic, and CBOW-$\Delta$, which predicts a tactic given a set of state changes. To ensure the models learn logical structures rather than memorizing variable names, we implement a rigorous preprocessing pipeline involving alpha-renaming.

Experimental Results

Our models were evaluated on the Lean Workbook corpus, a dataset of approximately 25,200 proof steps from contest-level mathematics.

Tactic Retrieval and Analogy

In tactic retrieval tasks, the CBOW-$\Delta$ (Full) model achieved a Mean Reciprocal Rank (MRR) of 0.085, representing a 25% relative improvement over models using only surface tokens. Furthermore, we conducted an "Operator Analogy Test" to verify if tactic embeddings act as translation vectors ($v(s_{before}) + e_t \approx v(s_{after})$). The "Full" model achieved a cosine similarity of 0.67, significantly outperforming the token-only baseline (0.62), confirming that these embeddings capture the transformational semantics of tactics.

Embedding Space Interpretability

Qualitative analysis via UMAP visualizations reveals a stark difference between $\Delta$-aware models and standard sequence-based baselines.

UMAP visualizations comparing delta-aware models (CBOW, SGNS) with a sequence-based baseline (SEQ).

As shown above, $\Delta$-aware models produce distinct, separable clusters of tactics based on their logical effects. In contrast, sequence-based models (SEQ), which rely solely on tactic co-occurrence, result in a diffuse "isotropic cloud" lacking clear logical organization. This demonstrates that structural logic and surface-level symbols provide complementary and essential information for theorem proving.

Conclusion

This work demonstrates that treating tactics as functional operators grounded in state changes leads to more robust and interpretable representations. While currently a proof-of-concept using minimalist architectures and heuristic $\Delta$-contexts, the results suggest significant potential for scaling these effect-grounded representations. Future work will focus on integrating these embeddings into more complex architectures like Transformers and applying them to end-to-end automated proof searches across larger libraries like Lean's mathlib.

Summary updated

BibTeX
@misc{samoylov2025modeling,
  author = {Elisaveta Samoylov and Soroush Vosoughi},
  title = {{Modeling Tactics as Operators: Effect-Grounded Representations for Lean Theorem Proving}},
  year = {2025},
  doi = {10.18653/v1/2025.mathnlp-main.12},
}
Figure