Lazy Sttream Programming in Prolog


Paul Tarau and Jan Wielemaker and Tom Schrijvers.
Technical Communications of ICLP 2019.
2019.

Abstract

In recent years, stream processing has become a prominent approach for incrementally handling large amounts of data, with special support and libraries in many programming languages. Unfortunately, support in Prolog has so far been lacking and most existing approaches are ad-hoc. To remedy this situation, we present \em lazy stream generators as a unified Prolog interface for stateful computations on both finite and infinite sequences of data that are produced incrementally through I/O and/or algorithmically. We expose stream generators to the application programmer in two ways: 1) through an abstract sequence manipulation API, convenient for defining custom generators, and 2) as idiomatic lazy lists, compatible with many existing list predicates. We define an algebra of stream generator operations that extends Prolog via an embedded language interpreter, provides a compact notation for composing generators and supports moving between the two isomorphic representations. As a special instance, we introduce answer stream generators that encapsulate the work of coroutining first-class logic engines and support interoperation between forward recursive AND-streamsand backtracking-generated \em OR-streams.

BibTeX

@inproceedings{iclp2019,
  author = {Paul Tarau and Jan Wielemaker and Tom Schrijvers},
  title = {Lazy Sttream Programming in Prolog},
  booktitle = {Technical Communications of ICLP 2019},
  year = {2019},
  url = {/Research/papers/iclp2019.pdf},
  abstract = {In recent years, stream processing has become a prominent approach for
incrementally handling large amounts of data, with special support and
libraries in many programming languages. Unfortunately, support in Prolog has
so far been lacking and most existing approaches are ad-hoc. To remedy this
situation, we present {\em lazy stream generators} as a unified Prolog
interface for stateful computations on both finite and infinite sequences of
data that are produced incrementally through I/O and/or algorithmically.

We expose stream generators to the application programmer in two ways: 1)
through an abstract sequence manipulation API, convenient for defining custom
generators, and 2) as idiomatic lazy lists, compatible with many existing list
predicates.  We define an algebra of stream generator operations that extends
Prolog via an embedded language interpreter, provides a compact notation for
composing generators and supports moving between the two isomorphic
representations.

As a special instance, we introduce answer stream generators that encapsulate
the work of coroutining first-class logic engines and support interoperation
between forward recursive AND-streamsand backtracking-generated {\em
OR-streams}. 
  },
}