Safe Autoformalization: Sufficiency and Necessity with Entailment Graphs
Summary (Overview)
-
Core contribution: The paper introduces Entailment Graphs (EGs)—a neurosymbolic framework for safe autoformalization that certifies one-sided logical adequacy of LLM-generated candidate formulas. A formula that is sufficient for the intent is safe to enforce; one that is necessary is safe to rely on.
-
Key mechanism: Candidate formulas are ordered by logical entailment in a DAG built by a solver. Two graph searches return the sufficient frontier (weakest candidates entailing the statement) and the necessary frontier (strongest candidates entailed by the statement), which bracket the statement's meaning.
-
Ambiguity residue: The gap between frontiers yields a single formula—the ambiguity residue—that holds exactly of situations the candidates certify neither as satisfying nor violating the statement. The statement is ambiguous precisely when this residue is satisfiable.
-
Theoretical guarantees: A sound entailment oracle (LLM) makes the selection safe regardless of pool quality (Theorem 23); completeness is needed only for tightness (Theorem 24). All proofs are machine-checked in Lean 4 over an arbitrary Boolean algebra.
-
Empirical results: On AWS cloud safety properties, EG selection is safe in all 20 expert-adjudicated cases (vs. 25% unsafe for majority vote, 10% for Universal Self-Consistency). An ablation removing the graph but keeping the same oracle is unsafe in 25% of cases and rejects all candidates in another 30%.
Introduction and Theoretical Foundation
Background and Motivation
Autoformalization translates natural-language (NL) statements into formal representations (e.g., SMT-LIB formulas). With LLMs, this has become practical for domains including mathematics, temporal-logic specifications, program contracts, and security policies. However, LLM-based autoformalization carries no formal guarantees—the same statement can be formalized into multiple inequivalent formulas, and natural language is inherently ambiguous.
The paper identifies a crucial insight: in verification pipelines, the role of a formula determines what "correct" means:
- Enforced formulas (guarantees): must be sufficient for the intent—every artifact admitted must be one the intent admits.
- Relied-upon formulas (assumptions): must be necessary—claiming no more than the intent guarantees.
Neither role requires equivalence; each requires one direction of entailment. This mirrors the weakest-precondition/strongest-postcondition duality in program verification (Dijkstra 1975).
Theoretical Foundation: Adjoints in a Boolean Algebra
Formulas modulo equivalence, ordered by entailment, form a Boolean (hence Heyting) algebra. The two key operations are adjoints:
- Residual (right adjoint to conjunction): Given , the residual of w.r.t. is the weakest formula such that . Classically: .
- Co-residual (left adjoint to disjunction): Given , the co-residual is the strongest formula such that . Classically: .
The key decompositions are:
Lemma 6 (Absolute adjoints suffice): Relativizing adjoints to a context leaves checks unchanged—one EG serves every context.
Methodology
Entailment Graph Construction
Definition 1 (Logical Entailment Graph): A DAG whose vertices are equivalence classes of candidate formulas (under logical equivalence) and whose edges represent strict entailment: edge exists when and . The graph is transitively closed.
The graph is always completed with two synthetic vertices:
- (False): the unique strongest vertex (universal root)
- (True): the unique weakest vertex (universal sink)
Frontier Searches
Sufficient-Frontier Search (downward, Figure 3): Starting from , weakens across edges while the co-residual check passes. Returns the weakest candidates entailing in context.
Necessary-Frontier Search (upward, Figure 4): Starting from , strengthens across edges while the residual check passes. Returns the strongest candidates entailed by .
Key theorems:
- Theorem 7: If , then iff .
- Theorem 8: If , then iff .
- Theorem 9/10: Both searches are correct—returning weakest sufficient / strongest necessary candidates.
- Lemma 11 (Frontier Completeness): Frontiers are exactly the extremal elements of the sets and .
Ambiguity Residue
Definition 15: , where and .
Theorem 17 (Disambiguation Criterion): The residue is unsatisfiable iff , which holds iff .
Proposition 20 (Monotonicity): Adding candidates or strengthening the context can only shrink the residue.
Neurosymbolic Realization
The implementation splits responsibilities:
- SMT solver (cvc5): Builds the EG, computes residuals/co-residuals, checks candidate entailments.
- LLM oracle: Answers only local edge checks of two shapes:
Definition 22 (Sound/Complete oracles):
- Sound: accepts only checks that hold of .
- Complete: accepts every check that holds.
Theorem 23 (Safety from sound oracle): A sound oracle makes the selection safe regardless of pool quality: and .
Theorem 24 (Tightness from complete oracle): Completeness yields exactly the tight frontiers.
Theorem 29 (Exact recovery under coverage): Under disjunctive/conjunctive coverage (Definition 28), the search recovers the intent exactly.
Empirical Validation / Results
Expert-Adjudicated Study (20 non-zero-entropy cases)
The study used 64 established NL properties for 20 AWS resource types. Results:
| Quantity | Count | Fraction |
|---|---|---|
| Properties | 64 | — |
| Zero entropy (single eq class) | 44 | 68.8% |
| Non-zero entropy (the benchmark) | 20 | 31.2% |
| MV: safe, matches reference | 8 | 40% |
| MV: safe but conservative | 7 | 35% |
| MV: unsafe (admits a violation) | 5 | 25% |
| USC: safe, matches reference | 10 | 50% |
| USC: safe but conservative | 8 | 40% |
| USC: unsafe | 2 | 10% |
| EG (ours): safe, matches reference | 18 | 90% |
| EG (ours): safe but conservative | 2 | 10% |
| EG (ours): unsafe | 0 | 0% |
| Ablation (flat filter): safe, matches | 6 | 30% |
| Ablation: safe but conservative | 3 | 15% |
| Ablation: unsafe | 5 | 25% |
| Ablation: rejects every candidate | 6 | 30% |
Scale Study (152 non-zero-entropy statements)
- MV selects a candidate weaker than the oracle certified: 23.7% of statements
- USC: 22.4%
- EG: safe on at least 149/152 (98.0%) (counting 10 pools with no sufficient candidate as abstentions)
Oracle Soundness Measurement
Of 30 accepted checks on the 20 cases, the solver decided 23: 22 hold, 1 is wrong, 7 undecided (informal facts). The one wrong check did not affect EG's selection.
Case Study: API Gateway Logging
The statement "All methods in Amazon API Gateway stage has logging enabled" yielded 10 candidates in 4 clusters. The ambiguity residue was:
This identifies the ambiguity precisely: should a stage with no configured methods be compliant? EG selected the safe strong reading , while MV chose the weaker (unsafe) .
Theoretical and Practical Implications
Theoretical Significance
-
One-sided guarantees: The framework formalizes the insight that verification-oriented adequacy is directional—sufficiency for enforcement, necessity for reliance. This aligns with contract-based design and weakest-precondition/strongest-postcondition calculi.
-
Error asymmetry: Only a wrongly accepted oracle check can cost safety; wrongly rejected checks merely cost tightness. This one-sidedness is a direct consequence of the adjoint structure.
-
Pool independence: Safety holds regardless of candidate pool quality—a poor pool yields slack frontiers, never unsafe ones. This separates EGs from statistical selection methods whose guarantees depend on pool quality.
-
Machine-checked proofs: All results are verified in Lean 4 over an arbitrary Boolean algebra, providing formal assurance beyond the paper's prose.
Practical Implications
-
Security-critical verification: For AWS cloud safety properties, EGs provide the first autoformalization method with certified safety guarantees, crucial for pre-deployment verification.
-
Neuro-symbolic division of labor: The framework minimizes what the LLM must judge—each decision is a local, inspectable entailment check between two candidates, not a global judgment about a formula and a sentence.
-
Actionable ambiguity: Unlike scalar uncertainty scores (e.g., semantic entropy), the ambiguity residue is a formula that names exactly what remains ambiguous, pointing directly to the clarifying question needed.
-
Conservative defaults: Oracle uncertainty (no strict majority) makes results more conservative, trading tightness for safety.
Conclusion
Main takeaways:
-
Entailment Graphs order LLM candidate formalizations by logical strength, enabling two directional searches that return the weakest sufficient and strongest necessary candidates—bracketing the statement's meaning.
-
A sound entailment oracle suffices for safety; completeness buys only tightness. The only way safety can fail is a wrongly accepted edge check.
-
The ambiguity residue is a formula that precisely characterizes what remains undetermined, and its unsatisfiability certifies contextual disambiguation.
-
On AWS safety properties, EG selection is safe in all 20 expert-adjudicated cases, where baselines are unsafe in 10–25%. The graph structure—not access to an entailment oracle—delivers the guarantee.
Future directions:
- Extending EGs to contract refinement (contravariant assumptions, covariant guarantees)
- Using the ambiguity residue to seed clarification questions (implemented in parallel work by Barnaby et al.)
- Generating more candidates guided by the residue to reduce ambiguity
- Applying EGs to other domains with solver-decidable entailment relations
Related papers
- Self-Improvement Memory Enables Continual Recursive Self-Improvement
Self-Improvement Memory, which records harness edit rationale and outcomes, enables continual recursive self-improvement to outperform harness-only transfer by 2.36 points across changed benchmarks and models.
- CoT-Proxy: Cross-Format Transfer for Distilling Long-Horizon Policies
Distilling a long-horizon policy from teacher actions alone, without chain-of-thought, transfers successfully via an empty reasoning block plus KL replay regularization, enabling closed-teacher distillation.
- FlyingStart: Learned Cross-Token Warm Starts for Fixed-Point Decoding in Recurrent-Depth Language Models
FlyingStart learns a linear warm-start map for recurrent-depth language models, cutting decoding layers by 14–19% while matching accuracy and preserving the exit rule's safety certificate.