Fork me on GitHub
#rdf
<
2021-02-15
>
rickmoynihan09:02:53

@simongray Naga has a data syntax for rules; it’s not the datomic syntax but instead looks to be a direct translation of the datalog horn clause syntax naga supports: https://github.com/threatgrid/naga/blob/964a71e300c947ead28f1b344ed9bccdbf97ff9b/test/naga/test_rules.cljc#L21 I’m not familiar with datomic rules, and have only played with naga briefly but after looking at them again it looks like the main differences are: 1. (I think) naga rules must be either unary or binary predicates. 2. Naga rules are materialised once at startup; datomic’s are AFAICT materialised at query time. I’m guessing datomics rules through a process similar to macro-expansion just expand into datomic query fragments… presumably with gensyms etc to prevent unintended bindings.

metal 1
simongray09:02:52

Ooh, that Clojure data Prolog style syntax looks interesting.

simongray09:02:38

I was asking about Zach Oakes' O'Doyle Rules, though, which uses Datomic-style triples/facts, but otherwise doesn't have anything to do with Datomic.

rickmoynihan10:02:59

AFAIK you can do the same with RETE (create infinite recursions)

quoll15:02:23

Ah, I just addressed some of this in the thread above (sorry... I’m slow on my phone)

quoll15:02:32

Naga was Datalog, with the restriction of binary/unary predicates. (Higher arity actually isn’t hard to do, but I never needed it :woman-shrugging:)

quoll15:02:00

But it’s been extended in ways that are described in the thread

quoll15:02:29

Full query syntax is allowed in the rules too.

quoll15:02:44

Including not, or, filters, bindings, etc. The head can also have multiple triples to be asserted for a single match (allowing multiple attributes for a single generated entity)

quoll15:02:20

Also, Naga rules are materialized as needed. If you’re using a macro, then yes, that has to be at startup in ClojureScript (because ClojureScript macros are evaluated as Clojure code during compilation), but not in Clojure. But the r macro is just a convenience around the rule function, which takes: • head: a seq of triple patterns • body: a query :where clause expression • name: optional This function can be called at runtime, even in Cljs.

quoll15:02:03

We do it at Cisco. Build rules on the fly, then execute them against a connection to Asami

simongray09:02:43

Just wanted to say thank you for this massive explanation 🙂