Safe Autoformalization: Sufficiency and Necessity with Entailment Graphs
Organizations: Carnegie Mellon University
Abstract
Autoformalization translates a natural-language statement into a formula that captures its intent, which depends on the statement's context: the background that disambiguates it. LLMs make autoformalization practical, but their probabilistic output carries no formal guarantees. We propose techniques for safe autoformalization that certify one-sided logical adequacy: a formula sufficient for the intent is safe to enforce, and a formula necessary for it is safe to rely on. We use LLMs to generate candidate formulas and order them by logical strength in an Entailment Graph (EG), an ordering a solver decides. Each edge carries a residual and a co-residual, the two adjoints of the entailment order, all fixed by the candidate pool alone. In a context, two searches return the sufficient frontier, the weakest candidates that entail the statement, and the necessary frontier, the strongest candidates the statement entails; each step is one local check against an edge's residual or co-residual. The frontiers bracket the statement and yield the ambiguity residue, which holds exactly of the situations the candidates certify neither as satisfying nor as violating it; the statement is ambiguous precisely when the residue is satisfiable. For natural-language statements and contexts, an LLM entailment oracle decides the checks; it is sound if it accepts only checks that hold, and complete if it accepts every check that holds. We prove that a sound oracle makes the search safe regardless of pool quality, and that a complete one makes the frontiers tight. On security-critical AWS properties, EGs are safe in all 20 cases of an expert-adjudicated study, where majority vote over equivalence clusters and Universal Self-Consistency are unsafe in 25% and 10%. An ablation with the same oracle but no graph is unsafe in 25% and rejects every candidate in another 30%. We machine-checked our proofs in Lean.
Figures & tables
| solver | Emits the edge’s implication in SMT-LIB and discharges it with cvc5 : (=> (forall ((j Int)) HttpProtocolIpv6 ) (forall ((j Int)) InstanceType )) ( 2.5 kB elided) valid : . |
|---|---|
| oracle | Receives both candidates in SMT-LIB and describes each in English. : for every EC2 instance, if HttpProtocolIpv6 is “enabled”, then (i) InstanceType is non-empty, (ii) SubnetId is non-empty, and (iii) every subnet matching SubnetId has a non-empty Ipv6CidrBlock or has Ipv6Native true. : then (iii) only. |
| oracle | States the difference: “ would allow an instance with HttpProtocolIpv6 enabled but with an empty InstanceType and/or an empty SubnetId .” |
| oracle | Judges it against: “the statement says the instance must be a Nitro-based instance , so InstanceType must be specified, and launched in a subnet that supports IPv6 , so SubnetId must be specified. Both are required.” |
| oracle | Verdict no , unanimous over five samples. |
| search | The search does not traverse the edge or weaken to , and remains on the sufficient frontier. |
| Quantity | Count | Fraction |
| Properties | 64 | — |
| Zero entropy (single eq class) | 44 | 68.8% |
| Non-zero entropy (the benchmark) | 20 | 31.2% |
| Accuracy on the 20 (expert manual audit) | ||
| Majority vote over clusters (MV) | ||
| — safe, matches reference | 8 | 40% |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Quantity | Count | Fraction |
| Statements ( base mutants) | 192 | — |
| Successfully autoformalized | 176 | 91.7% |
| Zero entropy (single class; agree) | 24 | 13.6% |
| Non-zero entropy (the benchmark) | 152 | 86.4% |
| The 152 informative cases, by agreement | ||
| Agree on same candidate | 85 | 55.9% |
| Metric | Suff. | Nec. |
|---|---|---|
| Edge checks ( samples) | 54 | 57 |
| Unanimous ( identical) | 85% | 86% |
| Mean agreement with quorum | 0.96 | 0.97 |
| Verdict flips, vs | 4% | 0% |
| Verdict flips, vs | 4% | 7% |
| Metric | Total | Suff. | Nec. |
|---|---|---|---|
| Checks the oracle accepts | 30 | 22 | 8 |
| and the check holds | 22 | 15 | 7 |
| and the check is wrong | 1 | 1 | 0 |
| and the check is undecided | 7 | 6 | 1 |
| Rate holding, decided checks |
Autoformalization
Autoformalization converts natural-language mathematics, proofs, and specifications into machine-checkable formal languages.
See all 130 papers