---
title: 'ASTactic: Neural Tactic Synthesis'
url: https://www.emergentmind.com/topics/astactic-model
type: topic
---

# ASTactic: Neural Tactic Synthesis

ASTactic is a deep learning-based model for automated theorem proving in the Coq proof assistant, designed to generate tactic commands as programs represented by abstract syntax trees (ASTs). Developed in the context of the CoqGym environment, ASTactic formalizes the task of tactic synthesis as a conditional program generation problem, where model outputs are structured according to the syntax and semantics of the Ltac tactic language. The architecture leverages tree-structured neural models to encode proof states and decode tactic trees, focusing on producing in-vocabulary tactics with arguments drawn from semantically valid options. The approach combines neural program synthesis with semantic pruning, enabling more efficient and effective search in the space of interactive proofs [1905.09381].

## 1. Formalization of Tactic Generation

In interactive theorem proving with Coq, proofs are constructed by iteratively issuing tactics that manipulate a proof state, which itself consists of a global environment $\Gamma$ of named premises and a list of current goals $G_1, G_2, \dots$ with local contexts $\Delta_i$. Tactics $t \in \mathcal{T}$ from Ltac are parameterized commands executed by Coq, updating the current proof state or resulting in failure.

ASTactic’s objective is to learn a conditional distribution $P(t\mid S)$ over the large space of well-formed Coq tactics, given the current proof state $S$. In practice, the tactic space $\mathcal{T}$ is restricted to a context-free grammar of atomic Ltac tactics, with parameters (e.g., identifiers, integers) synthesized only from currently available, syntactically valid options. This constraint drastically reduces the complexity of argument search and aligns tactic generation with Coq’s semantics.

## 2. Neural Architecture: Encoder–Decoder over Trees

ASTactic adopts an encoder–decoder framework where both the input (proof state) and output (tactic program) are tree-structured.

**Encoder:** Each goal $G$ and each premise $r \in \Gamma \cup \Delta$ is parsed as a Coq term AST, composed of constructors (App, Lambda, Match, etc.). These ASTs are embedded using a bottom-up child-sum TreeLSTM [Tai et al., 2015]. For each node $v$ with constructor $n_n$ and children $v_1,\dots,v_k$, the TreeLSTM updates hidden and cell states:
\[
h_v, c_v = \text{TreeLSTM\_update}( W^c[n_n], \{ h_i, c_i \}_{i=1}^k )
\]
where $W^c[n_n]$ is a learned embedding per constructor. The root state $h_{\text{root}}$ is taken as the embedding for each term. Goal and premise embeddings are tagged to indicate their role, and, for efficiency, only up to $K$ premises are encoded per state.

**Decoder:** The model produces tactic programs as ASTs corresponding to the Ltac grammar, generating each node in depth-first sequence. The decoder maintains a GRU state $s_t \in \mathbb{R}^d$ at each step, which summarizes the current expansion context:
\[
s_t = \text{GRU}( s_{t-1}, [ a_{t-1} ; p_t ; n_t ; g ; u_t ] )
\]
where $a_{t-1}$ encodes the prior production rule, $p_t$ encodes the parent node and expansion rule, $n_t$ is the current nonterminal, $g$ the goal embedding, and $u_t$ an attention-weighted summary of premise embeddings.

At each expansion step, a production rule is selected via a softmax over learned parameters:
\[
P(r \mid s_t) = \text{softmax}( W_R \cdot \tanh(U_R s_t + b_R) )
\]
For argument synthesis:
- **Premise identifiers:** Each premise is scored by attention;
- **Small integers:** Chosen by discrete softmax;
- **Quantified variables:** Uniform selection among variables in $G$.

## 3. Probabilistic Modeling of Tactics

Let $T$ be a tactic AST with node set $N(T)$. The probability of generating $T$ in proof state $S$ factors as:
\[
P(T \mid S) = \prod_{n \in N(T)} P( \text{rule}(n) \mid s(n) )
\]
where $s(n)$ is the decoder state at node $n$. For terminal nodes, the generation further conditions on the corresponding argument classifier, with context restrictions reflecting the current proof environment. This supports both deterministic (highest-probability) and stochastic decoding.

## 4. Training Strategy and Hyperparameters

ASTactic is trained on pairs $(S, T^*)$ with $T^*$ the ground-truth tactic AST executed in state $S$ (extracted from 44,000 human-written proofs in CoqGym). Teacher forcing is employed: the target AST is traversed in depth-first order, with the network unrolled along ground-truth expansions, and losses accumulated as cross-entropy on both production rule and argument generation:
\[
L = - \sum_t \left[ \log P(r_t^* \mid s_t) + \mathbb{I}_{\text{arg}}(t) \cdot \log P(\theta_t^* \mid s_t) \right]
\]
The optimization uses RMSProp [Tieleman & Hinton, 2012] with learning rate $3 \times 10^{-5}$, weight decay $10^{-6}$, embedding/hidden sizes $d = 256$, over five epochs and batch size $1$ (online updates). Training completes in a few days on a single GTX 1080 GPU.

## 5. Integration and Automated Proof Search

ASTactic is integrated with the Coq execution environment using a beam-search–enhanced depth-first search:

1. Given initial state $S_0 = (\Gamma_0, [G_0])$, invoke a recursive DFS-Prove procedure.
2. For each proof state, built-in Coq tactics (`trivial`, `auto`, `intuition`, `easy`, `hammer`) are applied first.
3. If none succeed, ASTactic proposes a beam of candidate tactics (via beam search over $P(t|S)$); candidates are executed and resulting states recursed upon up to a maximum search depth (50) or wall time (10 minutes), pruning duplicate states.
4. Communication with Coq uses SerAPI (“Undo; …; t”) and reconstructs new states post-tactic application.

## 6. Empirical Results on CoqGym and Comparative Evaluation

Experiments on CoqGym use a split of 123 Coq projects: 43,844 proofs for training, 13,875 for validation, 13,137 for testing. Performance is measured by proof success rate—the percentage of theorems fully proved within 300 tactics and 10 minutes.

| Method                      | Success Rate    |
|-----------------------------|----------------|
| trivial                     | 2.4%           |
| auto                        | 2.9%           |
| intuition                   | 4.4%           |
| easy                        | 4.9%           |
| hammer (20s)                | 17.8%          |
| hammer (10 min)             | 24.8%          |
| ASTactic                    | 12.2%          |
| ASTactic + auto             | 12.8%          |
| ASTactic + hammer (20s)     | 23.6%          |
| ASTactic + hammer (10 min)  | 30.0%          |

Combining ASTactic with “hammer” results in a new state-of-the-art 30.0% proof success rate (vs. 24.8% for hammer alone). Beam width controls a trade-off between computational time and coverage: width 20 yields 12.2% success at approximately 3.3 seconds per proof. Generated proofs are relatively short (6.0 steps on average vs. 12.5 for humans), and the number of tactics tried per proof is much lower than prior automaton-based systems (200 vs. 10,000 for SEPIA).

## 7. Strengths, Limitations, and Prospects

**Strengths:**
- Learns to synthesize in-vocabulary tactics with contextually valid arguments, contrasting with fixed-vocabulary or retrieval techniques.
- Employs semantic constraints to drastically reduce argument search complexity.
- Complements external automated theorem provers (“hammers”), providing a clear additive gain in proof success.
- Proof search is efficient, requiring fewer calls to Coq per proof.

**Limitations:**
- The tactic grammar is a hand-pruned subset of full Ltac; complex compound tactics (e.g., $t_1; t_2$), repetition, and custom tactics are excluded.
- The encoder only attends to a maximum of 10 premises, potentially limiting effectiveness; more comprehensive premise selection remains open.
- Proofs are generated stepwise using a Markovian GRU, making long-range proof planning challenging.

**Potential Extensions:**
- Extending coverage to the full Ltac language, including compound tactics and repetition.
- Use of end-to-end reinforcement learning, treating ASTactic as a policy to improve proof-space exploration.
- Explicit modeling of premise selection, potentially with learned attention over entire libraries.
- Transfer to other proof assistants, such as Isabelle or HOL Light.

ASTactic exemplifies a synthesis of neural program generation and symbolic proof search, offering a data-driven framework for interactive theorem proving that leverages both syntax and domain semantics [1905.09381].

Source: https://www.emergentmind.com/topics/astactic-model