design open-problem

Which operations can be done with beliefs, and where each one lives. The organising principle: an operation between variables is a factor, and the operation on beliefs is that factor’s message, one per polarity. Today only pooling (combine) exists, and only partially. This note lists the rest, what each needs, the order in which to build them, and where they should live (§6).

Sources: Loeliger, An introduction to factor graphs, IEEE Signal Processing Magazine 2004; Loeliger, Dauwels, Hu, Korl, Ping & Kschischang, The factor graph approach to model-based signal processing, Proc. IEEE 2007 (message tables for equality, addition and matrix nodes); Minka, Expectation Propagation for approximate Bayesian inference, UAI 2001; Fritz, A synthetic approach to Markov kernels, conditional independence and theorems on sufficient statistics, Adv. Math. 2020 (Markov categories); code: Mycelium/messages.jl (combine), LenticulumCore/open_model.jl (pushforward)

Theory (CT-ML wiki): Markov Category · Bayesian Inversion · Bayesian Lens

1. Operations are factors

In a Forney-style factor graph a variable is a wire and everything else is a factor (Everything is a Factor). So “add two beliefs”, “mix two beliefs” or “x implies y” is not an operation on the graph’s variables; it is a factor connecting them, and what happens to the beliefs is the message that factor sends.

A factor sends a different message for each choice of output, which is Lenticulum’s polarity (Channels and Polarity). Take the addition factor :

polaritymessageoperation on beliefs
convolution
deconvolution (correlation)
the same, with and swapped

The “operation” is one relation; the three operations on beliefs are its three readings. That is the same move the implicit learners make for learned relations, applied to the building blocks.

2. The catalogue

operationas a factoron beliefsGaussianDiracSamplestatus
identification equality node; the copy map of a Markov categoryproduct of the incoming beliefsexactabsorbingneeds densitiesimplicit: a variable node is an equality node
fusion (pooling)the variable nodeproduct of densities, normalisedadd absorbingimportance reweightingcombine: Gaussian, Dirac, Trivial (Beliefs)
addition, linear maps linear factorconvolution / deconvolutionexactshiftpairwise sums (forward)Gaussian through the linear factors only
deterministic function function factorforward: pushforward; backward: inversionlinearised or unscentedexactexact forwardforward pushforward; backward is the implicit learners’ job
mixturefactor with a categorical switch , weighted sum of componentsa Gaussian mixturea weighted point setunion with weightsmissing: no mixture belief
marginalisationdelete a wire (the delete map)integrate outdrop blocksdrop coordinatesdrop coordinatesGaussian only, inside the linear-Gaussian code
conditioningclamprestrict and renormaliseSchur complementreweightGaussian only
logic: implication, AND, OR, XORfactor on Bernoulli variablesdiscrete sum-productmissing: no discrete beliefs
projection onto a familymoment matchingthe nearest Gaussian in identitydegeneratesample momentsmissing; the EP step
tempering , division power EP, cavity distributions, counting numbersscale / subtract natural parametersexactmissing as operations; counting_number in Mycelium already assumes them
composition with a kerneltransition factor (a random walk in time)Chapman–Kolmogorovexact for linear-Gaussianpropagate particlesGaussian through the linear factors
max instead of sumthe semiringmax-product: MAP rather than marginalssame algebra, different meaningnaturalnot a separate mode; point inference already behaves this way

3. The categorical reading

Copy, delete, tensor and composition are the structure of a Markov category: they exist for every belief type that is a probability measure, and they compose freely. Mixture is the convex structure of the distribution monad. Fusion is different: the product of two densities is not a morphism of the Markov category but conditioning, a Bayesian inversion (Inversions and Bayesian Lenses). That is why it is the one operation that is partial, needs densities, and can fail (two contradictory Diracs). Everything else in the catalogue is easy in principle; fusion and projection are where the approximations live.

4. What to build, by what it unlocks

  1. belief_logdensity beyond Gaussians, and moment projection (EP). Pooling of Sample beliefs (densities exist for Gaussians only, Beliefs), and the first non-Gaussian factor whose messages stay Gaussian: a win/draw/loss outcome factor (the planned TrueSkill-through-time project), probit and other one-dimensional likelihoods.
  2. A mixture belief. The important one for the implicit learners: today point inference returns one branch of a multivalued relation (Inference Signatures §3). A mixture holds both, e.g. the circle’s or the robot arm’s elbow up and down. The cost is combinatorial growth under products, so it comes with merging and pruning, as in Gaussian-sum filters.
  3. Bernoulli and categorical beliefs. Logic factors, and switch variables: “is this enzyme active?” (Metabolomics and Proteomics) is a Bernoulli latent that turns a reaction on or off, and the mixture factor’s switch is a categorical.
  4. Addition and linear maps for Sample and Dirac beliefs. Bookkeeping, but it lets the particle path compose with the linear factors.

Each item is a belief type or a message rule, not a change to the graph machinery: combine dispatches on belief types, and a factor’s messages are its inversions (Messages are Inversions), so the catalogue extends by adding methods.

5. The nearest existing implementation

RxInfer.jl (and ForneyLab.jl before it) implements exactly such message rules, per node type and distribution family, including mixtures, addition and equality nodes (Related Julia Projects §5). Its rules are the reference to check against; what this project adds is that the factors themselves can be learned relations queried in any polarity.

6. Interop and package layout (for later)

Where the beliefs live is the real constraint. TrivialBelief, DiracBelief and SampleBelief are in LenticulumCore; GaussianBelief is in the top-level Lenticulum package, above the lib/ packages. So the diffusion and equilibrium factors cannot return a Gaussian message even where they could compute one, e.g. the Laplace approximation from the implicit adjoint (Gaussian Belief, Beliefs). Mycelium holds the graph, combine and the schedules; nothing in the graph machinery needs heavy dependencies.

The plan, when this is taken up:

  1. One low layer for all beliefs and their algebra: the belief types, combine, densities, and later mixtures and projection. Either LenticulumCore itself, or a small dedicated beliefs package if LenticulumCore should stay pure interfaces. Every factor package can then produce and consume every belief type.

  2. Connectors as package extensions on that layer, not as a second graph package:

    connector (Distributions.jl extension)what it enables
    SampleBelief(rng, d::Distribution, n)any distribution as a particle belief
    GaussianBelief(::MvNormal), and back to MvNormalCanoninterop with the ecosystem
    belief densities through logpdfdensities beyond Gaussians, hence pooling of particle beliefs by importance reweighting (§4, item 1)
    fit(Family, ::SampleBelief)infer a distribution from particles: projection onto a family, the EP step

    A later ExponentialFamily.jl / BayesBase.jl extension could lend combine their closed-form products (prod with ClosedProd), the most developed product rules in Julia.

  3. Split Mycelium into a core and a full package only if the graph machinery itself acquires heavy dependencies. Today it does not, and extensions cover the connectors.

Other Julia belief representations worth connecting or checking against: MonteCarloMeasurements.jl (particles with arithmetic, so addition is convolution), ParticleFilters.jl, KernelDensity.jl, MeasureTheory.jl (densities relative to base measures), AbstractGPs.jl (beliefs over functions), Bijectors.jl (pushforward beliefs), and IncrementalInference.jl with ApproxManifoldProducts.jl (multimodal, kernel-density beliefs on manifolds: the existing Julia take on non-Gaussian SLAM).

Related: Beliefs, Gaussian Belief, Dirac Belief, Sample Belief, Trivial Belief, Messages are Inversions, Everything is a Factor, Inference Signatures, Related Julia Projects