Can Large Language Models Solve Path Constraints in Symbolic Execution?

Wenhan Wang, Kaibo Liu, Zeyu Sun, An Ran Chen, Ge Li, Gang Huang, Lei MaarXiv 2025 · DOI

Abstract

Symbolic execution (SE) is a cornerstone of software testing, yet traditional SMT-based solvers struggle with complex data structures, external APIs, and the "translation" gap in dynamic languages like Python. This paper investigates whether Large Language Models (LLMs), particularly Large Reasoning Models (LRMs) with Chain-of-Thought capabilities, can serve as effective path constraint solvers. Through a large-scale empirical study across three benchmarks, we demonstrate that state-of-the-art models can solve up to 65.6% of complex paths and successfully navigate "black box" scenarios where traditional tools fail. However, challenges remain regarding inference cost, long-path bookkeeping, and occasional over-analysis in classification tasks.

Introduction

Symbolic Execution (SE) is a powerful technique for finding bugs and generating test cases by treating program inputs as symbols rather than concrete values. It collects mathematical requirements (constraints) needed to reach specific code branches and hands them to an SMT solver (like Z3) to find valid inputs. However, traditional SE faces a significant "translation" problem: converting modern, dynamic code into the rigid logic required by SMT solvers is difficult. Solvers often struggle with complex data structures (e.g., heaps, nested dictionaries), external API calls that appear as "black boxes," and the exponential growth of possible paths (path explosion).

This study explores a novel alternative: bypassing the mathematical translation layer by asking LLMs to directly "solve" the execution paths.

Methodology

To evaluate the potential of LLMs in this domain, researchers developed a systematic pipeline to compare non-reasoning LLMs (e.g., GPT-4.1-mini, DeepSeek-V3) against Large Reasoning Models (LRMs) (e.g., DeepSeek-R1, o4-mini) that utilize Chain-of-Thought (CoT) processing.

Overview of the proposed framework for evaluating LLMs on path constraint solving.

As illustrated in Figure 1, the framework consists of three primary phases:

  1. Benchmark Construction: Source code is processed to extract execution paths. This involves instrumenting code to record feasible paths during test execution and using graph traversal algorithms on Control Flow Graphs (CFGs) to identify both feasible and infeasible paths.
  2. LLM-Based Path Constraint Solving: The extracted code and desired paths are fed into LLMs. The models are tasked with either generating test cases (finding inputs) or classifying paths (determining feasibility and detecting bugs).
  3. Empirical Evaluation: The outputs are verified by executing generated test cases to check for path correctness and code coverage. Classification performance is measured using precision, recall, and F1 scores.

Experimental Setup and Datasets

The study utilized three distinct benchmarks to test various aspects of code complexity:

  • Competition-level (Generation): A modified TestEval dataset featuring 210 LeetCode-style Python programs with high cyclomatic complexity (averaging 13.35 branches).
  • Path Classification: Derived from the Google runtime error dataset (CodeNet), containing 2,010 execution paths labeled as Valid, Invalid, or ZeroDivision (bug-triggering).
  • Real-world Repositories: The TestGenEval dataset, consisting of 11 public Python repositories, used to evaluate test coverage improvements in complex, multi-file projects.

Key Insights and Results

The LRM Advantage and the "Overthinking" Trap

Reasoning models (LRMs) significantly outperformed standard LLMs in test case generation. Their ability to simulate program execution step-by-step in their Chain-of-Thought allows them to solve constraints requiring multiple logical leaps. For instance, the o4-mini model achieved a 65.6% path accuracy on the competition-level benchmark.

However, LRMs were occasionally less effective at path classification. The researchers observed an "overthinking" trap where models correctly identified a bug in their CoT but then over-analyzed branch conditions until they incorrectly labeled the path as "Invalid."

Handling the "Unsolvable"

LLMs demonstrated a unique advantage over traditional SMT solvers: the ability to handle external APIs. Because LLMs have been trained on documentation for common libraries (like collections or math), they can infer the constraints of an API call that an SMT solver would treat as an opaque black box.

Performance and Scalability

  • Bug Detection: In path classification, Qwen3-235B achieved 82.9% accuracy and was the only model to identify all 120 "division by zero" bugs in the dataset.
  • Coverage: In real-world scenarios, providing path information improved line coverage. GPT-4.1-mini reached 97.1% coverage on the test cases it successfully generated.
  • The 50-Branch Wall: Performance drops sharply once a path exceeds 30–50 branch conditions, as even the best models struggle with the bookkeeping required for extremely long execution traces.

Limitations and Future Outlook

While promising, LLM-based constraint solving faces several hurdles. High-end reasoning models are computationally expensive and slower than traditional tools (taking up to 5 minutes vs. 13 seconds). Additionally, models still suffer from "Understanding Errors" or hallucinations regarding complex library behaviors.

Future research may focus on Reinforcement Learning from Verifiable Rewards (RLVR)—using actual execution results as a reward signal to train smaller, specialized models. Furthermore, integrating LLMs earlier in the process could help prune the "path explosion" by identifying infeasible paths before they are fully explored.

Summary updated

BibTeX
@misc{wang2025can,
  author = {Wenhan Wang and Kaibo Liu and Zeyu Sun and An Ran Chen and Ge Li and Gang Huang and Lei Ma},
  title = {{Can Large Language Models Solve Path Constraints in Symbolic Execution?}},
  year = {2025},
  eprint = {2511.18288},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.18288},
}
Figure