Pre-built Prolog rule libraries that install into any Logic namespace in one call. Assert your facts, install a battery, and query its predicates immediately — no rules to write, no schemas to define.
Storing facts is easy. Writing the Prolog rules that reason over them — inventory weight limits, quest prerequisite chains, combat resolution — takes time, testing, and domain knowledge. Batteries solve this: curated, tested rule libraries that drop into your namespace and work immediately over the facts you've already asserted.
batteries.install_many
ids: ["inventory"], namespace: "my-game"
Prolog Engine
can_carry/2 · inventory_full/1
carrying_weight/2 · has_item/2
+ your own facts and rules
logic.query
can_carry(player1, legendary_axe)
→ true
Batteries live in the same Prolog engine as your facts. Installed predicates can call your
logic.assert facts and combine with your own logic.constrain rules.
Install multiple batteries into the same namespace and their predicates interoperate automatically.
Semantic search over the catalog by description, tag, or predicate name. Find what you need without knowing the exact ID.
Full predicate reference for any battery — signatures, parameter docs, and example queries — before you install.
Install one or more batteries in a single call. Rules are asserted immediately, persist cross-session, and all predicates share the namespace — batteries can call each other's rules.
List active batteries in a namespace with versions and predicate counts.
Diagnostic pass over an installed battery: every predicate is test-fired and classified — passing, waiting on facts, or not loaded — with concrete missing-fact hints.
Uninstall a battery and retract its rules. Your own asserted facts are left untouched.
Batteries in the probabilistic tier accept ProbLog-style weighted rules —
0.7::market_crash :- high_volatility. — and answer with exact probabilities:
psuccess(market_crash, P) combines every firing rule by noisy-or.
Layer prob-decide on top and best_action/2 picks the
expected-utility argmax across weighted outcomes. It runs identically on SWI and on
ISO-pinned (Scryer) namespaces, and the explain battery's why/2
shows exactly which facts support any conclusion.
35 modules across four categories — Reasoning, Probabilistic, Games, and Business.
Search the catalog with batteries.search, browse modules on
GitHub ↗,
or explore highlights:
| Battery | Key predicates |
|---|---|
|
fixpoint
Recursive rules that terminate
|
fixpoint_solve/2, fixpoint_answers/3 —
bottom-up Datalog saturation; transitive closure over cyclic data works verbatim
|
|
explain
Provenance for conclusions
|
why/2, explain/2 —
the facts supporting any answer, or full proof trees
|
|
fsm
State machine reasoning
|
fsm_reachable/3, fsm_deterministic/1,
fsm_shortest_path/4, fsm_stuck/1
|
|
prob-core-iso
ProbLog-lite runtime
|
psuccess/2, pnot/2, pand/2, expected/3
|
|
prob-decide
Decision theory
|
eu/2, best_action/2 —
expected utility and argmax over weighted outcomes
|
|
inventory
Items & weight limits
|
can_carry/2, inventory_full/1, carrying_weight/2
|
|
quests
Quest chains & objectives
|
quest_available/2, next_objective/3, can_turn_in/2
|
|
lead-scoring
Weighted lead qualification
|
lead_score/2, lead_tier/2, disqualified/2
|
Batteries are plain ISO/SWI Prolog files, so they also work outside DataGrout: the
battery CLI ↗
installs them into any swipl or scryer-prolog project with a
checksummed lock file — cargo install logic-batteries.
Batteries extend Logic — installed predicates are queryable via logic.query
and participate in logic.constrain rules you define yourself.
Chain battery query results through Flow for multi-step pipelines,
or pipe into Prism for analysis and reporting.