PyReason
What is neuro-symbolic logic?
Neural networks learn patterns from data. They are strong at perception, such as reading text or recognising an image, but the reasons behind their answers are hard to inspect, and they cannot be relied on to follow an explicit rule.
Symbolic logic works the other way round. It reasons with explicit facts and rules that people can read, and every conclusion can be traced back to the rules that produced it. On its own, though, it cannot learn from raw data.
Neuro-symbolic AI combines the two. A neural model turns raw data into facts, often with a measure of confidence, and a logic engine reasons over those facts with readable rules. The result learns from data and can still explain itself.
| Neural | Symbolic | Neuro-symbolic | |
|---|---|---|---|
| Learns from data | Yes | No | Yes |
| Follows explicit rules | No | Yes | Yes |
| Explains its conclusions | Rarely | Yes | Yes |
What PyReason is
PyReason™ is open-source Python software for explainable reasoning over graphs, built on annotated, temporal and open-world logic. It is developed by Lab V2 at Syracuse University and released under the BSD-2-Clause licence.
Graph-based reasoning
Applies logical rules to knowledge graphs and other networks, loaded from GraphML or NetworkX.
Annotated logic
Every fact carries a confidence interval between 0 and 1 rather than a plain true or false: [1, 1] is true, [0, 0] is false and [0, 1] is unknown.
Open-world reasoning
Anything not stated is treated as unknown, not as false.
Temporal rules
Rules can say "if A holds, then B holds after n time steps".
Explainable by design
It keeps a trace of every inference step behind each conclusion.
Works with machine learning
Predictions from a PyTorch classifier can be added as facts and reasoned over with rules. This is where PyReason is neuro-symbolic. See the machine-learning integration guide.
pip install pyreasonPython 3.8 to 3.13.
PyReason™ is a trademark of the Arizona Board of Regents / Arizona State University. Rational Agents is not affiliated with Lab V2.
How to support PyReason
Star it on GitHub
Stars help other developers find the project.
Try it and read the docs
Install the package from PyPI and work through the documentation.
Report bugs and request features
Open an issue when something breaks or a feature is missing.
Ask questions and share what you built
GitHub Discussions is the place for questions, ideas and projects made with PyReason.
Contribute code
Start with the contributing guide: pre-commit hooks run the unit tests on every commit and the functional tests on every push.
Cite the paper
If PyReason helps your research, cite the AAAI Spring Symposium paper.
@inproceedings{aditya_pyreason_2023, title = {{PyReason}: Software for Open World Temporal Logic}, booktitle = {{AAAI} Spring Symposium}, author = {Aditya, Dyuman and Mukherji, Kaustuv and Balasubramanian, Srikar and Chaudhary, Abhiraj and Shakarian, Paulo}, year = {2023}}Explore related work
PyReason Gym: PyReason in a grid-world reinforcement-learning setting.