← Latest papers
💻 computer science

Natural Language based Specification and Verification

This paper proposes and preliminarily validates a novel approach that leverages large language models to both generate natural language specifications and perform compositional verification of code, aiming to prevent the production of vulnerable implementations without relying on rigid formal languages.

Original authors: Zhaorui Li, Chengyu Song

Published 2026-05-13
📖 4 min read☕ Coffee break read

Original authors: Zhaorui Li, Chengyu Song

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to prove that a massive, complex machine (like a car engine or a computer program) will never break or cause an accident.

The Problem: The "Too Big to Read" Machine

In the world of computer code, especially in languages like C and C++, there are many ways things can go wrong. A pointer might point to nothing, memory might be used after it's been thrown away, or a buffer might be too small. These errors are like tiny cracks in a dam; they often happen because of how different parts of the machine interact with each other.

Traditionally, to prove a machine is safe, you need a strict, mathematical rulebook (formal specifications). But writing this rulebook is incredibly hard and tedious. It's like trying to write a legal contract for every single gear in an engine before you can even check if the engine works.

Recently, we have powerful AI models (Large Language Models or LLMs) that are great at reading code and finding bugs. However, asking these AIs to look at the entire engine at once and say, "Is this safe?" usually fails. The engine is too big, and the AI gets confused, missing the subtle connections between the pistons and the valves.

The Solution: NLForge (The "Summary Note" Approach)

The paper introduces a new tool called NLForge. Instead of asking the AI to read the whole machine at once, NLForge uses a strategy called compositional verification.

Think of it like a team of inspectors checking a massive skyscraper:

  1. The Old Way (Monolithic): You hire one inspector to stand on the roof and look at the whole building at once. They get overwhelmed, miss details, and can't see how the plumbing on the 10th floor affects the elevator on the 2nd.
  2. The NLForge Way (Compositional): You break the building down into floors.
    • First, you send an inspector to the basement. They check the foundation and write a simple, plain-English note (a summary) about what the basement does (e.g., "This floor holds water, but only if the pipes are connected").
    • Next, you send an inspector to the 1st floor. They read the basement's note. They don't need to see the basement's blueprints; they just need to know the rules. They check the 1st floor, write their own note, and pass it up.
    • This continues all the way to the roof. Each inspector only has to worry about their own floor, trusting the notes from the floors below.

The Secret Sauce: Plain English Notes

Here is the twist: Most previous attempts at this used strict, mathematical languages for these notes. But the AI is better at understanding and writing natural language (like English) than complex math symbols.

NLForge asks the AI to write these "notes" in plain English.

  • Instead of a complex formula, the AI writes: "This function gives you a new box of memory, but it might be empty (null)."
  • The next AI reading this note understands it perfectly and uses that information to check the next part of the code.

What They Found

The researchers tested this on a set of difficult code challenges (from a competition called SV-COMP).

  • Can AI be a verifier? Yes, but with a catch. The AI is very good at finding bugs (high recall), meaning it rarely misses a problem. However, it sometimes cries "wolf" when there is no wolf (false positives). It's not yet perfect enough to replace a strict mathematical proof, but it's excellent for finding potential issues quickly.
  • Does the "Note-Taking" method work? Yes! When the AI used the "summary notes" method (compositional), it found significantly more bugs than when it tried to read the whole code at once. This was especially true for smaller AI models that have trouble remembering long contexts. The notes acted like a cheat sheet, helping them reason better.

The Bottom Line

The paper argues that we shouldn't just use AI to generate strict math rules for other tools to check. Instead, we should let the AI be the reasoner itself, using simple, human-readable summaries to break down big, scary problems into small, manageable pieces.

It's like solving a giant jigsaw puzzle: instead of staring at the whole box and getting dizzy, you sort the pieces into small piles (summaries) and solve them one by one, trusting that the pieces from the previous pile fit perfectly into the next one.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →