Questions tagged [datalog]

Datalog is a query and rule language for (deductive) databases that syntactically is a subset of Prolog.

Datalog is a query and rule language for (deductive) databases that syntactically is a subset of Prolog. Compared to Prolog, Datalog has certain restrictions on the syntax of allowable predicates, which mean that any bottom-up calculation is guaranteed to terminate. These restrictions also guarantee that the order of Datalog statements within a program does not affect its functioning. However, unlike Prolog, it is not Turing Complete, and so cannot be used for general purpose programming.

164 questions
2
votes
1 answer

Can I pull an entity and it's parent components all the way up the tree of components?

Is it possible to pull an entity and all the component parents all the way up the tree? A reverse recursive pull. If not, how would I do this?
stuartrexking
  • 657
  • 5
  • 12
2
votes
2 answers

Find the shortest path in DLV

I am trying to find all the paths in a graph with minimum distance using DLV. Say I have the following graph: I am expecting to obtain the predicates (I hope I don't skip any): path(a, b, 1), path(a, d, 1), path(a, e, 1), path(a, c, 2) path(b, a,…
2
votes
1 answer

Add loop edges in datalog (bddbddb)

I have the following rules that find all the paths among a graph. path(X,Y) :- edge(X,Y). path(X,Y) :- edge(X,Z), path(Z,Y). But, I want also for each node n, to add the edge n->n if not already present. How can I do this without having any…
eternalStudent
  • 444
  • 2
  • 19
2
votes
1 answer

Dependency Graph Resolving with pyDatalog

I am striving to write more readable, declarative programs. So I decided to implement a simple algorithm we currently use. The procedural implementation is the following: There are commands and resources Each command can provide and require…
user3729659
2
votes
1 answer

Bug in Z3 Datalog

For the datalog program in Z3 at the bottom, the result of query (query (CallGraph invo heap):print-answer true) given by Z3 is: sat (and (= (:var 0) #b011) (= (:var 1) #b1)) However, the answer should be sat (and (= (:var 0) #b1) (=…
user1487718
2
votes
2 answers

How could I encode "implies" logic in LogicBlox?

I would like to encode "implies" logic in LogicBlox. I have a predicate: Number(n),hasNumberName(n:i)->int(i). isTrue[n] = i -> Number(n), boolean(i). And I add some data in that predicate: +Number(1). Now, I want to create number 2 and number 3,…
jitron
  • 135
  • 1
  • 9
2
votes
1 answer

Defining datalog query components outside of (datomic.api/q '[])

I am working with clojure's datomic.api. I wish to refactor a somewhat complex datalog query such as this: (datomic.api/q '[:find [?value ...] :in $ ?uid ?component :where [...some clause...] [...some other…
Dave Owens
  • 111
  • 1
  • 5
2
votes
1 answer

Datomic datalog: ArrayIndexOutOfBounds Exception when using aggregates

Given that db is a database value, the following query throws an exception: (d/q '[:find ?concert (count-distinct ?demand) :in $ ?campaignId :with ?concert :where [?c :campaign/id ?campaignId] [?concert…
2
votes
1 answer

fixed points in Z3

Can someone kindly point out why the final query doesn't have output? Basically I tell Z3 if vs-)vd and vs->ss and vd->sd, then sd is derived from ss. (set-option :fixedpoint.engine datalog) (define-sort site () (_ BitVec 3)) (declare-rel pointsto…
Tim
  • 355
  • 1
  • 8
2
votes
1 answer

Datomic apply predicate to attribute with cardinality many

Say I have a Datomic entity with a many-valued attribute (of numbers, for instance). How would I return a list of entities whose value doesn't contain a specific number? As an example, {:db/id #db/id [:db.part/db] :db/ident :strs :db/valueType…
Atlas
  • 33
  • 4
2
votes
1 answer

what are the semantics of datalog and prolog?

Does datalog operate on sets or multisets? Does the same apply to prolog as well? I wasn't able to find any documentations on that.
JRR
  • 6,014
  • 6
  • 39
  • 59
2
votes
1 answer

Answer Set Programming - How to count number of facts appears to be my query result?

So I have a set of facts and a query written in ASP to be run on DLV, %Q1 : Find the implicit "is_a" relationship between terms %ex: if term A is is_a term B, term B is_a term C, then term A is_a term C %is_a One level triple1(TermA,…
2
votes
1 answer

Why does this datalog query aggregate?

From https://github.com/tonsky/datascript (-> (d/q '[:find ?color (max ?amount ?x) (min ?amount ?x) :in [[?color ?x]] ?amount] [[:red 10] [:red 20] [:red 30] [:red 40] [:red 50] [:blue 7] [:blue 8]] 4) pr-str …
Stephen Cagle
  • 14,124
  • 16
  • 55
  • 86
2
votes
2 answers

What are the various Datalog implementations available in Java?

I am looking for a Jave implementation of Datalog that does not evaluate unnecessary rules. I looked at IRIS reasoner which seems to be the most stable one. However, it evaluates all the rules rather than only the ones being used. As an…
Jus12
  • 17,824
  • 28
  • 99
  • 157
2
votes
2 answers

"for all" in datalog

Given a set of facts of the form is_member(country, organisation), I have the following query to write in datalog: Return all countries who belong to all of the organisations of which Denmark is a member of. I want to do something like…
Alexandre Holden Daly
  • 6,944
  • 5
  • 25
  • 36