Bibliographic Details
| Title: |
Understanding code semantics: a benchmark study of LLMs. |
| Authors: |
Laneve, Cosimo1 (AUTHOR) cosimo.laneve@unibo.it, Spanò, Alvise2 (AUTHOR) alvise.spano@unive.it, Ressi, Dalila2 (AUTHOR) dalila.ressi@unive.it, Rossi, Sabina2 (AUTHOR) sabina.rossi@unive.it, Bugliesi, Michele2 (AUTHOR) michele.bugliesi@unive.it |
| Source: |
International Journal on Software Tools for Technology Transfer. Jun2026, Vol. 28 Issue 3, p329-343. 15p. |
| Subjects: |
Programming language semantics, Program transformation, Benchmark problems (Computer science), Python programming language, Language models |
| Abstract: |
We present an empirical study on the ability of Large Language Models (LLMs) to understand code by detecting semantically equivalent and inequivalent programs, that is, whether they compute the same result given the same input or not. To probe this, we deliberately perturb the program text by introducing semantics-preserving code transformations, namely copy propagation and constant folding. Using a benchmark of 11 Python functions with both equivalent and non-equivalent variants, we evaluate seven state-of-the-art LLMs (including ChatGPT, Claude, Gemini, and Deep-Seek) under zero-shot prompting, with and without minimal context. Despite strong performance in code generation tasks, the models often fail in this deeper reasoning challenge, misclassifying 41% of equivalent cases without context and 29% with context. Although prompting can improve performance, it does not address the underlying limitations of the models. We argue that improving LLMs themselves, through targeted fine-tuning, contrastive learning on equivalent and nonequivalent implementations, or training on transformation-invariant code, will be necessary for robust semantic understanding. Meanwhile, practitioners can achieve better results by selecting stronger models, carefully engineering prom-pts, or writing code with tools that normalize low-level differences before inference. [ABSTRACT FROM AUTHOR] |
|
Copyright of International Journal on Software Tools for Technology Transfer is the property of Springer Nature and its content may not be copied or emailed to multiple sites without the copyright holder's express written permission. Additionally, content may not be used with any artificial intelligence tools or machine learning technologies. However, users may print, download, or email articles for individual use. This abstract may be abridged. No warranty is given about the accuracy of the copy. Users should refer to the original published version of the material for the full abstract. (Copyright applies to all Abstracts.) |
| Database: |
Engineering Source |