# Safe Autoformalization: Sufficiency and Necessity with Entailment Graphs

> Entailment graphs certify safe autoformalization by returning the weakest sufficient and strongest necessary candidates, guaranteeing safety from a sound oracle alone.

- **Source:** [arXiv](https://arxiv.org/abs/2611.31571)
- **Published:** 2026-11-28
- **Permalink:** https://picx.dev/p/2V2knq
- **Whiteboard:** https://picx.dev/p/2V2knq/image

## Summary

# 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 $u \models v$, the residual of $v$ w.r.t. $u$ is the *weakest* formula $\rho$ such that $v \wedge \rho \iff u$. Classically: $\rho = v \Rightarrow u$.
- **Co-residual** (left adjoint to disjunction): Given $u \models v$, the co-residual is the *strongest* formula $\delta$ such that $u \vee \delta \iff v$. Classically: $\delta = v \wedge \neg u$.

The key decompositions are:

$$u \iff v \wedge (v \Rightarrow u) \quad \text{(Lemma 3: Residual Decomposition)}$$

$$v \iff u \vee (v \wedge \neg u) \quad \text{(Lemma 5: Co-residual Decomposition)}$$

**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 $(u,v)$ exists when $u \models v$ and $v \not\models u$. The graph is transitively closed.

The graph is always **completed** with two synthetic vertices:
- $\bot$ (False): the unique strongest vertex (universal root)
- $\top$ (True): the unique weakest vertex (universal sink)

### Frontier Searches

**Sufficient-Frontier Search** (downward, Figure 3): Starting from $\{\bot\}$, weakens across edges while the co-residual check $(v \wedge \neg u) \wedge ctx \models s$ passes. Returns the weakest candidates entailing $s$ in context.

**Necessary-Frontier Search** (upward, Figure 4): Starting from $\{\top\}$, strengthens across edges while the residual check $s \wedge ctx \models (v \Rightarrow u)$ passes. Returns the strongest candidates entailed by $s \wedge ctx$.

**Key theorems**:
- **Theorem 7**: If $u \wedge ctx \models s$, then $v \wedge ctx \models s$ iff $(v \wedge \neg u) \wedge ctx \models s$.
- **Theorem 8**: If $s \wedge ctx \models v$, then $s \wedge ctx \models u$ iff $s \wedge ctx \models (v \Rightarrow u)$.
- **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 $\{w \mid w \wedge ctx \models s\}$ and $\{w \mid s \wedge ctx \models w\}$.

### Ambiguity Residue

**Definition 15**: $\text{Amb}(s; EG, ctx) = \varphi_{\uparrow} \wedge \neg\varphi_{\downarrow} \wedge ctx$, where $\varphi_{\downarrow} = \bigvee_{v \in F_{\downarrow}} v$ and $\varphi_{\uparrow} = \bigwedge_{u \in F_{\uparrow}} u$.

**Theorem 17 (Disambiguation Criterion)**: The residue is unsatisfiable iff $\varphi_{\uparrow} \wedge ctx \vdash \varphi_{\downarrow}$, which holds iff $\varphi_{\downarrow} \wedge ctx \iff s \wedge ctx \iff \varphi_{\uparrow} \wedge ctx$.

**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:

$$(v \wedge \neg u) \wedge \widetilde{ctx} \models \widetilde{s}, \quad \widetilde{s} \wedge \widetilde{ctx} \models (v \Rightarrow u)$$

**Definition 22 (Sound/Complete oracles)**:
- *Sound*: accepts only checks that hold of $(ctx, s)$.
- *Complete*: accepts every check that holds.

**Theorem 23 (Safety from sound oracle)**: A sound oracle makes the selection safe regardless of pool quality: $\varphi_{\downarrow} \wedge ctx \models s$ and $s \wedge ctx \models \varphi_{\uparrow}$.

**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:

$$\text{Amb} = \varphi_{\uparrow} \wedge \neg\varphi_{\downarrow} \wedge ctx = (\neg M \vee L) \wedge \neg(M \wedge L) \wedge ctx = \neg M \wedge ctx$$

This identifies the ambiguity precisely: should a stage with no configured methods be compliant? EG selected the safe strong reading $M \wedge L$, while MV chose the weaker (unsafe) $M \Rightarrow L$.

---

## Theoretical and Practical Implications

### Theoretical Significance

1. **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.

2. **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.

3. **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.

4. **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

1. **Security-critical verification**: For AWS cloud safety properties, EGs provide the first autoformalization method with certified safety guarantees, crucial for pre-deployment verification.

2. **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.

3. **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.

4. **Conservative defaults**: Oracle uncertainty (no strict majority) makes results more conservative, trading tightness for safety.

---

## Conclusion

**Main takeaways**:

1. 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.

2. A sound entailment oracle suffices for safety; completeness buys only tightness. The only way safety can fail is a wrongly accepted edge check.

3. The ambiguity residue is a formula that precisely characterizes what remains undetermined, and its unsatisfiability certifies contextual disambiguation.

4. 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

---

_Markdown view of https://picx.dev/p/2V2knq, served by PicX — AI-generated visual whiteboard summaries of research papers._
