An Empirical Study of Rational Tree Unification for miniKanren
Eridan Domoratskiy, Dmitrii Kosarev, Dmitry Boulytchev
TL;DR
This work addresses unification for rational trees in miniKanren by introducing a Martelli-style unifier based on equation systems and $\mu$-images, augmented with a minimization pass. The authors prove termination and unifier properties, implement the approach in OCanren, and evaluate it against standard benchmarks, including equirecursive type inference and quines. They also explore practical optimizations (attributed variables, variable comparing) and several occurs-check strategies, comparing against conventional unification. While the rational-tree unifier offers performance gains for recursive structures, overhead remains a barrier to a drop-in replacement, motivating future work on coinductive support and mixed rational/Herbrand tree scenarios.
Abstract
We present a study of unification for rational trees in the context of miniKanren. We give the definition of rational trees, specify the unification algorithm and prove some of its properties. We also introduce a number of heuristic optimizations and evaluate them for a number of relevant benchmarks. Finally we discuss the relations between rational and conventional unification algorithms and possible scenarios of their coexistence in the context of relational programming.
