Registry / data / pylog
library1.1pypypi✓ verified 24d ago

Pylog is a lightweight Python library that implements core features of Prolog, enabling logic programming paradigms within Python. It allows defining facts and rules to perform simple logical deductions and goal-oriented queries. The current stable version is 1.1, with an infrequent release cadence focusing on stability and minor enhancements.

pip install pylog
INSTALL
IMPORT
SIG · PYLOG
P
pylog
datapythonv1.1
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

name
from pylog import name
from pylog.pylog import facts, rules, goal, run

This quickstart demonstrates how to define facts, create a simple rule using other predicates, set a goal, and retrieve solutions using the `run()` function. It showcases basic logical inference capabilities.

from pylog.pylog import facts, rules, goal, run # Define facts facts("human(socrates)") facts("human(plato)") # Define a rule: All humans are mortal # The body is a list of predicates that must be true for the head to be true. rules("mortal(X)", ["human(X)"]) # Define a goal to find all mortal beings goal("mortal(X)") # Run the inference engine to find solutions solutions = run() print("Solutions for mortal(X):") for s in solutions: print(s) # Example for a specific query goal("mortal(socrates)") solutions_socrates = run() print("\nSolutions for mortal(socrates):") for s in solutions_socrates: print(s)
Debug
Known issues
breakingThe project underwent significant restructuring around versions `1.0`/`1.1` (including the 'test1' release), which changed the import paths for core functions.
fix
Update all import statements. Instead of `import pylog` or `from pylog import symbol`, use `from pylog.pylog import symbol` for functions like `facts`, `rules`, `goal`, and `run`.
affects: <1.0
gotchaPylog heavily relies on global state for its `facts` and `rules` knowledge base. Calls to `facts()` and `rules()` modify a shared global state.
fix
Be aware that the knowledge base is global. For applications requiring isolated logical contexts, manually manage state or consider external mechanisms, as `pylog` does not provide explicit APIs for context management or resetting the knowledge base directly.
affects: All versions
gotchaPylog implements a subset of Prolog's features. It may not support advanced Prolog constructs like complex data structures, explicit cut/fail predicates, or certain types of recursion with optimal performance.
fix
Consult the library's GitHub repository for current capabilities and examples. Do not expect full Prolog compatibility; plan your logic programming tasks accordingly within the library's demonstrated scope.
affects: All versions
Upgrade
Version history
1.1latest on PyPI · released Sep 7, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
16 hits · last 30 days
node
12
Resources
pylog — pip install pylog · libregistry