4d94446c25
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1416 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
9229 lines
254 KiB
Prolog
9229 lines
254 KiB
Prolog
/* Generated by CHR bootstrap compiler
|
|
From: ../../../../work/LGPL/chr/chr_translate.chr
|
|
Date: [84,104,117,32,79,99,116,32,50,55,32,49,54,58,51,54,58,50,53,32,50,48,48,53,10]
|
|
|
|
DO NOT EDIT. EDIT THE CHR FILE INSTEAD
|
|
*/
|
|
|
|
:-module(chr_translate,[chr_translate/2]).
|
|
:-use_module(chr_runtime).
|
|
:-style_check((-singleton)).
|
|
:-style_check((-discontiguous)).
|
|
:-use_module(library(lists)).
|
|
:-use_module(hprolog).
|
|
:-use_module(library(assoc)).
|
|
:-use_module(pairlist).
|
|
:-use_module(library(ordsets)).
|
|
:-use_module(a_star).
|
|
:-use_module(listmap).
|
|
:-use_module(clean_code).
|
|
:-use_module(builtins).
|
|
:-use_module(find).
|
|
:-use_module(guard_entailment).
|
|
:-use_module(chr_compiler_options).
|
|
:-use_module(chr_compiler_utility).
|
|
:-include(chr_op).
|
|
:-op(1150,fx,chr_type).
|
|
:-op(1130,xfx,--->).
|
|
:-op(1150,fx,+).
|
|
:-op(1150,fx,-).
|
|
:-op(1150,fx,?).
|
|
set_constraint_indices(A) :-
|
|
set_constraint_indices(A,1).
|
|
set_constraint_indices([],A) :-
|
|
B is A-1,
|
|
max_constraint_index(B).
|
|
set_constraint_indices([A|B],C) :-
|
|
(
|
|
(
|
|
chr_pp_flag(debugable,on)
|
|
;
|
|
may_trigger(A)
|
|
;
|
|
is_stored(A),
|
|
get_store_type(A,default)
|
|
) ->
|
|
constraint_index(A,C),
|
|
D is C+1,
|
|
set_constraint_indices(B,D)
|
|
;
|
|
set_constraint_indices(B,C)
|
|
).
|
|
chr_translate(A,B) :-
|
|
init_chr_pp_flags,
|
|
partition_clauses(A,C,D,E),
|
|
check_declared_constraints(C),
|
|
( C==[] ->
|
|
insert_declarations(E,B)
|
|
;
|
|
generate_show_constraint(C,F,D,G),
|
|
add_constraints(F),
|
|
add_rules(G),
|
|
check_rules(G,F),
|
|
add_occurrences(G),
|
|
functional_dependency_analysis(G),
|
|
set_semantics_rules(G),
|
|
symmetry_analysis(G),
|
|
guard_simplification,
|
|
storage_analysis(F),
|
|
observation_analysis(F),
|
|
ai_observation_analysis(F),
|
|
late_allocation(F),
|
|
assume_constraint_stores(F),
|
|
set_constraint_indices(F),
|
|
constraints_code(F,H),
|
|
validate_store_type_assumptions(F),
|
|
store_management_preds(F,I),
|
|
insert_declarations(E,J),
|
|
chr_module_declaration(K),
|
|
append_lists([J,I,H,K],B)
|
|
).
|
|
store_management_preds(A,B) :-
|
|
generate_attach_detach_a_constraint_all(A,C),
|
|
generate_indexed_variables_clauses(A,D),
|
|
generate_attach_increment(E),
|
|
generate_attr_unify_hook(F),
|
|
generate_extra_clauses(A,G),
|
|
generate_insert_delete_constraints(A,H),
|
|
generate_attach_code(A,I),
|
|
generate_counter_code(J),
|
|
append_lists([C,D,E,F,G,H,I,J],B).
|
|
insert_declarations(A,B) :-
|
|
append(A,[(:-use_module(chr(chr_runtime))),(:-use_module(chr(chr_hashtable_store))),(:-use_module(library('clp/clp_events')))],B).
|
|
generate_counter_code(A) :-
|
|
( chr_pp_flag(store_counter,on) ->
|
|
A=[('$counter_init'(B):-nb_setval(B,0)),('$counter'(C,D):-nb_getval(C,D)),('$counter_inc'(E):-nb_getval(E,F),G is F+1,nb_setval(E,G)),(:-'$counter_init'('$insert_counter')),(:-'$counter_init'('$delete_counter')),('$insert_counter_inc':-'$counter_inc'('$insert_counter')),('$delete_counter_inc':-'$counter_inc'('$delete_counter')),(counter_stats(H,I):-'$counter'('$insert_counter',H),'$counter'('$delete_counter',I))]
|
|
;
|
|
A=[]
|
|
).
|
|
chr_module_declaration(A) :-
|
|
get_target_module(B),
|
|
( B\==chr_translate ->
|
|
A=[(:-multifile chr:'$chr_module'/1),chr:'$chr_module'(B)]
|
|
;
|
|
A=[]
|
|
).
|
|
partition_clauses([],[],[],[]).
|
|
partition_clauses([A|B],C,D,E) :-
|
|
( parse_rule(A,F) ->
|
|
C=G,
|
|
D=[F|H],
|
|
E=I
|
|
;
|
|
( is_declaration(A,J) ->
|
|
append(J,G,C),
|
|
D=H,
|
|
E=I
|
|
)
|
|
;
|
|
( is_module_declaration(A,K) ->
|
|
target_module(K),
|
|
C=G,
|
|
D=H,
|
|
E=[A|I]
|
|
)
|
|
;
|
|
( is_type_definition(A) ->
|
|
C=G,
|
|
D=H,
|
|
E=I
|
|
)
|
|
;
|
|
( A=(handler _) ->
|
|
format('CHR compiler WARNING: ~w.
|
|
',[A]),
|
|
format(' `--> SICStus compatibility: ignoring handler/1 declaration.
|
|
',[]),
|
|
C=G,
|
|
D=H,
|
|
E=I
|
|
)
|
|
;
|
|
( A=(rules _) ->
|
|
format('CHR compiler WARNING: ~w.
|
|
',[A]),
|
|
format(' `--> SICStus compatibility: ignoring rules/1 declaration.
|
|
',[]),
|
|
C=G,
|
|
D=H,
|
|
E=I
|
|
)
|
|
;
|
|
( A=option(L,M) ->
|
|
handle_option(L,M),
|
|
C=G,
|
|
D=H,
|
|
E=I
|
|
)
|
|
;
|
|
C=G,
|
|
D=H,
|
|
E=[A|I]
|
|
),
|
|
partition_clauses(B,G,H,I).
|
|
is_declaration(A,B) :-
|
|
( A=(:-C) ->
|
|
true
|
|
;
|
|
A=C
|
|
),
|
|
C=..[constraints,D],
|
|
conj2list(D,E),
|
|
extract_type_mode(E,B).
|
|
extract_type_mode([],[]).
|
|
extract_type_mode([A/B|C],[A/B|D]) :-
|
|
!,
|
|
extract_type_mode(C,D).
|
|
extract_type_mode([A|B],[C|D]) :-
|
|
functor(A,E,F),
|
|
C=E/F,
|
|
A=..[_|G],
|
|
extract_types_and_modes(G,H,I),
|
|
constraint_type(E/F,H),
|
|
constraint_mode(E/F,I),
|
|
extract_type_mode(B,D).
|
|
extract_types_and_modes([],[],[]).
|
|
extract_types_and_modes([(+A)|B],[A|C],[+|D]) :-
|
|
!,
|
|
extract_types_and_modes(B,C,D).
|
|
extract_types_and_modes([(?A)|B],[A|C],[?|D]) :-
|
|
!,
|
|
extract_types_and_modes(B,C,D).
|
|
extract_types_and_modes([(-A)|B],[A|C],[?|D]) :-
|
|
!,
|
|
extract_types_and_modes(B,C,D).
|
|
extract_types_and_modes([A|_],_,_) :-
|
|
format('CHR compiler ERROR: Illegal mode/type declaration "~w".
|
|
',[A]),
|
|
format(' `--> correct syntax is +type, -type or ?type.
|
|
',[]),
|
|
fail.
|
|
is_type_definition(A) :-
|
|
( A=(:-B) ->
|
|
true
|
|
;
|
|
A=B
|
|
),
|
|
B=..[chr_type,C],
|
|
( C=(D--->E) ->
|
|
tdisj2list(E,F),
|
|
type_definition(D,F)
|
|
;
|
|
format('CHR compiler WARNING: Illegal type definition "~w".
|
|
',[C]),
|
|
format(' `--> Ignoring this malformed type definition.
|
|
',[])
|
|
).
|
|
tdisj2list(A,B) :-
|
|
tdisj2list(A,B,[]).
|
|
tdisj2list(A,B,C) :-
|
|
A=(D;E),
|
|
!,
|
|
tdisj2list(D,B,F),
|
|
tdisj2list(E,F,C).
|
|
tdisj2list(A,[A|B],B).
|
|
parse_rule(A,B) :-
|
|
A=(C@D),
|
|
!,
|
|
rule(D,yes(C),B).
|
|
parse_rule(A,B) :-
|
|
rule(A,no,B).
|
|
rule(A,B,C) :-
|
|
A=(D pragma E),
|
|
!,
|
|
is_rule(D,F,G),
|
|
conj2list(E,H),
|
|
inc_rule_count(I),
|
|
C=pragma(F,G,H,B,I).
|
|
rule(A,B,C) :-
|
|
is_rule(A,D,E),
|
|
inc_rule_count(F),
|
|
C=pragma(D,E,[],B,F).
|
|
is_rule(A,B,C) :-
|
|
A=(D==>E),
|
|
!,
|
|
conj2list(D,F),
|
|
get_ids(F,G,H),
|
|
C=ids([],G),
|
|
( E=(I '|' J) ->
|
|
B=rule([],H,I,J)
|
|
;
|
|
B=rule([],H,true,E)
|
|
).
|
|
is_rule(A,B,C) :-
|
|
A=(D<=>E),
|
|
!,
|
|
( E=(F '|' G) ->
|
|
H=F,
|
|
I=G
|
|
;
|
|
H=true,
|
|
I=E
|
|
),
|
|
( D=(J\K) ->
|
|
conj2list(J,L),
|
|
conj2list(K,M),
|
|
get_ids(L,N,O,0,P),
|
|
get_ids(M,Q,R,P,_),
|
|
C=ids(Q,N)
|
|
;
|
|
conj2list(D,M),
|
|
O=[],
|
|
get_ids(M,Q,R),
|
|
C=ids(Q,[])
|
|
),
|
|
B=rule(R,O,H,I).
|
|
get_ids(A,B,C) :-
|
|
get_ids(A,B,C,0,_).
|
|
get_ids([],[],[],A,A).
|
|
get_ids([A|B],[C|D],[E|F],C,G) :-
|
|
( A=E#C ->
|
|
true
|
|
;
|
|
E=A
|
|
),
|
|
H is C+1,
|
|
get_ids(B,D,F,H,G).
|
|
is_module_declaration((:-module(A)),A).
|
|
is_module_declaration((:-module(A,_)),A).
|
|
add_constraints([]).
|
|
add_constraints([A|B]) :-
|
|
max_occurrence(A,0),
|
|
A=_/C,
|
|
length(D,C),
|
|
set_elems(D,?),
|
|
constraint_mode(A,D),
|
|
add_constraints(B).
|
|
add_rules([]).
|
|
add_rules([A|B]) :-
|
|
A=pragma(_,_,_,_,C),
|
|
rule(C,A),
|
|
add_rules(B).
|
|
check_declared_constraints(A) :-
|
|
check_declared_constraints(A,[]).
|
|
check_declared_constraints([],_).
|
|
check_declared_constraints([A|B],C) :-
|
|
( memberchk_eq(A,C) ->
|
|
format('CHR compiler ERROR: constraint ~w multiply defined.
|
|
',[A]),
|
|
format(' `--> Remove redundant declaration!
|
|
',[]),
|
|
fail
|
|
;
|
|
true
|
|
),
|
|
check_declared_constraints(B,[A|C]).
|
|
check_rules([],_).
|
|
check_rules([A|B],C) :-
|
|
check_rule(A,C),
|
|
check_rules(B,C).
|
|
check_rule(A,B) :-
|
|
check_rule_indexing(A),
|
|
A=pragma(C,_,D,_,_),
|
|
C=rule(E,F,_,_),
|
|
append(E,F,G),
|
|
check_head_constraints(G,B,A),
|
|
check_pragmas(D,A).
|
|
check_head_constraints([],_,_).
|
|
check_head_constraints([A|B],C,D) :-
|
|
functor(A,E,F),
|
|
( member(E/F,C) ->
|
|
check_head_constraints(B,C,D)
|
|
;
|
|
format('CHR compiler ERROR: Undeclared constraint ~w in head of ~@.
|
|
',[E/F,format_rule(D)]),
|
|
format(' `--> Constraint should be one of ~w.
|
|
',[C]),
|
|
fail
|
|
).
|
|
check_pragmas([],_).
|
|
check_pragmas([A|B],C) :-
|
|
check_pragma(A,C),
|
|
check_pragmas(B,C).
|
|
check_pragma(A,B) :-
|
|
var(A),
|
|
!,
|
|
format('CHR compiler ERROR: invalid pragma ~w in ~@.
|
|
',[A,format_rule(B)]),
|
|
format(' `--> Pragma should not be a variable!
|
|
',[]),
|
|
fail.
|
|
check_pragma(passive(A),B) :-
|
|
!,
|
|
B=pragma(_,ids(C,D),_,_,E),
|
|
( memberchk_eq(A,C) ->
|
|
true
|
|
;
|
|
( memberchk_eq(A,D) ->
|
|
true
|
|
)
|
|
;
|
|
format('CHR compiler ERROR: invalid identifier ~w in pragma passive in ~@.
|
|
',[A,format_rule(B)]),
|
|
fail
|
|
),
|
|
passive(E,A).
|
|
check_pragma(A,B) :-
|
|
A=already_in_heads,
|
|
!,
|
|
format('CHR compiler WARNING: currently unsupported pragma ~w in ~@.
|
|
',[A,format_rule(B)]),
|
|
format(' `--> Pragma is ignored. Termination and correctness may be affected
|
|
',[]).
|
|
check_pragma(A,B) :-
|
|
A=already_in_head(_),
|
|
!,
|
|
format('CHR compiler WARNING: currently unsupported pragma ~w in ~@.
|
|
',[A,format_rule(B)]),
|
|
format(' `--> Pragma is ignored. Termination and correctness may be affected
|
|
',[]).
|
|
check_pragma(A,B) :-
|
|
format('CHR compiler ERROR: invalid pragma ~w in ~@.
|
|
',[A,format_rule(B)]),
|
|
format(' `--> Pragma should be one of passive/1!
|
|
',[]),
|
|
fail.
|
|
format_rule(A) :-
|
|
A=pragma(_,_,_,B,C),
|
|
( B=yes(D) ->
|
|
write('rule '),
|
|
write(D)
|
|
;
|
|
write('rule number '),
|
|
write(C)
|
|
).
|
|
check_rule_indexing(A) :-
|
|
A=pragma(B,_,_,_,_),
|
|
B=rule(C,D,E,_),
|
|
term_variables(C-D,F),
|
|
remove_anti_monotonic_guards(E,F,G),
|
|
check_indexing(C,G-D),
|
|
check_indexing(D,G-C).
|
|
remove_anti_monotonic_guards(A,B,C) :-
|
|
conj2list(A,D),
|
|
remove_anti_monotonic_guard_list(D,B,E),
|
|
list2conj(E,C).
|
|
remove_anti_monotonic_guard_list([],_,[]).
|
|
remove_anti_monotonic_guard_list([A|B],C,D) :-
|
|
( A=var(E),
|
|
memberchk_eq(E,C) ->
|
|
D=F
|
|
;
|
|
D=[A|F]
|
|
),
|
|
remove_anti_monotonic_guard_list(B,C,F).
|
|
check_indexing([],_).
|
|
check_indexing([A|B],C) :-
|
|
functor(A,D,E),
|
|
A=..[_|F],
|
|
term_variables(B-C,G),
|
|
check_indexing(F,1,D/E,G),
|
|
check_indexing(B,[A|C]).
|
|
check_indexing([],_,_,_).
|
|
check_indexing([A|B],C,D,E) :-
|
|
( is_indexed_argument(D,C) ->
|
|
true
|
|
;
|
|
( nonvar(A) ->
|
|
indexed_argument(D,C)
|
|
)
|
|
;
|
|
term_variables(B,F),
|
|
append(F,E,G),
|
|
( memberchk_eq(A,G) ->
|
|
indexed_argument(D,C)
|
|
;
|
|
true
|
|
)
|
|
),
|
|
H is C+1,
|
|
term_variables(A,I),
|
|
append(I,E,J),
|
|
check_indexing(B,H,D,J).
|
|
add_occurrences([]).
|
|
add_occurrences([A|B]) :-
|
|
A=pragma(rule(C,D,_,_),ids(E,F),_,_,G),
|
|
add_occurrences(C,E,G),
|
|
add_occurrences(D,F,G),
|
|
add_occurrences(B).
|
|
add_occurrences([],[],_).
|
|
add_occurrences([A|B],[C|D],E) :-
|
|
functor(A,F,G),
|
|
H=F/G,
|
|
new_occurrence(H,E,C),
|
|
add_occurrences(B,D,E).
|
|
is_observed(A,B) :-
|
|
is_self_observer(A),
|
|
ai_is_observed(A,B).
|
|
observation_analysis(A) :-
|
|
( chr_pp_flag(observation,on) ->
|
|
observation_analysis(A,A)
|
|
;
|
|
true
|
|
).
|
|
observation_analysis([],_).
|
|
observation_analysis([A|B],C) :-
|
|
get_max_occurrence(A,D),
|
|
observation_analysis_occurrences(A,1,D,C),
|
|
observation_analysis(B,C).
|
|
observation_analysis_occurrences(A,B,C,D) :-
|
|
( B>C ->
|
|
true
|
|
;
|
|
observation_analysis_occurrence(A,B,D),
|
|
E is B+1,
|
|
observation_analysis_occurrences(A,E,C,D)
|
|
).
|
|
observation_analysis_occurrence(A,B,C) :-
|
|
get_occurrence(A,B,D,E),
|
|
( is_passive(D,E) ->
|
|
true
|
|
;
|
|
get_rule(D,F),
|
|
F=pragma(rule(G,H,_,I),ids(J,K),_,_,_),
|
|
( select2(E,L,J,G,_,M) ->
|
|
append(M,H,N)
|
|
;
|
|
( select2(E,L,K,H,_,O) ->
|
|
append(O,G,N)
|
|
)
|
|
),
|
|
observe_heads(A,N),
|
|
observe_body(A,I,C)
|
|
).
|
|
observe_heads(A,B) :-
|
|
findall(C/D,(member(E,B),functor(E,C,D)),F),
|
|
observe_all(A,F).
|
|
observe_all(A,B) :-
|
|
( B=[C|D] ->
|
|
observes(A,C),
|
|
observe_all(A,D)
|
|
;
|
|
true
|
|
).
|
|
spawn_all(A,B) :-
|
|
( B=[C|D] ->
|
|
spawns_observer(A,C),
|
|
spawn_all(A,D)
|
|
;
|
|
true
|
|
).
|
|
spawn_all_triggers(A,B) :-
|
|
( B=[C|D] ->
|
|
( may_trigger(C) ->
|
|
spawns_observer(A,C)
|
|
;
|
|
true
|
|
),
|
|
spawn_all_triggers(A,D)
|
|
;
|
|
true
|
|
).
|
|
observe_body(A,B,C) :-
|
|
( var(B) ->
|
|
spawn_all(A,C)
|
|
;
|
|
( B=true ->
|
|
true
|
|
)
|
|
;
|
|
( B=fail ->
|
|
true
|
|
)
|
|
;
|
|
( B=(D,E) ->
|
|
observe_body(A,D,C),
|
|
observe_body(A,E,C)
|
|
)
|
|
;
|
|
( B=(D;E) ->
|
|
observe_body(A,D,C),
|
|
observe_body(A,E,C)
|
|
)
|
|
;
|
|
( B=(D->E) ->
|
|
observe_body(A,D,C),
|
|
observe_body(A,E,C)
|
|
)
|
|
;
|
|
( functor(B,F,G),
|
|
member(F/G,C) ->
|
|
spawns_observer(A,F/G)
|
|
)
|
|
;
|
|
( B=(_=_) ->
|
|
spawn_all_triggers(A,C)
|
|
)
|
|
;
|
|
( B=(_ is _) ->
|
|
spawn_all_triggers(A,C)
|
|
)
|
|
;
|
|
( binds_b(B,H) ->
|
|
( H==[] ->
|
|
true
|
|
;
|
|
spawn_all_triggers(A,C)
|
|
)
|
|
)
|
|
;
|
|
spawn_all(A,C)
|
|
).
|
|
late_allocation_analysis(A) :-
|
|
( chr_pp_flag(late_allocation,on) ->
|
|
late_allocation(A)
|
|
;
|
|
true
|
|
).
|
|
late_allocation([]).
|
|
late_allocation([A|B]) :-
|
|
allocation_occurrence(A,1),
|
|
late_allocation(B).
|
|
generate_attach_detach_a_constraint_all([],[]).
|
|
generate_attach_detach_a_constraint_all([A|B],C) :-
|
|
(
|
|
(
|
|
chr_pp_flag(debugable,on)
|
|
;
|
|
may_trigger(A)
|
|
) ->
|
|
generate_attach_a_constraint(A,D),
|
|
generate_detach_a_constraint(A,E)
|
|
;
|
|
D=[],
|
|
E=[]
|
|
),
|
|
generate_attach_detach_a_constraint_all(B,F),
|
|
append_lists([D,E,F],C).
|
|
generate_attach_a_constraint(A,[B,C]) :-
|
|
generate_attach_a_constraint_empty_list(A,B),
|
|
get_max_constraint_index(D),
|
|
( D==1 ->
|
|
generate_attach_a_constraint_1_1(A,C)
|
|
;
|
|
generate_attach_a_constraint_t_p(A,C)
|
|
).
|
|
generate_attach_a_constraint_skeleton(A,B,C,D) :-
|
|
make_name(attach_,A,E),
|
|
F=..[E|B],
|
|
D=(F:-C).
|
|
generate_attach_a_constraint_empty_list(A,B) :-
|
|
generate_attach_a_constraint_skeleton(A,[[],_],true,B).
|
|
generate_attach_a_constraint_1_1(A,B) :-
|
|
C=[[D|E],F],
|
|
generate_attach_a_constraint_skeleton(A,C,G,B),
|
|
generate_attach_body_1(A,D,F,H),
|
|
make_name(attach_,A,I),
|
|
J=..[I,E,F],
|
|
chr_pp_flag(solver_events,K),
|
|
( K\==none ->
|
|
C=[[D|_],F],
|
|
get_target_module(L),
|
|
M=clp_events:subscribe(D,K,L,chr_runtime:'chr run_suspensions'([F]))
|
|
;
|
|
M=true
|
|
),
|
|
G=(H,M,J).
|
|
generate_attach_body_1(_,A,B,C) :-
|
|
get_target_module(D),
|
|
C=(get_attr(A,D,E)->F=[B|E],put_attr(A,D,F);put_attr(A,D,[B])).
|
|
generate_attach_a_constraint_t_p(A,B) :-
|
|
C=[[D|E],F],
|
|
generate_attach_a_constraint_skeleton(A,C,G,B),
|
|
make_name(attach_,A,H),
|
|
I=..[H,E,F],
|
|
generate_attach_body_n(A,D,F,J),
|
|
chr_pp_flag(solver_events,K),
|
|
( K\==none ->
|
|
C=[[D|_],F],
|
|
get_target_module(L),
|
|
M=clp_events:subscribe(D,K,L,chr_runtime:'chr run_suspensions'([F]))
|
|
;
|
|
M=true
|
|
),
|
|
G=(J,M,I).
|
|
generate_attach_body_n(A/B,C,D,E) :-
|
|
get_constraint_index(A/B,F),
|
|
or_pattern(F,G),
|
|
get_max_constraint_index(H),
|
|
make_attr(H,I,J,K),
|
|
nth(F,J,L),
|
|
substitute(L,J,[D|L],M),
|
|
make_attr(H,I,M,N),
|
|
substitute(L,J,[D],O),
|
|
make_attr(H,P,O,Q),
|
|
copy_term(J,R),
|
|
nth(F,R,[D]),
|
|
chr_delete(R,[D],S),
|
|
set_elems(S,[]),
|
|
make_attr(H,G,R,T),
|
|
get_target_module(U),
|
|
E=(get_attr(C,U,V)->V=K,(I/\G=:=G->put_attr(C,U,N);P is I\/G,put_attr(C,U,Q));put_attr(C,U,T)).
|
|
generate_detach_a_constraint(A,[B,C]) :-
|
|
generate_detach_a_constraint_empty_list(A,B),
|
|
get_max_constraint_index(D),
|
|
( D==1 ->
|
|
generate_detach_a_constraint_1_1(A,C)
|
|
;
|
|
generate_detach_a_constraint_t_p(A,C)
|
|
).
|
|
generate_detach_a_constraint_empty_list(A,B) :-
|
|
make_name(detach_,A,C),
|
|
D=[[],_],
|
|
E=..[C|D],
|
|
B=(E:-true).
|
|
generate_detach_a_constraint_1_1(A,B) :-
|
|
make_name(detach_,A,C),
|
|
D=[[E|F],G],
|
|
H=..[C|D],
|
|
I=..[C,F,G],
|
|
generate_detach_body_1(A,E,G,J),
|
|
K=(J,I),
|
|
B=(H:-K).
|
|
generate_detach_body_1(_,A,B,C) :-
|
|
get_target_module(D),
|
|
C=(get_attr(A,D,E)->'chr sbag_del_element'(E,B,F),(F==[]->del_attr(A,D);put_attr(A,D,F));true).
|
|
generate_detach_a_constraint_t_p(A,B) :-
|
|
make_name(detach_,A,C),
|
|
D=[[E|F],G],
|
|
H=..[C|D],
|
|
I=..[C,F,G],
|
|
generate_detach_body_n(A,E,G,J),
|
|
K=(J,I),
|
|
B=(H:-K).
|
|
generate_detach_body_n(A/B,C,D,E) :-
|
|
get_constraint_index(A/B,F),
|
|
or_pattern(F,G),
|
|
and_pattern(F,H),
|
|
get_max_constraint_index(I),
|
|
make_attr(I,J,K,L),
|
|
nth(F,K,M),
|
|
substitute(M,K,[],N),
|
|
make_attr(I,O,N,P),
|
|
substitute(M,K,Q,R),
|
|
make_attr(I,J,R,S),
|
|
get_target_module(T),
|
|
E=(get_attr(C,T,U)->U=L,(J/\G=:=G->'chr sbag_del_element'(M,D,Q),(Q==[]->O is J/\H,(O==0->del_attr(C,T);put_attr(C,T,P));put_attr(C,T,S));true);true).
|
|
generate_indexed_variables_clauses(A,B) :-
|
|
( forsome(C,A,chr_translate:may_trigger(C)) ->
|
|
generate_indexed_variables_clauses_(A,B)
|
|
;
|
|
B=[]
|
|
).
|
|
generate_indexed_variables_clauses_([],[]).
|
|
generate_indexed_variables_clauses_([A|B],C) :-
|
|
( is_stored(A) ->
|
|
C=[D|E],
|
|
generate_indexed_variables_clause(A,D)
|
|
;
|
|
C=E
|
|
),
|
|
generate_indexed_variables_clauses_(B,E).
|
|
create_indexed_variables_body([],[],_,_,_,empty,0).
|
|
create_indexed_variables_body([A|B],[C|D],E,F,G,H,I) :-
|
|
J is F+1,
|
|
create_indexed_variables_body(B,D,K,J,G,L,M),
|
|
( C\== +,
|
|
is_indexed_argument(G,F) ->
|
|
( L==empty ->
|
|
H=term_variables(A,E)
|
|
;
|
|
H=(term_variables(A,E,K),L)
|
|
),
|
|
I=M
|
|
;
|
|
E=K,
|
|
H=L,
|
|
I is M+1
|
|
).
|
|
generate_extra_clauses(A,B) :-
|
|
generate_activate_clause(B,C),
|
|
generate_remove_clause(C,D),
|
|
generate_allocate_clause(D,E),
|
|
generate_insert_constraint_internal(E,F),
|
|
global_indexed_variables_clause(A,F,[]).
|
|
generate_remove_clause(A,B) :-
|
|
( is_used_auxiliary_predicate(remove_constraint_internal) ->
|
|
A=[C|B],
|
|
use_auxiliary_predicate(chr_indexed_variables),
|
|
C=(remove_constraint_internal(D,E,F):-arg(2,D,G),G=mutable(H),'chr update_mutable'(removed,G),(compound(H)->E=[],F=no;H==removed->E=[],F=no;F=yes,chr_indexed_variables(D,E)))
|
|
;
|
|
A=B
|
|
).
|
|
generate_activate_clause(A,B) :-
|
|
( is_used_auxiliary_predicate(activate_constraint) ->
|
|
A=[C|B],
|
|
use_auxiliary_predicate(chr_indexed_variables),
|
|
C=(activate_constraint(D,E,F,G):-arg(2,F,H),H=mutable(I),'chr update_mutable'(active,H),(nonvar(G)->true;arg(4,F,J),J=mutable(K),G is K+1,'chr update_mutable'(G,J)),(compound(I)->term_variables(I,E),'chr none_locked'(E),D=yes;I==removed->chr_indexed_variables(F,E),D=yes;E=[],D=no))
|
|
;
|
|
A=B
|
|
).
|
|
generate_allocate_clause(A,B) :-
|
|
( is_used_auxiliary_predicate(allocate_constraint) ->
|
|
A=[C|B],
|
|
use_auxiliary_predicate(chr_indexed_variables),
|
|
C=(allocate_constraint(D,E,F,G):-E=..[suspension,H,I,D,J,K,F|G],J=mutable(0),'chr empty_history'(L),K=mutable(L),chr_indexed_variables(E,M),I=mutable(passive(M)),'chr gen_id'(H))
|
|
;
|
|
A=B
|
|
).
|
|
generate_insert_constraint_internal(A,B) :-
|
|
( is_used_auxiliary_predicate(insert_constraint_internal) ->
|
|
A=[C|B],
|
|
use_auxiliary_predicate(chr_indexed_variables),
|
|
C=(insert_constraint_internal(yes,D,E,F,G,H):-E=..[suspension,I,J,F,K,L,G|H],chr_indexed_variables(E,D),'chr none_locked'(D),J=mutable(active),K=mutable(0),L=mutable(M),'chr empty_history'(M),'chr gen_id'(I))
|
|
;
|
|
A=B
|
|
).
|
|
global_indexed_variables_clause(A,B,C) :-
|
|
( is_used_auxiliary_predicate(chr_indexed_variables) ->
|
|
B=[D|C],
|
|
( chr_pp_flag(reduced_indexing,on) ->
|
|
( forsome(E,A,chr_translate:may_trigger(E)) ->
|
|
F=(G=..[_,_,_,_,_,_,H|_],'$indexed_variables'(H,I))
|
|
;
|
|
F=true,
|
|
I=[]
|
|
),
|
|
D=(chr_indexed_variables(G,I):-F)
|
|
;
|
|
D=(chr_indexed_variables(G,I):-'chr chr_indexed_variables'(G,I))
|
|
)
|
|
;
|
|
B=C
|
|
).
|
|
generate_attach_increment(A) :-
|
|
get_max_constraint_index(B),
|
|
( B>0 ->
|
|
A=[C,D],
|
|
generate_attach_increment_empty(C),
|
|
( B==1 ->
|
|
generate_attach_increment_one(D)
|
|
;
|
|
generate_attach_increment_many(B,D)
|
|
)
|
|
;
|
|
A=[]
|
|
).
|
|
generate_attach_increment_empty((attach_increment([],_):-true)).
|
|
generate_attach_increment_one(A) :-
|
|
B=attach_increment([C|D],E),
|
|
get_target_module(F),
|
|
G=('chr not_locked'(C),(get_attr(C,F,H)->sort(H,I),merge(E,I,J),put_attr(C,F,J);put_attr(C,F,E)),attach_increment(D,E)),
|
|
A=(B:-G).
|
|
generate_attach_increment_many(A,B) :-
|
|
make_attr(A,C,D,E),
|
|
make_attr(A,F,G,H),
|
|
I=attach_increment([J|K],E),
|
|
bagof(L,M^N^O^P^(member2(D,G,M-N),L=(sort(N,O),'chr merge_attributes'(M,O,P))),Q),
|
|
list2conj(Q,R),
|
|
bagof(S,T^U^V^member((T,'chr merge_attributes'(U,V,S)),Q),W),
|
|
make_attr(A,X,W,Y),
|
|
get_target_module(Z),
|
|
A1=('chr not_locked'(J),(get_attr(J,Z,B1)->B1=H,R,X is C\/F,put_attr(J,Z,Y);put_attr(J,Z,E)),attach_increment(K,E)),
|
|
B=(I:-A1).
|
|
generate_attr_unify_hook(A) :-
|
|
get_max_constraint_index(B),
|
|
( B==0 ->
|
|
A=[]
|
|
;
|
|
A=[C],
|
|
( B==1 ->
|
|
generate_attr_unify_hook_one(C)
|
|
;
|
|
generate_attr_unify_hook_many(B,C)
|
|
)
|
|
).
|
|
generate_attr_unify_hook_one(A) :-
|
|
B=attr_unify_hook(C,D),
|
|
get_target_module(E),
|
|
make_run_suspensions(F,G),
|
|
make_run_suspensions(C,H),
|
|
I=(sort(C,J),(var(D)->(get_attr(D,E,K)->true;K=[]),sort(K,L),'chr merge_attributes'(J,L,F),put_attr(D,E,F),G;(compound(D)->term_variables(D,M),attach_increment(M,J);true),H)),
|
|
A=(B:-I).
|
|
generate_attr_unify_hook_many(A,B) :-
|
|
make_attr(A,C,D,E),
|
|
make_attr(A,F,G,H),
|
|
bagof(I,J^K^(member(J,D),I=sort(J,K)),L),
|
|
list2conj(L,M),
|
|
bagof(K,J^member(sort(J,K),L),N),
|
|
bagof(O,P^Q^R^S^(member2(N,G,P-Q),O=(sort(Q,R),'chr merge_attributes'(P,R,S))),T),
|
|
bagof(S,P^R^U^member((U,'chr merge_attributes'(P,R,S)),T),V),
|
|
list2conj(T,W),
|
|
make_attr(A,X,V,Y),
|
|
make_attr(A,C,N,Z),
|
|
A1=attr_unify_hook(E,B1),
|
|
get_target_module(C1),
|
|
make_run_suspensions_loop(V,D1),
|
|
make_run_suspensions_loop(N,E1),
|
|
F1=(M,(var(B1)->(get_attr(B1,C1,G1)->G1=H,W,X is C\/F,put_attr(B1,C1,Y),D1;put_attr(B1,C1,Z),E1);(compound(B1)->term_variables(B1,H1),attach_increment(H1,Z);true),E1)),
|
|
B=(A1:-F1).
|
|
make_run_suspensions(A,B) :-
|
|
( chr_pp_flag(debugable,on) ->
|
|
B='chr run_suspensions_d'(A)
|
|
;
|
|
B='chr run_suspensions'(A)
|
|
).
|
|
make_run_suspensions_loop(A,B) :-
|
|
( chr_pp_flag(debugable,on) ->
|
|
B='chr run_suspensions_loop_d'(A)
|
|
;
|
|
B='chr run_suspensions_loop'(A)
|
|
).
|
|
generate_insert_delete_constraints([],[]).
|
|
generate_insert_delete_constraints([A|B],C) :-
|
|
( is_stored(A) ->
|
|
C=[D,E|F],
|
|
generate_insert_delete_constraint(A,D,E)
|
|
;
|
|
C=F
|
|
),
|
|
generate_insert_delete_constraints(B,F).
|
|
generate_insert_delete_constraint(A,B,C) :-
|
|
get_store_type(A,D),
|
|
generate_insert_constraint(D,A,B),
|
|
generate_delete_constraint(D,A,C).
|
|
generate_insert_constraint(A,B,C) :-
|
|
make_name('$insert_in_store_',B,D),
|
|
E=..[D,F],
|
|
generate_insert_constraint_body(A,B,F,G),
|
|
( chr_pp_flag(store_counter,on) ->
|
|
H='$insert_counter_inc'
|
|
;
|
|
H=true
|
|
),
|
|
C=(E:-H,G).
|
|
generate_insert_constraint_body(default,A,B,C) :-
|
|
get_target_module(_),
|
|
get_max_constraint_index(D),
|
|
( D==1 ->
|
|
generate_attach_body_1(A,E,B,F)
|
|
;
|
|
generate_attach_body_n(A,E,B,F)
|
|
),
|
|
C=('chr global_term_ref_1'(E),F).
|
|
generate_insert_constraint_body(multi_hash(A),B,C,D) :-
|
|
generate_multi_hash_insert_constraint_bodies(A,B,C,D).
|
|
generate_insert_constraint_body(global_ground,A,B,C) :-
|
|
global_ground_store_name(A,D),
|
|
C=(nb_getval(D,E),b_setval(D,[B|E])).
|
|
generate_insert_constraint_body(global_singleton,A,B,C) :-
|
|
global_singleton_store_name(A,D),
|
|
C=b_setval(D,B).
|
|
generate_insert_constraint_body(multi_store(A),B,C,D) :-
|
|
find_with_var_identity(E,[C],(member(F,A),chr_translate:generate_insert_constraint_body(F,B,C,E)),G),
|
|
list2conj(G,D).
|
|
generate_multi_hash_insert_constraint_bodies([],_,_,true).
|
|
generate_multi_hash_insert_constraint_bodies([A|B],C,D,(E,F)) :-
|
|
multi_hash_store_name(C,A,G),
|
|
multi_hash_key(C,A,D,H,I),
|
|
E=(H,nb_getval(G,J),insert_ht(J,I,D)),
|
|
generate_multi_hash_insert_constraint_bodies(B,C,D,F).
|
|
generate_delete_constraint(A,B,C) :-
|
|
make_name('$delete_from_store_',B,D),
|
|
E=..[D,F],
|
|
generate_delete_constraint_body(A,B,F,G),
|
|
( chr_pp_flag(store_counter,on) ->
|
|
H='$delete_counter_inc'
|
|
;
|
|
H=true
|
|
),
|
|
C=(E:-H,G).
|
|
generate_delete_constraint_body(default,A,B,C) :-
|
|
get_target_module(_),
|
|
get_max_constraint_index(D),
|
|
( D==1 ->
|
|
generate_detach_body_1(A,E,B,F),
|
|
C=('chr global_term_ref_1'(E),F)
|
|
;
|
|
generate_detach_body_n(A,E,B,F),
|
|
C=('chr global_term_ref_1'(E),F)
|
|
).
|
|
generate_delete_constraint_body(multi_hash(A),B,C,D) :-
|
|
generate_multi_hash_delete_constraint_bodies(A,B,C,D).
|
|
generate_delete_constraint_body(global_ground,A,B,C) :-
|
|
global_ground_store_name(A,D),
|
|
C=(nb_getval(D,E),'chr sbag_del_element'(E,B,F),b_setval(D,F)).
|
|
generate_delete_constraint_body(global_singleton,A,_,B) :-
|
|
global_singleton_store_name(A,C),
|
|
B=b_setval(C,[]).
|
|
generate_delete_constraint_body(multi_store(A),B,C,D) :-
|
|
find_with_var_identity(E,[C],(member(F,A),chr_translate:generate_delete_constraint_body(F,B,C,E)),G),
|
|
list2conj(G,D).
|
|
generate_multi_hash_delete_constraint_bodies([],_,_,true).
|
|
generate_multi_hash_delete_constraint_bodies([A|B],C,D,(E,F)) :-
|
|
multi_hash_store_name(C,A,G),
|
|
multi_hash_key(C,A,D,H,I),
|
|
E=(H,nb_getval(G,J),delete_ht(J,I,D)),
|
|
generate_multi_hash_delete_constraint_bodies(B,C,D,F).
|
|
generate_delete_constraint_call(A,B,C) :-
|
|
make_name('$delete_from_store_',A,D),
|
|
C=..[D,B].
|
|
generate_insert_constraint_call(A,B,C) :-
|
|
make_name('$insert_in_store_',A,D),
|
|
C=..[D,B].
|
|
generate_attach_code(A,[B|C]) :-
|
|
enumerate_stores_code(A,B),
|
|
generate_attach_code(A,C,[]).
|
|
generate_attach_code([],A,A).
|
|
generate_attach_code([A|B],C,D) :-
|
|
get_store_type(A,E),
|
|
generate_attach_code(E,A,C,F),
|
|
generate_attach_code(B,F,D).
|
|
generate_attach_code(default,_,A,A).
|
|
generate_attach_code(multi_hash(A),B,C,D) :-
|
|
multi_hash_store_initialisations(A,B,C,E),
|
|
multi_hash_via_lookups(A,B,E,D).
|
|
generate_attach_code(global_ground,A,B,C) :-
|
|
global_ground_store_initialisation(A,B,C).
|
|
generate_attach_code(global_singleton,A,B,C) :-
|
|
global_singleton_store_initialisation(A,B,C).
|
|
generate_attach_code(multi_store(A),B,C,D) :-
|
|
multi_store_generate_attach_code(A,B,C,D).
|
|
multi_store_generate_attach_code([],_,A,A).
|
|
multi_store_generate_attach_code([A|B],C,D,E) :-
|
|
generate_attach_code(A,C,D,F),
|
|
multi_store_generate_attach_code(B,C,F,E).
|
|
multi_hash_store_initialisations([],_,A,A).
|
|
multi_hash_store_initialisations([A|B],C,D,E) :-
|
|
multi_hash_store_name(C,A,F),
|
|
D=[(:-new_ht(G),nb_setval(F,G))|H],
|
|
multi_hash_store_initialisations(B,C,H,E).
|
|
global_ground_store_initialisation(A,B,C) :-
|
|
global_ground_store_name(A,D),
|
|
B=[(:-nb_setval(D,[]))|C].
|
|
global_singleton_store_initialisation(A,B,C) :-
|
|
global_singleton_store_name(A,D),
|
|
B=[(:-nb_setval(D,[]))|C].
|
|
multi_hash_via_lookups([],_,A,A).
|
|
multi_hash_via_lookups([A|B],C,D,E) :-
|
|
multi_hash_via_lookup_name(C,A,F),
|
|
G=..[F,H,I],
|
|
multi_hash_store_name(C,A,J),
|
|
K=(nb_getval(J,L),lookup_ht(L,H,I)),
|
|
D=[(G:-K)|M],
|
|
multi_hash_via_lookups(B,C,M,E).
|
|
multi_hash_via_lookup_name(A/B,C,D) :-
|
|
( integer(C) ->
|
|
E=C
|
|
;
|
|
( is_list(C) ->
|
|
atom_concat_list(C,E)
|
|
)
|
|
),
|
|
atom_concat_list(['$via1_multi_hash_',A,/,B,-,E],D).
|
|
multi_hash_store_name(A/B,C,D) :-
|
|
get_target_module(E),
|
|
( integer(C) ->
|
|
F=C
|
|
;
|
|
( is_list(C) ->
|
|
atom_concat_list(C,F)
|
|
)
|
|
),
|
|
atom_concat_list(['$chr_store_multi_hash_',E,:,A,/,B,-,F],D).
|
|
multi_hash_key(_/_,A,B,C,D) :-
|
|
(
|
|
( integer(A) ->
|
|
E=A
|
|
;
|
|
A=[E]
|
|
) ->
|
|
F is E+6,
|
|
C=arg(F,B,D)
|
|
;
|
|
( is_list(A) ->
|
|
sort(A,G),
|
|
find_with_var_identity(arg(H,B,I)-I,[B],(member(E,G),H is E+6),J),
|
|
pairup(K,L,J),
|
|
D=..[k|L],
|
|
list2conj(K,C)
|
|
)
|
|
).
|
|
multi_hash_key_args(A,B,C) :-
|
|
( integer(A) ->
|
|
arg(A,B,D),
|
|
C=[D]
|
|
;
|
|
( is_list(A) ->
|
|
sort(A,E),
|
|
term_variables(B,F),
|
|
find_with_var_identity(D,F,(member(G,E),arg(G,B,D)),C)
|
|
)
|
|
).
|
|
global_ground_store_name(A/B,C) :-
|
|
get_target_module(D),
|
|
atom_concat_list(['$chr_store_global_ground_',D,:,A,/,B],C).
|
|
global_singleton_store_name(A/B,C) :-
|
|
get_target_module(D),
|
|
atom_concat_list(['$chr_store_global_singleton_',D,:,A,/,B],C).
|
|
enumerate_stores_code(A,B) :-
|
|
C='$enumerate_suspensions'(D),
|
|
enumerate_store_bodies(A,D,E),
|
|
list2disj(E,F),
|
|
B=(C:-F).
|
|
enumerate_store_bodies([],_,[]).
|
|
enumerate_store_bodies([A|B],C,D) :-
|
|
( is_stored(A) ->
|
|
get_store_type(A,E),
|
|
enumerate_store_body(E,A,C,F),
|
|
D=[F|G]
|
|
;
|
|
D=G
|
|
),
|
|
enumerate_store_bodies(B,C,G).
|
|
enumerate_store_body(default,A,B,C) :-
|
|
get_constraint_index(A,D),
|
|
get_target_module(E),
|
|
get_max_constraint_index(F),
|
|
G=('chr global_term_ref_1'(H),get_attr(H,E,I)),
|
|
( F>1 ->
|
|
J is D+1,
|
|
K=(arg(J,I,L),'chr sbag_member'(B,L))
|
|
;
|
|
K='chr sbag_member'(B,I)
|
|
),
|
|
C=(G,K).
|
|
enumerate_store_body(multi_hash([A|_]),B,C,D) :-
|
|
multi_hash_enumerate_store_body(A,B,C,D).
|
|
enumerate_store_body(global_ground,A,B,C) :-
|
|
global_ground_store_name(A,D),
|
|
C=(nb_getval(D,E),'chr sbag_member'(B,E)).
|
|
enumerate_store_body(global_singleton,A,B,C) :-
|
|
global_singleton_store_name(A,D),
|
|
C=(nb_getval(D,B),B\==[]).
|
|
enumerate_store_body(multi_store(A),B,C,D) :-
|
|
once((member(E,A),enumerate_store_body(E,B,C,D))).
|
|
multi_hash_enumerate_store_body(A,B,C,D) :-
|
|
multi_hash_store_name(B,A,E),
|
|
D=(nb_getval(E,F),value_ht(F,C)).
|
|
guard_simplification :-
|
|
( chr_pp_flag(guard_simplification,on) ->
|
|
multiple_occ_constraints_checked([]),
|
|
simplify_guards(1)
|
|
;
|
|
true
|
|
).
|
|
add_type_information_(_,[],true) :-
|
|
!.
|
|
add_type_information_(A,[B|C],D) :-
|
|
!,
|
|
add_type_information(A,B,E),
|
|
D=(E,F),
|
|
add_type_information_(A,C,F).
|
|
compute_derived_info(_,[],_,_,_,_,_,_,[],[]) :-
|
|
!.
|
|
compute_derived_info(A,[B|C],D,E,F,G,H,I,J,K) :-
|
|
!,
|
|
copy_term(A-F,L),
|
|
variable_replacement(A-F,L,M),
|
|
append(B,M,N),
|
|
list2conj(A,O),
|
|
negate_b(O,P),
|
|
make_head_matchings_explicit_not_negated2(E,D,Q),
|
|
list2conj(Q,R),
|
|
term_variables(N,S),
|
|
term_variables(A-F-Q,T),
|
|
new_vars(T,S,U),
|
|
append(N,U,V),
|
|
negate_b(F,W),
|
|
( F==true ->
|
|
X=P
|
|
;
|
|
X=(P;R,W)
|
|
),
|
|
copy_with_variable_replacement(X,Y,V),
|
|
copy_with_variable_replacement(F,Z,V),
|
|
copy_with_variable_replacement(A,A1,V),
|
|
list2conj(A1,B1),
|
|
add_guard_to_head(H,Z,C1),
|
|
add_guard_to_head(C1,B1,D1),
|
|
compute_derived_info(A,C,D,E,F,G,H,I,E1,F1),
|
|
append([Y],E1,J),
|
|
append([D1],F1,K).
|
|
simplify_guard(A,B,C,D,E) :-
|
|
conj2list(A,F),
|
|
guard_entailment:simplify_guards(C,B,F,G,E),
|
|
list2conj(G,D).
|
|
new_vars([],_,[]).
|
|
new_vars([A|B],C,D) :-
|
|
( memberchk_eq(A,C) ->
|
|
new_vars(B,C,D)
|
|
;
|
|
D=[A-E,E-A|F],
|
|
new_vars(B,C,F)
|
|
).
|
|
head_subset(A,B,C) :-
|
|
head_subset(A,B,C,[],_).
|
|
head_subset([],A,B,C,D) :-
|
|
!,
|
|
B=C,
|
|
D=A.
|
|
head_subset([A|B],C,D,E,F) :-
|
|
!,
|
|
head_subset(A,C,G,E,H),
|
|
head_subset(B,H,I,G,J),
|
|
D=I,
|
|
F=J.
|
|
head_subset(A,[B|C],D,E,F) :-
|
|
!,
|
|
(
|
|
head_subset(A,B,G,E,_),
|
|
D=G,
|
|
F=C
|
|
;
|
|
head_subset(A,C,H,E,I),
|
|
D=H,
|
|
F=[B|I]
|
|
).
|
|
head_subset(A,B,C,D,E) :-
|
|
variable_replacement(A,B,D,C),
|
|
E=[].
|
|
make_head_matchings_explicit(A,B,C) :-
|
|
extract_variables(A,D),
|
|
make_matchings_explicit(D,E,[],[],_,C),
|
|
insert_variables(E,A,B).
|
|
make_head_matchings_explicit_not_negated(A,B,C) :-
|
|
extract_variables(A,D),
|
|
make_matchings_explicit_not_negated(D,E,[],C),
|
|
insert_variables(E,A,B).
|
|
make_head_matchings_explicit_not_negated2(A,B,C) :-
|
|
extract_variables(A,D),
|
|
extract_variables(B,E),
|
|
make_matchings_explicit_not_negated(D,E,[],C).
|
|
extract_variables([],[]).
|
|
extract_variables([A|B],C) :-
|
|
A=..[_|D],
|
|
extract_variables(B,E),
|
|
append(D,E,C).
|
|
insert_variables([],[],[]) :-
|
|
!.
|
|
insert_variables(A,[B|C],[D|E]) :-
|
|
B=..[F|G],
|
|
length(G,H),
|
|
take_first_N(A,H,I,J),
|
|
D=..[F|I],
|
|
insert_variables(J,C,E).
|
|
take_first_N(A,0,[],A) :-
|
|
!.
|
|
take_first_N([A|B],C,[A|D],E) :-
|
|
F is C-1,
|
|
take_first_N(B,F,D,E).
|
|
make_matchings_explicit([],[],_,A,A,[]).
|
|
make_matchings_explicit([A|B],[C|D],E,F,G,H) :-
|
|
( var(A) ->
|
|
( memberchk_eq(A,E) ->
|
|
list2disj(F,I),
|
|
H=[(I;C==A)|J],
|
|
K=E
|
|
;
|
|
H=J,
|
|
C=A,
|
|
K=[A|E]
|
|
),
|
|
L=F
|
|
;
|
|
functor(A,M,N),
|
|
A=..[M|O],
|
|
make_matchings_explicit(O,P,E,F,Q,R),
|
|
S=..[M|P],
|
|
( R==[] ->
|
|
H=[functor(C,M,N)|J]
|
|
;
|
|
list2conj(R,T),
|
|
list2disj(F,I),
|
|
U=(C\=S;I;T),
|
|
H=[functor(C,M,N),U|J]
|
|
),
|
|
L=[C\=S|Q],
|
|
term_variables(O,V),
|
|
append(E,V,K)
|
|
),
|
|
make_matchings_explicit(B,D,K,L,G,J).
|
|
make_matchings_explicit_not_negated([],[],_,[]).
|
|
make_matchings_explicit_not_negated([A|B],[C|D],E,F) :-
|
|
F=[C=A|G],
|
|
H=E,
|
|
make_matchings_explicit_not_negated(B,D,H,G).
|
|
add_guard_to_head([],_,[]).
|
|
add_guard_to_head([A|B],C,[D|E]) :-
|
|
( var(A) ->
|
|
find_guard_info_for_var(A,C,D)
|
|
;
|
|
functor(A,F,_),
|
|
A=..[F|G],
|
|
add_guard_to_head(G,C,H),
|
|
D=..[F|H]
|
|
),
|
|
add_guard_to_head(B,C,E).
|
|
find_guard_info_for_var(A,(B,C),D) :-
|
|
!,
|
|
find_guard_info_for_var(A,B,E),
|
|
find_guard_info_for_var(E,C,D).
|
|
find_guard_info_for_var(A,B,C) :-
|
|
( B=(D=E),
|
|
A==D ->
|
|
C=E
|
|
;
|
|
( B=functor(F,G,H),
|
|
A==F,
|
|
ground(G),
|
|
ground(H) ->
|
|
length(I,H),
|
|
C=..[G|I]
|
|
)
|
|
;
|
|
C=A
|
|
).
|
|
replace_some_heads(A,B,_,[],A,B,_,_,[]) :-
|
|
!.
|
|
replace_some_heads([],[A|B],[C|D],[E|F],[],[G|H],I,J,K) :-
|
|
!,
|
|
( C==E ->
|
|
G=E,
|
|
replace_some_heads([],B,D,F,[],H,I,J,K)
|
|
;
|
|
( E=functor(L,M,N),
|
|
C==L ->
|
|
length(O,N),
|
|
( var(A) ->
|
|
P=[],
|
|
G=..[M|O]
|
|
;
|
|
A=..[M|Q],
|
|
use_same_args(Q,O,R,I,J,P),
|
|
G=..[M|R]
|
|
),
|
|
replace_some_heads([],B,D,F,[],H,I,J,S),
|
|
append(P,S,K)
|
|
)
|
|
;
|
|
G=A,
|
|
replace_some_heads([],B,D,[E|F],[],H,I,J,K)
|
|
).
|
|
replace_some_heads([A|B],C,[D|E],[F|G],[H|I],J,K,L,M) :-
|
|
!,
|
|
( D==F ->
|
|
H=F,
|
|
replace_some_heads(B,C,E,G,I,J,K,L,M)
|
|
;
|
|
( F=functor(N,O,P),
|
|
D==N ->
|
|
length(Q,P),
|
|
( var(A) ->
|
|
R=[],
|
|
H=..[O|Q]
|
|
;
|
|
A=..[O|S],
|
|
use_same_args(S,Q,T,K,L,R),
|
|
H=..[O|T]
|
|
),
|
|
replace_some_heads(B,C,E,G,I,J,K,L,U),
|
|
append(R,U,M)
|
|
)
|
|
;
|
|
H=A,
|
|
replace_some_heads(B,C,E,[F|G],I,J,K,L,M)
|
|
).
|
|
use_same_args([],[],[],_,_,[]).
|
|
use_same_args([A|B],[_|C],[D|E],F,G,H) :-
|
|
var(A),
|
|
!,
|
|
D=A,
|
|
use_same_args(B,C,E,F,G,H).
|
|
use_same_args([A|B],[C|D],[E|F],G,H,I) :-
|
|
nonvar(A),
|
|
!,
|
|
( vars_occur_in(A,H) ->
|
|
I=[C=A|J]
|
|
;
|
|
I=J
|
|
),
|
|
E=C,
|
|
use_same_args(B,D,F,G,H,J).
|
|
simplify_heads([],_,_,_,[],[]).
|
|
simplify_heads([A|B],C,D,E,F,G) :-
|
|
A=(H=I),
|
|
(
|
|
(
|
|
nonvar(I)
|
|
;
|
|
vars_occur_in(I,B-C)
|
|
),
|
|
guard_entailment:entails_guard(C,H=I) ->
|
|
( vars_occur_in(I,D-B-C) ->
|
|
G=J,
|
|
F=K
|
|
;
|
|
( vars_occur_in(I,E) ->
|
|
G=[H=I|J]
|
|
;
|
|
G=J
|
|
),
|
|
F=[H|K]
|
|
)
|
|
;
|
|
( nonvar(I),
|
|
functor(I,L,M),
|
|
guard_entailment:entails_guard([functor(H,L,M)|C],H=I) ->
|
|
G=J,
|
|
( vars_occur_in(I,D-B-C) ->
|
|
F=K
|
|
;
|
|
F=[functor(H,L,M)|K]
|
|
)
|
|
)
|
|
;
|
|
F=K,
|
|
G=J
|
|
),
|
|
simplify_heads(B,[A|C],D,E,K,J).
|
|
vars_occur_in(A,B) :-
|
|
term_variables(A,C),
|
|
term_variables(B,D),
|
|
intersect_eq(C,D,E),
|
|
E\==[].
|
|
flatten_stuff([A|B],C) :-
|
|
!,
|
|
flatten_stuff(A,D),
|
|
flatten_stuff(B,E),
|
|
append(D,E,C).
|
|
flatten_stuff((A;B),C) :-
|
|
!,
|
|
flatten_stuff(A,D),
|
|
flatten_stuff(B,E),
|
|
append(D,E,C).
|
|
flatten_stuff((A,B),C) :-
|
|
!,
|
|
flatten_stuff(A,D),
|
|
flatten_stuff(B,E),
|
|
append(D,E,C).
|
|
flatten_stuff(chr_pp_not_in_store(A),[A]) :-
|
|
!.
|
|
flatten_stuff(_,[]).
|
|
unify_stuff(_,[],[]).
|
|
unify_stuff(A,[B|C],[D|E]) :-
|
|
B\==D,
|
|
term_variables(B,F),
|
|
term_variables(D,G),
|
|
intersect_eq(F,G,H),
|
|
check_safe_unif(B,D,H),
|
|
variable_replacement(B,D,I),
|
|
check_replacement(I),
|
|
term_variables(I,J),
|
|
list_difference_eq(J,F,K),
|
|
intersect_eq(A,K,L),
|
|
L==[],
|
|
B=D,
|
|
unify_stuff(A,C,E),
|
|
!.
|
|
unify_stuff(A,B,[_|C]) :-
|
|
unify_stuff(A,B,C).
|
|
unify_stuff(A,[_|B],C) :-
|
|
unify_stuff(A,B,C).
|
|
check_safe_unif(A,B,C) :-
|
|
var(A),
|
|
!,
|
|
var(B),
|
|
(
|
|
(
|
|
memberchk_eq(A,C)
|
|
;
|
|
memberchk_eq(B,C)
|
|
) ->
|
|
A==B
|
|
;
|
|
true
|
|
).
|
|
check_safe_unif([],[],_) :-
|
|
!.
|
|
check_safe_unif([A|B],[C|D],E) :-
|
|
!,
|
|
check_safe_unif(A,C,E),
|
|
!,
|
|
check_safe_unif(B,D,E).
|
|
check_safe_unif(A,B,C) :-
|
|
nonvar(A),
|
|
!,
|
|
nonvar(B),
|
|
A=..[D|E],
|
|
B=..[D|F],
|
|
check_safe_unif(E,F,C).
|
|
check_safe_unif2(A,_) :-
|
|
var(A),
|
|
!.
|
|
check_safe_unif2([],[]) :-
|
|
!.
|
|
check_safe_unif2([A|B],[C|D]) :-
|
|
!,
|
|
check_safe_unif2(A,C),
|
|
!,
|
|
check_safe_unif2(B,D).
|
|
check_safe_unif2(A,B) :-
|
|
nonvar(A),
|
|
!,
|
|
nonvar(B),
|
|
A=..[C|D],
|
|
B=..[C|E],
|
|
check_safe_unif2(D,E).
|
|
check_replacement(A) :-
|
|
check_replacement(A,B),
|
|
sort(B,C),
|
|
length(C,D),
|
|
!,
|
|
length(B,D).
|
|
check_replacement([],[]).
|
|
check_replacement([A-_|B],[A|C]) :-
|
|
check_replacement(B,C).
|
|
add_failing_occ(A,B,C,D,E,F,_,G,H) :-
|
|
A=pragma(rule(_,_,I,_),ids(J,K),_,_,_),
|
|
append(K,J,L),
|
|
missing_partner_cond(B,C,L,D,M,N,G),
|
|
copy_term((N,B,C),(O,P,Q)),
|
|
variable_replacement((N,B,C),(O,P,Q),H),
|
|
copy_with_variable_replacement(I,R,H),
|
|
extract_explicit_matchings(R,S),
|
|
negate_b(S,T),
|
|
copy_with_variable_replacement(M,U,H),
|
|
( check_safe_unif2(F,O),
|
|
F=O ->
|
|
E=[(T;U)]
|
|
;
|
|
E=[chr_pp_void_info]
|
|
).
|
|
missing_partner_cond([],[],[],_,fail,_,_).
|
|
missing_partner_cond([A|B],[_|C],[D|E],D,F,A,G) :-
|
|
!,
|
|
missing_partner_cond(B,C,E,D,F,A,G).
|
|
missing_partner_cond([A|B],[_|C],[_|D],E,F,G,H/I) :-
|
|
F=(chr_pp_not_in_store(A);J),
|
|
missing_partner_cond(B,C,D,E,J,G,H/I).
|
|
extract_explicit_matchings(A=B) :-
|
|
var(A),
|
|
var(B),
|
|
!,
|
|
A=B.
|
|
extract_explicit_matchings(A==B) :-
|
|
var(A),
|
|
var(B),
|
|
!,
|
|
A=B.
|
|
extract_explicit_matchings((A,B),C) :-
|
|
!,
|
|
( extract_explicit_matchings(A) ->
|
|
extract_explicit_matchings(B,C)
|
|
;
|
|
C=(A,D),
|
|
extract_explicit_matchings(B,D)
|
|
).
|
|
extract_explicit_matchings(A,B) :-
|
|
!,
|
|
( extract_explicit_matchings(A) ->
|
|
B=true
|
|
;
|
|
B=A
|
|
).
|
|
add_mode_info([],[],true).
|
|
add_mode_info([+|A],[B|C],D) :-
|
|
!,
|
|
D=(ground(B),E),
|
|
add_mode_info(A,C,E).
|
|
add_mode_info([_|A],[_|B],C) :-
|
|
add_mode_info(A,B,C).
|
|
types2condition([],[],[],[],[]).
|
|
types2condition([A|B],[C|D],[E|F],[G|H],I) :-
|
|
( get_type_definition(A,J) ->
|
|
type2condition(J,C,E,K),
|
|
( G\== + ->
|
|
L=[\+ground(C)|K]
|
|
;
|
|
L=K
|
|
),
|
|
list2disj(L,M),
|
|
I=[M|N],
|
|
types2condition(B,D,F,H,N)
|
|
;
|
|
( builtin_type(A,C,O) ->
|
|
I=[O|N],
|
|
types2condition(B,D,F,H,N)
|
|
)
|
|
;
|
|
format('CHR compiler ERROR: Undefined type ~w.
|
|
',[A]),
|
|
fail
|
|
).
|
|
type2condition([],_,_,[]).
|
|
type2condition([A|B],C,D,E) :-
|
|
( builtin_type(A,C,F) ->
|
|
true
|
|
;
|
|
real_type(A,C,D,F)
|
|
),
|
|
item2list(F,G),
|
|
type2condition(B,C,D,H),
|
|
append(G,H,E).
|
|
item2list([],[]) :-
|
|
!.
|
|
item2list([A|B],[A|B]) :-
|
|
!.
|
|
item2list(A,B) :-
|
|
B=[A].
|
|
builtin_type(A,_,true) :-
|
|
var(A),
|
|
!.
|
|
builtin_type(any,_,true).
|
|
builtin_type(int,A,integer(A)).
|
|
builtin_type(number,A,number(A)).
|
|
builtin_type(float,A,float(A)).
|
|
builtin_type(natural,A,(integer(A),A>=0)).
|
|
real_type(A,B,C,D) :-
|
|
( nonvar(A) ->
|
|
functor(A,E,F),
|
|
( F==0 ->
|
|
D=(B=E)
|
|
;
|
|
A=..[_|G],
|
|
length(H,F),
|
|
I=..[E|H],
|
|
( var(C) ->
|
|
D=functor(B,E,F)
|
|
;
|
|
( functor(C,E,F) ->
|
|
C=..[_|J],
|
|
nested_types(G,H,J,K),
|
|
D=(functor(B,E,F),B=I,K)
|
|
)
|
|
;
|
|
D=functor(B,E,F)
|
|
)
|
|
)
|
|
;
|
|
format('CHR compiler ERROR: Illegal type definition (must be nonvar).
|
|
',[]),
|
|
fail
|
|
).
|
|
nested_types([],[],[],true).
|
|
nested_types([A|B],[C|D],[E|F],G) :-
|
|
( get_type_definition(A,H) ->
|
|
type2condition(H,C,E,I),
|
|
list2disj(I,J),
|
|
G=(J,K),
|
|
nested_types(B,D,F,K)
|
|
;
|
|
( builtin_type(A,C,L) ->
|
|
G=(L,K),
|
|
nested_types(B,D,F,K)
|
|
)
|
|
;
|
|
format('CHR compiler ERROR: Undefined type ~w inside type definition.
|
|
',[A]),
|
|
fail
|
|
).
|
|
storage_analysis(A) :-
|
|
( chr_pp_flag(storage_analysis,on) ->
|
|
check_constraint_storages(A)
|
|
;
|
|
true
|
|
).
|
|
check_constraint_storages([]).
|
|
check_constraint_storages([A|B]) :-
|
|
check_constraint_storage(A),
|
|
check_constraint_storages(B).
|
|
check_constraint_storage(A) :-
|
|
get_max_occurrence(A,B),
|
|
check_occurrences_storage(A,1,B).
|
|
check_occurrences_storage(A,B,C) :-
|
|
( B>C ->
|
|
stored_completing(A,1,0)
|
|
;
|
|
check_occurrence_storage(A,B),
|
|
D is B+1,
|
|
check_occurrences_storage(A,D,C)
|
|
).
|
|
check_occurrence_storage(A,B) :-
|
|
get_occurrence(A,B,C,D),
|
|
( is_passive(C,D) ->
|
|
stored(A,B,maybe)
|
|
;
|
|
get_rule(C,E),
|
|
E=pragma(rule(F,G,H,I),ids(J,K),_,_,_),
|
|
( select2(D,L,J,F,_,_) ->
|
|
check_storage_head1(L,B,F,G,H)
|
|
;
|
|
( select2(D,M,K,G,_,_) ->
|
|
check_storage_head2(M,B,F,I)
|
|
)
|
|
)
|
|
).
|
|
check_storage_head1(A,B,C,D,E) :-
|
|
functor(A,F,G),
|
|
H=F/G,
|
|
( C==[A],
|
|
D==[],
|
|
guard_entailment:entails_guard([chr_pp_headvariables(A)],E),
|
|
A=..[_|I],
|
|
no_matching(I,[]) ->
|
|
stored(H,B,no)
|
|
;
|
|
stored(H,B,maybe)
|
|
).
|
|
no_matching([],_).
|
|
no_matching([A|B],C) :-
|
|
var(A),
|
|
\+memberchk_eq(A,C),
|
|
no_matching(B,[A|C]).
|
|
check_storage_head2(A,B,C,D) :-
|
|
functor(A,E,F),
|
|
G=E/F,
|
|
(
|
|
(
|
|
C\==[],
|
|
D==true
|
|
;
|
|
\+is_observed(E/F,B)
|
|
) ->
|
|
stored(G,B,maybe)
|
|
;
|
|
stored(G,B,yes)
|
|
).
|
|
constraints_code(A,B) :-
|
|
constraints_code1(A,C,[]),
|
|
clean_clauses(C,B).
|
|
constraint_prelude(A/B,C) :-
|
|
vars_susp(B,D,E,F),
|
|
G=..[A|D],
|
|
build_head(A,B,[0],F,H),
|
|
get_target_module(I),
|
|
J=..[A|D],
|
|
( chr_pp_flag(debugable,on) ->
|
|
use_auxiliary_predicate(insert_constraint_internal),
|
|
generate_insert_constraint_call(A/B,E,K),
|
|
make_name(attach_,A/B,L),
|
|
M=..[L,N,E],
|
|
O=(arg(2,E,P),'chr update_mutable'(inactive,P)),
|
|
C=(G:-insert_constraint_internal(_,N,E,I:H,J,D),K,M,O,('chr debug_event'(call(E)),H;'chr debug_event'(fail(E)),!,fail),('chr debug_event'(exit(E));'chr debug_event'(redo(E)),fail))
|
|
;
|
|
( get_allocation_occurrence(A/B,0) ->
|
|
gen_insert_constraint_internal_goal(A/B,Q,F,D,E),
|
|
O=(arg(2,E,P),'chr update_mutable'(inactive,P)),
|
|
C=(G:-Q,O,H)
|
|
)
|
|
;
|
|
C=(G:-H)
|
|
).
|
|
gen_cond_attach_clause(A/B,C,D,E) :-
|
|
( is_finally_stored(A/B) ->
|
|
get_allocation_occurrence(A/B,F),
|
|
get_max_occurrence(A/B,G),
|
|
( chr_pp_flag(debugable,off),
|
|
G<F ->
|
|
( may_trigger(A/B) ->
|
|
gen_cond_attach_goal(A/B,H,I,J,K)
|
|
;
|
|
gen_insert_constraint_internal_goal(A/B,H,I,J,K)
|
|
)
|
|
;
|
|
vars_susp(B,J,K,I),
|
|
gen_uncond_attach_goal(A/B,K,H,_)
|
|
),
|
|
( chr_pp_flag(debugable,on) ->
|
|
L=..[A|J],
|
|
M='chr debug_event'(insert(L#K))
|
|
;
|
|
M=true
|
|
),
|
|
build_head(A,B,C,I,N),
|
|
O=(N:-M,H),
|
|
D=[O|E]
|
|
;
|
|
D=E
|
|
).
|
|
gen_cond_attach_goal(A/B,C,D,E,F) :-
|
|
vars_susp(B,E,F,D),
|
|
build_head(A,B,[0],D,G),
|
|
( may_trigger(A/B) ->
|
|
make_name(attach_,A/B,H),
|
|
I=..[H,J,F]
|
|
;
|
|
I=true
|
|
),
|
|
get_target_module(K),
|
|
L=..[A|E],
|
|
generate_insert_constraint_call(A/B,F,M),
|
|
use_auxiliary_predicate(insert_constraint_internal),
|
|
use_auxiliary_predicate(activate_constraint),
|
|
C=((var(F)->insert_constraint_internal(N,J,F,K:G,L,E);activate_constraint(N,J,F,_)),(N==yes->M,I;true)).
|
|
gen_insert_constraint_internal_goal(A/B,C,D,E,F) :-
|
|
vars_susp(B,E,F,D),
|
|
( may_trigger(A/B) ->
|
|
make_name(attach_,A/B,G),
|
|
H=..[G,I,F],
|
|
build_head(A,B,[0],D,J),
|
|
get_target_module(K),
|
|
L=K:J
|
|
;
|
|
H=true,
|
|
L=true
|
|
),
|
|
M=..[A|E],
|
|
generate_insert_constraint_call(A/B,F,N),
|
|
use_auxiliary_predicate(insert_constraint_internal),
|
|
C=(insert_constraint_internal(_,I,F,L,M,E),N,H).
|
|
gen_uncond_attach_goal(A,B,C,D) :-
|
|
( may_trigger(A) ->
|
|
make_name(attach_,A,E),
|
|
F=..[E,G,B]
|
|
;
|
|
F=true
|
|
),
|
|
generate_insert_constraint_call(A,B,H),
|
|
( chr_pp_flag(late_allocation,on) ->
|
|
use_auxiliary_predicate(activate_constraint),
|
|
C=(activate_constraint(I,G,B,D),(I==yes->H,F;true))
|
|
;
|
|
use_auxiliary_predicate(activate_constraint),
|
|
C=activate_constraint(I,G,B,D)
|
|
).
|
|
head1_code(A,B,C,D,E,F,G,H,I) :-
|
|
D=pragma(J,_,_,_,K),
|
|
J=rule(_,L,_,_),
|
|
( L==[] ->
|
|
reorder_heads(K,A,B,C,M,N),
|
|
simplification_code(A,M,N,D,E,F,G,H,I)
|
|
;
|
|
simpagation_head1_code(A,B,C,D,E,G,H,I)
|
|
).
|
|
head2_code(A,B,C,D,E,F,G,H,I) :-
|
|
D=pragma(J,_,_,_,K),
|
|
J=rule(L,_,_,_),
|
|
( L==[] ->
|
|
reorder_heads(K,A,B,C,M,N),
|
|
propagation_code(A,M,N,J,K,E,F,G,H,I)
|
|
;
|
|
simpagation_head2_code(A,B,C,D,E,F,G,H,I)
|
|
).
|
|
gen_alloc_inc_clause(A/B,C,D,E,F) :-
|
|
vars_susp(B,G,H,I),
|
|
build_head(A,B,D,I,J),
|
|
inc_id(D,K),
|
|
build_head(A,B,K,I,L),
|
|
gen_occ_allocation(A/B,C,G,H,I,M),
|
|
N=(J:-M,L),
|
|
E=[N|F].
|
|
gen_cond_allocation(A,B,C,D,E) :-
|
|
gen_allocation(A,B,C,D,F),
|
|
E=(var(B)->F;true).
|
|
gen_allocation(A,B,C/D,E,F) :-
|
|
( may_trigger(C/D) ->
|
|
build_head(C,D,[0],E,G),
|
|
get_target_module(H),
|
|
I=H:G
|
|
;
|
|
I=true
|
|
),
|
|
J=..[C|A],
|
|
use_auxiliary_predicate(allocate_constraint),
|
|
F=allocate_constraint(I,B,J,A).
|
|
gen_occ_allocation(A,B,C,D,E,F) :-
|
|
get_allocation_occurrence(A,G),
|
|
( chr_pp_flag(debugable,off),
|
|
B==G ->
|
|
( may_trigger(A) ->
|
|
gen_cond_allocation(C,D,A,E,F)
|
|
;
|
|
gen_allocation(C,D,A,E,F)
|
|
)
|
|
;
|
|
F=true
|
|
).
|
|
guard_via_reschedule(A,B,C,D) :-
|
|
( chr_pp_flag(guard_via_reschedule,on) ->
|
|
guard_via_reschedule_main(A,B,C,D)
|
|
;
|
|
append(A,B,E),
|
|
list2conj(E,D)
|
|
).
|
|
guard_via_reschedule_main(A,B,C,D) :-
|
|
initialize_unit_dictionary(C,E),
|
|
build_units(A,B,E,F),
|
|
dependency_reorder(F,G),
|
|
units2goal(G,D).
|
|
units2goal([],true).
|
|
units2goal([unit(_,A,_,_)|B],(A,C)) :-
|
|
units2goal(B,C).
|
|
dependency_reorder(A,B) :-
|
|
dependency_reorder(A,[],B).
|
|
dependency_reorder([],A,B) :-
|
|
reverse(A,B).
|
|
dependency_reorder([A|B],C,D) :-
|
|
A=unit(_,_,E,F),
|
|
( E==fixed ->
|
|
G=[A|C]
|
|
;
|
|
dependency_insert(C,A,F,G)
|
|
),
|
|
dependency_reorder(B,G,D).
|
|
dependency_insert([],A,_,[A]).
|
|
dependency_insert([A|B],C,D,E) :-
|
|
A=unit(F,_,_,_),
|
|
( memberchk(F,D) ->
|
|
E=[C,A|B]
|
|
;
|
|
E=[A|G],
|
|
dependency_insert(B,C,D,G)
|
|
).
|
|
build_units(A,B,C,D) :-
|
|
build_retrieval_units(A,1,E,C,F,D,G),
|
|
build_guard_units(B,E,F,G).
|
|
build_retrieval_units([],A,A,B,B,C,C).
|
|
build_retrieval_units([A|B],C,D,E,F,G,H) :-
|
|
term_variables(A,I),
|
|
update_unit_dictionary(I,C,E,J,[],K),
|
|
G=[unit(C,A,movable,K)|L],
|
|
M is C+1,
|
|
build_retrieval_units2(B,M,D,J,F,L,H).
|
|
build_retrieval_units2([],A,A,B,B,C,C).
|
|
build_retrieval_units2([A|B],C,D,E,F,G,H) :-
|
|
term_variables(A,I),
|
|
update_unit_dictionary(I,C,E,J,[],K),
|
|
G=[unit(C,A,fixed,K)|L],
|
|
M is C+1,
|
|
build_retrieval_units(B,M,D,J,F,L,H).
|
|
initialize_unit_dictionary(A,B) :-
|
|
term_variables(A,C),
|
|
pair_all_with(C,0,B).
|
|
update_unit_dictionary([],_,A,A,B,B).
|
|
update_unit_dictionary([A|B],C,D,E,F,G) :-
|
|
( lookup_eq(D,A,H) ->
|
|
(
|
|
(
|
|
H==C
|
|
;
|
|
memberchk(H,F)
|
|
) ->
|
|
I=F
|
|
;
|
|
I=[H|F]
|
|
),
|
|
J=D
|
|
;
|
|
J=[A-C|D],
|
|
I=F
|
|
),
|
|
update_unit_dictionary(B,C,J,E,I,G).
|
|
build_guard_units(A,B,C,D) :-
|
|
( A=[E] ->
|
|
D=[unit(B,E,fixed,[])]
|
|
;
|
|
( A=[E|F] ->
|
|
term_variables(E,G),
|
|
update_unit_dictionary2(G,B,C,H,[],I),
|
|
D=[unit(B,E,movable,I)|J],
|
|
K is B+1,
|
|
build_guard_units(F,K,H,J)
|
|
)
|
|
).
|
|
update_unit_dictionary2([],_,A,A,B,B).
|
|
update_unit_dictionary2([A|B],C,D,E,F,G) :-
|
|
( lookup_eq(D,A,H) ->
|
|
(
|
|
(
|
|
H==C
|
|
;
|
|
memberchk(H,F)
|
|
) ->
|
|
I=F
|
|
;
|
|
I=[H|F]
|
|
),
|
|
J=[A-C|D]
|
|
;
|
|
J=[A-C|D],
|
|
I=F
|
|
),
|
|
update_unit_dictionary2(B,C,J,E,I,G).
|
|
functional_dependency_analysis(A) :-
|
|
( chr_pp_flag(functional_dependency_analysis,on) ->
|
|
functional_dependency_analysis_main(A)
|
|
;
|
|
true
|
|
).
|
|
functional_dependency_analysis_main([]).
|
|
functional_dependency_analysis_main([A|B]) :-
|
|
( discover_unique_pattern(A,C,D,E,F) ->
|
|
functional_dependency(C,D,E,F)
|
|
;
|
|
true
|
|
),
|
|
functional_dependency_analysis_main(B).
|
|
discover_unique_pattern(A,B/C,D,E,F) :-
|
|
A=pragma(G,_,_,_,D),
|
|
G=rule(H,I,J,_),
|
|
( H=[K],
|
|
I=[L] ->
|
|
true
|
|
;
|
|
( H=[K,L],
|
|
I==[] ->
|
|
true
|
|
)
|
|
),
|
|
check_unique_constraints(K,L,J,D,M),
|
|
term_variables(K,N),
|
|
select_pragma_unique_variables(N,M,O),
|
|
copy_term_nat(K-O,E-F),
|
|
functor(K,B,C).
|
|
select_pragma_unique_variables([],_,[]).
|
|
select_pragma_unique_variables([A|B],C,D) :-
|
|
( lookup_eq(C,A,_) ->
|
|
D=E
|
|
;
|
|
D=[A|E]
|
|
),
|
|
select_pragma_unique_variables(B,C,E).
|
|
set_semantics_rules(A) :-
|
|
( chr_pp_flag(set_semantics_rule,on) ->
|
|
set_semantics_rules_main(A)
|
|
;
|
|
true
|
|
).
|
|
set_semantics_rules_main([]).
|
|
set_semantics_rules_main([A|B]) :-
|
|
set_semantics_rule_main(A),
|
|
set_semantics_rules_main(B).
|
|
set_semantics_rule_main(A) :-
|
|
A=pragma(B,C,_,_,D),
|
|
( B=rule([E],[F],true,_),
|
|
C=ids([G],[H]),
|
|
\+is_passive(D,G),
|
|
functor(E,I,J),
|
|
get_functional_dependency(I/J,D,K,L),
|
|
copy_term_nat(K-L,E-M),
|
|
copy_term_nat(K-L,F-N),
|
|
M==N ->
|
|
passive(D,H)
|
|
;
|
|
true
|
|
).
|
|
check_unique_constraints(A,B,C,D,E) :-
|
|
\+any_passive_head(D),
|
|
variable_replacement(A-B,B-A,E),
|
|
copy_with_variable_replacement(C,F,E),
|
|
negate_b(C,G),
|
|
once(entails_b(G,F)).
|
|
symmetry_analysis(A) :-
|
|
( chr_pp_flag(check_unnecessary_active,off) ->
|
|
true
|
|
;
|
|
symmetry_analysis_main(A)
|
|
).
|
|
symmetry_analysis_main([]).
|
|
symmetry_analysis_main([A|B]) :-
|
|
A=pragma(C,ids(D,E),_,_,F),
|
|
C=rule(G,H,_,_),
|
|
(
|
|
(
|
|
\+chr_pp_flag(check_unnecessary_active,simplification)
|
|
;
|
|
H==[]
|
|
),
|
|
G\==[] ->
|
|
symmetry_analysis_heads(G,D,[],[],C,F),
|
|
symmetry_analysis_heads(H,E,[],[],C,F)
|
|
;
|
|
true
|
|
),
|
|
symmetry_analysis_main(B).
|
|
symmetry_analysis_heads([],[],_,_,_,_).
|
|
symmetry_analysis_heads([A|B],[C|D],E,F,G,H) :-
|
|
( \+is_passive(H,C),
|
|
member2(E,F,I-J),
|
|
\+is_passive(H,J),
|
|
variable_replacement(I,A,K),
|
|
copy_with_variable_replacement(G,L,K),
|
|
identical_rules(G,L) ->
|
|
passive(H,C)
|
|
;
|
|
true
|
|
),
|
|
symmetry_analysis_heads(B,D,[A|E],[C|F],G,H).
|
|
simplification_code(A,B,C,D,E/F,G,H,I,J) :-
|
|
D=pragma(K,_,_,_,_),
|
|
head_info(A,F,_,L,M,N),
|
|
build_head(E,F,H,M,O),
|
|
get_constraint_mode(E/F,P),
|
|
head_arg_matches(N,P,[],Q,R,[],S),
|
|
rest_heads_retrieval_and_matching(B,C,A,T,U,R,V,[],[],[],S,_),
|
|
guard_body_copies2(K,V,W,X),
|
|
guard_via_reschedule(T,W,O-Q,Y),
|
|
gen_uncond_susps_detachments(U,B,Z),
|
|
gen_cond_susp_detachment(H,L,E/F,A1),
|
|
( chr_pp_flag(debugable,on) ->
|
|
K=rule(_,_,B1,C1),
|
|
my_term_copy(B1-C1,V,D1-E1),
|
|
F1='chr debug_event'(try([L|G1],[],D1,E1)),
|
|
H1='chr debug_event'(apply([L|G1],[],D1,E1)),
|
|
instrument_goal(I1,F1,H1,J1)
|
|
;
|
|
J1=I1
|
|
),
|
|
( unconditional_occurrence(E/F,G),
|
|
chr_pp_flag(late_allocation,on) ->
|
|
I1=true
|
|
;
|
|
I1=!
|
|
),
|
|
K1=(O:-Q,Y,J1,Z,A1,X),
|
|
I=[K1|J].
|
|
head_arg_matches(A,B,C,D,E) :-
|
|
head_arg_matches(A,B,C,D,E,[],_).
|
|
head_arg_matches(A,B,C,D,E,F,G) :-
|
|
head_arg_matches_(A,B,C,F,H,E,G),
|
|
list2conj(H,D).
|
|
head_arg_matches_([],[],A,B,[],A,B).
|
|
head_arg_matches_([A-B|C],[D|E],F,G,H,I,J) :-
|
|
( var(A) ->
|
|
( lookup_eq(F,A,K) ->
|
|
( D= + ->
|
|
( memberchk_eq(A,G) ->
|
|
H=[B=K|L],
|
|
M=G
|
|
;
|
|
H=[B==K|L],
|
|
M=[A|G]
|
|
)
|
|
;
|
|
H=[B==K|L],
|
|
M=G
|
|
),
|
|
N=F
|
|
;
|
|
N=[A-B|F],
|
|
H=L,
|
|
( D= + ->
|
|
M=[A|G]
|
|
;
|
|
M=G
|
|
)
|
|
),
|
|
O=C,
|
|
P=E
|
|
;
|
|
( atomic(A) ->
|
|
( D= + ->
|
|
H=[B=A|L]
|
|
;
|
|
H=[B==A|L]
|
|
),
|
|
F=N,
|
|
M=G,
|
|
O=C,
|
|
P=E
|
|
)
|
|
;
|
|
( D== +,
|
|
is_ground(G,A) ->
|
|
copy_with_variable_replacement(A,Q,F),
|
|
H=[B=Q|L],
|
|
F=N,
|
|
M=G,
|
|
O=C,
|
|
P=E
|
|
)
|
|
;
|
|
A=..[_|R],
|
|
functor(A,S,T),
|
|
functor(U,S,T),
|
|
U=..[_|V],
|
|
( D= + ->
|
|
H=[B=U|L]
|
|
;
|
|
H=[nonvar(B),B=U|L]
|
|
),
|
|
pairup(R,V,W),
|
|
append(W,C,O),
|
|
replicate(T,D,X),
|
|
append(X,E,P),
|
|
N=F,
|
|
M=G
|
|
),
|
|
head_arg_matches_(O,P,N,M,L,I,J).
|
|
is_ground(A,B) :-
|
|
( ground(B) ->
|
|
true
|
|
;
|
|
( compound(B) ->
|
|
B=..[_|C],
|
|
maplist(is_ground(A),C)
|
|
)
|
|
;
|
|
memberchk_eq(B,A)
|
|
).
|
|
rest_heads_retrieval_and_matching(A,B,C,D,E,F,G) :-
|
|
rest_heads_retrieval_and_matching(A,B,C,D,E,F,G,[],[],[],[],_).
|
|
rest_heads_retrieval_and_matching(A,B,C,D,E,F,G,H,I,J) :-
|
|
rest_heads_retrieval_and_matching(A,B,C,D,E,F,G,H,I,J,[],_).
|
|
rest_heads_retrieval_and_matching(A,B,C,D,E,F,G,H,I,J,K,L) :-
|
|
( A=[_|_] ->
|
|
rest_heads_retrieval_and_matching_n(A,B,H,I,C,D,E,F,G,J,K,L)
|
|
;
|
|
D=[],
|
|
E=[],
|
|
F=G,
|
|
K=L
|
|
).
|
|
rest_heads_retrieval_and_matching_n([],_,_,_,_,[],[],A,A,B,C,C) :-
|
|
instantiate_pattern_goals(B).
|
|
rest_heads_retrieval_and_matching_n([A|B],[_|C],D,E,F,[G|H],[I|J],K,L,M,N,O) :-
|
|
functor(A,P,Q),
|
|
head_info(A,Q,R,_,_,S),
|
|
get_store_type(P/Q,T),
|
|
( T==default ->
|
|
passive_head_via(A,[F|D],M,K,U,V,W),
|
|
get_max_constraint_index(X),
|
|
( X==1 ->
|
|
Y=V
|
|
;
|
|
get_constraint_index(P/Q,Z),
|
|
make_attr(X,_,A1,V),
|
|
nth(Z,A1,Y)
|
|
),
|
|
create_get_mutable(active,B1,C1),
|
|
get_constraint_mode(P/Q,D1),
|
|
head_arg_matches(S,D1,K,E1,F1,N,G1),
|
|
H1=(U,'chr sbag_member'(I,Y),I=I1,C1)
|
|
;
|
|
existential_lookup(T,A,[F|D],K,I1,B1,H1,I,S,J1),
|
|
get_constraint_mode(P/Q,D1),
|
|
filter_mode(J1,S,D1,K1),
|
|
head_arg_matches(J1,K1,K,E1,F1,N,G1),
|
|
W=M
|
|
),
|
|
I1=..[suspension,_,B1,_,_,_,_|R],
|
|
different_from_other_susps(A,I,D,E,L1),
|
|
G=(H1,L1,E1),
|
|
rest_heads_retrieval_and_matching_n(B,C,[A|D],[I|E],F,H,J,F1,L,W,G1,O).
|
|
filter_mode([],_,_,[]).
|
|
filter_mode([A-B|C],[_-D|E],[F|G],H) :-
|
|
( B==D ->
|
|
H=[F|I],
|
|
filter_mode(C,E,G,I)
|
|
;
|
|
filter_mode([A-B|C],E,G,H)
|
|
).
|
|
instantiate_pattern_goals([]).
|
|
instantiate_pattern_goals([_-attr(A,B,C)|D]) :-
|
|
get_max_constraint_index(E),
|
|
( E==1 ->
|
|
C=true
|
|
;
|
|
make_attr(E,F,_,A),
|
|
or_list(B,G),
|
|
!,
|
|
C=(F/\G=:=G)
|
|
),
|
|
instantiate_pattern_goals(D).
|
|
check_unique_keys([],_).
|
|
check_unique_keys([A|B],C) :-
|
|
lookup_eq(C,A,_),
|
|
check_unique_keys(B,C).
|
|
different_from_other_susps(A,B,C,D,E) :-
|
|
different_from_other_susps_(C,D,A,B,F),
|
|
list2conj(F,E).
|
|
different_from_other_susps_(_,[],_,_,[]) :-
|
|
!.
|
|
different_from_other_susps_([A|B],[C|D],E,F,G) :-
|
|
( functor(E,H,I),
|
|
functor(A,H,I),
|
|
copy_term_nat(A-E,J-K),
|
|
\+ \+J=K ->
|
|
G=[F\==C|L]
|
|
;
|
|
G=L
|
|
),
|
|
different_from_other_susps_(B,D,E,F,L).
|
|
passive_head_via(A,B,C,D,E,F,G) :-
|
|
functor(A,H,I),
|
|
get_constraint_index(H/I,J),
|
|
common_variables(A,B,K),
|
|
translate(K,D,L),
|
|
or_pattern(J,M),
|
|
( permutation(L,N),
|
|
lookup_eq(C,N,attr(F,O,_)) ->
|
|
member(M,O),
|
|
!,
|
|
G=C,
|
|
E=true
|
|
;
|
|
E=(P,Q),
|
|
gen_get_mod_constraints(L,P,F),
|
|
G=[L-attr(F,[M|_],Q)|C]
|
|
).
|
|
common_variables(A,B,C) :-
|
|
term_variables(A,D),
|
|
term_variables(B,E),
|
|
intersect_eq(D,E,C).
|
|
gen_get_mod_constraints(A,B,C) :-
|
|
get_target_module(D),
|
|
( A==[] ->
|
|
B=('chr global_term_ref_1'(E),get_attr(E,D,F),F=C)
|
|
;
|
|
( A=[G] ->
|
|
H='chr via_1'(G,I)
|
|
;
|
|
( A=[G,J] ->
|
|
H='chr via_2'(G,J,I)
|
|
)
|
|
;
|
|
H='chr via'(A,I)
|
|
),
|
|
B=(H,get_attr(I,D,F),F=C)
|
|
).
|
|
guard_body_copies(A,B,C,D) :-
|
|
guard_body_copies2(A,B,E,D),
|
|
list2conj(E,C).
|
|
guard_body_copies2(A,B,C,D) :-
|
|
A=rule(_,_,E,F),
|
|
conj2list(E,G),
|
|
split_off_simple_guard(G,B,H,I),
|
|
my_term_copy(H-I,B,J,K-L),
|
|
append(K,[M],C),
|
|
term_variables(I,N),
|
|
term_variables(L,O),
|
|
( chr_pp_flag(guard_locks,on),
|
|
bagof('chr lock'(P)-(chr_runtime:unlock(P)),Q^(lists:member(Q,N),pairlist:lookup_eq(B,Q,P),memberchk_eq(P,O)),R) ->
|
|
once(pairup(S,T,R))
|
|
;
|
|
S=[],
|
|
T=[]
|
|
),
|
|
list2conj(S,U),
|
|
list2conj(T,V),
|
|
list2conj(L,W),
|
|
M=(U,W,V),
|
|
my_term_copy(F,J,D).
|
|
split_off_simple_guard([],_,[],[]).
|
|
split_off_simple_guard([A|B],C,D,E) :-
|
|
( simple_guard(A,C) ->
|
|
D=[A|F],
|
|
split_off_simple_guard(B,C,F,E)
|
|
;
|
|
D=[],
|
|
E=[A|B]
|
|
).
|
|
simple_guard(A,B) :-
|
|
binds_b(A,C),
|
|
\+ (member(D,C),lookup_eq(B,D,_)).
|
|
gen_cond_susp_detachment(A,B,C,D) :-
|
|
( is_stored(C) ->
|
|
(
|
|
(
|
|
A==[0]
|
|
;
|
|
get_allocation_occurrence(C,E),
|
|
get_max_occurrence(C,F),
|
|
F<E
|
|
),
|
|
\+may_trigger(C),
|
|
chr_pp_flag(late_allocation,on) ->
|
|
D=true
|
|
;
|
|
gen_uncond_susp_detachment(B,C,G),
|
|
( chr_pp_flag(late_allocation,on) ->
|
|
D=(var(B)->true;G)
|
|
;
|
|
D=G
|
|
)
|
|
)
|
|
;
|
|
D=true
|
|
).
|
|
gen_uncond_susp_detachment(A,B,C) :-
|
|
( is_stored(B) ->
|
|
( may_trigger(B) ->
|
|
make_name(detach_,B,D),
|
|
E=..[D,F,A]
|
|
;
|
|
E=true
|
|
),
|
|
( chr_pp_flag(debugable,on) ->
|
|
G='chr debug_event'(remove(A))
|
|
;
|
|
G=true
|
|
),
|
|
generate_delete_constraint_call(B,A,H),
|
|
use_auxiliary_predicate(remove_constraint_internal),
|
|
C=(G,remove_constraint_internal(A,F,I),(I==yes->H,E;true))
|
|
;
|
|
C=true
|
|
).
|
|
gen_uncond_susps_detachments([],[],true).
|
|
gen_uncond_susps_detachments([A|B],[C|D],(E,F)) :-
|
|
functor(C,G,H),
|
|
gen_uncond_susp_detachment(A,G/H,E),
|
|
gen_uncond_susps_detachments(B,D,F).
|
|
simpagation_head1_code(A,B,C,D,E/F,G,H,I) :-
|
|
D=pragma(J,ids(_,K),_,_,_),
|
|
J=rule(_,L,M,N),
|
|
head_info(A,F,_,O,P,Q),
|
|
get_constraint_mode(E/F,R),
|
|
head_arg_matches(Q,R,[],S,T,[],U),
|
|
build_head(E,F,G,P,V),
|
|
append(B,L,W),
|
|
append(C,K,X),
|
|
reorder_heads(_,A,W,X,Y,Z),
|
|
rest_heads_retrieval_and_matching(Y,Z,A,A1,B1,T,C1,[],[],[],U,_),
|
|
split_by_ids(Z,B1,C,D1,E1),
|
|
guard_body_copies2(J,C1,F1,G1),
|
|
guard_via_reschedule(A1,F1,V-S,H1),
|
|
gen_uncond_susps_detachments(D1,B,I1),
|
|
gen_cond_susp_detachment(G,O,E/F,J1),
|
|
( chr_pp_flag(debugable,on) ->
|
|
my_term_copy(M-N,C1,K1-L1),
|
|
M1='chr debug_event'(try([O|D1],E1,K1,L1)),
|
|
N1='chr debug_event'(apply([O|D1],E1,K1,L1)),
|
|
instrument_goal(!,M1,N1,O1)
|
|
;
|
|
O1=!
|
|
),
|
|
P1=(V:-S,H1,O1,I1,J1,G1),
|
|
H=[P1|I].
|
|
split_by_ids([],[],_,[],[]).
|
|
split_by_ids([A|B],[C|D],E,F,G) :-
|
|
( memberchk_eq(A,E) ->
|
|
F=[C|H],
|
|
G=I
|
|
;
|
|
F=H,
|
|
G=[C|I]
|
|
),
|
|
split_by_ids(B,D,E,H,I).
|
|
simpagation_head2_code(A,B,C,D,E,F,G,H,I) :-
|
|
D=pragma(J,ids(K,L),_,_,M),
|
|
J=rule(N,_,O,P),
|
|
append(N,B,Q),
|
|
append(K,C,R),
|
|
reorder_heads(M,A,Q,R,[S|T],[U|V]),
|
|
simpagation_head2_prelude(A,S,[T,O,P],E,F,G,H,W),
|
|
extend_id(G,X),
|
|
( memberchk_eq(U,L) ->
|
|
simpagation_universal_searches(T,V,L,[S,A],J,E,Y,Z,A1,X,B1,W,C1)
|
|
;
|
|
W=C1,
|
|
X=B1,
|
|
Y=T,
|
|
Z=[S,A],
|
|
A1=V
|
|
),
|
|
universal_search_iterator_end(Z,Y,J,E,B1,C1,D1),
|
|
simpagation_head2_new_worker(Z,Y,A1,D,E,F,B1,D1,I).
|
|
simpagation_universal_searches([],[],_,A,_,_,[],A,[],B,B,C,C).
|
|
simpagation_universal_searches(A,[B|C],D,E,F,G,H,I,J,K,L,M,N) :-
|
|
A=[O|P],
|
|
inc_id(K,Q),
|
|
universal_search_iterator_end(E,A,F,G,K,M,R),
|
|
universal_search_iterator(A,E,F,G,K,R,S),
|
|
( memberchk_eq(B,D) ->
|
|
simpagation_universal_searches(P,C,D,[O|E],F,G,H,I,J,Q,L,S,N)
|
|
;
|
|
L=Q,
|
|
S=N,
|
|
H=P,
|
|
I=[O|E],
|
|
C=J
|
|
).
|
|
simpagation_head2_prelude(A,B,C,D/E,F,G,H,I) :-
|
|
head_info(A,E,J,K,L,M),
|
|
build_head(D,E,G,L,N),
|
|
get_constraint_mode(D/E,O),
|
|
head_arg_matches(M,O,[],P,Q),
|
|
lookup_passive_head(B,[A],Q,R,S),
|
|
gen_occ_allocation(D/E,F,J,K,L,T),
|
|
extend_id(G,U),
|
|
extra_active_delegate_variables(A,[B|C],Q,V),
|
|
append([S|L],V,W),
|
|
build_head(D,E,U,W,X),
|
|
Y=(N:-P,R,!,T,X),
|
|
H=[Y|I].
|
|
extra_active_delegate_variables(A,B,C,D) :-
|
|
A=..[_|E],
|
|
delegate_variables(A,B,C,E,D).
|
|
passive_delegate_variables(A,B,C,D,E) :-
|
|
term_variables(B,F),
|
|
delegate_variables(A,C,D,F,E).
|
|
delegate_variables(A,B,C,D,E) :-
|
|
term_variables(A,F),
|
|
term_variables(B,G),
|
|
intersect_eq(F,G,H),
|
|
list_difference_eq(H,D,I),
|
|
translate(I,C,E).
|
|
simpagation_head2_new_worker([A|B],C,D,E,F/G,H,I,J,K) :-
|
|
E=pragma(L,ids(M,_),N,_,_),
|
|
L=rule(_,_,O,P),
|
|
get_prop_inner_loop_vars(B,[A,C,O,P],Q,R,S,T),
|
|
gen_var(U),
|
|
gen_var(V),
|
|
functor(A,W,X),
|
|
gen_vars(X,Y),
|
|
head_info(A,X,Y,U,_,Z),
|
|
get_constraint_mode(W/X,A1),
|
|
head_arg_matches(Z,A1,R,B1,C1),
|
|
D1=..[suspension,_,E1,_,_,_,_|Y],
|
|
different_from_other_susps(A,U,B,T,F1),
|
|
create_get_mutable(active,E1,G1),
|
|
H1=(U=D1,G1,F1,B1),
|
|
I1=[[U|V]|Q],
|
|
build_head(F,G,I,I1,J1),
|
|
rest_heads_retrieval_and_matching(C,D,[A|B],K1,L1,C1,M1,[A|B],[U|T],[]),
|
|
split_by_ids(D,L1,M,N1,O1),
|
|
split_by_ids(D,C,M,P1,_),
|
|
gen_uncond_susps_detachments([U|N1],[A|P1],Q1),
|
|
R1=[V|Q],
|
|
build_head(F,G,I,R1,S1),
|
|
T1=[[]|Q],
|
|
build_head(F,G,I,T1,U1),
|
|
guard_body_copies2(L,M1,V1,W1),
|
|
guard_via_reschedule(K1,V1,v(J1,H1),X1),
|
|
( W1\==true,
|
|
is_observed(F/G,H) ->
|
|
gen_uncond_attach_goal(F/G,S,Y1,Z1),
|
|
gen_state_cond_call(S,G,S1,Z1,A2),
|
|
gen_state_cond_call(S,G,U1,Z1,B2)
|
|
;
|
|
Y1=true,
|
|
A2=S1,
|
|
B2=U1
|
|
),
|
|
( chr_pp_flag(debugable,on) ->
|
|
my_term_copy(O-P,R,C2-D2),
|
|
E2='chr debug_event'(try([U|N1],[S|O1],C2,D2)),
|
|
F2='chr debug_event'(apply([U|N1],[S|O1],C2,D2))
|
|
;
|
|
E2=true,
|
|
F2=true
|
|
),
|
|
( member(unique(_,G2),N),
|
|
check_unique_keys(G2,R) ->
|
|
H2=(J1:-H1->(X1,E2->F2,Q1,Y1,W1,B2;U1);S1)
|
|
;
|
|
H2=(J1:-H1,X1,E2->F2,Q1,Y1,W1,A2;S1)
|
|
),
|
|
J=[H2|K].
|
|
gen_state_cond_call(A,B,C,D,E) :-
|
|
length(F,B),
|
|
G=..[suspension,_,H,_,I,_,_|F],
|
|
create_get_mutable(active,H,J),
|
|
create_get_mutable(D,I,K),
|
|
E=(A=G,J,K->'chr update_mutable'(inactive,H),C;true).
|
|
propagation_code(A,B,C,D,E,F,G,H,I,J) :-
|
|
( B==[] ->
|
|
propagation_single_headed(A,D,E,F,G,H,I,J)
|
|
;
|
|
propagation_multi_headed(A,B,C,D,E,F,G,H,I,J)
|
|
).
|
|
propagation_single_headed(A,B,C,D/E,F,G,H,I) :-
|
|
head_info(A,E,J,K,L,M),
|
|
build_head(D,E,G,L,N),
|
|
inc_id(G,O),
|
|
build_head(D,E,O,L,P),
|
|
get_constraint_mode(D/E,Q),
|
|
head_arg_matches(M,Q,[],R,S),
|
|
guard_body_copies(B,S,T,U),
|
|
gen_occ_allocation(D/E,F,J,K,L,V),
|
|
W=P,
|
|
( U\==true,
|
|
is_observed(D/E,F) ->
|
|
gen_uncond_attach_goal(D/E,K,X,Y),
|
|
gen_state_cond_call(K,E,W,Y,Z)
|
|
;
|
|
X=true,
|
|
Z=W
|
|
),
|
|
( unconditional_occurrence(D/E,F),
|
|
chr_pp_flag(late_allocation,on) ->
|
|
A1=true
|
|
;
|
|
A1=!
|
|
),
|
|
( chr_pp_flag(debugable,on) ->
|
|
B=rule(_,_,B1,C1),
|
|
my_term_copy(B1-C1,S,D1-E1),
|
|
F1='chr debug_event'(try([],[K],D1,E1)),
|
|
G1='chr debug_event'(apply([],[K],D1,E1)),
|
|
instrument_goal(A1,F1,G1,H1)
|
|
;
|
|
H1=A1
|
|
),
|
|
( may_trigger(D/E) ->
|
|
I1='chr novel_production'(K,C),
|
|
J1='chr extend_history'(K,C)
|
|
;
|
|
I1=true,
|
|
J1=true
|
|
),
|
|
K1=(N:-R,V,I1,T,H1,J1,X,U,Z),
|
|
H=[K1|I].
|
|
propagation_multi_headed(A,B,C,D,E,F,G,H,I,J) :-
|
|
B=[K|L],
|
|
propagation_prelude(A,B,D,F,G,H,I,M),
|
|
extend_id(H,N),
|
|
propagation_nested_code(L,[K,A],C,D,E,F,G,N,M,J).
|
|
propagation_prelude(A,[B|C],D,E/F,G,H,I,J) :-
|
|
head_info(A,F,K,L,M,N),
|
|
build_head(E,F,H,M,O),
|
|
get_constraint_mode(E/F,P),
|
|
head_arg_matches(N,P,[],Q,R),
|
|
D=rule(_,_,S,T),
|
|
extra_active_delegate_variables(A,[B,C,S,T],R,U),
|
|
lookup_passive_head(B,[A],R,V,W),
|
|
gen_occ_allocation(E/F,G,K,L,M,X),
|
|
extend_id(H,Y),
|
|
append([W|M],U,Z),
|
|
build_head(E,F,Y,Z,A1),
|
|
B1=A1,
|
|
C1=(O:-Q,V,!,X,B1),
|
|
I=[C1|J].
|
|
propagation_nested_code([],[A|B],C,D,E,F,G,H,I,J) :-
|
|
universal_search_iterator_end([A|B],[],D,F,H,I,K),
|
|
propagation_body(A,B,C,D,E,F,G,H,K,J).
|
|
propagation_nested_code([A|B],C,D,E,F,G,H,I,J,K) :-
|
|
universal_search_iterator_end(C,[A|B],E,G,I,J,L),
|
|
universal_search_iterator([A|B],C,E,G,I,L,M),
|
|
inc_id(I,N),
|
|
propagation_nested_code(B,[A|C],D,E,F,G,H,N,M,K).
|
|
propagation_body(A,B,C,D,E,F/G,H,I,J,K) :-
|
|
D=rule(_,_,L,M),
|
|
get_prop_inner_loop_vars(B,[A,L,M],N,O,P,Q),
|
|
gen_var(R),
|
|
gen_var(S),
|
|
functor(A,T,U),
|
|
gen_vars(U,V),
|
|
W=..[suspension,_,X,_,_,_,_|V],
|
|
create_get_mutable(active,X,Y),
|
|
Z=(R=W,Y),
|
|
A1=[[R|S]|N],
|
|
build_head(F,G,I,A1,B1),
|
|
C1=[S|N],
|
|
build_head(F,G,I,C1,D1),
|
|
E1=D1,
|
|
A=..[_|F1],
|
|
pairup(F1,V,G1),
|
|
get_constraint_mode(T/U,H1),
|
|
head_arg_matches(G1,H1,O,I1,J1),
|
|
different_from_other_susps(A,R,B,Q,K1),
|
|
guard_body_copies(D,J1,L1,M1),
|
|
( M1\==true,
|
|
is_observed(F/G,H) ->
|
|
gen_uncond_attach_goal(F/G,P,N1,O1),
|
|
gen_state_cond_call(P,G,E1,O1,P1)
|
|
;
|
|
N1=true,
|
|
P1=E1
|
|
),
|
|
( is_least_occurrence(E) ->
|
|
Q1=true,
|
|
R1=true
|
|
;
|
|
get_occurrence(F/G,H,_,S1),
|
|
history_susps(C,[R|Q],P,S1,T1),
|
|
U1=..[t,E|T1],
|
|
bagof('chr novel_production'(V1,W1),(lists:member(V1,T1),W1=X1),Y1),
|
|
list2conj(Y1,Z1),
|
|
Q1=(X1=U1,Z1),
|
|
R1='chr extend_history'(P,X1)
|
|
),
|
|
( chr_pp_flag(debugable,on) ->
|
|
D=rule(_,_,L,M),
|
|
my_term_copy(L-M,J1,A2-B2),
|
|
C2='chr debug_event'(try([],[P,R|Q],A2,B2)),
|
|
D2='chr debug_event'(apply([],[P,R|Q],A2,B2))
|
|
;
|
|
C2=true,
|
|
D2=true
|
|
),
|
|
E2=(B1:-Z,K1,I1,Q1,L1,C2->D2,R1,N1,M1,P1;E1),
|
|
J=[E2|K].
|
|
history_susps(A,B,C,D,E) :-
|
|
reverse(B,F),
|
|
pairup([D|A],[C|F],G),
|
|
sort(G,H),
|
|
pairup(_,E,H).
|
|
get_prop_inner_loop_vars([A],B,C,D,E,[]) :-
|
|
!,
|
|
functor(A,F,G),
|
|
head_info(A,G,_,E,H,I),
|
|
get_constraint_mode(F/G,J),
|
|
head_arg_matches(I,J,[],_,D),
|
|
extra_active_delegate_variables(A,B,D,K),
|
|
append(H,K,C).
|
|
get_prop_inner_loop_vars([A|B],C,D,E,F,[G|H]) :-
|
|
get_prop_inner_loop_vars(B,[A|C],I,J,F,H),
|
|
functor(A,K,L),
|
|
gen_var(M),
|
|
head_info(A,L,_,G,_,N),
|
|
get_constraint_mode(K/L,O),
|
|
head_arg_matches(N,O,J,_,E),
|
|
passive_delegate_variables(A,B,C,E,P),
|
|
append(P,[G,M|I],D).
|
|
gen_var_susp_list_for([A],B,C,D,E,F) :-
|
|
!,
|
|
functor(A,G,H),
|
|
head_info(A,H,_,F,E,I),
|
|
get_constraint_mode(G/H,J),
|
|
head_arg_matches(I,J,[],_,C),
|
|
extra_active_delegate_variables(A,B,C,K),
|
|
append(E,K,D).
|
|
gen_var_susp_list_for([A|B],C,D,E,F,G) :-
|
|
gen_var_susp_list_for(B,[A|C],H,F,_,_),
|
|
functor(A,I,J),
|
|
gen_var(G),
|
|
head_info(A,J,_,K,_,L),
|
|
get_constraint_mode(I/J,M),
|
|
head_arg_matches(L,M,H,_,D),
|
|
passive_delegate_variables(A,B,C,D,N),
|
|
append(N,[K,G|F],E).
|
|
pre_vars_and_susps([A],B,C,D,[]) :-
|
|
!,
|
|
functor(A,E,F),
|
|
head_info(A,F,_,_,G,H),
|
|
get_constraint_mode(E/F,I),
|
|
head_arg_matches(H,I,[],_,D),
|
|
extra_active_delegate_variables(A,B,D,J),
|
|
append(G,J,C).
|
|
pre_vars_and_susps([A|B],C,D,E,[F|G]) :-
|
|
pre_vars_and_susps(B,[A|C],H,I,G),
|
|
functor(A,J,K),
|
|
gen_var(L),
|
|
head_info(A,K,_,F,_,M),
|
|
get_constraint_mode(J/K,N),
|
|
head_arg_matches(M,N,I,_,E),
|
|
passive_delegate_variables(A,B,C,E,O),
|
|
append(O,[F,L|H],D).
|
|
reorder_heads(A,B,C,D,E,F) :-
|
|
( chr_pp_flag(reorder_heads,on) ->
|
|
reorder_heads_main(A,B,C,D,E,F)
|
|
;
|
|
E=C,
|
|
F=D
|
|
).
|
|
reorder_heads_main(A,B,C,D,E,F) :-
|
|
term_variables(B,G),
|
|
H=entry([],[],G,C,D,A),
|
|
copy_term_nat(H,I),
|
|
a_star(I,J^(chr_translate:final_data(J)),K^L^M^(chr_translate:expand_data(K,L,M)),N),
|
|
I=H,
|
|
N=entry(O,P,_,_,_,_),
|
|
reverse(O,E),
|
|
reverse(P,F).
|
|
final_data(A) :-
|
|
A=entry(_,_,_,_,[],_).
|
|
expand_data(A,B,C) :-
|
|
A=entry(D,E,F,G,H,I),
|
|
select2(J,K,G,H,L,M),
|
|
term_variables([J|F],N),
|
|
B=entry([J|D],[K|E],N,L,M,I),
|
|
order_score(J,K,F,L,I,C).
|
|
order_score(A,B,C,D,E,F) :-
|
|
functor(A,G,H),
|
|
get_store_type(G/H,I),
|
|
order_score(I,A,B,C,D,E,F).
|
|
order_score(default,A,_,B,C,_,D) :-
|
|
term_variables(A,E),
|
|
term_variables(C,F),
|
|
order_score_vars(E,B,F,D).
|
|
order_score(multi_hash(A),B,_,C,_,_,D) :-
|
|
order_score_indexes(A,B,C,0,D).
|
|
order_score(global_ground,A,_,_,_,_,B) :-
|
|
functor(A,_,C),
|
|
( _==[] ->
|
|
B=10
|
|
;
|
|
( C==0 ->
|
|
B=1000
|
|
)
|
|
;
|
|
( C>0 ->
|
|
B=10000
|
|
)
|
|
).
|
|
order_score(global_singleton,_,_,_,_,_,A) :-
|
|
A=1.
|
|
order_score(multi_store(A),B,C,D,E,F,G) :-
|
|
find_with_var_identity(H,t(B,D,E),(lists:member(I,A),chr_translate:order_score(I,B,C,D,E,F,H)),J),
|
|
min_list(J,G).
|
|
order_score_indexes([],_,_,A,B) :-
|
|
A>0,
|
|
B=100.
|
|
order_score_indexes([A|B],C,D,E,F) :-
|
|
multi_hash_key_args(A,C,G),
|
|
( forall(H,G,memberchk_eq(H,D)) ->
|
|
I is E+1
|
|
;
|
|
I=E
|
|
),
|
|
order_score_indexes(B,C,D,I,F).
|
|
order_score_vars(A,B,C,D) :-
|
|
order_score_count_vars(A,B,C,E-F-G),
|
|
( E-F-G==0-0-0 ->
|
|
D=0
|
|
;
|
|
( E>0 ->
|
|
D is max(10-E,0)
|
|
)
|
|
;
|
|
( F>0 ->
|
|
D is max(10-F,1)*10
|
|
)
|
|
;
|
|
D is max(10-G,1)*100
|
|
).
|
|
order_score_count_vars([],_,_,0-0-0).
|
|
order_score_count_vars([A|B],C,D,E-F-G) :-
|
|
order_score_count_vars(B,C,D,H-I-J),
|
|
( memberchk_eq(A,C) ->
|
|
E is H+1,
|
|
F=I,
|
|
G=J
|
|
;
|
|
( memberchk_eq(A,D) ->
|
|
F is I+1,
|
|
E=H,
|
|
G=J
|
|
)
|
|
;
|
|
G is J+1,
|
|
E=H,
|
|
F=I
|
|
).
|
|
create_get_mutable(A,B,C) :-
|
|
B=mutable(A),
|
|
C=true.
|
|
gen_var(_).
|
|
gen_vars(A,B) :-
|
|
length(B,A).
|
|
head_info(A,B,C,D,E,F) :-
|
|
vars_susp(B,C,D,E),
|
|
A=..[_|G],
|
|
pairup(G,C,F).
|
|
inc_id([A|B],[C|B]) :-
|
|
C is A+1.
|
|
dec_id([A|B],[C|B]) :-
|
|
C is A-1.
|
|
extend_id(A,[0|A]).
|
|
next_id([_,A|B],[C|B]) :-
|
|
C is A+1.
|
|
build_head(A,B,C,D,E) :-
|
|
buildName(A,B,C,F),
|
|
(
|
|
(
|
|
chr_pp_flag(debugable,on)
|
|
;
|
|
is_stored(A/B),
|
|
has_active_occurrence(A/B),
|
|
(
|
|
may_trigger(A/B)
|
|
;
|
|
get_allocation_occurrence(A/B,G),
|
|
get_max_occurrence(A/B,H),
|
|
H>=G
|
|
)
|
|
) ->
|
|
E=..[F|D]
|
|
;
|
|
init(D,I),
|
|
E=..[F|I]
|
|
).
|
|
buildName(A,B,C,D) :-
|
|
(
|
|
(
|
|
chr_pp_flag(debugable,on)
|
|
;
|
|
once((is_stored(A/B),(has_active_occurrence(A/B);chr_pp_flag(late_allocation,off)),(may_trigger(A/B);get_allocation_occurrence(A/B,E),get_max_occurrence(A/B,F),F>=E);C\=[0]))
|
|
) ->
|
|
atom_concat(A,/,G),
|
|
atom_concat(G,B,H),
|
|
buildName_(C,H,D)
|
|
;
|
|
D=A
|
|
).
|
|
buildName_([],A,A).
|
|
buildName_([A|B],C,D) :-
|
|
buildName_(B,C,E),
|
|
atom_concat(E,'__',F),
|
|
atom_concat(F,A,D).
|
|
vars_susp(A,B,C,D) :-
|
|
length(B,A),
|
|
append(B,[C],D).
|
|
make_attr(A,B,C,D) :-
|
|
length(C,A),
|
|
D=..[v,B|C].
|
|
or_pattern(A,B) :-
|
|
C is A-1,
|
|
B is 1<<C.
|
|
and_pattern(A,B) :-
|
|
C is A-1,
|
|
D is 1<<C,
|
|
B is-1*(D+1).
|
|
make_name(A,B/C,D) :-
|
|
atom_concat_list([A,B,/,C],D).
|
|
lookup_passive_head(A,B,C,D,E) :-
|
|
functor(A,F,G),
|
|
get_store_type(F/G,H),
|
|
lookup_passive_head(H,A,B,C,D,E).
|
|
lookup_passive_head(default,A,B,C,D,E) :-
|
|
passive_head_via(A,B,[],C,D,F,G),
|
|
instantiate_pattern_goals(G),
|
|
get_max_constraint_index(H),
|
|
( H==1 ->
|
|
E=F
|
|
;
|
|
functor(A,I,J),
|
|
get_constraint_index(I/J,K),
|
|
make_attr(H,_,L,F),
|
|
nth(K,L,E)
|
|
).
|
|
lookup_passive_head(multi_hash(A),B,_,C,D,E) :-
|
|
once((member(F,A),multi_hash_key_args(F,B,G),translate(G,C,H))),
|
|
( H=[I] ->
|
|
true
|
|
;
|
|
I=..[k|H]
|
|
),
|
|
functor(B,J,K),
|
|
multi_hash_via_lookup_name(J/K,F,L),
|
|
D=..[L,I,E],
|
|
update_store_type(J/K,multi_hash([F])).
|
|
lookup_passive_head(global_ground,A,_,_,B,C) :-
|
|
functor(A,D,E),
|
|
global_ground_store_name(D/E,F),
|
|
B=nb_getval(F,C),
|
|
update_store_type(D/E,global_ground).
|
|
lookup_passive_head(global_singleton,A,_,_,B,C) :-
|
|
functor(A,D,E),
|
|
global_singleton_store_name(D/E,F),
|
|
B=(nb_getval(F,G),G\==[],C=[G]),
|
|
update_store_type(D/E,global_singleton).
|
|
lookup_passive_head(multi_store(A),B,C,D,E,F) :-
|
|
once((member(G,A),lookup_passive_head(G,B,C,D,E,F))).
|
|
existential_lookup(global_singleton,A,_,_,B,_,C,D,E,E) :-
|
|
!,
|
|
functor(A,F,G),
|
|
global_singleton_store_name(F/G,H),
|
|
C=(nb_getval(H,D),D\==[],D=B),
|
|
update_store_type(F/G,global_singleton).
|
|
existential_lookup(multi_store(A),B,C,D,E,F,G,H,I,J) :-
|
|
!,
|
|
once((member(K,A),existential_lookup(K,B,C,D,E,F,G,H,I,J))).
|
|
existential_lookup(multi_hash(A),B,_,C,D,E,F,G,H,I) :-
|
|
!,
|
|
once((member(J,A),multi_hash_key_args(J,B,K),translate(K,C,L))),
|
|
( L=[M] ->
|
|
true
|
|
;
|
|
M=..[k|L]
|
|
),
|
|
functor(B,N,O),
|
|
multi_hash_via_lookup_name(N/O,J,P),
|
|
Q=..[P,M,R],
|
|
create_get_mutable(active,E,S),
|
|
F=(Q,'chr sbag_member'(G,R),G=D,S),
|
|
hash_index_filter(H,J,I),
|
|
update_store_type(N/O,multi_hash([J])).
|
|
existential_lookup(A,B,C,D,E,F,G,H,I,I) :-
|
|
lookup_passive_head(A,B,C,D,J,K),
|
|
create_get_mutable(active,F,L),
|
|
G=(J,'chr sbag_member'(H,K),H=E,L).
|
|
hash_index_filter(A,B,C) :-
|
|
( integer(B) ->
|
|
D=[B]
|
|
;
|
|
D=B
|
|
),
|
|
hash_index_filter(A,D,1,C).
|
|
hash_index_filter([],_,_,[]).
|
|
hash_index_filter([A|B],C,D,E) :-
|
|
( C=[F|G] ->
|
|
H is D+1,
|
|
( F>D ->
|
|
E=[A|I],
|
|
hash_index_filter(B,[F|G],H,I)
|
|
;
|
|
( F==D ->
|
|
E=I,
|
|
hash_index_filter(B,G,H,I)
|
|
)
|
|
)
|
|
;
|
|
E=[A|B]
|
|
).
|
|
assume_constraint_stores([]).
|
|
assume_constraint_stores([A|B]) :-
|
|
( \+may_trigger(A),
|
|
is_stored(A),
|
|
get_store_type(A,default) ->
|
|
get_indexed_arguments(A,C),
|
|
findall(D,(sublist(D,C),D\==[]),E),
|
|
( get_functional_dependency(A,1,F,G),
|
|
all_distinct_var_args(F),
|
|
G==[] ->
|
|
assumed_store_type(A,global_singleton)
|
|
;
|
|
assumed_store_type(A,multi_store([multi_hash(E),global_ground]))
|
|
)
|
|
;
|
|
true
|
|
),
|
|
assume_constraint_stores(B).
|
|
all_distinct_var_args(A) :-
|
|
A=..[_|B],
|
|
copy_term_nat(B,C),
|
|
all_distinct_var_args_(C).
|
|
all_distinct_var_args_([]).
|
|
all_distinct_var_args_([A|B]) :-
|
|
var(A),
|
|
A=t,
|
|
all_distinct_var_args_(B).
|
|
get_indexed_arguments(A,B) :-
|
|
A=_/C,
|
|
get_indexed_arguments(1,C,A,B).
|
|
get_indexed_arguments(A,B,C,D) :-
|
|
( A>B ->
|
|
D=[]
|
|
;
|
|
( is_indexed_argument(C,A) ->
|
|
D=[A|E]
|
|
;
|
|
D=E
|
|
),
|
|
F is A+1,
|
|
get_indexed_arguments(F,B,C,E)
|
|
).
|
|
validate_store_type_assumptions([]).
|
|
validate_store_type_assumptions([A|B]) :-
|
|
validate_store_type_assumption(A),
|
|
validate_store_type_assumptions(B).
|
|
universal_search_iterator_end([A|B],C,D,E/F,G,H,I) :-
|
|
D=rule(_,_,J,K),
|
|
gen_var_susp_list_for(B,[A,C,J,K],_,L,M,N),
|
|
O=[[]|L],
|
|
build_head(E,F,G,O,P),
|
|
( G=[0|_] ->
|
|
next_id(G,Q),
|
|
R=M
|
|
;
|
|
dec_id(G,Q),
|
|
R=[N|M]
|
|
),
|
|
build_head(E,F,Q,R,S),
|
|
T=(P:-S),
|
|
H=[T|I].
|
|
universal_search_iterator([A|B],[C|D],E,F/G,H,I,J) :-
|
|
E=rule(_,_,K,L),
|
|
pre_vars_and_susps(D,[C,A,B,K,L],M,N,O),
|
|
gen_var(P),
|
|
functor(C,Q,R),
|
|
gen_vars(R,S),
|
|
head_info(C,R,S,T,_,U),
|
|
get_constraint_mode(Q/R,V),
|
|
head_arg_matches(U,V,N,W,X),
|
|
Y=..[suspension,_,Z,_,_,_,_|S],
|
|
different_from_other_susps(C,T,D,O,A1),
|
|
create_get_mutable(active,Z,B1),
|
|
C1=(T=Y,B1,A1,W),
|
|
lookup_passive_head(A,[C|D],X,D1,E1),
|
|
inc_id(H,F1),
|
|
G1=[[T|P]|M],
|
|
build_head(F,G,H,G1,H1),
|
|
passive_delegate_variables(C,D,[A,B,K,L],X,I1),
|
|
append([E1|I1],[T,P|M],J1),
|
|
build_head(F,G,F1,J1,K1),
|
|
L1=[P|M],
|
|
build_head(F,G,H,L1,M1),
|
|
N1=(H1:-C1,D1->K1;M1),
|
|
I=[N1|J].
|
|
ai_observation_analysis(A) :-
|
|
( chr_pp_flag(ai_observation_analysis,on) ->
|
|
list_to_ord_set(A,_),
|
|
abstract_constraints(A),
|
|
ai_observation_schedule_initial_calls(A)
|
|
;
|
|
true
|
|
).
|
|
ai_observation_schedule_initial_calls([]).
|
|
ai_observation_schedule_initial_calls([A|B]) :-
|
|
ai_observation_schedule_initial_call(A),
|
|
ai_observation_schedule_initial_calls(B).
|
|
ai_observation_schedule_initial_call(A) :-
|
|
ai_observation_top(A,B),
|
|
initial_call_pattern(B).
|
|
ai_observation_schedule_new_calls([],_).
|
|
ai_observation_schedule_new_calls([A|B],C) :-
|
|
C=odom(_,D),
|
|
initial_call_pattern(odom(A,D)),
|
|
ai_observation_schedule_new_calls(B,C).
|
|
ai_observation_lub(odom(A,B),odom(A,C),odom(A,D)) :-
|
|
ord_intersect(B,C,D).
|
|
ai_observation_top(A,odom(A,B)) :-
|
|
ord_empty(B).
|
|
ai_observation_leq(odom(A,B),odom(A,C)) :-
|
|
ord_subset(C,B).
|
|
ai_observation_observe(odom(A,B),C,odom(A,D)) :-
|
|
ord_del_element(B,C,D).
|
|
ai_observation_observe_list(odom(A,B),C,odom(A,D)) :-
|
|
list_to_ord_set(C,E),
|
|
ord_subtract(B,E,D).
|
|
ai_observation_abstract_constraint(A,B,C) :-
|
|
functor(A,D,E),
|
|
C=D/E,
|
|
member(C,B).
|
|
ai_observation_abstract_constraints(A,B,C) :-
|
|
findall(D,(member(E,A),ai_observation_abstract_constraint(E,B,D)),C).
|
|
ai_observation_abstract_goal(A,B,C) :-
|
|
ai_observation_abstract_goal(A,B,C,[]).
|
|
ai_observation_abstract_goal((A,B),C,D,E) :-
|
|
!,
|
|
ai_observation_abstract_goal(A,C,D,F),
|
|
ai_observation_abstract_goal(B,C,F,E).
|
|
ai_observation_abstract_goal((A;B),C,D,E) :-
|
|
!,
|
|
ai_observation_abstract_goal(A,C,D,F),
|
|
ai_observation_abstract_goal(B,C,F,E).
|
|
ai_observation_abstract_goal((A->B),C,D,E) :-
|
|
!,
|
|
ai_observation_abstract_goal(A,C,D,F),
|
|
ai_observation_abstract_goal(B,C,F,E).
|
|
ai_observation_abstract_goal(A,B,[C|D],D) :-
|
|
ai_observation_abstract_constraint(A,B,C),
|
|
!.
|
|
ai_observation_abstract_goal(true,_,A,A) :-
|
|
!.
|
|
ai_observation_abstract_goal(writeln(_),_,A,A) :-
|
|
!.
|
|
ai_observation_abstract_goal(_,_,[A|B],B) :-
|
|
A=builtin.
|
|
ai_observation_is_observed(odom(_,A),B) :-
|
|
\+ord_memberchk(B,A).
|
|
unconditional_occurrence(A,B) :-
|
|
get_occurrence(A,B,C,_),
|
|
get_rule(C,D),
|
|
D=pragma(E,_,_,_,_),
|
|
copy_term_nat(E,F),
|
|
F=rule(G,H,I,_),
|
|
guard_entailment:entails_guard([chr_pp_headvariables(G,H)],I),
|
|
once((G=[J],H==[];H=[J],G==[],\+may_trigger(A))),
|
|
functor(J,_,_),
|
|
J=..[_|K],
|
|
unconditional_occurrence_args(K).
|
|
unconditional_occurrence_args([]).
|
|
unconditional_occurrence_args([A|B]) :-
|
|
var(A),
|
|
A=x,
|
|
unconditional_occurrence_args(B).
|
|
generate_show_constraint(A,B,C,D) :-
|
|
( chr_pp_flag(show,on) ->
|
|
B=['$show'/0|A],
|
|
generate_show_rules(A,D,[E|C]),
|
|
inc_rule_count(F),
|
|
E=pragma(rule(['$show'],[],true,true),ids([0],[]),[],no,F)
|
|
;
|
|
B=A,
|
|
D=C
|
|
).
|
|
generate_show_rules([],A,A).
|
|
generate_show_rules([A/B|C],[D|E],F) :-
|
|
functor(G,A,B),
|
|
inc_rule_count(H),
|
|
D=pragma(rule([],['$show',G],true,writeln(G)),ids([],[0,1]),[passive(1)],no,H),
|
|
generate_show_rules(C,E,F).
|
|
:-use_module(chr(chr_runtime)).
|
|
:-use_module(chr(chr_hashtable_store)).
|
|
:-use_module(library('clp/clp_events')).
|
|
'attach_type_definition/2'([],_).
|
|
'attach_type_definition/2'([A|B],C) :-
|
|
( get_attr(A,chr_translate,D) ->
|
|
E=[C|D],
|
|
put_attr(A,chr_translate,E)
|
|
;
|
|
put_attr(A,chr_translate,[C])
|
|
),
|
|
true,
|
|
'attach_type_definition/2'(B,C).
|
|
'detach_type_definition/2'([],_).
|
|
'detach_type_definition/2'([A|B],C) :-
|
|
( get_attr(A,chr_translate,D) ->
|
|
'chr sbag_del_element'(D,C,E),
|
|
( E==[] ->
|
|
del_attr(A,chr_translate)
|
|
;
|
|
put_attr(A,chr_translate,E)
|
|
)
|
|
;
|
|
true
|
|
),
|
|
'detach_type_definition/2'(B,C).
|
|
'$indexed_variables'(B,A) :-
|
|
B=target_module(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=indexed_argument(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=constraint_mode(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=store_type(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=actual_store_types(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=assumed_store_type(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=rule_count(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=passive(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=occurrence(_,_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=max_occurrence(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=allocation_occurrence(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=rule(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=least_occurrence(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=constraint_index(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=max_constraint_index(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=observes(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=spawns_observer(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=observes_indirectly(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=prev_guard_list(_,_,_,_,_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=set_all_passive(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=multiple_occ_constraints_checked(_),
|
|
A=[].
|
|
'$indexed_variables'(C,B) :-
|
|
C=type_definition(A,_),
|
|
term_variables(A,B).
|
|
'$indexed_variables'(B,A) :-
|
|
B=constraint_type(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=add_type_information(_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=stored(_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=stored_complete(_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=check_all_passive(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=constraints_code1(_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=use_auxiliary_predicate(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=functional_dependency(_,_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=initial_call_pattern(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=call_pattern(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=final_answer_pattern(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=abstract_constraints(_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=depends_on(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=depends_on_ap(_,_,_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=depends_on_goal(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=ai_observed(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=ai_not_observed(_,_),
|
|
A=[].
|
|
'$indexed_variables'(B,A) :-
|
|
B=depends_on_as(_,_,_),
|
|
A=[].
|
|
attach_increment([],_).
|
|
attach_increment([B|C],A) :-
|
|
'chr not_locked'(B),
|
|
( get_attr(B,chr_translate,D) ->
|
|
sort(D,E),
|
|
merge(A,E,F),
|
|
put_attr(B,chr_translate,F)
|
|
;
|
|
put_attr(B,chr_translate,A)
|
|
),
|
|
attach_increment(C,A).
|
|
attr_unify_hook(A,B) :-
|
|
sort(A,D),
|
|
( var(B) ->
|
|
( get_attr(B,chr_translate,E) ->
|
|
true
|
|
;
|
|
E=[]
|
|
),
|
|
sort(E,F),
|
|
'chr merge_attributes'(D,F,C),
|
|
put_attr(B,chr_translate,C),
|
|
'chr run_suspensions'(C)
|
|
;
|
|
( compound(B) ->
|
|
term_variables(B,G),
|
|
attach_increment(G,D)
|
|
;
|
|
true
|
|
),
|
|
'chr run_suspensions'(A)
|
|
).
|
|
activate_constraint(A,B,C,D) :-
|
|
arg(2,C,E),
|
|
E=mutable(F),
|
|
'chr update_mutable'(active,E),
|
|
( nonvar(D) ->
|
|
true
|
|
;
|
|
arg(4,C,G),
|
|
G=mutable(H),
|
|
D is H+1,
|
|
'chr update_mutable'(D,G)
|
|
),
|
|
( compound(F) ->
|
|
term_variables(F,B),
|
|
'chr none_locked'(B),
|
|
A=yes
|
|
;
|
|
( F==removed ->
|
|
chr_indexed_variables(C,B),
|
|
A=yes
|
|
)
|
|
;
|
|
B=[],
|
|
A=no
|
|
).
|
|
remove_constraint_internal(A,B,C) :-
|
|
arg(2,A,D),
|
|
D=mutable(E),
|
|
'chr update_mutable'(removed,D),
|
|
( compound(E) ->
|
|
B=[],
|
|
C=no
|
|
;
|
|
( E==removed ->
|
|
B=[],
|
|
C=no
|
|
)
|
|
;
|
|
C=yes,
|
|
chr_indexed_variables(A,B)
|
|
).
|
|
allocate_constraint(A,B,C,D) :-
|
|
B=..[suspension,E,F,A,G,H,C|D],
|
|
G=mutable(0),
|
|
'chr empty_history'(I),
|
|
H=mutable(I),
|
|
chr_indexed_variables(B,J),
|
|
F=mutable(passive(J)),
|
|
'chr gen_id'(E).
|
|
insert_constraint_internal(yes,A,B,C,D,E) :-
|
|
B=..[suspension,F,G,C,H,I,D|E],
|
|
chr_indexed_variables(B,A),
|
|
'chr none_locked'(A),
|
|
G=mutable(active),
|
|
H=mutable(0),
|
|
I=mutable(J),
|
|
'chr empty_history'(J),
|
|
'chr gen_id'(F).
|
|
chr_indexed_variables(A,C) :-
|
|
A=..[_,_,_,_,_,_,B|_],
|
|
'$indexed_variables'(B,C).
|
|
'$insert_in_store_target_module/1'(A) :-
|
|
true,
|
|
b_setval('$chr_store_global_singleton_chr_translate:target_module/1',A).
|
|
'$delete_from_store_target_module/1'(_) :-
|
|
true,
|
|
b_setval('$chr_store_global_singleton_chr_translate:target_module/1',[]).
|
|
'$insert_in_store_indexed_argument/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:indexed_argument/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_indexed_argument/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:indexed_argument/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_constraint_mode/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraint_mode/2',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:constraint_mode/2',[A|B]),
|
|
arg(7,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_mode/2-1',D),
|
|
insert_ht(D,C,A),
|
|
true.
|
|
'$delete_from_store_constraint_mode/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraint_mode/2',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:constraint_mode/2',C),
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_mode/2-1',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_store_type/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:store_type/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_store_type/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:store_type/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_actual_store_types/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:actual_store_types/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_actual_store_types/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:actual_store_types/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_assumed_store_type/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_assumed_store_type/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_rule_count/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule_count/1',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:rule_count/1',[A|B]).
|
|
'$delete_from_store_rule_count/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule_count/1',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:rule_count/1',C).
|
|
'$insert_in_store_passive/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:passive/2',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:passive/2',[A|B]),
|
|
arg(7,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:passive/2-1',D),
|
|
insert_ht(D,C,A),
|
|
true.
|
|
'$delete_from_store_passive/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:passive/2',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:passive/2',C),
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:passive/2-1',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_occurrence/4'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:occurrence/4',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:occurrence/4',[A|B]),
|
|
arg(9,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:occurrence/4-3',D),
|
|
insert_ht(D,C,A),
|
|
true,
|
|
arg(7,A,E),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:occurrence/4-1',F),
|
|
insert_ht(F,E,A),
|
|
true.
|
|
'$delete_from_store_occurrence/4'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:occurrence/4',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:occurrence/4',C),
|
|
arg(9,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:occurrence/4-3',E),
|
|
delete_ht(E,D,A),
|
|
true,
|
|
arg(7,A,F),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:occurrence/4-1',G),
|
|
delete_ht(G,F,A),
|
|
true.
|
|
'$insert_in_store_max_occurrence/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:max_occurrence/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_max_occurrence/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:max_occurrence/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_allocation_occurrence/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
b_setval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',[A|D]).
|
|
'$delete_from_store_allocation_occurrence/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
'chr sbag_del_element'(D,A,E),
|
|
b_setval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',E).
|
|
'$insert_in_store_rule/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:rule/2',[A|B]),
|
|
arg(7,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:rule/2-1',D),
|
|
insert_ht(D,C,A),
|
|
true.
|
|
'$delete_from_store_rule/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:rule/2',C),
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:rule/2-1',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_least_occurrence/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:least_occurrence/2',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:least_occurrence/2',[A|B]),
|
|
arg(7,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:least_occurrence/2-1',D),
|
|
insert_ht(D,C,A),
|
|
true.
|
|
'$delete_from_store_least_occurrence/2'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:least_occurrence/2',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:least_occurrence/2',C),
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:least_occurrence/2-1',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_constraint_index/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_index/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_constraint_index/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_index/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_max_constraint_index/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:max_constraint_index/1',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:max_constraint_index/1',[A|B]).
|
|
'$delete_from_store_max_constraint_index/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:max_constraint_index/1',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:max_constraint_index/1',C).
|
|
'$insert_in_store_observes/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_observes/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_spawns_observer/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
arg(8,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-2',E),
|
|
insert_ht(E,D,A),
|
|
true.
|
|
'$delete_from_store_spawns_observer/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
arg(8,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-2',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_observes_indirectly/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes_indirectly/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_observes_indirectly/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes_indirectly/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_prev_guard_list/7'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:prev_guard_list/7',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:prev_guard_list/7',[A|B]),
|
|
arg(8,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-2',D),
|
|
insert_ht(D,C,A),
|
|
true,
|
|
arg(7,A,E),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-1',F),
|
|
insert_ht(F,E,A),
|
|
true.
|
|
'$delete_from_store_prev_guard_list/7'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:prev_guard_list/7',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:prev_guard_list/7',C),
|
|
arg(8,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-2',E),
|
|
delete_ht(E,D,A),
|
|
true,
|
|
arg(7,A,F),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-1',G),
|
|
delete_ht(G,F,A),
|
|
true.
|
|
'$insert_in_store_set_all_passive/1'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:set_all_passive/1-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_set_all_passive/1'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:set_all_passive/1-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_multiple_occ_constraints_checked/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',[A|B]).
|
|
'$delete_from_store_multiple_occ_constraints_checked/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',C).
|
|
'$insert_in_store_type_definition/2'(A) :-
|
|
true,
|
|
'chr global_term_ref_1'(B),
|
|
( get_attr(B,chr_translate,C) ->
|
|
D=[A|C],
|
|
put_attr(B,chr_translate,D)
|
|
;
|
|
put_attr(B,chr_translate,[A])
|
|
).
|
|
'$delete_from_store_type_definition/2'(A) :-
|
|
true,
|
|
'chr global_term_ref_1'(B),
|
|
( get_attr(B,chr_translate,C) ->
|
|
'chr sbag_del_element'(C,A,D),
|
|
( D==[] ->
|
|
del_attr(B,chr_translate)
|
|
;
|
|
put_attr(B,chr_translate,D)
|
|
)
|
|
;
|
|
true
|
|
).
|
|
'$insert_in_store_constraint_type/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_type/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_constraint_type/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_type/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_add_type_information/3'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:add_type_information/3',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:add_type_information/3',[A|B]).
|
|
'$delete_from_store_add_type_information/3'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:add_type_information/3',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:add_type_information/3',C).
|
|
'$insert_in_store_stored/3'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored/3-1',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:stored/3',D),
|
|
b_setval('$chr_store_global_ground_chr_translate:stored/3',[A|D]).
|
|
'$delete_from_store_stored/3'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored/3-1',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:stored/3',D),
|
|
'chr sbag_del_element'(D,A,E),
|
|
b_setval('$chr_store_global_ground_chr_translate:stored/3',E).
|
|
'$insert_in_store_stored_complete/3'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored_complete/3-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_stored_complete/3'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored_complete/3-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_check_all_passive/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:check_all_passive/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_check_all_passive/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:check_all_passive/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_constraints_code1/3'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraints_code1/3-1',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraints_code1/3',D),
|
|
b_setval('$chr_store_global_ground_chr_translate:constraints_code1/3',[A|D]).
|
|
'$delete_from_store_constraints_code1/3'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraints_code1/3-1',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraints_code1/3',D),
|
|
'chr sbag_del_element'(D,A,E),
|
|
b_setval('$chr_store_global_ground_chr_translate:constraints_code1/3',E).
|
|
'$insert_in_store_use_auxiliary_predicate/1'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:use_auxiliary_predicate/1-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_use_auxiliary_predicate/1'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:use_auxiliary_predicate/1-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_functional_dependency/4'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:functional_dependency/4-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_functional_dependency/4'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:functional_dependency/4-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_initial_call_pattern/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',[A|B]),
|
|
arg(7,A,C),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:initial_call_pattern/1-1',D),
|
|
insert_ht(D,C,A),
|
|
true.
|
|
'$delete_from_store_initial_call_pattern/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',C),
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:initial_call_pattern/1-1',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_call_pattern/1'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:call_pattern/1-1',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',D),
|
|
b_setval('$chr_store_global_ground_chr_translate:call_pattern/1',[A|D]).
|
|
'$delete_from_store_call_pattern/1'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:call_pattern/1-1',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',D),
|
|
'chr sbag_del_element'(D,A,E),
|
|
b_setval('$chr_store_global_ground_chr_translate:call_pattern/1',E).
|
|
'$insert_in_store_final_answer_pattern/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:final_answer_pattern/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_final_answer_pattern/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:final_answer_pattern/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_abstract_constraints/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',B),
|
|
b_setval('$chr_store_global_ground_chr_translate:abstract_constraints/1',[A|B]).
|
|
'$delete_from_store_abstract_constraints/1'(A) :-
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',B),
|
|
'chr sbag_del_element'(B,A,C),
|
|
b_setval('$chr_store_global_ground_chr_translate:abstract_constraints/1',C).
|
|
'$insert_in_store_depends_on/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:depends_on/2',D),
|
|
b_setval('$chr_store_global_ground_chr_translate:depends_on/2',[A|D]),
|
|
arg(8,A,E),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-2',F),
|
|
insert_ht(F,E,A),
|
|
true.
|
|
'$delete_from_store_depends_on/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
nb_getval('$chr_store_global_ground_chr_translate:depends_on/2',D),
|
|
'chr sbag_del_element'(D,A,E),
|
|
b_setval('$chr_store_global_ground_chr_translate:depends_on/2',E),
|
|
arg(8,A,F),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-2',G),
|
|
delete_ht(G,F,A),
|
|
true.
|
|
'$insert_in_store_depends_on_ap/4'(A) :-
|
|
true,
|
|
arg(8,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-2',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
arg(9,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-3',E),
|
|
insert_ht(E,D,A),
|
|
true.
|
|
'$delete_from_store_depends_on_ap/4'(A) :-
|
|
true,
|
|
arg(8,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-2',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
arg(9,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-3',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_depends_on_goal/2'(A) :-
|
|
true,
|
|
arg(8,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-2',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-1',E),
|
|
insert_ht(E,D,A),
|
|
true.
|
|
'$delete_from_store_depends_on_goal/2'(A) :-
|
|
true,
|
|
arg(8,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-2',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
arg(7,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-1',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$insert_in_store_ai_observed/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_observed/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_ai_observed/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_observed/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_ai_not_observed/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_not_observed/2-1',C),
|
|
insert_ht(C,B,A),
|
|
true.
|
|
'$delete_from_store_ai_not_observed/2'(A) :-
|
|
true,
|
|
arg(7,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_not_observed/2-1',C),
|
|
delete_ht(C,B,A),
|
|
true.
|
|
'$insert_in_store_depends_on_as/3'(A) :-
|
|
true,
|
|
arg(9,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-3',C),
|
|
insert_ht(C,B,A),
|
|
true,
|
|
arg(8,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-2',E),
|
|
insert_ht(E,D,A),
|
|
true.
|
|
'$delete_from_store_depends_on_as/3'(A) :-
|
|
true,
|
|
arg(9,A,B),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-3',C),
|
|
delete_ht(C,B,A),
|
|
true,
|
|
arg(8,A,D),
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-2',E),
|
|
delete_ht(E,D,A),
|
|
true.
|
|
'$enumerate_suspensions'(A) :-
|
|
(
|
|
nb_getval('$chr_store_global_singleton_chr_translate:target_module/1',A),
|
|
A\==[]
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:indexed_argument/2-1',B),
|
|
value_ht(B,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraint_mode/2',C),
|
|
'chr sbag_member'(A,C)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:store_type/2-1',D),
|
|
value_ht(D,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:actual_store_types/2-1',E),
|
|
value_ht(E,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1',F),
|
|
value_ht(F,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule_count/1',G),
|
|
'chr sbag_member'(A,G)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:passive/2',H),
|
|
'chr sbag_member'(A,H)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:occurrence/4',I),
|
|
'chr sbag_member'(A,I)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:max_occurrence/2-1',J),
|
|
value_ht(J,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1',K),
|
|
value_ht(K,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',L),
|
|
'chr sbag_member'(A,L)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:least_occurrence/2',M),
|
|
'chr sbag_member'(A,M)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_index/2-1',N),
|
|
value_ht(N,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:max_constraint_index/1',O),
|
|
'chr sbag_member'(A,O)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes/2-1',P),
|
|
value_ht(P,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-1',Q),
|
|
value_ht(Q,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes_indirectly/2-1',R),
|
|
value_ht(R,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:prev_guard_list/7',S),
|
|
'chr sbag_member'(A,S)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:set_all_passive/1-1',T),
|
|
value_ht(T,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',U),
|
|
'chr sbag_member'(A,U)
|
|
;
|
|
'chr global_term_ref_1'(V),
|
|
get_attr(V,chr_translate,W),
|
|
'chr sbag_member'(A,W)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_type/2-1',X),
|
|
value_ht(X,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:add_type_information/3',Y),
|
|
'chr sbag_member'(A,Y)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored/3-1',Z),
|
|
value_ht(Z,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored_complete/3-1',A1),
|
|
value_ht(A1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:check_all_passive/2-1',B1),
|
|
value_ht(B1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraints_code1/3-1',C1),
|
|
value_ht(C1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:use_auxiliary_predicate/1-1',D1),
|
|
value_ht(D1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:functional_dependency/4-1',E1),
|
|
value_ht(E1,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',F1),
|
|
'chr sbag_member'(A,F1)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:call_pattern/1-1',G1),
|
|
value_ht(G1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:final_answer_pattern/2-1',H1),
|
|
value_ht(H1,A)
|
|
;
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',I1),
|
|
'chr sbag_member'(A,I1)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-1',J1),
|
|
value_ht(J1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-2',K1),
|
|
value_ht(K1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-2',L1),
|
|
value_ht(L1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_observed/2-1',M1),
|
|
value_ht(M1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_not_observed/2-1',N1),
|
|
value_ht(N1,A)
|
|
;
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-3',O1),
|
|
value_ht(O1,A)
|
|
).
|
|
:-nb_setval('$chr_store_global_singleton_chr_translate:target_module/1',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:indexed_argument/2-1',A).
|
|
'$via1_multi_hash_indexed_argument/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:indexed_argument/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:constraint_mode/2',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:constraint_mode/2-1',A).
|
|
'$via1_multi_hash_constraint_mode/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_mode/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:store_type/2-1',A).
|
|
'$via1_multi_hash_store_type/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:store_type/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:actual_store_types/2-1',A).
|
|
'$via1_multi_hash_actual_store_types/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:actual_store_types/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1',A).
|
|
'$via1_multi_hash_assumed_store_type/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:rule_count/1',[]).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:passive/2',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:passive/2-1',A).
|
|
'$via1_multi_hash_passive/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:passive/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:occurrence/4',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:occurrence/4-3',A).
|
|
'$via1_multi_hash_occurrence/4-3'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:occurrence/4-3',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:occurrence/4-1',A).
|
|
'$via1_multi_hash_occurrence/4-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:occurrence/4-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:max_occurrence/2-1',A).
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:max_occurrence/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1',A).
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',[]).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:rule/2',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:rule/2-1',A).
|
|
'$via1_multi_hash_rule/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:rule/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:least_occurrence/2',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:least_occurrence/2-1',A).
|
|
'$via1_multi_hash_least_occurrence/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:least_occurrence/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:constraint_index/2-1',A).
|
|
'$via1_multi_hash_constraint_index/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_index/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:max_constraint_index/1',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:observes/2-1',A).
|
|
'$via1_multi_hash_observes/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:spawns_observer/2-1',A).
|
|
'$via1_multi_hash_spawns_observer/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:spawns_observer/2-2',A).
|
|
'$via1_multi_hash_spawns_observer/2-2'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:spawns_observer/2-2',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:observes_indirectly/2-1',A).
|
|
'$via1_multi_hash_observes_indirectly/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:observes_indirectly/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:prev_guard_list/7',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-2',A).
|
|
'$via1_multi_hash_prev_guard_list/7-2'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-2',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-1',A).
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:prev_guard_list/7-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:set_all_passive/1-1',A).
|
|
'$via1_multi_hash_set_all_passive/1-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:set_all_passive/1-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:constraint_type/2-1',A).
|
|
'$via1_multi_hash_constraint_type/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraint_type/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:add_type_information/3',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:stored/3-1',A).
|
|
'$via1_multi_hash_stored/3-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored/3-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:stored/3',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:stored_complete/3-1',A).
|
|
'$via1_multi_hash_stored_complete/3-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:stored_complete/3-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:check_all_passive/2-1',A).
|
|
'$via1_multi_hash_check_all_passive/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:check_all_passive/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:constraints_code1/3-1',A).
|
|
'$via1_multi_hash_constraints_code1/3-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:constraints_code1/3-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:constraints_code1/3',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:use_auxiliary_predicate/1-1',A).
|
|
'$via1_multi_hash_use_auxiliary_predicate/1-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:use_auxiliary_predicate/1-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:functional_dependency/4-1',A).
|
|
'$via1_multi_hash_functional_dependency/4-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:functional_dependency/4-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:initial_call_pattern/1-1',A).
|
|
'$via1_multi_hash_initial_call_pattern/1-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:initial_call_pattern/1-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:call_pattern/1-1',A).
|
|
'$via1_multi_hash_call_pattern/1-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:call_pattern/1-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:call_pattern/1',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:final_answer_pattern/2-1',A).
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:final_answer_pattern/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:abstract_constraints/1',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on/2-1',A).
|
|
'$via1_multi_hash_depends_on/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-nb_setval('$chr_store_global_ground_chr_translate:depends_on/2',[]).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on/2-2',A).
|
|
'$via1_multi_hash_depends_on/2-2'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on/2-2',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-2',A).
|
|
'$via1_multi_hash_depends_on_ap/4-2'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-2',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-3',A).
|
|
'$via1_multi_hash_depends_on_ap/4-3'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_ap/4-3',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-2',A).
|
|
'$via1_multi_hash_depends_on_goal/2-2'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-2',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-1',A).
|
|
'$via1_multi_hash_depends_on_goal/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_goal/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:ai_observed/2-1',A).
|
|
'$via1_multi_hash_ai_observed/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_observed/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:ai_not_observed/2-1',A).
|
|
'$via1_multi_hash_ai_not_observed/2-1'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:ai_not_observed/2-1',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on_as/3-3',A).
|
|
'$via1_multi_hash_depends_on_as/3-3'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-3',C),
|
|
lookup_ht(C,A,B).
|
|
:-new_ht(A),nb_setval('$chr_store_multi_hash_chr_translate:depends_on_as/3-2',A).
|
|
'$via1_multi_hash_depends_on_as/3-2'(A,B) :-
|
|
nb_getval('$chr_store_multi_hash_chr_translate:depends_on_as/3-2',C),
|
|
lookup_ht(C,A,B).
|
|
target_module(_) :-
|
|
nb_getval('$chr_store_global_singleton_chr_translate:target_module/1',A),
|
|
A\==[],
|
|
A=suspension(_,_,_,_,_,_,_),
|
|
!.
|
|
target_module(A) :-
|
|
insert_constraint_internal(_,_,B,true,target_module(A),[A]),
|
|
'$insert_in_store_target_module/1'(B).
|
|
get_target_module(A) :-
|
|
nb_getval('$chr_store_global_singleton_chr_translate:target_module/1',B),
|
|
B\==[],
|
|
B=suspension(_,_,_,_,_,_,C),
|
|
!,
|
|
A=C.
|
|
get_target_module(user).
|
|
indexed_argument(A,B) :-
|
|
'$via1_multi_hash_indexed_argument/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!.
|
|
indexed_argument(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,indexed_argument(A,B),[A,B]),
|
|
'$insert_in_store_indexed_argument/2'(C).
|
|
is_indexed_argument(A,B) :-
|
|
'$via1_multi_hash_indexed_argument/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D==B,
|
|
!.
|
|
is_indexed_argument(_,_) :-
|
|
fail.
|
|
constraint_mode(A,B) :-
|
|
'constraint_mode/2__0'(A,B,_).
|
|
'constraint_mode/2__0'(A,_,_) :-
|
|
'$via1_multi_hash_constraint_mode/2-1'(A,C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
!.
|
|
'constraint_mode/2__0'(A,B,C) :-
|
|
A=D/E,
|
|
nb_getval('$chr_store_global_ground_chr_translate:add_type_information/3',F),
|
|
!,
|
|
allocate_constraint(true,C,constraint_mode(A,B),[A,B]),
|
|
'constraint_mode/2__0__0'(F,A,B,C,D,E).
|
|
'constraint_mode/2__0__0'([],A,B,C,_,_) :-
|
|
'constraint_mode/2__1'(A,B,C).
|
|
'constraint_mode/2__0__0'([I|N],A,B,C,D,E) :-
|
|
( I=suspension(_,mutable(active),_,_,_,_,F,G,H),
|
|
F=[J|K],
|
|
G=[L|M],
|
|
functor(J,D,E) ->
|
|
remove_constraint_internal(I,_,O),
|
|
( O==yes ->
|
|
'$delete_from_store_add_type_information/3'(I)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(X,_,C,Y),
|
|
( X==yes ->
|
|
'$insert_in_store_constraint_mode/2'(C)
|
|
;
|
|
true
|
|
),
|
|
J=..[_|P],
|
|
L=..[_|Q],
|
|
add_mode_info(B,P,R),
|
|
H=(R,S),
|
|
( get_constraint_type(D/E,T) ->
|
|
types2condition(T,P,Q,B,U),
|
|
list2conj(U,V),
|
|
S=(V,W),
|
|
add_type_information(K,M,W)
|
|
;
|
|
add_type_information(K,M,S)
|
|
),
|
|
( C=suspension(_,mutable(active),_,mutable(Y),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'constraint_mode/2__0__0'(N,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'constraint_mode/2__0__0'(N,A,B,C,D,E)
|
|
).
|
|
'constraint_mode/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,constraint_mode(A,B),[A,B]),
|
|
'constraint_mode/2__1'(A,B,C).
|
|
'constraint_mode/2__1'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_constraint_mode/2'(A)
|
|
;
|
|
true
|
|
).
|
|
get_constraint_mode(A,B) :-
|
|
'$via1_multi_hash_constraint_mode/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_constraint_mode(_/B,A) :-
|
|
replicate(B,?,A).
|
|
may_trigger(A) :-
|
|
'$via1_multi_hash_constraint_mode/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
'$via1_multi_hash_indexed_argument/2-1'(A,G),
|
|
'chr sbag_member'(E,G),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F),
|
|
nth(F,C,H),
|
|
H\== +,
|
|
!,
|
|
is_stored(A).
|
|
may_trigger(_) :-
|
|
chr_pp_flag(debugable,on).
|
|
store_type(A,atom_hash(B)) :-
|
|
!,
|
|
store_type(A,multi_hash([B])).
|
|
store_type(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,store_type(A,B),[A,B]),
|
|
'$insert_in_store_store_type/2'(C).
|
|
get_store_type(A,B) :-
|
|
'$via1_multi_hash_store_type/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_store_type(A,B) :-
|
|
'$via1_multi_hash_assumed_store_type/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_store_type(_,default).
|
|
update_store_type(A,B) :-
|
|
'$via1_multi_hash_actual_store_types/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
member(B,D),
|
|
!.
|
|
update_store_type(A,B) :-
|
|
'$via1_multi_hash_actual_store_types/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
remove_constraint_internal(C,_,F),
|
|
( F==yes ->
|
|
'$delete_from_store_actual_store_types/2'(C)
|
|
;
|
|
true
|
|
),
|
|
actual_store_types(A,[B|D]).
|
|
update_store_type(A,B) :-
|
|
actual_store_types(A,[B]).
|
|
actual_store_types(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,actual_store_types(A,B),[A,B]),
|
|
'$insert_in_store_actual_store_types/2'(C).
|
|
assumed_store_type(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,assumed_store_type(A,B),[A,B]),
|
|
'$insert_in_store_assumed_store_type/2'(C).
|
|
validate_store_type_assumption(A) :-
|
|
'$via1_multi_hash_actual_store_types/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
'$via1_multi_hash_assumed_store_type/2-1'(A,F),
|
|
'chr sbag_member'(E,F),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
!,
|
|
remove_constraint_internal(B,_,G),
|
|
( G==yes ->
|
|
'$delete_from_store_actual_store_types/2'(B)
|
|
;
|
|
true
|
|
),
|
|
remove_constraint_internal(E,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_assumed_store_type/2'(E)
|
|
;
|
|
true
|
|
),
|
|
store_type(A,multi_store(C)).
|
|
validate_store_type_assumption(A) :-
|
|
'$via1_multi_hash_actual_store_types/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
'$via1_multi_hash_store_type/2-1'(A,F),
|
|
'chr sbag_member'(E,F),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
!,
|
|
remove_constraint_internal(B,_,G),
|
|
( G==yes ->
|
|
'$delete_from_store_actual_store_types/2'(B)
|
|
;
|
|
true
|
|
),
|
|
remove_constraint_internal(E,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_store_type/2'(E)
|
|
;
|
|
true
|
|
),
|
|
store_type(A,multi_store(C)).
|
|
validate_store_type_assumption(_).
|
|
rule_count(A) :-
|
|
insert_constraint_internal(_,_,B,true,rule_count(A),[A]),
|
|
'$insert_in_store_rule_count/1'(B).
|
|
inc_rule_count(A) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule_count/1',D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,C),
|
|
!,
|
|
remove_constraint_internal(B,_,E),
|
|
( E==yes ->
|
|
'$delete_from_store_rule_count/1'(B)
|
|
;
|
|
true
|
|
),
|
|
A is C+1,
|
|
rule_count(A).
|
|
inc_rule_count(1) :-
|
|
rule_count(1).
|
|
passive(A,B) :-
|
|
'passive/2__0'(A,B,_).
|
|
'passive/2__0'(A,B,_) :-
|
|
'$via1_multi_hash_passive/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!.
|
|
'passive/2__0'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
!,
|
|
allocate_constraint(true,C,passive(A,B),[A,B]),
|
|
'passive/2__0__0'(D,A,B,C).
|
|
'passive/2__0__0'([],A,B,C) :-
|
|
'passive/2__1'(A,B,C).
|
|
'passive/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(D,L),
|
|
'chr sbag_member'(H,L),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,K),
|
|
I==E,
|
|
J==A,
|
|
K==B ->
|
|
remove_constraint_internal(F,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(O,_,C,P),
|
|
( O==yes ->
|
|
'$insert_in_store_passive/2'(C)
|
|
;
|
|
true
|
|
),
|
|
N is E+1,
|
|
allocation_occurrence(D,N),
|
|
( C=suspension(_,mutable(active),_,mutable(P),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'passive/2__0__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'passive/2__0__0'(G,A,B,C)
|
|
).
|
|
'passive/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,passive(A,B),[A,B]),
|
|
'passive/2__1'(A,B,C).
|
|
'passive/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_least_occurrence/2-1'(A,D),
|
|
!,
|
|
'passive/2__1__0'(D,A,B,C).
|
|
'passive/2__1__0'([],A,B,C) :-
|
|
'passive/2__2'(A,B,C).
|
|
'passive/2__1__0'([F|I],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
E=[G|H],
|
|
G==B,
|
|
'$via1_multi_hash_rule/2-1'(A,K),
|
|
'chr sbag_member'(J,K),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,_) ->
|
|
remove_constraint_internal(F,_,L),
|
|
( L==yes ->
|
|
'$delete_from_store_least_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(M,_,C,N),
|
|
( M==yes ->
|
|
'$insert_in_store_passive/2'(C)
|
|
;
|
|
true
|
|
),
|
|
least_occurrence(A,H),
|
|
( C=suspension(_,mutable(active),_,mutable(N),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'passive/2__1__0'(I,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'passive/2__1__0'(I,A,B,C)
|
|
).
|
|
'passive/2__1'(A,B,C) :-
|
|
'passive/2__2'(A,B,C).
|
|
'passive/2__2'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:stored/3',D),
|
|
!,
|
|
'passive/2__2__0'(D,A,B,C).
|
|
'passive/2__2__0'([],A,B,C) :-
|
|
'passive/2__3'(A,B,C).
|
|
'passive/2__2__0'([G|H],A,B,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,D,E,F),
|
|
F=yes,
|
|
'$via1_multi_hash_occurrence/4-1'(D,M),
|
|
'chr sbag_member'(I,M),
|
|
I=suspension(_,mutable(active),_,_,_,_,_,J,K,L),
|
|
J==E,
|
|
K==A,
|
|
L==B,
|
|
'$via1_multi_hash_stored_complete/3-1'(D,Q),
|
|
'chr sbag_member'(N,Q),
|
|
N=suspension(_,mutable(active),_,_,_,_,_,O,P),
|
|
E<O ->
|
|
remove_constraint_internal(G,_,R),
|
|
( R==yes ->
|
|
'$delete_from_store_stored/3'(G)
|
|
;
|
|
true
|
|
),
|
|
remove_constraint_internal(N,_,S),
|
|
( S==yes ->
|
|
'$delete_from_store_stored_complete/3'(N)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(U,_,C,V),
|
|
( U==yes ->
|
|
'$insert_in_store_passive/2'(C)
|
|
;
|
|
true
|
|
),
|
|
T is P-1,
|
|
stored(D,E,maybe),
|
|
stored_complete(D,O,T),
|
|
( C=suspension(_,mutable(active),_,mutable(V),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'passive/2__2__0'(H,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'passive/2__2__0'(H,A,B,C)
|
|
).
|
|
'passive/2__2'(A,B,C) :-
|
|
'passive/2__3'(A,B,C).
|
|
'passive/2__3'(A,B,C) :-
|
|
'$via1_multi_hash_rule/2-1'(A,D),
|
|
!,
|
|
'passive/2__3__0'(D,A,B,C).
|
|
'passive/2__3__0'([],A,B,C) :-
|
|
'passive/2__4'(A,B,C).
|
|
'passive/2__3__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
M=t(91,F,C),
|
|
'chr novel_production'(F,M),
|
|
'chr novel_production'(C,M),
|
|
E=pragma(rule(_,_,_,_),ids([B|I],H),_,_,A) ->
|
|
'chr extend_history'(C,M),
|
|
activate_constraint(K,_,C,L),
|
|
( K==yes ->
|
|
'$insert_in_store_passive/2'(C)
|
|
;
|
|
true
|
|
),
|
|
append(I,H,J),
|
|
check_all_passive(A,J),
|
|
( C=suspension(_,mutable(active),_,mutable(L),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'passive/2__3__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'passive/2__3__0'(G,A,B,C)
|
|
).
|
|
'passive/2__3'(A,B,C) :-
|
|
'passive/2__4'(A,B,C).
|
|
'passive/2__4'(A,B,C) :-
|
|
'$via1_multi_hash_rule/2-1'(A,D),
|
|
!,
|
|
'passive/2__4__0'(D,A,B,C).
|
|
'passive/2__4__0'([],A,B,C) :-
|
|
'passive/2__5'(A,B,C).
|
|
'passive/2__4__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
K=t(92,F,C),
|
|
'chr novel_production'(F,K),
|
|
'chr novel_production'(C,K),
|
|
E=pragma(rule(_,_,_,_),ids([],[B|H]),_,_,A) ->
|
|
'chr extend_history'(C,K),
|
|
activate_constraint(I,_,C,J),
|
|
( I==yes ->
|
|
'$insert_in_store_passive/2'(C)
|
|
;
|
|
true
|
|
),
|
|
check_all_passive(A,H),
|
|
( C=suspension(_,mutable(active),_,mutable(J),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'passive/2__4__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'passive/2__4__0'(G,A,B,C)
|
|
).
|
|
'passive/2__4'(A,B,C) :-
|
|
'passive/2__5'(A,B,C).
|
|
'passive/2__5'(A,B,C) :-
|
|
'$via1_multi_hash_check_all_passive/2-1'(A,D),
|
|
!,
|
|
'passive/2__5__0'(D,A,B,C).
|
|
'passive/2__5__0'([],A,B,C) :-
|
|
'passive/2__6'(A,B,C).
|
|
'passive/2__5__0'([F|I],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
E=[G|H],
|
|
G==B ->
|
|
remove_constraint_internal(F,_,J),
|
|
( J==yes ->
|
|
'$delete_from_store_check_all_passive/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(K,_,C,L),
|
|
( K==yes ->
|
|
'$insert_in_store_passive/2'(C)
|
|
;
|
|
true
|
|
),
|
|
check_all_passive(A,H),
|
|
( C=suspension(_,mutable(active),_,mutable(L),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'passive/2__5__0'(I,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'passive/2__5__0'(I,A,B,C)
|
|
).
|
|
'passive/2__5'(A,B,C) :-
|
|
'passive/2__6'(A,B,C).
|
|
'passive/2__6'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_passive/2'(A)
|
|
;
|
|
true
|
|
).
|
|
is_passive(A,B) :-
|
|
'$via1_multi_hash_passive/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D==B,
|
|
!.
|
|
is_passive(_,_) :-
|
|
fail.
|
|
any_passive_head(A) :-
|
|
'$via1_multi_hash_passive/2-1'(A,C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
!.
|
|
any_passive_head(_) :-
|
|
fail.
|
|
new_occurrence(A,B,C) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,F),
|
|
'chr sbag_member'(D,F),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E),
|
|
!,
|
|
remove_constraint_internal(D,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_max_occurrence/2'(D)
|
|
;
|
|
true
|
|
),
|
|
G is E+1,
|
|
occurrence(A,G,B,C),
|
|
max_occurrence(A,G).
|
|
new_occurrence(A,B,_) :-
|
|
format('ERROR: new_occurrence: missing max_occurrence for ~w in rule ~w
|
|
',[A,B]),
|
|
fail.
|
|
occurrence(A,B,C,D) :-
|
|
'occurrence/4__0'(A,B,C,D,_).
|
|
'occurrence/4__0'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,F),
|
|
!,
|
|
allocate_constraint(true,E,occurrence(A,B,C,D),[A,B,C,D]),
|
|
'occurrence/4__0__0'(F,A,B,C,D,E).
|
|
'occurrence/4__0__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__1'(A,B,C,D,E).
|
|
'occurrence/4__0__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==A,
|
|
G==B,
|
|
'$via1_multi_hash_passive/2-1'(C,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
K==D ->
|
|
remove_constraint_internal(H,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(O,_,E,P),
|
|
( O==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
N is B+1,
|
|
allocation_occurrence(A,N),
|
|
( E=suspension(_,mutable(active),_,mutable(P),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__0__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__0__0'(I,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__0'(A,B,C,D,E) :-
|
|
allocate_constraint(true,E,occurrence(A,B,C,D),[A,B,C,D]),
|
|
'occurrence/4__1'(A,B,C,D,E).
|
|
'occurrence/4__1'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,F),
|
|
!,
|
|
'occurrence/4__1__0'(F,A,B,C,D,E).
|
|
'occurrence/4__1__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__2'(A,B,C,D,E).
|
|
'occurrence/4__1__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==A,
|
|
G==B,
|
|
'$via1_multi_hash_rule/2-1'(C,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
K=pragma(_,ids(N,_),_,_,_),
|
|
member(D,N) ->
|
|
remove_constraint_internal(H,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(P,_,E,Q),
|
|
( P==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
O is B+1,
|
|
allocation_occurrence(A,O),
|
|
( E=suspension(_,mutable(active),_,mutable(Q),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__1__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__1__0'(I,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__1'(A,B,C,D,E) :-
|
|
'occurrence/4__2'(A,B,C,D,E).
|
|
'occurrence/4__2'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,F),
|
|
!,
|
|
'occurrence/4__2__0'(F,A,B,C,D,E).
|
|
'occurrence/4__2__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__3'(A,B,C,D,E).
|
|
'occurrence/4__2__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==A,
|
|
G==B,
|
|
'$via1_multi_hash_rule/2-1'(C,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
K=pragma(rule([_|_],_,_,true),_,_,_,_) ->
|
|
remove_constraint_internal(H,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(O,_,E,P),
|
|
( O==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
N is B+1,
|
|
allocation_occurrence(A,N),
|
|
( E=suspension(_,mutable(active),_,mutable(P),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__2__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__2__0'(I,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__2'(A,B,C,D,E) :-
|
|
'occurrence/4__3'(A,B,C,D,E).
|
|
'occurrence/4__3'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,F),
|
|
!,
|
|
'occurrence/4__3__0'(F,A,B,C,D,E).
|
|
'occurrence/4__3__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__4'(A,B,C,D,E).
|
|
'occurrence/4__3__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==A,
|
|
G==B,
|
|
'$via1_multi_hash_rule/2-1'(C,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
K=pragma(rule([_|_],_,_,_),_,_,_,_),
|
|
\+is_observed(A,B) ->
|
|
remove_constraint_internal(H,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(O,_,E,P),
|
|
( O==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
N is B+1,
|
|
allocation_occurrence(A,N),
|
|
( E=suspension(_,mutable(active),_,mutable(P),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__3__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__3__0'(I,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__3'(A,B,C,D,E) :-
|
|
'occurrence/4__4'(A,B,C,D,E).
|
|
'occurrence/4__4'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,F),
|
|
!,
|
|
'occurrence/4__4__0'(F,A,B,C,D,E).
|
|
'occurrence/4__4__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__5'(A,B,C,D,E).
|
|
'occurrence/4__4__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==A,
|
|
G==B,
|
|
'$via1_multi_hash_least_occurrence/2-1'(C,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
K=[],
|
|
'$via1_multi_hash_rule/2-1'(C,O),
|
|
'chr sbag_member'(M,O),
|
|
M=suspension(_,mutable(active),_,_,_,_,_,N),
|
|
N=pragma(rule([],_,_,_),_,_,_,_),
|
|
\+is_observed(A,B) ->
|
|
remove_constraint_internal(H,_,P),
|
|
( P==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(R,_,E,S),
|
|
( R==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
Q is B+1,
|
|
allocation_occurrence(A,Q),
|
|
( E=suspension(_,mutable(active),_,mutable(S),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__4__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__4__0'(I,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__4'(A,B,C,D,E) :-
|
|
'occurrence/4__5'(A,B,C,D,E).
|
|
'occurrence/4__5'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_least_occurrence/2-1'(C,F),
|
|
!,
|
|
'occurrence/4__5__0'(F,A,B,C,D,E).
|
|
'occurrence/4__5__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__6'(A,B,C,D,E).
|
|
'occurrence/4__5__0'([H|K],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==C,
|
|
G=[I|J],
|
|
I==D,
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,N),
|
|
'chr sbag_member'(L,N),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M),
|
|
M>=B,
|
|
'$via1_multi_hash_rule/2-1'(C,P),
|
|
'chr sbag_member'(O,P),
|
|
O=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
\+may_trigger(A) ->
|
|
remove_constraint_internal(H,_,Q),
|
|
( Q==yes ->
|
|
'$delete_from_store_least_occurrence/2'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(R,_,E,S),
|
|
( R==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
least_occurrence(C,J),
|
|
( E=suspension(_,mutable(active),_,mutable(S),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__5__0'(K,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__5__0'(K,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__5'(A,B,C,D,E) :-
|
|
'occurrence/4__6'(A,B,C,D,E).
|
|
'occurrence/4__6'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_set_all_passive/1-1'(C,F),
|
|
!,
|
|
'occurrence/4__6__0'(F,A,B,C,D,E).
|
|
'occurrence/4__6__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__7'(A,B,C,D,E).
|
|
'occurrence/4__6__0'([G|H],A,B,C,D,E) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
F==C,
|
|
K=t(71,G,E),
|
|
'chr novel_production'(G,K),
|
|
'chr novel_production'(E,K) ->
|
|
'chr extend_history'(E,K),
|
|
activate_constraint(I,_,E,J),
|
|
( I==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
passive(C,D),
|
|
( E=suspension(_,mutable(active),_,mutable(J),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__6__0'(H,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__6__0'(H,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__6'(A,B,C,D,E) :-
|
|
'occurrence/4__7'(A,B,C,D,E).
|
|
'occurrence/4__7'(A,B,C,D,E) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',F),
|
|
!,
|
|
'occurrence/4__7__0'(F,A,B,C,D,E).
|
|
'occurrence/4__7__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__8'(A,B,C,D,E).
|
|
'occurrence/4__7__0'([G|H],A,B,C,D,E) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
chr_pp_flag(occurrence_subsumption,on),
|
|
'$via1_multi_hash_prev_guard_list/7-1'(C,R),
|
|
'chr sbag_member'(P,R),
|
|
P=suspension(_,mutable(active),_,_,_,_,_,Q,_,_,_,_,_),
|
|
Q=0,
|
|
'$via1_multi_hash_occurrence/4-1'(A,L),
|
|
'chr sbag_member'(I,L),
|
|
I=suspension(_,mutable(active),_,_,_,_,_,J,K,_),
|
|
K==C,
|
|
B<J,
|
|
'$via1_multi_hash_rule/2-1'(C,O),
|
|
'chr sbag_member'(M,O),
|
|
M=suspension(_,mutable(active),_,_,_,_,_,N),
|
|
N=pragma(rule(T,_,_,_),_,_,_,C),
|
|
T\==[],
|
|
\+memberchk_eq(A,F) ->
|
|
remove_constraint_internal(G,_,S),
|
|
( S==yes ->
|
|
'$delete_from_store_multiple_occ_constraints_checked/1'(G)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(U,_,E,V),
|
|
( U==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
first_occ_in_rule(C,A,B,D),
|
|
multiple_occ_constraints_checked([A|F]),
|
|
( E=suspension(_,mutable(active),_,mutable(V),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__7__0'(H,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__7__0'(H,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__7'(A,B,C,D,E) :-
|
|
'occurrence/4__8'(A,B,C,D,E).
|
|
'occurrence/4__8'(A,B,C,D,E) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',F),
|
|
!,
|
|
'occurrence/4__8__0'(F,A,B,C,D,E).
|
|
'occurrence/4__8__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__9'(A,B,C,D,E).
|
|
'occurrence/4__8__0'([G|H],A,B,C,D,E) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
chr_pp_flag(occurrence_subsumption,on),
|
|
'$via1_multi_hash_prev_guard_list/7-1'(C,S),
|
|
'chr sbag_member'(Q,S),
|
|
Q=suspension(_,mutable(active),_,_,_,_,_,R,_,_,_,_,_),
|
|
R=0,
|
|
'$via1_multi_hash_occurrence/4-1'(A,M),
|
|
'chr sbag_member'(I,M),
|
|
I=suspension(_,mutable(active),_,_,_,_,_,J,K,L),
|
|
K==C,
|
|
J<B,
|
|
'$via1_multi_hash_rule/2-1'(C,P),
|
|
'chr sbag_member'(N,P),
|
|
N=suspension(_,mutable(active),_,_,_,_,_,O),
|
|
O=pragma(rule(U,_,_,_),_,_,_,C),
|
|
U\==[],
|
|
\+memberchk_eq(A,F) ->
|
|
remove_constraint_internal(G,_,T),
|
|
( T==yes ->
|
|
'$delete_from_store_multiple_occ_constraints_checked/1'(G)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(V,_,E,W),
|
|
( V==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
first_occ_in_rule(C,A,J,L),
|
|
multiple_occ_constraints_checked([A|F]),
|
|
( E=suspension(_,mutable(active),_,mutable(W),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__8__0'(H,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__8__0'(H,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__8'(A,B,C,D,E) :-
|
|
'occurrence/4__9'(A,B,C,D,E).
|
|
'occurrence/4__9'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_stored/3-1'(A,F),
|
|
!,
|
|
'occurrence/4__9__0'(F,A,B,C,D,E).
|
|
'occurrence/4__9__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__10'(A,B,C,D,E).
|
|
'occurrence/4__9__0'([I|J],A,B,C,D,E) :-
|
|
( I=suspension(_,mutable(active),_,_,_,_,F,G,H),
|
|
F==A,
|
|
G==B,
|
|
H=yes,
|
|
'$via1_multi_hash_passive/2-1'(C,M),
|
|
'chr sbag_member'(K,M),
|
|
K=suspension(_,mutable(active),_,_,_,_,_,L),
|
|
L==D,
|
|
'$via1_multi_hash_stored_complete/3-1'(A,Q),
|
|
'chr sbag_member'(N,Q),
|
|
N=suspension(_,mutable(active),_,_,_,_,_,O,P),
|
|
B<O ->
|
|
remove_constraint_internal(I,_,R),
|
|
( R==yes ->
|
|
'$delete_from_store_stored/3'(I)
|
|
;
|
|
true
|
|
),
|
|
remove_constraint_internal(N,_,S),
|
|
( S==yes ->
|
|
'$delete_from_store_stored_complete/3'(N)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(U,_,E,V),
|
|
( U==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
T is P-1,
|
|
stored(A,B,maybe),
|
|
stored_complete(A,O,T),
|
|
( E=suspension(_,mutable(active),_,mutable(V),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__9__0'(J,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__9__0'(J,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__9'(A,B,C,D,E) :-
|
|
'occurrence/4__10'(A,B,C,D,E).
|
|
'occurrence/4__10'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_occurrence/4-3'(C,F),
|
|
!,
|
|
'occurrence/4__10__0'(F,A,B,C,D,E).
|
|
'occurrence/4__10__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__11'(A,B,C,D,E).
|
|
'occurrence/4__10__0'([H|J],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,_,G,_),
|
|
G==C,
|
|
'$via1_multi_hash_max_occurrence/2-1'(F,I) ->
|
|
'occurrence/4__10__1'(I,F,H,J,A,B,C,D,E)
|
|
;
|
|
'occurrence/4__10__0'(J,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__10__1'([],_,_,F,A,B,C,D,E) :-
|
|
'occurrence/4__10__0'(F,A,B,C,D,E).
|
|
'occurrence/4__10__1'([K|M],G,A,H,B,C,D,E,F) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==G,
|
|
'$via1_multi_hash_stored_complete/3-1'(G,L) ->
|
|
'occurrence/4__10__2'(L,J,K,M,G,A,H,B,C,D,E,F)
|
|
;
|
|
'occurrence/4__10__1'(M,G,A,H,B,C,D,E,F)
|
|
).
|
|
'occurrence/4__10__2'([],_,_,I,F,G,H,A,B,C,D,E) :-
|
|
'occurrence/4__10__1'(I,F,G,H,A,B,C,D,E).
|
|
'occurrence/4__10__2'([O|P],J,A,K,H,B,I,C,D,E,F,G) :-
|
|
( O=suspension(_,mutable(active),_,_,_,_,L,M,N),
|
|
L==H,
|
|
N=0,
|
|
S=t(90,G,B,O,A),
|
|
'chr novel_production'(G,S),
|
|
'chr novel_production'(B,S),
|
|
'chr novel_production'(O,S),
|
|
'chr novel_production'(A,S),
|
|
M=<J ->
|
|
'chr extend_history'(G,S),
|
|
activate_constraint(Q,_,G,R),
|
|
( Q==yes ->
|
|
'$insert_in_store_occurrence/4'(G)
|
|
;
|
|
true
|
|
),
|
|
passive(E,F),
|
|
( G=suspension(_,mutable(active),_,mutable(R),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__10__2'(P,J,A,K,H,B,I,C,D,E,F,G)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__10__2'(P,J,A,K,H,B,I,C,D,E,F,G)
|
|
).
|
|
'occurrence/4__10'(A,B,C,D,E) :-
|
|
'occurrence/4__11'(A,B,C,D,E).
|
|
'occurrence/4__11'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_occurrence/4-3'(C,F),
|
|
!,
|
|
'occurrence/4__11__0'(F,A,B,C,D,E).
|
|
'occurrence/4__11__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__12'(A,B,C,D,E).
|
|
'occurrence/4__11__0'([H|J],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,_,_,F,G),
|
|
F==C,
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,I) ->
|
|
'occurrence/4__11__1'(I,G,H,J,A,B,C,D,E)
|
|
;
|
|
'occurrence/4__11__0'(J,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__11__1'([],_,_,F,A,B,C,D,E) :-
|
|
'occurrence/4__11__0'(F,A,B,C,D,E).
|
|
'occurrence/4__11__1'([K|M],G,A,H,B,C,D,E,F) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==B,
|
|
'$via1_multi_hash_stored_complete/3-1'(B,L) ->
|
|
'occurrence/4__11__2'(L,J,K,M,G,A,H,B,C,D,E,F)
|
|
;
|
|
'occurrence/4__11__1'(M,G,A,H,B,C,D,E,F)
|
|
).
|
|
'occurrence/4__11__2'([],_,_,I,F,G,H,A,B,C,D,E) :-
|
|
'occurrence/4__11__1'(I,F,G,H,A,B,C,D,E).
|
|
'occurrence/4__11__2'([O|P],J,A,K,H,B,I,C,D,E,F,G) :-
|
|
( O=suspension(_,mutable(active),_,_,_,_,L,M,N),
|
|
L==C,
|
|
N=0,
|
|
S=t(90,B,G,O,A),
|
|
'chr novel_production'(B,S),
|
|
'chr novel_production'(G,S),
|
|
'chr novel_production'(O,S),
|
|
'chr novel_production'(A,S),
|
|
M=<J ->
|
|
'chr extend_history'(G,S),
|
|
activate_constraint(Q,_,G,R),
|
|
( Q==yes ->
|
|
'$insert_in_store_occurrence/4'(G)
|
|
;
|
|
true
|
|
),
|
|
passive(E,H),
|
|
( G=suspension(_,mutable(active),_,mutable(R),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__11__2'(P,J,A,K,H,B,I,C,D,E,F,G)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__11__2'(P,J,A,K,H,B,I,C,D,E,F,G)
|
|
).
|
|
'occurrence/4__11'(A,B,C,D,E) :-
|
|
'occurrence/4__12'(A,B,C,D,E).
|
|
'occurrence/4__12'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_stored_complete/3-1'(A,F),
|
|
!,
|
|
'occurrence/4__12__0'(F,A,B,C,D,E).
|
|
'occurrence/4__12__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__13'(A,B,C,D,E).
|
|
'occurrence/4__12__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G,_),
|
|
F==A,
|
|
L=t(99,H,E),
|
|
'chr novel_production'(H,L),
|
|
'chr novel_production'(E,L),
|
|
B>G ->
|
|
'chr extend_history'(E,L),
|
|
activate_constraint(J,_,E,K),
|
|
( J==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
passive(C,D),
|
|
( E=suspension(_,mutable(active),_,mutable(K),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__12__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__12__0'(I,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__12'(A,B,C,D,E) :-
|
|
'occurrence/4__13'(A,B,C,D,E).
|
|
'occurrence/4__13'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_functional_dependency/4-1'(A,F),
|
|
!,
|
|
'occurrence/4__13__0'(F,A,B,C,D,E).
|
|
'occurrence/4__13__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__14'(A,B,C,D,E).
|
|
'occurrence/4__13__0'([J|K],A,B,C,D,E) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,F,G,H,I),
|
|
F==A,
|
|
G==C,
|
|
C>1,
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,N),
|
|
'chr sbag_member'(L,N),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M),
|
|
M>B ->
|
|
remove_constraint_internal(J,_,O),
|
|
( O==yes ->
|
|
'$delete_from_store_functional_dependency/4'(J)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(P,_,E,Q),
|
|
( P==yes ->
|
|
'$insert_in_store_occurrence/4'(E)
|
|
;
|
|
true
|
|
),
|
|
functional_dependency(A,1,H,I),
|
|
( E=suspension(_,mutable(active),_,mutable(Q),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__13__0'(K,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__13__0'(K,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__13'(A,B,C,D,E) :-
|
|
'occurrence/4__14'(A,B,C,D,E).
|
|
'occurrence/4__14'(A,B,C,D,E) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',F),
|
|
!,
|
|
'occurrence/4__14__0'(F,A,B,C,D,E).
|
|
'occurrence/4__14__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__15'(A,B,C,D,E).
|
|
'occurrence/4__14__0'([G|M],A,B,C,D,E) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
F=odom(H,I),
|
|
H=occ(J,K),
|
|
J==A,
|
|
K==B,
|
|
'$via1_multi_hash_rule/2-1'(C,L) ->
|
|
'occurrence/4__14__1'(L,I,G,M,A,B,C,D,E)
|
|
;
|
|
'occurrence/4__14__0'(M,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__14__1'([],_,_,F,A,B,C,D,E) :-
|
|
'occurrence/4__14__0'(F,A,B,C,D,E).
|
|
'occurrence/4__14__1'([K|M],G,A,H,B,C,D,E,F) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==D,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',L) ->
|
|
'occurrence/4__14__2'(L,J,K,M,G,A,H,B,C,D,E,F)
|
|
;
|
|
'occurrence/4__14__1'(M,G,A,H,B,C,D,E,F)
|
|
).
|
|
'occurrence/4__14__2'([],_,_,I,G,F,H,A,B,C,D,E) :-
|
|
'occurrence/4__14__1'(I,G,F,H,A,B,C,D,E).
|
|
'occurrence/4__14__2'([M|N],J,A,K,H,B,I,C,D,E,F,G) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,L),
|
|
C1=t(140,B,M,G,A),
|
|
'chr novel_production'(B,C1),
|
|
'chr novel_production'(M,C1),
|
|
'chr novel_production'(G,C1),
|
|
'chr novel_production'(A,C1),
|
|
J=pragma(rule(O,P,_,Q),ids(R,_),_,_,_),
|
|
memberchk_eq(F,R) ->
|
|
'chr extend_history'(G,C1),
|
|
activate_constraint(A1,_,G,B1),
|
|
( A1==yes ->
|
|
'$insert_in_store_occurrence/4'(G)
|
|
;
|
|
true
|
|
),
|
|
select2(F,_,R,O,_,S),
|
|
ai_observation_abstract_constraints(S,L,T),
|
|
ai_observation_observe_list(odom([],H),T,odom([],U)),
|
|
ai_observation_abstract_constraints(P,L,V),
|
|
ai_observation_observe_list(odom([],U),V,odom([],W)),
|
|
ai_observation_abstract_goal(Q,L,X),
|
|
call_pattern(odom(X,W)),
|
|
Y is D+1,
|
|
Z=odom(occ(C,Y),H),
|
|
call_pattern(Z),
|
|
depends_on_as(odom(occ(C,D),H),odom(X,W),Z),
|
|
( G=suspension(_,mutable(active),_,mutable(B1),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__14__2'(N,J,A,K,H,B,I,C,D,E,F,G)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__14__2'(N,J,A,K,H,B,I,C,D,E,F,G)
|
|
).
|
|
'occurrence/4__14'(A,B,C,D,E) :-
|
|
'occurrence/4__15'(A,B,C,D,E).
|
|
'occurrence/4__15'(A,B,C,D,E) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',F),
|
|
!,
|
|
'occurrence/4__15__0'(F,A,B,C,D,E).
|
|
'occurrence/4__15__0'([],A,B,C,D,E) :-
|
|
'occurrence/4__16'(A,B,C,D,E).
|
|
'occurrence/4__15__0'([G|M],A,B,C,D,E) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
F=odom(H,I),
|
|
H=occ(J,K),
|
|
J==A,
|
|
K==B,
|
|
'$via1_multi_hash_rule/2-1'(C,L) ->
|
|
'occurrence/4__15__1'(L,I,G,M,A,B,C,D,E)
|
|
;
|
|
'occurrence/4__15__0'(M,A,B,C,D,E)
|
|
).
|
|
'occurrence/4__15__1'([],_,_,F,A,B,C,D,E) :-
|
|
'occurrence/4__15__0'(F,A,B,C,D,E).
|
|
'occurrence/4__15__1'([K|M],G,A,H,B,C,D,E,F) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==D,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',L) ->
|
|
'occurrence/4__15__2'(L,J,K,M,G,A,H,B,C,D,E,F)
|
|
;
|
|
'occurrence/4__15__1'(M,G,A,H,B,C,D,E,F)
|
|
).
|
|
'occurrence/4__15__2'([],_,_,I,G,F,H,A,B,C,D,E) :-
|
|
'occurrence/4__15__1'(I,G,F,H,A,B,C,D,E).
|
|
'occurrence/4__15__2'([M|N],J,A,K,H,B,I,C,D,E,F,G) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,L),
|
|
E1=t(142,B,M,G,A),
|
|
'chr novel_production'(B,E1),
|
|
'chr novel_production'(M,E1),
|
|
'chr novel_production'(G,E1),
|
|
'chr novel_production'(A,E1),
|
|
J=pragma(rule(O,P,_,Q),ids(_,R),_,_,_),
|
|
memberchk_eq(F,R) ->
|
|
'chr extend_history'(G,E1),
|
|
activate_constraint(C1,_,G,D1),
|
|
( C1==yes ->
|
|
'$insert_in_store_occurrence/4'(G)
|
|
;
|
|
true
|
|
),
|
|
select2(F,_,R,P,_,S),
|
|
ai_observation_abstract_constraints(S,L,T),
|
|
ai_observation_observe_list(odom([],H),T,odom([],U)),
|
|
ai_observation_abstract_constraints(O,L,V),
|
|
ai_observation_observe_list(odom([],U),V,odom([],W)),
|
|
ord_add_element(W,C,X),
|
|
ai_observation_abstract_goal(Q,L,Y),
|
|
call_pattern(odom(Y,X)),
|
|
( ord_memberchk(C,W) ->
|
|
Z=no
|
|
;
|
|
Z=yes
|
|
),
|
|
A1 is D+1,
|
|
B1=odom(occ(C,A1),H),
|
|
call_pattern(B1),
|
|
depends_on_ap(odom(occ(C,D),H),odom(Y,X),B1,Z),
|
|
( G=suspension(_,mutable(active),_,mutable(D1),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'occurrence/4__15__2'(N,J,A,K,H,B,I,C,D,E,F,G)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'occurrence/4__15__2'(N,J,A,K,H,B,I,C,D,E,F,G)
|
|
).
|
|
'occurrence/4__15'(A,B,C,D,E) :-
|
|
'occurrence/4__16'(A,B,C,D,E).
|
|
'occurrence/4__16'(_,_,_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_occurrence/4'(A)
|
|
;
|
|
true
|
|
).
|
|
get_occurrence(A,B,C,D) :-
|
|
'$via1_multi_hash_occurrence/4-1'(A,I),
|
|
'chr sbag_member'(E,I),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F,G,H),
|
|
F==B,
|
|
!,
|
|
G=C,
|
|
H=D.
|
|
get_occurrence(A,B,_,_) :-
|
|
format('get_occurrence: missing occurrence ~w:~w
|
|
',[A,B]),
|
|
fail.
|
|
max_occurrence(A,B) :-
|
|
'max_occurrence/2__0'(A,B,_).
|
|
'max_occurrence/2__0'(A,B,_) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D>=B,
|
|
!.
|
|
'max_occurrence/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,D),
|
|
!,
|
|
'max_occurrence/2__0__0'(D,A,B,C).
|
|
'max_occurrence/2__0__0'([],A,B,C) :-
|
|
'max_occurrence/2__1'(A,B,C).
|
|
'max_occurrence/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
B>=E ->
|
|
remove_constraint_internal(F,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_max_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
'max_occurrence/2__0__0'(G,A,B,C)
|
|
;
|
|
'max_occurrence/2__0__0'(G,A,B,C)
|
|
).
|
|
'max_occurrence/2__0'(A,B,C) :-
|
|
'max_occurrence/2__1'(A,B,C).
|
|
'max_occurrence/2__1'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:occurrence/4',D),
|
|
!,
|
|
allocate_constraint(true,C,max_occurrence(A,B),[A,B]),
|
|
'max_occurrence/2__1__0'(D,A,B,C).
|
|
'max_occurrence/2__1__0'([],A,B,C) :-
|
|
'max_occurrence/2__2'(A,B,C).
|
|
'max_occurrence/2__1__0'([F|H],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,_,_,D,E),
|
|
'$via1_multi_hash_stored_complete/3-1'(A,G) ->
|
|
'max_occurrence/2__1__1'(G,D,E,F,H,A,B,C)
|
|
;
|
|
'max_occurrence/2__1__0'(H,A,B,C)
|
|
).
|
|
'max_occurrence/2__1__1'([],_,_,_,D,A,B,C) :-
|
|
'max_occurrence/2__1__0'(D,A,B,C).
|
|
'max_occurrence/2__1__1'([K|M],E,F,A,G,B,C,D) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,H,I,J),
|
|
H==B,
|
|
J=0,
|
|
'$via1_multi_hash_occurrence/4-1'(B,L) ->
|
|
'max_occurrence/2__1__2'(L,I,K,M,E,F,A,G,B,C,D)
|
|
;
|
|
'max_occurrence/2__1__1'(M,E,F,A,G,B,C,D)
|
|
).
|
|
'max_occurrence/2__1__2'([],_,_,H,D,E,F,G,A,B,C) :-
|
|
'max_occurrence/2__1__1'(H,D,E,F,G,A,B,C).
|
|
'max_occurrence/2__1__2'([M|N],I,A,J,F,G,B,H,C,D,E) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,K,_,L,_),
|
|
M\==B,
|
|
K==C,
|
|
L==F,
|
|
Q=t(90,B,M,A,E),
|
|
'chr novel_production'(B,Q),
|
|
'chr novel_production'(M,Q),
|
|
'chr novel_production'(A,Q),
|
|
'chr novel_production'(E,Q),
|
|
I=<D ->
|
|
'chr extend_history'(E,Q),
|
|
activate_constraint(O,_,E,P),
|
|
( O==yes ->
|
|
'$insert_in_store_max_occurrence/2'(E)
|
|
;
|
|
true
|
|
),
|
|
passive(F,G),
|
|
( E=suspension(_,mutable(active),_,mutable(P),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'max_occurrence/2__1__2'(N,I,A,J,F,G,B,H,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'max_occurrence/2__1__2'(N,I,A,J,F,G,B,H,C,D,E)
|
|
).
|
|
'max_occurrence/2__1'(A,B,C) :-
|
|
allocate_constraint(true,C,max_occurrence(A,B),[A,B]),
|
|
'max_occurrence/2__2'(A,B,C).
|
|
'max_occurrence/2__2'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',D),
|
|
!,
|
|
'max_occurrence/2__2__0'(D,A,B,C).
|
|
'max_occurrence/2__2__0'([],A,B,C) :-
|
|
'max_occurrence/2__3'(A,B,C).
|
|
'max_occurrence/2__2__0'([E|F],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D),
|
|
D=odom(G,H),
|
|
G=occ(I,J),
|
|
I==A,
|
|
M=t(138,E,C),
|
|
'chr novel_production'(E,M),
|
|
'chr novel_production'(C,M),
|
|
J>B ->
|
|
'chr extend_history'(C,M),
|
|
activate_constraint(K,_,C,L),
|
|
( K==yes ->
|
|
'$insert_in_store_max_occurrence/2'(C)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(odom(occ(A,J),H),odom([],H)),
|
|
( C=suspension(_,mutable(active),_,mutable(L),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'max_occurrence/2__2__0'(F,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'max_occurrence/2__2__0'(F,A,B,C)
|
|
).
|
|
'max_occurrence/2__2'(A,B,C) :-
|
|
'max_occurrence/2__3'(A,B,C).
|
|
'max_occurrence/2__3'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_max_occurrence/2'(A)
|
|
;
|
|
true
|
|
).
|
|
get_max_occurrence(A,B) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_max_occurrence(A,B) :-
|
|
format('WARNING: get_max_occurrence: missing max occurrence for ~w
|
|
',[A]),
|
|
B=0.
|
|
allocation_occurrence(A,B) :-
|
|
'allocation_occurrence/2__0'(A,B,_).
|
|
'allocation_occurrence/2__0'(A,B,_) :-
|
|
'$via1_multi_hash_occurrence/4-1'(A,G),
|
|
'chr sbag_member'(C,G),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D,E,F),
|
|
D=B,
|
|
'$via1_multi_hash_passive/2-1'(E,J),
|
|
'chr sbag_member'(H,J),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I),
|
|
I=F,
|
|
!,
|
|
K is B+1,
|
|
allocation_occurrence(A,K).
|
|
'allocation_occurrence/2__0'(A,B,_) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(A,K),
|
|
'chr sbag_member'(G,K),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,J),
|
|
H=B,
|
|
I=D,
|
|
E=pragma(_,ids(L,_),_,_,_),
|
|
member(J,L),
|
|
!,
|
|
M is B+1,
|
|
allocation_occurrence(A,M).
|
|
'allocation_occurrence/2__0'(A,B,_) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(A,J),
|
|
'chr sbag_member'(G,J),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,_),
|
|
H=B,
|
|
I=D,
|
|
E=pragma(rule([_|_],_,_,true),_,_,_,_),
|
|
!,
|
|
K is B+1,
|
|
allocation_occurrence(A,K).
|
|
'allocation_occurrence/2__0'(A,B,_) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(A,J),
|
|
'chr sbag_member'(G,J),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,_),
|
|
H=B,
|
|
I=D,
|
|
E=pragma(rule([_|_],_,_,_),_,_,_,_),
|
|
\+is_observed(A,B),
|
|
!,
|
|
K is B+1,
|
|
allocation_occurrence(A,K).
|
|
'allocation_occurrence/2__0'(A,B,_) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(A,M),
|
|
'chr sbag_member'(J,M),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K,L,_),
|
|
K=B,
|
|
L=D,
|
|
'$via1_multi_hash_least_occurrence/2-1'(D,I),
|
|
'chr sbag_member'(G,I),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H),
|
|
H=[],
|
|
E=pragma(rule([],_,_,_),_,_,_,_),
|
|
\+is_observed(A,B),
|
|
!,
|
|
N is B+1,
|
|
allocation_occurrence(A,N).
|
|
'allocation_occurrence/2__0'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:least_occurrence/2',D),
|
|
!,
|
|
allocate_constraint(true,C,allocation_occurrence(A,B),[A,B]),
|
|
'allocation_occurrence/2__0__0'(D,A,B,C).
|
|
'allocation_occurrence/2__0__0'([],A,B,C) :-
|
|
'allocation_occurrence/2__1'(A,B,C).
|
|
'allocation_occurrence/2__0__0'([F|I],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
E=[G|H],
|
|
'$via1_multi_hash_occurrence/4-1'(A,N),
|
|
'chr sbag_member'(J,N),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K,L,M),
|
|
L==D,
|
|
M==G,
|
|
B>=K,
|
|
'$via1_multi_hash_rule/2-1'(D,P),
|
|
'chr sbag_member'(O,P),
|
|
O=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
\+may_trigger(A) ->
|
|
remove_constraint_internal(F,_,Q),
|
|
( Q==yes ->
|
|
'$delete_from_store_least_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(R,_,C,S),
|
|
( R==yes ->
|
|
'$insert_in_store_allocation_occurrence/2'(C)
|
|
;
|
|
true
|
|
),
|
|
least_occurrence(D,H),
|
|
( C=suspension(_,mutable(active),_,mutable(S),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'allocation_occurrence/2__0__0'(I,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'allocation_occurrence/2__0__0'(I,A,B,C)
|
|
).
|
|
'allocation_occurrence/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,allocation_occurrence(A,B),[A,B]),
|
|
'allocation_occurrence/2__1'(A,B,C).
|
|
'allocation_occurrence/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_functional_dependency/4-1'(A,D),
|
|
!,
|
|
'allocation_occurrence/2__1__0'(D,A,B,C).
|
|
'allocation_occurrence/2__1__0'([],A,B,C) :-
|
|
'allocation_occurrence/2__2'(A,B,C).
|
|
'allocation_occurrence/2__1__0'([H|I],A,B,C) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,D,E,F,G),
|
|
D==A,
|
|
E>1,
|
|
'$via1_multi_hash_occurrence/4-1'(A,M),
|
|
'chr sbag_member'(J,M),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K,L,_),
|
|
L==E,
|
|
B>K ->
|
|
remove_constraint_internal(H,_,N),
|
|
( N==yes ->
|
|
'$delete_from_store_functional_dependency/4'(H)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(O,_,C,P),
|
|
( O==yes ->
|
|
'$insert_in_store_allocation_occurrence/2'(C)
|
|
;
|
|
true
|
|
),
|
|
functional_dependency(A,1,F,G),
|
|
( C=suspension(_,mutable(active),_,mutable(P),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'allocation_occurrence/2__1__0'(I,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'allocation_occurrence/2__1__0'(I,A,B,C)
|
|
).
|
|
'allocation_occurrence/2__1'(A,B,C) :-
|
|
'allocation_occurrence/2__2'(A,B,C).
|
|
'allocation_occurrence/2__2'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_allocation_occurrence/2'(A)
|
|
;
|
|
true
|
|
).
|
|
get_allocation_occurrence(A,B) :-
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_allocation_occurrence(_,A) :-
|
|
chr_pp_flag(late_allocation,off),
|
|
A=0.
|
|
rule(A,B) :-
|
|
'rule/2__0'(A,B,_).
|
|
'rule/2__0'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
!,
|
|
allocate_constraint(true,C,rule(A,B),[A,B]),
|
|
'rule/2__0__0'(D,A,B,C).
|
|
'rule/2__0__0'([],A,B,C) :-
|
|
'rule/2__1'(A,B,C).
|
|
'rule/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(D,L),
|
|
'chr sbag_member'(H,L),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,K),
|
|
I==E,
|
|
J==A,
|
|
B=pragma(_,ids(N,_),_,_,_),
|
|
member(K,N) ->
|
|
remove_constraint_internal(F,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(P,_,C,Q),
|
|
( P==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
O is E+1,
|
|
allocation_occurrence(D,O),
|
|
( C=suspension(_,mutable(active),_,mutable(Q),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__0__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__0__0'(G,A,B,C)
|
|
).
|
|
'rule/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,rule(A,B),[A,B]),
|
|
'rule/2__1'(A,B,C).
|
|
'rule/2__1'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
!,
|
|
'rule/2__1__0'(D,A,B,C).
|
|
'rule/2__1__0'([],A,B,C) :-
|
|
'rule/2__2'(A,B,C).
|
|
'rule/2__1__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(D,K),
|
|
'chr sbag_member'(H,K),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,_),
|
|
I==E,
|
|
J==A,
|
|
B=pragma(rule([_|_],_,_,true),_,_,_,_) ->
|
|
remove_constraint_internal(F,_,L),
|
|
( L==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(N,_,C,O),
|
|
( N==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
M is E+1,
|
|
allocation_occurrence(D,M),
|
|
( C=suspension(_,mutable(active),_,mutable(O),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__1__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__1__0'(G,A,B,C)
|
|
).
|
|
'rule/2__1'(A,B,C) :-
|
|
'rule/2__2'(A,B,C).
|
|
'rule/2__2'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
!,
|
|
'rule/2__2__0'(D,A,B,C).
|
|
'rule/2__2__0'([],A,B,C) :-
|
|
'rule/2__3'(A,B,C).
|
|
'rule/2__2__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(D,K),
|
|
'chr sbag_member'(H,K),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,_),
|
|
I==E,
|
|
J==A,
|
|
B=pragma(rule([_|_],_,_,_),_,_,_,_),
|
|
\+is_observed(D,E) ->
|
|
remove_constraint_internal(F,_,L),
|
|
( L==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(N,_,C,O),
|
|
( N==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
M is E+1,
|
|
allocation_occurrence(D,M),
|
|
( C=suspension(_,mutable(active),_,mutable(O),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__2__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__2__0'(G,A,B,C)
|
|
).
|
|
'rule/2__2'(A,B,C) :-
|
|
'rule/2__3'(A,B,C).
|
|
'rule/2__3'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',D),
|
|
!,
|
|
'rule/2__3__0'(D,A,B,C).
|
|
'rule/2__3__0'([],A,B,C) :-
|
|
'rule/2__4'(A,B,C).
|
|
'rule/2__3__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_least_occurrence/2-1'(A,J),
|
|
'chr sbag_member'(H,J),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I),
|
|
I=[],
|
|
'$via1_multi_hash_occurrence/4-1'(D,N),
|
|
'chr sbag_member'(K,N),
|
|
K=suspension(_,mutable(active),_,_,_,_,_,L,M,_),
|
|
L==E,
|
|
M==A,
|
|
B=pragma(rule([],_,_,_),_,_,_,_),
|
|
\+is_observed(D,E) ->
|
|
remove_constraint_internal(F,_,O),
|
|
( O==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(Q,_,C,R),
|
|
( Q==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
P is E+1,
|
|
allocation_occurrence(D,P),
|
|
( C=suspension(_,mutable(active),_,mutable(R),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__3__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__3__0'(G,A,B,C)
|
|
).
|
|
'rule/2__3'(A,B,C) :-
|
|
'rule/2__4'(A,B,C).
|
|
'rule/2__4'(A,B,C) :-
|
|
'$via1_multi_hash_least_occurrence/2-1'(A,D),
|
|
!,
|
|
'rule/2__4__0'(D,A,B,C).
|
|
'rule/2__4__0'([],A,B,C) :-
|
|
'rule/2__5'(A,B,C).
|
|
'rule/2__4__0'([F|I],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
E=[G|H],
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',M),
|
|
'chr sbag_member'(J,M),
|
|
J=suspension(_,mutable(active),_,_,_,_,K,L),
|
|
'$via1_multi_hash_occurrence/4-1'(K,R),
|
|
'chr sbag_member'(N,R),
|
|
N=suspension(_,mutable(active),_,_,_,_,_,O,P,Q),
|
|
P==A,
|
|
Q==G,
|
|
L>=O,
|
|
\+may_trigger(K) ->
|
|
remove_constraint_internal(F,_,S),
|
|
( S==yes ->
|
|
'$delete_from_store_least_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(T,_,C,U),
|
|
( T==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
least_occurrence(A,H),
|
|
( C=suspension(_,mutable(active),_,mutable(U),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__4__0'(I,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__4__0'(I,A,B,C)
|
|
).
|
|
'rule/2__4'(A,B,C) :-
|
|
'rule/2__5'(A,B,C).
|
|
'rule/2__5'(A,B,C) :-
|
|
'$via1_multi_hash_least_occurrence/2-1'(A,D),
|
|
!,
|
|
'rule/2__5__0'(D,A,B,C).
|
|
'rule/2__5__0'([],A,B,C) :-
|
|
'rule/2__6'(A,B,C).
|
|
'rule/2__5__0'([F|I],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
E=[G|H],
|
|
'$via1_multi_hash_passive/2-1'(A,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
K==G ->
|
|
remove_constraint_internal(F,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_least_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(N,_,C,O),
|
|
( N==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
least_occurrence(A,H),
|
|
( C=suspension(_,mutable(active),_,mutable(O),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__5__0'(I,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__5__0'(I,A,B,C)
|
|
).
|
|
'rule/2__5'(A,B,C) :-
|
|
'rule/2__6'(A,B,C).
|
|
'rule/2__6'(A,B,C) :-
|
|
B=pragma(rule([],_,_,_),ids([],D),_,_,_),
|
|
!,
|
|
activate_constraint(E,_,C,F),
|
|
( E==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
least_occurrence(A,D),
|
|
( C=suspension(_,mutable(active),_,mutable(F),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__7'(A,B,C)
|
|
;
|
|
true
|
|
).
|
|
'rule/2__6'(A,B,C) :-
|
|
'rule/2__7'(A,B,C).
|
|
'rule/2__7'(A,B,C) :-
|
|
'$via1_multi_hash_prev_guard_list/7-2'(A,D),
|
|
!,
|
|
'rule/2__7__0'(D,A,B,C).
|
|
'rule/2__7__0'([],A,B,C) :-
|
|
'rule/2__8'(A,B,C).
|
|
'rule/2__7__0'([K|L],A,B,C) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,D,E,F,G,H,I,J),
|
|
E==A,
|
|
B=pragma(rule(N,O,P,_),_,_,_,A),
|
|
N\==[],
|
|
append(N,O,Q),
|
|
make_head_matchings_explicit(Q,R,S),
|
|
term_variables(R+F,T),
|
|
strip_attributes(T,U),
|
|
setof(V,chr_translate:head_subset(R,F,V),W),
|
|
restore_attributes(T,U),
|
|
W\=[] ->
|
|
remove_constraint_internal(K,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_prev_guard_list/7'(K)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(G1,_,C,H1),
|
|
( G1==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
compute_derived_info(S,W,R,Q,P,I,F,J,X,Y),
|
|
append(H,X,Z),
|
|
list2conj(Z,A1),
|
|
conj2list(A1,B1),
|
|
append(Y,J,C1),
|
|
list2conj(C1,D1),
|
|
conj2list(D1,E1),
|
|
F1 is A-1,
|
|
prev_guard_list(D,F1,F,G,B1,I,E1),
|
|
( C=suspension(_,mutable(active),_,mutable(H1),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__7__0'(L,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__7__0'(L,A,B,C)
|
|
).
|
|
'rule/2__7'(A,B,C) :-
|
|
'rule/2__8'(A,B,C).
|
|
'rule/2__8'(A,B,C) :-
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,J),
|
|
'chr sbag_member'(D,J),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F,G,H,I,_),
|
|
E=0,
|
|
B=pragma(rule(N,O,G,P),K,L,M,A),
|
|
G\==true,
|
|
append(I,H,Q),
|
|
simplify_guard(G,P,Q,R,S),
|
|
G\==R,
|
|
!,
|
|
remove_constraint_internal(D,_,T),
|
|
( T==yes ->
|
|
'$delete_from_store_prev_guard_list/7'(D)
|
|
;
|
|
true
|
|
),
|
|
( var(C) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(C,_,U),
|
|
( U==yes ->
|
|
'$delete_from_store_rule/2'(C)
|
|
;
|
|
true
|
|
)
|
|
),
|
|
rule(A,pragma(rule(N,O,R,S),K,L,M,A)),
|
|
prev_guard_list(A,0,F,R,H,I,[]).
|
|
'rule/2__8'(A,B,C) :-
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,D),
|
|
!,
|
|
'rule/2__8__0'(D,A,B,C).
|
|
'rule/2__8__0'([],A,B,C) :-
|
|
'rule/2__9'(A,B,C).
|
|
'rule/2__8__0'([I|J],A,B,C) :-
|
|
( I=suspension(_,mutable(active),_,_,_,_,D,E,_,F,G,H,_),
|
|
D==A,
|
|
E=0,
|
|
chr_pp_flag(check_impossible_rules,on),
|
|
B=pragma(rule(_,_,F,_),_,_,_,A),
|
|
append(H,G,L),
|
|
guard_entailment:entails_guard(L,fail) ->
|
|
remove_constraint_internal(I,_,K),
|
|
( K==yes ->
|
|
'$delete_from_store_prev_guard_list/7'(I)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(M,_,C,N),
|
|
( M==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
format('CHR compiler WARNING: heads will never match in ~@.
|
|
',[format_rule(B)]),
|
|
format(' `--> In the refined operational semantics (rules applied in textual order)
|
|
',[]),
|
|
format(' this rule will never fire! (given the declared types/modes)
|
|
',[]),
|
|
format(' Removing this redundant rule by making all its heads passive...
|
|
',[]),
|
|
format(' ... next warning is caused by this ...
|
|
',[]),
|
|
set_all_passive(A),
|
|
( C=suspension(_,mutable(active),_,mutable(N),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__8__0'(J,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__8__0'(J,A,B,C)
|
|
).
|
|
'rule/2__8'(A,B,C) :-
|
|
'rule/2__9'(A,B,C).
|
|
'rule/2__9'(A,B,C) :-
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,J),
|
|
'chr sbag_member'(D,J),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F,G,H,I,_),
|
|
E=0,
|
|
B=pragma(rule(N,O,G,P),K,L,M,A),
|
|
simplify_heads(I,H,G,P,Q,R),
|
|
Q\==[],
|
|
extract_variables(N,S),
|
|
extract_variables(O,T),
|
|
extract_variables(F,U),
|
|
replace_some_heads(S,T,U,Q,V,W,G,P,X),
|
|
insert_variables(V,N,Y),
|
|
insert_variables(W,O,Z),
|
|
append(R,X,A1),
|
|
list2conj(A1,B1),
|
|
C1=pragma(rule(Y,Z,G,(B1,P)),K,L,M,A),
|
|
(
|
|
N\==Y
|
|
;
|
|
O\==Z
|
|
),
|
|
!,
|
|
( var(C) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(C,_,D1),
|
|
( D1==yes ->
|
|
'$delete_from_store_rule/2'(C)
|
|
;
|
|
true
|
|
)
|
|
),
|
|
rule(A,C1).
|
|
'rule/2__9'(A,B,C) :-
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,D),
|
|
!,
|
|
'rule/2__9__0'(D,A,B,C).
|
|
'rule/2__9__0'([],A,B,C) :-
|
|
'rule/2__10'(A,B,C).
|
|
'rule/2__9__0'([G|H],A,B,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,D,E,_,F,_,_,_),
|
|
D==A,
|
|
E=0,
|
|
L=t(73,G,C),
|
|
'chr novel_production'(G,L),
|
|
'chr novel_production'(C,L),
|
|
chr_pp_flag(check_impossible_rules,on),
|
|
B=pragma(rule(_,_,F,_),_,_,_,A),
|
|
conj2list(F,I),
|
|
guard_entailment:entails_guard(I,fail) ->
|
|
'chr extend_history'(C,L),
|
|
activate_constraint(J,_,C,K),
|
|
( J==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
format('CHR compiler WARNING: guard will always fail in ~@.
|
|
',[format_rule(B)]),
|
|
format(' Removing this redundant rule by making all its heads passive...
|
|
',[]),
|
|
format(' ... next warning is caused by this ...
|
|
',[]),
|
|
set_all_passive(A),
|
|
( C=suspension(_,mutable(active),_,mutable(K),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__9__0'(H,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__9__0'(H,A,B,C)
|
|
).
|
|
'rule/2__9'(A,B,C) :-
|
|
'rule/2__10'(A,B,C).
|
|
'rule/2__10'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',D),
|
|
!,
|
|
'rule/2__10__0'(D,A,B,C).
|
|
'rule/2__10__0'([],A,B,C) :-
|
|
'rule/2__11'(A,B,C).
|
|
'rule/2__10__0'([E|F],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D),
|
|
chr_pp_flag(occurrence_subsumption,on),
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,R),
|
|
'chr sbag_member'(P,R),
|
|
P=suspension(_,mutable(active),_,_,_,_,_,Q,_,_,_,_,_),
|
|
Q=0,
|
|
'$via1_multi_hash_occurrence/4-3'(A,K),
|
|
'chr sbag_member'(G,K),
|
|
G=suspension(_,mutable(active),_,_,_,_,H,I,_,J),
|
|
'$via1_multi_hash_occurrence/4-1'(H,O),
|
|
'chr sbag_member'(L,O),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M,N,_),
|
|
L\==G,
|
|
N==A,
|
|
I<M,
|
|
B=pragma(rule(T,_,_,_),_,_,_,A),
|
|
T\==[],
|
|
\+memberchk_eq(H,D) ->
|
|
remove_constraint_internal(E,_,S),
|
|
( S==yes ->
|
|
'$delete_from_store_multiple_occ_constraints_checked/1'(E)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(U,_,C,V),
|
|
( U==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
first_occ_in_rule(A,H,I,J),
|
|
multiple_occ_constraints_checked([H|D]),
|
|
( C=suspension(_,mutable(active),_,mutable(V),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__10__0'(F,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__10__0'(F,A,B,C)
|
|
).
|
|
'rule/2__10'(A,B,C) :-
|
|
'rule/2__11'(A,B,C).
|
|
'rule/2__11'(A,B,C) :-
|
|
'$via1_multi_hash_passive/2-1'(A,D),
|
|
!,
|
|
'rule/2__11__0'(D,A,B,C).
|
|
'rule/2__11__0'([],A,B,C) :-
|
|
'rule/2__12'(A,B,C).
|
|
'rule/2__11__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
M=t(91,C,F),
|
|
'chr novel_production'(C,M),
|
|
'chr novel_production'(F,M),
|
|
B=pragma(rule(_,_,_,_),ids([E|I],H),_,_,A) ->
|
|
'chr extend_history'(C,M),
|
|
activate_constraint(K,_,C,L),
|
|
( K==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
append(I,H,J),
|
|
check_all_passive(A,J),
|
|
( C=suspension(_,mutable(active),_,mutable(L),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__11__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__11__0'(G,A,B,C)
|
|
).
|
|
'rule/2__11'(A,B,C) :-
|
|
'rule/2__12'(A,B,C).
|
|
'rule/2__12'(A,B,C) :-
|
|
'$via1_multi_hash_passive/2-1'(A,D),
|
|
!,
|
|
'rule/2__12__0'(D,A,B,C).
|
|
'rule/2__12__0'([],A,B,C) :-
|
|
'rule/2__13'(A,B,C).
|
|
'rule/2__12__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
K=t(92,C,F),
|
|
'chr novel_production'(C,K),
|
|
'chr novel_production'(F,K),
|
|
B=pragma(rule(_,_,_,_),ids([],[E|H]),_,_,A) ->
|
|
'chr extend_history'(C,K),
|
|
activate_constraint(I,_,C,J),
|
|
( I==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
check_all_passive(A,H),
|
|
( C=suspension(_,mutable(active),_,mutable(J),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__12__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__12__0'(G,A,B,C)
|
|
).
|
|
'rule/2__12'(A,B,C) :-
|
|
'rule/2__13'(A,B,C).
|
|
'rule/2__13'(A,B,C) :-
|
|
'$via1_multi_hash_check_all_passive/2-1'(A,D),
|
|
!,
|
|
'rule/2__13__0'(D,A,B,C).
|
|
'rule/2__13__0'([],A,B,C) :-
|
|
'rule/2__14'(A,B,C).
|
|
'rule/2__13__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
E=[] ->
|
|
remove_constraint_internal(F,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_check_all_passive/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(I,_,C,J),
|
|
( I==yes ->
|
|
'$insert_in_store_rule/2'(C)
|
|
;
|
|
true
|
|
),
|
|
format('CHR compiler WARNING: all heads passive in ~@.
|
|
',[format_rule(B)]),
|
|
format(' `--> Rule never fires. Check your program, this might be a bug!
|
|
',[]),
|
|
( C=suspension(_,mutable(active),_,mutable(J),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__13__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__13__0'(G,A,B,C)
|
|
).
|
|
'rule/2__13'(A,B,C) :-
|
|
'rule/2__14'(A,B,C).
|
|
'rule/2__14'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',D),
|
|
!,
|
|
'rule/2__14__0'(D,A,B,C).
|
|
'rule/2__14__0'([],A,B,C) :-
|
|
'rule/2__15'(A,B,C).
|
|
'rule/2__14__0'([E|K],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D),
|
|
D=odom(F,G),
|
|
F=occ(H,I),
|
|
'$via1_multi_hash_occurrence/4-1'(H,J) ->
|
|
'rule/2__14__1'(J,H,I,G,E,K,A,B,C)
|
|
;
|
|
'rule/2__14__0'(K,A,B,C)
|
|
).
|
|
'rule/2__14__1'([],_,_,_,_,D,A,B,C) :-
|
|
'rule/2__14__0'(D,A,B,C).
|
|
'rule/2__14__1'([M|O],F,G,E,A,H,B,C,D) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,I,J,K,L),
|
|
I==F,
|
|
J==G,
|
|
K==B,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',N) ->
|
|
'rule/2__14__2'(N,L,M,O,F,G,E,A,H,B,C,D)
|
|
;
|
|
'rule/2__14__1'(O,F,G,E,A,H,B,C,D)
|
|
).
|
|
'rule/2__14__2'([],_,_,I,F,G,E,D,H,A,B,C) :-
|
|
'rule/2__14__1'(I,F,G,E,D,H,A,B,C).
|
|
'rule/2__14__2'([M|N],J,A,K,G,H,F,B,I,C,D,E) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,L),
|
|
C1=t(140,B,M,A,E),
|
|
'chr novel_production'(B,C1),
|
|
'chr novel_production'(M,C1),
|
|
'chr novel_production'(A,C1),
|
|
'chr novel_production'(E,C1),
|
|
D=pragma(rule(O,P,_,Q),ids(R,_),_,_,_),
|
|
memberchk_eq(J,R) ->
|
|
'chr extend_history'(E,C1),
|
|
activate_constraint(A1,_,E,B1),
|
|
( A1==yes ->
|
|
'$insert_in_store_rule/2'(E)
|
|
;
|
|
true
|
|
),
|
|
select2(J,_,R,O,_,S),
|
|
ai_observation_abstract_constraints(S,L,T),
|
|
ai_observation_observe_list(odom([],F),T,odom([],U)),
|
|
ai_observation_abstract_constraints(P,L,V),
|
|
ai_observation_observe_list(odom([],U),V,odom([],W)),
|
|
ai_observation_abstract_goal(Q,L,X),
|
|
call_pattern(odom(X,W)),
|
|
Y is H+1,
|
|
Z=odom(occ(G,Y),F),
|
|
call_pattern(Z),
|
|
depends_on_as(odom(occ(G,H),F),odom(X,W),Z),
|
|
( E=suspension(_,mutable(active),_,mutable(B1),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__14__2'(N,J,A,K,G,H,F,B,I,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__14__2'(N,J,A,K,G,H,F,B,I,C,D,E)
|
|
).
|
|
'rule/2__14'(A,B,C) :-
|
|
'rule/2__15'(A,B,C).
|
|
'rule/2__15'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',D),
|
|
!,
|
|
'rule/2__15__0'(D,A,B,C).
|
|
'rule/2__15__0'([],A,B,C) :-
|
|
'rule/2__16'(A,B,C).
|
|
'rule/2__15__0'([E|K],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D),
|
|
D=odom(F,G),
|
|
F=occ(H,I),
|
|
'$via1_multi_hash_occurrence/4-1'(H,J) ->
|
|
'rule/2__15__1'(J,H,I,G,E,K,A,B,C)
|
|
;
|
|
'rule/2__15__0'(K,A,B,C)
|
|
).
|
|
'rule/2__15__1'([],_,_,_,_,D,A,B,C) :-
|
|
'rule/2__15__0'(D,A,B,C).
|
|
'rule/2__15__1'([M|O],F,G,E,A,H,B,C,D) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,I,J,K,L),
|
|
I==F,
|
|
J==G,
|
|
K==B,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',N) ->
|
|
'rule/2__15__2'(N,L,M,O,F,G,E,A,H,B,C,D)
|
|
;
|
|
'rule/2__15__1'(O,F,G,E,A,H,B,C,D)
|
|
).
|
|
'rule/2__15__2'([],_,_,I,F,G,E,D,H,A,B,C) :-
|
|
'rule/2__15__1'(I,F,G,E,D,H,A,B,C).
|
|
'rule/2__15__2'([M|N],J,A,K,G,H,F,B,I,C,D,E) :-
|
|
( M=suspension(_,mutable(active),_,_,_,_,L),
|
|
E1=t(142,B,M,A,E),
|
|
'chr novel_production'(B,E1),
|
|
'chr novel_production'(M,E1),
|
|
'chr novel_production'(A,E1),
|
|
'chr novel_production'(E,E1),
|
|
D=pragma(rule(O,P,_,Q),ids(_,R),_,_,_),
|
|
memberchk_eq(J,R) ->
|
|
'chr extend_history'(E,E1),
|
|
activate_constraint(C1,_,E,D1),
|
|
( C1==yes ->
|
|
'$insert_in_store_rule/2'(E)
|
|
;
|
|
true
|
|
),
|
|
select2(J,_,R,P,_,S),
|
|
ai_observation_abstract_constraints(S,L,T),
|
|
ai_observation_observe_list(odom([],F),T,odom([],U)),
|
|
ai_observation_abstract_constraints(O,L,V),
|
|
ai_observation_observe_list(odom([],U),V,odom([],W)),
|
|
ord_add_element(W,G,X),
|
|
ai_observation_abstract_goal(Q,L,Y),
|
|
call_pattern(odom(Y,X)),
|
|
( ord_memberchk(G,W) ->
|
|
Z=no
|
|
;
|
|
Z=yes
|
|
),
|
|
A1 is H+1,
|
|
B1=odom(occ(G,A1),F),
|
|
call_pattern(B1),
|
|
depends_on_ap(odom(occ(G,H),F),odom(Y,X),B1,Z),
|
|
( E=suspension(_,mutable(active),_,mutable(D1),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'rule/2__15__2'(N,J,A,K,G,H,F,B,I,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'rule/2__15__2'(N,J,A,K,G,H,F,B,I,C,D,E)
|
|
).
|
|
'rule/2__15'(A,B,C) :-
|
|
'rule/2__16'(A,B,C).
|
|
'rule/2__16'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_rule/2'(A)
|
|
;
|
|
true
|
|
).
|
|
get_rule(A,B) :-
|
|
'$via1_multi_hash_rule/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_rule(_,_) :-
|
|
fail.
|
|
least_occurrence(A,B) :-
|
|
'least_occurrence/2__0'(A,B,_).
|
|
'least_occurrence/2__0'(A,[],B) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',C),
|
|
!,
|
|
allocate_constraint(true,B,least_occurrence(A,[]),[A,[]]),
|
|
'least_occurrence/2__0__0'(C,A,[],B).
|
|
'least_occurrence/2__0__0'([],A,B,C) :-
|
|
'least_occurrence/2__1'(A,B,C).
|
|
'least_occurrence/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(D,K),
|
|
'chr sbag_member'(H,K),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,_),
|
|
I==E,
|
|
J==A,
|
|
'$via1_multi_hash_rule/2-1'(A,N),
|
|
'chr sbag_member'(L,N),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M),
|
|
M=pragma(rule([],_,_,_),_,_,_,_),
|
|
\+is_observed(D,E) ->
|
|
remove_constraint_internal(F,_,O),
|
|
( O==yes ->
|
|
'$delete_from_store_allocation_occurrence/2'(F)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(Q,_,C,R),
|
|
( Q==yes ->
|
|
'$insert_in_store_least_occurrence/2'(C)
|
|
;
|
|
true
|
|
),
|
|
P is E+1,
|
|
allocation_occurrence(D,P),
|
|
( C=suspension(_,mutable(active),_,mutable(R),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'least_occurrence/2__0__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'least_occurrence/2__0__0'(G,A,B,C)
|
|
).
|
|
'least_occurrence/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,least_occurrence(A,B),[A,B]),
|
|
'least_occurrence/2__1'(A,B,C).
|
|
'least_occurrence/2__1'(A,[C|D],B) :-
|
|
'$via1_multi_hash_rule/2-1'(A,F),
|
|
'chr sbag_member'(E,F),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
nb_getval('$chr_store_global_ground_chr_translate:allocation_occurrence/2',J),
|
|
'chr sbag_member'(G,J),
|
|
G=suspension(_,mutable(active),_,_,_,_,H,I),
|
|
'$via1_multi_hash_occurrence/4-1'(H,O),
|
|
'chr sbag_member'(K,O),
|
|
K=suspension(_,mutable(active),_,_,_,_,_,L,M,N),
|
|
M=A,
|
|
N=C,
|
|
I>=L,
|
|
\+may_trigger(H),
|
|
!,
|
|
( var(B) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(B,_,P),
|
|
( P==yes ->
|
|
'$delete_from_store_least_occurrence/2'(B)
|
|
;
|
|
true
|
|
)
|
|
),
|
|
least_occurrence(A,D).
|
|
'least_occurrence/2__1'(A,[C|D],B) :-
|
|
'$via1_multi_hash_rule/2-1'(A,F),
|
|
'chr sbag_member'(E,F),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
'$via1_multi_hash_passive/2-1'(A,I),
|
|
'chr sbag_member'(G,I),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H),
|
|
H=C,
|
|
!,
|
|
( var(B) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(B,_,J),
|
|
( J==yes ->
|
|
'$delete_from_store_least_occurrence/2'(B)
|
|
;
|
|
true
|
|
)
|
|
),
|
|
least_occurrence(A,D).
|
|
'least_occurrence/2__1'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_least_occurrence/2'(A)
|
|
;
|
|
true
|
|
).
|
|
is_least_occurrence(A) :-
|
|
'$via1_multi_hash_least_occurrence/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
C=[],
|
|
!.
|
|
is_least_occurrence(_) :-
|
|
fail.
|
|
constraint_index(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,constraint_index(A,B),[A,B]),
|
|
'$insert_in_store_constraint_index/2'(C).
|
|
get_constraint_index(A,B) :-
|
|
'$via1_multi_hash_constraint_index/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_constraint_index(_,_) :-
|
|
fail.
|
|
max_constraint_index(A) :-
|
|
insert_constraint_internal(_,_,B,true,max_constraint_index(A),[A]),
|
|
'$insert_in_store_max_constraint_index/1'(B).
|
|
get_max_constraint_index(A) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:max_constraint_index/1',D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,C),
|
|
!,
|
|
A=C.
|
|
get_max_constraint_index(0).
|
|
observes(A,B) :-
|
|
'$via1_multi_hash_observes/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!.
|
|
observes(A,B) :-
|
|
'$via1_multi_hash_spawns_observer/2-2'(A,C),
|
|
!,
|
|
'observes/2__0__0'(C,A,B).
|
|
'observes/2__0__0'([],A,B) :-
|
|
'observes/2__1'(A,B).
|
|
'observes/2__0__0'([E|F],A,B) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,C,D),
|
|
D==A ->
|
|
observes_indirectly(C,B),
|
|
'observes/2__0__0'(F,A,B)
|
|
;
|
|
'observes/2__0__0'(F,A,B)
|
|
).
|
|
observes(A,B) :-
|
|
'observes/2__1'(A,B).
|
|
'observes/2__1'(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,observes(A,B),[A,B]),
|
|
'$insert_in_store_observes/2'(C).
|
|
spawns_observer(A,B) :-
|
|
'spawns_observer/2__0'(A,B,_).
|
|
'spawns_observer/2__0'(A,B,_) :-
|
|
'$via1_multi_hash_spawns_observer/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!.
|
|
'spawns_observer/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_observes/2-1'(B,D),
|
|
!,
|
|
allocate_constraint(true,C,spawns_observer(A,B),[A,B]),
|
|
'spawns_observer/2__0__0'(D,A,B,C).
|
|
'spawns_observer/2__0__0'([],A,B,C) :-
|
|
'spawns_observer/2__1'(A,B,C).
|
|
'spawns_observer/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==B ->
|
|
activate_constraint(H,_,C,I),
|
|
( H==yes ->
|
|
'$insert_in_store_spawns_observer/2'(C)
|
|
;
|
|
true
|
|
),
|
|
observes_indirectly(A,E),
|
|
( C=suspension(_,mutable(active),_,mutable(I),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'spawns_observer/2__0__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'spawns_observer/2__0__0'(G,A,B,C)
|
|
).
|
|
'spawns_observer/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,spawns_observer(A,B),[A,B]),
|
|
'spawns_observer/2__1'(A,B,C).
|
|
'spawns_observer/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_observes_indirectly/2-1'(B,D),
|
|
!,
|
|
'spawns_observer/2__1__0'(D,A,B,C).
|
|
'spawns_observer/2__1__0'([],A,B,C) :-
|
|
'spawns_observer/2__2'(A,B,C).
|
|
'spawns_observer/2__1__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==B,
|
|
J=t(58,C,F),
|
|
'chr novel_production'(C,J),
|
|
'chr novel_production'(F,J) ->
|
|
'chr extend_history'(C,J),
|
|
activate_constraint(H,_,C,I),
|
|
( H==yes ->
|
|
'$insert_in_store_spawns_observer/2'(C)
|
|
;
|
|
true
|
|
),
|
|
observes_indirectly(A,E),
|
|
( C=suspension(_,mutable(active),_,mutable(I),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'spawns_observer/2__1__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'spawns_observer/2__1__0'(G,A,B,C)
|
|
).
|
|
'spawns_observer/2__1'(A,B,C) :-
|
|
'spawns_observer/2__2'(A,B,C).
|
|
'spawns_observer/2__2'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_spawns_observer/2'(A)
|
|
;
|
|
true
|
|
).
|
|
observes_indirectly(A,B) :-
|
|
'observes_indirectly/2__0'(A,B,_).
|
|
'observes_indirectly/2__0'(A,B,_) :-
|
|
'$via1_multi_hash_observes_indirectly/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!.
|
|
'observes_indirectly/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_spawns_observer/2-2'(A,D),
|
|
!,
|
|
allocate_constraint(true,C,observes_indirectly(A,B),[A,B]),
|
|
'observes_indirectly/2__0__0'(D,A,B,C).
|
|
'observes_indirectly/2__0__0'([],A,B,C) :-
|
|
'observes_indirectly/2__1'(A,B,C).
|
|
'observes_indirectly/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
E==A,
|
|
J=t(58,F,C),
|
|
'chr novel_production'(F,J),
|
|
'chr novel_production'(C,J) ->
|
|
'chr extend_history'(C,J),
|
|
activate_constraint(H,_,C,I),
|
|
( H==yes ->
|
|
'$insert_in_store_observes_indirectly/2'(C)
|
|
;
|
|
true
|
|
),
|
|
observes_indirectly(D,B),
|
|
( C=suspension(_,mutable(active),_,mutable(I),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'observes_indirectly/2__0__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'observes_indirectly/2__0__0'(G,A,B,C)
|
|
).
|
|
'observes_indirectly/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,observes_indirectly(A,B),[A,B]),
|
|
'observes_indirectly/2__1'(A,B,C).
|
|
'observes_indirectly/2__1'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_observes_indirectly/2'(A)
|
|
;
|
|
true
|
|
).
|
|
is_self_observer(A) :-
|
|
'$via1_multi_hash_observes_indirectly/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
C==A,
|
|
!.
|
|
is_self_observer(_) :-
|
|
chr_pp_flag(observation_analysis,off).
|
|
generate_indexed_variables_clause(B/C,A) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraint_mode/2',G),
|
|
'chr sbag_member'(D,G),
|
|
D=suspension(_,mutable(active),_,_,_,_,E,F),
|
|
E=B/C,
|
|
!,
|
|
functor(H,B,C),
|
|
H=..[_|I],
|
|
create_indexed_variables_body(I,F,J,1,B/C,K,L),
|
|
( K==empty ->
|
|
M=(J=[])
|
|
;
|
|
( L==0 ->
|
|
M=term_variables(N,J)
|
|
)
|
|
;
|
|
K=M
|
|
),
|
|
A=('$indexed_variables'(N,J):-N=H,M).
|
|
generate_indexed_variables_clause(A,_) :-
|
|
format('ERROR: generate_indexed_variables_clause: missing mode info for ~w
|
|
',[A]),
|
|
fail.
|
|
prev_guard_list(A,B,C,D,E,F,G) :-
|
|
'prev_guard_list/7__0'(A,B,C,D,E,F,G,_).
|
|
'prev_guard_list/7__0'(A,B,C,D,E,F,G,_) :-
|
|
'$via1_multi_hash_rule/2-1'(B,J),
|
|
'chr sbag_member'(H,J),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I),
|
|
I=pragma(rule(K,L,M,_),_,_,_,B),
|
|
K\==[],
|
|
append(K,L,N),
|
|
make_head_matchings_explicit(N,O,P),
|
|
term_variables(O+C,Q),
|
|
strip_attributes(Q,R),
|
|
setof(S,chr_translate:head_subset(O,C,S),T),
|
|
restore_attributes(Q,R),
|
|
T\=[],
|
|
!,
|
|
compute_derived_info(P,T,O,N,M,F,C,G,U,V),
|
|
append(E,U,W),
|
|
list2conj(W,X),
|
|
conj2list(X,Y),
|
|
append(V,G,Z),
|
|
list2conj(Z,A1),
|
|
conj2list(A1,B1),
|
|
C1 is B-1,
|
|
prev_guard_list(A,C1,C,D,Y,F,B1).
|
|
'prev_guard_list/7__0'(A,B,C,D,E,F,G,_) :-
|
|
B>0,
|
|
!,
|
|
H is B-1,
|
|
prev_guard_list(A,H,C,D,E,F,G).
|
|
'prev_guard_list/7__0'(A,0,B,C,D,E,F,_) :-
|
|
F\==[],
|
|
!,
|
|
add_type_information_(B,F,G),
|
|
conj2list(G,H),
|
|
term_variables(B,I),
|
|
append([chr_pp_headvariables(I)|H],D,J),
|
|
list2conj(J,K),
|
|
conj2list(K,L),
|
|
prev_guard_list(A,0,B,C,L,E,[]).
|
|
'prev_guard_list/7__0'(A,0,B,C,D,E,_,_) :-
|
|
'$via1_multi_hash_rule/2-1'(A,H),
|
|
'chr sbag_member'(F,H),
|
|
F=suspension(_,mutable(active),_,_,_,_,_,G),
|
|
G=pragma(rule(L,M,C,N),I,J,K,A),
|
|
C\==true,
|
|
append(E,D,O),
|
|
simplify_guard(C,N,O,P,Q),
|
|
C\==P,
|
|
!,
|
|
remove_constraint_internal(F,_,R),
|
|
( R==yes ->
|
|
'$delete_from_store_rule/2'(F)
|
|
;
|
|
true
|
|
),
|
|
rule(A,pragma(rule(L,M,P,Q),I,J,K,A)),
|
|
prev_guard_list(A,0,B,P,D,E,[]).
|
|
'prev_guard_list/7__0'(A,0,_,B,C,D,_,_) :-
|
|
chr_pp_flag(check_impossible_rules,on),
|
|
'$via1_multi_hash_rule/2-1'(A,G),
|
|
'chr sbag_member'(E,G),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F),
|
|
F=pragma(rule(_,_,B,_),_,_,_,A),
|
|
append(D,C,H),
|
|
guard_entailment:entails_guard(H,fail),
|
|
!,
|
|
format('CHR compiler WARNING: heads will never match in ~@.
|
|
',[format_rule(F)]),
|
|
format(' `--> In the refined operational semantics (rules applied in textual order)
|
|
',[]),
|
|
format(' this rule will never fire! (given the declared types/modes)
|
|
',[]),
|
|
format(' Removing this redundant rule by making all its heads passive...
|
|
',[]),
|
|
format(' ... next warning is caused by this ...
|
|
',[]),
|
|
set_all_passive(A).
|
|
'prev_guard_list/7__0'(A,0,B,C,D,E,F,G) :-
|
|
'$via1_multi_hash_rule/2-1'(A,H),
|
|
!,
|
|
allocate_constraint(true,G,prev_guard_list(A,0,B,C,D,E,F),[A,0,B,C,D,E,F]),
|
|
'prev_guard_list/7__0__0'(H,A,0,B,C,D,E,F,G).
|
|
'prev_guard_list/7__0__0'([],A,B,C,D,E,F,G,H) :-
|
|
'prev_guard_list/7__1'(A,B,C,D,E,F,G,H).
|
|
'prev_guard_list/7__0__0'([K|L],A,B,C,D,E,F,G,H) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==A,
|
|
J=pragma(rule(Q,R,D,S),N,O,P,A),
|
|
simplify_heads(F,E,D,S,T,U),
|
|
T\==[],
|
|
extract_variables(Q,V),
|
|
extract_variables(R,W),
|
|
extract_variables(C,X),
|
|
replace_some_heads(V,W,X,T,Y,Z,D,S,A1),
|
|
insert_variables(Y,Q,B1),
|
|
insert_variables(Z,R,C1),
|
|
append(U,A1,D1),
|
|
list2conj(D1,E1),
|
|
F1=pragma(rule(B1,C1,D,(E1,S)),N,O,P,A),
|
|
(
|
|
Q\==B1
|
|
;
|
|
R\==C1
|
|
) ->
|
|
remove_constraint_internal(K,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_rule/2'(K)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(G1,_,H,H1),
|
|
( G1==yes ->
|
|
'$insert_in_store_prev_guard_list/7'(H)
|
|
;
|
|
true
|
|
),
|
|
rule(A,F1),
|
|
( H=suspension(_,mutable(active),_,mutable(H1),_,_,_,_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'prev_guard_list/7__0__0'(L,A,B,C,D,E,F,G,H)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'prev_guard_list/7__0__0'(L,A,B,C,D,E,F,G,H)
|
|
).
|
|
'prev_guard_list/7__0'(A,B,C,D,E,F,G,H) :-
|
|
allocate_constraint(true,H,prev_guard_list(A,B,C,D,E,F,G),[A,B,C,D,E,F,G]),
|
|
'prev_guard_list/7__1'(A,B,C,D,E,F,G,H).
|
|
'prev_guard_list/7__1'(A,0,B,C,D,E,F,G) :-
|
|
'$via1_multi_hash_rule/2-1'(A,H),
|
|
!,
|
|
'prev_guard_list/7__1__0'(H,A,0,B,C,D,E,F,G).
|
|
'prev_guard_list/7__1__0'([],A,B,C,D,E,F,G,H) :-
|
|
'prev_guard_list/7__2'(A,B,C,D,E,F,G,H).
|
|
'prev_guard_list/7__1__0'([K|L],A,B,C,D,E,F,G,H) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==A,
|
|
P=t(73,H,K),
|
|
'chr novel_production'(H,P),
|
|
'chr novel_production'(K,P),
|
|
chr_pp_flag(check_impossible_rules,on),
|
|
J=pragma(rule(_,_,D,_),_,_,_,A),
|
|
conj2list(D,M),
|
|
guard_entailment:entails_guard(M,fail) ->
|
|
'chr extend_history'(H,P),
|
|
activate_constraint(N,_,H,O),
|
|
( N==yes ->
|
|
'$insert_in_store_prev_guard_list/7'(H)
|
|
;
|
|
true
|
|
),
|
|
format('CHR compiler WARNING: guard will always fail in ~@.
|
|
',[format_rule(J)]),
|
|
format(' Removing this redundant rule by making all its heads passive...
|
|
',[]),
|
|
format(' ... next warning is caused by this ...
|
|
',[]),
|
|
set_all_passive(A),
|
|
( H=suspension(_,mutable(active),_,mutable(O),_,_,_,_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'prev_guard_list/7__1__0'(L,A,B,C,D,E,F,G,H)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'prev_guard_list/7__1__0'(L,A,B,C,D,E,F,G,H)
|
|
).
|
|
'prev_guard_list/7__1'(A,B,C,D,E,F,G,H) :-
|
|
'prev_guard_list/7__2'(A,B,C,D,E,F,G,H).
|
|
'prev_guard_list/7__2'(A,0,B,C,D,E,F,G) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',H),
|
|
!,
|
|
'prev_guard_list/7__2__0'(H,A,0,B,C,D,E,F,G).
|
|
'prev_guard_list/7__2__0'([],A,B,C,D,E,F,G,H) :-
|
|
'prev_guard_list/7__3'(A,B,C,D,E,F,G,H).
|
|
'prev_guard_list/7__2__0'([J|K],A,B,C,D,E,F,G,H) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,I),
|
|
chr_pp_flag(occurrence_subsumption,on),
|
|
'$via1_multi_hash_occurrence/4-3'(A,O),
|
|
'chr sbag_member'(L,O),
|
|
L=suspension(_,mutable(active),_,_,_,_,M,N,_,_),
|
|
'$via1_multi_hash_occurrence/4-1'(M,W),
|
|
'chr sbag_member'(S,W),
|
|
S=suspension(_,mutable(active),_,_,_,_,_,T,U,V),
|
|
S\==L,
|
|
U==A,
|
|
T<N,
|
|
'$via1_multi_hash_rule/2-1'(A,R),
|
|
'chr sbag_member'(P,R),
|
|
P=suspension(_,mutable(active),_,_,_,_,_,Q),
|
|
Q=pragma(rule(Y,_,_,_),_,_,_,A),
|
|
Y\==[],
|
|
\+memberchk_eq(M,I) ->
|
|
remove_constraint_internal(J,_,X),
|
|
( X==yes ->
|
|
'$delete_from_store_multiple_occ_constraints_checked/1'(J)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(Z,_,H,A1),
|
|
( Z==yes ->
|
|
'$insert_in_store_prev_guard_list/7'(H)
|
|
;
|
|
true
|
|
),
|
|
first_occ_in_rule(A,M,T,V),
|
|
multiple_occ_constraints_checked([M|I]),
|
|
( H=suspension(_,mutable(active),_,mutable(A1),_,_,_,_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'prev_guard_list/7__2__0'(K,A,B,C,D,E,F,G,H)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'prev_guard_list/7__2__0'(K,A,B,C,D,E,F,G,H)
|
|
).
|
|
'prev_guard_list/7__2'(A,B,C,D,E,F,G,H) :-
|
|
'prev_guard_list/7__3'(A,B,C,D,E,F,G,H).
|
|
'prev_guard_list/7__3'(_,0,_,_,_,_,_,A) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:multiple_occ_constraints_checked/1',C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_),
|
|
!,
|
|
remove_constraint_internal(B,_,D),
|
|
( D==yes ->
|
|
'$delete_from_store_multiple_occ_constraints_checked/1'(B)
|
|
;
|
|
true
|
|
),
|
|
( var(A) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(A,_,E),
|
|
( E==yes ->
|
|
'$delete_from_store_prev_guard_list/7'(A)
|
|
;
|
|
true
|
|
)
|
|
).
|
|
'prev_guard_list/7__3'(_,_,_,_,_,_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_prev_guard_list/7'(A)
|
|
;
|
|
true
|
|
).
|
|
simplify_guards(A) :-
|
|
'$via1_multi_hash_rule/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
!,
|
|
C=pragma(rule(E,F,G,_),_,_,_,A),
|
|
append(E,F,H),
|
|
make_head_matchings_explicit_not_negated(H,I,J),
|
|
add_guard_to_head(H,G,K),
|
|
L is A-1,
|
|
prev_guard_list(A,L,I,G,[],J,[K]),
|
|
multiple_occ_constraints_checked([]),
|
|
M is A+1,
|
|
simplify_guards(M).
|
|
simplify_guards(_).
|
|
set_all_passive(A) :-
|
|
'set_all_passive/1__0'(A,_).
|
|
'set_all_passive/1__0'(A,B) :-
|
|
'$via1_multi_hash_occurrence/4-3'(A,C),
|
|
!,
|
|
allocate_constraint(true,B,set_all_passive(A),[A]),
|
|
'set_all_passive/1__0__0'(C,A,B).
|
|
'set_all_passive/1__0__0'([],A,B) :-
|
|
'set_all_passive/1__1'(A,B).
|
|
'set_all_passive/1__0__0'([E|F],A,B) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,_,_,C,D),
|
|
C==A,
|
|
I=t(71,B,E),
|
|
'chr novel_production'(B,I),
|
|
'chr novel_production'(E,I) ->
|
|
'chr extend_history'(B,I),
|
|
activate_constraint(G,_,B,H),
|
|
( G==yes ->
|
|
'$insert_in_store_set_all_passive/1'(B)
|
|
;
|
|
true
|
|
),
|
|
passive(A,D),
|
|
( B=suspension(_,mutable(active),_,mutable(H),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'set_all_passive/1__0__0'(F,A,B)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'set_all_passive/1__0__0'(F,A,B)
|
|
).
|
|
'set_all_passive/1__0'(A,B) :-
|
|
allocate_constraint(true,B,set_all_passive(A),[A]),
|
|
'set_all_passive/1__1'(A,B).
|
|
'set_all_passive/1__1'(_,A) :-
|
|
( var(A) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(A,_,B),
|
|
( B==yes ->
|
|
'$delete_from_store_set_all_passive/1'(A)
|
|
;
|
|
true
|
|
)
|
|
).
|
|
first_occ_in_rule(A,B,C,_) :-
|
|
'$via1_multi_hash_occurrence/4-1'(B,H),
|
|
'chr sbag_member'(D,H),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F,G),
|
|
F=A,
|
|
E<C,
|
|
!,
|
|
first_occ_in_rule(A,B,E,G).
|
|
first_occ_in_rule(A,B,C,D) :-
|
|
B=E/F,
|
|
functor(G,E,F),
|
|
next_occ_in_rule(A,B,C,D,[],G).
|
|
next_occ_in_rule(A,B,C,D,_,E) :-
|
|
'$via1_multi_hash_passive/2-1'(A,H),
|
|
'chr sbag_member'(F,H),
|
|
F=suspension(_,mutable(active),_,_,_,_,_,G),
|
|
'$via1_multi_hash_occurrence/4-1'(B,M),
|
|
'chr sbag_member'(I,M),
|
|
I=suspension(_,mutable(active),_,_,_,_,_,J,K,L),
|
|
K=A,
|
|
L=G,
|
|
J is C+1,
|
|
!,
|
|
next_occ_in_rule(A,B,J,D,_,E).
|
|
next_occ_in_rule(A,B,C,D,E,F) :-
|
|
'$via1_multi_hash_occurrence/4-1'(B,U),
|
|
'chr sbag_member'(Q,U),
|
|
Q=suspension(_,mutable(active),_,_,_,_,_,R,S,T),
|
|
S=A,
|
|
'$via1_multi_hash_prev_guard_list/7-1'(A,M),
|
|
'chr sbag_member'(G,M),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,J,K,L,_),
|
|
H=0,
|
|
'$via1_multi_hash_rule/2-1'(A,P),
|
|
'chr sbag_member'(N,P),
|
|
N=suspension(_,mutable(active),_,_,_,_,_,O),
|
|
R is C+1,
|
|
O=pragma(rule(V,W,J,_),ids(_,_),_,_,A),
|
|
!,
|
|
append(V,W,X),
|
|
add_failing_occ(O,X,I,D,Y,F,L,B,Z),
|
|
( Y==[chr_pp_void_info] ->
|
|
next_occ_in_rule(A,B,R,T,E,F)
|
|
;
|
|
append(Y,E,A1),
|
|
add_failing_occ(O,X,I,T,B1,F,L,B,C1),
|
|
copy_term(K,D1),
|
|
variable_replacement(K,D1,E1),
|
|
copy_with_variable_replacement(K,F1,Z),
|
|
copy_with_variable_replacement(K,G1,C1),
|
|
copy_with_variable_replacement(G1,H1,E1),
|
|
append(A1,F1,I1),
|
|
append(I1,H1,J1),
|
|
copy_with_variable_replacement(L,K1,Z),
|
|
copy_with_variable_replacement(L,L1,C1),
|
|
append(L1,J1,M1),
|
|
append([chr_pp_active_constraint(F)|K1],M1,N1),
|
|
list2conj(B1,O1),
|
|
copy_term((A1,J1,N1,O1,F),(P1,_,Q1,R1,S1)),
|
|
term_variables(P1-S1,T1),
|
|
flatten_stuff(Q1,U1),
|
|
flatten_stuff(R1,V1),
|
|
(
|
|
O1\=chr_pp_void_info,
|
|
unify_stuff(T1,U1,V1),
|
|
!,
|
|
( guard_entailment:entails_guard(Q1,R1) ->
|
|
passive(A,T)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
true
|
|
),
|
|
!,
|
|
next_occ_in_rule(A,B,R,T,A1,F)
|
|
).
|
|
next_occ_in_rule(_,_,_,_,_,_).
|
|
multiple_occ_constraints_checked(A) :-
|
|
chr_pp_flag(occurrence_subsumption,on),
|
|
nb_getval('$chr_store_global_ground_chr_translate:prev_guard_list/7',E),
|
|
'chr sbag_member'(B,E),
|
|
B=suspension(_,mutable(active),_,_,_,_,C,D,_,_,_,_,_),
|
|
D=0,
|
|
'$via1_multi_hash_rule/2-1'(C,L),
|
|
'chr sbag_member'(J,L),
|
|
J=suspension(_,mutable(active),_,_,_,_,_,K),
|
|
'$via1_multi_hash_occurrence/4-3'(C,I),
|
|
'chr sbag_member'(F,I),
|
|
F=suspension(_,mutable(active),_,_,_,_,G,H,_,_),
|
|
'$via1_multi_hash_occurrence/4-1'(G,Q),
|
|
'chr sbag_member'(M,Q),
|
|
M=suspension(_,mutable(active),_,_,_,_,_,N,O,P),
|
|
M\==F,
|
|
O=C,
|
|
N<H,
|
|
K=pragma(rule(R,_,_,_),_,_,_,C),
|
|
R\==[],
|
|
\+memberchk_eq(G,A),
|
|
!,
|
|
first_occ_in_rule(C,G,N,P),
|
|
multiple_occ_constraints_checked([G|A]).
|
|
multiple_occ_constraints_checked(_) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:prev_guard_list/7',C),
|
|
'chr sbag_member'(A,C),
|
|
A=suspension(_,mutable(active),_,_,_,_,_,B,_,_,_,_,_),
|
|
B=0,
|
|
!,
|
|
remove_constraint_internal(A,_,D),
|
|
( D==yes ->
|
|
'$delete_from_store_prev_guard_list/7'(A)
|
|
;
|
|
true
|
|
).
|
|
multiple_occ_constraints_checked(A) :-
|
|
insert_constraint_internal(_,_,B,true,multiple_occ_constraints_checked(A),[A]),
|
|
'$insert_in_store_multiple_occ_constraints_checked/1'(B).
|
|
type_definition(A,B) :-
|
|
( var(C) ->
|
|
insert_constraint_internal(E,D,C,chr_translate:type_definition(A,B),type_definition(A,B),[A,B])
|
|
;
|
|
activate_constraint(E,D,C,_)
|
|
),
|
|
( E==yes ->
|
|
'$insert_in_store_type_definition/2'(C),
|
|
'attach_type_definition/2'(D,C)
|
|
;
|
|
true
|
|
).
|
|
constraint_type(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,constraint_type(A,B),[A,B]),
|
|
'$insert_in_store_constraint_type/2'(C).
|
|
get_type_definition(A,B) :-
|
|
nonvar(A),
|
|
'chr global_term_ref_1'(F),
|
|
get_attr(F,chr_translate,G),
|
|
G=H,
|
|
'chr sbag_member'(C,H),
|
|
C=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
nonvar(D),
|
|
functor(D,I,J),
|
|
functor(A,I,J),
|
|
!,
|
|
copy_term((D,E),(K,L)),
|
|
K=A,
|
|
B=L.
|
|
get_type_definition(_,_) :-
|
|
fail.
|
|
get_constraint_type(A,B) :-
|
|
'$via1_multi_hash_constraint_type/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
!,
|
|
B=D.
|
|
get_constraint_type(_,_) :-
|
|
fail.
|
|
add_type_information([],[],A) :-
|
|
!,
|
|
A=true.
|
|
add_type_information([B|C],[D|E],A) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:constraint_mode/2',I),
|
|
'chr sbag_member'(F,I),
|
|
F=suspension(_,mutable(active),_,_,_,_,G,H),
|
|
G=J/K,
|
|
functor(B,J,K),
|
|
!,
|
|
B=..[_|L],
|
|
D=..[_|M],
|
|
add_mode_info(H,L,N),
|
|
A=(N,O),
|
|
( get_constraint_type(J/K,P) ->
|
|
types2condition(P,L,M,H,Q),
|
|
list2conj(Q,R),
|
|
O=(R,S),
|
|
add_type_information(C,E,S)
|
|
;
|
|
add_type_information(C,E,O)
|
|
).
|
|
add_type_information([A|_],_,_) :-
|
|
!,
|
|
functor(A,B,C),
|
|
format('CHR compiler ERROR: mode information missing for ~w.
|
|
',[B/C]),
|
|
format(' `--> Most likely this is a bug in the compiler itself.
|
|
',[]),
|
|
format(' Please contact the maintainers.
|
|
',[]),
|
|
fail.
|
|
add_type_information(A,B,C) :-
|
|
insert_constraint_internal(_,_,D,true,add_type_information(A,B,C),[A,B,C]),
|
|
'$insert_in_store_add_type_information/3'(D).
|
|
stored(A,B,yes) :-
|
|
'$via1_multi_hash_stored_complete/3-1'(A,F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D,E),
|
|
B<D,
|
|
'$via1_multi_hash_occurrence/4-1'(A,K),
|
|
'chr sbag_member'(G,K),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,J),
|
|
H=B,
|
|
'$via1_multi_hash_passive/2-1'(I,N),
|
|
'chr sbag_member'(L,N),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M),
|
|
M=J,
|
|
!,
|
|
remove_constraint_internal(C,_,P),
|
|
( P==yes ->
|
|
'$delete_from_store_stored_complete/3'(C)
|
|
;
|
|
true
|
|
),
|
|
O is E-1,
|
|
stored(A,B,maybe),
|
|
stored_complete(A,D,O).
|
|
stored(A,B,yes) :-
|
|
'$via1_multi_hash_stored_complete/3-1'(A,F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D,E),
|
|
B<D,
|
|
'$via1_multi_hash_ai_not_observed/2-1'(A,I),
|
|
'chr sbag_member'(G,I),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H),
|
|
H=B,
|
|
!,
|
|
remove_constraint_internal(C,_,K),
|
|
( K==yes ->
|
|
'$delete_from_store_stored_complete/3'(C)
|
|
;
|
|
true
|
|
),
|
|
J is E-1,
|
|
stored(A,B,maybe),
|
|
stored_complete(A,D,J).
|
|
stored(A,B,C) :-
|
|
insert_constraint_internal(_,_,D,true,stored(A,B,C),[A,B,C]),
|
|
'$insert_in_store_stored/3'(D).
|
|
stored_completing(A,B,C) :-
|
|
'$via1_multi_hash_stored/3-1'(A,G),
|
|
'chr sbag_member'(D,G),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F),
|
|
E==B,
|
|
F=yes,
|
|
!,
|
|
H is B+1,
|
|
I is C+1,
|
|
stored_completing(A,H,I).
|
|
stored_completing(A,B,C) :-
|
|
'$via1_multi_hash_stored/3-1'(A,G),
|
|
'chr sbag_member'(D,G),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F),
|
|
E==B,
|
|
F=maybe,
|
|
!,
|
|
H is B+1,
|
|
stored_completing(A,H,C).
|
|
stored_completing(A,B,C) :-
|
|
'$via1_multi_hash_stored/3-1'(A,F),
|
|
'chr sbag_member'(D,F),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,_),
|
|
E==B,
|
|
!,
|
|
stored_complete(A,B,C).
|
|
stored_completing(A,B,C) :-
|
|
stored_complete(A,B,C).
|
|
stored_complete(A,B,C) :-
|
|
'stored_complete/3__0'(A,B,C,_).
|
|
'stored_complete/3__0'(A,B,C,_) :-
|
|
'$via1_multi_hash_stored/3-1'(A,G),
|
|
'chr sbag_member'(D,G),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F),
|
|
F=yes,
|
|
E<B,
|
|
'$via1_multi_hash_occurrence/4-1'(A,L),
|
|
'chr sbag_member'(H,L),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,K),
|
|
I=E,
|
|
'$via1_multi_hash_passive/2-1'(J,O),
|
|
'chr sbag_member'(M,O),
|
|
M=suspension(_,mutable(active),_,_,_,_,_,N),
|
|
N=K,
|
|
!,
|
|
remove_constraint_internal(D,_,Q),
|
|
( Q==yes ->
|
|
'$delete_from_store_stored/3'(D)
|
|
;
|
|
true
|
|
),
|
|
P is C-1,
|
|
stored(A,E,maybe),
|
|
stored_complete(A,B,P).
|
|
'stored_complete/3__0'(A,B,C,_) :-
|
|
'$via1_multi_hash_stored/3-1'(A,G),
|
|
'chr sbag_member'(D,G),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E,F),
|
|
F=yes,
|
|
E<B,
|
|
'$via1_multi_hash_ai_not_observed/2-1'(A,J),
|
|
'chr sbag_member'(H,J),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I),
|
|
I=E,
|
|
!,
|
|
remove_constraint_internal(D,_,L),
|
|
( L==yes ->
|
|
'$delete_from_store_stored/3'(D)
|
|
;
|
|
true
|
|
),
|
|
K is C-1,
|
|
stored(A,E,maybe),
|
|
stored_complete(A,B,K).
|
|
'stored_complete/3__0'(A,B,0,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:occurrence/4',D),
|
|
!,
|
|
allocate_constraint(true,C,stored_complete(A,B,0),[A,B,0]),
|
|
'stored_complete/3__0__0'(D,A,B,0,C).
|
|
'stored_complete/3__0__0'([],A,B,C,D) :-
|
|
'stored_complete/3__1'(A,B,C,D).
|
|
'stored_complete/3__0__0'([G|I],A,B,C,D) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,_,_,E,F),
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,H) ->
|
|
'stored_complete/3__0__1'(H,E,F,G,I,A,B,C,D)
|
|
;
|
|
'stored_complete/3__0__0'(I,A,B,C,D)
|
|
).
|
|
'stored_complete/3__0__1'([],_,_,_,E,A,B,C,D) :-
|
|
'stored_complete/3__0__0'(E,A,B,C,D).
|
|
'stored_complete/3__0__1'([K|M],F,G,A,H,B,C,D,E) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==B,
|
|
'$via1_multi_hash_occurrence/4-1'(B,L) ->
|
|
'stored_complete/3__0__2'(L,J,K,M,F,G,A,H,B,C,D,E)
|
|
;
|
|
'stored_complete/3__0__1'(M,F,G,A,H,B,C,D,E)
|
|
).
|
|
'stored_complete/3__0__2'([],_,_,I,E,F,G,H,A,B,C,D) :-
|
|
'stored_complete/3__0__1'(I,E,F,G,H,A,B,C,D).
|
|
'stored_complete/3__0__2'([N|O],J,A,K,G,H,B,I,C,D,E,F) :-
|
|
( N=suspension(_,mutable(active),_,_,_,_,L,_,M,_),
|
|
N\==B,
|
|
L==C,
|
|
M==G,
|
|
R=t(90,B,N,F,A),
|
|
'chr novel_production'(B,R),
|
|
'chr novel_production'(N,R),
|
|
'chr novel_production'(F,R),
|
|
'chr novel_production'(A,R),
|
|
D=<J ->
|
|
'chr extend_history'(F,R),
|
|
activate_constraint(P,_,F,Q),
|
|
( P==yes ->
|
|
'$insert_in_store_stored_complete/3'(F)
|
|
;
|
|
true
|
|
),
|
|
passive(G,H),
|
|
( F=suspension(_,mutable(active),_,mutable(Q),_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'stored_complete/3__0__2'(O,J,A,K,G,H,B,I,C,D,E,F)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'stored_complete/3__0__2'(O,J,A,K,G,H,B,I,C,D,E,F)
|
|
).
|
|
'stored_complete/3__0'(A,B,C,D) :-
|
|
allocate_constraint(true,D,stored_complete(A,B,C),[A,B,C]),
|
|
'stored_complete/3__1'(A,B,C,D).
|
|
'stored_complete/3__1'(A,B,C,D) :-
|
|
'$via1_multi_hash_occurrence/4-1'(A,E),
|
|
!,
|
|
'stored_complete/3__1__0'(E,A,B,C,D).
|
|
'stored_complete/3__1__0'([],A,B,C,D) :-
|
|
'stored_complete/3__2'(A,B,C,D).
|
|
'stored_complete/3__1__0'([I|J],A,B,C,D) :-
|
|
( I=suspension(_,mutable(active),_,_,_,_,E,F,G,H),
|
|
E==A,
|
|
M=t(99,D,I),
|
|
'chr novel_production'(D,M),
|
|
'chr novel_production'(I,M),
|
|
F>B ->
|
|
'chr extend_history'(D,M),
|
|
activate_constraint(K,_,D,L),
|
|
( K==yes ->
|
|
'$insert_in_store_stored_complete/3'(D)
|
|
;
|
|
true
|
|
),
|
|
passive(G,H),
|
|
( D=suspension(_,mutable(active),_,mutable(L),_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'stored_complete/3__1__0'(J,A,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'stored_complete/3__1__0'(J,A,B,C,D)
|
|
).
|
|
'stored_complete/3__1'(A,B,C,D) :-
|
|
'stored_complete/3__2'(A,B,C,D).
|
|
'stored_complete/3__2'(_,_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_stored_complete/3'(A)
|
|
;
|
|
true
|
|
).
|
|
is_stored(A) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
'$via1_multi_hash_stored_complete/3-1'(A,H),
|
|
'chr sbag_member'(E,H),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F,G),
|
|
G=0,
|
|
F=<C,
|
|
!,
|
|
fail.
|
|
is_stored(_).
|
|
is_finally_stored(A) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
'$via1_multi_hash_stored_complete/3-1'(A,G),
|
|
'chr sbag_member'(E,G),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F,_),
|
|
F=<C,
|
|
!,
|
|
fail.
|
|
is_finally_stored(_).
|
|
check_all_passive(A,[B|C]) :-
|
|
'$via1_multi_hash_passive/2-1'(A,F),
|
|
'chr sbag_member'(D,F),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E),
|
|
E=B,
|
|
!,
|
|
check_all_passive(A,C).
|
|
check_all_passive(A,[]) :-
|
|
'$via1_multi_hash_rule/2-1'(A,D),
|
|
'chr sbag_member'(B,D),
|
|
B=suspension(_,mutable(active),_,_,_,_,_,C),
|
|
!,
|
|
format('CHR compiler WARNING: all heads passive in ~@.
|
|
',[format_rule(C)]),
|
|
format(' `--> Rule never fires. Check your program, this might be a bug!
|
|
',[]).
|
|
check_all_passive(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,check_all_passive(A,B),[A,B]),
|
|
'$insert_in_store_check_all_passive/2'(C).
|
|
constraints_code1([],A,B) :-
|
|
!,
|
|
A=B.
|
|
constraints_code1([C|D],A,B) :-
|
|
!,
|
|
constraint_code(C,A,E),
|
|
constraints_code1(D,E,B).
|
|
constraints_code1(A,B,C) :-
|
|
insert_constraint_internal(_,_,D,true,constraints_code1(A,B,C),[A,B,C]),
|
|
'$insert_in_store_constraints_code1/3'(D).
|
|
constraint_code(A,B,C) :-
|
|
(
|
|
(
|
|
chr_pp_flag(debugable,on)
|
|
;
|
|
is_stored(A),
|
|
(
|
|
has_active_occurrence(A)
|
|
;
|
|
chr_pp_flag(late_allocation,off)
|
|
),
|
|
(
|
|
may_trigger(A)
|
|
;
|
|
get_allocation_occurrence(A,D),
|
|
get_max_occurrence(A,E),
|
|
E>=D
|
|
)
|
|
) ->
|
|
constraint_prelude(A,F),
|
|
B=[F|G]
|
|
;
|
|
B=G
|
|
),
|
|
H=[0],
|
|
occurrences_code(A,1,H,I,G,J),
|
|
gen_cond_attach_clause(A,I,J,C).
|
|
has_active_occurrence(A) :-
|
|
has_active_occurrence(A,1).
|
|
has_active_occurrence(A,B) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
B>D,
|
|
!,
|
|
fail.
|
|
has_active_occurrence(A,B) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:passive/2',F),
|
|
'chr sbag_member'(C,F),
|
|
C=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
'$via1_multi_hash_occurrence/4-1'(A,K),
|
|
'chr sbag_member'(G,K),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,J),
|
|
H==B,
|
|
I=D,
|
|
J=E,
|
|
!,
|
|
L is B+1,
|
|
has_active_occurrence(A,L).
|
|
has_active_occurrence(_,_).
|
|
use_auxiliary_predicate(A) :-
|
|
'$via1_multi_hash_use_auxiliary_predicate/1-1'(A,C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_),
|
|
!.
|
|
use_auxiliary_predicate(A) :-
|
|
insert_constraint_internal(_,_,B,true,use_auxiliary_predicate(A),[A]),
|
|
'$insert_in_store_use_auxiliary_predicate/1'(B).
|
|
is_used_auxiliary_predicate(A) :-
|
|
'$via1_multi_hash_use_auxiliary_predicate/1-1'(A,C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_),
|
|
!.
|
|
is_used_auxiliary_predicate(_) :-
|
|
fail.
|
|
occurrences_code(A,B,C,D,E,F) :-
|
|
'$via1_multi_hash_max_occurrence/2-1'(A,I),
|
|
'chr sbag_member'(G,I),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H),
|
|
B>H,
|
|
!,
|
|
D=C,
|
|
E=F.
|
|
occurrences_code(A,B,C,D,E,F) :-
|
|
occurrence_code(A,B,C,G,E,H),
|
|
I is B+1,
|
|
occurrences_code(A,I,G,D,H,F).
|
|
occurrence_code(A,B,C,D,E,F) :-
|
|
'$via1_multi_hash_occurrence/4-1'(A,K),
|
|
'chr sbag_member'(G,K),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,J),
|
|
H=B,
|
|
'$via1_multi_hash_passive/2-1'(I,N),
|
|
'chr sbag_member'(L,N),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M),
|
|
M=J,
|
|
!,
|
|
D=C,
|
|
E=F.
|
|
occurrence_code(A,B,C,D,E,F) :-
|
|
'$via1_multi_hash_occurrence/4-1'(A,K),
|
|
'chr sbag_member'(G,K),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H,I,J),
|
|
H=B,
|
|
'$via1_multi_hash_rule/2-1'(I,N),
|
|
'chr sbag_member'(L,N),
|
|
L=suspension(_,mutable(active),_,_,_,_,_,M),
|
|
!,
|
|
M=pragma(rule(O,P,_,_),ids(Q,R),_,_,_),
|
|
( select2(J,S,Q,O,T,U) ->
|
|
D=C,
|
|
head1_code(S,U,T,M,A,B,C,E,F)
|
|
;
|
|
( select2(J,V,R,P,W,X) ->
|
|
head2_code(V,X,W,M,A,B,C,E,Y),
|
|
inc_id(C,D),
|
|
( unconditional_occurrence(A,B) ->
|
|
Y=F
|
|
;
|
|
gen_alloc_inc_clause(A,B,C,Y,F)
|
|
)
|
|
)
|
|
).
|
|
occurrence_code(A,B,_,_,_,_) :-
|
|
format('occurrence_code/6: missing information to compile ~w:~w
|
|
',[A,B]),
|
|
fail.
|
|
functional_dependency(A,B,C,D) :-
|
|
B>1,
|
|
'$via1_multi_hash_allocation_occurrence/2-1'(A,G),
|
|
'chr sbag_member'(E,G),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F),
|
|
'$via1_multi_hash_occurrence/4-1'(A,K),
|
|
'chr sbag_member'(H,K),
|
|
H=suspension(_,mutable(active),_,_,_,_,_,I,J,_),
|
|
J=B,
|
|
F>I,
|
|
!,
|
|
functional_dependency(A,1,C,D).
|
|
functional_dependency(A,B,C,D) :-
|
|
insert_constraint_internal(_,_,E,true,functional_dependency(A,B,C,D),[A,B,C,D]),
|
|
'$insert_in_store_functional_dependency/4'(E).
|
|
get_functional_dependency(A,B,C,D) :-
|
|
'$via1_multi_hash_functional_dependency/4-1'(A,I),
|
|
'chr sbag_member'(E,I),
|
|
E=suspension(_,mutable(active),_,_,_,_,_,F,G,H),
|
|
B>=F,
|
|
!,
|
|
C=G,
|
|
D=H.
|
|
get_functional_dependency(_,_,_,_) :-
|
|
fail.
|
|
initial_call_pattern(A) :-
|
|
'initial_call_pattern/1__0'(A,_).
|
|
'initial_call_pattern/1__0'(A,_) :-
|
|
'$via1_multi_hash_initial_call_pattern/1-1'(A,C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_),
|
|
!.
|
|
'initial_call_pattern/1__0'(A,B) :-
|
|
allocate_constraint(true,B,initial_call_pattern(A),[A]),
|
|
activate_constraint(C,_,B,D),
|
|
( C==yes ->
|
|
'$insert_in_store_initial_call_pattern/1'(B)
|
|
;
|
|
true
|
|
),
|
|
call_pattern(A),
|
|
( B=suspension(_,mutable(active),_,mutable(D),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'initial_call_pattern/1__1'(A,B)
|
|
;
|
|
true
|
|
).
|
|
'initial_call_pattern/1__1'(A,B) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(A,C),
|
|
!,
|
|
'initial_call_pattern/1__1__0'(C,A,B).
|
|
'initial_call_pattern/1__1__0'([],A,B) :-
|
|
'initial_call_pattern/1__2'(A,B).
|
|
'initial_call_pattern/1__1__0'([E|G],A,B) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,C,D),
|
|
C==A,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',F) ->
|
|
'initial_call_pattern/1__1__1'(F,D,E,G,A,B)
|
|
;
|
|
'initial_call_pattern/1__1__0'(G,A,B)
|
|
).
|
|
'initial_call_pattern/1__1__1'([],_,_,C,A,B) :-
|
|
'initial_call_pattern/1__1__0'(C,A,B).
|
|
'initial_call_pattern/1__1__1'([G|H],D,A,E,B,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
K=t(130,C,A,G),
|
|
'chr novel_production'(C,K),
|
|
'chr novel_production'(A,K),
|
|
'chr novel_production'(G,K) ->
|
|
'chr extend_history'(C,K),
|
|
activate_constraint(I,_,C,J),
|
|
( I==yes ->
|
|
'$insert_in_store_initial_call_pattern/1'(C)
|
|
;
|
|
true
|
|
),
|
|
ai_observation_schedule_new_calls(F,D),
|
|
( C=suspension(_,mutable(active),_,mutable(J),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'initial_call_pattern/1__1__1'(H,D,A,E,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'initial_call_pattern/1__1__1'(H,D,A,E,B,C)
|
|
).
|
|
'initial_call_pattern/1__1'(A,B) :-
|
|
'initial_call_pattern/1__2'(A,B).
|
|
'initial_call_pattern/1__2'(_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_initial_call_pattern/1'(A)
|
|
;
|
|
true
|
|
).
|
|
call_pattern(A) :-
|
|
'call_pattern/1__0'(A,_).
|
|
'call_pattern/1__0'(A,_) :-
|
|
'$via1_multi_hash_call_pattern/1-1'(A,C),
|
|
'chr sbag_member'(B,C),
|
|
B=suspension(_,mutable(active),_,_,_,_,_),
|
|
!.
|
|
'call_pattern/1__0'(A,B) :-
|
|
A=odom(C,D),
|
|
C=[],
|
|
allocate_constraint(true,B,call_pattern(A),[A]),
|
|
!,
|
|
activate_constraint(E,_,B,F),
|
|
( E==yes ->
|
|
'$insert_in_store_call_pattern/1'(B)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(odom([],D),odom([],D)),
|
|
( B=suspension(_,mutable(active),_,mutable(F),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__1'(A,B)
|
|
;
|
|
true
|
|
).
|
|
'call_pattern/1__0'(A,B) :-
|
|
allocate_constraint(true,B,call_pattern(A),[A]),
|
|
'call_pattern/1__1'(A,B).
|
|
'call_pattern/1__1'(A,B) :-
|
|
A=odom(C,D),
|
|
C=[E|F],
|
|
!,
|
|
activate_constraint(H,_,B,I),
|
|
( H==yes ->
|
|
'$insert_in_store_call_pattern/1'(B)
|
|
;
|
|
true
|
|
),
|
|
G=odom(E,D),
|
|
depends_on_goal(odom([E|F],D),G),
|
|
call_pattern(G),
|
|
( B=suspension(_,mutable(active),_,mutable(I),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__2'(A,B)
|
|
;
|
|
true
|
|
).
|
|
'call_pattern/1__1'(A,B) :-
|
|
'call_pattern/1__2'(A,B).
|
|
'call_pattern/1__2'(A,B) :-
|
|
A=odom(C,D),
|
|
C=builtin,
|
|
!,
|
|
activate_constraint(F,_,B,G),
|
|
( F==yes ->
|
|
'$insert_in_store_call_pattern/1'(B)
|
|
;
|
|
true
|
|
),
|
|
ord_empty(E),
|
|
final_answer_pattern(odom(builtin,D),odom([],E)),
|
|
( B=suspension(_,mutable(active),_,mutable(G),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__3'(A,B)
|
|
;
|
|
true
|
|
).
|
|
'call_pattern/1__2'(A,B) :-
|
|
'call_pattern/1__3'(A,B).
|
|
'call_pattern/1__3'(A,B) :-
|
|
A=odom(C,D),
|
|
C=occ(E,F),
|
|
'$via1_multi_hash_max_occurrence/2-1'(E,G),
|
|
!,
|
|
'call_pattern/1__3__0'(G,A,B,E,F,D).
|
|
'call_pattern/1__3__0'([],A,B,_,_,_) :-
|
|
'call_pattern/1__4'(A,B).
|
|
'call_pattern/1__3__0'([H|I],A,B,D,E,C) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==D,
|
|
L=t(138,B,H),
|
|
'chr novel_production'(B,L),
|
|
'chr novel_production'(H,L),
|
|
E>G ->
|
|
'chr extend_history'(B,L),
|
|
activate_constraint(J,_,B,K),
|
|
( J==yes ->
|
|
'$insert_in_store_call_pattern/1'(B)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(odom(occ(D,E),C),odom([],C)),
|
|
( B=suspension(_,mutable(active),_,mutable(K),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__3__0'(I,A,B,D,E,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'call_pattern/1__3__0'(I,A,B,D,E,C)
|
|
).
|
|
'call_pattern/1__3'(A,B) :-
|
|
'call_pattern/1__4'(A,B).
|
|
'call_pattern/1__4'(A,B) :-
|
|
A=odom(C,D),
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',E),
|
|
!,
|
|
'call_pattern/1__4__0'(E,A,B,C,D).
|
|
'call_pattern/1__4__0'([],A,B,_,_) :-
|
|
'call_pattern/1__5'(A,B).
|
|
'call_pattern/1__4__0'([F|G],A,B,C,D) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,E),
|
|
K=t(139,B,F),
|
|
'chr novel_production'(B,K),
|
|
'chr novel_production'(F,K),
|
|
memberchk_eq(C,E) ->
|
|
'chr extend_history'(B,K),
|
|
activate_constraint(I,_,B,J),
|
|
( I==yes ->
|
|
'$insert_in_store_call_pattern/1'(B)
|
|
;
|
|
true
|
|
),
|
|
H=odom(occ(C,1),D),
|
|
call_pattern(H),
|
|
depends_on(odom(C,D),H),
|
|
( B=suspension(_,mutable(active),_,mutable(J),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__4__0'(G,A,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'call_pattern/1__4__0'(G,A,B,C,D)
|
|
).
|
|
'call_pattern/1__4'(A,B) :-
|
|
'call_pattern/1__5'(A,B).
|
|
'call_pattern/1__5'(A,B) :-
|
|
A=odom(C,D),
|
|
C=occ(E,F),
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',G),
|
|
!,
|
|
'call_pattern/1__5__0'(G,A,B,E,F,D).
|
|
'call_pattern/1__5__0'([],A,B,_,_,_) :-
|
|
'call_pattern/1__6'(A,B).
|
|
'call_pattern/1__5__0'([G|I],A,B,D,E,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',H) ->
|
|
'call_pattern/1__5__1'(H,F,G,I,A,B,D,E,C)
|
|
;
|
|
'call_pattern/1__5__0'(I,A,B,D,E,C)
|
|
).
|
|
'call_pattern/1__5__1'([],_,_,F,A,B,D,E,C) :-
|
|
'call_pattern/1__5__0'(F,A,B,D,E,C).
|
|
'call_pattern/1__5__1'([K|M],G,A,H,B,C,E,F,D) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
'$via1_multi_hash_occurrence/4-1'(E,L) ->
|
|
'call_pattern/1__5__2'(L,I,J,K,M,G,A,H,B,C,E,F,D)
|
|
;
|
|
'call_pattern/1__5__1'(M,G,A,H,B,C,E,F,D)
|
|
).
|
|
'call_pattern/1__5__2'([],_,_,_,I,F,G,H,A,B,D,E,C) :-
|
|
'call_pattern/1__5__1'(I,F,G,H,A,B,D,E,C).
|
|
'call_pattern/1__5__2'([Q|R],J,K,A,L,H,B,I,C,D,F,G,E) :-
|
|
( Q=suspension(_,mutable(active),_,_,_,_,M,N,O,P),
|
|
M==F,
|
|
N==G,
|
|
O==J,
|
|
G1=t(140,D,B,Q,A),
|
|
'chr novel_production'(D,G1),
|
|
'chr novel_production'(B,G1),
|
|
'chr novel_production'(Q,G1),
|
|
'chr novel_production'(A,G1),
|
|
K=pragma(rule(S,T,_,U),ids(V,_),_,_,_),
|
|
memberchk_eq(P,V) ->
|
|
'chr extend_history'(D,G1),
|
|
activate_constraint(E1,_,D,F1),
|
|
( E1==yes ->
|
|
'$insert_in_store_call_pattern/1'(D)
|
|
;
|
|
true
|
|
),
|
|
select2(P,_,V,S,_,W),
|
|
ai_observation_abstract_constraints(W,H,X),
|
|
ai_observation_observe_list(odom([],E),X,odom([],Y)),
|
|
ai_observation_abstract_constraints(T,H,Z),
|
|
ai_observation_observe_list(odom([],Y),Z,odom([],A1)),
|
|
ai_observation_abstract_goal(U,H,B1),
|
|
call_pattern(odom(B1,A1)),
|
|
C1 is G+1,
|
|
D1=odom(occ(F,C1),E),
|
|
call_pattern(D1),
|
|
depends_on_as(odom(occ(F,G),E),odom(B1,A1),D1),
|
|
( D=suspension(_,mutable(active),_,mutable(F1),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__5__2'(R,J,K,A,L,H,B,I,C,D,F,G,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'call_pattern/1__5__2'(R,J,K,A,L,H,B,I,C,D,F,G,E)
|
|
).
|
|
'call_pattern/1__5'(A,B) :-
|
|
'call_pattern/1__6'(A,B).
|
|
'call_pattern/1__6'(A,B) :-
|
|
A=odom(C,D),
|
|
C=occ(E,F),
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',G),
|
|
!,
|
|
'call_pattern/1__6__0'(G,A,B,E,F,D).
|
|
'call_pattern/1__6__0'([],A,B,_,_,_) :-
|
|
'call_pattern/1__7'(A,B).
|
|
'call_pattern/1__6__0'([G|I],A,B,D,E,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',H) ->
|
|
'call_pattern/1__6__1'(H,F,G,I,A,B,D,E,C)
|
|
;
|
|
'call_pattern/1__6__0'(I,A,B,D,E,C)
|
|
).
|
|
'call_pattern/1__6__1'([],_,_,F,A,B,D,E,C) :-
|
|
'call_pattern/1__6__0'(F,A,B,D,E,C).
|
|
'call_pattern/1__6__1'([K|M],G,A,H,B,C,E,F,D) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
'$via1_multi_hash_occurrence/4-1'(E,L) ->
|
|
'call_pattern/1__6__2'(L,I,J,K,M,G,A,H,B,C,E,F,D)
|
|
;
|
|
'call_pattern/1__6__1'(M,G,A,H,B,C,E,F,D)
|
|
).
|
|
'call_pattern/1__6__2'([],_,_,_,I,F,G,H,A,B,D,E,C) :-
|
|
'call_pattern/1__6__1'(I,F,G,H,A,B,D,E,C).
|
|
'call_pattern/1__6__2'([Q|R],J,K,A,L,H,B,I,C,D,F,G,E) :-
|
|
( Q=suspension(_,mutable(active),_,_,_,_,M,N,O,P),
|
|
M==F,
|
|
N==G,
|
|
O==J,
|
|
I1=t(142,D,B,Q,A),
|
|
'chr novel_production'(D,I1),
|
|
'chr novel_production'(B,I1),
|
|
'chr novel_production'(Q,I1),
|
|
'chr novel_production'(A,I1),
|
|
K=pragma(rule(S,T,_,U),ids(_,V),_,_,_),
|
|
memberchk_eq(P,V) ->
|
|
'chr extend_history'(D,I1),
|
|
activate_constraint(G1,_,D,H1),
|
|
( G1==yes ->
|
|
'$insert_in_store_call_pattern/1'(D)
|
|
;
|
|
true
|
|
),
|
|
select2(P,_,V,T,_,W),
|
|
ai_observation_abstract_constraints(W,H,X),
|
|
ai_observation_observe_list(odom([],E),X,odom([],Y)),
|
|
ai_observation_abstract_constraints(S,H,Z),
|
|
ai_observation_observe_list(odom([],Y),Z,odom([],A1)),
|
|
ord_add_element(A1,F,B1),
|
|
ai_observation_abstract_goal(U,H,C1),
|
|
call_pattern(odom(C1,B1)),
|
|
( ord_memberchk(F,A1) ->
|
|
D1=no
|
|
;
|
|
D1=yes
|
|
),
|
|
E1 is G+1,
|
|
F1=odom(occ(F,E1),E),
|
|
call_pattern(F1),
|
|
depends_on_ap(odom(occ(F,G),E),odom(C1,B1),F1,D1),
|
|
( D=suspension(_,mutable(active),_,mutable(H1),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'call_pattern/1__6__2'(R,J,K,A,L,H,B,I,C,D,F,G,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'call_pattern/1__6__2'(R,J,K,A,L,H,B,I,C,D,F,G,E)
|
|
).
|
|
'call_pattern/1__6'(A,B) :-
|
|
'call_pattern/1__7'(A,B).
|
|
'call_pattern/1__7'(_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_call_pattern/1'(A)
|
|
;
|
|
true
|
|
).
|
|
final_answer_pattern(A,B) :-
|
|
'final_answer_pattern/2__0'(A,B,_).
|
|
'final_answer_pattern/2__0'(A,B,_) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
ai_observation_leq(B,D),
|
|
!.
|
|
'final_answer_pattern/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__0__0'(D,A,B,C).
|
|
'final_answer_pattern/2__0__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__1'(A,B,C).
|
|
'final_answer_pattern/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==A,
|
|
ai_observation_leq(E,B) ->
|
|
remove_constraint_internal(F,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_final_answer_pattern/2'(F)
|
|
;
|
|
true
|
|
),
|
|
'final_answer_pattern/2__0__0'(G,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__0__0'(G,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__0'(A,B,C) :-
|
|
'final_answer_pattern/2__1'(A,B,C).
|
|
'final_answer_pattern/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_initial_call_pattern/1-1'(A,D),
|
|
!,
|
|
allocate_constraint(true,C,final_answer_pattern(A,B),[A,B]),
|
|
'final_answer_pattern/2__1__0'(D,A,B,C).
|
|
'final_answer_pattern/2__1__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__2'(A,B,C).
|
|
'final_answer_pattern/2__1__0'([E|G],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D),
|
|
D==A,
|
|
nb_getval('$chr_store_global_ground_chr_translate:abstract_constraints/1',F) ->
|
|
'final_answer_pattern/2__1__1'(F,E,G,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__1__0'(G,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__1__1'([],_,D,A,B,C) :-
|
|
'final_answer_pattern/2__1__0'(D,A,B,C).
|
|
'final_answer_pattern/2__1__1'([G|H],A,E,B,C,D) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,F),
|
|
K=t(130,A,D,G),
|
|
'chr novel_production'(A,K),
|
|
'chr novel_production'(D,K),
|
|
'chr novel_production'(G,K) ->
|
|
'chr extend_history'(D,K),
|
|
activate_constraint(I,_,D,J),
|
|
( I==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(D)
|
|
;
|
|
true
|
|
),
|
|
ai_observation_schedule_new_calls(F,C),
|
|
( D=suspension(_,mutable(active),_,mutable(J),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__1__1'(H,A,E,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__1__1'(H,A,E,B,C,D)
|
|
).
|
|
'final_answer_pattern/2__1'(A,B,C) :-
|
|
allocate_constraint(true,C,final_answer_pattern(A,B),[A,B]),
|
|
'final_answer_pattern/2__2'(A,B,C).
|
|
'final_answer_pattern/2__2'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on/2-2'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__2__0'(D,A,B,C).
|
|
'final_answer_pattern/2__2__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__3'(A,B,C).
|
|
'final_answer_pattern/2__2__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
E==A,
|
|
J=t(132,F,C),
|
|
'chr novel_production'(F,J),
|
|
'chr novel_production'(C,J) ->
|
|
'chr extend_history'(C,J),
|
|
activate_constraint(H,_,C,I),
|
|
( H==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(C)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(D,B),
|
|
( C=suspension(_,mutable(active),_,mutable(I),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__2__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__2__0'(G,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__2'(A,B,C) :-
|
|
'final_answer_pattern/2__3'(A,B,C).
|
|
'final_answer_pattern/2__3'(A,B,C) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:depends_on/2',D),
|
|
!,
|
|
'final_answer_pattern/2__3__0'(D,A,B,C).
|
|
'final_answer_pattern/2__3__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__4'(A,B,C).
|
|
'final_answer_pattern/2__3__0'([E|F],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D,_),
|
|
'$via1_multi_hash_depends_on_goal/2-1'(D,I),
|
|
'chr sbag_member'(G,I),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,H),
|
|
H==A ->
|
|
remove_constraint_internal(E,_,J),
|
|
( J==yes ->
|
|
'$delete_from_store_depends_on/2'(E)
|
|
;
|
|
true
|
|
),
|
|
'final_answer_pattern/2__3__0'(F,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__3__0'(F,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__3'(A,B,C) :-
|
|
'final_answer_pattern/2__4'(A,B,C).
|
|
'final_answer_pattern/2__4'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on_goal/2-2'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__4__0'(D,A,B,C).
|
|
'final_answer_pattern/2__4__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__5'(A,B,C).
|
|
'final_answer_pattern/2__4__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
E==A,
|
|
M=t(136,F,C),
|
|
'chr novel_production'(F,M),
|
|
'chr novel_production'(C,M) ->
|
|
'chr extend_history'(C,M),
|
|
activate_constraint(K,_,C,L),
|
|
( K==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(C)
|
|
;
|
|
true
|
|
),
|
|
D=odom([_|H],_),
|
|
B=odom([],I),
|
|
J=odom(H,I),
|
|
call_pattern(J),
|
|
depends_on(D,J),
|
|
( C=suspension(_,mutable(active),_,mutable(L),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__4__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__4__0'(G,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__4'(A,B,C) :-
|
|
'final_answer_pattern/2__5'(A,B,C).
|
|
'final_answer_pattern/2__5'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on_as/3-2'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__5__0'(D,A,B,C).
|
|
'final_answer_pattern/2__5__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__6'(A,B,C).
|
|
'final_answer_pattern/2__5__0'([G|I],A,B,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,D,E,F),
|
|
E==A,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(F,H) ->
|
|
'final_answer_pattern/2__5__1'(H,D,F,G,I,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__5__0'(I,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__5__1'([],_,_,_,D,A,B,C) :-
|
|
'final_answer_pattern/2__5__0'(D,A,B,C).
|
|
'final_answer_pattern/2__5__1'([J|K],E,F,A,G,B,C,D) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,H,I),
|
|
H==F,
|
|
O=t(141,A,D,J),
|
|
'chr novel_production'(A,O),
|
|
'chr novel_production'(D,O),
|
|
'chr novel_production'(J,O) ->
|
|
'chr extend_history'(D,O),
|
|
activate_constraint(M,_,D,N),
|
|
( M==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(D)
|
|
;
|
|
true
|
|
),
|
|
ai_observation_lub(C,I,L),
|
|
final_answer_pattern(E,L),
|
|
( D=suspension(_,mutable(active),_,mutable(N),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__5__1'(K,E,F,A,G,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__5__1'(K,E,F,A,G,B,C,D)
|
|
).
|
|
'final_answer_pattern/2__5'(A,B,C) :-
|
|
'final_answer_pattern/2__6'(A,B,C).
|
|
'final_answer_pattern/2__6'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on_as/3-3'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__6__0'(D,A,B,C).
|
|
'final_answer_pattern/2__6__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__7'(A,B,C).
|
|
'final_answer_pattern/2__6__0'([G|I],A,B,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,D,E,F),
|
|
F==A,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(E,H) ->
|
|
'final_answer_pattern/2__6__1'(H,D,E,G,I,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__6__0'(I,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__6__1'([],_,_,_,D,A,B,C) :-
|
|
'final_answer_pattern/2__6__0'(D,A,B,C).
|
|
'final_answer_pattern/2__6__1'([J|K],E,F,A,G,B,C,D) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,H,I),
|
|
H==F,
|
|
O=t(141,A,J,D),
|
|
'chr novel_production'(A,O),
|
|
'chr novel_production'(J,O),
|
|
'chr novel_production'(D,O) ->
|
|
'chr extend_history'(D,O),
|
|
activate_constraint(M,_,D,N),
|
|
( M==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(D)
|
|
;
|
|
true
|
|
),
|
|
ai_observation_lub(I,C,L),
|
|
final_answer_pattern(E,L),
|
|
( D=suspension(_,mutable(active),_,mutable(N),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__6__1'(K,E,F,A,G,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__6__1'(K,E,F,A,G,B,C,D)
|
|
).
|
|
'final_answer_pattern/2__6'(A,B,C) :-
|
|
'final_answer_pattern/2__7'(A,B,C).
|
|
'final_answer_pattern/2__7'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on_ap/4-3'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__7__0'(D,A,B,C).
|
|
'final_answer_pattern/2__7__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__8'(A,B,C).
|
|
'final_answer_pattern/2__7__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,_,E,_),
|
|
E==A,
|
|
J=t(143,F,C),
|
|
'chr novel_production'(F,J),
|
|
'chr novel_production'(C,J) ->
|
|
'chr extend_history'(C,J),
|
|
activate_constraint(H,_,C,I),
|
|
( H==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(C)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(D,B),
|
|
( C=suspension(_,mutable(active),_,mutable(I),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__7__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__7__0'(G,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__7'(A,B,C) :-
|
|
'final_answer_pattern/2__8'(A,B,C).
|
|
'final_answer_pattern/2__8'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on_ap/4-2'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__8__0'(D,A,B,C).
|
|
'final_answer_pattern/2__8__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__9'(A,B,C).
|
|
'final_answer_pattern/2__8__0'([H|J],A,B,C) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,D,E,F,G),
|
|
E==A,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(F,I) ->
|
|
'final_answer_pattern/2__8__1'(I,D,F,G,H,J,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__8__0'(J,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__8__1'([],_,_,_,_,D,A,B,C) :-
|
|
'final_answer_pattern/2__8__0'(D,A,B,C).
|
|
'final_answer_pattern/2__8__1'([K|L],E,F,G,A,H,B,C,D) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==F,
|
|
U=t(144,A,D,K),
|
|
'chr novel_production'(A,U),
|
|
'chr novel_production'(D,U),
|
|
'chr novel_production'(K,U) ->
|
|
'chr extend_history'(D,U),
|
|
activate_constraint(S,_,D,T),
|
|
( S==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(D)
|
|
;
|
|
true
|
|
),
|
|
E=odom(occ(M,N),_),
|
|
( ai_observation_is_observed(C,M) ->
|
|
ai_observed(M,N)
|
|
;
|
|
ai_not_observed(M,N)
|
|
),
|
|
( G==yes ->
|
|
C=odom([],O),
|
|
ord_del_element(O,M,P),
|
|
Q=odom([],P)
|
|
;
|
|
Q=C
|
|
),
|
|
ai_observation_lub(Q,J,R),
|
|
final_answer_pattern(E,R),
|
|
( D=suspension(_,mutable(active),_,mutable(T),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__8__1'(L,E,F,G,A,H,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__8__1'(L,E,F,G,A,H,B,C,D)
|
|
).
|
|
'final_answer_pattern/2__8'(A,B,C) :-
|
|
'final_answer_pattern/2__9'(A,B,C).
|
|
'final_answer_pattern/2__9'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on_ap/4-3'(A,D),
|
|
!,
|
|
'final_answer_pattern/2__9__0'(D,A,B,C).
|
|
'final_answer_pattern/2__9__0'([],A,B,C) :-
|
|
'final_answer_pattern/2__10'(A,B,C).
|
|
'final_answer_pattern/2__9__0'([H|J],A,B,C) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,D,E,F,G),
|
|
F==A,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(E,I) ->
|
|
'final_answer_pattern/2__9__1'(I,D,E,G,H,J,A,B,C)
|
|
;
|
|
'final_answer_pattern/2__9__0'(J,A,B,C)
|
|
).
|
|
'final_answer_pattern/2__9__1'([],_,_,_,_,D,A,B,C) :-
|
|
'final_answer_pattern/2__9__0'(D,A,B,C).
|
|
'final_answer_pattern/2__9__1'([K|L],E,F,G,A,H,B,C,D) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
I==F,
|
|
U=t(144,A,K,D),
|
|
'chr novel_production'(A,U),
|
|
'chr novel_production'(K,U),
|
|
'chr novel_production'(D,U) ->
|
|
'chr extend_history'(D,U),
|
|
activate_constraint(S,_,D,T),
|
|
( S==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(D)
|
|
;
|
|
true
|
|
),
|
|
E=odom(occ(M,N),_),
|
|
( ai_observation_is_observed(J,M) ->
|
|
ai_observed(M,N)
|
|
;
|
|
ai_not_observed(M,N)
|
|
),
|
|
( G==yes ->
|
|
J=odom([],O),
|
|
ord_del_element(O,M,P),
|
|
Q=odom([],P)
|
|
;
|
|
Q=J
|
|
),
|
|
ai_observation_lub(Q,C,R),
|
|
final_answer_pattern(E,R),
|
|
( D=suspension(_,mutable(active),_,mutable(T),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'final_answer_pattern/2__9__1'(L,E,F,G,A,H,B,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'final_answer_pattern/2__9__1'(L,E,F,G,A,H,B,C,D)
|
|
).
|
|
'final_answer_pattern/2__9'(A,B,C) :-
|
|
'final_answer_pattern/2__10'(A,B,C).
|
|
'final_answer_pattern/2__10'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_final_answer_pattern/2'(A)
|
|
;
|
|
true
|
|
).
|
|
abstract_constraints(A) :-
|
|
'abstract_constraints/1__0'(A,_).
|
|
'abstract_constraints/1__0'(A,B) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:initial_call_pattern/1',C),
|
|
!,
|
|
allocate_constraint(true,B,abstract_constraints(A),[A]),
|
|
'abstract_constraints/1__0__0'(C,A,B).
|
|
'abstract_constraints/1__0__0'([],A,B) :-
|
|
'abstract_constraints/1__1'(A,B).
|
|
'abstract_constraints/1__0__0'([D|F],A,B) :-
|
|
( D=suspension(_,mutable(active),_,_,_,_,C),
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(C,E) ->
|
|
'abstract_constraints/1__0__1'(E,C,D,F,A,B)
|
|
;
|
|
'abstract_constraints/1__0__0'(F,A,B)
|
|
).
|
|
'abstract_constraints/1__0__1'([],_,_,C,A,B) :-
|
|
'abstract_constraints/1__0__0'(C,A,B).
|
|
'abstract_constraints/1__0__1'([H|I],D,A,E,B,C) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==D,
|
|
L=t(130,A,H,C),
|
|
'chr novel_production'(A,L),
|
|
'chr novel_production'(H,L),
|
|
'chr novel_production'(C,L) ->
|
|
'chr extend_history'(C,L),
|
|
activate_constraint(J,_,C,K),
|
|
( J==yes ->
|
|
'$insert_in_store_abstract_constraints/1'(C)
|
|
;
|
|
true
|
|
),
|
|
ai_observation_schedule_new_calls(B,G),
|
|
( C=suspension(_,mutable(active),_,mutable(K),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'abstract_constraints/1__0__1'(I,D,A,E,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'abstract_constraints/1__0__1'(I,D,A,E,B,C)
|
|
).
|
|
'abstract_constraints/1__0'(A,B) :-
|
|
allocate_constraint(true,B,abstract_constraints(A),[A]),
|
|
'abstract_constraints/1__1'(A,B).
|
|
'abstract_constraints/1__1'(A,B) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',C),
|
|
!,
|
|
'abstract_constraints/1__1__0'(C,A,B).
|
|
'abstract_constraints/1__1__0'([],A,B) :-
|
|
'abstract_constraints/1__2'(A,B).
|
|
'abstract_constraints/1__1__0'([D|E],A,B) :-
|
|
( D=suspension(_,mutable(active),_,_,_,_,C),
|
|
C=odom(F,G),
|
|
K=t(139,D,B),
|
|
'chr novel_production'(D,K),
|
|
'chr novel_production'(B,K),
|
|
memberchk_eq(F,A) ->
|
|
'chr extend_history'(B,K),
|
|
activate_constraint(I,_,B,J),
|
|
( I==yes ->
|
|
'$insert_in_store_abstract_constraints/1'(B)
|
|
;
|
|
true
|
|
),
|
|
H=odom(occ(F,1),G),
|
|
call_pattern(H),
|
|
depends_on(odom(F,G),H),
|
|
( B=suspension(_,mutable(active),_,mutable(J),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'abstract_constraints/1__1__0'(E,A,B)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'abstract_constraints/1__1__0'(E,A,B)
|
|
).
|
|
'abstract_constraints/1__1'(A,B) :-
|
|
'abstract_constraints/1__2'(A,B).
|
|
'abstract_constraints/1__2'(A,B) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',C),
|
|
!,
|
|
'abstract_constraints/1__2__0'(C,A,B).
|
|
'abstract_constraints/1__2__0'([],A,B) :-
|
|
'abstract_constraints/1__3'(A,B).
|
|
'abstract_constraints/1__2__0'([D|J],A,B) :-
|
|
( D=suspension(_,mutable(active),_,_,_,_,C),
|
|
C=odom(E,F),
|
|
E=occ(G,H),
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',I) ->
|
|
'abstract_constraints/1__2__1'(I,G,H,F,D,J,A,B)
|
|
;
|
|
'abstract_constraints/1__2__0'(J,A,B)
|
|
).
|
|
'abstract_constraints/1__2__1'([],_,_,_,_,C,A,B) :-
|
|
'abstract_constraints/1__2__0'(C,A,B).
|
|
'abstract_constraints/1__2__1'([J|L],E,F,D,A,G,B,C) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,H,I),
|
|
'$via1_multi_hash_occurrence/4-1'(E,K) ->
|
|
'abstract_constraints/1__2__2'(K,H,I,J,L,E,F,D,A,G,B,C)
|
|
;
|
|
'abstract_constraints/1__2__1'(L,E,F,D,A,G,B,C)
|
|
).
|
|
'abstract_constraints/1__2__2'([],_,_,_,H,E,F,D,C,G,A,B) :-
|
|
'abstract_constraints/1__2__1'(H,E,F,D,C,G,A,B).
|
|
'abstract_constraints/1__2__2'([P|Q],I,J,A,K,F,G,E,B,H,C,D) :-
|
|
( P=suspension(_,mutable(active),_,_,_,_,L,M,N,O),
|
|
L==F,
|
|
M==G,
|
|
N==I,
|
|
F1=t(140,B,D,P,A),
|
|
'chr novel_production'(B,F1),
|
|
'chr novel_production'(D,F1),
|
|
'chr novel_production'(P,F1),
|
|
'chr novel_production'(A,F1),
|
|
J=pragma(rule(R,S,_,T),ids(U,_),_,_,_),
|
|
memberchk_eq(O,U) ->
|
|
'chr extend_history'(D,F1),
|
|
activate_constraint(D1,_,D,E1),
|
|
( D1==yes ->
|
|
'$insert_in_store_abstract_constraints/1'(D)
|
|
;
|
|
true
|
|
),
|
|
select2(O,_,U,R,_,V),
|
|
ai_observation_abstract_constraints(V,C,W),
|
|
ai_observation_observe_list(odom([],E),W,odom([],X)),
|
|
ai_observation_abstract_constraints(S,C,Y),
|
|
ai_observation_observe_list(odom([],X),Y,odom([],Z)),
|
|
ai_observation_abstract_goal(T,C,A1),
|
|
call_pattern(odom(A1,Z)),
|
|
B1 is G+1,
|
|
C1=odom(occ(F,B1),E),
|
|
call_pattern(C1),
|
|
depends_on_as(odom(occ(F,G),E),odom(A1,Z),C1),
|
|
( D=suspension(_,mutable(active),_,mutable(E1),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'abstract_constraints/1__2__2'(Q,I,J,A,K,F,G,E,B,H,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'abstract_constraints/1__2__2'(Q,I,J,A,K,F,G,E,B,H,C,D)
|
|
).
|
|
'abstract_constraints/1__2'(A,B) :-
|
|
'abstract_constraints/1__3'(A,B).
|
|
'abstract_constraints/1__3'(A,B) :-
|
|
nb_getval('$chr_store_global_ground_chr_translate:call_pattern/1',C),
|
|
!,
|
|
'abstract_constraints/1__3__0'(C,A,B).
|
|
'abstract_constraints/1__3__0'([],A,B) :-
|
|
'abstract_constraints/1__4'(A,B).
|
|
'abstract_constraints/1__3__0'([D|J],A,B) :-
|
|
( D=suspension(_,mutable(active),_,_,_,_,C),
|
|
C=odom(E,F),
|
|
E=occ(G,H),
|
|
nb_getval('$chr_store_global_ground_chr_translate:rule/2',I) ->
|
|
'abstract_constraints/1__3__1'(I,G,H,F,D,J,A,B)
|
|
;
|
|
'abstract_constraints/1__3__0'(J,A,B)
|
|
).
|
|
'abstract_constraints/1__3__1'([],_,_,_,_,C,A,B) :-
|
|
'abstract_constraints/1__3__0'(C,A,B).
|
|
'abstract_constraints/1__3__1'([J|L],E,F,D,A,G,B,C) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,H,I),
|
|
'$via1_multi_hash_occurrence/4-1'(E,K) ->
|
|
'abstract_constraints/1__3__2'(K,H,I,J,L,E,F,D,A,G,B,C)
|
|
;
|
|
'abstract_constraints/1__3__1'(L,E,F,D,A,G,B,C)
|
|
).
|
|
'abstract_constraints/1__3__2'([],_,_,_,H,E,F,D,C,G,A,B) :-
|
|
'abstract_constraints/1__3__1'(H,E,F,D,C,G,A,B).
|
|
'abstract_constraints/1__3__2'([P|Q],I,J,A,K,F,G,E,B,H,C,D) :-
|
|
( P=suspension(_,mutable(active),_,_,_,_,L,M,N,O),
|
|
L==F,
|
|
M==G,
|
|
N==I,
|
|
H1=t(142,B,D,P,A),
|
|
'chr novel_production'(B,H1),
|
|
'chr novel_production'(D,H1),
|
|
'chr novel_production'(P,H1),
|
|
'chr novel_production'(A,H1),
|
|
J=pragma(rule(R,S,_,T),ids(_,U),_,_,_),
|
|
memberchk_eq(O,U) ->
|
|
'chr extend_history'(D,H1),
|
|
activate_constraint(F1,_,D,G1),
|
|
( F1==yes ->
|
|
'$insert_in_store_abstract_constraints/1'(D)
|
|
;
|
|
true
|
|
),
|
|
select2(O,_,U,S,_,V),
|
|
ai_observation_abstract_constraints(V,C,W),
|
|
ai_observation_observe_list(odom([],E),W,odom([],X)),
|
|
ai_observation_abstract_constraints(R,C,Y),
|
|
ai_observation_observe_list(odom([],X),Y,odom([],Z)),
|
|
ord_add_element(Z,F,A1),
|
|
ai_observation_abstract_goal(T,C,B1),
|
|
call_pattern(odom(B1,A1)),
|
|
( ord_memberchk(F,Z) ->
|
|
C1=no
|
|
;
|
|
C1=yes
|
|
),
|
|
D1 is G+1,
|
|
E1=odom(occ(F,D1),E),
|
|
call_pattern(E1),
|
|
depends_on_ap(odom(occ(F,G),E),odom(B1,A1),E1,C1),
|
|
( D=suspension(_,mutable(active),_,mutable(G1),_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'abstract_constraints/1__3__2'(Q,I,J,A,K,F,G,E,B,H,C,D)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'abstract_constraints/1__3__2'(Q,I,J,A,K,F,G,E,B,H,C,D)
|
|
).
|
|
'abstract_constraints/1__3'(A,B) :-
|
|
'abstract_constraints/1__4'(A,B).
|
|
'abstract_constraints/1__4'(_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_abstract_constraints/1'(A)
|
|
;
|
|
true
|
|
).
|
|
depends_on(A,B) :-
|
|
'depends_on/2__0'(A,B,_).
|
|
'depends_on/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(B,D),
|
|
!,
|
|
allocate_constraint(true,C,depends_on(A,B),[A,B]),
|
|
'depends_on/2__0__0'(D,A,B,C).
|
|
'depends_on/2__0__0'([],A,B,C) :-
|
|
'depends_on/2__1'(A,B,C).
|
|
'depends_on/2__0__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==B,
|
|
J=t(132,C,F),
|
|
'chr novel_production'(C,J),
|
|
'chr novel_production'(F,J) ->
|
|
'chr extend_history'(C,J),
|
|
activate_constraint(H,_,C,I),
|
|
( H==yes ->
|
|
'$insert_in_store_depends_on/2'(C)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(A,E),
|
|
( C=suspension(_,mutable(active),_,mutable(I),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'depends_on/2__0__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'depends_on/2__0__0'(G,A,B,C)
|
|
).
|
|
'depends_on/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,depends_on(A,B),[A,B]),
|
|
'depends_on/2__1'(A,B,C).
|
|
'depends_on/2__1'(A,_,B) :-
|
|
'$via1_multi_hash_depends_on_goal/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(D,G),
|
|
'chr sbag_member'(F,G),
|
|
F=suspension(_,mutable(active),_,_,_,_,_,_),
|
|
!,
|
|
( var(B) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(B,_,H),
|
|
( H==yes ->
|
|
'$delete_from_store_depends_on/2'(B)
|
|
;
|
|
true
|
|
)
|
|
).
|
|
'depends_on/2__1'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_depends_on/2'(A)
|
|
;
|
|
true
|
|
).
|
|
depends_on_ap(A,B,C,D) :-
|
|
'depends_on_ap/4__0'(A,B,C,D,_).
|
|
'depends_on_ap/4__0'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(C,F),
|
|
!,
|
|
allocate_constraint(true,E,depends_on_ap(A,B,C,D),[A,B,C,D]),
|
|
'depends_on_ap/4__0__0'(F,A,B,C,D,E).
|
|
'depends_on_ap/4__0__0'([],A,B,C,D,E) :-
|
|
'depends_on_ap/4__1'(A,B,C,D,E).
|
|
'depends_on_ap/4__0__0'([H|I],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==C,
|
|
L=t(143,E,H),
|
|
'chr novel_production'(E,L),
|
|
'chr novel_production'(H,L) ->
|
|
'chr extend_history'(E,L),
|
|
activate_constraint(J,_,E,K),
|
|
( J==yes ->
|
|
'$insert_in_store_depends_on_ap/4'(E)
|
|
;
|
|
true
|
|
),
|
|
final_answer_pattern(A,G),
|
|
( E=suspension(_,mutable(active),_,mutable(K),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'depends_on_ap/4__0__0'(I,A,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'depends_on_ap/4__0__0'(I,A,B,C,D,E)
|
|
).
|
|
'depends_on_ap/4__0'(A,B,C,D,E) :-
|
|
allocate_constraint(true,E,depends_on_ap(A,B,C,D),[A,B,C,D]),
|
|
'depends_on_ap/4__1'(A,B,C,D,E).
|
|
'depends_on_ap/4__1'(A,B,C,D,E) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(B,F),
|
|
!,
|
|
'depends_on_ap/4__1__0'(F,A,B,C,D,E).
|
|
'depends_on_ap/4__1__0'([],A,B,C,D,E) :-
|
|
'depends_on_ap/4__2'(A,B,C,D,E).
|
|
'depends_on_ap/4__1__0'([H|J],A,B,C,D,E) :-
|
|
( H=suspension(_,mutable(active),_,_,_,_,F,G),
|
|
F==B,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(C,I) ->
|
|
'depends_on_ap/4__1__1'(I,G,H,J,A,B,C,D,E)
|
|
;
|
|
'depends_on_ap/4__1__0'(J,A,B,C,D,E)
|
|
).
|
|
'depends_on_ap/4__1__1'([],_,_,F,A,B,C,D,E) :-
|
|
'depends_on_ap/4__1__0'(F,A,B,C,D,E).
|
|
'depends_on_ap/4__1__1'([K|L],G,A,H,B,C,D,E,F) :-
|
|
( K=suspension(_,mutable(active),_,_,_,_,I,J),
|
|
K\==A,
|
|
I==D,
|
|
U=t(144,F,A,K),
|
|
'chr novel_production'(F,U),
|
|
'chr novel_production'(A,U),
|
|
'chr novel_production'(K,U) ->
|
|
'chr extend_history'(F,U),
|
|
activate_constraint(S,_,F,T),
|
|
( S==yes ->
|
|
'$insert_in_store_depends_on_ap/4'(F)
|
|
;
|
|
true
|
|
),
|
|
B=odom(occ(M,N),_),
|
|
( ai_observation_is_observed(G,M) ->
|
|
ai_observed(M,N)
|
|
;
|
|
ai_not_observed(M,N)
|
|
),
|
|
( E==yes ->
|
|
G=odom([],O),
|
|
ord_del_element(O,M,P),
|
|
Q=odom([],P)
|
|
;
|
|
Q=G
|
|
),
|
|
ai_observation_lub(Q,J,R),
|
|
final_answer_pattern(B,R),
|
|
( F=suspension(_,mutable(active),_,mutable(T),_,_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'depends_on_ap/4__1__1'(L,G,A,H,B,C,D,E,F)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'depends_on_ap/4__1__1'(L,G,A,H,B,C,D,E,F)
|
|
).
|
|
'depends_on_ap/4__1'(A,B,C,D,E) :-
|
|
'depends_on_ap/4__2'(A,B,C,D,E).
|
|
'depends_on_ap/4__2'(_,_,_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_depends_on_ap/4'(A)
|
|
;
|
|
true
|
|
).
|
|
depends_on_goal(A,B) :-
|
|
'depends_on_goal/2__0'(A,B,_).
|
|
'depends_on_goal/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_depends_on/2-1'(A,D),
|
|
!,
|
|
'depends_on_goal/2__0__0'(D,A,B,C).
|
|
'depends_on_goal/2__0__0'([],A,B,C) :-
|
|
'depends_on_goal/2__1'(A,B,C).
|
|
'depends_on_goal/2__0__0'([E|F],A,B,C) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,D,_),
|
|
D==A,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(B,H),
|
|
'chr sbag_member'(G,H),
|
|
G=suspension(_,mutable(active),_,_,_,_,_,_) ->
|
|
remove_constraint_internal(E,_,I),
|
|
( I==yes ->
|
|
'$delete_from_store_depends_on/2'(E)
|
|
;
|
|
true
|
|
),
|
|
'depends_on_goal/2__0__0'(F,A,B,C)
|
|
;
|
|
'depends_on_goal/2__0__0'(F,A,B,C)
|
|
).
|
|
'depends_on_goal/2__0'(A,B,C) :-
|
|
'depends_on_goal/2__1'(A,B,C).
|
|
'depends_on_goal/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(B,D),
|
|
!,
|
|
allocate_constraint(true,C,depends_on_goal(A,B),[A,B]),
|
|
'depends_on_goal/2__1__0'(D,A,B,C).
|
|
'depends_on_goal/2__1__0'([],A,B,C) :-
|
|
'depends_on_goal/2__2'(A,B,C).
|
|
'depends_on_goal/2__1__0'([F|G],A,B,C) :-
|
|
( F=suspension(_,mutable(active),_,_,_,_,D,E),
|
|
D==B,
|
|
M=t(136,C,F),
|
|
'chr novel_production'(C,M),
|
|
'chr novel_production'(F,M) ->
|
|
'chr extend_history'(C,M),
|
|
activate_constraint(K,_,C,L),
|
|
( K==yes ->
|
|
'$insert_in_store_depends_on_goal/2'(C)
|
|
;
|
|
true
|
|
),
|
|
A=odom([_|H],_),
|
|
E=odom([],I),
|
|
J=odom(H,I),
|
|
call_pattern(J),
|
|
depends_on(A,J),
|
|
( C=suspension(_,mutable(active),_,mutable(L),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'depends_on_goal/2__1__0'(G,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'depends_on_goal/2__1__0'(G,A,B,C)
|
|
).
|
|
'depends_on_goal/2__1'(A,B,C) :-
|
|
allocate_constraint(true,C,depends_on_goal(A,B),[A,B]),
|
|
'depends_on_goal/2__2'(A,B,C).
|
|
'depends_on_goal/2__2'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_depends_on_goal/2'(A)
|
|
;
|
|
true
|
|
).
|
|
ai_observed(A,B) :-
|
|
'$via1_multi_hash_ai_not_observed/2-1'(A,C),
|
|
!,
|
|
'ai_observed/2__0__0'(C,A,B).
|
|
'ai_observed/2__0__0'([],A,B) :-
|
|
'ai_observed/2__1'(A,B).
|
|
'ai_observed/2__0__0'([E|F],A,B) :-
|
|
( E=suspension(_,mutable(active),_,_,_,_,C,D),
|
|
C==A,
|
|
D==B ->
|
|
remove_constraint_internal(E,_,G),
|
|
( G==yes ->
|
|
'$delete_from_store_ai_not_observed/2'(E)
|
|
;
|
|
true
|
|
),
|
|
'ai_observed/2__0__0'(F,A,B)
|
|
;
|
|
'ai_observed/2__0__0'(F,A,B)
|
|
).
|
|
ai_observed(A,B) :-
|
|
'ai_observed/2__1'(A,B).
|
|
'ai_observed/2__1'(A,B) :-
|
|
'$via1_multi_hash_ai_observed/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!.
|
|
'ai_observed/2__1'(A,B) :-
|
|
insert_constraint_internal(_,_,C,true,ai_observed(A,B),[A,B]),
|
|
'$insert_in_store_ai_observed/2'(C).
|
|
ai_not_observed(A,B) :-
|
|
'ai_not_observed/2__0'(A,B,_).
|
|
'ai_not_observed/2__0'(A,B,C) :-
|
|
'$via1_multi_hash_stored/3-1'(A,D),
|
|
!,
|
|
allocate_constraint(true,C,ai_not_observed(A,B),[A,B]),
|
|
'ai_not_observed/2__0__0'(D,A,B,C).
|
|
'ai_not_observed/2__0__0'([],A,B,C) :-
|
|
'ai_not_observed/2__1'(A,B,C).
|
|
'ai_not_observed/2__0__0'([G|H],A,B,C) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,D,E,F),
|
|
D==A,
|
|
E==B,
|
|
F=yes,
|
|
'$via1_multi_hash_stored_complete/3-1'(A,L),
|
|
'chr sbag_member'(I,L),
|
|
I=suspension(_,mutable(active),_,_,_,_,_,J,K),
|
|
B<J ->
|
|
remove_constraint_internal(G,_,M),
|
|
( M==yes ->
|
|
'$delete_from_store_stored/3'(G)
|
|
;
|
|
true
|
|
),
|
|
remove_constraint_internal(I,_,N),
|
|
( N==yes ->
|
|
'$delete_from_store_stored_complete/3'(I)
|
|
;
|
|
true
|
|
),
|
|
activate_constraint(P,_,C,Q),
|
|
( P==yes ->
|
|
'$insert_in_store_ai_not_observed/2'(C)
|
|
;
|
|
true
|
|
),
|
|
O is K-1,
|
|
stored(A,B,maybe),
|
|
stored_complete(A,J,O),
|
|
( C=suspension(_,mutable(active),_,mutable(Q),_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'ai_not_observed/2__0__0'(H,A,B,C)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'ai_not_observed/2__0__0'(H,A,B,C)
|
|
).
|
|
'ai_not_observed/2__0'(A,B,C) :-
|
|
allocate_constraint(true,C,ai_not_observed(A,B),[A,B]),
|
|
'ai_not_observed/2__1'(A,B,C).
|
|
'ai_not_observed/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_ai_observed/2-1'(A,F),
|
|
'chr sbag_member'(D,F),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E),
|
|
E=B,
|
|
!,
|
|
( var(C) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(C,_,G),
|
|
( G==yes ->
|
|
'$delete_from_store_ai_not_observed/2'(C)
|
|
;
|
|
true
|
|
)
|
|
).
|
|
'ai_not_observed/2__1'(A,B,C) :-
|
|
'$via1_multi_hash_ai_not_observed/2-1'(A,F),
|
|
'chr sbag_member'(D,F),
|
|
D=suspension(_,mutable(active),_,_,_,_,_,E),
|
|
E=B,
|
|
!,
|
|
( var(C) ->
|
|
true
|
|
;
|
|
remove_constraint_internal(C,_,G),
|
|
( G==yes ->
|
|
'$delete_from_store_ai_not_observed/2'(C)
|
|
;
|
|
true
|
|
)
|
|
).
|
|
'ai_not_observed/2__1'(_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_ai_not_observed/2'(A)
|
|
;
|
|
true
|
|
).
|
|
ai_is_observed(A,B) :-
|
|
'$via1_multi_hash_ai_not_observed/2-1'(A,E),
|
|
'chr sbag_member'(C,E),
|
|
C=suspension(_,mutable(active),_,_,_,_,_,D),
|
|
D=B,
|
|
!,
|
|
fail.
|
|
ai_is_observed(_,_).
|
|
depends_on_as(A,B,C) :-
|
|
'depends_on_as/3__0'(A,B,C,_).
|
|
'depends_on_as/3__0'(A,B,C,D) :-
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(B,E),
|
|
!,
|
|
allocate_constraint(true,D,depends_on_as(A,B,C),[A,B,C]),
|
|
'depends_on_as/3__0__0'(E,A,B,C,D).
|
|
'depends_on_as/3__0__0'([],A,B,C,D) :-
|
|
'depends_on_as/3__1'(A,B,C,D).
|
|
'depends_on_as/3__0__0'([G|I],A,B,C,D) :-
|
|
( G=suspension(_,mutable(active),_,_,_,_,E,F),
|
|
E==B,
|
|
'$via1_multi_hash_final_answer_pattern/2-1'(C,H) ->
|
|
'depends_on_as/3__0__1'(H,F,G,I,A,B,C,D)
|
|
;
|
|
'depends_on_as/3__0__0'(I,A,B,C,D)
|
|
).
|
|
'depends_on_as/3__0__1'([],_,_,E,A,B,C,D) :-
|
|
'depends_on_as/3__0__0'(E,A,B,C,D).
|
|
'depends_on_as/3__0__1'([J|K],F,A,G,B,C,D,E) :-
|
|
( J=suspension(_,mutable(active),_,_,_,_,H,I),
|
|
J\==A,
|
|
H==D,
|
|
O=t(141,E,A,J),
|
|
'chr novel_production'(E,O),
|
|
'chr novel_production'(A,O),
|
|
'chr novel_production'(J,O) ->
|
|
'chr extend_history'(E,O),
|
|
activate_constraint(M,_,E,N),
|
|
( M==yes ->
|
|
'$insert_in_store_depends_on_as/3'(E)
|
|
;
|
|
true
|
|
),
|
|
ai_observation_lub(F,I,L),
|
|
final_answer_pattern(B,L),
|
|
( E=suspension(_,mutable(active),_,mutable(N),_,_,_,_,_) ->
|
|
'chr update_mutable'(inactive,mutable(active)),
|
|
'depends_on_as/3__0__1'(K,F,A,G,B,C,D,E)
|
|
;
|
|
true
|
|
)
|
|
;
|
|
'depends_on_as/3__0__1'(K,F,A,G,B,C,D,E)
|
|
).
|
|
'depends_on_as/3__0'(A,B,C,D) :-
|
|
allocate_constraint(true,D,depends_on_as(A,B,C),[A,B,C]),
|
|
'depends_on_as/3__1'(A,B,C,D).
|
|
'depends_on_as/3__1'(_,_,_,A) :-
|
|
activate_constraint(B,_,A,_),
|
|
( B==yes ->
|
|
'$insert_in_store_depends_on_as/3'(A)
|
|
;
|
|
true
|
|
).
|