Heuristics Entwined with Handlers Combined

Tom Schrijvers, Nicolas Wu, Benoit Desouter, Bart Demoen
2014 Proceedings of the 16th International Symposium on Principles and Practice of Declarative Programming - PPDP '14  
A long-standing problem in logic programming is how to cleanly separate logic and control. While solutions exist, they fall short in one of two ways: some are too intrusive, because they require significant changes to Prolog's underlying implementation; others are lacking a clean semantic grounding. We resolve both of these issues in this paper. We derive a solution that is both lightweight and principled. We do so by starting from a functional specification of Prolog based on monads, and
more » ... this with the effect handlers approach to capture the dynamic search tree as syntax. Effect handlers then express heuristics in terms of tree transformations. Moreover, we can declaratively express many heuristics as trees themselves that are combined with search problems using a generic entwining handler. Our solution is not restricted to a functional model: we show how to implement this technique as a library in Prolog by means of delimited continuations. • We show how to obtain modular search heuristics by means of effect handlers, and, in particular, define an unusual entwine handler that allows us to express search heuristics as archetypal search trees much like TOR's merge/2 combinator.
doi:10.1145/2643135.2643145 dblp:conf/ppdp/SchrijversWDD14 fatcat:j7wsvb2oevb6jl24rn3xpfxjv4