The AC-3 Algorithm

AC-3 repeatedly revises arcs until no domain changes or a domain becomes empty.

r1c15r1c23r1c3r1c4r1c57r1c6r1c7r1c8r1c9
r2c16r2c2r2c3r2c41r2c59r2c65r2c7r2c8r2c9
r3c1r3c29r3c38r3c4r3c5r3c6r3c7r3c86r3c9
r4c18r4c2r4c3r4c4r4c56r4c6r4c7r4c8r4c93
r5c14r5c2r5c3r5c48r5c5r5c63r5c7r5c8r5c91
r6c17r6c2r6c3r6c4r6c52r6c6r6c7r6c8r6c96
r7c1r7c26r7c3r7c4r7c5r7c6r7c72r7c88r7c9
r8c1r8c2r8c3r8c44r8c51r8c69r8c7r8c8r8c95
r9c1r9c2r9c3r9c4r9c58r9c6r9c7r9c87r9c99
queue = every directed peer arc
while queue is not empty:
    (Xi, Xj) = remove an arc
    if REVISE(Xi, Xj):
        if D(Xi) is empty: fail
        add (Xk, Xi) for other neighbors Xk

Sudoku trace

Propagation establishes D(r5c5)={5}. Revising neighboring arcs removes 5 from peers: r5c2:{2,5}→{2} and r7c5:{3,5}→{3}. Because those domains changed, their incoming arcs return to the queue.

Why the queue matters

A deletion can create a new singleton, which can cause more deletions. AC-3 continues until this cascade reaches a fixed point.

Trace: After r5c2 becomes {2}, list its row, column, and box peers whose domains must be reconsidered.