Survey propagation: the implemented equations#
From assignment marginals to state-level information#
In the cavity description, satisfying configurations may organize into states or clusters with internally correlated variables. In one state, variable i may be forced True, forced False, or remain unfrozen. These are statements about variation within a state, not about whether the program has already fixed the variable. A free solver variable can have a strongly forced survey.
The conceptual state-level partition function is \(\mathcal Z(m)=\sum_\gamma Z_\gamma^m\), with \(Z_\gamma\) the number of assignments in state gamma. Equal assignment weighting and equal state weighting differ when state sizes differ. The cluster-counting, hard-field SP closure used here corresponds to the m=0 perspective, rather than evaluating this expression for general m. States are a cavity-model description; the solver does not enumerate them or construct connected components of the full solution graph [BMWZ2003] [MZ2002].
Fig. 3 Three admissible hard-warning configurations. Solid edges are positive, dashed edges negative; the edge labels are warning bits. Hatched fill marks an unfrozen variable, distinct from white=True and grey=False. Simultaneous positive and negative warnings are incompatible. This is a schematic of states, not a measured population or a claim that the three cases are equally likely. Clause boxes summarize incident constraints with other neighbors omitted.#
The two cavity quantities#
For each directed clause incidence a to i define
\(\eta_{a\to i}\in[0,1]\), the probability across cavity states that a
warns i: every other literal in a is forced to violate a, so i must satisfy it.
This is the Python messages array. A warning on a negative literal demands
False; eta itself is not a True marginal or the probability that a clause is
unsatisfied.
Define the internal variable-to-clause quantity \(q_{i\to a}\) as the survey probability that i is forced to the value violating its literal in a. It is not exposed as a separate Python array. The cavity independence closure then gives the clause update [BMZ2005]
The product excludes the target, and uses messages computed from the same old iterate. This exclusion prevents a clause from immediately reinforcing its own warning through a variable.
Same-sign and opposite-sign exclusion products#
Relative to the literal of i in a, split its other incident clauses into \(\mathcal S_{ia}\) (same sign) and \(\mathcal O_{ia}\) (opposite sign), always excluding a. Define the probability of no incoming warning in each group:
An empty product is one. To force i to violate a, there must be at least one opposite-sign warning and no same-sign warning. Configurations carrying both types of warnings are inconsistent. Conditioning on the remaining cases gives
These equations can be read directly against the scalar Rust cavity routine:
same, opposite, and norm are the two products and z. Independent
incoming warnings and the exclusion of inconsistent combinations are modeling
assumptions, not consequences of convergence on a loopy finite graph.
For example, with \(P^{\rm same}=0.8\) and \(P^{\rm opp}=0.6\), the compatible weight is 0.92 and \(q=0.32/0.92\simeq0.347826\). If the other cavity variable of a 3-clause has q=0.2, its outgoing warning to the target is about 0.069565. This is a product of forcing probabilities, not the BP product of ordinary probabilities of false literals.
Full variable surveys#
Using all active incidences, set
The three compatible events are: at least one positive warning and none negative; at least one negative warning and none positive; and no warning. Their normalized surveys are
Their sum is one when the normalization is positive. surveys[i] is exactly
the ordered vector \([S_i^T,S_i^F,S_i^0]\), refreshed after convergence.
With \(P_i^+=0.8\) and \(P_i^-=0.6\), the vector is approximately
[0.130435, 0.347826, 0.521739]. Its free entry is a fraction of states with
no forcing, not a third Boolean truth value.
Complexity versus entropy#
The implementation evaluates the cluster-counting Bethe expression using the final cavities. For active degree \(d_i\), let
All sums and products refer to the residual active/free graph. This is the total complexity estimate; \(\Sigma/N\) would be a density. The heuristic interpretation is \(\mathcal N_{\rm states}\approx e^\Sigma\), not the number of satisfying assignments. It neither supplies a rigorous integer count nor includes every state’s internal entropy. An invalid normalization or non-finite expression causes an explicit numerical failure.
The code’s paramagnetic flag is true when every free variable of active
degree at least two has \(Z_i=1\) in the evaluated arithmetic. It then
reports complexity zero and hands the residual to WalkSAT. This algebraic
criterion is a practical handoff rule; it does not prove the residual is SAT.
Iteration, damping, and numerical care#
One synchronous sweep computes all q values from old eta values, then all raw clause updates from those q values. The implementation thresholds raw products below \(10^{-16}\) to zero and applies damping
The stopping criterion is \(R_t\le\epsilon\); it is deliberately undamped. Normalizers and surveys are recomputed from the final stored messages, rather than reusing cavities from the preceding iterate.
Prefix/suffix products compute exclusions without dividing by a potentially zero factor. Nevertheless, finite precision can underflow a positive product or create an unusable denominator. GPU f32 modes detect dangerous cases and retry on CPU f64. Numerical agreement, fixed-point convergence, accuracy of the state-factorization approximation, and probability of finding a solution are four separate questions; each needs its own evidence.