← Latest papers
🤖 AI

Faithful Autoformalization of Natural Language Assertions

The paper introduces Monty, an autoformalization framework that improves the precision of synthesizing executable assertions from natural language by filtering LLM-generated outputs using novel conformance and validity scores, achieving up to a 20-point average precision gain over naive translation methods.

Original authors: Hongyi Liu, Madhusudan Parthasarathy, Adithya Murali

Published 2026-07-16
📖 7 min read🧠 Deep dive

Original authors: Hongyi Liu, Madhusudan Parthasarathy, Adithya Murali

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

The Translator's Dilemma: When Code Meets Human Words

Imagine you are building a massive digital city. To keep the traffic flowing and the buildings standing, every street corner and skyscraper needs a rulebook. In the world of software, these rulebooks are called "formal specifications." They are precise, mathematical instructions that tell a computer exactly what a piece of code is supposed to do and what it must never do. Think of them as the unbreakable laws of physics for a digital world. The problem is, writing these laws is incredibly hard. It requires a level of precision that feels like speaking a different language entirely, one that most human programmers find tedious and error-prone.

Enter the "Autoformalization" problem. This is the quest to take a human's messy, natural-language idea—like "don't let the list get too big"—and automatically translate it into that strict, mathematical code. For years, scientists have tried to use Artificial Intelligence (AI), specifically Large Language Models (LLMs), to act as translators. These AI models are like super-smart polyglots that have read almost everything ever written. They are great at guessing what a sentence means. But here is the catch: when you ask an AI to translate a vague human thought into a strict legal contract, it often hallucinates. It might invent rules that don't exist, miss a tiny detail that breaks the whole system, or confidently translate a "maybe" into a "definitely." The core question this paper tackles is: How do we trust an AI translator when the stakes are high, and the human instructions are fuzzy?

Meet Monty: The Detective Who Checks the AI's Homework

This paper introduces a new framework called Monty, a system designed to be a skeptical, detail-oriented editor for AI-generated code rules. The authors, researchers from the University of Wisconsin-Madison and the University of Illinois, realized that simply asking an AI to translate a sentence into code isn't enough. If you ask an AI to translate "the list should be empty," it might guess that means "the list has zero items" or "the list has no items at all." Both sound right, but in computer code, they might mean very different things.

Monty doesn't just trust the first answer the AI gives. Instead, it acts like a detective running a series of tests. Here is how the story unfolds:

1. The AI Generates a Crowd of Suspects
First, Monty asks a Large Language Model to translate a natural-language assertion (a human sentence) into formal code. The AI doesn't just give one answer; it generates a whole crowd of "candidate" translations. Some might be perfect, some might be slightly off, and some might be completely wrong.

2. The "Fuzz" Test: Breaking the Code
Next, Monty puts these candidate translations through a stress test called "fuzzing." Imagine a robot throwing random, wild inputs at the code to see if it crashes or behaves strangely.

  • If a candidate translation crashes the computer or throws an error, Monty throws it out immediately.
  • If the translation works but fails to match the logic of the original human sentence, it gets a low score.
  • Crucially, Monty doesn't assume the human sentence is correct. Sometimes, a programmer writes a rule that is actually wrong (a "buggy" rule). Monty is smart enough to realize that a "valid" translation of a "buggy" rule is still a bug. It looks for both the most likely correct translation and the most likely incorrect translation to see which one fits the context.

3. The "Clause Coverage" Check: The Reverse Translation
This is Monty's secret weapon. To check if an AI translation is truly faithful, Monty uses a clever trick called clausal coverage. It takes the AI's formal code and asks the AI to translate it back into plain English. Then, it compares this new English sentence with the original human sentence.

  • Did the AI miss a part of the original sentence?
  • Did it add something that wasn't there?
  • Did it change the meaning?
    The AI acts as a judge, giving a score based on how well the pieces (clauses) of the two sentences match. If the back-translation is missing a key detail, the score drops, and that candidate is filtered out.

4. The Final Showdown: Active Learning
Sometimes, the AI generates two candidates that both look perfect and pass all the tests, but they mean slightly different things. This is where the "ambiguity" of human language bites back. In these rare cases, Monty doesn't guess. It uses active learning. It finds a specific scenario (a "distinguishing valuation") where the two candidates would behave differently. It then asks a human (or a simulated oracle) a simple question: "In this specific case, which rule did you actually mean?" The human picks the winner, and Monty locks in the correct translation.

What Monty Found

The researchers tested Monty on 541 different tasks involving Java code, which is a popular programming language. They used datasets that included both perfectly written rules and intentionally broken ones to see if Monty could handle the messiness of real life.

The results were promising. When they let the AI translate naturally without Monty's help, the accuracy was decent but far from perfect. For example, using a specific model called Qwen2.5-Coder, the raw AI got the translation right about 75% of the time on one dataset. But when Monty stepped in to filter and check the answers, that accuracy jumped to 91.6%. On another dataset, it went from 64% to 85%.

The paper suggests that Monty is particularly good at fixing the "precision" problem. This means that when Monty says, "Here is the correct rule," you can trust it much more than when you just ask an AI and take its first answer. It managed to do this without throwing away too many correct answers (keeping the "recall" high).

What Monty Does Not Do

It is important to know what this paper is not claiming. Monty is not a magic wand that solves every programming problem.

  • It does not try to figure out the high-level "intent" of a whole software project (like "build me a social media app"). It focuses strictly on translating specific, localized rules for individual pieces of code.
  • It does not claim to have solved the problem of ambiguity forever. Sometimes, the human input is so vague that even Monty needs a human to step in and clarify.
  • The authors explicitly argue against the idea that we should just assume every rule a programmer writes is correct. Many older tools assumed that if a rule was written, it must be true. Monty rejects this, showing that sometimes the goal is to find the rule that fails, proving the code is buggy.

The Bottom Line

In the end, Monty suggests that the future of writing code isn't just about asking an AI to do the work. It's about building a system where the AI generates ideas, but a smart, rigorous process checks them against reality. By combining the creativity of AI with the skepticism of testing and the precision of "reverse translation," Monty shows a path toward making software safer and more reliable, turning the messy, ambiguous thoughts of human developers into the clean, unbreakable laws of the digital world. The paper suggests that while we aren't there yet, this "check-your-work" approach is a significant step forward in making AI a trustworthy partner in software development.

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 →