winner(X):- format('Winner is ~s', X).
win(X1, X2, X3):- X1 == X2, X2 == X3, winner(X1).
winRow([X1, X2, X3|Tail]):- win(X1, X2, X3); winRow(Tail).
winCross([ 
    X1, _, X4,
    _, X2, _,
    X5, _, X3]):- win(X1, X2, X3); win(X4, X2, X5).

win(X):- winRow(X); winCross(X).

whoWins:- win([
  x, _, _,
  o, x, o,
  x, _, o
  ]).

/** <examples>

?- whoWins.
*/