%%%[(1,[(b,0),(a,0),(d,0)]),(2,[(c,0)])]
%%% 'ASP_to_CHR'([(b:-not(a)),(a:-not(b)),(a:-not(a),not(b)),(c:-b),(d:-b),(bot:-not(a))],'test_10',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, launcher/0, next_it/1, cfc/1, clean_result/0, d/0, c/0, b/0, out_b/0, a/0, out_a/0.
success <=> true.
failure <=> fail.
d # passive \ d <=> true.
c # passive \ c <=> true.
b # passive \ b <=> true.
a # passive \ a <=> true.

b,out_b <=> fail.
a,out_a <=> fail.


%% bot:-not(a)
apply_constraint_1 @ supported_1,out_a<=>
   failure.
blocked_1 @ a \ supported_1<=>
   success.
necessity_1 @ supported_1<=>
   exclusion_1.
clean_exclusion_1 @ a \ exclusion_1<=>
   success.

%% d:-b
propagate_2 @ b==>
   d.

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

%% b:-not(a)
unuseful_5 @ b \ supported_5<=>
   success.
propagate_5 @ out_a \ supported_5<=>
   b.
blocked_5 @ a \ supported_5<=>
   success.
exclusion_5 @ out_a,exclusion_5<=>
   failure.
clean_exclusion_5 @ a \ exclusion_5<=>
   success.

%% c:-b
propagate_6 @ b==>
   c.
choice_3 @ next_it(X_0),supported_3 # passive <=>
   X_1 is X_0*2, out_a,out_b,a,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_a,b,next_it(X_1) ; X_1 is X_0*2+1, exclusion_5,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.

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

launcher <=> supported_1,supported_3,supported_4,supported_5,
   next_it(0).

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




