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
0
votes
1 answer

Preventing symetric pairs in datalog logic

I am running a datalog rule with clingo in jupyter notebook against graph nodes checking for nodes that share the same direct ancestor as follows: ancestor(A,B). ancestor(A,C). sibs(X,Y) = ancestor(Z,X), ancestor(Z,Y), X!=Y. This gives me 2…
Paul
  • 813
  • 11
  • 27
0
votes
0 answers

ununderstandable behavior subprocess.Popen(cmd,stdout) and os.system(cmd)

I use an external command inside a python script using firstly: subprocess.Popen(cmd, stdout=subprocess.PIPE) then i get the stdout. The problem is that the result of this external command when executing it inside the script is not the same if i…
Inzo. Geo
  • 47
  • 4
0
votes
1 answer

DLV predicate not being derived

I have this simple DLV program consisting of few predicates and derivations rules. One of the rules is not being activated and I have no clue why since apparently all predicates exist. I have to admit I am no expert in DLV and a bit rusty since the…
rutex
  • 137
  • 3
  • 12
0
votes
0 answers

How to create a collection structure from a transformation function in datalog?

I would like to create a list from many pattern variables so I could compare the lists instead of the individual pattern variables. I.e. Instead of writing [:find ?attr :where ;; Many lines of data patterns and predicates ;; And now, the…
jgomo3
  • 1,153
  • 1
  • 13
  • 26
0
votes
1 answer

Cyclic relation in Datalog using SMTLib for z3

I would like to express this problem in the SMTLib Format and evaluate it using Z3. edge("som1","som3"). edge("som2","som4"). edge("som4","som1"). edge("som3","som4"). path(x,y) :- edge(x,y). % x and y are strings path(x,z) :- edge(x,y),…
Inzo. Geo
  • 47
  • 4
0
votes
1 answer

Count ones in BitVec in Z3 with Datalog input format

Is there a compact way of counting the number of bits that are set to 1 in a BitVec in Z3 using Datalog input format? $ z3 -h # most of the lines below omited for clarity Input format: -dl use parser for Datalog input format. The…
km9c3uwc
  • 51
  • 5
0
votes
0 answers

acyclic relation in bddbddb

I'm using Z3 to evaluate datalog programmes write using the bddbddb format (http://bddbddb.sourceforge.net/). How to express the fact that a relation is acyclic in bddbddb format ? I mean a rule such this one in datalog :- rel(X,Y),…
Josep Ng
  • 43
  • 7
0
votes
1 answer

racket datalog - is '>' supported?

Suppose racket's datalog code: #lang datalog price(a, 1). a1(A) :- price(A, Price), Price > 0. a1(A)? I would expect result: a1(a) I receive an error: prices_datalog.rkt:4:32: datalog: Unexpected token IDENTIFIER in: ">" How can I solve this…
Jaro
  • 3,799
  • 5
  • 31
  • 47
0
votes
0 answers

Antlr Grammar Token not being recognized

Hello I need help with antlr4 grammar. I have been trying to create a parser for Datalog grammar. This is just a small snippet of the whole code. Whatever I try to parse its being recognized as Uppercase or Lowercase. The predicate token is not…
Ajay Santhosh
  • 19
  • 1
  • 1
  • 5
0
votes
2 answers

Building sequence in datalog

I'm using a version of datalog with negation. I'm trying to write a program that assigns increasing sequence numbers of each row in a relation. Example: Given some EDB items("a", "b") items("a", "c") items("b", "b") I'd like to be able to generate…
Noah Watkins
  • 5,446
  • 3
  • 34
  • 47
0
votes
2 answers

Datalog: Why does (X==False) & (Y==not(X)) not evaluate?

I'm using pyDatalog (in Python 2.7). Using an arithmetic function like +, I can refer to an earlier bound variable: >>> (X==1) & (Y==X+1) [(1, 2)] But I cannot use the boolean not operator the same way: >>> not(False) True >>> (X==False) &…
Jeffrey Benjamin Brown
  • 3,427
  • 2
  • 28
  • 40
0
votes
1 answer

Best way to practise Datalog?

What is the best way to practice Datalog? Should I practice in pyDatalog? Or should I go with Prolog? (but isnt the syntax different for Datalog and Prolog?) Thank you.
Susha Suresh
  • 65
  • 1
  • 1
  • 8
0
votes
1 answer

Datalog code not working in Racket

I am trying to port this Prolog code to Datalog in Racket, using example at bottom of this page. #lang datalog edge(a, b). edge(b, c). edge(c, d). edge(d, a). path(X, Y) :- edge(X, Y). path(X, Y) :- edge(X, Z), path(Z, Y). path(X,…
rnso
  • 23,686
  • 25
  • 112
  • 234
0
votes
1 answer

How to create arithmetic predicates in pyDatalog?

how do I translate this kind of arithmetic predicate to a legal pyDatalog predicate? add(X, Y, Z) ← X + Y = Z for example: ?add(5, 7, Z). the answer should be: add(5, 7, 12). Thanks!
user2199630
  • 203
  • 1
  • 2
  • 12
0
votes
1 answer

How to create dynamic arithmetic facts in pyDatalog?

I need to create a simple Datalog machine (Which means that my input are 2 files: 1. facts , 2. rules.) I'm currently using pyDatalog package. I need to parse the facts and create terms dynamically. from pyDatalog's tutorial I've found this example…
user2199630
  • 203
  • 1
  • 2
  • 12