RegexPSPACE: A Benchmark for Evaluating LLM Reasoning on PSPACE-complete Regex Problems

Hyundong Jin, Joonghyuk Hahn, Yo-Sub Han · DOI

RegexPSPACE is a new benchmark designed to push Large Language Models (LLMs) beyond standard reasoning tasks by challenging them with PSPACE-complete regular expression problems. The study reveals a significant gap between the theoretical Turing-completeness of LLMs and their practical ability to navigate the massive search spaces required for regex minimization and equivalence.

The Complexity Challenge

While LLMs have shown impressive results on mathematical and logical reasoning, their fundamental computational limits—especially regarding spatial complexity—remain poorly understood. Most existing benchmarks focus on problems within the NP complexity class. However, the true bottleneck for LLMs often lies in their finite context windows, which act as limited memory.

To probe these boundaries, the authors turn to PSPACE-complete problems. These are theoretically harder than NP-hard problems (unless P=NP=PSPACE) and require exhaustive search space exploration. Specifically, they focus on two regex tasks: equivalence decision (RegexEQ) and minimization (RegexMin). These tasks offer clear, quantitative metrics for success and are practically relevant in software engineering.

Complexity classes hierarchy showing the PSPACE-complete nature of the targeted regex problems.

Methodology and Dataset Construction

The authors developed a rigorous pipeline to construct a high-quality benchmark from scratch:

  1. Double-Exponential Exploration: A bottom-up approach was used to enumerate millions of regex instances. Because the number of possible regexes grows double-exponentially with expression depth, this process is computationally massive.
  2. Equivalence Partitioning: To find ground truths for minimization, the team partitioned over 243 million regexes into roughly 191 million equivalence classes. This allowed them to identify the absolute shortest regex for any given expression.
  3. Filtering & Curation: Strict filtering criteria were applied to create the final RegexPSPACE benchmark, consisting of 1,685 non-trivial problems.
  4. Evaluation: They tested 6 standard LLMs (like Llama-3.1 and Qwen2.5) and 5 Large Reasoning Models (LRMs, like DeepSeek-R1 and gpt-oss) using zero-shot and five-shot prompting.

Key Results

The evaluation results show that PSPACE-complete regex problems are exceptionally difficult for current models. Most models struggle to produce truly minimal regexes; while the best achievable length ratio is 0.7270, most models only achieve a ~10% reduction.

Performance of various LLMs and reasoning models on RegexMin and RegexEq tasks.
  • Minimization is the Hardest: Models perform better at deciding if two regexes are the same (RegexEQ) than at finding a shorter one (RegexMin). However, they show a systematic bias toward judging regexes as non-equivalent.
  • Model Size Matters: Models with 14B+ parameters significantly outperform 7-8B models, suggesting that larger capacity is essential for handling the complex state-tracking required by PSPACE tasks.

Analysis of Failure Modes

  • The "Spatial" Bottleneck: PSPACE problems serve as a "spatial" stress test. Because LLMs cannot "overwrite" previous tokens, solving these problems requires them to manage their context window extremely efficiently.
  • Failure Patterns: Models don't just get the answer wrong; they fail in specific ways. Common patterns include verbosity (generating too much text) and repetition (getting stuck in loops), which quickly exhaust the token budget.
  • Reasoning vs. Non-Reasoning Models: While LRMs generally perform better on minimization, they are often more prone to excessive verbosity during their "thinking" phase, sometimes hitting token limits before reaching an answer.
  • Generalization Gap: Models fine-tuned on shorter regexes fail almost completely when faced with longer regexes, highlighting that they are learning heuristics rather than robust algorithmic reasoning.

Conclusion

The authors acknowledge that their dataset is currently restricted to small alphabet sizes and expression depths due to the astronomical computational cost of finding ground truths. Future work includes expanding the benchmark to even more complex regexes and exploring other PSPACE-complete domains like game-playing (e.g., Chess or Go) to see if these findings hold across different types of massive search spaces.

Summary updated

BibTeX
@misc{jin2025regexpspace,
  author = {Hyundong Jin and Joonghyuk Hahn and Yo-Sub Han},
  title = {{RegexPSPACE: A Benchmark for Evaluating LLM Reasoning on PSPACE-complete Regex Problems}},
  year = {2025},
  eprint = {2510.09227},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.09227},
}
Figure