Disproving Program Equivalence with LLMs
Miltiadis Allamanis, Pengcheng Yin
TL;DR
ProbeGen presents a white-box, execution-feedback-driven method to disprove functional equivalence among code implementations by generating usage probes with LLMs. It complements unit tests by exposing semantic differences that unit tests often miss, and it enables semantic clustering and self-consistency analyses to improve code synthesis evaluation. Across the LBPP code-synthesis benchmark, ProbeGen finds significant semantic differences in samples deemed equivalent by unit tests (about 18–24%), and deeper tree-search strategies can boost discovery efficiency with manageable cost. The results suggest ProbeGen is a valuable tool for evaluating and debugging LLM-generated code, particularly when unit tests are weak or unavailable, and for enabling more interpretable, semantically aware analyses of code proposals.
Abstract
To evaluate large language models (LLMs) for code, research has used manually created unit test-based benchmarks. However, these tests are often inadequate, missing corner cases and other implementation-specific oddities. This work introduces ProbeGen, a whitebox method that takes two or more executable pieces of code and searches for counterexamples to their equivalence. Comparing code semantics requires a deep understanding of code. We demonstrate that LLMs with execution feedback perform well at this task. In a common code synthesis benchmark, ProbeGen disproves 18% of samples considered equivalent to the ground truth by the benchmark-provided unit tests. Additionally, using ProbeGen, we can semantically cluster LLM samples for semantic self-consistency, improving pass@1 by 10% by unifying syntactically distinct but semantically similar samples.
