← Latest papers
💬 NLP

Agentic Separation Logic Specification Synthesis

Spec-Agent is an agentic system that synthesizes expressive, well-validated separation logic specifications for large C++ codebases by combining static analysis, runtime heap tracing, and counterexample-guided LLM refinement, achieving 85% success with zero false positives at significantly lower cost than existing methods.

Original authors: Tarun Suresh, David Korczynski, Julien Vanegue

Published 2026-05-28
📖 5 min read🧠 Deep dive

Original authors: Tarun Suresh, David Korczynski, Julien Vanegue

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 have a massive library of old, complex computer code written in C++. This code is the engine room of huge financial systems, but it's written in a way that's hard for humans to read and even harder to prove is bug-free. The authors of this paper, working at Bloomberg, built a new tool called Spec-Agent to act like a super-smart translator and quality inspector for this code.

Here is how Spec-Agent works, explained through simple analogies:

1. The Problem: The "Black Box" Code

Think of a C++ function (a small piece of code) as a black box machine. You put ingredients in (inputs), and it spits out a cake (outputs). The problem is, the machine doesn't have a label saying what ingredients it needs or what the cake will look like.

  • The Risk: If you don't know the rules, you might put in the wrong ingredients, and the machine might explode (crash) or make a terrible cake (a security bug).
  • The Goal: The team wanted to automatically write a "recipe card" (a formal specification) for every machine in the library. This card would say: "If you put in X, you must get Y," and "If you put in Z, the machine will break."

2. The Solution: The "Agentic" Chef

Instead of just asking a smart AI (a Large Language Model) to guess the recipe, the authors built a team of agents (a system that acts on its own) to do the job. They call it Spec-Agent.

Here is the step-by-step process, using a cooking analogy:

Step A: The Detective Work (Code Mining)

Before writing the recipe, Spec-Agent acts like a detective. It looks at the code to see:

  • Does this machine use a simple list of ingredients? (Propositional Logic)
  • Does it check every single item in a huge basket? (First-Order Logic)
  • Does it handle raw, messy memory like a butcher shop, moving meat around on a table? (Separation Logic)
  • Analogy: It's like checking if a recipe is for a simple sandwich or a complex banquet that requires managing multiple kitchen stations simultaneously.

Step B: Choosing the Right Language

Based on what the detective found, Spec-Agent picks the right "language" to write the recipe in.

  • If the code is simple, it uses Propositional Logic (Yes/No rules).
  • If the code loops through lists, it uses First-Order Logic (Rules for "all" or "some" items).
  • If the code messes with computer memory (like moving data around), it uses Separation Logic.
    • Analogy: Separation Logic is like a rule that says, "This knife is only for cutting the steak, and that fork is only for the salad. They cannot touch the same spot on the table at the same time." This is crucial for preventing the computer from getting confused about where data is stored.

Step C: The "Fuzz" Taste Test (Validation)

This is the most creative part. Usually, when you write a recipe, you just follow it once. Spec-Agent does something different: Fuzz Testing.

  • Imagine you have a recipe for a cake. Instead of baking it once, you throw thousands of random, weird ingredients at it (flour, sand, water, fire) to see if the kitchen explodes.
  • In the paper, they take existing tests and turn them into "Fuzz Harnesses." These are automated machines that throw random data at the code.
  • The Magic: If the "recipe card" (the specification) says "This machine can handle sand," but the machine actually crashes when you throw sand at it, the system knows the recipe is wrong. It throws the bad recipe back to the AI chef and says, "Try again, you missed this!"

Step D: The Refinement Loop

The system keeps this cycle going:

  1. AI guesses a recipe.
  2. The "Fuzz Machine" tries to break it with weird inputs.
  3. If it breaks, the AI gets a "counterexample" (a specific weird input that caused the crash) and tries to fix the recipe.
  4. They repeat this until the recipe survives thousands of weird tests without breaking.

3. The Results: A Winning Recipe

The team tested Spec-Agent on two massive, real-world open-source libraries (BDE and BlazingMQ) containing millions of lines of code.

  • Success Rate: Spec-Agent successfully wrote valid, bug-free recipe cards for 85% of the functions it tried.
  • Accuracy: In their testing, they found zero false positives. This means every time the system said a recipe was good, it actually worked.
  • Cost: They compared Spec-Agent to a top-tier commercial AI (Claude Code Opus 4.6). Spec-Agent was 10 times cheaper in terms of computing costs (tokens) while performing better.
  • Complexity: Unlike other tools that only handle simple rules, Spec-Agent could handle the complex "memory management" rules (Separation Logic) that are essential for C++ code.

Summary

Think of Spec-Agent as a tireless, hyper-observant quality control team for software. It doesn't just read the code; it invents a formal rulebook for it, then tries to break that rulebook with thousands of random attacks. If the rulebook survives, it's accepted.

The paper claims this is the first system to do this at such a massive scale (millions of lines of code) while using advanced logic to handle memory safety, all while costing a fraction of what other methods require. It turns the chaotic, unverified world of C++ code into a place where every function has a verified, trustworthy instruction manual.

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 →