Resin reasoning · ProMis mission design · CoFi tracking · CoCo control
Reactive Knowledge Representation and Asynchronous Reasoning
Simon Kohaut, Benedict Flade, Julian Eggert, Kristian Kersting, Devendra Singh Dhami
Paper · Project Page · Citation
Resin is a probabilistic first-order logic programming language for building reactive inference pipelines over continuous, asynchronous data streams. Resin programs are compiled via Answer Set Programming (ASP) into Reactive Circuits: vectorised, self-adapting computation graphs that perform Algebraic Model Counting (AMC) in real time.
- Resin merges probabilistic first-order logic with reactive programming: programs declare asynchronous data streams as sources and query targets over them.
- Reactive Circuits are time-dynamic DAGs over Algebraic Circuits that adapt their own structure to the estimated Frequency of Change of each input, as in the animation above.
- Exact and incremental: inference is partitioned into individually memoized sub-problems, so a new input only re-evaluates the parts of the model it affects.
The core library is written in Rust. A Python package (pyresin) is published to PyPI and built with Maturin.
For employing Resin with Python, you can install the pre-compiled package via PyPI:
pip install pyresinTo use Resin with Rust, you may clone this repository and build locally with cargo (see Development).
import time
from resin import Resin
# Sources are asynchronous signals; rules and targets are probabilistic logic
resin = Resin.compile("""
rain <- source("/weather/rain", Probability).
sprinkler <- source("/garden/sprinkler", Boolean).
wet if rain.
wet if sprinkler.
wet -> target("/garden/wet").
""")
resin.make_writer("/weather/rain").write([0.3])
resin.make_writer("/garden/sprinkler").write(False)
time.sleep(0.05) # writers deliver values asynchronously
circuit = resin.get_reactive_circuit()
print(circuit.update()) # {'/garden/wet': array([0.3])}Writing a new value only recomputes the parts of the circuit that depend on it, and circuit.adapt(...) restructures the circuit by how often each source changes.
![]() |
![]() |
![]() |
| ProMis Probabilistic mission design: where an agent's rules are satisfied, kept up to date as the world changes. |
CoFi The Constitutional Filter: tracking agents by trusting them to follow their rules. |
CoCo The Constitutional Controller: steering agents to comply despite their own control inaccuracies. |
- The Resin Language: sources, rules, targets and their semantics.
- Semirings: probabilities, most probable explanations, fuzzy logic, satisfiability, gradients, and critical explanations.
- Learning: fitting clause probabilities and training networks through Resin.
- Python API: compiling programs, writing signals, updating targets and adapting Reactive Circuits.
- Development: building from source, running checks and the pre-commit hook.
See LICENSE.md.
If you find our work useful, please consider citing the paper Reactive Knowledge Representation and Asynchronous Reasoning (also available via Cite this repository on GitHub):
@article{kohaut2026reactive,
title={Reactive Knowledge Representation and Asynchronous Reasoning},
author={Kohaut, Simon and Flade, Benedict and Eggert, Julian and Kersting, Kristian and Dhami, Devendra Singh},
journal={arXiv preprint arXiv:2602.05625},
year={2026},
doi={10.48550/arXiv.2602.05625},
url={https://arxiv.org/abs/2602.05625}
}

