Skip to content
Book Open access

From Syntactic Mimicry to Semantic Correctness: Behavioral Understanding in LLM Code Generation

Jul 2026 · SIGSOFT FSE Companion · pp. 31-34 · 0 citations · 19 references
Computer Science

TL;DR

This work addresses three interconnected challenges in building behaviorally-grounded code generation: retrieving not just what symbols are, but how they behave through usage patterns; adapting practices across contexts by separating behavioral intent from implementation details; and enforcing semantic properties during generation without prohibitive runtime costs.

Abstract

Large Language Models (LLMs) have transformed software engineering by automating code generation, yet they frequently produce code that is syntactically correct but behaviorally incorrect—failing to respect repository conventions, misapplying practices across contexts, or violating semantic properties. These failures come from a fundamental limitation: current LLMs learn syntactic patterns but lack behavioral understanding of how code executes in context. This work addresses three interconnected challenges in building behaviorally-grounded code generation: (1) retrieving not just what symbols are, but how they behave through usage patterns; (2) adapting practices across contexts by separating behavioral intent from implementation details; and (3) enforcing semantic properties during generation without prohibitive runtime costs. Preliminary results demonstrate substantial improvements: 48.2% exact match on repository completion (vs. 29.05% baseline) and 100% conformance on cross-framework practice transfer (vs. 0% baseline). This work aims to transform LLMs from pattern-matching systems into behaviorally-aware generation system that understand what code does, not just what it looks like.

Read PDF

Similar papers

#artificial intelligence Book Open access Sep 2026

Predicting Program Exit Code with LLMs and Programming Language Semantics

This work evaluates open-source coding LLMs under two semantic formalisms and two semantic shifts across Human-Written, LLM-Translated, and Fuzzer-Generated program splits, showing that LLMs lean on pre-training priors rather than systematically applying the given rules.

Lara Marinov, Aditya Thimmaiah, Jayanth Srinivasa et al. · 0 citations
Open access Aug 2026

How well do LLMs understand code?

SemBench is introduced, a novel benchmark consisting of 1000 diverse C programs sourced from the CodeParrot GitHub-code dataset, with 15,404 semantic questions spanning six basic but fundamental properties: dead code-statement, data dependency, function reachability, dominator, dead code-loop, and liveness.

Jade Xu, Ren-Liang Sun, Zijian Ding et al. · 0 citations
Jul 2026

The Language of Security: How Prompt Syntax Shapes Secure Code Generation in Open LLMs

This work systematically generates syntactic variants of security-relevant code generation prompts and evaluates their impact on code security across multiple open LLMs and programming languages, identifying prompt syntax as a concrete security control surface and providing actionable guidance for reducing vulnerabilit...

Matteo Cicalese, Antonio Della Porta, Stefano Lambiase et al. · 0 citations
Jul 2026

Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphs

This work introduces Code-MUE, a purely black-box framework that measures uncertainty through execution-based Semantic Interaction Graphs, and grounds uncertainty in observable runtime behavior, calculating the Von Neumann entropy of the solution space to quantify global semantic diversity.

Xiao-Ning Ren, Yin-Xing Xue, Lei Ma et al. · 0 citations
Jul 2026

A Mechanistic Lens on Semantic Conflicts: Using Activation Patching to Understand LLM Behavior

The findings show that semantic conflicts affect program comprehension and downstream tasks, with relevant information concentrated in a small number of causally active residual-stream states, and demonstrate a framework for mechanistically analyzing how LLMs integrate code-related information under controlled semantic...

Youssef Abdelsalam, Norman Peitek, Anna-Maria Maurer et al. · 2 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.