rdf

simongray 2021-02-13T10:00:34.008400Z

@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 (https://www.youtube.com/watch?v=XONRaJJAhpA) 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 README.md is Prolog-based rather than Datomic-style. Is the Datomic style also supported?

quoll 2021-02-15T14:39:02.023400Z

Just saw this now on my phone…

quoll 2021-02-15T14:44:56.026200Z

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.

💯 1
quoll 2021-02-15T14:46:46.028900Z

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)

quoll 2021-02-15T14:50:28.031600Z

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

quoll 2021-02-15T14:53:10.032500Z

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

quoll 2021-02-15T14:58:24.038Z

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])

quoll 2021-02-15T14:59:14.039Z

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

quoll 2021-02-15T15:00:01.040200Z

(Adjust the require for ClojureScript, of course)

quoll 2021-02-15T15:01:29.041300Z

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

quoll 2021-02-15T15:12:42.049700Z

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.

quoll 2021-02-15T15:13:21.050800Z

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

quoll 2021-02-15T15:14:54.053100Z

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.

Steven Deobald 2021-02-13T17:20:36.008700Z

@simongray 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.