A simple programming language and inference engine powered by backward chaining.
Project description
A simple programming language and inference engine powered by backward chaining. When given rules and facts, it will deduce new information.
Installation
pip install backward
Usage
>>> from backward import Backward
>>> ctx = Backward()
>>> _ = ctx.evaluate("a => b")
>>> _ = ctx.evaluate("b => c")
>>> _ = ctx.evaluate("= a") # a is true
>>> ctx.evaluate("a b c") # are b and c true?
[True, True, True]
You can also type python -m backward into your shell to enter an interactive REPL.
Syntax
C => E # C implies E A & B & C => D # A and B and C implies D A | B => C # A or B implies C A & !B => F # A and not B implies F C | !G => H # C or not G implies H V ^ W => X # V xor W implies X A & B => Y & Z # A and B implies Y and Z = A B G # Initial facts : A, B and G are true. All others are false. G V X # What are G, V and X ?
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
backward-0.0.3.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file backward-0.0.3.tar.gz
.
File metadata
- Download URL: backward-0.0.3.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36b0a6f72e3144387962b491f2bc74d0fb33e722ff8204d6b238153705d3ea65 |
|
MD5 | 826081ab456941374d7d886b2547c7f5 |
|
BLAKE2b-256 | 3b5c001b526a2652b110136ae0d2815569d17ea815efae51d45e86259225d655 |
File details
Details for the file backward-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: backward-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95fb077deff478b346053ac013a02b5b2a4d1cf977fa0687257ec4a312297674 |
|
MD5 | f963956b907f512c73cac96b0aa30700 |
|
BLAKE2b-256 | f1ad2796dbf113dab6efe8bb55d563c291efe3dd12b59e1204c78b96d9135432 |