Skip to content
simon-kohautPublic

About

Reactive probabilistic logic programming with Reactive Circuits: exact, incremental inference over asynchronous data streams.

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Repository files navigation

Resin — Reactive Signal Inference

arXiv CI Release PyPI version Python versions License: BSD-3-Clause

Resin reasoning · ProMis mission design · CoFi tracking · CoCo control

Animation: four Reactive Circuits start as flat formulas over shared input leaves, grow downward as leaves are sorted by update frequency, and merge identical sub-circuits into a shared graph. Leaf updates travel upward as pulses; once adapted, frequent updates only touch the top.

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.

Highlights

  • 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.

Installation

For employing Resin with Python, you can install the pre-compiled package via PyPI:

pip install pyresin

To use Resin with Rust, you may clone this repository and build locally with cargo (see Development).

Quick Start

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.

Built on Resin

ProMis: a reactive mission landscape over New York City with live vessels and drones CoFi: tracking a drone through an obstacle course by its constitution CoCo: steering drones through an obstacle course despite their control inaccuracies
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.

Documentation

  • 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.

License

See LICENSE.md.

Citation

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}
}

About

Reactive probabilistic logic programming with Reactive Circuits: exact, incremental inference over asynchronous data streams.

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages