Skip to main content

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.

made-with-python PyPI-package-version PyPI-license PyPI-python-versions travis-ci PyPI-downloads-month

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.4.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

backward-0.0.4-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page