Proving Theorems Recursively

Recent advances in automated theorem proving leverages language models to explore expanded search spaces by step-by-step proof generation. However, such approaches are usually based on short-sighted heuristics (e.g., log probability or value function scores) that potentially lead to suboptimal or even distracting subgoals, preventing us from finding longer proofs. To address this challenge, we propose POETRY (PrOvE Theorems RecursivelY), which proves theorems in a recursive, level-by-level manner in the Isabelle theorem prover. Unlike previous step-by-step methods, POETRY searches for a verifiable sketch of the proof at each level and focuses on solving the current level's theorem or conjecture. Detailed proofs of intermediate conjectures within the sketch are temporarily replaced by a placeholder tactic called sorry, deferring their proofs to subsequent levels. This approach allows the theorem to be tackled incrementally by outlining the overall theorem at the first level and then solving the intermediate conjectures at deeper levels. Experiments are conducted on the miniF2F and PISA datasets and significant performance gains are observed in our POETRY approach over state-of-the-art methods. POETRY on miniF2F achieves an average proving success rate improvement of 5.1%. Moreover, we observe a substantial increase in the maximum proof length found by POETRY, from 10 to 26.

Paper

References (40)

Scroll for more · 28 remaining

Similar papers

Peer review

Reviewer p8XS7/10 · confidence 4/52024-06-13

Summary

This paper designs a novel hierarchical search algorithm (POETRY) for generating formal proofs with large language models step-by-step. In particular, POETRY will first search for proof steps with proof level 0 (these steps typically correspond to subgoals in the proof), and check the correctness of the level 0 proofs by assuming that all the subgoals can be proved. If and only if the level 0 proofs are correct, POETRY will recursively search for proofs to each of the proposed subgoals. Compared with the baseline best-first search methods with the same compute, POETRY significantly improves the pass@1 succ rate on both miniF2F valid and test set, as well as the PISA test set.

Strengths

- The POETRY algorithm is neat and novel by mimicking how human write mathematical proofs hierarchically. - This paper is well written and easy to follow. - The POETRY algorithm has potentials to be further improved by incorporating premise-selection techniques such as sledgehammer or Magnushammer.

Weaknesses

- From Table 1, it seems to me that the improvement from the search algorithm is less significant than the beam search. A drawback of the beam search method is that the algorithm becomes deterministic, meaning that generating more samples per theorem does not improve its performance. Since this paper only shows pass@1 results, it is unclear how the POETRY algorithm scales with more computing resources.

Questions

- In the example shown in Figure 4, it seems to me that Path 1 is quite similar to the first part of the proof found by POETRY. Can the authors elaborate on why is the GPT-f baseline tries to utilize a more complex way to prove the first property?

Rating

7

Confidence

4

Soundness

4

Presentation

4

Contribution

4

Limitations

The authors adequately addressed the limitations and potential negative societal impact.

Reviewer 9pow5/10 · confidence 4/52024-07-12

Summary

This paper proposes POETRY, a method for formal theorem proving using language models by training the model to iteratively decompose the problem into sketches, recursively. The authors focus on Isabelle. At each step, POETRY takes a proof state and goal and predicts either a formal sketch (a proof using sorry at each step), or a ground proof step (e.g. 'by ...') that requires no recursion. These intermediate states are visited within best-first search, where the score of a node is given by the log-probability of all predictions made so far to get to that node. Intuitively, POETRY works by recursively generating lower level steps / sketches, until finding a complete proof, getting feedback from the formal environment at each step. To train the LM, the authors introduce a simple method to decompose existing Isabelle proofs from the AFP as if they had been generated by this recursive proof generation process. Experiments on minif2f show improvements on top of GPT-f and a version of Thor without Sledgehammer.

Strengths

The paper is well motivated and tackles a timely topic, using a standard, hard benchmark (minif2f) for methods in this space. The writing is mostly clear (though see some notes below). POETRY is a simple, sound and novel method to structure the proof generation process. It should be adaptable to other interactive theorem provers with some work. POETRY allows the prover model to get more intermediate feedback from the environment compared to methods that try to produce the whole proof at once. It also uses this feedback in a way that is complementary to proof repair methods (generally what the standard when we consider using intermediate feedback).

Weaknesses

The choice of baselines (for Table 1) seems a bit convoluted. In particular, I don't really understand why use Thor without sledgehammer. The main point of Thor is to learn when to use hammers in proofs. Removing this makes the model much more similar to the GPT-f baseline. As for the choice of pass@1, even though POETRY only makes a single prediction at the end, it gets feedback from Isabelle at each node in its tree. So that doesn't seem like a fair comparison either, if POETRY makes many intermediate predictions and calls Isabelle during its search, whereas GPT-f and Thor w/o sledgehammer seem to only produce and test a single prediction. It might be more fair to match the methods based on some other metric, like number of tokens generated, or number of calls to Isabelle (whichever seems to be the most significant bottleneck). The question of "Can POETRY find longer proof?" is a bit ill posed as is. It would be possible for a method to find very long proofs that do not *need* to be long, and do better on this analysis without really being able to prove more complex theorems. What I think the authors are trying to show here is that POETRY can solve harder problems, estimating hardness by looking at proof length. For this, you might want to compare success rate based on the length of the ground truth proof: perhaps the baselines perform very poorly on theorems where the human proof is longer, whereas POETRY might have a better success rate. Another option is to show that either POETRY generates proofs of similar length to the ground truth proof (so, when POETRY generates long proofs, you'd estimate that the ground truth proof would also be long), or that it generates proofs of similar length to the baselines in cases where they all manage to prove a theorem. Any of these would help show that this result is not trivial.

Questions

* Is an intermediate sketch valid (accepted by Isabelle) as long as it's syntactically correct and the last step shows the thesis? Or do you manage to get richer feedback besides that the last step declares to show the thesis? * For problems that both POETRY and the GPT-f baseline solve, does POETRY tend to generate longer proofs? * As for the relationship with LEGO-Prover, you mention that in some cases it is impossible to decompose a proof into lemmas, but still possible to decompose it into sketches recursively. Do you have an example? * What exactly is the search algorithm used in the Thor w/o sledgehammer and GPT-f baselines? It is a one-shot prediction? Or do you use the (also best-first) search method described in the original GPT-f paper? * What is Thor without sledgehammer? It sounds like a different thing other than Thor. * I'm confused by what Figure 5 is trying to show. Fundamentally, reorganizing a proof into sketches shouldn't change its inherent complexity (e.g., the atomic proof steps). Is this just comparing the full proof length against the number of steps in the top-level sketch (without considering the deeper sketches recursively)? If you were to consider the steps in the deeper sketches recursively, I'm assuming you would not expect to see a reduction (if you do, where would that come from? do you have an example?)

Rating

5

Confidence

4

Soundness

3

Presentation

3

Contribution

3

Limitations

Yes, adequately addressed.

Reviewer BhWC5/10 · confidence 4/52024-07-12

Summary

The authors introduce a method called POETRY (proving theorems recursively) for constructing formal proofs in Isabelle/HOL. POETRY performs best-first search on proof sketches guided by a language model fine-tuned on proof sketches. POETRY outperforms other algorithms guided by language models that prove theorems step-by-step. POETRY also outperforms other methods that integrate automated theorem provers and language models.

Strengths

While the idea of a proof sketch is not novel, the combination of the data curation process to enable the construction of proof sketches is. This takes a step towards generating conjectures which would be crucial to making progress on neural theorem proving.

Weaknesses

1. It seems to me that the real reason for the success of POETRY is not the algorithm per say, but the data curation to construct proof sketches. In this vein, it would be instructive to have a before sorry and after having sorry to illustrate how the dataset is constructed. 2. There should be more context explaining how to compare the Lean results against Isabelle/HOL. These are two different formal systems, with different proof methodologies. 3. More details on success cases and failure cases would help understanding the pros and cons of the approach taken in POETRY. For instance, are there certain kinds of problems that POETRY performs well on, e.g., geometry problems? How does POETRY perform when existentials need to be instantiated? Is it the case that POETRY can prove the same theorems as previous step-by-step approaches and can additionally prove more theorems that are longer, or do the approaches prove different short theorems?

Questions

1. The distinction between a proof sketch and the decomposition of a theorem into a tree of conjectures needs to be addressed. Is there any difference? 2. In your training procedure, do you fine-tune on any theorems in the miniF2F dataset?

Rating

5

Confidence

4

Soundness

2

Presentation

3

Contribution

3

Limitations

Yes.

Reviewer BhWC2024-08-10

Thank you for your response

Thank you for your response and clarifying the strengths. Perhaps I mis-worded the section on the strengths poorly, but I understood that the proof sketches both insert a sorry and are applied recursively. I'm merely pointing out that recursive decomposition and lazy evaluation is in general not novel. On the contrary, I think it is clever to take a formal proof dataset and algorithmically insert sorry/admitted at strategic points and show that this additional signal can be leveraged is novel. w1. Dataset construction. Thank you for the reference to Figure 1. To clarify my original question concerning having a before and after sorry, which is partially shown in Figure 1, is precisely what information is contained in the arrow from the upper level to a recursive level. In particular, does it contain the minimal proof context for the entire theorem required to make the subgoal well-typed or just the local subgoal plus a reference to a location in the existing proof? It was not clear to me which it was from the Figure or the paper description. > Therefore, the model trained with POETRY data does not receive more information compared to the GPT-f Baseline. I disagree with this statement. Your approach augments the dataset with sorry which precisely indicates when multi-level proofs are required as per your dataset curation process. Put another way, sorry indicates that a hammer will likely fail. This is additional information that other methods do not see and could benefit from! To test this, you could change the dataset curation process to insert a sorry every n proof levels instead of 1, or at random proof levels, to tease apart the effect of dataset augmentation on your approach. w2. Context explaining the comparison with Lean result against Isabelle. Thank you for this additional clarification. w3. Details on Pros and Cons of POETRY Thank you for the additional work in the RM. With regards to the types of problems that Poetry excels at, I buy that it does indeed prove longer theorems. However, I was wondering how it performs on kinds of problems such as algebraic vs. geometric, since algebraic are more compute heavy (longer proofs) and geometric problems require more constructions (i.e., existentials). Thank you for the discussion on existentials as this is a limitation of this work. I appreciate the work overall and find the approach with dataset augmentation with sorry is valuable. I am inclined to maintain my score since I still have slight concerns about weakness 1.

Authorsrebuttal2024-08-11

Response to Reviewer BhWC

Dear Reviewer BhWC, We appreciate your prompt reply and recognition of our work. ## w1. Dataset Construction Regarding your question, the language model perceives only the local subgoal when entering the next level, without knowing the location of the `sorry`. The rBFS handles all movements, whether going deeper or jumping backward. As the model progresses to the next level (as indicated by the arrow in Figure 1), the rBFS identifies the sorry and extracts the proof state immediately preceding it (i.e., the state of the conjecture). This proof state is then used to prompt the model for the next steps. Therefore, there is no difference between the input in the middle of the sketch and the input that starts a low-level sketch. While adding minimal proof context from the upper level could improve POETRY’s performance (and we believe it would), we did not include this to ensure a fair comparison with the GPT-f baseline. This allows us to clearly assess the impact of recursive proving. > This is additional information that other methods do not see and could benefit from! We agree that the model receives more information compared to the GPT-f baseline in this aspect, and we acknowledge the value of the suggested ablation experiment. However, due to the limited time remaining during the rebuttal period, we may not be able to complete this experiment. We will include these ablation results in our final paper. ## w3. Types of problems that POETRY excels To provide more clarity on the types of problems where POETRY excels, we’ve included the table below, comparing the performance of POETRY and the GPT-f baseline across different mathematical categories in the PISA dataset. The results are categorized based on the directories of lemmas in the AFP library. From the table, we can see that POETRY outperforms the GPT-f baseline in most categories, including geometry and algebra. | Category | GPT-f Baseline | POETRY | | -------- | -------- | -------- | | **Graph Theory** | 38.7% | **41.9%** | | **Cryptography** | 65.2% | **69.5%** | | **Logic** | 48.1% | **53.2%** | | **Linear Algebra** | 39.3% | 39.3% | | **Set Theory** | 54.5% | **59.1%** | | **Computation Theory** | 51.7% | 51.7% | | **Probability and Statistics**| 52.2% | **65.2%** | | **Differential Equations** | 52.3% | 52.3% | | **Combinatorics** | 55.0% | **62.5%** | | **Geometry** | 46.7% | **50.0%** | | **Abstract Algebra** | 41.5% | **50.9%** | | **Algebraic Geometry** | 53.1% | **61.2%** | | **Algorithms and Data Structures** | 59.1% | **63.6%** | | **Functional Analysis** | **46.7%** | 40.0% | | **Number Theory** | 35.0% | **45.0%** | | **Miscellaneous** | **50.5%** | 50.0% | Have our responses above adequately addressed your concerns? Is there any additional information we can provide to persuade you to improve your rating?

Reviewer eTZY7/10 · confidence 3/52024-07-18

Summary

This paper introduces POETRY, a new method to prove theorems recursively. The key ideas are to use a modified best first search algorithm for the search part, and a *sorry* tactic for assumptions at the current level (to be proven later). The authors provide the intuition that this recursive structure allows POETRY to prove theorems in a top-down fashion similar to humans, getting into the details of proving a conjecture only if it is actually relevant to the best overall proof being explored. The authors conduct experiments with two standard benchmarks, showing notable improvements over baselines and SOTA search-based methods (but not LEGO-Prover etc. which rely on substantially larger general purpose LLMs).

Strengths

The paper is very well structured and clearly written. Intuitions, method details, connection to existing methods, limitations, and take away messages from experiments are all very well articulated. The idea seems simple but is apparently novel (see 'weaknesses' below, related to this). The gains over several baselines are notable, of 5% or more (absolute). I am assuming the authors will publicly release the code of their POETRY system for further research on this topic.

Weaknesses

Not being very familiar with the area, I am surprised none of the existing SOTA methods use a similar recursive, top-down search of in theorem proving. I will have to defer to other, more knowledgeable reviewers for assessing novelty of the present work. I did not fully follow why a *novel* recursive best-first search strategy is needed here. The description of this section (3.2) can probably use some clarification. E.g., why could one not account for the conjecture's level in the utility of the conjecture, and thus implicity enforce level-by-level proof search? On the same note, could the authors comment on the relationship between their proposed recursive best-first search and a combination of standard breadth-first search (i.e., staying within a level) and best-first search (i.e., preferring to explore the most promising node first)? Just for completeness, it would have been good to know how well very large LLM based methods, such as LEGO-Prover, do on the considered benchmarks.

Questions

Please see weaknesses section above.

Rating

7

Confidence

3

Soundness

4

Presentation

4

Contribution

3

Limitations

Yes

Reviewer 9pow2024-08-10

I thank the authors for the clarifications on the method, as well as the new analyses. I do think these clarify the results, and have alleviated most of my concerns. I have raised my score assuming the new results will make it to the paper: I think the method contributes a simple but neat idea for the problem. About q1. (condition of a sketch being valid), I think your answer confirms my understanding, but I'd still like to clarify just because I'm interested (and this would also be helpful to clarify in the paper). Since sorry can prove any goal, my question was whether the semantic validation that Isabelle is capable of doing is essentially just that the sketch ends by concluding the thesis. For instance, this would be a toy example based on the LEGO-Prover example above: theorem aime_1983_p9: fixes x::real assumes "0<x" "x<pi" shows "12 \<le> ((9 * (x^2 * (sin x)^2)) + 4) / (x * sin x)" proof - have c0: "x = 0" by sorry then show ?thesis by sorry qed I'm understanding this would be marked by Isabelle as a valid sketch, or is there something else I'm missing? What I wanted to understand is exactly how much semantic feedback you can get at the sketch level, since sorry can prove anything. Your results show that structuring the proof search process in this way is helpful overall, but I'm just trying to understand whether it's more of a helpful bias to the LLM vs how much extra feedback it actually enables you to extract from the environment.

Authorsrebuttal2024-08-11

More explanation on `show ?thesis`

Dear reviewer 9pow Thank you for your prompt reply and for recognizing the value of our work. We will include all the new results in our paper. Regarding the example you mentioned, POETRY does validate the sketch, and the usefulness of the skipped conjectures was not tested. We are unable to extract additional semantic information from the environment to assist in this situation. We acknowledge this problem during the development of POETRY, and to address it, POETRY employs the “last unsolved sorry” strategy during proof search (as detailed in Appendix A.1). This strategy focuses on the final sorry in the proof sketch (i.e., the sorry in `show ?thesis sorry`), allowing for quicker validation of the proposed conjectures by first concentrating on the final incomplete part of the proof. Another potential approach could involve explicitly disallowing the use of sorry after `show ?thesis` and requiring the model to find a complete proof within the `show ?thesis` block. However, this is acceptable for proofs that can be accomplished with a single level of `show ?thesis` (i.e., `show ?thesis by ...`). For proofs requiring more complex structural reasoning within the `show ?thesis` part, this method would reduce POETRY to a step-by-step approach and fail to leverage the structural reasoning capabilities that POETRY is designed to utilize. Given the current constraints in extracting semantic information from the environment, beyond the “last sorry” strategy, a promising direction might involve using neural-based value functions as assistants to help distinguish between useful and less useful sketches. We are excited to explore this aspect in our future work. Have our responses above adequately addressed your concerns? Is there any additional information we can provide to persuade you to improve your rating?

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC