Fork me on GitHub
#rdf
<
2021-02-13
>
simongray10:02:34

@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?

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.

simongray06:02:59

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

quoll14:02:02

Just saw this now on my phone…

quoll14:02:56

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
quoll14:02:46

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)

quoll14:02:28

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

quoll14:02:10

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

quoll14:02:24

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

quoll14:02:14

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

quoll15:02:01

(Adjust the require for ClojureScript, of course)

quoll15:02:29

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

quoll15:02:42

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.

quoll15:02:21

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

quoll15:02:54

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.