Search code examples
streamprologreactive-programmingswi-prologevent-driven

Stream reasoning / Reactive programming in prolog?


I was wondering if you know of any way to use prolog for stream processing, that is, some kind of reactive programming, or at least to let a query run on a knowledge base that is continuously updated (effectively a stream), and continuously output the output of the reasoning?

Anything implemented in the popular "prologs", such as SWI-prolog?


Solution

  • You can use Logtalk's support for event-driven programming to define monitors that watch for knowledge base update events and react accordingly. You can run Logtalk using most Prolog systems as the backed compiler, including SWI-Prolog.

    The event-driven features are described e.g. in the user manual: http://logtalk.org/manuals/userman/events.html

    The current distribution contains some examples of using events and monitors. An interesting one considering your question is the bricks example: https://github.com/LogtalkDotOrg/logtalk3/tree/master/examples/bricks

    Running this example first and then looking at its code should give you as good idea of what you can do with system wide events and monitors.