Skip to main content

2017 | Supplement | Buchkapitel

Effect Polymorphism in Higher-Order Logic (Proof Pearl)

verfasst von : Andreas Lochbihler

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

The notion of a monad cannot be expressed within higher-order logic (HOL) due to type system restrictions. We show that if a monad is used with values of only one type, this notion can be formalised in HOL. Based on this idea, we develop a library of effect specifications and implementations of monads and monad transformers. Hence, we can abstract over the concrete monad in HOL definitions and thus use the same definition for different (combinations of) effects. We illustrate the usefulness of effect polymorphism with a monadic interpreter.

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
Type variables that appear in the signature of locale parameters are fixed for the whole locale. In particular, the value type https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq37_HTML.gif cannot be instantiated inside the locale https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq38_HTML.gif or its extension https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq39_HTML.gif . The interpreter https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq40_HTML.gif , however, returns https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq41_HTML.gif s. For this reason, https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq42_HTML.gif is defined in an extension of https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq43_HTML.gif that merely specialises https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq44_HTML.gif . For readability, we usually omit this detail in this paper.
 
2
Such environments can be nicely handled by applying a reader monad transformer on top (Sect. 4).
 
3
Isabelle’s https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq328_HTML.gif feature, which resolves overloading during type checking, cannot be used either as it does not support recursive resolutions. For example, resolving https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq329_HTML.gif takes two steps: first to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq330_HTML.gif and then to https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq331_HTML.gif . The second step fails due to the intricate interleaving of type checking and resolution. Even if this is just an implementation issue, resolving overloading during type checking prevents definitions that are generic in the monad, which general overloading supports.
 
4
Following the “as abstract as possible” spirit of this paper, we actually proved the identities in the locale of commutative monads and showed that https://static-content.springer.com/image/chp%3A10.1007%2F978-3-319-66107-0_25/978-3-319-66107-0_25_IEq460_HTML.gif is commutative if its inner monad is.
 
Literatur
1.
Zurück zum Zitat Ballarin, C.: Locales: a module system for mathematical theories. J. Automat. Reason. 52(2), 123–153 (2014)MathSciNetCrossRef Ballarin, C.: Locales: a module system for mathematical theories. J. Automat. Reason. 52(2), 123–153 (2014)MathSciNetCrossRef
2.
Zurück zum Zitat Blanchette, J.C., Hölzl, J., Lochbihler, A., Panny, L., Popescu, A., Traytel, D.: Truly modular (co)datatypes for Isabelle/HOL. In: Klein, G., Gamboa, R. (eds.) ITP 2014. LNCS, vol. 8558, pp. 93–110. Springer, Cham (2014). doi:10.1007/978-3-319-08970-6_7CrossRef Blanchette, J.C., Hölzl, J., Lochbihler, A., Panny, L., Popescu, A., Traytel, D.: Truly modular (co)datatypes for Isabelle/HOL. In: Klein, G., Gamboa, R. (eds.) ITP 2014. LNCS, vol. 8558, pp. 93–110. Springer, Cham (2014). doi:10.​1007/​978-3-319-08970-6_​7CrossRef
3.
Zurück zum Zitat Bulwahn, L., Krauss, A., Haftmann, F., Erkök, L., Matthews, J.: Imperative functional programming with Isabelle/HOL. In: Ait Mohamed, O., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 134–149. Springer, Heidelberg (2008). doi:10.1007/978-3-540-71067-7_14CrossRef Bulwahn, L., Krauss, A., Haftmann, F., Erkök, L., Matthews, J.: Imperative functional programming with Isabelle/HOL. In: Ait Mohamed, O., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 134–149. Springer, Heidelberg (2008). doi:10.​1007/​978-3-540-71067-7_​14CrossRef
5.
Zurück zum Zitat Erwig, M., Kollmansberger, S.: Functional pearls: probabilistic functional programming in Haskell. J. Funct. Program. 16, 21–34 (2006)CrossRef Erwig, M., Kollmansberger, S.: Functional pearls: probabilistic functional programming in Haskell. J. Funct. Program. 16, 21–34 (2006)CrossRef
6.
Zurück zum Zitat Gibbons, J., Hinze, R.: Just do it: simple monadic equational reasoning. In: ICFP 2011, pp. 2–14. ACM (2011) Gibbons, J., Hinze, R.: Just do it: simple monadic equational reasoning. In: ICFP 2011, pp. 2–14. ACM (2011)
7.
9.
Zurück zum Zitat Huffman, B.: Formal verification of monad transformers. In: ICFP 2012, pp. 15–16. ACM (2012) Huffman, B.: Formal verification of monad transformers. In: ICFP 2012, pp. 15–16. ACM (2012)
10.
11.
Zurück zum Zitat Huffman, B., Matthews, J., White, P.: Axiomatic constructor classes in Isabelle/HOLCF. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 147–162. Springer, Heidelberg (2005). doi:10.1007/11541868_10CrossRefMATH Huffman, B., Matthews, J., White, P.: Axiomatic constructor classes in Isabelle/HOLCF. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 147–162. Springer, Heidelberg (2005). doi:10.​1007/​11541868_​10CrossRefMATH
12.
Zurück zum Zitat Jeuring, J., Jansson, P., Amaral, C.: Testing type class laws. In: Haskell 2012, pp. 49–60. ACM (2012) Jeuring, J., Jansson, P., Amaral, C.: Testing type class laws. In: Haskell 2012, pp. 49–60. ACM (2012)
13.
Zurück zum Zitat Kunčar, O.: Correctness of Isabelle’s cyclicity checker: implementability of overloading in proof assistants. In: CPP 2015, pp. 85–94. ACM (2015) Kunčar, O.: Correctness of Isabelle’s cyclicity checker: implementability of overloading in proof assistants. In: CPP 2015, pp. 85–94. ACM (2015)
14.
Zurück zum Zitat Lammich, P., Tuerk, T.: Applying data refinement for monadic programs to Hopcroft’s algorithm. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 166–182. Springer, Heidelberg (2012). doi:10.1007/978-3-642-32347-8_12CrossRef Lammich, P., Tuerk, T.: Applying data refinement for monadic programs to Hopcroft’s algorithm. In: Beringer, L., Felty, A. (eds.) ITP 2012. LNCS, vol. 7406, pp. 166–182. Springer, Heidelberg (2012). doi:10.​1007/​978-3-642-32347-8_​12CrossRef
15.
Zurück zum Zitat Liang, S., Hudak, P., Jones, M.: Monad transformers and modular interpreters. In: POPL 1995, pp. 333–343. ACM (1995) Liang, S., Hudak, P., Jones, M.: Monad transformers and modular interpreters. In: POPL 1995, pp. 333–343. ACM (1995)
19.
Zurück zum Zitat Lochbihler, A., Schneider, J.: Equational reasoning with applicative functors. In: Blanchette, J.C., Merz, S. (eds.) ITP 2016. LNCS, vol. 9807, pp. 252–273. Springer, Cham (2016). doi:10.1007/978-3-319-43144-4_16 Lochbihler, A., Schneider, J.: Equational reasoning with applicative functors. In: Blanchette, J.C., Merz, S. (eds.) ITP 2016. LNCS, vol. 9807, pp. 252–273. Springer, Cham (2016). doi:10.​1007/​978-3-319-43144-4_​16
20.
Zurück zum Zitat Mitchell, J.C.: Representation independence and data abstraction. In: POPL 1986, pp. 263–276. ACM (1986) Mitchell, J.C.: Representation independence and data abstraction. In: POPL 1986, pp. 263–276. ACM (1986)
21.
Zurück zum Zitat Moggi, E.: An abstract view of programming languages. Technical report ECS-LFCS-90-113, LFCS, School of Informatics, University of Edinburgh (1990) Moggi, E.: An abstract view of programming languages. Technical report ECS-LFCS-90-113, LFCS, School of Informatics, University of Edinburgh (1990)
23.
Zurück zum Zitat Nipkow, T., Paulson, L.C.: Proof pearl: defining functions over finite sets. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 385–396. Springer, Heidelberg (2005). doi:10.1007/11541868_25CrossRef Nipkow, T., Paulson, L.C.: Proof pearl: defining functions over finite sets. In: Hurd, J., Melham, T. (eds.) TPHOLs 2005. LNCS, vol. 3603, pp. 385–396. Springer, Heidelberg (2005). doi:10.​1007/​11541868_​25CrossRef
24.
Zurück zum Zitat Ramsey, N., Pfeffer, A.: Stochastic lambda calculus and monads of probability distributions. In: POPL 2002, pp. 154–165. ACM (2002) Ramsey, N., Pfeffer, A.: Stochastic lambda calculus and monads of probability distributions. In: POPL 2002, pp. 154–165. ACM (2002)
26.
Zurück zum Zitat Wenzel, M.: Type classes and overloading in higher-order logic. In: Gunter, E.L., Felty, A. (eds.) TPHOLs 1997. LNCS, vol. 1275, pp. 307–322. Springer, Heidelberg (1997). doi:10.1007/BFb0028402CrossRef Wenzel, M.: Type classes and overloading in higher-order logic. In: Gunter, E.L., Felty, A. (eds.) TPHOLs 1997. LNCS, vol. 1275, pp. 307–322. Springer, Heidelberg (1997). doi:10.​1007/​BFb0028402CrossRef
Metadaten
Titel
Effect Polymorphism in Higher-Order Logic (Proof Pearl)
verfasst von
Andreas Lochbihler
Copyright-Jahr
2017
Verlag
Springer International Publishing
DOI
https://doi.org/10.1007/978-3-319-66107-0_25

Premium Partner