Combination problem

Hello all,

I have a problem to figure out all the possible connection combination of 16 nodes with some constraints. One adjacency matrix (16*16) could be defined to indicate their connections by using 0 (disconnected) or 1(connected) shown below. We could see the self connected was not allowed which indicated by 0 in the diagonal line. For instance, (V11,V11)=0.
I just started SWI Prolog several days ago and had some difficulties for writing the codes of constraints. For example:

  1. if (V4n,V8i)+(V4n,V8j)=2, then (V8i,V8k)+(V8j,V8k)!=2, n is any of {1,2}, i, j, k is any of {1,2,3}. I am able to write this constraint one by one by specifying n, i, j and k with an exact number. Do we have any smarter way to express this constraint?
  2. \sum_{i=1}^{3} (V7i,V8j)<2, j is any of {1,2,3}. Similar to the above one, how we could write it in a compact way?

Would someone do me a favor for my difficulties? Thank you in advance.