Saved in:
Bibliographic Details
Main Authors: Shao, Lize, Cardei, Michael, Xie, Zichen, Fioretto, Ferdinando, Wang, Wenxi
Format: Preprint
Published: 2026
Subjects:
Online Access:https://arxiv.org/abs/2605.16829
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913134732640256
author Shao, Lize
Cardei, Michael
Xie, Zichen
Fioretto, Ferdinando
Wang, Wenxi
author_facet Shao, Lize
Cardei, Michael
Xie, Zichen
Fioretto, Ferdinando
Wang, Wenxi
contents Discrete diffusion models are a powerful, emerging paradigm for code generation. They construct programs through iterative refinement of partially corrupted token sequences and enable parallel token refinement. Importantly, this paradigm exposes a global program state at each denoising step, which provides a natural intervention point for enforcing program-level functionality and security constraints, guiding the generation before the final code is committed. Building on this observation, the paper introduces Constrained Diffusion for Code (CDC), a training-free neurosymbolic inference framework that integrates constraint satisfaction directly into the reverse denoising process. CDC augments the base discrete diffusion sampler with constraint-aware denoising operators that combine mathematical optimization with program analysis to identify constraint-relevant regions of the intermediate program state and locally adjust the denoising trajectory, steering generation toward feasible programs while remaining close to the base model. Across code generation benchmarks, CDC consistently improves constraint satisfaction in functional correctness, security, and even syntax, outperforming discrete diffusion and autoregressive baselines with less corrective computation and more localized edits.
format Preprint
id arxiv_https___arxiv_org_abs_2605_16829
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Constrained Code Generation with Discrete Diffusion
Shao, Lize
Cardei, Michael
Xie, Zichen
Fioretto, Ferdinando
Wang, Wenxi
Computation and Language
Programming Languages
Discrete diffusion models are a powerful, emerging paradigm for code generation. They construct programs through iterative refinement of partially corrupted token sequences and enable parallel token refinement. Importantly, this paradigm exposes a global program state at each denoising step, which provides a natural intervention point for enforcing program-level functionality and security constraints, guiding the generation before the final code is committed. Building on this observation, the paper introduces Constrained Diffusion for Code (CDC), a training-free neurosymbolic inference framework that integrates constraint satisfaction directly into the reverse denoising process. CDC augments the base discrete diffusion sampler with constraint-aware denoising operators that combine mathematical optimization with program analysis to identify constraint-relevant regions of the intermediate program state and locally adjust the denoising trajectory, steering generation toward feasible programs while remaining close to the base model. Across code generation benchmarks, CDC consistently improves constraint satisfaction in functional correctness, security, and even syntax, outperforming discrete diffusion and autoregressive baselines with less corrective computation and more localized edits.
title Constrained Code Generation with Discrete Diffusion
topic Computation and Language
Programming Languages
url https://arxiv.org/abs/2605.16829