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.
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 | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyexpert-0.0.1.tar.gz
(16.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyexpert-0.0.1.tar.gz.
File metadata
- Download URL: pyexpert-0.0.1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
886b0c65017931e61104b0c6b01a85a43283d538b2dc26f8718283342fa24f6e
|
|
| MD5 |
267a554816d6fa231300b50b2a208bea
|
|
| BLAKE2b-256 |
c7d41bd024ae9479b562b64052de3691c6b6c7f919e55866a22800ed293defa7
|
File details
Details for the file pyexpert-0.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: pyexpert-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a4fd56728f96c4c37e0bc729b1f0c926cbb253e6c560015684e8c1c73120108
|
|
| MD5 |
adf369e763c1569eaa6714ee2cbb5002
|
|
| BLAKE2b-256 |
afa13db7eca4c4e54acf8adb0720f084bcd21aa297bd5f4319f8dfdec1007219
|