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
47
votes
4 answers

Forward Chaining vs Backward Chaining

What is one good for that the other's not in practice? I understand the theory of what they do, but what are their limitations and capabilities in practical use? I'm considering Drools vs a java prolog for a new AI project, but open to other…
gtrak
  • 5,598
  • 4
  • 32
  • 41
34
votes
2 answers

Datalog vs CLIPS vs Prolog

As many programmers I studied Prolog in university, but only very little. I understand that Prolog and Datalog are closely related, but Datalog is simpler? Also, I believe that I read that Datalog does not depend on ordering of the logic clauses,…
Eli Schneider
  • 4,903
  • 3
  • 28
  • 50
11
votes
3 answers

Possible to get enum value via Datomic pull syntax?

In the mbrainz sample data, the :artist/type is an enum. Is it possible to pull the value of the enum out of :db/ident and associate it as the value of the :artist/type key using pull syntax? This is as close as I could get: [:find (pull ?e…
Upgradingdave
  • 12,916
  • 10
  • 62
  • 72
11
votes
1 answer

How to sort result in a Datalog query

I am using datomic with play framework. Play is amazing and datomic is fast. So a good combination overall. Since, I am new to datomic (and datalog i.e. query language datomic uses), I am unable to sort my result ( like we do, order by in sql). For…
Dave Ranjan
  • 2,966
  • 24
  • 55
10
votes
2 answers

What is the difference between naive and semi naive evaluation?

I have been trying to implement an algorithm for the semi naive evaluation of a datalog program but couldn't get a straightforward answer anywhere that explains the difference in simple words. According to my understanding naive is a bottom up…
9
votes
2 answers

How to construct a query that matches exactly a vector of refs in DataScript?

Setup Consider the following DataScript database of films and cast, with data stolen from learndatalogtoday.org: the following code can be executed in a JVM/Clojure REPL or a ClojureScript REPL, as long as project.clj contains [datascript "0.15.0"]…
Ahmed Fasih
  • 6,458
  • 7
  • 54
  • 95
7
votes
1 answer

Datalog computational class?

Datalog is not Turing complete. But what is its computational class? Is it equivalent to Finite state machine or Pushdown machine (i.e. context free) ... or is it something in between?
7
votes
0 answers

Is datalog more efficient than SQL for column oriented databases?

Both Cascalog and Datomic have chosen to use Datalog (over SQL) as their query engine. Dave Thomas made the claim: Datalog is better than SQL for large queries in small amounts of space. My question is: Is datalog more efficient than SQL for…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
7
votes
1 answer

Datalog Stratification

So I'm trying to understand how Datalog works and one of the differences between it and Prolog is that it has stratification limitations placed upon negation and recursion. To quote Wikipedia: If a predicate P is positively derived from a…
J Bellamy
  • 159
  • 3
  • 7
6
votes
2 answers

Read text file line by line using timer

StreamReader sr = new StreamReader("C:/CR EZ Test/Log.txt"); //use with IF private void timer2_Tick(object sender, EventArgs e) { if ((line = sr.ReadLine()) != null) { //FileStream fs = File.Open("C:/CR EZ Test/Log.txt",…
RatherLogical
  • 310
  • 4
  • 15
6
votes
2 answers

Find entities whose ref-to-many attribute contains all elements of input

Suppose I have entity entry with ref-to-many attribute :entry/groups. How should I build a query to find entities whose :entry/groups attribute contains all of my input foreign ids? Next pseudocode will illustrate my question better: [2 3] ; having…
Twice_Twice
  • 527
  • 4
  • 16
6
votes
1 answer

How to express universal quantifier in the body of a datalog rule?

I want to use universal quantifier in the body of a predicate rule, i.e., something like A(x,y) <- ∀B(x,a), C(y,a). It means that only if for each a from C(y, a), B(x,a) always has x to match (x,a), then A(x,y) is true. Since in Datalog, every…
silverbullettt
  • 846
  • 1
  • 10
  • 13
6
votes
1 answer

Datalog patterns for changing data

I am considering using datalog as a database backend for an application I am writing, because I see potential to allow me to switch between representations easily without having to sacrifice my collected data or write a cumbersome…
luqui
  • 59,485
  • 12
  • 145
  • 204
5
votes
3 answers

translation from Datalog to SQL

I am still thinking on how to translate the recursivity of a Datalog program into SQL, such as P(x,y) <- Q(x,y). Q(x,y) <- P(x,z), A(y). where A/1 is an EDB predicate. This, there is a co-dependency between P and Q. For longer queries, how to solve…
zfm
  • 1,906
  • 2
  • 17
  • 28
5
votes
1 answer

Recursive Datalog queries for Datomic really slow

I'm currently evaluating Datomic for the use-case of storing and querying parsed symbols that form an ontology. In total there are 225122 symbols (entities) in the database (so it's a rather big ontology, but shouldn't be a big deal for a DB). The…
fricke
  • 1,330
  • 1
  • 11
  • 21
1
2 3
10 11