Zhidaily AI · Intelligence · Daily
Zhidaily
Issue 13 · November 12, 2026 · Thu
Today's stories
14 stories · 11 companies
Home / November 12, 2026 / AWS researchers use anti-unification to build semantic diffs for formal policies
← Back
Guide Official Safety · Amazon·AWS Score78

AWS researchers use anti-unification to build semantic diffs for formal policies

In brief
AWS authors propose using anti-unification on e-graphs to compare formal policies by meaning, and have open-sourced the engine. It lays out where several LLM-generated candidate policies agree and differ, so reviewers can look first at the parts that actually change behaviour.
AWS Machine Learning Blog aws.amazon.com
Nov 12 · 07:33 Read the original ↗
01Summary

Code review starts with a diff, but text diffs of formal policies are often drowned in meaningless syntax differences: two conditions swapped, the sides of an equation exchanged, external written as not internal. The file looks heavily changed while the meaning is unchanged, and the genuinely dangerous edits, such as writing "or" where "and" was required, hide in the noise. The authors set out to fix this by comparing policies at the semantic level rather than character by character.

02Background

Code review starts with a diff, but text diffs of formal policies are often drowned in meaningless syntax differences: two conditions swapped, the sides of an equation exchanged, external written as not internal. The file looks heavily changed while the meaning is unchanged, and the genuinely dangerous edits, such as writing "or" where "and" was required, hide in the noise. The authors set out to fix this by comparing policies at the semantic level rather than character by character.

03Approach

The core idea is anti-unification: given two expressions, find their most specific common pattern, write the shared parts once, and keep the differing parts side by side as variants. The engine runs on an e-graph, a structure that records which expressions have been judged equal. The authors first declare algebraic laws and domain rules, such as treating external and not internal as equivalent and stating that And is associative, commutative and idempotent, and the engine absorbs differences that do not affect meaning. What remains is real disagreement. The most practical setting is autoformalisation: an LLM translates a natural-language requirement into an SMT-LIB, Cedar, Dogwood, OpenShell or CEL policy, and running the same requirement twice can produce two different versions with no ground truth. A semantic diff can show which parts are stable and which vary with sampling, so reviewers look at the latter first. The authors demonstrate with an example: two rules differ in condition order, write external as not internal, and reach different conclusions, yet the engine reports only two real problems. One writes "or" where "and" was required, which could let confidential objects be copied across accounts; the other is whether a threshold comparison uses strict less-than or less-than-or-equal, which sends the case exactly at the threshold down a different branch. After adding a domain rewrite stating that the approved regions are those two, the region difference merges into the common skeleton and the divergence score falls from 0.5862 to 0.4000. The whole program runs in 50–60 milliseconds on an M3 Pro. The authors also note limits: anti-unification alone cannot generalise connectives, so And against Or is split into two alignments, and when rules or search are incomplete, leftover differences may just be equivalences the engine did not find.

04Implications

The authors argue that review of formal policies should move from text diffs to semantic diffs: cluster equivalent candidates first, compare representatives, and hand recurring disagreements to verification, replay or human clarification. The engine is open-sourced under Apache-2.0 and includes a checkau command that can set an upper bound on result size as a CI regression gate.