How can I formulate the k-knights problem as a constraint satisfaction problem?
There are many possible ways to encode this problem, and some will be more advantageous than others

An encoding that seems like a reasonable starting point to me is:


Variables: Let $S$ be a set of $k$ variables representing the coordinates of knights on the chess board.
Domain: The domain of each variable is initially all vectors in $[n]^2$. Denote the components of these vectors with $[r, c]$.
Constraints: 


Let A be the set of 8 attacking moves: $A=\{[2,1],[2,-1],[-2,1],[-2,-1],[1,2],[1,-2],[-1,2],[-1,-2]\}$
$\forall_{i &lt; j} S_i \neq S_j$ (no knights on the same squares)
$\forall_{i &lt; j} [r_i, c_i] \notin \{[r_j + x, c_j + y] | x,y \in A\}$ (no knight attacks another knight)



That should be it. Note the use of $\forall_{i&lt;j}$ in the constraints is to reduce the total number of constraints by half, exploiting the symmetry that knight $i$ can attack knight $j$ iff knight $j$ can attack knight $i$. You could also use $\forall_{i\neq j}$, but it would increase your constraint count to no gain.