Using ISO Prolog notation:

  cousin(X,Y) :- grandparent(Z,X), grandparent(Z,Y), \+(X = Y), \+ sibling(X,Y).

Using typical Prolog dialect notation:

  cousin(X,Y) :- grandparent(Z,X), grandparent(Z,Y), not(X = Y), not(sibling(X,Y)).

Note that it is important to put the negated goals at the end, since you cannot bind a variable inside a negated goal. For example,

  cousin(X,Y) :- not(X = Y), not(sibling(X,Y)), grandparent(Z,X), grandparent(Z,Y).
is not correct since it will need to perform the negated goal not(X = Y) before it knows what X and Y are, unless both are given. We would like this predicate to be able to find a cousin of someone.