Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "nan_system_sources"

Title:Nan.System.Sources - Answer Sources in Prolog
Rating:Not rated. Create the first rating!
Latest version:1.2.0
SHA1 sum:c9c6bbd2a6f86d785469363d6154fb4e41f2d326
Author:Julio P. Di Egidio <julio@diegidio.name>
Home page:http://julio.diegidio.name/Projects/Nan.System.Sources/
Download URL:https://github.com/jp-diegidio/Nan.System.Sources-Prolog/releases/download/1.2.0-beta/nan_system_sources-1.2.0.zip
Provides:sources
system

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
1.2.0c9c6bbd2a6f86d785469363d6154fb4e41f2d3262https://github.com/jp-diegidio/Nan.System.Sources-Prolog/releases/download/1.2.0-beta/nan_system_sources-1.2.0.zip

Answer Sources in Prolog

Nan.System.Sources Nan.System.Sources/Prolog 1.2.0-beta Answer Sources in Prolog Copyright 2015-2017 Julio P. Di Egidio Licensed under GNU GPLv3. http://julio.diegidio.name/Projects/Nan.System.Sources/ https://github.com/jp-diegidio/Nan.System.Sources-Prolog/

This library implements Answer Sources in Prolog. This is an open and free project. Source code available and pull requests accepted.

  1. What are answer sources
  2. How to use this library
  3. Still to be done

1. What are answer sources

Answer sources can be seen as generalized iterators, allowing a given program to control answer production in another. Each source works as a separate program interpreter, and, in our implementation, in its own process, via multi-threading.

For the rationale and design, we have followed almost exactly Paul Tarau on fluents [1], with at least the following differences:

  • Our sources use multi-threading unlike Tarau's;
  • Our sources execute arbitrary Prolog goals, i.e. are not restricted to Horn clauses;
  • Thanks to multi-threading, our next operation (get in Tarau's) supports an asynchronous pattern: e.g. this allows for easy implementation of parallelism in combinators;
  • Our sources implement a reset operation that restarts the enumeration, so Tarau's split combinator is not necessary;
  • The overhead of threading being unnecessary for combinators, support for combined sources is built into our source object module;
  • Our answer term extends Tarau's to report exact determinism. TODO: A still needed final step is to extend our sources from fluents to interactors [2], which requires implementation of a yield operation (return in Tarau's) to be available to the target predicate, i.e. in the context of the source worker loop.

    A "Preview" version of Answer Sources was initially presented here [3]. A flow diagram for the yield operation (denoted return in the diagram) was later presented here [4].

    [1] P. Tarau, "Fluents: A Refactoring of Prolog for Uniform Reflection and Interoperation with External Objects": http://www.cse.unt.edu/~tarau/research/LeanProlog/RefactoringPrologWithFluents.pdf [2] P. Tarau, A. Majumdar, "Interoperating Logic Engines": http://www.cse.unt.edu/~tarau/research/LeanProlog/InteroperatingLogicEngines.pdf [3] J.P. Di Egidio, "Answer Sources in Prolog (SWI) - Preview": http://seprogrammo.blogspot.it/2015/09/answer-sources-in-prolog-swi-preview.html [4] J.P. Di Egidio, "Answer Sources: from Fluents to Interactors": http://seprogrammo.blogspot.co.uk/2015/09/answer-sources-from-fluents-to.html

2. How to use this library

This library comprises the following modules:

For detailed documentation on the available modules and predicates, please see the code docs accompanying the Prolog code files.

This library was developed and tested with SWI-Prolog 7.3.25.

Basic usage example:

?- pack_install(nan_system_sources).
true.

?- use_module(library(nan/system/sources)).
true.

?- using_source(I, between(1, 2, I), _S,
   (   repeat,
       source_next(_S, answer(_Det, the(I))),
       (_Det == last -> !; true)
   )).
I = 1 ;
I = 2.

3. Still to be done

  • Extend from fluents to interactors (implement yield/1).
  • Improve compatibility with other Prolog systems (implement a compatibility layer).
  • Improve documentation and test cases.

Contents of pack "nan_system_sources"

Pack contains 15 files holding a total of 96.7K bytes.