%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% (Simplified) Shur numbers problem.
% Find all subsets S of {1,...,N} such that, for each pair of
% (not necessarily distinct) numbers in S, their sum is not in S
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
shur(N,S):-
subset(S,int(1,N)) &
forall(X in S,
forall(Y in S,
forall(Z in S,Z =\= X+Y)
)
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
Example
{log}=> Sh = {S : shur(5,S)}.
Sh = {{},{1},{2},{3},{4},{5},{1,3},{2,3},{1,4},
{3,4},{1,5},{2,5},{3,5},{4,5},{1,3,5},{3,4,5}}
Another solution? (y/n)y
no
*/