Technology1 min read

Semantic diffing of formal policies with anti-unification

By · Published by Everything Blog

In short

The diffing engine processes specifications encoded as terms paired with declared equalities rather than reading native file formats directly. It isolates genuine behavioral conflicts across multiple LLM runs and displays shared logic just once. While standard satisfiability modulo theories solvers highlight disagreements using concrete counterexamples, this method structures conflicting fragments directly without issuing SMT queries. This capability aids autoformalization targets ranging from Cedar to SMT-LIB and Common Expression Language.

Key points

  • Semantic diffing assists autoformalization by exposing genuine conflicts among varied lar…: Semantic diffing assists autoformalization by exposing genuine conflicts among varied large language model outputs.
  • The engine functions as a formal-methods analogue to semantic entropy while preserving ex…: The engine functions as a formal-methods analogue to semantic entropy while preserving exact structural divergence points.
  • Comparing policies through an e-graph guarantees that completely resolved differences pro…: Comparing policies through an e-graph guarantees that completely resolved differences prove full semantic equivalence.

Sources checked by our analysis pipeline: 1

Artificial Intelligence

Semantic diffing of formal policies with anti-unification

When reviewing code, you start with a diff. You wouldn’t compare two 3,000-line files by eye and hope to spot every change. Formal policies can be even harder to compare because a textual diff often highlights syntactic changes that don’t affect meaning. Reorder two conjuncts, swap the arguments of an equality, or use an equivalent predicate, and much of the file might appear changed. A real change in behavior, such as an Or

where the requirement says and, can get lost in that noise.

A semantic diff shows what two policies have in common and where they disagree. The open source engine used in this post computes this diff using anti-unification, which finds a most specific common pattern for two expressions. Plotkin’s 1970 paper gives the classical formulation. The engine works over an e-graph, which keeps track of expressions known to be equal. We supply the algebraic laws and domain rules that justify those equalities, such as equating an external destination with one that isn’t internal. The result shows the shared…

Technology