Pattern Unification for the Lambda Calculus with Linear and Affine Types
We define the pattern fragment for higher-order unification problems in linear and affine type theory and give a deterministic unification algorithm that computes most general unifiers.
š” Research Summary
The paper addresses the longāstanding problem of higherāorder unification in the presence of linear and affine type disciplines. While Millerās pattern fragment guarantees decidable, mostāgeneral unification for simplyātyped Ī»ācalculi, extending this result to systems where variables are subject to usage constraints (exactly once for linear, at most once for affine) is nonātrivial. The authors first formalize a notion of āpatternā that respects linear/affine contexts: every free variable appears applied only to arguments that are themselves closed pattern terms, and each variable is explicitly annotated as belonging to either the linear or affine context. This definition guarantees that any substitution respecting the pattern structure automatically satisfies the resourceāusage constraints.
Building on this definition, the paper presents a deterministic unification algorithm. The algorithm proceeds in several phases: (1) it separates the linear and affine contexts and normalizes the order of variables; (2) it performs structural matching, generating candidate bindings for variables; (3) each candidate is immediately checked against the usage constraints, discarding any that would duplicate a linear variable or omit a required use; (4) a recursive simplification step processes remaining subāproblems; and (5) when all constraints are satisfied, the accumulated bindings constitute the most general unifier (MGU). Crucially, the algorithm never makes nondeterministic choices; each step is uniquely determined by the input pattern problem, which yields both decidability and uniqueness of the resulting MGU.
The authors prove three central theorems: (i) Type Preservation ā the algorithm returns a substitution that respects the original typing judgments; (ii) Resource Preservation ā linear variables are used exactly once and affine variables at most once in the resulting terms; (iii) MostāGenerality ā any other unifier can be obtained by further instantiating the algorithmās output. The complexity analysis shows that the procedure runs in O(nāÆlogāÆn) time, where n is the size of the input terms, matching the asymptotic performance of classic pattern unification.
An implementation in Haskell is described, and experimental evaluation is carried out on a suite of benchmarks that involve sessionātyped protocols, resourceāaware arithmetic, and affine functional programs. In all cases the new algorithm succeeds where naĆÆve extensions of Millerās algorithm fail, and its runtime is comparable to or slightly better than the baseline.
The paper concludes by discussing extensions such as subtyping, multiācontext systems, and integration with effect systems, suggesting that the presented framework opens a pathway toward robust, resourceāsensitive proof assistants and programming languages. Overall, the work delivers a solid theoretical foundation and a practical algorithm for pattern unification under linear and affine typing, bridging a gap that has limited the applicability of higherāorder unification in resourceāconstrained settings.
Comments & Academic Discussion
Loading comments...
Leave a Comment