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

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


%% h:-a,b,not(c),not(d)
supported_1 @ b,a==>
   true | 
   supported_1.
unuseful_1 @ h \ supported_1<=>
   success.
propagate_1 @ out_d,out_c \ supported_1<=>
   h.
blocked_1 @ c \ supported_1<=>
   success.
blocked_1 @ d \ supported_1<=>
   success.
exclusion_1 @ out_d,out_c,exclusion_1<=>
   failure.
clean_exclusion_1 @ c \ exclusion_1<=>
   success.
clean_exclusion_1 @ d \ exclusion_1<=>
   success.
choice_1 @ next_it(X_0),supported_1 # passive <=>
   X_1 is X_0*2, out_c,out_d,h,next_it(X_1) ; X_1 is X_0*2+1, exclusion_1,next_it(X_1).




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

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

launcher <=>    next_it(0).

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




