Abstract
This paper presents PFLP, a library for probabilistic programming in the functional logic programming language Curry. It demonstrates how the concepts of a functional logic programming language support the implementation of a library for probabilistic programming. In fact, the paradigms of functional logic and probabilistic programming are closely connected. That is, we can apply techniques from one area to the other and vice versa. We will see that an implementation based on the concepts of functional logic programming can have benefits with respect to performance compared to a standard list-based implementation.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
We provide the code for the library at https://github.com/finnteegen/pflp.
- 2.
We use version 0.6.0 of KiCS2 and the source is found at https://www-ps.informatik.uni-kiel.de/kics2/.
- 3.
Here and in the following we write probabilities as fractions for readability.
- 4.
We visualize the interactions with the REPL using \(\lambda \mathbin {>}\) as prompt.
- 5.
We shorten the implementation of \( enum \) for presentation purposes; actually, \( enum \) only allows valid distributions, e.g., that the given probabilities add up to \(\mathrm {1.0}\).
- 6.
Due to the lack of overloading in Curry, operations on \( Float \) have a (floating) point suffix, e.g. \((\mathbin {*.})\), whereas operations on \( Int \) use the common operation names.
- 7.
We use an abstract view of the result of an encapsulation to emphasize that the order of encapsulated results does not matter. In practice, we can, for example, use the function \( allValues \mathbin {{:}{:}} a \rightarrow [ a ]\) defined in the library \( Findall \).
- 8.
All benchmarks were executed on a Linux machine with an Intel Core i7-6500U (2.50 GHz) and 8 GiB RAM running Fedora 25. We used the Glasgow Haskell Compiler (version 8.0.2, option -O2) and set the search strategy in KiCS2 to depth-first.
- 9.
Non-determinism causes significant overhead for KiCS2, thus, “Curry ND” does not show linear development, but we measured a linear running time using PAKCS [14].
References
Antoy, S.: Evaluation strategies for functional logic programming. J. Symbolic Comput. 40(1), 875–903 (2005)
Antoy, S., Hanus, M.: Functional logic programming. Commun. ACM 53(4), 74–85 (2010)
Braßel, B.: A technique to build debugging tools for lazy functional logic languages. Electron. Notes Theoret. Comput. Sci. 246, 39–53 (2009)
Braßel, B., Hanus, M., Huch, F.: Encapsulating non-determinism in functional logic computations. J. Funct. Logic Program. 2004 (2004)
Braßel, B., Hanus, M., Peemöller, B., Reck, F.: KiCS2: a new compiler from Curry to Haskell. In: Kuchen, H. (ed.) WFLP 2011. LNCS, vol. 6816, pp. 1–18. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22531-4_1
Christiansen, J., Fischer, S.: EasyCheck - test data for free. In: Proceedings of the International Symposium on Functional and Logic Programming (2008)
Christiansen, J., Seidel, D., Voigtländer, J.: Free theorems for functional logic programs. In: Proceedigns of the Workshop on Programming Languages Meets Program Verification (2010)
De Raedt, L., Kimmig, A.: Probabilistic Programming Concepts. arXiv:1312.4328 (preprint) (2013)
De Raedt, L., Kimmig, A., Toivonen, H.: ProbLog: a probabilistic prolog and its application in link discovery. In: Proceedings of the International Joint Conference on Artifical Intelligence (2007)
Erwig, M., Kollmansberger, S.: Functional pearls: probabilistic functional programming in Haskell. J. Funct. Program. 16(1), 21–34 (2006)
Fischer, S., Kiselyov, O., Shan, C.: Purely functional lazy non-deterministic programming. In: Proceedings of the International Conference on Functional Programming (2009)
Goodman, N.D., Mansinghka, V.K., Roy, D.M., Bonawitz, K., Tenenbaum, J.B.: Church: A Language for Generative Models. CoRR (2012)
Gordon, A.D., Henzinger, T.A., Nori, A.V., Rajamani, S.K.: Probabilistic programming. In: Proceedings of the on Future of Software Engineering (2014)
Hanus, M. (ed.): PAKCS: The Portland Aachen Kiel Curry System (2017). http://www.informatik.uni-kiel.de/pakcs/
Kiselyov, O., Shan, C.: Embedded probabilistic programming. In: Taha, W.M. (ed.) DSL 2009. LNCS, vol. 5658, pp. 360–384. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-03034-5_17
McCallum, A., Schultz, K., Singh, S.: FACTORIE: probabilistic programming via imperatively defined factor graphs. In: Proceedings of International Conference on Neural Information Processing Systems (2009)
Paige, B., Wood, F.: A compilation target for probabilistic programming languages. In: Proceedings of the International Conference on Machine Learning (2014)
Runciman, C., Naylor, M., Lindblad, F.: SmallCheck and Lazy SmallCheck: automatic exhaustive testing for small values. In: Proceedings of the Symposium on Haskell (2008)
Ścibior, A., Ghahramani, Z., Gordon, A.D.: Practical probabilistic programming with monads. In: Proceedings of the Symposium on Haskell (2015)
Wadler, P.: How to replace failure by a list of successes. In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture (1985)
Wood, F., Meent, J.W., Mansinghka, V.: A new approach to probabilistic programming inference. In: Artificial Intelligence and Statistics (2014)
Acknowledgements
We are thankful for fruitful discussions with Michael Hanus as well as suggestions of Jan Bracker and the anonymous reviewers to improve the readability of this paper.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer International Publishing AG
About this paper
Cite this paper
Dylus, S., Christiansen, J., Teegen, F. (2018). Probabilistic Functional Logic Programming. In: Calimeri, F., Hamlen, K., Leone, N. (eds) Practical Aspects of Declarative Languages. PADL 2018. Lecture Notes in Computer Science(), vol 10702. Springer, Cham. https://doi.org/10.1007/978-3-319-73305-0_1
Download citation
DOI: https://doi.org/10.1007/978-3-319-73305-0_1
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-73304-3
Online ISBN: 978-3-319-73305-0
eBook Packages: Computer ScienceComputer Science (R0)