by kybernetikos · 5y ago · 0 comments
The fact that this is bottom up makes me think that you probably can't go crazy with the number of rules.
For example, if we declare the predicate f/1 dynamic using the standard directive dynamic/1:
:- dynamic(f/1).
then we can assert new clauses for f/1 using the standard predicates asserta/1 and assertz/1: ?- asserta(f(a)), assertz(f(b)).
true.
We then get: ?- f(X).
X = a
; X = b.
Rules can also be asserted: ?- use_module(library(lists)), asserta((f(X):-length(_,X))).
true.
yielding: ?- f(X).
X = 0
; X = 1
; X = 2
; X = 3
; ...
I used Scryer Prolog to run these examples.Dynamic changes to the database have advantages and drawbacks. On the plus side, they let us incorporate new knowledge and rules, and we automatically benefit from built-in features such as argument indexing. However, running the same query twice can lead to different results, changes in the order of goals can affect the meaning of the conjunction, and we can no longer reason about different predicates in isolation. Dynamic changes of the database are said to be side-effects, since they affect the program in a way that is outside the logical interpretation of the given definitions.
I wonder if that is part of the benefits advertised by DDlog, the ability to update a program without having to worry about clause ordering (which one does not have to, with datalog and bottom-up evaluation) or generally side effects.
Very tentatively, I'm guessing that, since datalog programs lack negation, any new facts or rules added to the (extensional) database will update the "output" of the database (its Herbrand model) monotonically, i.e. you'll see new facts comeing out but no facts will "disappear". I'm a bit unsure because the DDlog github is talking about functions and typed datalog and I'm not really sure how that works now.
Out of curiosity, what kind of negation do you mean? Negation as failure or classical negation? And what do you mean about limitations?
I don't see much literature out there on it (after the mid-2000s) but it always seemed a conceptually elegant way of doing forward-chaining (and inference) in the way of most rules engines. It only has a few simple rules: simplification (remove data/rules), simpagation and propagation (new data).
The best part is that it embeds very easily in Prolog.
It doesn't actually care much about the number of rules, and more about how much memory it costs to materialize them. There are delta-join techniques to do at least most of that in linear memory (w.r.t. input size) though, and DDlog has at least experimental support for them.