%%%[(1,[(a,0),(b,0),(e,0),(f,0),(c,0),(d,0)])]
%%% 'ASP_to_CHR'([(a:-not(b)),(b:-not(a)),(e:-not(f)),(f:-not(e)),(c:-not(d)),(d:-not(c)),(bot:-a,e),(bot:-a,f)],'test_28',all_answer_sets,'no_data')
:- use_module(library(chr)).
:- chr_constraint success/0, failure/0, supported_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, supported_7/0, exclusion_7/0, supported_8/0, exclusion_8/0, launcher/0, next_it/1, cfc/1, clean_result/0, c/0, out_c/0, d/0, out_d/0, e/0, out_e/0, f/0, out_f/0, a/0, out_a/0, b/0, out_b/0.
success <=> true.
failure <=> fail.
c # passive \ c <=> true.
d # passive \ d <=> true.
e # passive \ e <=> true.
f # passive \ f <=> true.
a # passive \ a <=> true.
b # passive \ b <=> true.

c,out_c <=> fail.
d,out_d <=> fail.
e,out_e <=> fail.
f,out_f <=> fail.
a,out_a <=> fail.
b,out_b <=> fail.


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

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

%% d:-not(c)
unuseful_3 @ d \ supported_3<=>
   success.
propagate_3 @ out_c \ supported_3<=>
   d.
blocked_3 @ c \ supported_3<=>
   success.
exclusion_3 @ out_c,exclusion_3<=>
   failure.
clean_exclusion_3 @ c \ exclusion_3<=>
   success.

%% c:-not(d)
unuseful_4 @ c \ supported_4<=>
   success.
propagate_4 @ out_d \ supported_4<=>
   c.
blocked_4 @ d \ supported_4<=>
   success.
exclusion_4 @ out_d,exclusion_4<=>
   failure.
clean_exclusion_4 @ d \ exclusion_4<=>
   success.

%% f:-not(e)
unuseful_5 @ f \ supported_5<=>
   success.
propagate_5 @ out_e \ supported_5<=>
   f.
blocked_5 @ e \ supported_5<=>
   success.
exclusion_5 @ out_e,exclusion_5<=>
   failure.
clean_exclusion_5 @ e \ exclusion_5<=>
   success.

%% e:-not(f)
unuseful_6 @ e \ supported_6<=>
   success.
propagate_6 @ out_f \ supported_6<=>
   e.
blocked_6 @ f \ supported_6<=>
   success.
exclusion_6 @ out_f,exclusion_6<=>
   failure.
clean_exclusion_6 @ f \ exclusion_6<=>
   success.

%% b:-not(a)
unuseful_7 @ b \ supported_7<=>
   success.
propagate_7 @ out_a \ supported_7<=>
   b.
blocked_7 @ a \ supported_7<=>
   success.
exclusion_7 @ out_a,exclusion_7<=>
   failure.
clean_exclusion_7 @ a \ exclusion_7<=>
   success.

%% a:-not(b)
unuseful_8 @ a \ supported_8<=>
   success.
propagate_8 @ out_b \ supported_8<=>
   a.
blocked_8 @ b \ supported_8<=>
   success.
exclusion_8 @ out_b,exclusion_8<=>
   failure.
clean_exclusion_8 @ b \ exclusion_8<=>
   success.
choice_3 @ next_it(X_0),supported_3 # passive <=>
   X_1 is X_0*2, out_c,d,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_d,c,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_e,f,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,e,next_it(X_1) ; X_1 is X_0*2+1, exclusion_6,next_it(X_1).
choice_7 @ next_it(X_0),supported_7 # passive <=>
   X_1 is X_0*2, out_a,b,next_it(X_1) ; X_1 is X_0*2+1, exclusion_7,next_it(X_1).
choice_8 @ next_it(X_0),supported_8 # passive <=>
   X_1 is X_0*2, out_b,a,next_it(X_1) ; X_1 is X_0*2+1, exclusion_8,next_it(X_1).




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.
next_it(_Profondeur), exclusion_7# passive <=> fail.
next_it(_Profondeur), exclusion_8# passive <=> fail.

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

launcher <=> supported_3,supported_4,supported_5,supported_6,supported_7,supported_8,
   next_it(0).

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




