Pattern matches in HOL: A new representation and improved code generation
Paper in proceedings, 2015

Pattern matching is ubiquitous in functional programming and also very useful for definitions in higher-order logic. However, it is not directly supported by higher-order logic. Therefore, the parsers of theorem provers like HOL4 and Isabelle/HOL contain a pattern-compilation algorithm. Internally, decision trees based on case constants are used. For non-trivial case expressions, there is a big discrepancy between the user’s view and the internal representation. This paper presents a new general-purpose representation for case expressions that mirrors the input syntax in the internal representation closely. Because of this close connection, the new representation is more intuitive and often much more compact. Complicated parsers and pretty printers are no longer required. Proofs can more closely follow the user’s intentions, and code generators can produce better code. Moreover, the new representation is more general than the currently used representation, supporting guards, patterns with multiple occurrences of the same bound variable, unbound variables, arithmetic expressions in patterns, and more. This work has been implemented in the HOL4 theorem prover and integrated into CakeML’s proof-producing code generator.

Author

Thomas Tuerk

Magnus Myreen

Chalmers, Computer Science and Engineering (Chalmers), Software Technology (Chalmers)

R. Kumar

University of Cambridge

Lecture Notes in Computer Science

0302-9743 (ISSN)

Vol. 9236 453-468

Areas of Advance

Information and Communication Technology

Subject Categories

Computer and Information Science

DOI

10.1007/978-3-319-22102-1_30

ISBN

978-3-319-22101-4