Fork me on GitHub

@quoll Hey Paula, I wanted to ask some questions here that may also be relevant to others in the channel. I watched the presentation that Zach Oakes gave on O’Doyle Rules ( and that made me much more interested in Rules Engines than I was before. I was wondering how Naga compares to it (and Clara Rules). One thing I’ve noticed is that the Datalog syntax in the is Prolog-based rather than Datomic-style. Is the Datomic style also supported?

Steven Deobald17:02:36

@U4P4NREBY Just a heads-up, Paula mentioned in #asami that she's on vacation (and offline) for a week or so. Might take her a few days to get back to you.


Ah, thank you. I'll try to ask her another time then 😊


Just saw this now on my phone…


I’ll start by raising my standard objection that “Datalog syntax” really is Prolog syntax (with restrictions). Rich called it Datalog because it has Datalog semantics, but it’s his own syntax.

💯 3

But I know what you mean, so to answer your question, yes. Internally, the rules get converted anyway. If you write your rules in code, then you HAVE to do it with the query syntax (unless you want to build up a whole lot of strings and parse them)


The easiest way to create rules is with a macro in naga.rules called r. This follows the Prolog convention of: head :- body


The difference is that it’s based on triple-patterns


So the Datalog rule of: uncle(N,U) :- parent(N,P), brother(P,U). Can be expressed as:

'(require naga.rules :refer [r])
(r [?n :uncle ?u] :- [?n :parent ?p] [?p :brother ?u])


Macros mean that I don’t have to quote all the symbols in there 🙂


(Adjust the require for ClojureScript, of course)


A Naga program is a seq of such rules. You compile them, then run them on a connection


About rule options... Naga was originally Datalog centric, which excluded negations in queries, retracting statements, or existential statements (such as mother(C,M) :- person(C).) Right now, Naga supports: • existential statements (meaning that new objects can be created, like in the mother example there) • query negations (via not) • limited retraction. This is when you update a value that already exists, and requires a retract/assert on the value, since everything is multicardinality. It’s done via a ' annotation on an attribute.


The last one looks like we need to extend it to full retractions of statements though


Each of these extensions to Datalog (I mean the real Datalog here) are “dangerous” and can result in an infinite loop. That’s actually why they’re not in the standard Datalog definition.