mixle.reason.belief_walk module

Reasoning as a belief walk across a chain of verified transports.

A multi-hop reasoning path, such as binding -> structure -> activity, transports a belief at each hop. This module composes fitted conditional transports from fit_cycle_transport() by Monte Carlo forward simulation: draw from the belief at hop 0, push the sample through hop 1’s transport, and continue through the chain. The result is an empirical posterior over the final variable whose spread reflects uncertainty from every intervening hop.

Composition is gated on the edge premise: a transport that has not been verified usable and calibrated on its own edge is refused before composition. coverage_by_hop_count() checks calibration by hop count with a two-sided binomial test against nominal coverage, so degradation across composed hops is measured rather than assumed.

class HopTransport(name, fit, premise_passed=True)[source]

Bases: object

One edge of the belief walk and its own calibration verdict.

premise_passed records whether this transport was independently verified usable and calibrated on this edge.

Parameters:
sampler(seed=None)[source]

Return the sampler for this hop’s fitted transport.

Parameters:

seed (int | None)

Return type:

Any

class WalkResult(hop_names, samples)[source]

Bases: object

The belief walk’s outcome: an empirical posterior over the final hop’s variable.

Parameters:
property mean: ndarray

Return posterior sample mean for the final hop.

property std: ndarray

Return posterior sample standard deviation for the final hop.

credible_interval(alpha=0.1)[source]

Return marginal credible interval bounds from walk samples.

Parameters:

alpha (float)

Return type:

tuple[ndarray, ndarray]

belief_walk(hops, x0, *, n_draws=200, seed=0)[source]

Propagate a belief forward through a chain of hops, starting from a single value x0.

Each hop’s transport is applied by drawing n_draws samples of the current belief and pushing each through the hop’s sample_given method. Raises if any hop’s premise_passed flag is False.

Parameters:
Return type:

WalkResult

coverage_by_hop_count(hops, x0_test, true_final, *, alpha=0.1, n_draws=150, seed=0)[source]

Return empirical calibration by hop count.

For k = 1 .. len(hops), walks the first k hops for every test point in x0_test and checks credible-interval coverage of true_final[k] against the nominal 1 - alpha rate with a two-sided binomial test. true_final must supply ground truth for each checked hop count.

Parameters:
Return type:

dict[int, dict[str, float]]