cs.CLSep 16, 2026

Verification of PETSc with CIVL using LLM-generated ACSL contracts and deterministic driver generation

Authors: Hansol Suh, Jan Hückelheim, Stephen Siegel

Organizations: Argonne National Laboratory, Lemont, Illinois, USA · University of Delaware, Newark, Delaware, USA

Abstract

Parallel numerical libraries such as PETSc are widely used in science and engineering applications where wrong results can have costly consequences. Despite this, numerical libraries are rarely formally verified. One of the challenges is the need for an expert to hand-write a specification and manually apply a verification tool, often requiring the development of a harness or driver, all of which can contain additional bugs that lead to false positives or false negatives during verification. With recent advancements in large language models (LLMs), it is tempting to generate such drivers and reference models automatically, but one-shot generation based on a simple prompt is brittle and leads to additional unverified code that needs to be audited. In this paper, we present an approach to use LLMs in a limited setting to generate a small, human-certifiable ACSL contract from the function's documentation, combined with a deterministic toolchain that supports a restricted ACSL profile and generates a driver that uses the CIVL verifier to check the implementation against the contract and, when available, an existing reference model. We demonstrate the pipeline end-to-end on three PETSc functions: MatAXPY (reference model already exists), MatAYPX (no reference model, so the certified contract is the sole oracle), and the non-compressing mode of MatFilter (no reference model, with more complex, conditional behavior). With this pipeline, we were able to discover a bug in PETSc's MatAYPX function that was previously undiscovered and had been present in the code since 1997.

Figures & tables

Explore similar work

CardsList
  1. An Agentic Evaluation Framework for AI-Generated Scientific Code in PETSc

    Mar 16, 2026Hong Zhang, Barry Smith, Satish Balay +4High-Performance ComputingCode Generation

  2. An Empirical Study of LLM-Generated Specifications for VeriFast

    Jun 25, 2026Wen Fan, Minh Tran, Sanya Dod +5LLM EvaluationFormal Verification