Second- and Third-Order Matching via Explicit Substitutions FL ´ AVIO LEONARDO CAVALCANTI DE MOURA, Departamento de Ciˆ encia da Computa¸ c˜ ao, Universidade de Bras´ ılia, Bras´ ılia DF, Brasil. E-mail: flavio@cic.unb.br FAIROUZ KAMAREDDINE, School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh, Scotland. E-mail: fairouz@macs.hw.ac.uk MAURICIO AYALA-RINC ´ ON, Departamento de Matem´ atica, Universidade de Bras´ ılia, Bras´ ılia DF, Brasil. E-mail: ayala@unb.br Abstract The past few years have established the benefits of using explicit substitutions in the treatment of problems such as unification and matching related to higher-order automated deduction and the implementation of programming languages. Matching is a basic operation extensively used in computation and deduction. Second and third-order matching, in particular, provide an adequate environment for expressing pattern recognition and program transformation or simplification. We present a practical algorithm which solves a class of second-order matching problems in the language of the λσ-calculus of explicit substitutions. This class includes all the problems originated in the language of the simply typed λ-calculus. In addition, we show how Dowek’s third-order matching decision procedure can be adapted to the whole language of the simply typed λσ-calculus and as a consequence we get the decidability of third-(and consequently second-)order matching for the whole language of the simply typed λσ-calculus. Keywords : Higher-Order Unification, Higher-Order Matching, Explicit Substitutions. 1 Introduction Matching is a basic operation which is extensively used in the implementation of automated deduction and programming environments. The decidability of higher- order matching has been an open question for about thirty years [Hue75]. Progress has been made where second-, third- and fourth-order matching have been shown to be decidable [Hue75, Dow94, Pad00]. However, matching solutions are not necessarily unique and most general unifiers do not necessarily exist. Moreover, in [Loa03], the undecidability of fifth-order β-matching is given, but the proof does not deal with η-conversion. Despite all these developments, for the general higher orders case, it remains unknown whether matching is decidable. Calculi of explicit substitutions are refinements of the λ-calculus by internalising the substitution operation. This is done by extending the language of the λ-calculus and decomposing the substitution operation into smaller steps. By studying matching using explicit substitutions, we can ensure a more accurate theoretical description of 1 L. J. of the IGPL, Vol. 0 No. 0, pp. 1–28 0000 c Oxford University Press