SoS1: O1 and R1-Like Reasoning LLMs are Sum-of-Square Solvers

Kechen Li, Wenqi Zhu, Coralia Cartis, Tianbo Ji, Shiwei Liu

TL;DR

This paper explores whether large language models (LLMs) can solve research-level, NP-hard mathematical problems—specifically, determining if a multivariate polynomial can be expressed as a Sum of Squares (SoS). By introducing a new benchmark dataset (SoS-1K) and expert-designed reasoning prompts, the authors boost LLM accuracy from near-random guessing up to 81%. Remarkably, a lightweight 7B model fine-tuned on this data for just 4 hours outperforms massive 671B models like DeepSeek-V3 while requiring less than 2% of the computation time.

What Problem Does This Paper Address?

The authors tackle a fundamental and computationally intractable problem in mathematics: determining whether a given multivariate polynomial is nonnegative (meaning it never evaluates to a negative value for any real inputs). This problem is deeply connected to Hilbert’s Seventeenth Problem and is a cornerstone of global polynomial optimization, with vital applications in control theory, quantum computing, and fluid dynamics.

Because proving general nonnegativity is provably NP-hard, mathematicians typically look for a sufficient alternative condition: the Sum of Squares (SoS). If a polynomial can be rewritten as a sum of squared polynomials, it is guaranteed to be nonnegative. Traditional numerical software packages solve this by converting it into a Semidefinite Programming (SDP) problem. However, as the number of variables and the polynomial degree grow, the size of these SDP matrices explodes, rendering classical solvers useless for large-scale problems. This paper investigates whether reasoning-focused LLMs can offer a new way forward.

Methods

The authors designed three distinct prompting strategies to evaluate and guide LLMs through the SoS verification process:

  1. SoS Plain: A basic binary classification prompt ("Please analyze if this polynomial can be expressed as a Sum of Squares").
  2. SoS Simple: A prompt that classifies polynomials into five distinct groups using concise, one-line rules.
  3. SoS Reasoning: A highly structured, expert-annotated five-step mathematical verification framework. It guides the model to systematically check the polynomial's degree, verify nonnegativity via specific mathematical properties, analyze well-known special cases, look for direct square forms, and perform matrix decomposition ($Q$-matrix verification).
Figure 1: Demonstration of SoS Plain (left), SoS Simple (mid), and SoS Reasoning (right).

Beyond prompting, the authors performed Supervised Fine-Tuning (SFT) on a pre-trained Qwen2.5-7B-Instruct-1M model using their new dataset. The training took just 4 hours on two NVIDIA A100 GPUs, resulting in a specialized, highly efficient model named SoS-7B.

Datasets

The paper introduces SoS-1K, a meticulously curated dataset of approximately 1,000 polynomials. The dataset features:

  • An even split between SoS and non-SoS polynomials.
  • Variables and polynomial degrees ranging from 2 to 10.
  • Five distinct difficulty subsets mapped directly to the five steps of the SoS Reasoning framework.
  • Expert-annotated reasoning traces, theoretical proofs for certain classes, and labels verified by standard numerical solvers.

Key Insights and Ideas

  • Plain Prompts Fall Flat: When given a plain question without structured guidance, state-of-the-art LLMs fail, hovering around 50% to 60% accuracy—barely better than a random coin flip on a binary task.
  • Scaffolding Unlocks Latent Knowledge: Introducing the expert-designed SoS Reasoning prompt yields a massive performance leap (up to a 21% accuracy boost). This indicates that while LLMs possess the underlying mathematical knowledge, they require explicit logical scaffolding to retrieve and apply it correctly.
  • The "Laziness" Phenomenon: The authors noticed that under the complex SoS Reasoning prompt, some models become "lazy" at Step 5 (Matrix Decomposition). Instead of grinding through the heavy matrix algebra, they try to guess the final answer based on clues from earlier, simpler steps.
  • Capacity vs. Reasoning Length: Higher-capacity models (like DeepSeek-R1 and OpenAI o1-mini) actually require fewer thinking tokens to reach correct conclusions, whereas smaller models require longer, more explicit reasoning paths to hit peak accuracy.
Figure 3: Number of correct samples with various re-

Key Results

  • Top Prompted Performance: DeepSeek-R1 combined with the SoS Reasoning prompt achieved the highest accuracy on valid samples at 81%.
  • Small Model, Big Impact: The fine-tuned SoS-7B model achieved a total accuracy of 70%, outperforming the massive 671B DeepSeek-V3 (69%) and the 32B QwQ-32B-Preview (52%).
  • Dramatic Speedups: SoS-7B achieved its high accuracy with a blistering response time of just 1.8 seconds—utilizing only 1.8% of the computation time required by DeepSeek-V3 (100 seconds) and 5% of OpenAI o1-mini (34.9 seconds).
Table 2: Accuracy Comparison on SoS Reasoning

Limitations and Future Work

  • Context Window Limits: To prevent LLM degradation over long sequences, the authors capped polynomial lengths to 4,000 tokens. Consequently, most of the test cases still fall within the boundaries of what traditional numerical solvers can handle.
  • Low-Rank Matrix Vulnerability: While LLMs excel at smaller polynomials, they consistently struggle when the underlying quadratic form of the polynomial requires a low-rank matrix decomposition.
  • Future Outlook: The team plans to expand the dataset to include much larger, more complex polynomials that completely break traditional numerical solvers, testing whether LLMs can truly push the boundaries of unsolved NP-hard mathematical problems.

Summary updated

Abstract

Large Language Models (LLMs) have achieved human-level proficiency across diverse tasks, but their ability to perform rigorous mathematical problem solving remains an open challenge. In this work, we investigate a fundamental yet computationally intractable problem: determining whether a given multivariate polynomial is nonnegative. This problem, closely related to Hilbert's Seventeenth Problem, plays a crucial role in global polynomial optimization and has applications in various fields. First, we introduce SoS-1K, a meticulously curated dataset of approximately 1,000 polynomials, along with expert-designed reasoning instructions based on five progressively challenging criteria. Evaluating multiple state-of-the-art LLMs, we find that without structured guidance, all models perform only slightly above the random guess baseline 50%. However, high-quality reasoning instructions significantly improve accuracy, boosting performance up to 81%. Furthermore, our 7B model, SoS-7B, fine-tuned on SoS-1K for just 4 hours, outperforms the 671B DeepSeek-V3 and GPT-4o-mini in accuracy while only requiring 1.8% and 5% of the computation time needed for letters, respectively. Our findings highlight the potential of LLMs to push the boundaries of mathematical reasoning and tackle NP-hard problems.
BibTeX
@inproceedings{li2025sos,
  author = {Kechen Li and Wenqi Zhu and Coralia Cartis and Tianbo Ji and Shiwei Liu},
  title = {{SoS1: O1 and R1-Like Reasoning LLMs are Sum-of-Square Solvers}},
  booktitle = {AI4MATH @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=riv0OYWsB7},
}
Figure