# Unification of Hypergraph \(\lambda \)-Terms

## Abstract

We developed a technique for modeling formal systems involving name binding in a modeling language based on hypergraph rewriting. A hypergraph consists of graph nodes, edges with two endpoints and edges with multiple endpoints. The idea is that hypergraphs allow us to represent terms containing bindings and that our notion of a graph type keeps bound variables distinct throughout rewriting steps. We previously encoded the untyped \(\lambda \)-calculus and the evaluation and type checking of System \(F_\texttt {<:}\), but the encoding of System \(F_\texttt {<:}\) type inference requires a unification algorithm. We studied and successfully implemented a unification algorithm modulo \(\alpha \)-equivalence for hypergraphs representing untyped \(\lambda \)-terms. The unification algorithm turned out to be similar to nominal unification despite the fact that our approach and nominal approach to name binding are very different. However, some basic properties of our framework are easier to establish compared to the ones in nominal unification. We believe this indicates that hypergraphs provide a nice framework for encoding formal systems involving binders and unification modulo \(\alpha \)-equivalence.

## Notes

### Acknowledgement

The authors are indebted to anonymous referees for their useful comments and pointers to the literature. This work is partially supported by Grant-In-Aid for Scientific Research ((B)26280024), JSPS, Japan, and Waseda University Grant for Special Research Projects.

## References

- 1.Barendregt, H.: The Lambda Calculus: its Syntax and Semantics. Studies in Logic and the Foundations of Mathematics, vol. 103. North-Holland, Amsterdam (1984)Google Scholar
- 2.Cheney, J.: Relating higher-order pattern unification and nominal unification. In: Proceedings of the 19th International Workshop on Unification, UNIF 2005, pp. 104–119 (2005)Google Scholar
- 3.Cheney, J., Urban, C.: \(\alpha \)Prolog: a logic programming language with names, binding and \(alpha\)-equivalence. In: Demoen, B., Lifschitz, V. (eds.) ICLP 2004. LNCS, vol. 3132, pp. 269–283. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-27775-0_19 CrossRefGoogle Scholar
- 4.Gabbay, M.J., Pitts, A.M.: A new approach to abstract syntax with variable binding. Formal Aspects Comput.
**13**, 341–363 (2002)CrossRefzbMATHGoogle Scholar - 5.Huet, G.J.: A unification algorithm for typed \(\lambda \)-Calculus. Theoret. Comput. Sci.
**1**(1), 27–57 (1975)MathSciNetCrossRefzbMATHGoogle Scholar - 6.Levy, J., Villaret, M.: Nominal unification from a higher-order perspective. In: Voronkov, A. (ed.) RTA 2008. LNCS, vol. 5117, pp. 246–260. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-70590-1_17 CrossRefGoogle Scholar
- 7.Martelli, A., Montanari, U.: An efficient unification algorithm. ACM Trans. Program. Lang. Syst.
**4**(2), 258–282 (1982)CrossRefzbMATHGoogle Scholar - 8.Miller, D.: A logic programming language with lambda-abstraction, function variables, and simple unification. J. Logic Comput.
**1**, 497–536 (1991)MathSciNetCrossRefzbMATHGoogle Scholar - 9.Pfenning, F., Elliott, C.: Higher-order abstract syntax. In: Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 199–208 (1988)Google Scholar
- 10.Qi, X.: An Implementation of the Language Lambda Prolog Organized around Higher-Order Pattern Unification. Ph.D. thesis, University of Minnesota (2009)Google Scholar
- 11.Robinson, J.A.: A machine-oriented logic based on the resolution principle. J. ACM
**12**(1), 23–41 (1965)MathSciNetCrossRefzbMATHGoogle Scholar - 12.Ueda, K.: Encoding the pure lambda calculus into hierarchical graph rewriting. In: Voronkov, A. (ed.) RTA 2008. LNCS, vol. 5117, pp. 392–408. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-70590-1_27 CrossRefGoogle Scholar
- 13.Ueda, K., Ogawa, S.: HyperLMNtal: an extension of a hierarchical graph rewriting model. Küstliche Intelligenz
**26**(1), 27–36 (2012)CrossRefGoogle Scholar - 14.Urban, C., Pitts, A.M., Gabbay, M.J.: Nominal unification. J. Theor. Comput. Sci.
**323**(1–3), 473–497 (2004)MathSciNetCrossRefzbMATHGoogle Scholar - 15.Urban, C.: Nominal unification revisited. In: Proceedings of the 24th International Workshop on Unification, UNIF 2010, pp. 1–11 (2010)Google Scholar
- 16.Yasen, A., Ueda, K.: Hypergraph representation of lambda-terms. In: Proceedings of 10th International Symposium on Theoretical Aspects of Software Engineering, pp. 113–116 (2016)Google Scholar
- 17.Yasen, A., Ueda, K.: Name Binding is Easy with Hypergraphs. submittedGoogle Scholar
- 18.Qian, Z.: Linear unification of higher-order patterns. In: Gaudel, M.-C., Jouannaud, J.-P. (eds.) CAAP 1993. LNCS, vol. 668, pp. 391–405. Springer, Heidelberg (1993). https://doi.org/10.1007/3-540-56610-4_78 CrossRefGoogle Scholar
- 19.Bourbaki, N.: Théorie des ensembless, Hermann (1970)Google Scholar
- 20.Mackie, I.: Efficient \(\lambda \)-evaluation with interaction nets. In: van Oostrom, V. (ed.) RTA 2004. LNCS, vol. 3091, pp. 155–169. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-25979-4_11 CrossRefGoogle Scholar