Course / Lectures / Lecture 08 / Lab Lab 08

The constraint reweights the prior.

Four cells, four values, twenty-four valid rows. The neural module gives each cell a distribution; the program keeps the permutations. The posterior is computed by enumerating every valid row — no sampling, no approximation.

4 cells · 4 values 24 valid rows 256 total assignments No install · runs in the browser

The exact-inference lab

The neural module

Each cell has a categorical distribution over 1–4. The peak is the simulated perception; the noise slider flattens the distribution. These are the numbers the program receives — no image, no network weights, just probabilities over facts.

All twenty-four valid rows

The program says the four cells are a permutation of 1–4. There are 4! = 24 such rows, out of 44 = 256 assignments. The table is sorted by posterior; every row is enumerated exactly once.

#RowPrior weightPosterior
Sum over the 24 valid rows——

With the constraint on, the posterior column sums to 1. With it off, the valid rows show their prior weights; the other 232 assignments carry the rest.

Controls

Z · normalizer—
P(all-different)—
MAP row—
MAP posterior—

Loading the exact enumeration…

Prior vs posterior marginals

Each cell's marginal, before and after the constraint. The thin teal bar is the prior; the solid orange bar is the posterior. When the constraint is off, the two coincide.

prior marginalposterior marginal
WHAT TO NOTICE

Three regimes, one normalizer.

REGIME 01 · CLEAN READ

The prior is already almost valid

At low noise each cell peaks at its target value; the valid rows carry almost all the mass. The posterior is close to the prior, and Z is close to 1. The constraint is doing little because there is little to repair.

REGIME 02 · COLLISION

The constraint repairs a conflict

Two cells peak at the same value. The prior's MAP is invalid, so the posterior must move one of them. The mass splits between the two valid resolutions. This is the neurosymbolic moment: the program changes which row is the answer.

REGIME 03 · UNIFORM

The logic alone cannot choose

At 100% noise the prior is uniform. The posterior is uniform over the twenty-four valid rows and every marginal is 0.25. The constraint removes the impossible; it does not create a preference. The neural prior is what breaks the tie.

What this shows — and what it does not

It shows exact conditioning on a hard constraint with twenty-four worlds, the partition function Z, and the difference between prior and posterior marginals. It does not show a real classifier, a real Sudoku, or a scalable inference engine. The distributions are simulated; the enumeration is exact for the simulated numbers. The point is the mechanism, not a benchmark.

The one-line version

The posterior is the prior reweighted by the constraint indicator and divided by Z. When the constraint rejects a row, its mass is redistributed, not deleted. When the prior is uniform, the redistribution is uniform: logic alone cannot choose among the worlds it permits.

← Read the arithmetic of the hook · Back to Lecture 08 · Slides →