Abstract
Meseguer and Roşu proposed rewriting logic semantics (RLS) as a programing language definitional framework that unifies operational and algebraic denotational semantics. RLS has already been used to define a series of didactic and real languages, but its benefits in connection with defining and reasoning about type systems have not been fully investigated. This paper shows how the same RLS style employed for giving formal definitions of languages can be used to define type systems. The same term-rewriting mechanism used to execute RLS language definitions can now be used to execute type systems, giving type checkers or type inferencers. The proposed approach is exemplified by defining the Hindley-Milner polymorphic type inferencer \(\mathcal{W}\) as a rewrite logic theory and using this definition to obtain a type inferencer by executing it in a rewriting logic engine. The inferencer obtained this way compares favorably with other definitions or implementations of \(\mathcal{W}\). The performance of the executable definition is within an order of magnitude of that of highly optimized implementations of type inferencers, such as that of OCaml.
Supported in part by NSF grants CCF-0448501, CNS-0509321 and CNS-0720512, by NASA contract NNL08AA23C, by the Microsoft/Intel funded Universal Parallel Computing Research Center at UIUC, and by several Microsoft gifts.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Meseguer, J., Roşu, G.: Rewriting logic semantics: From language specifications to formal analysis tools. In: Basin, D., Rusinowitch, M. (eds.) IJCAR 2004. LNCS, vol. 3097, pp. 1–44. Springer, Heidelberg (2004)
Meseguer, J., Roşu, G.: The rewriting logic semantics project. J. TCS 373(3), 213–237 (2007)
Roşu, G.: K: A rewrite-based framework for modular language design, semantics, analysis and implementation. Technical Report UIUCDCS-R-2006-2802, Computer Science Department, University of Illinois at Urbana-Champaign (2006)
Kuan, G., MacQueen, D., Findler, R.B.: A rewriting semantics for type inference. In: De Nicola, R. (ed.) ESOP 2007. LNCS, vol. 4421, pp. 426–440. Springer, Heidelberg (2007)
Felleisen, M., Hieb, R.: A revised report on the syntactic theories of sequential control and state. J. TCS 103(2), 235–271 (1992)
Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38–94 (1994)
Matthews, J., Findler, R.B., Flatt, M., Felleisen, M.: A visual environment for developing context-sensitive term rewriting systems. In: van Oostrom, V. (ed.) RTA 2004. LNCS, vol. 3091, pp. 301–311. Springer, Heidelberg (2004)
Milner, R.: A theory of type polymorphism in programming. J. Computer and System Sciences 17(3), 348–375 (1978)
Bravenboer, M., Kalleberg, K.T., Vermaas, R., Visser, E.: Stratego/XT Tutorial, Examples, and Reference Manual. Department of Information and Computing Sciences, Universiteit Utrecht (August 2005) (Draft)
Barendregt, H.: Introduction to generalized type systems. J. Functional Programming 1(2), 125–154 (1991)
Stehr, M.-O., Meseguer, J.: Pure type systems in rewriting logic: Specifying typed higher-order languages in a first-order logical framework. In: Owe, O., Krogdahl, S., Lyche, T. (eds.) From Object-Orientation to Formal Methods. LNCS, vol. 2635, pp. 334–375. Springer, Heidelberg (2004)
Barendregt, H.P., van Eekelen, M.C.J.D., Glauert, J.R.W., Kennaway, R., Plasmeijer, M.J., Sleep, M.R.: Term graph rewriting. In: de Bakker, J.W., Nijman, A.J., Treleaven, P.C. (eds.) PARLE 1987. LNCS, vol. 259, pp. 141–158. Springer, Heidelberg (1987)
Plump, D.: Term graph rewriting. In: Handbook of Graph Grammars and Computing by Graph Transformation, vol. 2. World Scientific, Singapore (1998)
Banach, R.: Simple type inference for term graph rewriting systems. In: Rusinowitch, M., Remy, J.-L. (eds.) CTRS 1992. LNCS, vol. 656, pp. 51–66. Springer, Heidelberg (1993)
Fogarty, S., Pasalic, E., Siek, J., Taha, W.: Concoqtion: Indexed types now! In: PEPM 2007, pp. 112–121. ACM, New York (2007)
Kamareddine, F., Klop, J.W.(eds.): Special Issue on Type Theory and Term Rewriting: A Collection of Papers. Journal of Logic and Computation 10(3). Oxford University Press, Oxford (2000)
Hünke, Y., de Moor, O.: Aiding dependent type checking with rewrite rules (2001) (unpublished), http://citeseer.ist.psu.edu/huencke01aiding.html
Mametjanov, A.: Types and program transformations. In: OOPSLA 2007 Companion, pp. 937–938. ACM, New York (2007)
Levin, M.Y., Pierce, B.C.: TinkerType: A language for playing with formal systems. J. Functional Programing 13(2), 295–316 (2003)
Lee, D.K., Crary, K., Harper, R.: Towards a mechanized metatheory of standard ML. In: POPL 2007, pp. 173–184. ACM, New York (2007)
Klein, G., Nipkow, T.: A machine-checked model for a Java-like language, virtual machine and compiler. TOPLAS 28(4), 619–695 (2006)
Sewell, P., Nardelli, F.Z., Owens, S., Peskine, G., Ridge, T., Sarkar, S., Strniša, R.: Ott: Effective tool support for the working semanticist. In: ICFP 2007: Proceedings of the 2007 ACM SIGPLAN international conference on Functional programming, pp. 1–12. ACM, New York (2007)
van den Brand, M., et al.: The ASF+SDF meta-environment: A component-based language development environment. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, p. 365. Springer, Heidelberg (2001)
Roşu, G.: K: A rewriting-based framework for computations—an informal guide. Technical Report UIUCDCS-R-2007-2926, University of Illinois at Urbana-Champaign (2007)
Meseguer, J.: Conditional rewriting logic as a unified model of concurrency. J. TCS 96(1), 73–155 (1992)
Clavel, M., Durán, F., Eker, S., Lincoln, P., Martí-Oliet, N., Meseguer, J., Quesada, J.F.: Maude: Specification and programming in rewriting logic. Theor. Comput. Sci. 285(2), 187–243 (2002)
Plotkin, G.D.: A structural approach to operational semantics. Journal of Logic and Algebraic Programming 60-61, 17–139 (2004)
Gurevich, Y.: Evolving algebras 1993: Lipari guide. In: Specification and validation methods, pp. 9–36. Oxford University Press Inc., New York (1995)
Strachey, C., Wadsworth, C.P.: Continuations: A mathematical semantics for handling full jumps. Higher-Order and Symb. Computation 13(1/2), 135–152 (2000)
Martelli, A., Montanari, U.: An efficient unification algorithm. ACM Trans. Program. Lang. Syst. 4(2), 258–282 (1982)
Roşu, G.: K-style Maude definition of the W type inferencer (2007), http://fsl.cs.uiuc.edu/index.php/Special:WOnline
Kothari, S., Caldwell, J.: Algorithm W for lambda calculus extended with Milner-let Implementation used for Type Reconstruction Algorithms—A Survey. Technical Report, University of Wyoming (2007)
Li, Z.: Enhtop: A patch for an enhanced OCaml toplevel (2007), http://www.pps.jussieu.fr/~li/software/index.html
Eker, S.: Fast matching in combinations of regular equational theories. In: WRLA 1996. ENTCS, vol. 4, pp. 90–109 (1996)
Ellison, C.: A rewriting logic approach to defining type systems. Master’s thesis, University of Illinois at Urbana-Champaign (2008), http://fsl.cs.uiuc.edu/pubs/ellison-2008-mastersthesis.pdf
Hosabettu, R., Srivas, M.K., Gopalakrishnan, G.: Decomposing the proof of correctness of pipelined microprocessors. In: Y. Vardi, M. (ed.) CAV 1998. LNCS, vol. 1427, pp. 122–134. Springer, Heidelberg (1998)
Kanade, A., Sanyal, A., Khedker, U.P.: A PVS based framework for validating compiler optimizations. In: SEFM 2006, pp. 108–117. IEEE Computer Society, Los Alamitos (2006)
Kanade, A., Sanyal, A., Khedker, U.P.: Structuring optimizing transformations and proving them sound. In: COCV 2006. ENTCS, vol. 176(3), pp. 79–95. Elsevier, Amsterdam (2007)
Aydemir, B.E., Bohannon, A., Fairbairn, M., Foster, J.N., Pierce, B.C., Sewell, P., Vytiniotis, D., Washburn, G., Weirich, S., Zdancewic, S.: Mechanized metatheory for the masses: The PoplMark challenge. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 50–65. Springer, Heidelberg (2005)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Ellison, C., Şerbănuţă, T.F., Roşu, G. (2009). A Rewriting Logic Approach to Type Inference. In: Corradini, A., Montanari, U. (eds) Recent Trends in Algebraic Development Techniques. WADT 2008. Lecture Notes in Computer Science, vol 5486. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03429-9_10
Download citation
DOI: https://doi.org/10.1007/978-3-642-03429-9_10
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-03428-2
Online ISBN: 978-3-642-03429-9
eBook Packages: Computer ScienceComputer Science (R0)