Questions tagged [pydatalog]

A pure-python implementation of Datalog, a truly declarative language derived from Prolog.

A pure- implementation of , a truly declarative language derived from .

pyDatalog adds the logic programming paradigm to Python's extensive toolbox, in a pythonic way.

Logic programmers can now use the extensive standard library of Python, and Python programmers can now express complex algorithms quickly.

Datalog is a truly declarative language derived from Prolog, with strong academic foundations.

Datalog excels at managing complexity. Datalog programs are shorter than their Python equivalent, and Datalog statements can be specified in any order, as simply as formula in a spreadsheet.

In particular, Datalog can be used for: - simulating intelligent behavior (for games or expert systems), - querying complex sets of related information (e.g. in data integration or Natural Language Processing), - performing recursive algorithms (e.g. on hierarchical data structure)

pyDatalog is derived from previous work by John D. Ramsdell.

It is an open-source project (LGPL) lead by Pierre Carbonnelle (in Belgium). It is inspired by LogicBlox.

25 questions
3
votes
1 answer

PyDatalog: list of values in answer

In PyDatalog I have defined the following assertions: #stations assert_fact('station', 'A' ,'yellow') assert_fact('station', 'B' ,'yellow') assert_fact('station', 'C' ,'yellow') assert_fact('station', 'D' ,'yellow') #sections assert_fact('stretch',…
Ignasi
  • 77
  • 1
  • 9
2
votes
0 answers

Am I entering an infinite recursive loop?

I had written a program in Prolog and I want to reproduce the results in python using pyDatalog. Below is a snippet of my program. To give an overview of my problem, I have the nodes('a','b','c' and 'd') connected by arrows ('w1,'w2','w3', and…
njemal
  • 87
  • 9
2
votes
0 answers

How to create function symbols dynamically in pyDatalog?

For example I have this kind of rules in Datalog: How do I create these rules dynamically in pyDatalog using "load"? Thanks!
user2199630
  • 203
  • 1
  • 2
  • 12
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

Using boolean operators in pyDatalog

I attempted to create a predicate in pyDatalog using the == operator, but the definition of flammable[X] appears to be invalid: from pyDatalog import pyDatalog pyDatalog.create_terms('flammable, notFlammable, X, Y') flammable[X] = ((X == 'wood') or…
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
2
votes
1 answer

Using pyDatalog for constraint stores

Consider the following rules: pyDatalog.create_atoms('X') pyDatalog.create_atoms('Y') pyDatalog.create_atoms('a') pyDatalog.create_atoms('b') b(X,1) <= (X<0) b(X,Y) <= (X==1) & (Y>0) a(X,Y) <= b(X,Y) & (X>0) And the problem of finding the…
Andres
  • 33
  • 3
1
vote
1 answer

Is there another way to use PyDataLog in CherryPy than the conventional way of using PyDataLog?

I am getting error like this below in the 500 internal server error page. File "/usr/local/lib/python3.5/dist-packages/pyDatalog/pyParser.py", line 388, in __call__ literal = Literal.make(self._pyD_name, tuple(args), kwargs) File…
Enkum
  • 635
  • 8
  • 22
1
vote
0 answers

Why is pyDatalog not terminating?

I'm taking a look at pydatalog and I created this quick conversion program loosely based on this blog entry: convert_length.py: from pyDatalog import pyDatalog pyDatalog.create_terms(','.join(( 'scale', 'convert', 'From', 'To', …
Paul Whipp
  • 16,028
  • 4
  • 42
  • 54
1
vote
2 answers

Logical Disjunct with PyDatalog

I don't seem to be able to write (pseudo-code): Print X and Y for all X,Y where X==True and Y==True or Y==False >>> from pyDatalog import pyDatalog >>> pyDatalog.create_terms('X,Y') >>> print((X==True) X ---- True >>> print((X==True) &…
Goodies
  • 4,439
  • 3
  • 31
  • 57
1
vote
1 answer

pyDatalog: handling unbound variables in a custom predicate

I'm writing a pyDatalog program to analyse weather data from Weather Underground (just as a demo for myself and others in the company at the moment). I have written a custom predicate resolver which returns readings between a start and end time: #…
highfellow
  • 35
  • 8
1
vote
1 answer

Loading a datalog program in a file into pyDatalog

I am trying to use the pyDatalog.load() method to load a small pyDatalog program. For example, I am loading the factorial sample from https://sites.google.com/site/pydatalog/ from pyDatalog import pyDatalog pyDatalog.create_atoms('factorial, N, F')…
Andres
  • 33
  • 3
0
votes
0 answers

Can I get a single answer in pydatalog ask?

I'm using pydatalog to solve a path-planning problem (just an example). I want one path from the begin state to the end state, i.e. one answer. As far as I can tell, ask() yields a list of all answers and I would like to generate the answers…
0
votes
0 answers

what is the item followed by square bracket in prolog? A relation, a variable, or a function...?

I am new to prolog, and I was trying to write rules for shortest path finding, I tried many times writing rules like path(X, Y) := ... and they never work as intented, until I find these rules (path[X,Y]==P) <= ((path[X,Z]==P2) & nextTo(Z,Y) …
0
votes
1 answer

Pydatalog, Can't print right side of rules

Following my last post with no answer, and because I'm stuck by this (by the way I have other question =I don't know if Pydatalog conceptor,Mr Carbonnelle, is still answerring on this site ??) So it would be nice if someone can help, and I will try…
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
1
2