Skip to main content

2015 | OriginalPaper | Buchkapitel

Pattern Matches in HOL:

A New Representation and Improved Code Generation

verfasst von : Thomas Tuerk, Magnus O. Myreen, Ramana Kumar

Erschienen in: Interactive Theorem Proving

Verlag: Springer International Publishing

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

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.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Fußnoten
2
Compare function CASEWISE in define.ml.
 
3
See patternMatchesSyntax.
 
4
See e. g. PMATCH_SIMP_ss or PMATCH_REMOVE_GUARDS_ss.
 
5
See PMATCH_LIFT_BOOL_ss.
 
6
See e. g. PMATCH_CASE_SPLIT_ss.
 
7
See COMPUTE_REDUNDANT_ROWS_INFO_OF_PMATCH and
PMATCH_IS_EXHAUSTIVE_CONSEQ_CONV.
 
8
See PMATCH_REMOVE_REDUNDANT_ss.
 
9
See /src/1/PmatchHeuristics.sig in the HOL4 sources.
 
10
See e. g. HOL4’s Description Manual Sect. 4.5.2 or Isabelle/HOL’s manual Defining Recursive Functions in Isabelle/HOL Sect. 10.1.
 
11
See PMATCH_IS_EXHAUSTIVE_CONSEQ_CONV.
 
12
See PMATCH_REMOVE_REDUNDANT_ss.
 
13
Our code generator renames variables. Here x has become v5, for example.
 
14
The exceptions are non-constructor patterns that are not part of a constructor family.
 
Literatur
3.
Zurück zum Zitat Krauss, A.: Partial recursive functions in higher-order logic. In: Furbach, U., Shankar, N. (eds.) IJCAR 2006. LNCS (LNAI), vol. 4130, pp. 589–603. Springer, Heidelberg (2006) CrossRef Krauss, A.: Partial recursive functions in higher-order logic. In: Furbach, U., Shankar, N. (eds.) IJCAR 2006. LNCS (LNAI), vol. 4130, pp. 589–603. Springer, Heidelberg (2006) CrossRef
5.
Zurück zum Zitat Kumar, R., Myreen, M.O., Norrish, M., Owens, S.: CakeML: a verified implementation of ML. In: Jagannathan, S., Sewell, P. (eds.) POPL, pp. 179–192. ACM (2014) Kumar, R., Myreen, M.O., Norrish, M., Owens, S.: CakeML: a verified implementation of ML. In: Jagannathan, S., Sewell, P. (eds.) POPL, pp. 179–192. ACM (2014)
6.
Zurück zum Zitat Maranget, L.: Compiling pattern matching to good decision trees, September 2008 Maranget, L.: Compiling pattern matching to good decision trees, September 2008
7.
Zurück zum Zitat Myreen, M.O., Owens, S.: Proof-producing translation of higher-order logic into pure and stateful ML. J. Funct. Program. 24(2–3), 284–315 (2014)MATHMathSciNetCrossRef Myreen, M.O., Owens, S.: Proof-producing translation of higher-order logic into pure and stateful ML. J. Funct. Program. 24(2–3), 284–315 (2014)MATHMathSciNetCrossRef
8.
Zurück zum Zitat Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998) CrossRef Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998) CrossRef
9.
Zurück zum Zitat Peyton Jones, S.L.: The Implementation of Functional Programming Languages (Prentice-Hall International Series in Computer Science). Prentice-Hall Inc., Upper Saddle River (1987) Peyton Jones, S.L.: The Implementation of Functional Programming Languages (Prentice-Hall International Series in Computer Science). Prentice-Hall Inc., Upper Saddle River (1987)
10.
Zurück zum Zitat Slind, K.: Function definition in higher-order logic. In: von Wright, J., Harrison, J., Grundy, J. (eds.) TPHOLs 1996. LNCS, vol. 1125, pp. 381–397. Springer, Heidelberg (1996) CrossRef Slind, K.: Function definition in higher-order logic. In: von Wright, J., Harrison, J., Grundy, J. (eds.) TPHOLs 1996. LNCS, vol. 1125, pp. 381–397. Springer, Heidelberg (1996) CrossRef
11.
Zurück zum Zitat Slind, K., Norrish, M.: A brief overview of HOL4. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 28–32. Springer, Heidelberg (2008) CrossRef Slind, K., Norrish, M.: A brief overview of HOL4. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 28–32. Springer, Heidelberg (2008) CrossRef
12.
Zurück zum Zitat Wadler, P.: Views: A way for pattern matching to cohabit with data abstraction. In: POPL, pp. 307–313. ACM (1987) Wadler, P.: Views: A way for pattern matching to cohabit with data abstraction. In: POPL, pp. 307–313. ACM (1987)
Metadaten
Titel
Pattern Matches in HOL:
verfasst von
Thomas Tuerk
Magnus O. Myreen
Ramana Kumar
Copyright-Jahr
2015
DOI
https://doi.org/10.1007/978-3-319-22102-1_30