user2199630
user2199630

Reputation: 223

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 for loading facts:

load("""
ancestor(X,Y) <= parent(X,Y)
ancestor(X,Y) <= parent(X,Z) & ancestor(Z,Y)
""")  

in this case I just need to parse strings from a file.

How can I dynamically load an arithmetic term? (for example: SUM(X,Y,Z)-> Z = X + Y)

Thanks!

Upvotes: 0

Views: 366

Answers (1)

Pierre Carbonnelle
Pierre Carbonnelle

Reputation: 2625

How about :

load("""
sum(X,Y) <= (Z == X + Y)
""") 

?

Upvotes: 1

Related Questions