%%%[(1,[(c,0),(d,0),(a,0),(b,0),(e,0)])]
%%% 'ASP_to_CHR'([(a:-not(b)),(d:-a),(b:-c),(c:-d),(e:-not(c)),(b:-e)],'test_24',all_answer_sets,'no_data')
:- use_module(library(chr)).
:- chr_constraint success/0, failure/0, supported_1/0, supported_2/0, exclusion_2/0, supported_3/0, supported_4/0, supported_5/0, supported_6/0, exclusion_6/0, launcher/0, next_it/1, cfc/1, clean_result/0, e/0, c/0, out_c/0, d/0, a/0, b/0, out_b/0.
success <=> true.
failure <=> fail.
e # passive \ e <=> true.
c # passive \ c <=> true.
d # passive \ d <=> true.
a # passive \ a <=> true.
b # passive \ b <=> true.

c,out_c <=> fail.
b,out_b <=> fail.


%% b:-e
propagate_1 @ e==>
   b.

%% e:-not(c)
unuseful_2 @ e \ supported_2<=>
   success.
propagate_2 @ out_c \ supported_2<=>
   e.
blocked_2 @ c \ supported_2<=>
   success.
exclusion_2 @ out_c,exclusion_2<=>
   failure.
clean_exclusion_2 @ c \ exclusion_2<=>
   success.

%% c:-d
propagate_3 @ d==>
   c.

%% b:-c
propagate_4 @ c==>
   b.

%% d:-a
propagate_5 @ a==>
   d.

%% a:-not(b)
unuseful_6 @ a \ supported_6<=>
   success.
propagate_6 @ out_b \ supported_6<=>
   a.
blocked_6 @ b \ supported_6<=>
   success.
exclusion_6 @ out_b,exclusion_6<=>
   failure.
clean_exclusion_6 @ b \ exclusion_6<=>
   success.
choice_2 @ next_it(X_0),supported_2 # passive <=>
   X_1 is X_0*2, out_c,e,next_it(X_1) ; X_1 is X_0*2+1, exclusion_2,next_it(X_1).
choice_6 @ next_it(X_0),supported_6 # passive <=>
   X_1 is X_0*2, out_b,a,next_it(X_1) ; X_1 is X_0*2+1, exclusion_6,next_it(X_1).




next_it(_Profondeur), exclusion_2# passive <=> fail.
next_it(_Profondeur), exclusion_6# passive <=> fail.

success @ next_it(_Profondeur) <=> clean_result, chr_show_store(user),  write("--"), nl, fail.

launcher <=> supported_2,supported_6,
   next_it(0).

clean_result, out_c # passive <=> clean_result.
clean_result, out_b # passive <=> clean_result.
clean_result <=> true.




