About
I am a PhD student in Computer Science at Kiel University and a member of Prof. Dr. Michael Hanus' research group Programming Languages and Compiler Construction. My research (see below) concentrates on declarative programming with an emphasis on functional logic programming languages and both their implementation and applications. In addition to research, I also enjoy teaching. For example, I have given courses on algorithmics, compiler construction, and programming languages of various paradigms, such as functional, logic, concurrent, and object-oriented programming. I have also supervised numerous student projects and theses.
Research
As my research group develops the functional logic programming language Curry, I am closely involved in its design and implementation. Among other things, I have devised a novel implementation scheme for functional logic programming languages. It has led to the most efficient implementation of Curry to date, allowing Curry to compete with other programming languages.
Recently, my research focus has expanded to include inverse computations as well. In particular, I am studying the automatic synthesis of inverse functions in the functional programming language Haskell, which is also the topic of my PhD thesis. One result of this work is a plugin for the Glasgow Haskell Compiler that extends Haskell with automatic function inversion. The plugin is available on GitHub.
Publications
Embedding Functional Logic Programming in Haskell via a Compiler Plugin (2023)
AbstractWe present a technique to embed a functional logic language in Haskell using a GHC plugin. Our approach is based on a monadic lifting that models the functional logic semantics explicitly. Using a GHC plugin, we get many language extensions that GHC provides for free in the embedded language. As a result, we obtain a seamless embedding of a functional logic language, without having to implement a full compiler. We briefly show that our approach can be used to embed other domain-specific languages as well. Furthermore, we can use such a plugin to build a full blown compiler for our language.
@inproceedings{ProttEtAl2023EmbeddingFunctionalLogic,
author = {Prott, Kai-Oliver and Teegen, Finn and Christiansen, Jan},
editor = {Hanus, Michael and Inclezan, Daniela},
title = {Embedding Functional Logic Programming in Haskell via a Compiler Plugin},
booktitle = {Practical Aspects of Declarative Languages},
year = {2023},
publisher = {Springer Nature Switzerland},
address = {Cham},
doi = {10.1007/978-3-031-24841-2_3}
pages = {37--55},
isbn = {978-3-031-24841-2}
}
A Monadic Implementation of Functional Logic Programs (2022) Selected for Rapid Journal Publication
AbstractFunctional logic languages are a high-level approach to programming by combining the most important declarative features. They abstract from small-step operational details so that programmers can concentrate on the logical aspects of an application. This is supported by appropriate evaluation strategies. Demand-driven evaluation from functional programming is amalgamated with non-determinism from logic programming so that solutions or values are computed whenever they exist. This frees the programmer from considering the influence of an operational strategy to the success of a computation but it is a challenge to the language implementer. A non-deterministic demand-driven strategy might duplicate unevaluated choices of an expression which could duplicate the computational efforts. In recent implementations, this problem has been tackled by adding a kind of memoization of non-deterministic choices to the expression under evaluation. Since this has been implemented in imperative target languages, it was unclear whether this could also be supported in a functional programming environment, like Haskell. This paper presents a solution to this challenge by transforming functional logic programs into a monadic representation. Although this transformation is not new, we present an implementation of the monadic interface which supports memoization in non-deterministic branches. We demonstrate that our approach yields a promising performance that outperforms current compilers for Curry.
@inproceedings{HanusEtAl2022AMonadicImplementation,
author = {Hanus, Michael and Prott, Kai-Oliver and Teegen, Finn},
title = {A Monadic Implementation of Functional Logic Programs},
year = {2022},
isbn = {9781450397032},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
doi = {10.1145/3551357.3551370},
booktitle = {Proceedings of the 24th International Symposium on Principles and Practice of Declarative Programming},
articleno = {1},
numpages = {15},
location = {Tbilisi, Georgia},
series = {PPDP '22}
}
Haskell⁻¹: Automatic Function Inversion in Haskell (2021)
AbstractWe present an approach for automatic function inversion in Haskell. The inverse functions we generate are based on an extension of Haskell's computational model with non-determinism and free variables. We implement this functional logic extension of Haskell via a monadic lifting of functions and type declarations. Using inverse functions, we additionally show how Haskell's pattern matching can be augmented with support for functional patterns, which enable arbitrarily deep pattern matching in data structures. Finally, we provide a plugin for the Glasgow Haskell Compiler to seamlessly integrate inverses and functional patterns into the language, covering almost all of the Haskell2010 language standard.
@inproceedings{TeegenEtAl2021HaskellAutomaticFunction,
author = {Teegen, Finn and Prott, Kai-Oliver and Bunkenburg, Niels},
title = {Haskell⁻¹: Automatic Function Inversion in Haskell},
year = {2021},
isbn = {9781450386159},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
doi = {10.1145/3471874.3472982},
booktitle = {Proceedings of the 14th ACM SIGPLAN International Symposium on Haskell},
pages = {41--55},
numpages = {15},
location = {Virtual, Republic of Korea},
series = {Haskell 2021}
}
From Non-determinism to Goroutines: A Fair Implementation of Curry in Go (2021)
AbstractThe declarative programming language Curry amalgamates demand-driven evaluation from functional programming with non-determinism from logic programming. In contrast to Prolog, the search strategy for non-deterministic computations is not fixed so that complete or parallel strategies are reasonable for Curry. In particular, a desirable option is a fair strategy which frees the programmer from considering the influence of the search strategy to the success of a computation. In this paper we describe an implementation with this property. Based on recent developments on operational models for functional logic programming, we present a new implementation which transforms Curry programs in several transformation steps into Go programs. By exploiting lightweight threads in the form of goroutines, we obtain a complete and fair implementation which automatically uses multi-processing to speed up non-deterministic computations. This has the effect that, in some cases, non-deterministic algorithms are more efficiently evaluated than deterministic ones.
@inproceedings{BohmEtAl2021NondeterminismGoroutinesFair,
author = {B\"{o}hm, Jonas and Hanus, Michael and Teegen, Finn},
title = {From Non-determinism to Goroutines: A Fair Implementation of Curry in Go},
year = {2021},
isbn = {9781450386890},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
doi = {10.1145/3479394.3479411},
articleno = {16},
numpages = {15},
location = {Tallinn, Estonia},
series = {PPDP '21}
}
Implementing a Library for Probabilistic Programming Using Non-strict Non-determinism (2020)
AbstractThis 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, language characteristics from one area exist in the other and vice versa. For example, the concepts of non-deterministic choice and call-time choice as known from functional logic programming are related to and coincide with stochastic memoization and probabilistic choice in probabilistic programming, respectively. We will further 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 and can even compete with full-blown probabilistic programming languages, which we illustrate by several benchmarks.
@article{DylusEtAl2020ImplementingLibraryProbabilistic,
title = {Implementing a {{Library}} for {{Probabilistic Programming Using Non-Strict Non-Determinism}}},
author = {Dylus, Sandra and Christiansen, Jan and Teegen, Finn},
year = {2020},
journal = {Theory and Practice of Logic Programming},
volume = {20},
number = {1},
pages = {147--175},
publisher = {{Cambridge University Press}},
doi = {10.1017/S1471068419000085},
}
Memoized Pull-Tabbing for Functional Logic Programming (2020)
AbstractPull-tabbing is an evaluation technique for functional logic programs which computes all non-deterministic results in a single graph structure. Pull-tab steps are local graph transformations to move non-deterministic choices towards the root of an expression. Pull-tabbing is independent of a search strategy so that different strategies (depth-first, breadth-first, parallel) can be used to extract the results of a computation. It has been used to compile functional logic languages into imperative or purely functional target languages. Pull-tab steps might duplicate choices in case of shared subexpressions. This could result in a dramatic increase of execution time compared to a backtracking implementation. In this paper we propose a refinement which avoids this efficiency problem while keeping all the good properties of pull-tabbing. We evaluate a first implementation of this improved technique in the Julia programming language.
@inproceedings{HanusTeegen2021MemoizedPulltabbingFunctional,
title = {Memoized Pull-Tabbing for Functional Logic Programming},
booktitle = {Functional and Constraint Logic Programming},
author = {Hanus, Michael and Teegen, Finn},
editor = {Hanus, Michael and Sacerdoti Coen, Claudio},
year = {2021},
pages = {57--73},
publisher = {{Springer International Publishing}},
address = {{Cham}},
isbn = {978-3-030-75333-7}
}
Research Summary on Implementing Functional Patterns by Synthesizing Inverse Functions (2020)
AbstractIn this research summary we present our recent work on implementing functional patterns with inverse functions in the lazy functional-logic programming language Curry. Our goal is the synthesis of the inverse of any given function in Curry itself. The setting of a functional-logic language especially allows the inversion of non-injective functions. In general, inverse computation is a non-trivial problem in lazy programming languages due to their non-strict semantics. We are so far able to directly derive the inverse function for a limited class of functions, namely those consisting of rules that do not involve both extra variables and non-linear right-hand sides. Because the synthesized definitions are based on standard code, known optimizations techniques can be applied to them. For all other functions we can still provide an inverse function by using non-strict unification.
@inproceedings{Teegen2020ResearchSummaryImplementing,
title = {Research Summary on Implementing Functional Patterns by Synthesizing Inverse Functions},
booktitle = {Proceedings 36th International Conference on Logic Programming (Technical Communications), {{ICLP}} Technical Communications 2020, (Technical Communications) {{UNICAL}}, Rende ({{CS}}), Italy, 18-24th September 2020},
author = {Teegen, Finn},
editor = {Ricca, Francesco and Russo, Alessandra and Greco, Sergio and Leone, Nicola and Artikis, Alexander and Friedrich, Gerhard and Fodor, Paul and Kimmig, Angelika and Lisi, Francesca A. and Maratea, Marco and Mileo, Alessandra and Riguzzi, Fabrizio},
year = {2020},
series = {{{EPTCS}}},
volume = {325},
pages = {296--302},
doi = {10.4204/EPTCS.325.39},
}
One Monad to Prove Them All (2019)
AbstractOne Monad to Prove Them All is a modern fairy tale about curiosity and perseverance, two important properties of a successful PhD student. We follow the PhD student Mona on her adventure of proving properties about Haskell programs in the proof assistant Coq. On the one hand, as a PhD student in computer science Mona observes an increasing demand for correct software products. In particular, because of the large amount of existing software, verifying existing software products becomes more important. Verifying programs in the functional programming language Haskell is no exception. On the other hand, Mona is delighted to see that communities in the area of theorem proving are becoming popular. Thus, Mona sets out to learn more about the interactive theorem prover Coq and verifying Haskell programs in Coq. To prove properties about a Haskell function in Coq, Mona has to translate the function into Coq code. As Coq programs have to be total and Haskell programs are often not, Mona has to model partiality explicitly in Coq. In her quest for a solution Mona finds an ancient manuscript that explains how properties about Haskell functions can be proven in the proof assistant Agda by translating Haskell programs into monadic Agda programs. By instantiating the monadic program with a concrete monad instance the proof can be performed in either a total or a partial setting. Mona discovers that the proposed transformation does not work in Coq due to a restriction in the termination checker. In fact the transformation does not work in Agda anymore as well, as the termination checker in Agda has been improved. We follow Mona on an educational journey through the land of functional programming where she learns about concepts like free monads and containers as well as basics and restrictions of proof assistants like Coq. These concepts are well-known individually, but their interplay gives rise to a solution for Mona's problem based on the originally proposed monadic tranformation that has not been presented before. When Mona starts to test her approach by proving a statement about simple Haskell functions, she realizes that her approach has an additional advantage over the original idea in Agda. Mona's final solution not only works for a specific monad instance but even allows her to prove monad-generic properties. Instead of proving properties over and over again for specific monad instances she is able to prove properties that hold for all monads representable by a container-based instance of the free monad. In order to strengthen her confidence in the practicability of her approach, Mona evaluates her approach in a case study that compares two implementations for queues. In order to share the results with other functional programmers the fairy tale is available as a literate Coq file. If you are a citizen of the land of functional programming or are at least familiar with its customs, had a journey that involved reasoning about functional programs of your own, or are just a curious soul looking for the next story about monads and proofs, then this tale is for you.
@article{DylusEtAl2019OneMonadProve,
title = {One {{Monad}} to {{Prove Them All}}},
author = {Dylus, Sandra and Christiansen, Jan and Teegen, Finn},
year = {2019},
month = feb,
journal = {The Art, Science, and Engineering of Programming},
volume = {3},
number = {3},
publisher = {{Aspect-Oriented Software Association (AOSA)}},
issn = {2473-7321},
doi = {10.22152/programming-journal.org/2019/3/8},
}
Adding Data to Curry (2019)
AbstractFunctional logic languages can solve equations over user-defined data and functions. Thus, the definition of an appropriate meaning of equality has a long history in these languages, ranging from reflexive equality in early equational logic languages to strict equality in contemporary functional logic languages like Curry. With the introduction of type classes, where the equality operation “==” is overloaded and user-defined, the meaning became more complex. Moreover, logic variables appearing in equations require a different typing than pattern variables, since the latter might be instantiated with functional values or non-terminating operations. In this paper, we present a solution to these problems by introducing a new type class Data which is associated with specific algebraic data types, logic variables, and strict equality. We discuss the ideas of this class and its implications on various concepts of Curry, like unification, functional patterns, and program optimization.
@inproceedings{HanusTeegen2020AddingDataCurry,
title = {Adding {{Data}} to {{Curry}}},
booktitle = {Declarative {{Programming}} and {{Knowledge Management}}},
author = {Hanus, Michael and Teegen, Finn},
year = {2020},
series = {{{WFLP}} 2019},
pages = {230--246},
publisher = {{Springer International Publishing}},
address = {{Cham}},
doi = {10.1007/978-3-030-46714-2_15}
}
Structured Traversal of Search Trees in Constraint-logic Object-oriented Programming (2019)
AbstractIn this paper, we propose an explicit, non-strict representation of search trees in constraint-logic object-oriented programming. Our search tree representation includes both the non-deterministic and deterministic behaviours of executing an application. Introducing such a representation facilitates the use of various search strategies. In order to demonstrate the applicability of our approach, we incorporate explicit search trees into the virtual machine of the constraint-logic object-oriented programming language Muli. We then exemplarily implement three search algorithms that traverse the search tree on-demand: depth-first search, breadth-first search, and iterative deepening depth-first search. In particular, the last two strategies allow for a complete search, which is novel in constraint-logic object-oriented programming and highlights our main contribution. Finally, we compare the implemented strategies using several benchmarks.
@inproceedings{DagefordeTeegen2020StructuredTraversalSearch,
title = {Structured Traversal of Search Trees in Constraint-Logic Object-Oriented Programming},
booktitle = {Declarative Programming and Knowledge Management},
author = {Dagef{\"o}rde, Jan C. and Teegen, Finn},
editor = {Hofstedt, Petra and Abreu, Salvador and John, Ulrich and Kuchen, Herbert and Seipel, Dietmar},
year = {2020},
pages = {199--214},
publisher = {{Springer International Publishing}},
address = {{Cham}},
isbn = {978-3-030-46714-2}
}
Probabilistic Functional Logic Programming (2018) Best Student Paper Selected for Rapid Journal Publication
AbstractThis 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.
@inproceedings{DylusEtAl2018ProbabilisticFunctionalLogic,
title = {Probabilistic Functional Logic Programming},
booktitle = {Practical Aspects of Declarative Languages},
author = {Dylus, Sandra and Christiansen, Jan and Teegen, Finn},
editor = {Calimeri, Francesco and Hamlen, Kevin and Leone, Nicola},
year = {2018},
pages = {3--19},
publisher = {{Springer International Publishing}},
address = {{Cham}},
isbn = {978-3-319-73305-0}
}
Synthesizing Set Functions (2018)
AbstractSet functions are a feature of functional logic programming to encapsulate all results of a non-deterministic computation in a single data structure. Given a function f of a functional logic program written in Curry, we describe a technique to synthesize the definition of the set function of f. The definition produced by our technique is based on standard Curry constructs. Our approach is interesting for three reasons. It allows reasoning about set functions, it offers an implementation of set functions which can be added to any Curry system, and it has the potential of changing our thinking about the implementation of non-determinism, a notoriously difficult problem.
@inproceedings{AntoyEtAl2018SynthesizingSetFunctions,
title = {Synthesizing Set Functions},
booktitle = {Functional and Constraint Logic Programming - 26th International Workshop, {{WFLP}} 2018, {{Frankfurt}}/{{Main}}, Germany, September 6, 2018, Revised Selected Papers},
author = {Antoy, Sergio and Hanus, Michael and Teegen, Finn},
editor = {Silva, Josep},
year = {2018},
series = {Lecture Notes in Computer Science},
volume = {11285},
pages = {93--111},
publisher = {{Springer}},
doi = {10.1007/978-3-030-16202-3_6}
}
Contact
If you would like to contact me, you can write me an or message me on LinkedIn.