PyReason is a powerful Python-based temporal first-order logic explainable AI system supporting multi-step inference, uncertainty, open-world reasoning, and graph-based syntax.

Read the latest PyReason docs here:

PyReason-as-a-Sim now available that leverages PyReason as a simulator in a reinforcement learning framework.

Code for PyReason-as-a-Sim (integration with DQN):
Code for PyReason Gym:

• Supports generalized annotated logic with temporal, graphical and uncertainty extensions, capturing a wide variety of fuzzy, real-valued, interval, and temporal logics

• Modern Python-based system supporting reasoning on graph-based data structures (e.g., exported from Neo4j, GraphML, etc.)

• Rule-based reasoning in a manner that support uncertainty, open-world reasoning, non-ground rules, quantification, etc., agnostic to selection of t-norm, etc.

• Fast, highly optimized, correct fixpoint-based deduction allows for explainable AI reasoning, scales to graphs with over 30 million edges

Read the PyReason paper (w. supplement):

Introductory blog post:

PyReason docs:

Open source Python library is available at:

PyReason codebase can be found at:

Install with pip:
pip install pyreason

Technical talk:

Introduction to PyReason v 1.1

Bibtex citation:
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} }

PyReason-as-a-Sim for Deep Reinforcement Learning

PyReason can function as a semantic proxy for simulation in a reinforcement learning (RL) framework.  We showed that inference with PyReason logic program can provide a three order-of-magnitude speedup when compared with native simulations (we studied AFSIM and Starcraft2) while providing comparable reward and win rate (we found that PyReason-trained agents actually performed better than expected in both AFSIM and Starcraft2).  However, the benefits of our semantic proxy go well beyond performance.  The use of temporal logic programming has two crucial beneficial by-products such as symbolic explainability and modularity.  PyReason provides an explainable symbolic trace that captures the evolution of the environment in a precise manner while modularity allows us to add or remove aspects of the logic program – allowing for adjustments to the simulation based on a library of behaviors. PyReason is well-suited to model simulated environments for other reasons – namely the ability to directly capture non-Markovian relationships and the open-world nature (defaults are “uncertain” instead of true or false).  We have demonstrated that agents can be trained using standard RL techniques such as DQN using this framework

Code for PyReason-as-a-Sim (integration with DQN):
Code for PyReason Gym: