The diagonal constraint requires that no two queens occupy the same diagonal. Representing the queen in row r by column index c, compare every pair of rows: for row difference Δ, the column difference must be neither 0, Δ, nor −Δ. section 8.3.1
For a pair of queens in rows r1 and r2, compute diff = c1 − c2:
- Reject diff = 0 because the queens share a column. section 8.3.1
- Reject |diff| = r2 − r1 because the queens share a diagonal. section 8.3.1
- Check each row pair independently and store its validity for the marking oracle. section 8.2.2
Classical validation
After extracting one column index per row, reject a placement whenever diff == 0 or abs(diff) == r2 - r1; otherwise continue through all row pairs.
