Skip to content

feat(active_inference): Expected Free Energy decomposition (epistemic/pragmatic)#19

Merged
docxology merged 2 commits into
mainfrom
improve/active-inference-additions
Jun 5, 2026
Merged

feat(active_inference): Expected Free Energy decomposition (epistemic/pragmatic)#19
docxology merged 2 commits into
mainfrom
improve/active-inference-additions

Conversation

@docxology

Copy link
Copy Markdown
Owner

Adds the single most defining Active Inference quantity the template was missing — and which 15_discussion_outlook.md explicitly flags as deferred ("extending to full expected-free-energy policy selection is documented as a follow-on track"). Identified as the #1 addition by all three agents of a survey of the exemplar.

Layer 1 (this commit): the scientific core

src/simulation/efe_decomposition.py computes, in closed form on the finite T-maze generative model (A,B,C,D), both canonical EFE decompositions and their exact algebraic identity:

  • G(π) = risk + ambiguity — risk = KL[q(o|π) ‖ softmax(C)] (pragmatic deviation), ambiguity = E_q(s)[H[p(o|s)]] (outcome uncertainty)
  • = −(pragmatic_value + epistemic_value) — pragmatic = E_q(o)[ln p(o)] (utility), epistemic = I(s;o|π) (mutual-information info-gain / salience)
  • machine-checked: risk + ambiguity + pragmatic + epistemic ≡ 0 to 1e-10, mirroring the analytical track's decomposition_identity_holds (Theorem 5.1).

Closed-form, no sampling, byte-deterministic. 17 deterministic no-mocks tests, 100% module coverage. Full active_inference suite 286/287, 92.1% (maintained); ruff/mypy/format clean. The EFE-minimizing policy correctly seeks the goal; the identity holds across all policies and likelihood settings.

Planned follow-on layers (same PR or follow-up)

Producer → output/data/efe_decomposition.json (byte-deterministic) → EFE risk/ambiguity bar figure → Methods/Results section with hydrated tokens → claim-ledger + sheaf-track binding, each gated on the full suite + render.

docxology added 2 commits June 4, 2026 20:02
Add the defining Active Inference quantity the template was missing (and that
15_discussion_outlook.md flags as deferred): a closed-form EFE decomposition on
the finite T-maze generative model.

src/simulation/efe_decomposition.py computes both canonical forms and their exact
identity:
  G(pi) = risk + ambiguity = -(pragmatic_value + epistemic_value)
where risk = KL[q(o|pi) || softmax(C)], ambiguity = E_q(s)[H[p(o|s)]],
pragmatic_value = E_q(o)[ln p(o)], epistemic_value = I(s;o|pi). The identity is
machine-checked to 1e-10, mirroring the analytical track's
decomposition_identity_holds. Closed-form, no sampling, byte-deterministic.

17 deterministic no-mocks tests, 100% module coverage; full active_inference
suite 286/287, 92.1% (maintained); ruff/mypy/format clean.
main's v3.2.0 prep added infrastructure modules (validation/docs/* subpackage,
etc.) without refreshing the factsheet, so canonical_facts.md drifted to 516 vs
the tracked tree's 518 and test_canonical_facts_infrastructure_python_count_matches_tree
fails on main (and on any PR merged with it). Update both the header measurement
and the 'Last refreshed count' literal to 518 (git ls-files infrastructure | grep
.py). Unblocks CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant