Belief propagation in chain BNs

Belief propagation in chains, i.e. variables X1,X2, ... Xn
where Xi is the parent of Xi+1. The evidence e is seen as composed of
"up-chain" evidence e+ and "down-chain" evidence e-.

"Downwards message" PI(Xi) is defined as: P(Xi|e+) and can be computed based on PI(Xi-1) as:
    P(Xi|e+) = alpha sum(w over domain (Xi-1))  P(Xi|Xi-1=w) P(Xi-1=w|e+)
Note that the above stands for one equation for each possible value of Xi,
and alpha is a normalizer.

"Upwards message" LAMBDA(Xi) is defined as: P(e-|Xi), and can be computed based on LAMBDA(Xi+1) as:
    P(e-|Xi) = alpha sum(w over domain (Xi+1)) P(e-|Xi+1=w) P(Xi+1=w|Xi)
Again, alpha is a normalization constant (obviously not necessarily the same value of alpha as before).

Finally, we have:
    P(Xi|e) = P(Xi|e+,e-) = alpha PI(Xi)*LAMBDA(Xi)
where "*" is a per-item multiplication.

Note that to introduce evidence Xj=x, we use a dummy message (whether PI or LAMBDA,
depending on whether this is up-chain or down-chain evidence) with P(Xj=x)=1 and P(Xj=z)=0
for every value z not equal to x. In order to set null e+, use a dummy PI message with
the prior distributions.
To set null e-, use a dummy LAMBDA message with (unnormalized) probability values P(Xj=x)=1
for every value x.