/*-------------------------------------------------------------------------*/
/* Benchmark (Finite Domain)                                               */
/*                                                                         */
/* Name           : sorted-gnu.pl                                          */
/* Title          : academic problem                                       */
/* Original Source: public domain                                          */
/* Adapted by     : P. Deransart - INRIA France                            */
/* Date           : April 2004                                             */
/*                                                                         */
/*-------------------------------------------------------------------------*/
%['sorted-gnu'], codeine(sort,xml). sorted(100,L).

sorted(N, L):-
        codeine_maxint(N),
	length(L, N),
        cod_sort_vname(L, N),
	fd_cstrname(fd_domain(L,1,N),fdom),
	sorted_constraints(L,N).

multsorted(N, L):-
        N1 is N+1,
        codeine_maxint(N1),
	length(L, N),
        cod_sort_vname(L, N),
	fd_cstrname(fd_domain(L,1,N1),fdom),
	sorted_constraints(L,N),
        fd_labeling(L).

sorted_constraints([_],_).
sorted_constraints([A|[B|L]],N):-
        number_chars(N,LN), atom_chars(AN,LN), atom_concat(c,AN,VN),
	fd_cstrname(B #> A, VN), N1 is N-1,
	sorted_constraints([B|L], N1).


cod_sort_vname([],_).
cod_sort_vname([V|L1],N) :-
        number_chars(N,LN), atom_chars(AN,LN), atom_concat(v,AN,VN),
        fd_varnames([V],[VN]),
        N1 is N-1,
        cod_sort_vname(L1,N1).

/* version non annotee

sorted(N, L):-
        length(L, N),
        fd_domain(L,1,N),
        sorted_constraints(L).

multsorted(N, L):-
        N1 is N+1,
        length(L, N),
        fd_domain(L,1,N1),
        sorted_constraints(L).

sorted_constraints([_]).
sorted_constraints([A|[B|L]]):-
        B #> A,
        sorted_constraints([B|L]).

*/

