Download
language Essence 1.3
$ prob024.essence: Langford's Number Problem
$ Problem details available at http://www.csplib.org/Problems/prob024

$ numbers 1 to n, each appearing k times in a sequence (of length k*n)
given k : int(2..)
given n : int(1..)

letting seqLength be k * n

$ The sequence of numbers
find seq : sequence (size seqLength) of int(1..n)

$ symmetry breaking
such that seq(1) < seq(seqLength)

$ Each number from 1 to n appear exactly k times in seq.
$ This constraint is implied, and it probably doesn't help search either.
such that
    forAll i : int(1..n) . |preImage(seq, i)| = k

$ Each occurrence of a number N is N positions apart.
$ 
$ So if the number 4 is at position 1 and if k=3,
$ then there has to be a 4 at position 6 and 11 as well.
such that
    $ for each number
    forAll number : int(1..n) .                     
        $ there exists a starting position 
        $ (i.e. the first position where number occurs)
        exists start : int(1..seqLength) .          
            $ positions start, start+(number+1), start+2*(number+1), ... 
            $ all contain the value "number"
            forAll i : int(1..k) . seq(start + (i-1) * (number+1)) = number