arXiv:2610.22568cs.AIOct 2026

Manuscript Offprint

arXiv:2610.22568

Repairing LLM-Generated Specifications with Deterministic Diagnosis

Giovanni Vaccarino, Emanuele La Malfa, Dehai Min, Hanrong Zhang, Pier Luca Lanzi, Lu Cheng, Michael J. Wooldridge, Philip S. Yu, Sara Bernardini

Abstract

Large language models (LLMs) are increasingly used as formalizers: given a reasoning problem expressed in natural language, they produce a formal specification that a symbolic solver can then solve, with guarantees relative to that specification. Many specifications are runnable yet semantically wrong, encoding incorrect constraints, domains, objectives, predicates, or goals, and solver-error feedback dries up once execution succeeds. Purely LLM-based diagnosis, lacking a formal ground truth, often fails to spot these errors, and its ungrounded critiques cause regressions in 11.8% of initially correct specifications in our experiments. We propose DRAGO, a repair framework that replaces this ungrounded critique with deterministic, formalism-specific diagnosis, and retains a rewrite only when the diagnosed error weight strictly decreases under a reference-free acceptance predicate. Across five benchmarks spanning logical reasoning (SMT-LIB2), constraint programming (MiniZinc), and planning (PDDL), DRAGO cuts regressions by nearly an order of magnitude, to 1.3%, while improving answer accuracy by 12.9 percentage points over zero-shot formalization and 8.7 percentage points over LLM-diagnostic repair, averaged across benchmarks. We also uncover two rendering defects in Planetarium that cause 50% (3,086 instances) of its floor-tile split to be inconsistent with the reference formalizations, and release a corrected split.

1 Introduction

In the paradigm of Large Language Models (LLMs) as formalizers, an LLM turns a natural language problem specification into a formal specification (Liu et al., 2023; Olausson et al., 2023; Cai et al., 2025). Such a paradigm separates the linguistic interpretation from the combinatorial machinery that a solver provides, and delegates searching, proving, or validating an (optimal) solution to a symbolic backend (Pan et al., 2023; Ye et al., 2023; AhmadiTeshnizi et al., 2024; Hao et al., 2025a; Huang and Zhang, 2025).

A fundamental challenge beyond generating executable code with LLMs is that of ensuring that the resulting artifact preserves the intended semantics of the original problem. In fact, semantic failures often go unnoticed, as solvers cannot provide guidance on resolving them (Ni et al., 2026a; Peran et al., 2026). A generated artifact may parse and run while still encoding an incorrect quantifier scope, missing a constraint, mistyping a domain, or specifying the wrong goal. In this sense, solver-based feedback loops are weak: while parse, type, runtime, and status failures provide a rich repair signal (Pan et al., 2023; AhmadiTeshnizi et al., 2024), that signal becomes sparse precisely when an incorrect artifact becomes executable, leaving the LLM with no actionable feedback for improving. Recent mitigations include LLM-based diagnosis, which supplies denser feedback by asking a reviewer (e.g., another LLM (Kambhampati et al., 2024)) to critique the generated formalization. However, when no reference formalization or ground-truth answer is available, the reviewer must infer the errors from the same problem statement and artifact that produced the mistake. This can result in missed errors, false alarms, and repairs that corrupt previously correct artifacts (Huang et al., 2024; Stechly et al., 2025; Tyen et al., 2024); Figure 1 in Sec. 5 illustrates this failure mode directly. The failure is not merely that self-review misses errors; it is that its false alarms actively corrupt correct artifacts, often breaking more than they repair. Since a reference formalization is typically unavailable at test time, repair requires reliable, reference-free feedback grounded in observable evidence.

We propose Design, Repair And GO (DRAGO), a formalization-repair framework centered on automatic reference-free diagnosis. DRAGO first generates a candidate formalization, then applies deterministic, formalism-specific checks to the candidate and its observable execution behavior. These checks produce structured findings, which are converted into repair hints and provided to a repair model for artifact revision. The diagnostic rules are deliberately formalism-specific, but the repair pattern is shared and replaces ungrounded LLM-based diagnosis with automatic reference-free feedback. Beyond diagnosis, DRAGO retains a proposed rewrite only if it satisfies an evidence-gated acceptance predicate that requires the diagnosed error weight to decrease strictly. The underlying design principle is that repairs should be aimed and accepted based on observable deterministic evidence rather than by the model's own ungrounded judgment. This principle provides a common repair interface that decouples the roles of grounded diagnosis and evidence-gated acceptance (Lian et al., 2026; Ao et al., 2026; Ni et al., 2026a).

We instantiate DRAGO on three domains: logical reasoning, constraint programming, and automated planning. These domains are operationalized through SMT-LIB2 artifacts (Barrett et al., 2010) for first-order logic, MiniZinc models (Nethercote et al., 2007) for constraint programming, and PDDL specifications (McDermott et al., 1998) for planning. We fix one diagnostic configuration per formalism and apply it consistently across all benchmarks and models evaluated within that formalism. Across these settings, DRAGO improves answer accuracy by an average of 12.9 percentage points over zero-shot generation and by 8.7 percentage points over LLM-diagnostic repair. Crucially, the two methods differ most in what they break: LLM-diagnostic repair corrupts more initially correct formalizations than it fixes, while DRAGO's regression rate is nearly an order of magnitude lower (1.3% vs. 11.8% of initially correct artifacts). We also highlight a common evaluation issue in LLM formalization: benchmarks themselves are subject to errors and ambiguities. In Planetarium, we uncover two rendering defects affecting 50% of the floor-tile test split and release a corrected version. Our main contributions are:

• We identify runnable-but-wrong artifacts as a recurrent failure mode in LLM formalization across three formalisms and show that LLM-diagnostic repair is unreliable precisely in this silent region, producing both missed repairs and right-to-wrong regressions.

• We introduce DRAGO, a repair interface shared across formalisms that replaces LLM-based diagnosis with automatic, reference-free diagnosis grounded in deterministic checks and solver probes, and combines it with evidence-gated acceptance.

• Across five benchmarks and four models, DRAGO cuts right-to-wrong regressions by nearly an order of magnitude relative to LLM-diagnostic repair (1.3% vs. 11.8% of initially correct artifacts), while improving answer accuracy by 12.9 percentage points over zero-shot formalization and 8.7 percentage points over the LLM-diagnostic baseline.

• Highlighting the broader challenge of reliable evaluation in LLM formalization, we identify two previously undocumented rendering defects that make 50% (3,086 instances) of Planetarium’s floor-tile test split inconsistent with its references. We patch all affected instances and release the corrected split as open source.

Below, we present DRAGO’s formal framework, evaluate it across three formalization domains, and discuss its empirical behavior, broader implications, and limitations.

References (18)