- The problem we want to solve: - 〚x〛= __, 〚y〛= __, 〚z〛= __ ⊢ type constraints
--- # Unification vs. Anti-Unification | | Unification | Anti-Unification | |---|---|---| | Goal | Find a common instance | Find a common generalization | | Input | T₁, T₂ | T₁, T₂ | | Output | Substitution σ | Term G and substitutions σ₁, σ₂ | | Condition | σ(T₁) = σ(T₂) | σ₁(G) = T₁, σ₂(G) = T₂ | | Optimal result | Most General Unifier (MGU) | Least General Generalization (LGG) | **Unification example** - T₁ = Box(α), T₂ = Box(i32) - σ = {α ↦ i32} - Common instance: Box(i32) **Anti-unification example** - T₁ = Box(i32), T₂ = Box(bool) - G = Box(α) - σ₁ = {α ↦ i32}, σ₂ = {α ↦ bool} **Unification specializes; anti-unification generalizes.**