Active logic meets Prolog — three-valued reasoning engine
Project description
Proact
pip install proact-py
Prolog like language for decision making and parallel reasoning under uncertainty. Proact adds a continuation state to Prolog's truth values, signalling uncertainty.
Every goal returns a status (3 state value). Conjunction is a sequence. Disjunction is a selector. Backtracking only triggers on failure — cont and done cut the search. Between ticks, queries returning cont are automatically re-evaluated while the database persists, giving you a stateless tick loop for free.
Applications:
-
Reasoning under uncertainty. The three values map onto epistemic states: verified, undetermined, refuted. A conjunction of checks naturally implements iterative deepening — work focuses on the earliest unresolved premise. Unary operators give you cognitive control:
demotemeans "don't commit yet" (done→cont);promotemeans "don't give up yet" (fail→cont). This is relevant to validation layers for LLM reasoning, where forcing every check into true/false is lossy compression of the actual epistemic state. -
Behavior modeling. Reactive agents, planners, robot controllers — anything where logic meets time. Prolog gives you unification, backtracking, and pattern matching. Active logic adds temporal flow. You get behavior trees with the expressiveness of logic programming, without the trees.
Python integration
from proact import Proact
p = Proact()
p.add("mortal(X) :- human(X). human(socrates).")
print(p.query("mortal(socrates)")) # Result(status='done')
Using Proact in terminal
./proact # interactive mode
./proact file.pa # load file, then interactive mode
./proact file.pa -e "goal." # evaluate goal and exit
./proact --max-ticks 100 -e "g." # limit ticks; run until resolved or budget exhausted
Tutorials
- Reasoning under uncertainty — from predicate logic to three-valued epistemics
- Behavior modeling — behavior trees via logic programming
The Transform
Conjunction (,) — Active logic AND / Sequence
fail cont done
fail fail fail fail
cont cont cont cont
done fail cont done
If the left goal is cont, the whole conjunction is cont — don't evaluate the right side yet.
Disjunction (;) — Active logic OR / Selector
fail cont done
fail fail cont done
cont cont cont cont
done done done done
If the left goal is done or cont, don't try alternatives.
Clause resolution
Multiple clauses for the same predicate provide choice points. Backtracking occurs only on fail — if a clause body returns cont or done, stop searching.
Tick loop
Queries returning cont are automatically re-evaluated on the next tick with a fresh environment. The database (asserted facts) persists between ticks.
Built-ins
| Predicate | Status | Description |
|---|---|---|
done / true |
done | Always succeeds |
fail / false |
fail | Always fails |
cont |
cont | Always continues |
inv(G) / \+ G |
swap done/fail, keep cont | Inverter |
condone(G) |
fail→done | Forgive failure |
promote(G) |
fail→cont, cont→done | Optimistic |
demote(G) |
done→cont, cont→fail | Pessimistic |
par_any(A,B) |
max(A,B) | Lenient parallel |
par_all(A,B) |
min(A,B) | Strict parallel |
tick(N) |
done | Unify N with current tick |
Plus standard Prolog: write/1, writeln/1, nl, assert/1, retract/1, is/2, =/2, \=/2, </2, >/2, >=/2, =</2, call/1, consult/1.
Examples
Wait N ticks, then succeed
wait(N) :- tick(T), T >= N.
wait(N) :- tick(T), T < N, cont.
?- wait(3), writeln(hello).
[tick 0] cont
[tick 1] cont
[tick 2] cont
hello
done.
Counter (stateful, using assert/retract)
:- assert(count(0)).
count_to(Target) :- count(N), N >= Target.
count_to(Target) :-
count(N), N < Target,
retract(count(N)), N1 is N + 1, assert(count(N1)),
cont.
Reactive behavior (condition-gated sequence)
:- assert(agent_pos(0)).
move_to(X) :- agent_pos(P), P =:= X.
move_to(X) :- agent_pos(P), P < X,
retract(agent_pos(P)), P1 is P + 1, assert(agent_pos(P1)), cont.
patrol :-
agent_pos(P), P < 3, move_to(3), cont.
patrol :-
agent_pos(P), P >= 3, P < 5, move_to(5), cont.
patrol :-
agent_pos(P), P >= 5.
Reasoning under uncertainty
% reason.pa — three-valued validation for multi-step arguments
:- assert(known(premise_a)).
:- assert(investigation(premise_b, 2)).
:- assert(investigation(premise_c, 1)).
check(P) :- known(P).
check(P) :- known_false(P), fail.
check(P) :-
investigation(P, N), N > 0,
retract(investigation(P, N)), N1 is N - 1,
(N1 > 0 -> assert(investigation(P, N1)) ; assert(known(P))),
cont.
argument :- check(premise_a), check(premise_b), check(premise_c).
The conjunction is the search strategy — it focuses work on the earliest unresolved premise and doesn't waste computation on steps whose preconditions haven't been met:
[tick 0] a=done, b=cont → cont (c never reached)
[tick 1] a=done, b=done, c=cont → cont (work shifts to c)
[tick 2] a=done, b=done, c=done → done
The epistemic operators give cognitive control over the validation:
cautious(X) :- demote(check(X)). % "verified but needs review" (done→cont)
keep_exploring(X) :- promote(check(X)). % "refuted but try harder" (fail→cont)
viable_theory :- par_any(hyp_a, hyp_b). % first hypothesis verified wins
Relation to active-logic
Proact implements the core active logic operators:
| C# (activelogic-cs) | Proact | BT equivalent |
|---|---|---|
status && status |
Goal, Goal |
Sequence |
status || status |
Goal ; Goal |
Selector |
+ (lenient) |
par_any(A, B) |
Parallel (any) |
* (strict) |
par_all(A, B) |
Parallel (all) |
!status |
inv(G) |
Inverter |
~status |
condone(G) |
Condone |
+status (unary) |
promote(G) |
Promoter |
-status (unary) |
demote(G) |
Demoter |
cont |
cont |
Running |
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file proact_py-0.2.1.tar.gz.
File metadata
- Download URL: proact_py-0.2.1.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41f3f0aa3b13f0a68fe0333d14a8e08f75bec4b18a39e8a72044d9c2a01f795a
|
|
| MD5 |
c379a67256978622119d39309bbbedfa
|
|
| BLAKE2b-256 |
904ca07ae7ff858d66da17033df7014cafb1d982c159aa7dad3fdde86a4e17f8
|
Provenance
The following attestation bundles were made for proact_py-0.2.1.tar.gz:
Publisher:
release.yml on eelstork/proact
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
proact_py-0.2.1.tar.gz -
Subject digest:
41f3f0aa3b13f0a68fe0333d14a8e08f75bec4b18a39e8a72044d9c2a01f795a - Sigstore transparency entry: 1156960287
- Sigstore integration time:
-
Permalink:
eelstork/proact@f0f73917e51eabc09c0d6c98e57713a222107d5d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/eelstork
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f0f73917e51eabc09c0d6c98e57713a222107d5d -
Trigger Event:
push
-
Statement type:
File details
Details for the file proact_py-0.2.1-py3-none-win_amd64.whl.
File metadata
- Download URL: proact_py-0.2.1-py3-none-win_amd64.whl
- Upload date:
- Size: 101.1 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
638f56c64a2a86d8aa0cdfd577e1001cf6d9a16c767b17445634629d4367e771
|
|
| MD5 |
168c641e7ce6dc4ea0a7c5b6c18ba73e
|
|
| BLAKE2b-256 |
c71fe851561493ed3703f5ca2463cb7a1f01df42f51ffbe4fc15495b40ac1229
|
Provenance
The following attestation bundles were made for proact_py-0.2.1-py3-none-win_amd64.whl:
Publisher:
release.yml on eelstork/proact
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
proact_py-0.2.1-py3-none-win_amd64.whl -
Subject digest:
638f56c64a2a86d8aa0cdfd577e1001cf6d9a16c767b17445634629d4367e771 - Sigstore transparency entry: 1156960369
- Sigstore integration time:
-
Permalink:
eelstork/proact@f0f73917e51eabc09c0d6c98e57713a222107d5d -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/eelstork
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f0f73917e51eabc09c0d6c98e57713a222107d5d -
Trigger Event:
push
-
Statement type: