Clover: Closed-Loop Verifiable Code Generation

Chuyue Sun, Ying Sheng, Oded Padon, Clark Barrett

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

Abstract

The use of large language models for code generation is a rapidly growing trend in software development. However, without effective methods for ensuring the correctness of generated code, this trend could lead to undesirable outcomes. In this paper, we introduce a new approach for addressing this challenge: the Clover paradigm, short for Closed-Loop Verifiable Code Generation, which uses consistency checking to provide a strong filter for incorrect code. Clover performs consistency checks among code, docstrings, and formal annotations. The checker is implemented using a novel integration of formal verification tools and large language models. We provide a theoretical analysis to support our thesis that Clover should be effective at consistency checking. We also empirically investigate its performance on a hand-designed dataset (CloverBench) featuring annotated Dafny programs at a textbook level of difficulty. Experimental results show that for this dataset: (i) LLMs are reasonably successful at automatically generating formal specifications; and (ii) our consistency checker achieves a promising acceptance rate (up to 87%) for correct instances while maintaining zero tolerance for adversarial incorrect ones (no false positives). Clover also discovered 6 incorrect programs in the existing human-written dataset MBPP-DFY-50.

Original languageEnglish
Title of host publicationAI Verification - 1st International Symposium, SAIV 2024, Proceedings
EditorsGuy Avni, Mirco Giacobbe, Taylor T. Johnson, Guy Katz, Anna Lukina, Nina Narodytska, Christian Schilling
PublisherSpringer Science and Business Media B.V.
Pages134-155
Number of pages22
ISBN (Print)9783031651113
DOIs
StatePublished - 2024
Externally publishedYes
Event1st International Symposium on AI Verification, SAIV 2024 - Montreal, Canada
Duration: 22 Jul 202423 Jul 2024

Publication series

NameLecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
Volume14846 LNCS

Conference

Conference1st International Symposium on AI Verification, SAIV 2024
Country/TerritoryCanada
CityMontreal
Period22/07/2423/07/24

All Science Journal Classification (ASJC) codes

  • Theoretical Computer Science
  • General Computer Science

Fingerprint

Dive into the research topics of 'Clover: Closed-Loop Verifiable Code Generation'. Together they form a unique fingerprint.

Cite this