Proceedingsbeitrag
Zitieren …

LLM-based Program Synthesis in Correctness-by-Construction Engineering

Maximilian Kodetzki  ORCID-iD-Icon 1, Hannah Grimm 1, Fynn Demmler 1 und Ina Schaefer ORCID-iD-Icon 1
1 Institut für Informationssicherheit und Verlässlichkeit (KASTEL), Karlsruher Institut für Technologie (KIT)
DOI: 10.5445/IR/1000196752/pub
Verlagsausgabe veröffentlicht am 04.11.2026
CC BY 4.0
DOI: 10.5445/IR/1000196752
Postprint veröffentlicht am 01.09.2026
Abstract

The growing reliance on software in safety-critical systems demands strong guarantees of functional correctness. Formal methods address this need by providing proofs as evidence of correctness. Among these, Correctness-by-Construction (CbC) ensures functional correctness through the incremental application of refinement rules while providing early feedback on the program correctness. However, its practical adoption is limited by the required manual effort. Among others, writing concrete program code is left to the developer. In recent years, large language models (LLMs) have demonstrated strong capabilities in code generation from both natural language and formal inputs. Therefore, we explore the use of LLMs to automatically generate code in the context of CbC to make the approach more applicable. We evaluate LLM-based program synthesis using four LLMs and a prompt tailored to CbC on a dataset of 57 specifications drawn from existing CbC case studies, each consisting of a precondition and a postcondition describing the desired behavior. We assess the generated code with respect to correctness and reproducibility across multiple runs. In addition, we compare the results to classically synthesized code, as it can currently be generated in CbC. Our evaluation shows that all considered LLMs outperform the current synthesis approach. Among them, Claude achieves the best performance, reaching 80.70% correct results.