TL;DR
EquiBench is a novel benchmark designed to evaluate whether Large Language Models (LLMs) possess a deep semantic understanding of code or merely rely on syntactic patterns. By testing 19 state-of-the-art models on program equivalence checking—determining if two different code snippets produce identical outputs—the study reveals that even advanced reasoning models struggle with structural changes, often falling prey to superficial visual similarities.
Introduction
The rapid integration of LLMs into software engineering workflows has highlighted a critical question: do these models truly understand the logic of the code they generate? While popular benchmarks like HumanEval measure the ability to translate natural language into short code snippets, they often fail to capture deep semantic reasoning. To address this, EquiBench introduces the task of program equivalence checking.
Proving that two programs are functionally identical for all possible inputs is a fundamentally difficult (and generally undecidable) problem in computer science. If an LLM can reliably identify equivalence despite drastic syntactic differences, it demonstrates a grounded understanding of program execution rather than simple pattern matching. EquiBench provides a large-scale, automated framework to push these models to their logical limits.
Methodology
To ensure high-confidence labels without the impossibility of exhaustive execution testing, the authors developed an automated pipeline utilizing formal program analysis and compiler infrastructure.
The benchmark generates pairs using four primary techniques:
- Program Analysis (C): Employs Dead Code Elimination (DCE) to remove non-functional code, creating equivalent pairs.
- Compiler Scheduling (CUDA): Uses tensor compilers (TVM) to apply structural optimizations like loop tiling. The resulting code appears different but remains mathematically identical.
- Superoptimization (x86-64): Utilizes the Stoke superoptimizer to find verified, non-obvious assembly sequences equivalent to a target program.
- Algorithmic Variations (Python): Scrapes competitive programming solutions to find diverse algorithmic approaches to the same problem.
The resulting EquiBench dataset comprises 2,400 program pairs (1,200 equivalent and 1,200 inequivalent) across six categories and four languages: C, CUDA, x86-64, and Python.
Key Results
The evaluation of 19 models reveals a significant performance gap between standard instruction-tuned models and those specifically optimized for reasoning.
- Top Performers: OpenAI’s o4-mini achieved the highest overall accuracy at 82.3%, followed by other reasoning-centric models like DeepSeek-R1 and o3-mini.
- Structural Struggles: Models performed worst on tasks requiring deep structural analysis. In the CUDA and C (DCE) categories, the best accuracies were only 63.8% (Claude 3.7 Sonnet) and 76.2% (o4-mini), respectively—barely surpassing the 50% threshold of a random guess.
- Syntactic Bias: Models showed a strong tendency to label syntactically different programs as "inequivalent." In the CUDA and x86-64 categories, models like o1-mini correctly identified inequivalent pairs nearly 99% of the time but failed to recognize equivalent pairs in over 70% of cases.
- The "Easy" Baseline: On the simplest category—Python variable renaming (OJ_V)—models scored as high as 96.5%, confirming that while they handle surface-level changes well, they falter when logic is restructured.
Key Insights and Discussion
The findings from EquiBench suggest several critical takeaways for the development of code-centric LLMs:
- Fooled by Syntax: LLMs rely heavily on superficial structure. Low syntactic similarity often triggers an "inequivalent" prediction, regardless of mathematical identity.
- Prompting Limitations: Techniques like Chain-of-Thought (CoT) and few-shot learning provided negligible improvements, indicating that the lack of semantic reasoning is a fundamental capability gap rather than a prompting issue.
- Fine-Tuning Challenges: Simple fine-tuning on binary labels resulted in only a ~3% accuracy increase. This suggests that models may require exposure to execution traces or step-by-step state analysis to truly internalize program semantics.
Conclusion and Future Work
EquiBench exposes a significant "semantic gap" in current LLMs. While reasoning models show promise, the heavy reliance on syntax over logic remains a hurdle for reliable automated software engineering. Future research should focus on training paradigms that incorporate execution-based feedback, reinforcement learning with formal verifiers, and the use of agentic models capable of active code execution to identify edge cases.
Summary updated