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

g,out_g <=> fail.
f,out_f <=> fail.


%% g:-d,f
supported_1 @ f,d==>
   true | 
   supported_1.
unuseful_1 @ g \ supported_1<=>
   success.
propagate_1 @ supported_1<=>
   g.

%% f:-c,g
supported_2 @ g,c==>
   true | 
   supported_2.
unuseful_2 @ f \ supported_2<=>
   success.
propagate_2 @ supported_2<=>
   f.

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

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

%% b:-a,c,not(g),not(f)
supported_5 @ c,a==>
   true | 
   supported_5.
unuseful_5 @ b \ supported_5<=>
   success.
propagate_5 @ out_f,out_g \ supported_5<=>
   b.
blocked_5 @ g \ supported_5<=>
   success.
blocked_5 @ f \ supported_5<=>
   success.
exclusion_5 @ out_f,out_g,exclusion_5<=>
   failure.
clean_exclusion_5 @ g \ exclusion_5<=>
   success.
clean_exclusion_5 @ f \ exclusion_5<=>
   success.

%% a:-b,c,not(f),not(g)
supported_6 @ c,b==>
   true | 
   supported_6.
unuseful_6 @ a \ supported_6<=>
   success.
propagate_6 @ out_g,out_f \ supported_6<=>
   a.
blocked_6 @ f \ supported_6<=>
   success.
blocked_6 @ g \ supported_6<=>
   success.
exclusion_6 @ out_g,out_f,exclusion_6<=>
   failure.
clean_exclusion_6 @ f \ exclusion_6<=>
   success.
clean_exclusion_6 @ g \ exclusion_6<=>
   success.
choice_5 @ next_it(X_0),supported_5 # passive <=>
   X_1 is X_0*2, out_g,out_f,b,next_it(X_1) ; X_1 is X_0*2+1, exclusion_5,next_it(X_1).
choice_6 @ next_it(X_0),supported_6 # passive <=>
   X_1 is X_0*2, out_f,out_g,a,next_it(X_1) ; X_1 is X_0*2+1, exclusion_6,next_it(X_1).




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

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

launcher <=>    next_it(0).

clean_result, out_g # passive <=> clean_result.
clean_result, out_f # passive <=> clean_result.
clean_result <=> true.




