Semantic diffing of formal policies with anti-unification
The article introduces an open‑source engine that computes semantic diffs of formal policies by using anti‑unification over an e‑graph to find the most specific common pattern between two expressions. By supplying algebraic laws and domain‑specific rules (e.g., equating external and internal destinations), the engine can highlight shared policy fragments and isolate differing parts, revealing true behavioral changes that textual diffs miss. This approach aids auto‑formalization pipelines where large language models generate multiple formalizations (e.g., SMT‑LIB, Cedar, Dogwood, OpenShell, CEL) and engineers need to pinpoint agreement and divergence. Ultimately, semantic diffs help reviewers focus on substantive policy differences, improving correctness and auditability.
⚡ Key Takeaways
- The engine uses anti‑unification (Plotkin’s 1970 formulation) on an e‑graph to compute semantic diffs.
- Engineers must provide the algebraic laws and domain rules that define expression equivalences for the engine.
- The method surfaces genuine policy changes (e.g., an Or vs. an And) that textual diffs can obscure, reducing false positives.
- It can be applied to formal artifacts such as SMT‑LIB, Cedar, Dogwood, OpenShell YAML policies, and CEL expressions.
- If the supplied rules are incomplete, remaining differences may reflect undiscovered equivalences rather than real mismatches.
🔧 Tools & Libraries
By automatically isolating meaningful policy differences, engineers can more efficiently validate LLM‑generated formalizations and ensure that security or compliance rules remain consistent across revisions.
✅ Practical Steps
- Apply the concepts from this article to your own system design.
Want the full story? Read the original article.
Read on AWS ML Blog ↗