Hierarchical Attention Generates Better Proofs
Jianlong Chen, Chao Li, Yang Yuan, Andrew C Yao
TL;DR
This work tackles the difficulty of neural theorem provers capturing the inherent hierarchy in formal proofs. It introduces Hierarchical Attention, a regularization that enforces a five-level structure from $T_0$ (context) to $T_4$ (goal) and governs attention flow with a flow loss that respects level relations. Across miniF2F and ProofNet, the method yields higher proof-pass rates and shorter proofs, with notable reductions in proof length and improved attention patterns confirmed by ablations and visualization. The approach demonstrates that incorporating explicit hierarchical structure into LLM-based proof generation can bridge neural reasoning with formal mathematical rigor, offering practical gains and reusable code for reproducibility.
Abstract
Large language models (LLMs) have shown promise in formal theorem proving, but their token-level processing often fails to capture the inherent hierarchical nature of mathematical proofs. We introduce \textbf{Hierarchical Attention}, a regularization method that aligns LLMs' attention mechanisms with mathematical reasoning structures. Our approach establishes a five-level hierarchy from foundational elements to high-level concepts, ensuring structured information flow in proof generation. Experiments demonstrate that our method improves proof success rates by 2.05\% on miniF2F and 1.69\% on ProofNet while reducing proof complexity by 23.81\% and 16.50\% respectively. The code is available at https://github.com/Car-pe/HAGBP.
