%%%[(1,[(c,0),(a,0)])]
%%% 'ASP_to_CHR'([(a:-e,f,g,not(c),not(d)),e,f,g,(c:-a)],'test_3',all_answer_sets,'no_data')
:- use_module(library(chr)).
:- chr_constraint success/0, failure/0, supported_1/0, supported_2/0, exclusion_2/0, launcher/0, next_it/1, cfc/1, clean_result/0, a/0, g/0, f/0, e/0, d/0, out_d/0, c/0, out_c/0.
success <=> true.
failure <=> fail.
a # passive \ a <=> true.
c # passive \ c <=> true.

d,out_d <=> fail.
c,out_c <=> fail.


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

%% a:-e,f,g,not(c),not(d)
supported_2 @ g,f,e==>
   true | 
   supported_2.
unuseful_2 @ a \ supported_2<=>
   success.
propagate_2 @ out_d,out_c \ supported_2<=>
   a.
blocked_2 @ c \ supported_2<=>
   success.
blocked_2 @ d \ supported_2<=>
   success.
exclusion_2 @ out_d,out_c,exclusion_2<=>
   failure.
clean_exclusion_2 @ c \ exclusion_2<=>
   success.
clean_exclusion_2 @ d \ exclusion_2<=>
   success.
choice_2 @ next_it(X_0),supported_2 # passive <=>
   X_1 is X_0*2, out_c,out_d,a,next_it(X_1) ; X_1 is X_0*2+1, exclusion_2,next_it(X_1).




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

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

launcher <=> e, f, g, 
   next_it(0).

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




