Attachment 'schur-numbers.core.asp.txt'
Download 1 % Schur numbers.
2 %
3 % The range of integers to be partitioned is n and the number of
4 % parts is k. The main predicate is assigned. Atom assigned(X,P)
5 % represents the fact that number X is included in part P.
6 % The idea is to find a partition of integers {1,2,...,n} into k
7 % parts such that each part is sum free, i.e. for any X and Y,
8 % X and X+X are in different parts and if X and Y are in the
9 % same part, then X+Y is in a different part.
10
11
12 % Guess
13 assigned(X,P) v insomeotherpart(X,P) :- number(X), part(P).
14
15 % Assign each integer to exactly one part.
16 :- number(X), assigned(X,P1), assigned(X,P2), P1!=P2.
17
18 % X, Y, and X+Y cannot be in the same part
19 :- X <= Y, assigned(X,P), assigned(Y,P), assigned(Z,P), Z = X + Y.
Attached Files
You are not allowed to attach a file to this page.