| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.98.0/docs/handbook/_sources/libraries/datalog.rst.txt |
.. _library_datalog:
datalogThis library provides a portable Datalog and incremental rule engine for educational purposes and non-demanding applications. This library is work-in-progress and changes, possibly breaking backwards compatibility, are to be expected.
Open the `../../apis/library_index.html#datalog <../../apis/library_index.html#datalog>`__ link in a web browser.
To load all entities in this library, load the loader.lgt file:
::
| ?- logtalk_load(datalog(loader)).
To run the library unit tests, load the tester.lgt file:
::
| ?- logtalk_load(datalog(tester)).
agg(Op, Template, Goals, Result)) with
lower-strata dependencies (Op in count, sum, min,
max)Head and negated literal variables must appear in
positive Body literals)rule(Id, Head, Body) where Body is a list of Literal
terms:
Termneg(Term)agg(Op, Template, Goals, Result) where Op
is one of count, sum, min, maxfact(Fact) for extensional database (EDB) facts
Aggregate notes:min and max require at least one matching value; otherwise no
fact is derived.::
| ?- logtalk_load(datalog(loader)).
...
| ?- Program = [
rule(path_base, path(X,Y), [edge(X,Y)]),
rule(path_rec, path(X,Z), [edge(X,Y), path(Y,Z)]),
fact(edge(a,b)),
fact(edge(b,c))
],
datalog::load_program(Program),
datalog::query(path(a,c)).
This first version intentionally keeps the implementation simple and
portable. Negation support is currently limited to stratified programs.
Aggregates and cost-based optimization are planned future enhancements.
Aggregate support is currently limited to count, sum, min,
and max.