Datalog
The aria.datalog package provides a vendored pyDatalog runtime under
the ARIA namespace. It is a trimmed, runtime-oriented copy intended to keep
logic-programming support available inside the repository without depending on
an external top-level pyDatalog installation.
Overview
Use the package through:
from aria.datalog import pyDatalog
The main runtime surface lives in pyDatalog.py and supports common Datalog
operations such as declaring terms, asserting and retracting facts, loading
rules, and querying derived relations.
Representative operations include:
from aria.datalog import pyDatalog
pyDatalog.create_terms("X, Y, parent, ancestor")
pyDatalog.assert_fact("parent", "alice", "bob")
pyDatalog.assert_fact("parent", "bob", "carol")
pyDatalog.load("ancestor(X,Y) <= parent(X,Y)")
pyDatalog.load("ancestor(X,Y) <= parent(X,Z) & ancestor(Z,Y)")
print(pyDatalog.ask("ancestor('alice',Y)"))
Package Structure
Key files in aria/datalog include:
pyDatalog.py: public runtime APILogic.py: logic-engine state managementpyEngine.py: evaluation engine internalspyParser.py: parsing and query handlingAggregate.py: aggregate supportutil.py: utilities and exceptionsgrammar.txt: grammar reference
Status and Provenance
The top-level package README documents the intended status of this directory:
it is a flattened vendored copy of
pyDatalog;the upstream project is unmaintained;
ARIA keeps only the runtime-oriented pieces needed locally;
a small Python 3 compatibility adjustment replaces
inspect.getargspec()withinspect.signature().
Examples
The repository includes runnable examples under aria/datalog/examples.
From the repo root, you can run:
python aria/datalog/examples/tutorial_example.py
python aria/datalog/examples/datalog_example.py
python aria/datalog/examples/graph_example.py
python aria/datalog/examples/queens_example.py
python aria/datalog/examples/python_objects_example.py
These cover recursive family relations, employee-style Datalog facts and aggregates, graph reachability, the eight-queens problem, and querying Python objects through Datalog rules.
Further Reading
aria/datalog/README.mdfor ARIA-specific packaging notesaria/datalog/examples/README.mdfor the example maparia/datalog/UPSTREAM_README.mdfor upstream usage contextaria/datalog/UPSTREAM_LICENSEfor licensing information