Skip to main content

2017 | OriginalPaper | Buchkapitel

The Negligible and Yet Subtle Cost of Pattern Matching

verfasst von : Beniamino Accattoli, Bruno Barras

Erschienen in: Programming Languages and Systems

Verlag: Springer International Publishing

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

search-config
loading …

Abstract

The model behind functional programming languages is the closed \(\lambda \) -calculus, that is, the fragment of the \(\lambda \)-calculus where evaluation is weak (i.e. out of abstractions) and terms are closed. It is well-known that the number of \(\beta \) (i.e. evaluation) steps is a reasonable cost model in this setting, for all natural evaluation strategies (call-by-name/value/need). In this paper we try to close the gap between the closed \(\lambda \)-calculus and actual languages, by considering an extension of the \(\lambda \)-calculus with pattern matching. It is straightforward to prove that \(\beta \) plus matching steps provide a reasonable cost model. What we do then is finer: we show that \(\beta \) steps only, without matching steps, provide a reasonable cost model also in this extended setting—morally, pattern matching comes for free, complexity-wise. The result is proven for all evaluation strategies (name/value/need), and, while the proof itself is simple, the problem is shown to be subtle. In particular we show that qualitatively equivalent definitions of call-by-need may behave very differently.

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
1
The kernel of Coq is the subset of the codebase which ensures that only valid proofs are accepted. Hence the use of an abstract machine, which has a better ratio efficiency/complexity than the use of a compiler or a naive interpreter.
 
2
We do not prove the equivalence between the two formulations of CbNeed studied in the paper, but the difference is essentially that in one case \(\mathtt{c}(\varvec{t})\) is reduced to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-71237-6_21/460753_1_En_21_IEq378_HTML.gif (via \(\rightarrow _{\mathtt{cstr}}\)) while in the other case it is left unchanged—the two calculi compute the same result, up to substitutions, just with very different complexities.
 
Literatur
1.
2.
Zurück zum Zitat Accattoli, B.: An abstract factorization theorem for explicit substitutions. In: RTA, pp. 6–21 (2012) Accattoli, B.: An abstract factorization theorem for explicit substitutions. In: RTA, pp. 6–21 (2012)
4.
Zurück zum Zitat Accattoli, B.: The complexity of abstract machines. In: WPTE@FSCD 2016, pp. 1–15 (2016) Accattoli, B.: The complexity of abstract machines. In: WPTE@FSCD 2016, pp. 1–15 (2016)
6.
Zurück zum Zitat Accattoli, B., Barenbaum, P., Mazza, D.: Distilling abstract machines. In: ICFP 2014, pp. 363–376. ACM (2014) Accattoli, B., Barenbaum, P., Mazza, D.: Distilling abstract machines. In: ICFP 2014, pp. 363–376. ACM (2014)
7.
Zurück zum Zitat Accattoli, B., Barras, B.: Environments and the complexity of abstract machines (2017). Accepted to PPDP 2017 Accattoli, B., Barras, B.: Environments and the complexity of abstract machines (2017). Accepted to PPDP 2017
8.
Zurück zum Zitat Accattoli, B., Bonelli, E., Kesner, D., Lombardi, C.: A nonstandard standardization theorem. In: POPL, pp. 659–670 (2014) Accattoli, B., Bonelli, E., Kesner, D., Lombardi, C.: A nonstandard standardization theorem. In: POPL, pp. 659–670 (2014)
9.
Zurück zum Zitat Accattoli, B., Coen, C.S.: On the relative usefulness of fireballs. In: LICS 2015, pp. 141–155. IEEE Computer Society (2015) Accattoli, B., Coen, C.S.: On the relative usefulness of fireballs. In: LICS 2015, pp. 141–155. IEEE Computer Society (2015)
10.
Zurück zum Zitat Accattoli, B., Dal Lago, U.: (Leftmost-outermost) beta reduction is invariant, indeed. Logical Methods Comput. Sci. 12(1), 1–46 (2016)MathSciNetCrossRefMATH Accattoli, B., Dal Lago, U.: (Leftmost-outermost) beta reduction is invariant, indeed. Logical Methods Comput. Sci. 12(1), 1–46 (2016)MathSciNetCrossRefMATH
16.
Zurück zum Zitat Barras, B.: Auto-validation d’un système de preuves avec familles inductives. Ph.D. thesis, Université Paris 7 (1999) Barras, B.: Auto-validation d’un système de preuves avec familles inductives. Ph.D. thesis, Université Paris 7 (1999)
17.
Zurück zum Zitat Blelloch, G.E., Greiner, J.: Parallelism in sequential functional languages. In: FPCA 1995, pp. 226–237. ACM (1995) Blelloch, G.E., Greiner, J.: Parallelism in sequential functional languages. In: FPCA 1995, pp. 226–237. ACM (1995)
18.
23.
Zurück zum Zitat Danvy, O., Zerny, I.: A synthetic operational account of call-by-need evaluation. In: PPDP 2013, pp. 97–108. ACM (2013) Danvy, O., Zerny, I.: A synthetic operational account of call-by-need evaluation. In: PPDP 2013, pp. 97–108. ACM (2013)
24.
Zurück zum Zitat Fernández, M., Siafakas, N.: New developments in environment machines. Electr. Notes Theor. Comput. Sci. 237, 57–73 (2009)CrossRefMATH Fernández, M., Siafakas, N.: New developments in environment machines. Electr. Notes Theor. Comput. Sci. 237, 57–73 (2009)CrossRefMATH
25.
Zurück zum Zitat Grégoire, B., Leroy, X.: A compiled implementation of strong reduction. In: ICFP 2002, pp. 235–246. ACM (2002) Grégoire, B., Leroy, X.: A compiled implementation of strong reduction. In: ICFP 2002, pp. 235–246. ACM (2002)
27.
Zurück zum Zitat Jeannin, J., Kozen, D.: Computing with capsules. J. Automata Lang. Comb. 17(2–4), 185–204 (2012)MathSciNetMATH Jeannin, J., Kozen, D.: Computing with capsules. J. Automata Lang. Comb. 17(2–4), 185–204 (2012)MathSciNetMATH
29.
30.
Zurück zum Zitat Launchbury, J.: A natural semantics for lazy evaluation. In: POPL 1993, pp. 144–154. ACM Press (1993) Launchbury, J.: A natural semantics for lazy evaluation. In: POPL 1993, pp. 144–154. ACM Press (1993)
31.
32.
Zurück zum Zitat Milner, R.: Local bigraphs and confluence: two conjectures. Electr. Notes Theor. Comput. Sci. 175(3), 65–73 (2007)CrossRefMATH Milner, R.: Local bigraphs and confluence: two conjectures. Electr. Notes Theor. Comput. Sci. 175(3), 65–73 (2007)CrossRefMATH
33.
Zurück zum Zitat Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)MATH Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)MATH
35.
Zurück zum Zitat Sergey, I., Vytiniotis, D., Peyton Jones, S.L.: Modular, higher-order cardinality analysis in theory and practice. In: POPL 2014, pp. 335–348 (2014) Sergey, I., Vytiniotis, D., Peyton Jones, S.L.: Modular, higher-order cardinality analysis in theory and practice. In: POPL 2014, pp. 335–348 (2014)
37.
Zurück zum Zitat Wadsworth, C.P.: Semantics and pragmatics of the lambda-calculus. Ph.D. thesis, Oxford (1971). Chapter 4 Wadsworth, C.P.: Semantics and pragmatics of the lambda-calculus. Ph.D. thesis, Oxford (1971). Chapter 4
38.
Zurück zum Zitat Walker, D.: Substructural type systems. In: Pierce, B.C. (ed.) Advanced Topics in Types and Programming Languages, pp. 3–43. The MIT Press (2004) Walker, D.: Substructural type systems. In: Pierce, B.C. (ed.) Advanced Topics in Types and Programming Languages, pp. 3–43. The MIT Press (2004)
Metadaten
Titel
The Negligible and Yet Subtle Cost of Pattern Matching
verfasst von
Beniamino Accattoli
Bruno Barras
Copyright-Jahr
2017
DOI
https://doi.org/10.1007/978-3-319-71237-6_21

Premium Partner