Co-Synthesis of Code and Formal Models Using Large Language Models and Functors

Sumit Kumar Jha, Susmit Jha, Rickard Ewetz, Alvaro Velasquez · 2024

Large Language Models (LLMs) have demonstrated remarkable capabilities in generating code from natural language descriptions, including code for parallel systems. However, ensuring that this code is free of errors, particularly in concurrent and synchronization-heavy contexts, remains a significant challenge. In this paper, we introduce a new approach that employs LLMs to co-synthesize the code, its formal model and the functor that establishes the mapping between the code and its formal model. The formal models are then verified against temporal logic specifications using model checking. The functors serve as human-auditable artifacts that help establish equivalence between the code and its formal model. Our methodology is demonstrated through experiments involving the co-synthesis of C code and its formal model for the dining philosophers problem. Our experimental results using models from OpenAI, Anthropic, and Meta evaluate the effectiveness of our approach.

Read the paper · More papers on PaperTik