Skip to main content
QUICK REVIEW

[Paper Review] Neuro-Symbolic Generation and Validation of Memory-Aware Formal Function Specifications

Liao Zhang, Tong Chen|arXiv (Cornell University)|Mar 12, 2026
Formal Methods in VerificationComputer Science0 citations
TL;DR

The paper presents a neuro-symbolic workflow that generates memory-aware formal C function specifications from natural language and function signatures, with iterative refinement using symbolic provers and a Coq-based counterexample-guided refutation framework, evaluated on a LeetCode-derived benchmark.

ABSTRACT

Formal verification of memory-manipulating programs critically depends on precise function specifications that capture memory states written by experts. This requirement has become a major bottleneck as large language models (LLMs) increasingly generate low-level systems code whose correctness cannot be assumed. To enable scalable formal verification, we focus exclusively on function specification generation, deliberately avoiding the synthesis of complex loop invariants that are central to traditional verification pipelines. We propose a neuro-symbolic framework for automatically generating memory-aware formal function specifications for C programs from natural language problem descriptions and function signatures. The pipeline first produces candidate specifications via in-context learning, and then iteratively refines them using compiler diagnostics from symbolic provers and the verification toolchain. In particular, we validate candidate specifications by constructing a proof for the negation of the specification with concrete examples, enabling machine-checked rejection of plausible-but-incorrect specifications. To support systematic evaluation, we introduce LeetCode-C-Spec, a new benchmark of 200 C programming problems for generating memory-aware formal function specifications. Experiments show that iterative refinement substantially improves syntactic validity, while symbolic prover-based refutation significantly enhances correctness assessment by filtering false positives that LLM-only judges frequently accept. Our results demonstrate that combining neural generation with symbolic feedback provides an effective approach to formal specification synthesis for memory-safe systems software.

Motivation & Objective

  • Address the bottleneck in formal verification caused by writing memory-aware function specifications for C programs.
  • Develop a neuro-symbolic, two-phase workflow to generate and refine memory-aware function specifications from natural language and function signatures.
  • Enable automated validation of specifications via counterexample-guided refutation using Coq and symbolic provers.
  • Create and release LeetCode-C-Spec-200, a benchmark of 200 C problems for memory-aware specification generation.

Proposed method

  • Two-phase pipeline: Phase 1 uses in-context learning with curated prompts to generate QCP-compatible memory-aware C function specifications.
  • Phase 2 iteratively refines specifications using compiler diagnostics from Coq and QCP, and counterexample-guided refutation to fix syntactic and semantic errors.
  • Validation combines LLM semantic checks with formal methods: generate negated postconditions, instantiate concrete Coq test cases, and attempt to discharge via Coq hammer with automated theorem provers.
  • Counterexample generation workflow converts natural-language examples to typed Coq representations, then to refutation test cases to formally refute incorrect specifications.
  • Dataset and transformation: LeetCode-C-Spec-200 (200 LeetCode problems) is constructed for memory-aware specification generation, with mappings to QCP predicates and Coq imports.
  • The approach emphasizes function-level specifications over loop invariants to enable test-based validation and layered verification.

Experimental results

Research questions

  • RQ1Can memory-aware functional specifications for C be automatically generated from natural language problem descriptions and function signatures?
  • RQ2Does iterative refinement with symbolic feedback improve syntactic validity of specifications generated by LLMs?
  • RQ3Does Coq-based counterexample-guided refutation effectively filter false positives that LLM-only judgments accept?
  • RQ4Is LeetCode-C-Spec-200 a suitable benchmark for memory-aware formal specification generation in C?
  • RQ5What is the impact of combining neural generation with symbolic validation on correctness and verification readiness?

Key findings

  • Iterative refinement substantially improves syntactic validity of LLM-generated specifications.
  • Symbolic prover-based refutation via Coq significantly enhances correctness assessment by filtering false positives.
  • The integrated neuro-symbolic workflow improves memory-aware function specification generation for C programs.
  • LeetCode-C-Spec-200 provides a challenging benchmark with diverse data structures and algorithmic complexity for evaluation.
  • Coq hammer and automated theorem provers help validate postconditions and detect specification errors.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.