# Encoding schur.dlv.1

Name schur.dlv.1 [Root]    Unclassified (114) Martin Gebser n/a A dlv-style encoding for "SchurNumbers" problem (version with some pre-placed numbers). 2009-03-30 13:03 2009-03-10 12:22 SchurCompetition assigned/2number/1part/1 inpart/2 No % Schur numbers. % % The range of integers to be partitioned is n and the number of parts is k. % The main predicate is inpart. Atom inpart(X,P) % represents the fact that number X is included in part P. % The idea is to find a partition of integers {1,2,...,n} into k parts % such that each part is sum free, i.e. for any X and Y, % X and X+X are in different parts and % if X and Y are in the same part, then X+Y is in a different part. #maxint=1000000. inpart(X,P) :- assigned(X,P). % Assign each integer to exactly one part. inpart(X,P) v insomeotherpart(X,P) :- number(X), part(P), not assigned(X,P). :- number(X), #count{P: inpart(X,P)} > 1. :- number(X), #count{P: inpart(X,P)} < 1. % X, Y, and X+Y cannot be in the same part :- X <= Y, inpart(X,P), inpart(Y,P), inpart(Z,P), Z = X + Y.