/* 
 * Structural comparison in CHR(chr)
 * Author: Seiji OGAWA, 2011-03-31
 *
 * If you'd like to change parameter N, 
 * please change the 1st argument of query: start("N", 0).
 *
 */

:- use_module(library(chr)).
:- chr_option(optimize, full).
:- chr_constraint start/2, s/2, a(+dense_int), b(+dense_int), gettime/1.

%query is 'start(N, 0)'.
start @ start(S, I) <=> cputime(X), s(S, I), cputime(Y), Z is Y-X, gettime(Z).
init @ s(S, I) <=> S > I | I1 is I+1, S1 is S-I-1, s(S, I1), a(I), a(I), a(I), b(S1), b(S1), b(S1).
ab @ a(X), b(X) <=> true.

