set(arithmetic).
assign(domain_size, 4).     
assign(max_models, -1).     

formulas(latin_square).
  all x all y1 all y2 (f(x,y1) = f(x,y2) -> y1 = y2).
  all x1 all x2 all y (f(x1,y) = f(x2,y) -> x1 = x2).	
end_of_list.

formulas(neighbours).
  all x1 all x2 all y1 all y2 (n(x1,y1,x2,y2) 
      -> f(x1,y1) = (f(x2,y2) + 1) | f(x2,y2) = (f(x1, y1) + 1)).
  
  all x1 all x2 all y1 all y2 (-n(x1,y1,x2,y2) 
      -> f(x1,y1) != (f(x2,y2)+1) & f(x2,y2) != (f(x1,y1) + 1)).
end_of_list.

formulas(sample_puzzle).
  f(0,0) = 0.    f(3,1) = 0.
  
  n(0,0,0,1).    n(0,1,0,2).     n(0,2,0,3).
 -n(0,0,1,0).    n(0,1,1,1).     n(0,2,1,2).    -n(0,3,1,3).
  n(1,0,1,1).    n(1,1,1,2).     n(1,2,1,3).
  n(1,0,2,0).    n(1,1,2,1).     n(1,2,2,2).     n(1,3,2,3).
  n(2,0,2,1).   -n(2,1,2,2).     n(2,2,2,3).
  n(2,0,3,0).   -n(2,1,3,1).    -n(2,2,3,2).     n(2,3,3,3).
  n(3,0,3,1).   -n(3,1,3,2).     n(3,2,3,3).
end_of_list.
