A Prolog interpreter implemented in Go and Python. WAM-based engine with ISO compliance, modules, streams, rational arithmetic, MCP server, and interactive REPL. Zero external dependencies.
| Go | Python | |
|---|---|---|
| Directory | go-prolog/ |
py-prolog/ |
| Install | go build -o uc-prolog . |
pip install uc-prolog |
| Run | ./uc-prolog --repl |
python3 -m uc_prolog --repl |
| Embed | import "github.com/cuber-it/uc-prolog/go-prolog/prolog" |
from uc_prolog import Engine |
| MCP Server | ./uc-prolog --port 4001 |
python3 -m uc_prolog --mcp |
| Binary | Single static binary | Pure Python, no C extensions |
Both implementations share the same Prolog knowledge base (core/) and pass the same ISO compliance test suite (tests/).
parent(tom, bob).
parent(bob, ann).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
?- grandparent(tom, X).
X = ann.from uc_prolog import Engine
engine = Engine()
engine.eval("parent(tom, bob).")
engine.eval("parent(bob, ann).")
engine.eval("grandparent(X, Z) :- parent(X, Y), parent(Y, Z).")
result = engine.eval("?- grandparent(tom, X).")
# result: "X = ann."Expose Prolog as an MCP tool server — connect any LLM agent to a live knowledge base:
# Install with MCP support:
pip install uc-prolog[mcp]
# Start MCP server (stdio — for Claude Desktop etc.):
python3 -m uc_prolog --mcp
# Start MCP server (HTTP/SSE — for remote clients):
python3 -m uc_prolog --mcp --port 4003Available MCP tools: prolog_eval, prolog_query, prolog_assert, prolog_load_file, prolog_status.
uc-prolog/
core/ shared Prolog knowledge base (.prolog files)
base.prolog standard predicates: member, append, length, ...
frames.prolog frame-based knowledge representation
refs.prolog reference/pointer utilities
tests/ shared ISO compliance test suite (444 tests)
iso_unification.plg
iso_arithmetic.plg
iso_control.plg
iso_lists.plg
iso_modules.plg
iso_streams.plg
iso_rational.plg
... (20 test files)
web/ shared web GUI (index.html)
go-prolog/ Go reference implementation
py-prolog/ Python implementation (PyPI: uc-prolog)
444 tests across 20 ISO Prolog categories — both implementations pass all of them:
| Category | Tests |
|---|---|
| Unification | ✅ |
| Arithmetic | ✅ |
| Control flow | ✅ |
| Type checks | ✅ |
| Lists | ✅ |
| Database (assert/retract) | ✅ |
| DCG | ✅ |
| Modules | ✅ |
| Stream I/O | ✅ |
| Rational arithmetic | ✅ |
| Flags | ✅ |
Both implementations serve the same HTTP API:
POST /api/eval { "code": "parent(tom, bob)." }
POST /api/query { "goal": "parent(tom, X)" }
GET /api/listing list all defined predicates
POST /api/reset clear knowledge base
GET /api/events SSE stream
# Go
cd go-prolog && go test ./prolog/ -v
# Python
cd py-prolog && python3 -m pytest tests/ -vApache 2.0 — Ulrich Cuber / cuber IT service