Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

A small prolog implementation for embedded expert systems

Project description

# PyExpert 0.0.1

This is a small embeddable Prolog interpreter in Python3, designed primarily for
implementing explainable expert systems.



Usage:

```python

# Imports
from weak.prolog import prolog_driver,prolog_default_env,prolog_next_solution,prolog_core_library

# Initialise environment
env = prolog_default_env()

# Execute query
ret,vars = prolog_driver(env, '? append(A, B, [x,y]).')
print(vars)

# Inspect all the remaining solutions
while prolog_next_solution(env):
print(vars)

```

# Weak sets

The main feature of this implementation is a `weak set` - a value that unifies
with any other weak set, resulting in a new set containing elements of both
sets. This is useful for implementing certain kinds of type systems and for
higher level hacks, such as tracing a Prolog execution (e.g., for a
human-readable narration of an expert system decision), implementing
constraints, etc.

For example:

```prolog
? weak(a,W1), weak(b,W1), weak(c,W2), W1=W2.
```

results in `W1=W2=[a,b,c]`

See `weak/narrate.py` for an example of an instrumentation of a Prolog code for
producing execution traces, or a "narration", which can then be used to
generate, for example, a plain English narration of the expert system thought
process.

See `tests/demo.py` for an example of constructing an explainable expert system.


Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyexpert-0.0.1-py2.py3-none-any.whl (18.4 kB) Copy SHA256 hash SHA256 Wheel py2.py3
pyexpert-0.0.1.tar.gz (16.3 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page