English

Hashing Modulo Alpha-Equivalence

Programming Languages 2021-05-07 v1 Data Structures and Algorithms

Abstract

In many applications one wants to identify identical subtrees of a program syntax tree. This identification should ideally be robust to alpha-renaming of the program, but no existing technique has been shown to achieve this with good efficiency (better than O(n2)\mathcal{O}(n^2) in expression size). We present a new, asymptotically efficient way to hash modulo alpha-equivalence. A key insight of our method is to use a weak (commutative) hash combiner at exactly one point in the construction, which admits an algorithm with O(n(logn)2)\mathcal{O}(n (\log n)^2) time complexity. We prove that the use of the commutative combiner nevertheless yields a strong hash with low collision probability. Numerical benchmarks attest to the asymptotic behaviour of the method.

Keywords

Cite

@article{arxiv.2105.02856,
  title  = {Hashing Modulo Alpha-Equivalence},
  author = {Krzysztof Maziarz and Tom Ellis and Alan Lawrence and Andrew Fitzgibbon and Simon Peyton Jones},
  journal= {arXiv preprint arXiv:2105.02856},
  year   = {2021}
}

Comments

Accepted for publication at the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation (PLDI 2021)

R2 v1 2026-06-24T01:51:07.634Z