Efficient Type Matching [chapter]

Somesh Jha, Jens Palsberg, Tian Zhao, Fritz Henglein
2008 Automatic Program Development  
Palsberg and Zhao (2000) presented an O(n 2 ) time algorithm for matching two recursive types; that is, deciding type isomorphism under associative-commutative type constructors. In this paper, we present an O(n log n) algorithm for matching recursive types and an O(n) algorithm for matching nonrecursive types. The linear-time algorithm for nonrecursive types works without hashing or pointer arithmetic, by employing multiset discrimination due to Paige et al.. The O(n log n) algorithm for
more » ... ive types works by reducing the type matching problem to the problem of finding a size-stable partition of a graph, which has O(n log n) algorithms due to Cardon/Crochemore and Paige/Tarjan. The key to these algorithms is the use of a "modify-the-smaller-half" approach pioneered by Hopcroft and Ullman for DFA minimization. Our results may help improve systems, such as Polyspin and Mockingbird, that are designed to facilitate interoperability of software components. We also discuss possible applications of our algorithm to Java. Issues related to subtyping of recursive types are also discussed. c 2002 Jha, Palsberg, Zhao Henglein. Printed in Denmark. doc-tr.tex; 19/09/2002; 21:17; p.1 In the same way, the structures of the interfaces J 1 , J 2 are: J 1 = µβ.(float → β) × (float → J 2 ) J 2 = µη.(J 1 → int) × (η → float ).
doi:10.1007/978-1-4020-6585-9_15 fatcat:4tf33j7wunabnakylbcveieokq