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

b(X_0),out_b(X_0) <=> fail.
c(X_0),out_c(X_0) <=> fail.


%% c(_39556):-a(_39556),not(b(_39556))
supported_1 @ a(X_0)==>
   true | 
   supported_1(X_0).
unuseful_1 @ c(X_0) \ supported_1(X_0)<=>
   success.
propagate_1 @ out_b(X_0) \ supported_1(X_0)<=>
   c(X_0).
blocked_1 @ b(X_0) \ supported_1(X_0)<=>
   success.
exclusion_1 @ out_b(X_0),exclusion_1(X_0)<=>
   failure.
clean_exclusion_1 @ b(X_0) \ exclusion_1(X_0)<=>
   success.

%% b(_39556):-a(_39556),not(c(_39556))
supported_2 @ a(X_0)==>
   true | 
   supported_2(X_0).
unuseful_2 @ b(X_0) \ supported_2(X_0)<=>
   success.
propagate_2 @ out_c(X_0) \ supported_2(X_0)<=>
   b(X_0).
blocked_2 @ c(X_0) \ supported_2(X_0)<=>
   success.
exclusion_2 @ out_c(X_0),exclusion_2(X_0)<=>
   failure.
clean_exclusion_2 @ c(X_0) \ exclusion_2(X_0)<=>
   success.

%% d(_39556):-c(_39556)
propagate_3 @ c(X_0)==>
   d(X_0).
choice_1 @ next_it(X_1),supported_1(X_0) # passive <=>
   X_2 is X_1*2, out_b(X_0),c(X_0),next_it(X_2) ; X_2 is X_1*2+1, exclusion_1(X_0),next_it(X_2).
choice_2 @ next_it(X_1),supported_2(X_0) # passive <=>
   X_2 is X_1*2, out_c(X_0),b(X_0),next_it(X_2) ; X_2 is X_1*2+1, exclusion_2(X_0),next_it(X_2).




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

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

launcher <=> a(1), 
   next_it(0).

clean_result, out_b(X_0) # passive <=> clean_result.
clean_result, out_c(X_0) # passive <=> clean_result.
clean_result <=> true.




