EquiBench: Benchmarking Large Language Models’ Reasoning about Program Semantics via Equivalence Checking

Anjiang Wei, Jiannan Cao, Ran Li, Hongyu Chen, Yuhui Zhang, Ziheng Wang, Yuan Liu, Thiago Teixeira, Diyi Yang, Ke Wang, Alex Aiken

Abstract

Anjiang Wei, Jiannan Cao, Ran Li, Hongyu Chen, Yuhui Zhang, Ziheng Wang, Yuan Liu, Thiago S. F. X. Teixeira, Diyi Yang, Ke Wang, Alex Aiken. Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing.

2025.

Introduction

While Large Language Models (LLMs) have demonstrated remarkable proficiency in code generation, a critical question remains: do they truly understand program semantics? Existing benchmarks like HumanEval primarily evaluate a model's ability to generate code from natural language, which can often be achieved through syntactic pattern matching or memorization. To address this, we introduce EquiBench, a rigorous benchmark designed to test semantic understanding through equivalence checking—the task of determining if two programs are functionally identical across all possible inputs.

Equivalence checking is a fundamental, undecidable problem in computer science. Solving it requires deep reasoning about execution behavior, state changes, and edge cases, making it a more robust "stress test" for AI reasoning than simple generation tasks.

The EquiBench Pipeline

EquiBench consists of 2,400 program pairs across four languages: Python, C, CUDA, and x86-64 assembly. To ensure the benchmark captures non-trivial semantic relationships, we developed an automated pipeline that applies four distinct transformation strategies:

  1. Dead Code Elimination (DCE): Removing code that does not affect the final output based on compiler analysis.
  2. Compiler Scheduling (CUDA): Applying different optimization strategies (e.g., loop tiling) to identical mathematical operations using tensor compilers like TVM.
  3. Superoptimization (x86-64): Using tools like Stoke to find efficient assembly sequences that match a target function's behavior.
  4. Algorithmic & Syntactic Changes (Python): Comparing different algorithms for the same problem and performing variable renaming.
Overview of the EquiBench automated transformation pipeline for generating (in)equivalent program pairs.

Experimental Results

Our evaluation of 19 state-of-the-art models reveals significant gaps in LLM reasoning capabilities. While models excel at simple syntactic tasks, such as recognizing equivalence after variable renaming (OJ_V category, ~96.5% accuracy for top models), performance plummets when structural changes are introduced.

Accuracy of various LLMs across EquiBench categories, highlighting the performance gap in complex transformations.

Key Findings

  • The "Look-Alike" Bias: Models exhibit a heavy syntactic bias. They tend to assume programs are equivalent if they look similar and inequivalent if they look different (e.g., unrolled loops), regardless of the underlying logic.
  • The Difficulty of Compiler Transformations: Dead Code Elimination (DCE) proved the most challenging category, with a mean accuracy of only 49.0%—effectively no better than a random guess. Similarly, CUDA and x86-64 assembly tasks remain significant hurdles for even the most advanced models.
  • Reasoning Models vs. Standard Models: Specialized "reasoning" models like OpenAI’s o4-mini (82.3% overall) and o3-mini (78.0%) significantly outperform standard large-scale models like Llama-3.1-405B (63.9%).
  • Ineffectiveness of Prompting: Techniques such as Chain-of-Thought (CoT) or few-shot prompting provided negligible benefits, suggesting that models lack the fundamental "mental model" of program execution required for semantic reasoning.

Conclusion and Future Work

EquiBench highlights that current LLMs often rely on surface-level patterns rather than deep semantic understanding. Future research should explore agentic approaches, where models can actively execute code to observe behavior, and the generation of mathematically verifiable formal proofs. Bridging this gap is essential for developing AI that can reliably assist in complex software engineering tasks like compiler optimization and formal verification.

Summary updated

BibTeX
@misc{wei2025equibench,
  author = {Anjiang Wei and Jiannan Cao and Ran Li and Hongyu Chen and Yuhui Zhang and Ziheng Wang and Yuan Liu and Thiago Teixeira and Diyi Yang and Ke Wang and Alex Aiken},
  title = {{EquiBench: Benchmarking Large Language Models’ Reasoning about Program Semantics via Equivalence Checking}},
  year = {2025},
  eprint = {2502.12466},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.12466},
}
Figure