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

d,out_d <=> fail.
c,out_c <=> fail.
a,out_a <=> fail.
b,out_b <=> fail.


%% e:-not(d)
unuseful_1 @ e \ supported_1<=>
   success.
propagate_1 @ out_d \ supported_1<=>
   e.
blocked_1 @ d \ supported_1<=>
   success.
exclusion_1 @ out_d,exclusion_1<=>
   failure.
clean_exclusion_1 @ d \ exclusion_1<=>
   success.

%% bot:-a,e
apply_guarded_constraint_2 @ e,a==>
   true | 
   failure.

%% b:-not(a)
unuseful_3 @ b \ supported_3<=>
   success.
propagate_3 @ out_a \ supported_3<=>
   b.
blocked_3 @ a \ supported_3<=>
   success.
exclusion_3 @ out_a,exclusion_3<=>
   failure.
clean_exclusion_3 @ a \ exclusion_3<=>
   success.

%% a:-not(b)
unuseful_4 @ a \ supported_4<=>
   success.
propagate_4 @ out_b \ supported_4<=>
   a.
blocked_4 @ b \ supported_4<=>
   success.
exclusion_4 @ out_b,exclusion_4<=>
   failure.
clean_exclusion_4 @ b \ exclusion_4<=>
   success.

%% c:-a,not(d)
supported_5 @ a==>
   true | 
   supported_5.
unuseful_5 @ c \ supported_5<=>
   success.
propagate_5 @ out_d \ supported_5<=>
   c.
blocked_5 @ d \ supported_5<=>
   success.
exclusion_5 @ out_d,exclusion_5<=>
   failure.
clean_exclusion_5 @ d \ exclusion_5<=>
   success.

%% d:-a,not(c)
supported_6 @ a==>
   true | 
   supported_6.
unuseful_6 @ d \ supported_6<=>
   success.
propagate_6 @ out_c \ supported_6<=>
   d.
blocked_6 @ c \ supported_6<=>
   success.
exclusion_6 @ out_c,exclusion_6<=>
   failure.
clean_exclusion_6 @ c \ exclusion_6<=>
   success.
choice_1 @ next_it(X_0),supported_1 # passive <=>
   X_1 is X_0*2, out_d,e,next_it(X_1) ; X_1 is X_0*2+1, exclusion_1,next_it(X_1).
choice_3 @ next_it(X_0),supported_3 # passive <=>
   X_1 is X_0*2, out_a,b,next_it(X_1) ; X_1 is X_0*2+1, exclusion_3,next_it(X_1).
choice_4 @ next_it(X_0),supported_4 # passive <=>
   X_1 is X_0*2, out_b,a,next_it(X_1) ; X_1 is X_0*2+1, exclusion_4,next_it(X_1).
choice_5 @ next_it(X_0),supported_5 # passive <=>
   X_1 is X_0*2, out_d,c,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_c,d,next_it(X_1) ; X_1 is X_0*2+1, exclusion_6,next_it(X_1).




next_it(_Profondeur), exclusion_1# passive <=> fail.
next_it(_Profondeur), exclusion_3# passive <=> fail.
next_it(_Profondeur), exclusion_4# passive <=> fail.
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 <=> supported_1,supported_3,supported_4,
   next_it(0).

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




