asami

Asami, the graph database https://github.com/threatgrid/asami
2021-03-04T23:10:30.054200Z

@quoll: Am I right that naga/pabu doesn’t implement negation or failure, or any way to do intersection? It’s purely monotonic right?

quoll 2021-03-04T23:10:53.054400Z

no

quoll 2021-03-04T23:11:05.054600Z

Not at all

quoll 2021-03-04T23:11:37.055100Z

There’s the not operator in queries

quoll 2021-03-04T23:12:34.056400Z

which can also be used in rules for Naga. Indeed, if you create a new object in the head of a rule, then Naga updates the query to use a not expression to remove existing entities that already match the pattern

2021-03-04T23:12:59.057100Z

is there an example?

quoll 2021-03-04T23:13:19.057500Z

Uh… probably. I’m rushing out at the moment, sorry

2021-03-04T23:13:40.057900Z

its ok I’ll do some digging in the code; thanks for the pointer 🙇

quoll 2021-03-04T23:14:42.058600Z

asami.core-query-test/test-not-query (line 70) uses it

quoll 2021-03-04T23:15:05.058900Z

Also, I don’t know what you mean by “intersection”

quoll 2021-03-04T23:15:25.059400Z

inner joins are an intersection. Do you maybe mean graph intersections? Or something else again?

2021-03-04T23:17:36.060600Z

sorry I didn’t mean intersection at all; that’s clearly used a everywhere — I meant disjointness constraints

quoll 2021-03-04T23:18:52.061400Z

OK, yes. It’s the not operator. I don’t actually follow Datomic semantics 😳 Instead, I follow SPARQL semantics

2021-03-04T23:19:15.061600Z

me too

2021-03-04T23:19:20.061800Z

🙂

quoll 2021-03-04T23:21:15.063Z

Also, look at test/naga/test_rules.cljc line 238 (test-rewrite). That’s doing query rewriting for rules

👀 1
2021-03-04T23:21:35.063500Z

@quoll: Sorry that appears to be in asami queries… I’m meaning in naga rules

quoll 2021-03-04T23:22:03.064Z

Well, Naga rules ARE Asami queries

quoll 2021-03-04T23:22:25.064700Z

They’re based on them anyway

quoll 2021-03-04T23:23:59.066200Z

That test takes a set of patterns for generating data, and a :where clause, and it rewrites the :where clause to exclude data that already matches the output pattern

quoll 2021-03-04T23:24:22.066600Z

Rules do this internally

2021-03-04T23:24:52.067Z

ok — not sure if this is quite what I’m after

2021-03-04T23:26:10.067500Z

Essentially if I detect a contradiction in the graph; I’d like to fail the reasoning

2021-03-04T23:27:16.068400Z

e.g. return a failing goal

2021-03-04T23:28:38.069400Z

I suppose I could always just return a special error report node, that if present meant inconsistency… I guess I could capture information the failure that way too

quoll 2021-03-04T23:43:14.069700Z

Are you thinking like eq-diff1 rule?

👍 1
quoll 2021-03-04T23:45:13.071200Z

That kind of thing is not negation! There are 2 approaches. One is to assert data that indicates a failure. The other is to have rules perform a failing action rather than asserting data. Either way, it’s a positive test. It’s just what you choose to do with what you find

quoll 2021-03-04T23:45:30.071600Z

Naga has a space in it for doing non-assertion things. I just haven’t had a need to do it yet 🙂

quoll 2021-03-04T23:47:49.075200Z

My original thought was to connect to a messaging API and send things there. A client process could then report on what comes through. The other thing is to define a head that indicates an error. I thought maybe an empty head. Or possibly a predicate form, like (error "eq-diff2") :- owl:sameAs(X, Y), owl:differentFrom(X, Y).

quoll 2021-03-04T23:48:41.076200Z

see in Naga: src/naga/engine.cljc line 125

quoll 2021-03-04T23:51:25.077Z

OK. You’re looking for output when something does not exist

quoll 2021-03-04T23:51:47.077200Z

That’s hard to do in terms of query bindings

quoll 2021-03-04T23:52:53.077400Z

It’s approximated by having statements that match the negation term, and use a NOT operation to remove them

quoll 2021-03-04T23:53:31.078Z

But you need data that exists to subtract your terms from

2021-03-04T23:54:46.079300Z

ok cool that’s essentially what I was thinking I’d do too. I think that’ll work for a lot of what I want.

quoll 2021-03-04T23:57:01.080Z

It’s interesting to think of an assertion when something doesn’t exist. It doesn’t make sense for a query, but it does for a rule. I think I can manage that