This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/LGPL/chr/chr_translate.pl
2008-03-27 00:41:33 +00:00

21473 lines
638 KiB
Prolog

/* Generated by CHR bootstrap compiler
From: chr_translate.chr
Date: Wed Mar 26 03:32:05 2008
DO NOT EDIT. EDIT THE CHR FILE INSTEAD
*/
:-module(chr_translate,[chr_translate/2,chr_translate_line_info/3]).
:-use_module(chr_runtime).
:-style_check(-discontiguous).
:-use_module(library(lists),[member/2,append/3,reverse/2,permutation/2,last/2]).
:-use_module(library(ordsets)).
:-use_module(library(aggregate)).
:-use_module(library(apply_macros)).
:-use_module(library(occurs)).
:-use_module(library(assoc)).
:-use_module(hprolog).
:-use_module(pairlist).
:-use_module(a_star).
:-use_module(listmap).
:-use_module(clean_code).
:-use_module(builtins).
:-use_module(find).
:-use_module(binomialheap).
:-use_module(guard_entailment).
:-use_module(chr_compiler_options).
:-use_module(chr_compiler_utility).
:-use_module(chr_compiler_errors).
:-include(chr_op).
:-op(1150,fx,chr_type).
:-op(1150,fx,chr_declaration).
:-op(1130,xfx,--->).
:-op(980,fx,+).
:-op(980,fx,-).
:-op(980,fx,?).
:-op(1150,fx,constraints).
:-op(1150,fx,chr_constraint).
format_storetype(multi_store(A)) :-
!,
maplist(format_storetype,A).
format_storetype(atomic_constants(A,B,_)) :-
format(' * a trie index on the argument(s) ~w for the ground terms ~w
',[A,B]).
format_storetype(ground_constants(A,B,_)) :-
format(' * a trie index on the argument(s) ~w for the ground terms ~w
',[A,B]).
format_storetype(A) :-
format(' * ~w
',[A]).
get_constraint_arg_type(A,B,C) :-
get_constraint_type(A,D),
nth1(B,D,E),
unalias_type(E,C).
partial_store(ground_constants(_,_,incomplete)).
partial_store(atomic_constants(_,_,incomplete)).
late_allocation_analysis(A) :-
( chr_pp_flag(late_allocation,on) ->
maplist(late_allocation,A)
;
true
).
late_allocation(A) :-
late_allocation(A,0).
late_allocation(A,B) :-
allocation_occurrence(A,B),
!.
late_allocation(A,B) :-
C is B+1,
late_allocation(A,C).
stored_in_guard_before_next_kept_occurrence(A,B) :-
chr_pp_flag(store_in_guards,on),
C is B+1,
stored_in_guard_lookahead(A,C).
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)
;
\+only_ground_indexed_arguments(A),
is_stored(A)
;
is_stored(A),
get_store_type(A,default)
;
get_store_type(A,var_assoc_store(_,_))
) ->
constraint_index(A,C),
D is C+1,
set_constraint_indices(B,D)
;
set_constraint_indices(B,C)
).
type_indexed_identifier_structure(A,B) :-
type_indexed_identifier_name(A,type_indexed_identifier_struct,C),
get_type_indexed_identifier_size(A,D),
functor(B,C,D).
type_indexed_identifier_name(A,B,C) :-
( atom(A) ->
D=A
;
term_to_atom(A,D)
),
atom_concat_list([B,'_',D],C).
chr_translate(A,B) :-
chr_translate_line_info(A,bootstrap,B).
chr_translate_line_info(A,B,C) :-
chr_banner,
restart_after_flattening(A,D),
init_chr_pp_flags,
chr_source_file(B),
partition_clauses(D,E,F,G),
chr_compiler_options:sanity_check,
dump_code(D),
check_declared_constraints(E),
generate_show_constraint(E,H,F,I),
add_constraints(H),
add_rules(I),
generate_never_stored_rules(H,J),
add_rules(J),
append(I,J,K),
chr_analysis(K,H,D),
time('constraint code generation',chr_translate:constraints_code(H,L)),
time('validate store assumptions',chr_translate:validate_store_type_assumptions(H)),
phase_end(validate_store_type_assumptions),
used_states_known,
time('store code generation',chr_translate:store_management_preds(H,M)),
insert_declarations(G,N),
chr_module_declaration(O),
append([M,L,O,[end_of_file]],P),
clean_clauses(P,Q),
append([N,Q],C),
dump_code(C),
!.
chr_analysis(A,B,C) :-
check_rules(A,B),
time('type checking',chr_translate:static_type_check),
collect_constants(A,B,C),
add_occurrences(A),
time('functional dependency',chr_translate:functional_dependency_analysis(A)),
time('set semantics',chr_translate:set_semantics_rules(A)),
time('symmetry analysis',chr_translate:symmetry_analysis(A)),
time('guard simplification',chr_translate:guard_simplification),
time('late storage',chr_translate:storage_analysis(B)),
time(observation,chr_translate:observation_analysis(B)),
time('ai observation',chr_translate:ai_observation_analysis(B)),
time('late allocation',chr_translate:late_allocation_analysis(B)),
partial_wake_analysis,
time('assume constraint stores',chr_translate:assume_constraint_stores(B)),
time('default constraint indices',chr_translate:set_constraint_indices(B)),
time('check storedness assertions',chr_translate:check_storedness_assertions(B)),
time('continuation analysis',chr_translate:continuation_analysis(B)).
store_management_preds(A,B) :-
generate_attach_detach_a_constraint_all(A,C),
generate_attr_unify_hook(D),
generate_attach_increment(E),
generate_extra_clauses(A,F),
generate_insert_delete_constraints(A,G),
generate_attach_code(A,H),
generate_counter_code(I),
generate_dynamic_type_check_clauses(J),
append([C,E,D,F,G,H,I,J],B).
insert_declarations(A,B) :-
findall((:-use_module(chr(C))),(auxiliary_module(C),is_used_auxiliary_module(C)),D),
append(A,[(:-use_module(chr(chr_runtime)))|D],B).
auxiliary_module(chr_hashtable_store).
auxiliary_module(chr_integertable_store).
auxiliary_module(chr_assoc_store).
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,
chr_pp_flag(toplevel_show_store,on) ->
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
)
;
( is_chr_declaration(A) ->
C=G,
D=H,
E=I
)
;
( A=(handler _) ->
chr_warning(deprecated(A),'Backward compatibility: ignoring handler/1 declaration.
',[]),
C=G,
D=H,
E=I
)
;
( A=(rules _) ->
chr_warning(deprecated(A),'Backward compatibility: ignoring rules/1 declaration.
',[]),
C=G,
D=H,
E=I
)
;
( A=option(L,M) ->
chr_warning(deprecated(A),'Instead use `:-chr_option(~w,~w).''
',[L,M]),
handle_option(L,M),
C=G,
D=H,
E=I
)
;
( A=(:-chr_option(L,M)) ->
handle_option(L,M),
C=G,
D=H,
E=I
)
;
( A='$chr_compiled_with_version'(_) ->
C=G,
D=H,
E=['$chr_compiled_with_version'(3)|I]
)
;
C=G,
D=H,
E=[A|I]
),
partition_clauses(B,G,H,I).
'$chr_compiled_with_version'(3).
is_declaration(A,B) :-
( A=(:-C),
C=..[D,E],
D==chr_constraint ->
conj2list(E,F)
;
( A=(:-C) ->
C=..[constraints,E]
;
A=..[constraints,E]
),
conj2list(E,F),
chr_warning(deprecated(A),'Instead use :- chr_constraint ~w.
',[E])
),
extract_type_mode(F,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]) :-
( A=E#F ->
functor(E,G,H),
extract_annotation(F,G/H)
;
A=E,
functor(E,G,H)
),
C=G/H,
E=..[_|I],
extract_types_and_modes(I,J,K),
assert_constraint_type(C,J),
constraint_mode(C,K),
extract_type_mode(B,D).
extract_annotation(stored,A) :-
stored_assertion(A).
extract_annotation(default(A),B) :-
never_stored_default(B,A).
extract_types_and_modes([],[],[]).
extract_types_and_modes([A|B],[C|D],[E|F]) :-
extract_type_and_mode(A,C,E),
extract_types_and_modes(B,D,F).
extract_type_and_mode(+A,A,+) :-
!.
extract_type_and_mode(?A,A,?) :-
!.
extract_type_and_mode(-A,A,-) :-
!.
extract_type_and_mode(+,any,+) :-
!.
extract_type_and_mode(?,any,?) :-
!.
extract_type_and_mode(-,any,-) :-
!.
extract_type_and_mode(A,_,_) :-
chr_error(syntax(A),'Illegal mode/type declaration.
Correct syntax is +type, -type or ?type
or +, - or ?.
',[]).
is_chr_declaration(A) :-
A=(:-chr_declaration B),
( B=(C--->D) ->
background_info(C,D)
;
( B=D ->
background_info([D])
)
).
is_type_definition(A) :-
is_type_definition(A,B),
assert_type_definition(B).
assert_type_definition(typedef(A,B)) :-
type_definition(A,B).
assert_type_definition(alias(A,B)) :-
type_alias(A,B).
is_type_definition(A,B) :-
( A=(:-C) ->
true
;
A=C
),
C=..[chr_type,D],
( D=(E--->F) ->
tdisj2list(F,G),
B=typedef(E,G)
;
( D=(H==E) ->
B=alias(H,E)
)
;
B=typedef(D,[]),
chr_warning(syntax,'Empty type definition `~w''.
Are you sure you want to declare a phantom type?
',[A])
).
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),
!,
( var(E) ->
F=[_]
;
conj2list(E,F)
),
inc_rule_count(G),
C=pragma(H,I,F,B,G),
is_rule(D,H,I,C).
rule(A,B,C) :-
inc_rule_count(D),
C=pragma(E,F,[],B,D),
is_rule(A,E,F,C).
is_rule(A,B,C,D) :-
A=(E==>F),
!,
conj2list(E,G),
get_ids(G,H,I,D),
C=ids([],H),
( F=(J '|' K) ->
B=rule([],I,J,K)
;
B=rule([],I,true,F)
).
is_rule(A,B,C,D) :-
A=(E<=>F),
!,
( F=(G '|' H) ->
I=G,
J=H
;
I=true,
J=F
),
( E=(K\L) ->
conj2list(K,M),
conj2list(L,N),
get_ids(M,O,P,0,Q,D),
get_ids(N,R,S,Q,_,D),
C=ids(R,O)
;
conj2list(E,N),
P=[],
get_ids(N,R,S,D),
C=ids(R,[])
),
B=rule(S,P,I,J).
get_ids(A,B,C,D) :-
get_ids(A,B,C,0,_,D).
get_ids([],[],[],A,A,_).
get_ids([A|B],[C|D],[E|F],C,G,H) :-
( A=E#I ->
( var(I) ->
I=C
;
check_direct_pragma(I,C,H)
)
;
E=A
),
J is C+1,
get_ids(B,D,F,J,G,H).
check_direct_pragma(passive,A,B) :-
!,
B=pragma(_,_,_,_,C),
passive(C,A).
check_direct_pragma(A,_,B) :-
( direct_pragma(C),
atom_concat(A,_,C) ->
chr_warning(problem_pragma(A,B),'completed `~w'' to `~w''
',[A,C])
;
chr_warning(unsupported_pragma(A,B),'',[])
).
direct_pragma(passive).
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) :-
tree_set_empty(B),
check_declared_constraints(A,B).
check_declared_constraints([],_).
check_declared_constraints([A|B],C) :-
( tree_set_memberchk(A,C) ->
chr_error(syntax(A),'Constraint multiply defined: ~w.
Remove redundant declaration!
',[A])
;
true
),
tree_set_add(C,A,D),
check_declared_constraints(B,D).
check_rules([],_).
check_rules([A|B],C) :-
check_rule(A,C),
check_rules(B,C).
check_rule(A,B) :-
check_rule_indexing(A),
check_trivial_propagation_rule(A),
A=pragma(C,_,D,_,_),
C=rule(E,F,_,_),
append(E,F,G),
check_head_constraints(G,B,A),
check_pragmas(D,A).
check_trivial_propagation_rule(A) :-
A=pragma(B,_,_,_,C),
( B=rule([],_,_,true) ->
chr_warning(weird_program,'Ignoring propagation rule with empty body: ~@.
',[format_rule(A)]),
set_all_passive(C)
;
true
).
check_head_constraints([],_,_).
check_head_constraints([A|B],C,D) :-
functor(A,E,F),
( memberchk(E/F,C) ->
check_head_constraints(B,C,D)
;
chr_error(syntax(A),'Undeclared constraint ~w in head of ~@.
Constraint should be one of ~w.
',[E/F,format_rule(D),C])
).
check_pragmas([],_).
check_pragmas([A|B],C) :-
check_pragma(A,C),
check_pragmas(B,C).
check_pragma(A,B) :-
var(A),
!,
chr_error(syntax(A),'Invalid pragma ~w in ~@.
Pragma should not be a variable!
',[A,format_rule(B)]).
check_pragma(passive(A),B) :-
!,
B=pragma(_,ids(C,D),_,_,E),
( memberchk_eq(A,C) ->
true
;
( memberchk_eq(A,D) ->
true
)
;
chr_error(syntax(A),'Invalid identifier ~w in pragma passive in ~@.
',[A,format_rule(B)])
),
passive(E,A).
check_pragma(mpassive(A),B) :-
!,
B=pragma(_,_,_,_,C),
chr_warning(experimental,'Experimental pragma ~w. Use with care!
',[mpassive(A)]),
maplist(passive(C),A).
check_pragma(A,B) :-
A=already_in_heads,
!,
chr_warning(unsupported_pragma(A,B),'Termination and correctness may be affected.
',[]).
check_pragma(A,B) :-
A=already_in_head(_),
!,
chr_warning(unsupported_pragma(A,B),'Termination and correctness may be affected.
',[]).
check_pragma(A,B) :-
A=no_history,
!,
chr_warning(experimental,'Experimental pragma no_history. Use with care!
',[]),
B=pragma(_,_,_,_,C),
no_history(C).
check_pragma(A,B) :-
A=history(C,D),
!,
B=pragma(_,ids(E,F),_,_,G),
chr_warning(experimental,'Experimental pragma ~w. Use with care!
',[A]),
( E\==[] ->
chr_error(syntax(A),'Pragma history only implemented for propagation rules.
',[])
;
( \+atom(C) ->
chr_error(syntax(A),'Illegal argument for pragma history: ~w is not an atom (rule number ~w).
',[C,G])
)
;
( \+is_set(D) ->
chr_error(syntax(A),'Illegal argument for pragma history: ~w is not a set (rule number ~w).
',[D,G])
)
;
( check_history_pragma_ids(D,E,F) ->
history(G,C,D)
)
;
chr_error(syntax(A),'Invalid identifier(s) in pragma ~w of rule number ~w.
',[A,G])
).
check_pragma(A,B) :-
A=line_number(C),
!,
B=pragma(_,_,_,_,D),
line_number(D,C).
check_history_pragma_ids([],_,_).
check_history_pragma_ids([A|B],C,D) :-
(
memberchk_eq(A,D)
;
memberchk_eq(A,C)
),
check_history_pragma_ids(B,C,D).
check_pragma(A,B) :-
chr_error(syntax(A),'Unknown pragma ~w in ~@.
',[A,format_rule(B)]).
test_named_history_id_pairs(_,[],_,[]).
test_named_history_id_pairs(A,[B|C],D,[E|F]) :-
test_named_history_id_pair(A,B,D,E),
test_named_history_id_pairs(A,C,D,F).
format_rule(A) :-
A=pragma(_,_,_,B,C),
( B=yes(D) ->
write('rule '),
write(D)
;
write('rule number '),
write(C)
),
get_line_number(C,E),
write(' (line '),
write(E),
write(')').
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),
( chr_pp_flag(term_indexing,on) ->
term_variables(G,H),
append(C,D,I),
check_specs_indexing(I,H,_)
;
true
).
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).
check_specs_indexing([],_,[]).
check_specs_indexing([A|B],C,D) :-
D=[E|F],
term_variables(B,G,C),
check_spec_indexing(A,G,E),
term_variables(A,H,C),
check_specs_indexing(B,H,F).
check_spec_indexing(A,B,C) :-
functor(A,D,E),
C=spec(D,E,F),
A=..[_|G],
check_args_spec_indexing(G,1,B,F),
indexing_spec(D/E,[F]).
check_args_spec_indexing([],_,_,[]).
check_args_spec_indexing([A|B],C,D,E) :-
term_variables(B,F,D),
( check_arg_spec_indexing(A,C,F,G) ->
E=[G|H]
;
E=H
),
I is C+1,
term_variables(A,J,D),
check_args_spec_indexing(B,I,J,H).
check_arg_spec_indexing(A,B,C,D) :-
( var(A) ->
memberchk_eq(A,C),
D=specinfo(B,any,[])
;
functor(A,E,F),
D=specinfo(B,E/F,[G]),
A=..[_|H],
check_args_spec_indexing(H,1,C,G)
).
add_occurrences([]).
add_occurrences([A|B]) :-
A=pragma(rule(C,D,_,_),ids(E,F),_,_,G),
add_occurrences(C,E,simplification,G),
add_occurrences(D,F,propagation,G),
add_occurrences(B).
add_occurrences([],[],_,_).
add_occurrences([A|B],[C|D],E,F) :-
functor(A,G,H),
I=G/H,
new_occurrence(I,F,C,E),
add_occurrences(B,D,E,F).
observation_analysis(A,B,C,D) :-
( all_spawned(A,C) ->
true
;
( var(B) ->
spawns_all(A,C)
)
;
( B=true ->
true
)
;
( B=fail ->
true
)
;
( B=! ->
true
)
;
( B=(E,F) ->
observation_analysis(A,E,C,D),
observation_analysis(A,F,C,D)
)
;
( B=(E;F) ->
observation_analysis(A,E,C,D),
observation_analysis(A,F,C,D)
)
;
( B=(E->F) ->
observation_analysis(A,E,C,D),
observation_analysis(A,F,C,D)
)
;
( B=(\+G) ->
observation_analysis(A,G,C,D)
)
;
( functor(B,H,I),
memberchk(H/I,D) ->
spawns(A,C,H/I)
)
;
( B=(_=_) ->
spawns_all_triggers(A,C)
)
;
( B=(_ is _) ->
spawns_all_triggers(A,C)
)
;
( builtin_binds_b(B,J) ->
( J==[] ->
true
;
spawns_all_triggers(A,C)
)
)
;
spawns_all(A,C)
).
is_observed(A,B) :-
is_observed(A,B,_),
ai_is_observed(A,B).
is_stored_in_guard(A,B) :-
chr_pp_flag(store_in_guards,on),
do_is_observed(A,B,guard).
generate_attach_detach_a_constraint_all([],[]).
generate_attach_detach_a_constraint_all([A|B],C) :-
(
(
chr_pp_flag(debugable,on)
;
is_stored(A),
\+only_ground_indexed_arguments(A),
\+get_store_type(A,var_assoc_store(_,_))
) ->
generate_attach_a_constraint(A,D),
generate_detach_a_constraint(A,E)
;
D=[],
E=[]
),
generate_attach_detach_a_constraint_all(B,F),
append([D,E,F],C).
generate_attach_a_constraint(A,[B,C]) :-
generate_attach_a_constraint_nil(A,B),
generate_attach_a_constraint_cons(A,C).
attach_constraint_atom(A,B,C,D) :-
make_name(attach_,A,E),
D=..[E,B,C].
generate_attach_a_constraint_nil(A,B) :-
B=(C:-true),
attach_constraint_atom(A,[],_,C).
generate_attach_a_constraint_cons(A,B) :-
B=(C:-D),
attach_constraint_atom(A,[E|F],G,C),
attach_constraint_atom(A,F,G,H),
D=(I,J,H),
get_max_constraint_index(K),
( K==1 ->
generate_attach_body_1(A,E,G,I)
;
generate_attach_body_n(A,E,G,I)
),
chr_pp_flag(solver_events,L),
( L\==none ->
_=[[E|_],G],
get_target_module(M),
use_auxiliary_predicate(run_suspensions),
J=clp_events:subscribe(E,L,M,M:'$run_suspensions'([G]))
;
J=true
).
generate_attach_body_1(_,A,B,C) :-
get_target_module(D),
C=(get_attr(A,D,E)->put_attr(A,D,[B|E]);put_attr(A,D,[B])).
generate_attach_body_n(A/B,C,D,E) :-
get_constraint_index(A/B,F),
get_max_constraint_index(G),
get_target_module(H),
add_attr(G,D,F,I,J,K),
singleton_attr(G,D,F,L),
E=(get_attr(C,H,I)->J,put_attr(C,H,K);put_attr(C,H,L)),
!.
generate_detach_a_constraint(A,[B,C]) :-
generate_detach_a_constraint_nil(A,B),
generate_detach_a_constraint_cons(A,C).
detach_constraint_atom(A,B,C,D) :-
make_name(detach_,A,E),
D=..[E,B,C].
generate_detach_a_constraint_nil(A,B) :-
B=(C:-true),
detach_constraint_atom(A,[],_,C).
generate_detach_a_constraint_cons(A,B) :-
B=(C:-D),
detach_constraint_atom(A,[E|F],G,C),
detach_constraint_atom(A,F,G,H),
D=(I,H),
get_max_constraint_index(J),
( J==1 ->
generate_detach_body_1(A,E,G,I)
;
generate_detach_body_n(A,E,G,I)
).
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_body_n(A/B,C,D,E) :-
get_constraint_index(A/B,F),
get_max_constraint_index(G),
rem_attr(G,C,D,F,H,I),
get_target_module(J),
E=(get_attr(C,J,H)->I;true),
!.
create_indexed_variables_body([],[],[],_,_,_,empty,0).
create_indexed_variables_body([A|B],[C|D],[E|F],G,H,I,J,K) :-
L is H+1,
create_indexed_variables_body(B,D,F,M,L,I,N,O),
( C== ?,
is_indexed_argument(I,H) ->
( atomic_type(E) ->
J=((var(A)->G=[A|M];G=M),P),
( N==empty ->
P=true,
M=[]
;
P=N
)
;
( N==empty ->
J=term_variables(A,G)
)
;
J=(term_variables(A,G,M),N)
),
K=O
;
( C== -,
is_indexed_argument(I,H) ->
( N==empty ->
J=(G=[A])
;
J=(G=[A|M],N)
),
K is O+1
)
;
G=M,
J=N,
K is O+1
).
spectermvars(A,B,C,D,E,F) :-
spectermvars(B,1,A,C,D,F,[],E).
spectermvars([],A,_,_,B,C,C,true) :-
A>B,
!.
spectermvars([A|B],C,D,E,F,G,H,I) :-
I=(J,K),
argspecs(D,C,L,M),
merge_argspecs(L,N),
arggoal(N,A,J,G,O),
P is C+1,
spectermvars(B,P,M,E,F,O,H,K).
argspecs([],_,[],[]).
argspecs([[]|A],B,C,D) :-
argspecs(A,B,C,D).
argspecs([[specinfo(A,B,C)|D]|E],F,G,H) :-
( F==A ->
G=[specinfo(A,B,C)|I],
( D=[] ->
J=H
;
H=[D|J]
)
;
G=I,
H=[[specinfo(A,B,C)|D]|J]
),
argspecs(E,F,I,J).
merge_argspecs(A,B) :-
sort(A,C),
merge_argspecs_(C,B).
merge_argspecs_([],[]).
merge_argspecs_([A],B) :-
!,
B=[A].
merge_argspecs_([specinfo(A,B,C),specinfo(A,D,E)|F],G) :-
(
(
B==any
;
D==any
) ->
merge_argspecs_([specinfo(A,any,[])|F],G)
;
( B==D ->
append(C,E,H),
merge_argspecs_([specinfo(A,B,H)|F],G)
)
;
G=[specinfo(A,B,C)|I],
merge_argspecs_([specinfo(A,D,E)|F],I)
).
arggoal(A,B,C,D,E) :-
( A==[] ->
D=E,
C=true
;
( A=[specinfo(_,any,_)] ->
C=term_variables(B,D,E)
)
;
C=(var(B)->D=[B|E];F),
arggoal_cases(A,B,D,E,F)
).
arggoal_cases([],_,A,B,A=B).
arggoal_cases([specinfo(_,A,B)|C],D,E,F,G) :-
( B==[] ->
G=H
;
( B==[[]] ->
G=H
)
;
( A=I/J ->
G=(K;H),
functor(L,I,J),
L=..[_|M],
K=(D=L->N),
spectermvars(M,1,B,I,J,E,F,N)
)
),
arggoal_cases(C,D,E,F,H).
generate_extra_clauses(A,B) :-
generate_activate_clauses(A,B,C),
generate_remove_clauses(A,C,D),
generate_allocate_clauses(A,D,E),
generate_insert_constraint_internal_clauses(A,E,F),
generate_novel_production(F,G),
generate_extend_history(G,H),
generate_run_suspensions_clauses(A,H,I),
generate_empty_named_history_initialisations(I,J),
J=[].
generate_remove_clauses([],A,A).
generate_remove_clauses([A|B],C,D) :-
generate_remove_clause(A,C,E),
generate_remove_clauses(B,E,D).
remove_constraint_goal(A,B,C,D,E,F,G) :-
uses_state(A,removed),
( chr_pp_flag(inline_insertremove,off) ->
use_auxiliary_predicate(remove_constraint_internal,A),
G=(H,(I==yes->E;D)),
remove_constraint_atom(A,B,C,I,H)
;
delay_phase_end(validate_store_type_assumptions,generate_remove_body(A,B,C,D,E,F,G))
).
remove_constraint_atom(A,B,C,D,E) :-
make_name('$remove_constraint_internal_',A,F),
( chr_pp_flag(debugable,off),
(
only_ground_indexed_arguments(A)
;
get_store_type(A,var_assoc_store(_,_))
) ->
E=..[F,B,D]
;
E=..[F,B,C,D]
).
generate_remove_clause(A,B,C) :-
( is_used_auxiliary_predicate(remove_constraint_internal,A) ->
B=[D|C],
D=(E:-F),
remove_constraint_atom(A,G,H,I,E),
generate_remove_body(A,G,H,I=no,I=yes,active,F)
;
B=C
).
generate_remove_body(A,B,C,D,E,F,G) :-
( chr_pp_flag(debugable,off),
(
only_ground_indexed_arguments(A)
;
get_store_type(A,var_assoc_store(_,_))
) ->
( F==active ->
get_update_suspension_field(A,B,state,H,removed,I,J,K),
if_used_state(A,not_stored_yet,J,true,L),
if_used_state(A,not_stored_yet,(H==not_stored_yet->D;E),E,M)
;
( F==partner ->
get_update_suspension_field(A,B,state,H,removed,I,_,K),
L=true,
M=E
)
),
G=(I,L,K,M)
;
static_suspension_term(A,N),
get_static_suspension_term_field(arguments,A,N,O),
generate_indexed_variables_body(A,O,P,C),
( chr_pp_flag(debugable,on) ->
A=Q/_,
get_static_suspension_term_field(functor,A,N,Q)
;
true
),
( F==active ->
get_update_static_suspension_field(A,B,N,state,H,removed,J,K),
if_used_state(A,not_stored_yet,J,true,L),
if_used_state(A,not_stored_yet,(H==not_stored_yet->C=[],D;P,E),(P,E),M)
;
( F==partner ->
get_update_static_suspension_field(A,B,N,state,H,removed,_,K),
L=true,
M=(P,E)
)
),
G=(B=N,L,K,M)
).
generate_activate_clauses([],A,A).
generate_activate_clauses([A|B],C,D) :-
generate_activate_clause(A,C,E),
generate_activate_clauses(B,E,D).
activate_constraint_goal(A,B,C,D,E,F) :-
( chr_pp_flag(inline_insertremove,off) ->
use_auxiliary_predicate(activate_constraint,A),
F=(G,(H==yes->B;true)),
activate_constraint_atom(A,H,C,D,E,G)
;
delay_phase_end(validate_store_type_assumptions,activate_constraint_body(A,B,true,C,D,E,F))
).
activate_constraint_atom(A,B,C,D,E,F) :-
make_name('$activate_constraint_',A,G),
( chr_pp_flag(debugable,off),
only_ground_indexed_arguments(A) ->
F=..[G,B,D]
;
( chr_pp_flag(debugable,off),
may_trigger(A),
get_store_type(A,var_assoc_store(_,_)) ->
F=..[G,B,D,E]
)
;
( chr_pp_flag(debugable,off),
may_trigger(A),
get_store_type(A,var_assoc_store(_,_)) ->
F=..[G,B,C,D,E]
)
;
F=..[G,B,C,D]
).
generate_activate_clause(A,B,C) :-
( is_used_auxiliary_predicate(activate_constraint,A) ->
B=[D|C],
D=(E:-F),
activate_constraint_atom(A,G,H,I,J,E),
activate_constraint_body(A,G=yes,G=no,H,I,J,F)
;
B=C
).
activate_constraint_body(A,B,C,D,E,F,G) :-
( chr_pp_flag(debugable,off),
may_trigger(A),
uses_field(A,generation) ->
get_update_suspension_field(A,E,generation,H,F,I,J,K),
L=(I,J,F is H+1,K)
;
L=true
),
get_update_suspension_field(A,E,state,M,active,N,O,P),
if_used_state(A,not_stored_yet,O,true,Q),
( chr_pp_flag(debugable,off),
(
only_ground_indexed_arguments(A)
;
get_store_type(A,var_assoc_store(_,_))
) ->
if_used_state(A,not_stored_yet,(M==not_stored_yet->B;C),C,R)
;
get_dynamic_suspension_term_field(arguments,A,E,S,T),
generate_indexed_variables_body(A,S,U,D),
( chr_pp_flag(guard_locks,off) ->
V=true
;
V='chr none_locked'(D)
),
if_used_state(A,not_stored_yet,(M==not_stored_yet->T,U,V,B;C),C,R)
),
G=(N,Q,P,L,R).
generate_allocate_clauses([],A,A).
generate_allocate_clauses([A|B],C,D) :-
generate_allocate_clause(A,C,E),
generate_allocate_clauses(B,E,D).
allocate_constraint_goal(A,B,C,D) :-
uses_state(A,not_stored_yet),
( chr_pp_flag(inline_insertremove,off) ->
use_auxiliary_predicate(allocate_constraint,A),
allocate_constraint_atom(A,B,C,D)
;
D=(B=E,F),
delay_phase_end(validate_store_type_assumptions,allocate_constraint_body(A,E,C,F))
).
allocate_constraint_atom(A,B,C,D) :-
make_name('$allocate_constraint_',A,E),
D=..[E,B|C].
generate_allocate_clause(A,B,C) :-
( is_used_auxiliary_predicate(allocate_constraint,A) ->
B=[D|C],
D=(E:-F),
A=_/G,
length(H,G),
allocate_constraint_atom(A,I,H,E),
allocate_constraint_body(A,I,H,F)
;
B=C
).
allocate_constraint_body(A,B,C,D) :-
static_suspension_term(A,E),
get_static_suspension_term_field(arguments,A,E,C),
( chr_pp_flag(debugable,on) ->
A=F/_,
get_static_suspension_term_field(functor,A,E,F)
;
true
),
( chr_pp_flag(debugable,on) ->
( may_trigger(A) ->
append(C,[B],G),
build_head(_,_,[0],G,H),
get_target_module(I),
J=I:H
;
J=true
),
K=(B=E),
create_static_suspension_field(A,E,continuation,J,L),
create_static_suspension_field(A,E,generation,0,M)
;
( may_trigger(A),
uses_field(A,generation) ->
create_static_suspension_field(A,E,generation,0,M),
B=E,
K=true,
L=true
)
;
M=true,
B=E,
K=true,
L=true
),
( uses_history(A) ->
create_static_suspension_field(A,E,history,t,N)
;
N=true
),
create_static_suspension_field(A,E,state,not_stored_yet,O),
( has_suspension_field(A,id) ->
get_static_suspension_term_field(id,A,E,P),
gen_id(P,Q)
;
Q=true
),
D=(K,L,M,N,O,Q).
gen_id(A,'chr gen_id'(A)).
generate_insert_constraint_internal_clauses([],A,A).
generate_insert_constraint_internal_clauses([A|B],C,D) :-
generate_insert_constraint_internal_clause(A,C,E),
generate_insert_constraint_internal_clauses(B,E,D).
insert_constraint_internal_constraint_goal(A,B,C,D,E,F) :-
( chr_pp_flag(inline_insertremove,off) ->
use_auxiliary_predicate(remove_constraint_internal,A),
insert_constraint_internal_constraint_atom(A,B,C,D,E,F)
;
delay_phase_end(validate_store_type_assumptions,generate_insert_constraint_internal_body(A,C,D,E,B,F))
).
insert_constraint_internal_constraint_atom(A,B,C,D,E,F) :-
insert_constraint_internal_constraint_name(A,G),
( chr_pp_flag(debugable,on) ->
F=..[G,B,C,D|E]
;
(
(
only_ground_indexed_arguments(A)
;
get_store_type(A,var_assoc_store(_,_))
) ->
F=..[G,C|E]
)
;
F=..[G,B,C|E]
).
insert_constraint_internal_constraint_name(A,B) :-
make_name('$insert_constraint_internal_',A,B).
generate_insert_constraint_internal_clause(A,B,C) :-
( is_used_auxiliary_predicate(insert_constraint_internal,A) ->
B=[D|C],
D=(E:-F),
A=_/G,
length(H,G),
insert_constraint_internal_constraint_atom(A,I,J,K,H,E),
generate_insert_constraint_internal_body(A,J,K,H,I,F)
;
B=C
).
generate_insert_constraint_internal_body(A,B,C,D,E,F) :-
static_suspension_term(A,G),
create_static_suspension_field(A,G,state,active,H),
( chr_pp_flag(debugable,on) ->
get_static_suspension_term_field(continuation,A,G,C),
create_static_suspension_field(A,G,generation,0,I)
;
( may_trigger(A),
uses_field(A,generation) ->
create_static_suspension_field(A,G,generation,0,I)
)
;
I=true
),
( chr_pp_flag(debugable,on) ->
A=J/_,
get_static_suspension_term_field(functor,A,G,J)
;
true
),
( uses_history(A) ->
create_static_suspension_field(A,G,history,t,K)
;
K=true
),
get_static_suspension_term_field(arguments,A,G,D),
_=[_|_],
( chr_pp_flag(debugable,off),
(
only_ground_indexed_arguments(A)
;
get_store_type(A,var_assoc_store(_,_))
) ->
suspension_term_base_fields(A,_),
( has_suspension_field(A,id) ->
get_static_suspension_term_field(id,A,G,L),
gen_id(L,M)
;
M=true
),
F=(B=G,H,I,K,M)
;
( has_suspension_field(A,id) ->
get_static_suspension_term_field(id,A,G,L),
gen_id(L,M)
;
M=true
),
generate_indexed_variables_body(A,D,N,E),
( chr_pp_flag(guard_locks,off) ->
O=true
;
O='chr none_locked'(E)
),
F=(B=G,N,O,H,I,K,M)
).
generate_novel_production(A,B) :-
( is_used_auxiliary_predicate(novel_production) ->
A=[C|B],
C=('$novel_production'(D,E):-arg(3,D,F),(hprolog:get_ds(E,F,_)->fail;true))
;
A=B
).
generate_extend_history(A,B) :-
( is_used_auxiliary_predicate(extend_history) ->
A=[C|B],
C=('$extend_history'(D,E):-arg(3,D,F),hprolog:put_ds(E,F,x,G),setarg(3,D,G))
;
A=B
).
generate_empty_named_history_initialisations(A,B) :-
empty_named_history_initialisations(A,B),
find_empty_named_histories.
empty_named_history_global_variable(A,B) :-
atom_concat('chr empty named history ',A,B).
empty_named_history_novel_production(A,nb_getval(B,0)) :-
empty_named_history_global_variable(A,B).
empty_named_history_extend_history(A,b_setval(B,1)) :-
empty_named_history_global_variable(A,B).
generate_run_suspensions_clauses([],A,A).
generate_run_suspensions_clauses([A|B],C,D) :-
generate_run_suspensions_clause(A,C,E),
generate_run_suspensions_clauses(B,E,D).
run_suspensions_goal(A,B,C) :-
make_name('$run_suspensions_',A,D),
C=..[D,B].
generate_run_suspensions_clause(A,B,C) :-
( is_used_auxiliary_predicate(run_suspensions,A) ->
B=[D,E|C],
run_suspensions_goal(A,[],D),
( chr_pp_flag(debugable,on) ->
run_suspensions_goal(A,[F|G],H),
get_update_suspension_field(A,F,state,I,triggered,J,K,L),
get_update_suspension_field(A,F,state,M,active,N,O,P),
get_update_suspension_field(A,F,generation,Q,R,S,T,U),
get_dynamic_suspension_term_field(continuation,A,F,V,W),
run_suspensions_goal(A,G,X),
E=(H:-J,K,(I==active->L,S,T,R is Q+1,U,W,('chr debug_event'(wake(F)),call(V);'chr debug_event'(fail(F)),!,fail),('chr debug_event'(exit(F));'chr debug_event'(redo(F)),fail),N,O,(M==triggered->P;true);true),X)
;
run_suspensions_goal(A,[F|G],H),
static_suspension_term(A,Y),
get_static_suspension_term_field(arguments,A,Y,Z),
append(Z,[F],A1),
make_suspension_continuation_goal(A,A1,V),
run_suspensions_goal(A,G,X),
( uses_field(A,generation) ->
get_update_static_suspension_field(A,F,Y,generation,Q,R,S,U),
B1=(S,R is Q+1,U)
;
B1=true
),
get_update_static_suspension_field(A,F,Y,state,I,triggered,J,L),
get_update_static_suspension_field(A,F,Y,state,M,active,C1,D1),
if_used_state(A,removed,(J,(I==active->E1;true)),E1,F1),
E1=(L,B1,V,C1,(M==triggered->D1;true)),
E=(H:-F=Y,F1,X)
)
;
B=C
).
generate_attach_increment(A) :-
get_max_constraint_index(B),
( is_used_auxiliary_predicate(attach_increment),
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),
( chr_pp_flag(guard_locks,off) ->
G=true
;
G='chr not_locked'(C)
),
H=(G,(get_attr(C,F,I)->sort(I,J),'chr merge_attributes'(E,J,K),put_attr(C,F,K);put_attr(C,F,E)),attach_increment(D,E)),
A=(B:-H).
generate_attach_increment_many(A,B) :-
C=attach_increment([D|E],F),
merge_attributes(A,F,G,H,I),
get_target_module(J),
( chr_pp_flag(guard_locks,off) ->
K=true
;
K='chr not_locked'(D)
),
L=(K,(get_attr(D,J,G)->H,put_attr(D,J,I);put_attr(D,J,F)),attach_increment(E,F)),
B=(C:-L).
generate_attr_unify_hook(A) :-
get_max_constraint_index(B),
( B==0 ->
A=[]
;
( B==1 ->
generate_attr_unify_hook_one(A)
)
;
generate_attr_unify_hook_many(B,A)
).
generate_attr_unify_hook_one([A]) :-
B=attr_unify_hook(C,D),
get_target_module(E),
get_indexed_constraint(1,F),
( get_store_type(F,G),
(
G=default
;
G=multi_store(H),
memberchk(default,H)
) ->
make_run_suspensions(I,J,K),
make_run_suspensions(J,J,L),
( atomic_types_suspended_constraint(F) ->
M=true,
J=C,
N=true,
O=P,
Q=(append(C,P,R),sort(R,I)),
S=true
;
M=sort(C,J),
N=sort(P,O),
Q='chr merge_attributes'(J,O,I),
use_auxiliary_predicate(attach_increment),
S=(compound(D)->term_variables(D,T),attach_increment(T,J);true)
),
U=(M,(var(D)->(get_attr(D,E,P)->N,Q,put_attr(D,E,I),K;put_attr(D,E,J),L);S,L)),
A=(B:-U)
;
( get_store_type(F,var_assoc_store(_,_)) ->
make_run_suspensions(R,R,K),
Q=merge_into_assoc_store(C,P,R),
U=(get_attr(D,E,P)->Q,K;put_attr(D,E,C)),
A=(B:-U)
)
).
generate_attr_unify_hook_many(A,[B]) :-
chr_pp_flag(dynattr,off),
!,
C=attr_unify_hook(D,E),
get_target_module(F),
make_attr(A,G,H,D),
bagof(I,J^K^(member(J,H),I=sort(J,K)),L),
list2conj(L,M),
bagof(K,J^member(sort(J,K),L),N),
merge_attributes2(A,G,N,O,P,Q),
get_all_suspensions2(A,Q,R),
make_attr(A,G,N,S),
make_run_suspensions_loop(R,N,T),
make_run_suspensions_loop(N,N,U),
( forall((between(1,A,V),get_indexed_constraint(V,W)),atomic_types_suspended_constraint(W)) ->
X=true
;
use_auxiliary_predicate(attach_increment),
X=(compound(E)->term_variables(E,Y),attach_increment(Y,S);true)
),
Z=(M,(var(E)->(get_attr(E,F,O)->P,put_attr(E,F,Q),T;put_attr(E,F,S),U);X,U)),
B=(C:-Z).
generate_attr_unify_hook_many(A,B) :-
C=attr_unify_hook(D,E),
get_target_module(F),
normalize_attr(D,G,H),
normalize_attr(I,J,K),
merge_attributes(A,H,K,L,M),
make_run_suspensions(A),
( forall((between(1,A,N),get_indexed_constraint(N,O)),atomic_types_suspended_constraint(O)) ->
P=true
;
use_auxiliary_predicate(attach_increment),
P=(compound(E)->term_variables(E,Q),attach_increment(Q,H);true)
),
R=(G,(var(E)->(get_attr(E,F,I)->J,L,put_attr(E,F,M),'$dispatch_run_suspensions'(M);put_attr(E,F,H),'$dispatch_run_suspensions'(H));P,'$dispatch_run_suspensions'(H))),
S=(C:-R),
B=[S,T,U|V],
T='$dispatch_run_suspensions'([]),
U=('$dispatch_run_suspensions'([W-X|Y]):-'$dispatch_run_suspensions'(W,X),'$dispatch_run_suspensions'(Y)),
run_suspensions_dispatchers(A,[],V).
run_suspensions_dispatchers(A,B,C) :-
( A>0 ->
get_indexed_constraint(A,D),
E=[('$dispatch_run_suspensions'(A,F):-G)|B],
( may_trigger(D) ->
run_suspensions_goal(D,F,G)
;
G=true
),
H is A-1,
run_suspensions_dispatchers(H,E,C)
;
C=B
).
make_run_suspensions(A) :-
( A>0 ->
( get_indexed_constraint(A,B),
may_trigger(B) ->
use_auxiliary_predicate(run_suspensions,B)
;
true
),
C is A-1,
make_run_suspensions(C)
;
true
).
make_run_suspensions(A,B,C) :-
make_run_suspensions(1,A,B,C).
make_run_suspensions(A,B,C,D) :-
( get_indexed_constraint(A,E),
may_trigger(E) ->
use_auxiliary_predicate(run_suspensions,E),
( wakes_partially(E) ->
run_suspensions_goal(E,C,D)
;
run_suspensions_goal(E,B,D)
)
;
D=true
).
make_run_suspensions_loop(A,B,C) :-
make_run_suspensions_loop(A,B,1,C).
make_run_suspensions_loop([],[],_,true).
make_run_suspensions_loop([A|B],[C|D],E,(F,G)) :-
make_run_suspensions(E,A,C,F),
H is E+1,
make_run_suspensions_loop(B,D,H,G).
generate_insert_delete_constraints([],[]).
generate_insert_delete_constraints([A|B],C) :-
( is_stored(A) ->
generate_insert_delete_constraint(A,C,D)
;
C=D
),
generate_insert_delete_constraints(B,D).
generate_insert_delete_constraint(A,B,C) :-
insert_constraint_clause(A,B,D),
delete_constraint_clause(A,D,C).
insert_constraint_goal(A,B,C,D) :-
( chr_pp_flag(inline_insertremove,off) ->
use_auxiliary_predicate(insert_in_store,A),
insert_constraint_atom(A,B,D)
;
delay_phase_end(validate_store_type_assumptions,(insert_constraint_body(A,B,E,D),insert_constraint_direct_used_vars(E,C)))
).
insert_constraint_direct_used_vars([],_).
insert_constraint_direct_used_vars([A-B|C],D) :-
nth1(A,D,B),
insert_constraint_direct_used_vars(C,D).
insert_constraint_atom(A,B,C) :-
make_name('$insert_in_store_',A,D),
C=..[D,B].
insert_constraint_clause(A,B,C) :-
( is_used_auxiliary_predicate(insert_in_store,A) ->
B=[D|C],
D=(E:-F,G,H),
insert_constraint_atom(A,I,E),
insert_constraint_body(A,I,J,H),
insert_constraint_used_vars(J,A,I,G),
( chr_pp_flag(store_counter,on) ->
F='$insert_counter_inc'
;
F=true
)
;
B=C
).
insert_constraint_used_vars([],_,_,true).
insert_constraint_used_vars([A-B|C],D,E,(F,G)) :-
get_dynamic_suspension_term_field(argument(A),D,E,B,F),
insert_constraint_used_vars(C,D,E,G).
insert_constraint_body(A,B,C,D) :-
get_store_type(A,E),
insert_constraint_body(E,A,B,C,D).
insert_constraint_body(default,A,B,[],C) :-
global_list_store_name(A,D),
make_get_store_goal(D,E,F),
make_update_store_goal(D,G,H),
( chr_pp_flag(debugable,on) ->
G=[B|E],
C=(F,H)
;
set_dynamic_suspension_term_field(global_list_prev,A,I,G,J),
C=(F,G=[B|E],H,(E=[I|_]->J;true))
).
insert_constraint_body(multi_inthash(A),B,C,[],D) :-
generate_multi_inthash_insert_constraint_bodies(A,B,C,D).
insert_constraint_body(multi_hash(A),B,C,D,E) :-
generate_multi_hash_insert_constraint_bodies(A,B,C,E,D),
sort_out_used_vars(D,_).
insert_constraint_body(atomic_constants(A,_,_),B,C,D,E) :-
multi_hash_key_direct(B,A,C,F,D),
constants_store_index_name(B,A,G),
H=..[G,F,I],
E=(H->nb_getval(I,J),b_setval(I,[C|J]);true).
insert_constraint_body(ground_constants(A,_,_),B,C,D,E) :-
multi_hash_key_direct(B,A,C,F,D),
constants_store_index_name(B,A,G),
H=..[G,F,I],
E=(H->nb_getval(I,J),b_setval(I,[C|J]);true).
insert_constraint_body(global_ground,A,B,[],C) :-
global_ground_store_name(A,D),
make_get_store_goal(D,E,F),
make_update_store_goal(D,G,H),
( chr_pp_flag(debugable,on) ->
G=[B|E],
C=(F,H)
;
set_dynamic_suspension_term_field(global_list_prev,A,I,G,J),
C=(F,G=[B|E],H,(E=[I|_]->J;true))
).
insert_constraint_body(var_assoc_store(A,B),_,C,[A-D,B-E],F) :-
get_target_module(G),
F=(get_attr(D,G,H)->insert_assoc_store(H,E,C);new_assoc_store(H),put_attr(D,G,H),insert_assoc_store(H,E,C)).
insert_constraint_body(global_singleton,A,B,[],C) :-
global_singleton_store_name(A,D),
make_update_store_goal(D,B,E),
C=E.
insert_constraint_body(multi_store(A),B,C,D,E) :-
maplist(insert_constraint_body1(B,C),A,F,G),
list2conj(G,E),
sort_out_used_vars(F,D).
insert_constraint_body1(A,B,C,D,E) :-
insert_constraint_body(C,A,B,D,E).
insert_constraint_body(identifier_store(A),B,C,D,E) :-
D=[A-F],
get_identifier_size(G),
functor(H,struct,G),
get_identifier_index(B,A,I),
arg(I,H,J),
E=(F=H,setarg(I,F,[C|J])).
insert_constraint_body(type_indexed_identifier_store(A,B),C,D,E,F) :-
E=[A-G],
type_indexed_identifier_structure(B,H),
get_type_indexed_identifier_index(B,C,A,I),
arg(I,H,J),
F=(G=H,setarg(I,G,[D|J])).
sort_out_used_vars(A,B) :-
flatten(A,C),
sort(C,D),
sort_out_used_vars1(D,B).
sort_out_used_vars1([],[]).
sort_out_used_vars1([A-B],C) :-
!,
C=[A-B].
sort_out_used_vars1([A-B,C-D|E],F) :-
( A==C ->
B=D,
sort_out_used_vars1([A-B|E],F)
;
F=[A-B|G],
sort_out_used_vars1([C-D|E],G)
).
generate_multi_inthash_insert_constraint_bodies([],_,_,true).
generate_multi_inthash_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_iht(J,I,D)),
generate_multi_inthash_insert_constraint_bodies(B,C,D,F).
generate_multi_hash_insert_constraint_bodies([],_,_,true,[]).
generate_multi_hash_insert_constraint_bodies([A|B],C,D,(E,F),[G|H]) :-
multi_hash_store_name(C,A,I),
multi_hash_key_direct(C,A,D,J,G),
make_get_store_goal(I,K,L),
( chr_pp_flag(ht_removal,on) ->
ht_prev_field(A,M),
set_dynamic_suspension_term_field(M,C,N,O,P),
E=(L,insert_ht(K,J,D,O),(O=[_,N|_]->P;true))
;
E=(L,insert_ht(K,J,D))
),
generate_multi_hash_insert_constraint_bodies(B,C,D,F,H).
delete_constraint_clause(A,B,C) :-
( is_used_auxiliary_predicate(delete_from_store,A) ->
B=[D|C],
D=(E:-F),
delete_constraint_atom(A,G,E),
A=H/I,
functor(E,H,I),
delete_constraint_body(A,E,G,[],F)
;
B=C
).
delete_constraint_goal(A,B,C,D) :-
functor(A,E,F),
G=E/F,
( chr_pp_flag(inline_insertremove,off) ->
use_auxiliary_predicate(delete_from_store,G),
delete_constraint_atom(G,B,D)
;
delay_phase_end(validate_store_type_assumptions,delete_constraint_body(G,A,B,C,D))
).
delete_constraint_atom(A,B,C) :-
make_name('$delete_from_store_',A,D),
C=..[D,B].
delete_constraint_body(A,B,C,D,E) :-
E=(F,G),
( chr_pp_flag(store_counter,on) ->
F='$delete_counter_inc'
;
F=true
),
get_store_type(A,H),
delete_constraint_body(H,A,B,C,D,G).
delete_constraint_body(default,A,_,B,_,C) :-
( chr_pp_flag(debugable,on) ->
global_list_store_name(A,D),
make_get_store_goal(D,E,F),
make_update_store_goal(D,G,H),
C=(F,'chr sbag_del_element'(E,B,G),H)
;
get_dynamic_suspension_term_field(global_list_prev,A,B,I,J),
global_list_store_name(A,D),
make_get_store_goal(D,E,F),
make_update_store_goal(D,K,H),
set_dynamic_suspension_term_field(global_list_prev,A,L,_,M),
set_dynamic_suspension_term_field(global_list_prev,A,L,I,N),
C=(J,(var(I)->F,E=[_|K],H,(K=[L|_]->M;true);I=[_,_|K],setarg(2,I,K),(K=[L|_]->N;true)))
).
delete_constraint_body(multi_inthash(A),B,_,C,_,D) :-
generate_multi_inthash_delete_constraint_bodies(A,B,C,D).
delete_constraint_body(multi_hash(A),B,C,D,E,F) :-
generate_multi_hash_delete_constraint_bodies(A,B,C,D,E,F).
delete_constraint_body(atomic_constants(A,_,_),B,C,D,E,F) :-
multi_hash_key(B,C,A,D,E,G,H),
constants_store_index_name(B,A,I),
J=..[I,H,K],
F=(G,(J->nb_getval(K,L),'chr sbag_del_element'(L,D,M),b_setval(K,M);true)).
delete_constraint_body(ground_constants(A,_,_),B,C,D,E,F) :-
multi_hash_key(B,C,A,D,E,G,H),
constants_store_index_name(B,A,I),
J=..[I,H,K],
F=(G,(J->nb_getval(K,L),'chr sbag_del_element'(L,D,M),b_setval(K,M);true)).
delete_constraint_body(global_ground,A,_,B,_,C) :-
( chr_pp_flag(debugable,on) ->
global_ground_store_name(A,D),
make_get_store_goal(D,E,F),
make_update_store_goal(D,G,H),
C=(F,'chr sbag_del_element'(E,B,G),H)
;
get_dynamic_suspension_term_field(global_list_prev,A,B,I,J),
global_ground_store_name(A,D),
make_get_store_goal(D,E,F),
make_update_store_goal(D,K,H),
set_dynamic_suspension_term_field(global_list_prev,A,L,_,M),
set_dynamic_suspension_term_field(global_list_prev,A,L,I,N),
C=(J,(var(I)->F,E=[_|K],H,(K=[L|_]->M;true);I=[_,_|K],setarg(2,I,K),(K=[L|_]->N;true)))
).
delete_constraint_body(var_assoc_store(A,B),C,_,D,_,E) :-
get_target_module(F),
get_dynamic_suspension_term_field(argument(A),C,D,G,H),
get_dynamic_suspension_term_field(argument(B),C,D,I,J),
E=(H,get_attr(G,F,K),J,delete_assoc_store(K,I,D)).
delete_constraint_body(global_singleton,A,_,_,_,B) :-
global_singleton_store_name(A,C),
make_update_store_goal(C,[],D),
B=D.
delete_constraint_body(multi_store(A),B,C,D,E,F) :-
maplist(delete_constraint_body1(B,C,D,E),A,G),
list2conj(G,F).
delete_constraint_body1(A,B,C,D,E,F) :-
delete_constraint_body(E,A,B,C,D,F).
delete_constraint_body(identifier_store(A),B,C,D,E,F) :-
get_suspension_argument_possibly_in_scope(C,E,D,A,G,H),
get_identifier_size(I),
functor(J,struct,I),
get_identifier_index(B,A,K),
arg(K,J,L),
F=(H,G=J,'chr sbag_del_element'(L,D,M),setarg(K,G,M)).
delete_constraint_body(type_indexed_identifier_store(A,B),C,D,E,F,G) :-
get_suspension_argument_possibly_in_scope(D,F,E,A,H,I),
type_indexed_identifier_structure(B,J),
get_type_indexed_identifier_index(B,C,A,K),
arg(K,J,L),
G=(I,H=J,'chr sbag_del_element'(L,E,M),setarg(K,H,M)).
generate_multi_inthash_delete_constraint_bodies([],_,_,true).
generate_multi_inthash_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_iht(J,I,D)),
generate_multi_inthash_delete_constraint_bodies(B,C,D,F).
generate_multi_hash_delete_constraint_bodies([],_,_,_,_,true).
generate_multi_hash_delete_constraint_bodies([A|B],C,D,E,F,(G,H)) :-
multi_hash_store_name(C,A,I),
multi_hash_key(C,D,A,E,F,J,K),
make_get_store_goal(I,L,M),
( chr_pp_flag(ht_removal,on) ->
ht_prev_field(A,N),
get_dynamic_suspension_term_field(N,C,E,O,P),
set_dynamic_suspension_term_field(N,C,Q,_,R),
set_dynamic_suspension_term_field(N,C,Q,O,S),
G=(P,(var(O)->M,J,delete_first_ht(L,K,T),(T=[Q|_]->R;true);O=[_,_|T],setarg(2,O,T),(T=[Q|_]->S;true)))
;
G=(J,M,delete_ht(L,K,E))
),
generate_multi_hash_delete_constraint_bodies(B,_,D,E,F,H).
generate_attach_code(A,B) :-
enumerate_stores_code(A,C),
append(C,D,B),
generate_attach_code(A,D,E),
module_initializers(F),
prolog_global_variables_code(G),
E=[('$chr_initialization':-F),(:-initialization '$chr_initialization')|G].
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,B,C) :-
global_list_store_initialisation(A,B,C).
generate_attach_code(multi_inthash(A),B,C,D) :-
multi_inthash_store_initialisations(A,B,C,E),
multi_inthash_via_lookups(A,B,E,D).
generate_attach_code(multi_hash(A),B,C,D) :-
multi_hash_store_initialisations(A,B,C,E),
multi_hash_lookups(A,B,E,D).
generate_attach_code(atomic_constants(A,B,_),C,D,E) :-
constants_initializers(C,A,B),
atomic_constants_code(C,A,B,D,E).
generate_attach_code(ground_constants(A,B,_),C,D,E) :-
constants_initializers(C,A,B),
ground_constants_code(C,A,B,D,E).
generate_attach_code(global_ground,A,B,C) :-
global_ground_store_initialisation(A,B,C).
generate_attach_code(var_assoc_store(_,_),_,A,A) :-
use_auxiliary_module(chr_assoc_store).
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).
generate_attach_code(identifier_store(A),B,C,D) :-
get_identifier_index(B,A,E),
( E==2 ->
get_identifier_size(F),
functor(G,struct,F),
G=..[_,H|I],
set_elems(I,[]),
J=new_identifier(H,G),
functor(K,struct,F),
arg(1,K,L),
M=(user:portray(K):-write('<id:'),print(L),write(>)),
functor(N,struct,F),
arg(1,N,O),
P=identifier_label(N,O),
C=[J,M,P|D]
;
C=D
).
generate_attach_code(type_indexed_identifier_store(A,B),C,D,E) :-
get_type_indexed_identifier_index(B,C,A,F),
( F==2 ->
identifier_store_initialization(B,D,G),
get_type_indexed_identifier_size(B,_),
type_indexed_identifier_structure(B,H),
H=..[_,I|J],
set_elems(J,[]),
type_indexed_identifier_name(B,new_identifier,K),
L=..[K,I,H],
M=..[K,N,O],
type_indexed_identifier_structure(B,P),
P=..[_,N|Q],
set_elems(Q,[]),
R=(O=P),
S=user:goal_expansion(M,R),
type_indexed_identifier_structure(B,T),
arg(1,T,U),
V=(user:portray(T):-write('<id:'),print(U),write(>)),
type_indexed_identifier_structure(B,W),
arg(1,W,X),
type_indexed_identifier_name(B,identifier_label,Y),
Z=..[Y,W,X],
A1=..[Y,_,B1],
type_indexed_identifier_structure(B,C1),
arg(1,C1,B1),
D1=(_=C1),
E1=(user:goal_expansion(A1,D1):-writeln(expanding)),
identifier_store_name(B,F1),
lookup_identifier_atom(B,G1,H1,I1),
type_indexed_identifier_name(B,new_identifier,J1),
K1=..[J1,G1,H1],
L1=(I1:-nb_getval(F1,M1),(lookup_ht(M1,G1,[H1])->true;K1,insert_ht(M1,G1,H1))),
G=[(:-multifile goal_expansion/2),(:-dynamic goal_expansion/2),L,S,V,Z,E1,L1|E]
;
D=E
).
constants_initializers(A,B,C) :-
maplist(constant_initializer(A,B),C).
constant_initializer(A,B,C) :-
constants_store_name(A,B,C,D),
module_initializer(nb_setval(D,[])).
lookup_identifier_atom(A,B,C,D) :-
atom_concat(lookup_identifier_,A,E),
D=..[E,B,C].
identifier_label_atom(A,B,C,D) :-
type_indexed_identifier_name(A,identifier_label,E),
D=..[E,B,C].
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_inthash_store_initialisations([],_,A,A).
multi_inthash_store_initialisations([A|B],C,D,E) :-
use_auxiliary_module(chr_integertable_store),
multi_hash_store_name(C,A,F),
module_initializer((new_iht(G),nb_setval(F,G))),
H=D,
multi_inthash_store_initialisations(B,C,H,E).
multi_hash_store_initialisations([],_,A,A).
multi_hash_store_initialisations([A|B],C,D,E) :-
use_auxiliary_module(chr_hashtable_store),
multi_hash_store_name(C,A,F),
prolog_global_variable(F),
make_init_store_goal(F,G,H),
module_initializer((new_ht(G),H)),
I=D,
multi_hash_store_initialisations(B,C,I,E).
global_list_store_initialisation(A,B,C) :-
( is_stored(A) ->
global_list_store_name(A,D),
prolog_global_variable(D),
make_init_store_goal(D,[],E),
module_initializer(E)
;
true
),
B=C.
global_ground_store_initialisation(A,B,C) :-
global_ground_store_name(A,D),
prolog_global_variable(D),
make_init_store_goal(D,[],E),
module_initializer(E),
B=C.
global_singleton_store_initialisation(A,B,C) :-
global_singleton_store_name(A,D),
prolog_global_variable(D),
make_init_store_goal(D,[],E),
module_initializer(E),
B=C.
identifier_store_initialization(A,B,C) :-
use_auxiliary_module(chr_hashtable_store),
identifier_store_name(A,D),
prolog_global_variable(D),
make_init_store_goal(D,E,F),
module_initializer((new_ht(E),F)),
B=C.
multi_inthash_via_lookups([],_,A,A).
multi_inthash_via_lookups([A|B],C,D,E) :-
multi_hash_lookup_head(C,A,F,G,H),
multi_hash_lookup_body(C,inthash,A,F,G,I),
D=[(H:-I)|J],
multi_inthash_via_lookups(B,C,J,E).
multi_hash_lookups([],_,A,A).
multi_hash_lookups([A|B],C,D,E) :-
multi_hash_lookup_head(C,A,F,G,H),
multi_hash_lookup_body(C,hash,A,F,G,I),
D=[(H:-I)|J],
multi_hash_lookups(B,C,J,E).
multi_hash_lookup_head(A,B,C,D,E) :-
multi_hash_lookup_name(A,B,F),
E=..[F,C,D].
multi_hash_lookup_body(A,B,C,D,E,F) :-
get_store_type(A,multi_store(G)),
( memberchk(atomic_constants(C,H,_),G) ->
( ground(D) ->
constants_store_name(A,C,D,I),
F=nb_getval(I,E)
;
constants_store_index_name(A,C,J),
K=..[J,D,I],
F=(K,nb_getval(I,E))
)
;
( memberchk(ground_constants(C,H,_),G) ->
( ground(D) ->
constants_store_name(A,C,D,I),
F=nb_getval(I,E)
;
constants_store_index_name(A,C,J),
K=..[J,D,I],
F=(K,nb_getval(I,E))
)
)
;
( memberchk(multi_hash([C]),G) ->
multi_hash_store_name(A,C,I),
make_get_store_goal(I,L,M),
( B==hash,
specialized_hash_term_call(A,C,D,N,O) ->
F=(M,O,lookup_ht1(L,N,D,E))
;
lookup_hash_call(B,L,D,E,K),
F=(M,K)
)
)
;
( B==inthash ->
multi_hash_store_name(A,C,I),
make_get_store_goal(I,L,M),
lookup_hash_call(B,L,D,E,K),
F=(M,K)
)
).
lookup_hash_call(hash,A,B,C,lookup_ht(A,B,C)).
lookup_hash_call(inthash,A,B,C,lookup_iht(A,B,C)).
specialized_hash_term_call(A,B,C,D,E) :-
( ground(C) ->
hash_term(C,D),
E=true
;
( B=[F],
get_constraint_type(A,G),
nth1(F,G,H),
unalias_type(H,I),
memberchk_eq(I,[int,natural]) ->
( I==int ->
E=(D is abs(C))
;
D=C,
E=true
)
)
;
nonvar(C),
specialize_hash_term(C,J),
J\==C,
E=hash_term(J,D)
).
specialize_hash_term(A,B) :-
( ground(A) ->
hash_term(A,B)
;
( var(A) ->
B=A
)
;
A=..[C|D],
maplist(specialize_hash_term,D,E),
B=..[C|E]
).
multi_hash_lookup_goal(A,B,C,D,E,F) :-
( atomic(D) ->
actual_atomic_multi_hash_keys(A,C,[D])
;
( ground(D) ->
actual_ground_multi_hash_keys(A,C,[D])
)
;
( C=[G],
get_constraint_arg_type(A,G,H),
is_chr_constants_type(H,_,_) ->
true
)
;
actual_non_ground_multi_hash_key(A,C)
),
delay_phase_end(validate_store_type_assumptions,multi_hash_lookup_body(A,B,C,D,E,F)).
multi_hash_lookup_name(A/B,C,D) :-
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),
atom_concat_list(C,F),
atom_concat_list(['$chr_store_multi_hash_',E,'____',A,'___',B,-,F],D).
multi_hash_key(A,B,C,D,E) :-
( B=[F] ->
get_dynamic_suspension_term_field(argument(F),A,C,E,D)
;
maplist(get_dynamic_suspension_term_field1(A,C),B,G,H),
E=..[k|G],
list2conj(H,D)
).
get_dynamic_suspension_term_field1(A,B,C,D,E) :-
get_dynamic_suspension_term_field(argument(C),A,B,D,E).
multi_hash_key(_,A,B,C,D,E,F) :-
( B=[G] ->
get_suspension_argument_possibly_in_scope(A,D,C,G,F,E)
;
maplist(get_suspension_argument_possibly_in_scope(A,D,C),B,H,I),
F=..[k|H],
list2conj(I,E)
).
get_suspension_argument_possibly_in_scope(A,B,C,D,E,F) :-
arg(D,A,G),
( term_variables(G,H),
copy_term_nat(G-H,E-I),
translate(H,B,I) ->
F=true
;
functor(A,J,K),
L=J/K,
get_dynamic_suspension_term_field(argument(D),L,C,E,F)
).
multi_hash_key_direct(_,A,_,B,C) :-
( A=[D] ->
C=[D-B]
;
pairup(A,E,C),
B=..[k|E]
).
multi_hash_key_args(A,B,C) :-
maplist(arg1(B),A,C).
atomic_constants_code(A,B,C,D,E) :-
constants_store_index_name(A,B,F),
maplist(atomic_constant_code(A,B,F),C,G),
append(G,E,D).
atomic_constant_code(A,B,C,D,E) :-
constants_store_name(A,B,D,F),
E=..[C,D,F].
ground_constants_code(A,B,C,D,E) :-
constants_store_index_name(A,B,F),
maplist(constants_store_name(A,B),C,G),
length(C,H),
replicate(H,[],I),
trie_index([C|I],G,F,D,E).
constants_store_name(A/B,C,D,E) :-
get_target_module(F),
term_to_atom(D,G),
term_to_atom(C,H),
atom_concat_list(['$chr_store_constants_',F,'____',A,'___',B,'___',H,'___',G],E).
constants_store_index_name(A/B,C,D) :-
get_target_module(E),
term_to_atom(C,F),
atom_concat_list(['$chr_store_constants_',E,'____',A,'___',B,'___',F],D).
trie_index([A|B],C,D,E,F) :-
trie_step(A,D,D,B,C,E,F).
trie_step([],_,_,[],[],A,A) :-
!.
trie_step(A,B,C,D,E,F,G) :-
D=[H|_],
length(H,I),
aggregate_all(set(J/K),(member(L,A),functor(L,J,K)),M),
N is I+1,
trie_step_cases(M,N,A,D,E,B,C,F,G).
trie_step_cases([],_,_,_,_,_,_,A,A).
trie_step_cases([A|B],C,D,E,F,G,H,I,J) :-
trie_step_case(A,C,D,E,F,G,H,I,K),
trie_step_cases(B,C,D,E,F,G,H,K,J).
trie_step_case(A/B,C,D,E,F,G,H,[I|J],K) :-
I=(L:-M),
N is C+1,
functor(L,G,N),
arg(1,L,O),
L=..[_,_|P],
once(append(Q,[R],P)),
functor(O,A,B),
O=..[_|S],
append(S,P,T),
( T==[R] ->
J=K,
M=true,
rec_cases(D,_,F,A/B,_,_,U),
U=[R]
;
rec_cases(D,E,F,A/B,V,W,U),
( W=[X] ->
J=K,
M=true,
append([V,X,U],T)
;
pairup(V,W,Y),
common_pattern(Y,Z,A1,B1),
append(S,Q,[C1|D1]),
C1-D1=Z,
gensym(H,E1),
append(A1,[R],F1),
M=..[E1|F1],
maplist(head_tail,B1,G1,H1),
trie_step(G1,E1,H,H1,U,J,K)
)
).
head_tail([A|B],A,B).
rec_cases([],[],[],_,[],[],[]).
rec_cases([A|B],[C|D],[E|F],G/H,I,J,K) :-
( functor(A,G,H),
A=..[_|L],
append(L,C,[M|N]) ->
I=[M|O],
J=[N|P],
K=[E|Q],
rec_cases(B,D,F,G/H,O,P,Q)
;
rec_cases(B,D,F,G/H,I,J,K)
).
common_pattern(A,B,C,D) :-
fold1(gct,A,B),
term_variables(B,C),
findall(C,member(B,A),D).
gct(A,B,C) :-
gct_(A,B,C,[],_).
gct_(A,B,C,D,E) :-
( nonvar(A),
nonvar(B),
functor(A,F,G),
functor(B,H,I),
F==H,
G==I ->
functor(C,F,G),
A=..[_|J],
B=..[_|K],
C=..[_|L],
maplist_dcg(gct_,J,K,L,D,E)
;
( lookup_eq(D,A+B,C) ->
E=D
)
;
E=[A+B-C|D]
).
fold1(A,[B|C],D) :-
fold(C,A,B,D).
fold([],_,A,A).
fold([A|B],C,D,E) :-
call(C,A,D,F),
fold(B,C,F,E).
maplist_dcg(A,B,C,D)-->maplist_dcg_(B,C,D,A).
maplist_dcg_([],[],[],_)-->[].
maplist_dcg_([A|B],[C|D],[E|F],G)-->call(G,A,C,E),maplist_dcg_(B,D,F,G).
global_list_store_name(A/B,C) :-
get_target_module(D),
atom_concat_list(['$chr_store_global_list_',D,'____',A,'___',B],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).
identifier_store_name(A,B) :-
get_target_module(C),
atom_concat_list(['$chr_identifier_lookup_',C,'____',A],B).
prolog_global_variables_code(A) :-
prolog_global_variables(B),
( B==[] ->
A=[]
;
maplist(wrap_in_functor('$chr_prolog_global_variable'),B,C),
A=[(:-dynamic user:exception/3),(:-multifile user:exception/3),(user:exception(undefined_global_variable,D,retry):-'$chr_prolog_global_variable'(D),'$chr_initialization')|C]
).
sbag_member_call(A,B,'chr sbag_member'(A,B)).
update_mutable_call(A,B,'chr update_mutable'(A,B)).
create_mutable_call(A,B,true) :-
B=mutable(A).
get_suspension_field(A,B,C,D,E) :-
get_dynamic_suspension_term_field(C,A,B,D,E).
update_suspension_field(A,B,C,D,E) :-
set_dynamic_suspension_term_field(C,A,B,D,E).
get_update_suspension_field(A,B,C,D,E,true,F,G) :-
get_dynamic_suspension_term_field(C,A,B,D,F),
set_dynamic_suspension_term_field(C,A,B,E,G).
create_static_suspension_field(A,B,C,D,true) :-
get_static_suspension_term_field(C,A,B,D).
get_static_suspension_field(A,B,C,D,true) :-
get_static_suspension_term_field(C,A,B,D).
get_update_static_suspension_field(A,B,C,D,E,F,true,G) :-
get_static_suspension_term_field(D,A,C,E),
set_dynamic_suspension_term_field(D,A,B,F,G).
enumerate_stores_code(A,[B|C]) :-
D='$enumerate_constraints'(E),
B=(D:-F),
enumerate_store_bodies(A,E,C),
( C=[] ->
F=fail
;
F=(nonvar(E)->functor(E,G,_),'$enumerate_constraints'(G,E);'$enumerate_constraints'(_,E))
).
enumerate_store_bodies([],_,[]).
enumerate_store_bodies([A|B],C,D) :-
( is_stored(A) ->
get_store_type(A,E),
( enumerate_store_body(E,A,F,G) ->
true
;
chr_error(internal,'Could not generate enumeration code for constraint ~w.
',[A])
),
get_dynamic_suspension_term_field(arguments,A,F,H,I),
A=J/_,
K=..[J|H],
L='$enumerate_constraints'(J,C),
M=(G,I,C=K),
D=[(L:-M)|N]
;
D=N
),
enumerate_store_bodies(B,C,N).
enumerate_store_body(default,A,B,C) :-
global_list_store_name(A,D),
sbag_member_call(B,E,F),
make_get_store_goal(D,E,G),
C=(G,F).
enumerate_store_body(multi_inthash([A|_]),B,C,D) :-
multi_inthash_enumerate_store_body(A,B,C,D).
enumerate_store_body(multi_hash([A|_]),B,C,D) :-
multi_hash_enumerate_store_body(A,B,C,D).
enumerate_store_body(atomic_constants(A,B,C),D,E,F) :-
C==complete,
maplist(enumerate_constant_store_body(D,A,G),B,H),
list2disj(H,I),
F=(I,member(E,G)).
enumerate_constant_store_body(A,B,C,D,nb_getval(E,C)) :-
constants_store_name(A,B,D,E).
enumerate_store_body(ground_constants(A,B,C),D,E,F) :-
enumerate_store_body(atomic_constants(A,B,C),D,E,F).
enumerate_store_body(global_ground,A,B,C) :-
global_ground_store_name(A,D),
sbag_member_call(B,E,F),
make_get_store_goal(D,E,G),
C=(G,F).
enumerate_store_body(var_assoc_store(_,_),_,_,A) :-
A=fail.
enumerate_store_body(global_singleton,A,B,C) :-
global_singleton_store_name(A,D),
make_get_store_goal(D,B,E),
C=(E,B\==[]).
enumerate_store_body(multi_store(A),B,C,D) :-
( memberchk(global_ground,A) ->
enumerate_store_body(global_ground,B,C,D)
;
once((member(E,A),enumerate_store_body(E,B,C,D)))
).
enumerate_store_body(identifier_store(_),_,_,A) :-
A=fail.
enumerate_store_body(type_indexed_identifier_store(_,_),_,_,A) :-
A=fail.
multi_inthash_enumerate_store_body(A,B,C,D) :-
multi_hash_store_name(B,A,E),
D=(nb_getval(E,F),value_iht(F,C)).
multi_hash_enumerate_store_body(A,B,C,D) :-
multi_hash_store_name(B,A,E),
make_get_store_goal(E,F,G),
D=(G,value_ht(F,C)).
guard_simplification :-
( chr_pp_flag(guard_simplification,on) ->
precompute_head_matchings,
simplify_guards(1)
;
true
).
next_prev_rule(A,B,C) :-
( find_min_q(A,_-D) ->
D=(-B),
normalize_heap(A,D,C)
;
B=0,
C=A
).
normalize_heap(A,B,C) :-
( find_min_q(A,_-B) ->
delete_min_q(A,D,tuple(E,F,_)-_),
( F>1 ->
G is F-1,
get_occurrence(E,G,H,_),
insert_q(D,tuple(E,G,H)-(-H),I)
;
I=D
),
normalize_heap(I,B,C)
;
C=A
).
head_types_modes_condition([],_,true).
head_types_modes_condition([A|B],C,(D,E)) :-
types_modes_condition(C,A,D),
head_types_modes_condition(B,C,E).
add_background_info(A,B) :-
get_bg_info(C),
add_background_info2(A,D),
append(C,D,B).
add_background_info2(A,[]) :-
var(A),
!.
add_background_info2([],[]) :-
!.
add_background_info2([A|B],C) :-
!,
add_background_info2(A,D),
add_background_info2(B,E),
append(D,E,C).
add_background_info2(A,B) :-
( functor(A,_,C),
C>0 ->
A=..[_|D],
add_background_info2(D,E)
;
E=[]
),
get_bg_info(A,F),
append(F,E,B).
normalize_conj_list(A,B) :-
list2conj(A,C),
conj2list(C,B).
compute_derived_info([],_,_,_,_,_,_,_,[],[]).
compute_derived_info([A|B],C,D,E,F,G,H,I,[J|K],[L|M]) :-
copy_term(C-F,N),
variable_replacement(C-F,N,O),
append(A,O,P),
list2conj(C,Q),
negate_b(Q,R),
make_head_matchings_explicit_not_negated2(E,D,S),
list2conj(S,T),
term_variables(P,U),
term_variables(C-F-S,V),
new_vars(V,U,W),
append(P,W,X),
( F==true ->
Y=R
;
negate_b(F,Z),
Y=(R;T,Z)
),
copy_with_variable_replacement(Y,J,X),
copy_with_variable_replacement(F,A1,X),
copy_with_variable_replacement(C,B1,X),
list2conj(B1,C1),
apply_guard_wrt_term(H,A1,D1),
apply_guard_wrt_term(D1,C1,L),
compute_derived_info(B,C,D,E,F,G,H,I,K,M).
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,B,A).
head_subset([A|B],C,D,E,F) :-
head_member(C,A,G,E,H),
head_subset(B,H,D,G,F).
head_member([A|B],C,D,E,F) :-
(
variable_replacement(C,A,E,D),
F=B
;
F=[A|G],
head_member(B,C,D,E,G)
).
make_head_matchings_explicit(A,B,C) :-
make_head_matchings_explicit_memo_lookup(A,D,E),
copy_term_nat(D-E,B-C).
make_head_matchings_explicit_(A,B,C) :-
extract_arguments(A,D),
make_matchings_explicit(D,E,[],[],_,C),
substitute_arguments(A,E,B).
make_head_matchings_explicit_not_negated(A,B,C) :-
extract_arguments(A,D),
make_matchings_explicit_not_negated(D,E,C),
substitute_arguments(A,E,B).
make_head_matchings_explicit_not_negated2(A,B,C) :-
extract_arguments(A,D),
extract_arguments(B,E),
make_matchings_explicit_not_negated(D,E,C).
extract_arguments([],[]).
extract_arguments([A|B],C) :-
A=..[_|D],
append(D,E,C),
extract_arguments(B,E).
substitute_arguments([],[],[]).
substitute_arguments([A|B],C,[D|E]) :-
functor(A,F,G),
split_at(G,C,H,I),
D=..[F|H],
substitute_arguments(B,I,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(B,V),
append(V,E,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) :-
E=[C=A|F],
make_matchings_explicit_not_negated(B,D,F).
apply_guard_wrt_term([],_,[]).
apply_guard_wrt_term([A|B],C,[D|E]) :-
( var(A) ->
apply_guard_wrt_variable(C,A,D)
;
A=..[F|G],
apply_guard_wrt_term(G,C,H),
D=..[F|H]
),
apply_guard_wrt_term(B,C,E).
apply_guard_wrt_variable((A,B),C,D) :-
!,
apply_guard_wrt_variable(A,C,E),
apply_guard_wrt_variable(B,E,D).
apply_guard_wrt_variable(A,B,C) :-
( A=(D=E),
B==D ->
C=E
;
( A=functor(F,G,H),
B==F,
ground(G),
ground(H) ->
functor(C,G,H)
)
;
C=B
).
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),
!,
( common_variables(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)
;
common_variables(I,B-C)
),
guard_entailment:entails_guard(C,H=I) ->
( common_variables(I,D-B-C) ->
G=J,
F=K
;
( common_variables(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,
( common_variables(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).
common_variables(A,B) :-
term_variables(A,C),
term_variables(B,D),
intersect_eq(C,D,E),
E\==[].
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),
( subsumes(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),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
).
extract_explicit_matchings(A=B) :-
var(A),
var(B),
!,
A=B.
extract_explicit_matchings(A==B) :-
var(A),
var(B),
!,
A=B.
assert_constraint_type(A,B) :-
( ground(B) ->
constraint_type(A,B)
;
chr_error(type_error,'Declared argument types "~w" for constraint "~w" must be ground!
',[B,A])
).
get_type_definition_det(A,B) :-
( get_type_definition(A,B) ->
true
;
chr_error(type,'Could not find type definition for type `~w''.
',[A])
).
get_constraint_type_det(A,B) :-
( get_constraint_type(A,B) ->
true
;
A=_/C,
replicate(C,any,B)
).
modes_condition([],[],true).
modes_condition([A|B],[C|D],E) :-
( A== + ->
E=(ground(C),F)
;
( A== - ->
E=(var(C),F)
)
;
E=F
),
modes_condition(B,D,F).
types_condition([],[],[],[],true).
types_condition([A|B],[C|D],[E|F],[G|H],(I,J)) :-
( G== - ->
K=[true]
;
get_type_definition_det(A,L),
type_condition(L,C,E,G,M),
( G== + ->
K=M
;
K=[\+ground(C)|M]
)
),
list2disj(K,I),
types_condition(B,D,F,H,J).
type_condition([],_,_,_,[]).
type_condition([A|B],C,D,E,[F|G]) :-
( var(A) ->
chr_error(type,'Unexpected variable type in type definition!
',[])
;
( atomic_builtin_type(A,C,F) ->
true
)
;
( compound_builtin_type(A,C,F,_) ->
true
)
;
type_def_case_condition(A,C,D,E,F)
),
type_condition(B,C,D,E,G).
atomic_builtin_type(any,_,true).
atomic_builtin_type(dense_int,A,(integer(A),A>=0)).
atomic_builtin_type(int,A,integer(A)).
atomic_builtin_type(number,A,number(A)).
atomic_builtin_type(float,A,float(A)).
atomic_builtin_type(natural,A,(integer(A),A>=0)).
atomic_builtin_type(chr_identifier,_,true).
compound_builtin_type(chr_constants(_),_,true,true).
compound_builtin_type(chr_constants(_,_),_,true,true).
compound_builtin_type(chr_identifier(_),_,true,true).
compound_builtin_type(chr_enum(A),B,(ground(B),memberchk(B,A)),once((member(C,A),unifiable(B,C,_)))).
is_chr_constants_type(chr_constants(A),A,no).
is_chr_constants_type(chr_constants(A,B),A,yes(B)).
type_def_case_condition(A,B,C,D,E) :-
( nonvar(A) ->
functor(A,F,G),
( G==0 ->
E=(B=A)
;
( var(C) ->
E=functor(B,F,G)
)
;
( functor(C,F,G) ->
E=(functor(B,F,G),B=H,I),
A=..[_|J],
C=..[_|K],
functor(H,F,G),
H=..[_|L],
replicate(G,D,M),
types_condition(J,L,K,M,I)
)
;
E=functor(B,F,G)
)
;
chr_error(internal,'Illegal type definition (must be nonvar).
',[])
).
static_type_check_heads([]).
static_type_check_heads([A|B]) :-
static_type_check_head(A),
static_type_check_heads(B).
static_type_check_head(A) :-
functor(A,B,C),
get_constraint_type_det(B/C,D),
A=..[_|E],
maplist(static_type_check_term(head(A)),E,D).
static_type_check_body([]).
static_type_check_body([A|B]) :-
functor(A,C,D),
get_constraint_type_det(C/D,E),
A=..[_|F],
maplist(static_type_check_term(body(A)),F,E),
static_type_check_body(B).
format_src(head(A)) :-
format('head ~w',[A]).
format_src(body(A)) :-
format('body goal ~w',[A]).
generate_dynamic_type_check_clauses(A) :-
( chr_pp_flag(debugable,on) ->
dynamic_type_check,
get_dynamic_type_check_clauses(B),
append(B,[('$dynamic_type_check'(C,D):-throw(error(type_error(C,D),context(_,'CHR Runtime Type Error'))))],A)
;
A=[]
).
dynamic_type_check_clause(A,B,C) :-
copy_term(A-B,D-E),
functor(E,F,G),
functor(H,F,G),
E=..[_|I],
H=..[_|J],
maplist(dynamic_type_check_call,I,J,K),
list2conj(K,L),
C=('$dynamic_type_check'(D,H):-L).
dynamic_type_check_alias_clause(A,B,C) :-
C=('$dynamic_type_check'(A,D):-'$dynamic_type_check'(B,D)).
dynamic_type_check_call(A,B,C) :-
( A==any ->
C=true
;
C=when(nonvar(B),once('$dynamic_type_check'(A,B)))
).
atomic_types_suspended_constraint(A) :-
A=_/B,
get_constraint_type(A,C),
get_constraint_mode(A,D),
numlist(1,B,E),
maplist(atomic_types_suspended_constraint(A),C,D,E).
atomic_types_suspended_constraint(A,B,C,D) :-
( is_indexed_argument(A,D) ->
( C== ? ->
atomic_type(B)
;
true
)
;
true
).
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 ->
stored(G,B,maybe)
;
stored(G,B,yes)
).
constraints_code(A,B) :-
( chr_pp_flag(reduced_indexing,on),
forall(C,A,chr_translate:only_ground_indexed_arguments(C)) ->
none_suspended_on_variables
;
true
),
constraints_code1(A,B,[]).
constraint_prelude(A/B,C) :-
vars_susp(B,D,E,F),
G=..[A|D],
make_suspension_continuation_goal(A/B,F,H),
build_head(A,B,[0],F,I),
( chr_pp_flag(debugable,on) ->
insert_constraint_goal(A/B,E,D,J),
attach_constraint_atom(A/B,K,E,L),
delay_phase_end(validate_store_type_assumptions,chr_translate:update_suspension_field(A/B,E,state,inactive,M)),
insert_constraint_internal_constraint_goal(A/B,K,E,H,D,N),
( get_constraint_type(A/B,O) ->
maplist(dynamic_type_check_call,O,D,P),
list2conj(P,Q)
;
Q=true
),
C=(G:-Q,N,J,L,M,'chr debug_event'(insert(G#E)),('chr debug_event'(call(E)),I;'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,R,F,D,E),
delay_phase_end(validate_store_type_assumptions,chr_translate:update_suspension_field(A/B,E,state,inactive,M)),
C=(G:-R,M,I)
)
;
C=(G:-I)
).
make_suspension_continuation_goal(A/B,C,D) :-
( may_trigger(A/B) ->
build_head(A,B,[0],C,E),
( chr_pp_flag(debugable,off) ->
D=E
;
get_target_module(F),
D=F:E
)
;
D=true
).
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 ->
( only_ground_indexed_arguments(A/B) ->
gen_insert_constraint_internal_goal(A/B,H,I,J,K)
;
gen_cond_attach_goal(A/B,H,I,J,K)
)
;
vars_susp(B,J,K,I),
gen_uncond_attach_goal(A/B,K,J,H,_)
),
build_head(A,B,C,I,L),
M=(L:-H),
add_dummy_location(M,N),
D=[N|E]
;
D=E
).
gen_cond_attach_goal(A/B,C,D,E,F) :-
vars_susp(B,E,F,D),
make_suspension_continuation_goal(A/B,D,G),
( get_store_type(A/B,var_assoc_store(_,_)) ->
H=true
;
attach_constraint_atom(A/B,I,F,H)
),
_=..[A|E],
insert_constraint_goal(A/B,F,E,J),
insert_constraint_internal_constraint_goal(A/B,I,F,G,E,K),
( may_trigger(A/B) ->
activate_constraint_goal(A/B,(J,H),I,F,_,L),
C=(var(F)->K,J,H;L)
;
C=(K,J,H)
).
gen_insert_constraint_internal_goal(A/B,C,D,E,F) :-
vars_susp(B,E,F,D),
make_suspension_continuation_goal(A/B,D,G),
( \+only_ground_indexed_arguments(A/B),
\+get_store_type(A/B,var_assoc_store(_,_)) ->
attach_constraint_atom(A/B,H,F,I)
;
I=true
),
_=..[A|E],
insert_constraint_goal(A/B,F,E,J),
insert_constraint_internal_constraint_goal(A/B,H,F,G,E,K),
( only_ground_indexed_arguments(A/B),
chr_pp_flag(debugable,off) ->
C=(K,J)
;
C=(K,J,I)
).
gen_uncond_attach_goal(A,B,C,D,E) :-
( \+only_ground_indexed_arguments(A),
\+get_store_type(A,var_assoc_store(_,_)) ->
attach_constraint_atom(A,F,B,G)
;
G=true
),
insert_constraint_goal(A,B,C,H),
( chr_pp_flag(late_allocation,on) ->
activate_constraint_goal(A,(H,G),F,B,E,D)
;
activate_constraint_goal(A,true,F,B,E,D)
).
head1_code(A,B,C,D,E,F,G,H,I,J) :-
E=pragma(K,_,_,_,L),
K=rule(_,M,_,_),
( M==[] ->
reorder_heads(L,A,C,D,N,O),
simplification_code(A,B,N,O,E,F,G,H,I,J)
;
simpagation_head1_code(A,B,C,D,E,F,G,H,I,J)
).
head2_code(A,B,C,D,E,F,G,H,I,J) :-
E=pragma(K,_,_,_,L),
K=rule(M,_,_,_),
( M==[] ->
reorder_heads(L,A,C,D,N,O),
propagation_code(A,B,N,O,K,L,F,G,H,I,J)
;
simpagation_head2_code(A,B,C,D,E,F,G,H,I,J)
).
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,M),
N=(J:-M,L),
add_dummy_location(N,O),
E=[O|F].
gen_occ_allocation(A,B,C,D,E) :-
get_allocation_occurrence(A,F),
get_occurrence_code_id(A,F,G),
get_occurrence_code_id(A,B,H),
( chr_pp_flag(debugable,off),
H==G ->
allocate_constraint_goal(A,D,C,I),
( may_trigger(A) ->
E=(var(D)->I;true)
;
E=I
)
;
E=true
).
gen_occ_allocation_in_guard(A,B,C,D,E) :-
get_allocation_occurrence(A,F),
( chr_pp_flag(debugable,off),
B<F ->
allocate_constraint_goal(A,D,C,G),
( may_trigger(A) ->
E=(var(D)->G;true)
;
E=G
)
;
E=true
).
guard_via_reschedule_new(A,B,C,D,E,F) :-
( chr_pp_flag(guard_via_reschedule,on) ->
guard_via_reschedule_main_new(A,B,C,D,E,G),
list2conj(G,F)
;
length(A,H),
length(E,H),
length(B,I),
length(D,I),
append(E,D,J),
list2conj(J,F)
).
guard_via_reschedule_main_new(A,B,C,D,E,F) :-
initialize_unit_dictionary(C,G),
maplist(wrap_in_functor(lookup),A,H),
maplist(wrap_in_functor(guard),B,I),
build_units(H,I,G,J),
dependency_reorder(J,K),
wrappedunits2lists(K,L,E,F),
sort(L,M),
snd_of_pairs(M,D).
wrappedunits2lists([],[],[],[]).
wrappedunits2lists([unit(A,B,_,_)|C],D,E,F) :-
F=[G|H],
( B=lookup(I) ->
E=[G|J],
D=K
;
( B=guard(I) ->
D=[A-G|K],
E=J
)
),
wrappedunits2lists(C,K,J,H).
guard_splitting(A,B) :-
A=rule(C,D,E,_),
append(C,D,F),
conj2list(E,G),
term_variables(F,H),
split_off_simple_guard_new(G,H,I,J),
append(I,[K],B),
term_variables(J,L),
ground_vars(F,M),
list_difference_eq(H,M,N),
intersect_eq(N,L,O),
( chr_pp_flag(guard_locks,on),
bagof('chr lock'(P)-'chr unlock'(P),lists:member(P,O),Q) ->
once(pairup(R,S,Q))
;
R=[],
S=[]
),
list2conj(R,T),
list2conj(S,U),
list2conj(J,V),
K=(T,V,U).
guard_body_copies3(A,B,C,D,E) :-
A=rule(_,_,_,F),
my_term_copy(B,C,G,D),
my_term_copy(F,G,E).
split_off_simple_guard_new([],_,[],[]).
split_off_simple_guard_new([A|B],C,D,E) :-
( simple_guard_new(A,C) ->
D=[A|F],
split_off_simple_guard_new(B,C,F,E)
;
D=[],
E=[A|B]
).
simple_guard_new(A,B) :-
builtin_binds_b(A,C),
\+ (member(D,C),memberchk_eq(D,B)).
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,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) :-
( fail,
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),
\+ (member(O,N),lookup_eq(M,O,P),memberchk_eq(P,N)),
select_pragma_unique_variables(N,M,Q),
copy_term_nat(K-Q,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) :-
( fail,
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_simplification(G,D,[],[],C,F),
symmetry_analysis_heads_propagation(H,E,[],[],C,F)
;
true
),
symmetry_analysis_main(B).
symmetry_analysis_heads_simplification([],[],_,_,_,_).
symmetry_analysis_heads_simplification([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_guarded_rules(G,L) ->
passive(H,C)
;
true
),
symmetry_analysis_heads_simplification(B,D,[A|E],[C|F],G,H).
symmetry_analysis_heads_propagation([],[],_,_,_,_).
symmetry_analysis_heads_propagation([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_propagation(B,D,[A|E],[C|F],G,H).
simplification_code(A,B,C,D,E,F/G,H,I,J,K) :-
E=pragma(L,_,_,_,M),
head_info(A,G,_,N,O,P),
build_head(F,G,I,O,Q),
get_constraint_mode(F/G,R),
head_arg_matches(P,R,[],S,T,[],U),
guard_splitting(L,V),
( is_stored_in_guard(F/G,M) ->
W=[_|V]
;
W=V
),
guard_via_reschedule_new(C,W,A,X,Y,Z),
rest_heads_retrieval_and_matching(C,D,A,Y,A1,T,B1,[],[],[],U,_),
guard_body_copies3(L,W,B1,X,C1),
( is_stored_in_guard(F/G,M) ->
gen_occ_allocation_in_guard(F/G,H,D1,N,E1),
gen_uncond_attach_goal(F/G,N,D1,F1,_),
X=[G1|_],
G1=(E1,F1)
;
true
),
partner_constraint_detachments(A1,C,B1,H1),
active_constraint_detachment(I,N,A,B1,I1),
( chr_pp_flag(debugable,on) ->
L=rule(_,_,J1,K1),
my_term_copy(J1-K1,B1,L1-M1),
sort_by_key([N|A1],[B|D],N1),
O1='chr debug_event'(try(N1,[],L1,M1)),
P1='chr debug_event'(apply(N1,[],L1,M1)),
instrument_goal(Q1,O1,P1,R1)
;
R1=Q1
),
( unconditional_occurrence(F/G,H),
chr_pp_flag(late_allocation,on) ->
Q1=true
;
Q1=!
),
S1=(Q:-S,Z,R1,H1,I1,C1),
add_location(S1,M,T1),
J=[T1|K].
add_location(A,B,C) :-
( chr_pp_flag(line_numbers,on) ->
get_chr_source_file(D),
get_line_number(B,E),
C='$source_location'(D,E):A
;
C=A
).
add_dummy_location(A,B) :-
( chr_pp_flag(line_numbers,on) ->
get_chr_source_file(C),
B='$source_location'(C,1):A
;
B=A
).
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_([silent(A-_)|B],[C|D],E,F,G,H,I) :-
!,
( C== + ->
term_variables(A,J,F),
head_arg_matches_(B,D,E,J,G,H,I)
;
head_arg_matches_(B,D,E,F,G,H,I)
).
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
;
( ground(A),
A='$chr_identifier_match'(Q,R) ->
identifier_label_atom(R,B,Q,S),
H=[S|L],
F=N,
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,T,F),
H=[B=T|L],
F=N,
M=G,
O=C,
P=E
)
;
( D== ?,
is_ground(G,A) ->
copy_with_variable_replacement(A,T,F),
H=[B==T|L],
F=N,
M=G,
O=C,
P=E
)
;
A=..[_|U],
functor(A,V,W),
functor(X,V,W),
X=..[_|Y],
( D= + ->
H=[B=X|L]
;
H=[nonvar(B),B=X|L]
),
pairup(U,Y,Z),
append(Z,C,O),
replicate(W,D,A1),
append(A1,E,P),
N=F,
M=G
),
head_arg_matches_(O,P,N,M,L,I,J).
add_heads_types([],A,A).
add_heads_types([A|B],C,D) :-
add_head_types(A,C,E),
add_heads_types(B,E,D).
add_head_types(A,B,C) :-
functor(A,D,E),
get_constraint_type_det(D/E,F),
A=..[_|G],
add_args_types(G,F,B,C).
add_args_types([],[],A,A).
add_args_types([A|B],[C|D],E,F) :-
add_arg_types(A,C,E,G),
add_args_types(B,D,G,F).
add_arg_types(A,B,C,D) :-
( var(A) ->
( lookup_eq(C,A,_) ->
D=C
;
D=[A-B|C]
)
;
( ground(A) ->
D=C
)
;
term_variables(A,E),
length(E,F),
replicate(F,any,G),
add_args_types(E,G,C,D)
).
add_heads_ground_variables([],A,A).
add_heads_ground_variables([A|B],C,D) :-
add_head_ground_variables(A,C,E),
add_heads_ground_variables(B,E,D).
add_head_ground_variables(A,B,C) :-
functor(A,D,E),
get_constraint_mode(D/E,F),
A=..[_|G],
add_arg_ground_variables(G,F,B,C).
add_arg_ground_variables([],[],A,A).
add_arg_ground_variables([A|B],[C|D],E,F) :-
( C== + ->
term_variables(A,G),
add_var_ground_variables(G,E,H)
;
E=H
),
add_arg_ground_variables(B,D,H,F).
add_var_ground_variables([],A,A).
add_var_ground_variables([A|B],C,D) :-
( memberchk_eq(A,C) ->
E=C
;
E=[A|C]
),
add_var_ground_variables(B,E,D).
is_ground(A,B) :-
( ground(B) ->
true
;
( compound(B) ->
B=..[_|C],
maplist(is_ground(A),C)
)
;
memberchk_eq(B,A)
).
check_ground(A,B,C) :-
term_variables(B,D),
check_ground_variables(D,A,C).
check_ground_variables([],_,true).
check_ground_variables([A|B],C,D) :-
( memberchk_eq(A,C) ->
check_ground_variables(B,C,D)
;
D=(ground(A),E),
check_ground_variables(B,C,E)
).
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,B).
rest_heads_retrieval_and_matching_n([A|B],[_|C],D,E,F,[G|H],[I|J],K,L,_,M,N) :-
functor(A,O,P),
head_info(A,P,Q,_,_,R),
get_store_type(O/P,S),
( S==default ->
passive_head_via(A,[F|D],K,T,U),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(O/P,V),get_static_suspension_term_field(arguments,O/P,V,Q),get_static_suspension_field(O/P,V,state,active,W))),
get_constraint_mode(O/P,X),
head_arg_matches(R,X,K,Y,Z,M,A1),
B1=R,
sbag_member_call(I,U,C1),
D1=(T,C1,I=V,W)
;
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(O/P,V),get_static_suspension_term_field(arguments,O/P,V,Q))),
existential_lookup(S,A,[F|D],K,M,V,D1,I,R,B1),
get_constraint_mode(O/P,X),
E1=X,
head_arg_matches(B1,E1,K,Y,Z,M,A1)
),
different_from_other_susps(A,I,D,E,F1),
filter_append(B1,Z,G1),
translate(A1,G1,H1),
translate(A1,Z,I1),
inline_matching_goal(Y,J1,H1,I1),
G=(D1,F1,J1),
rest_heads_retrieval_and_matching_n(B,C,[A|D],[I|E],F,H,J,Z,L,_,A1,N).
inline_matching_goal(A==B,true,C,D) :-
memberchk_eq(A,C),
memberchk_eq(B,D),
A=B,
!.
inline_matching_goal((A,B),(C,D),E,F) :-
!,
inline_matching_goal(A,C,E,F),
inline_matching_goal(B,D,E,F).
inline_matching_goal(A,A,_,_).
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)
).
filter_append([],A,A).
filter_append([A|B],C,D) :-
( A=silent(_) ->
filter_append(B,C,D)
;
D=[A|E],
filter_append(B,C,E)
).
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) :-
functor(A,F,G),
get_constraint_index(F/G,_),
common_variables(A,B,H),
ground_vars([A],I),
list_difference_eq(H,I,J),
global_list_store_name(F/G,K),
L=nb_getval(K,E),
get_constraint_mode(F/G,M),
( N==[] ->
D=L
;
( member(O,J),
nth1(P,M,-),
arg(P,A,Q),
Q==O ->
translate([O],C,[R]),
gen_get_mod_constraints(F/G,R,S,E),
D=S
)
;
translate(J,C,N),
add_heads_types(B,[],T),
my_term_copy(T,C,U),
gen_get_mod_constraints(F/G,N,U,V,S,E),
D=(V->S;L)
).
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,D,E,F) :-
via_goal(B,C,D,G),
get_target_module(H),
E=(get_attr(G,H,I),J),
get_max_constraint_index(K),
( K==1 ->
J=true,
F=I
;
get_constraint_index(A,L),
get_suspensions(K,L,I,J,F)
).
via_goal(A,B,C,D) :-
( A=[] ->
C=fail
;
( A=[E] ->
lookup_eq(B,E,F),
( atomic_type(F) ->
C=var(E),
E=D
;
C='chr newvia_1'(E,D)
)
)
;
( A=[E,G] ->
C='chr newvia_2'(E,G,D)
)
;
C='chr newvia'(A,D)
).
gen_get_mod_constraints(A,B,C,D) :-
get_target_module(E),
C=(get_attr(B,E,F),G),
get_max_constraint_index(H),
( H==1 ->
G=true,
D=F
;
get_constraint_index(A,I),
get_suspensions(H,I,F,G,D)
).
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,G),
conj2list(F,H),
split_off_simple_guard(H,B,I,J),
my_term_copy(I-J,B,K,L-M),
append(L,[N],C),
term_variables(J,O),
term_variables(M,P),
ground_vars(E,Q),
list_difference_eq(O,Q,R),
( chr_pp_flag(guard_locks,on),
bagof('chr lock'(S)-'chr unlock'(S),T^(lists:member(T,R),pairlist:lookup_eq(B,T,S),memberchk_eq(S,P)),U) ->
once(pairup(V,W,U))
;
V=[],
W=[]
),
list2conj(V,X),
list2conj(W,Y),
list2conj(M,Z),
N=(X,Z,Y),
my_term_copy(G,K,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,_)).
active_constraint_detachment(A,B,C,D,E) :-
functor(C,F,G),
H=F/G,
( is_stored(H) ->
(
(
A==[0],
chr_pp_flag(store_in_guards,off)
;
get_allocation_occurrence(H,I),
get_max_occurrence(H,J),
J<I
),
only_ground_indexed_arguments(H),
chr_pp_flag(late_allocation,on) ->
E=true
;
gen_uncond_susp_detachment(C,B,active,D,K),
( chr_pp_flag(late_allocation,on) ->
E=(var(B)->true;K)
;
E=K
)
)
;
E=true
).
partner_constraint_detachments([],[],_,true).
partner_constraint_detachments([A|B],[C|D],E,(F,G)) :-
gen_uncond_susp_detachment(C,A,partner,E,F),
partner_constraint_detachments(B,D,E,G).
gen_uncond_susp_detachment(A,B,C,D,E) :-
functor(A,F,G),
H=F/G,
( is_stored(H) ->
E=(I,J),
( chr_pp_flag(debugable,on) ->
I='chr debug_event'(remove(B))
;
I=true
),
remove_constraint_goal(H,B,K,true,(L,M),C,J),
delete_constraint_goal(A,B,D,L),
( \+only_ground_indexed_arguments(H),
\+get_store_type(H,var_assoc_store(_,_)) ->
detach_constraint_atom(H,K,B,M)
;
M=true
)
;
E=true
).
simpagation_head1_code(A,B,C,D,E,F/G,_,H,I,J) :-
E=pragma(K,ids(_,L),_,_,M),
K=rule(_,N,O,P),
head_info(A,G,Q,R,S,T),
get_constraint_mode(F/G,U),
head_arg_matches(T,U,[],V,W,[],X),
build_head(F,G,H,S,Y),
append(C,N,Z),
append(D,L,A1),
reorder_heads(M,A,Z,A1,B1,C1),
guard_splitting(K,D1),
( is_stored_in_guard(F/G,M) ->
E1=[_|D1]
;
E1=D1
),
guard_via_reschedule_new(B1,E1,A,F1,G1,H1),
rest_heads_retrieval_and_matching(B1,C1,A,G1,I1,W,J1,[],[],[],X,_),
split_by_ids(C1,I1,D,K1,L1,M1,N1),
guard_body_copies3(K,E1,J1,F1,O1),
( is_stored_in_guard(F/G,M) ->
gen_uncond_attach_goal(F/G,R,Q,P1,_),
F1=[Q1|_],
Q1=P1
;
true
),
sort_by_key(K1,L1,R1),
partner_constraint_detachments(R1,C,J1,S1),
active_constraint_detachment(H,R,A,J1,T1),
( chr_pp_flag(debugable,on) ->
my_term_copy(O-P,J1,U1-V1),
sort_by_key([R|K1],[B|L1],W1),
sort_by_key(M1,N1,X1),
Y1='chr debug_event'(try(W1,X1,U1,V1)),
Z1='chr debug_event'(apply(W1,X1,U1,V1)),
instrument_goal(!,Y1,Z1,A2)
;
A2=!
),
B2=(Y:-V,H1,A2,S1,T1,O1),
add_location(B2,M,C2),
I=[C2|J].
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).
split_by_ids([],[],_,[],[],[],[]).
split_by_ids([A|B],[C|D],E,F,G,H,I) :-
( memberchk_eq(A,E) ->
F=[C|J],
G=[A|K],
H=L,
I=M
;
F=J,
G=K,
H=[C|L],
I=[A|M]
),
split_by_ids(B,D,E,J,K,L,M).
simpagation_head2_code(A,B,C,D,E,F,G,H,I,J) :-
E=pragma(K,ids(L,M),_,_,N),
K=rule(O,_,P,Q),
append(O,C,R),
append(L,D,S),
reorder_heads(N,A,R,S,[T|U],[V|W]),
simpagation_head2_prelude(A,T,[U,P,Q],F,G,H,I,X),
extend_id(H,Y),
( memberchk_eq(V,M) ->
simpagation_universal_searches(U,W,M,[T,A],K,F,G,Z,A1,B1,Y,C1,X,D1)
;
X=D1,
Y=C1,
Z=U,
A1=[T,A],
B1=W
),
universal_search_iterator_end(A1,Z,K,F,G,C1,D1,E1),
simpagation_head2_worker(A1,Z,B1,B,E,F,G,C1,E1,J).
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,O) :-
A=[P|Q],
inc_id(L,R),
universal_search_iterator_end(E,A,F,G,H,L,N,S),
universal_search_iterator(A,E,F,G,H,L,S,T),
( memberchk_eq(B,D) ->
simpagation_universal_searches(Q,C,D,[P|E],F,G,H,I,J,K,R,M,T,O)
;
M=R,
T=O,
I=Q,
J=[P|E],
C=K
).
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,[],R),
lookup_passive_head(B,[A],Q,R,S,T),
gen_occ_allocation(D/E,F,J,K,U),
extend_id(G,V),
extra_active_delegate_variables(A,[B|C],Q,W),
append([T|L],W,X),
build_head(D,E,[F|V],X,Y),
Z=(N:-P,S,!,U,Y),
add_dummy_location(Z,A1),
H=[A1|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_worker([A|B],C,D,_,E,F/G,H,I,J,K) :-
E=pragma(L,ids(M,_),N,_,O),
L=rule(_,_,P,Q),
get_prop_inner_loop_vars(B,[A,C,P,Q],R,S,T,U,V),
gen_var(W),
gen_var(X),
functor(A,Y,Z),
gen_vars(Z,A1),
head_info(A,Z,A1,W,_,B1),
get_constraint_mode(Y/Z,C1),
head_arg_matches(B1,C1,S,D1,E1,[],_),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(Y/Z,F1),get_static_suspension_field(Y/Z,F1,state,active,G1),get_static_suspension_term_field(arguments,Y/Z,F1,A1))),
different_from_other_susps(A,W,B,V,H1),
I1=(W=F1,G1,H1,D1),
J1=[[W|X]|R],
build_head(F,G,[H|I],J1,K1),
guard_splitting(L,L1),
( is_stored_in_guard(F/G,O) ->
M1=[_|L1]
;
M1=L1
),
guard_via_reschedule_new(C,M1,[A|B],N1,O1,P1),
rest_heads_retrieval_and_matching(C,D,[A|B],O1,Q1,E1,R1,[A|B],[W|V],[]),
split_by_ids(D,Q1,M,S1,T1),
split_by_ids(D,C,M,U1,_),
partner_constraint_detachments([W|S1],[A|U1],R1,V1),
W1=[X|R],
build_head(F,G,[H|I],W1,X1),
Y1=[[]|R],
build_head(F,G,[H|I],Y1,Z1),
guard_body_copies3(L,M1,R1,N1,A2),
( is_stored_in_guard(F/G,O) ->
N1=[B2|_]
;
true
),
( is_observed(F/G,H) ->
gen_uncond_attach_goal(F/G,T,U,C2,D2),
gen_state_cond_call(T,F/G,X1,D2,E2),
gen_state_cond_call(T,F/G,Z1,D2,F2)
;
C2=true,
E2=X1,
F2=Z1
),
( chr_pp_flag(debugable,on) ->
my_term_copy(P-Q,S,G2-H2),
I2='chr debug_event'(try([W|S1],[T|T1],G2,H2)),
J2='chr debug_event'(apply([W|S1],[T|T1],G2,H2))
;
I2=true,
J2=true
),
( is_stored_in_guard(F/G,O) ->
B2=C2,
K2=true
;
B2=true,
K2=C2
),
( member(unique(_,L2),N),
check_unique_keys(L2,S) ->
M2=(K1:-I1->(P1,I2->J2,V1,K2,A2,F2;Z1);X1)
;
M2=(K1:-I1,P1,I2->J2,V1,K2,A2,E2;X1)
),
add_location(M2,O,N2),
J=[N2|K].
gen_state_cond_call(A,B,C,D,E) :-
( may_trigger(B) ->
does_use_field(B,generation),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(B,F),get_update_static_suspension_field(B,A,F,state,active,inactive,G,H),get_static_suspension_field(B,F,generation,D,I),get_static_suspension_term_field(arguments,B,F,J)))
;
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(B,F),get_update_static_suspension_field(B,A,F,state,active,inactive,G,H),get_static_suspension_term_field(arguments,B,F,J))),
I=true
),
E=(A=F,G,I->H,C;true).
propagation_code(A,B,C,D,E,F,G,H,I,J,K) :-
( C==[] ->
propagation_single_headed(A,B,E,F,G,H,I,J,K)
;
propagation_multi_headed(A,C,D,E,F,G,H,I,J,K)
).
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),
V=P,
( unconditional_occurrence(D/E,F),
chr_pp_flag(late_allocation,on) ->
W=true
;
W=!
),
B=rule(_,_,X,Y),
( chr_pp_flag(debugable,on) ->
my_term_copy(X-Y,S,Z-A1),
B1='chr debug_event'(try([],[K],Z,A1)),
C1='chr debug_event'(apply([],[K],Z,A1)),
instrument_goal(W,B1,C1,D1)
;
D1=W
),
( may_trigger(D/E),
\+has_no_history(C) ->
use_auxiliary_predicate(novel_production),
use_auxiliary_predicate(extend_history),
does_use_history(D/E,F),
gen_occ_allocation(D/E,F,J,K,E1),
( named_history(C,F1,G1) ->
( G1==[] ->
empty_named_history_novel_production(F1,H1),
empty_named_history_extend_history(F1,I1)
;
J1=F1
)
;
J1=C
),
( var(H1) ->
H1='$novel_production'(K,J1),
I1='$extend_history'(K,J1)
;
true
),
( is_observed(D/E,F) ->
gen_uncond_attach_goal(D/E,K,J,K1,L1),
gen_state_cond_call(K,D/E,V,L1,M1)
;
K1=true,
M1=V
)
;
E1=true,
H1=true,
I1=true,
( is_observed(D/E,F) ->
get_allocation_occurrence(D/E,N1),
( F==N1 ->
gen_insert_constraint_internal_goal(D/E,K1,L,J,K),
L1=0
;
K1=(O1,P1),
gen_occ_allocation(D/E,F,J,K,O1),
gen_uncond_attach_goal(D/E,K,J,P1,L1)
),
gen_state_cond_call(K,D/E,V,L1,M1)
;
gen_occ_allocation(D/E,F,J,K,K1),
M1=V
)
),
( is_stored_in_guard(D/E,C) ->
Q1=K1,
R1=true
;
Q1=true,
R1=K1
),
S1=(N:-R,E1,H1,Q1,T,D1,I1,R1,U,M1),
add_location(S1,C,T1),
H=[T1|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,[],S),
D=rule(_,_,T,U),
extra_active_delegate_variables(A,[B,C,T,U],R,V),
lookup_passive_head(B,[A],R,S,W,X),
gen_occ_allocation(E/F,G,K,L,Y),
extend_id(H,Z),
append([X|M],V,A1),
build_head(E,F,[G|Z],A1,B1),
C1=B1,
D1=(O:-Q,W,!,Y,C1),
add_dummy_location(D1,E1),
I=[E1|J].
propagation_nested_code([],[A|B],C,D,E,F,G,H,I,J) :-
universal_search_iterator_end([A|B],[],D,F,G,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,H,I,J,L),
universal_search_iterator([A|B],C,E,G,H,I,L,M),
inc_id(I,N),
propagation_nested_code(B,[A|C],D,E,F,G,H,N,M,K).
check_fd_lookup_condition(A,B,_,_) :-
get_store_type(A/B,global_singleton),
!.
check_fd_lookup_condition(A,B,C,D) :-
\+may_trigger(A/B),
get_functional_dependency(A/B,1,E,F),
copy_term(E-F,C-G),
term_variables(D,H),
intersect_eq(G,H,G),
!.
propagation_body(A,B,C,D,E,F/G,H,I,J,K) :-
D=rule(_,L,M,N),
gen_var_susp_list_for_b(B,[A,M,N],O,P,Q,R,S),
flatten(P,T),
init(R,U),
last(R,V),
gen_var(W),
gen_var(X),
functor(A,Y,Z),
gen_vars(Z,A1),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(Y/Z,B1),get_static_suspension_field(Y/Z,B1,state,active,C1),get_static_suspension_term_field(arguments,Y/Z,B1,A1))),
D1=(W=B1,C1),
E1=[[W|X]|T],
build_head(F,G,[H|I],E1,F1),
( check_fd_lookup_condition(Y,Z,A,B) ->
universal_search_iterator_failure_vars(B,I,P,Q,S,G1,H1),
I1=G1
;
I1=[X|T],
H1=I
),
( H1=[_] ->
J1=H1
;
J1=[H|H1]
),
build_head(F,G,J1,I1,K1),
L1=K1,
A=..[_|M1],
pairup(M1,A1,N1),
get_constraint_mode(Y/Z,O1),
head_arg_matches(N1,O1,O,P1,Q1),
different_from_other_susps(A,W,B,U,R1),
guard_body_copies(D,Q1,S1,T1),
get_occurrence(F/G,H,_,U1),
( is_observed(F/G,H) ->
init(Q,V1),
gen_uncond_attach_goal(F/G,V,V1,W1,X1),
gen_state_cond_call(V,F/G,L1,X1,Y1)
;
W1=true,
Y1=L1
),
(
(
is_least_occurrence(E)
;
has_no_history(E)
) ->
Z1=true,
A2=true
;
( \+may_trigger(F/G),
maplist(is_passive(E),C) ->
Z1=true,
A2=true
)
;
get_occurrence(F/G,H,_,U1),
use_auxiliary_predicate(novel_production),
use_auxiliary_predicate(extend_history),
does_use_history(F/G,H),
( named_history(E,B2,C2) ->
( C2==[] ->
empty_named_history_novel_production(B2,Z1),
empty_named_history_extend_history(B2,A2)
;
reverse([W|U],D2),
named_history_susps(C2,[U1|C],[V|D2],E2),
E2=[F2|_],
( length(C2,1) ->
A2='$extend_history'(F2,B2),
Z1='$novel_production'(F2,B2)
;
findall(G2,(member(H2,C2),get_occurrence_from_id(G2,_,E,H2)),I2),
J2=..[t,B2|E2]
)
)
;
F2=V,
maplist(extract_symbol,L,I2),
sort([U1|C],C2),
history_susps(C,[W|U],V,U1,E2),
J2=..[t,E|E2]
),
( var(Z1) ->
novel_production_calls(I2,C2,E2,E,K2,L2),
A2='$extend_history'(F2,K2),
Z1=(K2=J2,L2)
;
true
)
),
( chr_pp_flag(debugable,on) ->
D=rule(_,_,M,N),
my_term_copy(M-N,Q1,M2-N2),
get_occurrence(F/G,H,_,U1),
sort_by_key([V,W|U],[U1|C],O2),
P2='chr debug_event'(try([],O2,M2,N2)),
Q2='chr debug_event'(apply([],O2,M2,N2))
;
P2=true,
Q2=true
),
( is_stored_in_guard(F/G,E) ->
R2=W1,
S2=true
;
R2=true,
S2=W1
),
T2=(F1:-D1,R1,P1,Z1,R2,S1,P2->Q2,A2,S2,T1,Y1;L1),
add_location(T2,E,U2),
J=[U2|K].
extract_symbol(A,B/C) :-
functor(A,B,C).
novel_production_calls([],[],[],_,_,true).
novel_production_calls([A|B],[C|D],[E|F],G,H,(I,J)) :-
get_occurrence_from_id(A,K,G,C),
delay_phase_end(validate_store_type_assumptions,novel_production_call(A,K,'$novel_production'(E,H),I)),
novel_production_calls(B,D,F,G,H,J).
history_susps(A,B,C,D,E) :-
reverse(B,F),
sort_by_key([C|F],[D|A],E).
named_history_susps([],_,_,[]).
named_history_susps([A|B],C,D,[E|F]) :-
select2(A,E,C,D,G,H),
!,
named_history_susps(B,G,H,F).
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).
gen_var_susp_list_for_b([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_b([A|B],C,D,[E|F],G,[H|I],[J|K]) :-
gen_var_susp_list_for_b(B,[A|C],L,F,G,I,K),
functor(A,M,N),
gen_var(J),
head_info(A,N,_,H,_,O),
get_constraint_mode(M/N,P),
head_arg_matches(O,P,L,_,D),
passive_delegate_variables(A,B,C,D,Q),
append(Q,[H,J],E).
get_prop_inner_loop_vars([A],B,C,D,E,F,[]) :-
!,
functor(A,G,H),
head_info(A,H,F,E,I,J),
get_constraint_mode(G/H,K),
head_arg_matches(J,K,[],_,D),
extra_active_delegate_variables(A,B,D,L),
append(I,L,C).
get_prop_inner_loop_vars([A|B],C,D,E,F,G,[H|I]) :-
get_prop_inner_loop_vars(B,[A|C],J,K,F,G,I),
functor(A,L,M),
gen_var(N),
head_info(A,M,_,H,_,O),
get_constraint_mode(L/M,P),
head_arg_matches(O,P,K,_,E),
passive_delegate_variables(A,B,C,E,Q),
append(Q,[H,N|J],D).
reorder_heads(A,B,C,D,E,F) :-
( chr_pp_flag(reorder_heads,on),
length(C,G),
G=<6 ->
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,99999,F).
order_score(default,A,_,B,C,_,D,E) :-
term_variables(A,F),
term_variables(C,G),
ground_vars([A],H),
list_difference_eq(F,H,I),
order_score_vars(I,B,G,J),
E is min(D,J).
order_score(multi_inthash(A),B,_,C,_,_,D,E) :-
( D=<100 ->
E=D
;
order_score_indexes(A,B,C,E)
).
order_score(multi_hash(A),B,_,C,_,_,D,E) :-
( D=<100 ->
E=D
;
order_score_indexes(A,B,C,E)
).
order_score(global_ground,A,_,B,C,_,D,E) :-
term_variables(A,F),
term_variables(C,G),
order_score_vars(F,B,G,H),
I is H*200,
E is min(D,I).
order_score(var_assoc_store(_,_),_,_,_,_,_,_,1).
order_score(global_singleton,_,_,_,_,_,_,A) :-
A=1.
order_score(multi_store(A),B,C,D,E,F,G,H) :-
multi_order_score(A,B,C,D,E,F,G,H).
multi_order_score([],_,_,_,_,_,A,A).
multi_order_score([A|B],C,D,E,F,G,H,I) :-
( order_score(A,C,D,E,F,G,H,J) ->
true
;
J=H
),
multi_order_score(B,C,D,E,F,G,J,I).
order_score(identifier_store(_),_,_,_,_,_,A,B) :-
B is min(A,10).
order_score(type_indexed_identifier_store(_,_),_,_,_,_,_,A,B) :-
B is min(A,10).
order_score_indexes(A,B,C,D) :-
copy_term_nat(B+C,E+F),
numbervars(F,0,_),
order_score_indexes(A,E,D).
order_score_indexes([A|B],C,D) :-
multi_hash_key_args(A,C,E),
( maplist(ground,E) ->
D=100
;
order_score_indexes(B,C,D)
).
memberchk_eq_flip(A,B) :-
memberchk_eq(B,A).
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)*100
)
;
D is max(10-G,1)*1000
).
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_ref(A,B,C) :-
C=(B=mutable(A)).
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)
;
chr_pp_flag(late_allocation,off)
),
(
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),
atomic_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),
atomic_concat(F,A,D).
vars_susp(A,B,C,D) :-
length(B,A),
append(B,[C],D).
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).
make_attr(A,B,C,D) :-
length(C,A),
D=..[v,B|C].
get_all_suspensions2(A,B,C) :-
chr_pp_flag(dynattr,off),
!,
make_attr(A,_,C,B).
get_all_suspensions2(A,B,C,D) :-
length(D,A),
C='chr all_suspensions'(D,1,B).
normalize_attr(A,B,C) :-
B='chr normalize_attr'(A,C).
get_suspensions(A,B,C,C=D,E) :-
chr_pp_flag(dynattr,off),
!,
make_attr(A,_,F,D),
nth1(B,F,E).
get_suspensions(_,A,B,C,D) :-
C=(memberchk(A-D,B)->true;D=[]).
singleton_attr(A,B,C,D) :-
chr_pp_flag(dynattr,off),
!,
or_pattern(C,E),
make_attr(A,E,F,D),
nth1(C,F,[B]),
chr_delete(F,[B],G),
set_elems(G,[]).
singleton_attr(_,A,B,C) :-
C=[B-[A]].
add_attr(A,B,C,D,E,F) :-
chr_pp_flag(dynattr,off),
!,
make_attr(A,G,H,I),
or_pattern(C,J),
nth1(C,H,K),
substitute_eq(K,H,[B|K],L),
make_attr(A,G,L,M),
substitute_eq(K,H,[B],N),
make_attr(A,O,N,P),
E=(D=I,(G/\J=:=J->F=M;O is G\/J,F=P)),
!.
add_attr(_,A,B,C,D,E) :-
D=('chr select'(C,B-F,G)->E=[B-[A|F]|G];E=[B-[A]|C]).
rem_attr(A,B,C,D,E,F) :-
chr_pp_flag(dynattr,off),
!,
or_pattern(D,G),
and_pattern(D,H),
make_attr(A,I,J,K),
nth1(D,J,L),
substitute_eq(L,J,[],M),
make_attr(A,N,M,O),
substitute_eq(L,J,P,Q),
make_attr(A,I,Q,R),
get_target_module(S),
F=(E=K,(I/\G=:=G->'chr sbag_del_element'(L,C,P),(P==[]->N is I/\H,(N==0->del_attr(B,S);put_attr(B,S,O));put_attr(B,S,R));true)),
!.
rem_attr(_,A,B,C,D,E) :-
get_target_module(F),
E=('chr select'(D,C-G,H)->'chr sbag_del_element'(G,B,I),(I==[]->(H==[]->del_attr(A,F);put_attr(A,F,H));put_attr(A,F,[C-I|H]));true).
merge_attributes(A,B,C,D,E) :-
chr_pp_flag(dynattr,off),
!,
make_attr(A,F,G,H),
merge_attributes2(A,F,G,C,I,E),
D=(B=H,I).
merge_attributes(_,A,B,C,D) :-
C=(sort(A,E),sort(B,F),'chr new_merge_attributes'(E,F,D)).
merge_attributes2(A,B,C,D,E,F) :-
make_attr(A,G,H,I),
bagof(J,K^L^M^N^(member2(C,H,K-L),J=(sort(L,M),'chr merge_attributes'(K,M,N))),O),
list2conj(O,P),
bagof(Q,R^S^T^member((R,'chr merge_attributes'(S,T,Q)),O),U),
make_attr(A,V,U,F),
E=(D=I,P,V is B\/G).
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(A,B,C,D,E,F) :-
functor(A,G,H),
get_store_type(G/H,I),
lookup_passive_head(I,A,B,C,D,E,F).
lookup_passive_head(default,A,B,C,_,D,E) :-
functor(A,F,G),
passive_head_via(A,B,C,D,E),
update_store_type(F/G,default).
lookup_passive_head(multi_inthash(A),B,_,C,D,E,F) :-
hash_lookup_passive_head(inthash,A,B,C,D,E,F,_).
lookup_passive_head(multi_hash(A),B,_,C,D,E,F) :-
hash_lookup_passive_head(hash,A,B,C,D,E,F,_).
lookup_passive_head(global_ground,A,_,_,_,B,C) :-
functor(A,D,E),
global_ground_store_name(D/E,F),
make_get_store_goal(F,C,B),
update_store_type(D/E,global_ground).
lookup_passive_head(var_assoc_store(A,B),C,_,D,_,E,F) :-
arg(A,C,G),
arg(B,C,H),
translate([G,H],D,[I,J]),
get_target_module(K),
E=(get_attr(I,K,L),lookup_assoc_store(L,J,F)).
lookup_passive_head(global_singleton,A,_,_,_,B,C) :-
functor(A,D,E),
global_singleton_store_name(D/E,F),
make_get_store_goal(F,G,H),
B=(H,G\==[],C=[G]),
update_store_type(D/E,global_singleton).
lookup_passive_head(multi_store(A),B,C,D,E,F,G) :-
once((member(H,A),lookup_passive_head(H,B,C,D,E,F,G))).
lookup_passive_head(identifier_store(A),B,_,C,_,D,E) :-
functor(B,F,G),
arg(A,B,H),
translate([H],C,[I]),
delay_phase_end(validate_store_type_assumptions,identifier_lookup(F/G,A,E,I,D)),
update_store_type(F/G,identifier_store(A)),
get_identifier_index(F/G,A,_).
lookup_passive_head(type_indexed_identifier_store(A,B),C,_,D,_,E,F) :-
functor(C,G,H),
arg(A,C,I),
( var(I) ->
translate([I],D,[J]),
E=K
;
( ground(I),
I='$chr_identifier_match'(L,_) ->
lookup_identifier_atom(B,L,J,M),
E=(M,K)
)
),
delay_phase_end(validate_store_type_assumptions,type_indexed_identifier_lookup(G/H,A,B,F,J,K)),
update_store_type(G/H,type_indexed_identifier_store(A,B)),
get_type_indexed_identifier_index(B,G/H,A,_).
identifier_lookup(A,B,C,D,E) :-
get_identifier_size(F),
functor(G,struct,F),
get_identifier_index(A,B,H),
arg(H,G,C),
E=(D=G).
type_indexed_identifier_lookup(A,B,C,D,E,F) :-
type_indexed_identifier_structure(C,G),
get_type_indexed_identifier_index(C,A,B,H),
arg(H,G,D),
F=(E=G).
hash_lookup_passive_head(A,B,C,D,E,F,G,H) :-
pick_hash_index(B,C,D,H,I,J),
( J=[K] ->
true
;
K=..[k|J]
),
functor(C,L,M),
multi_hash_lookup_goal(L/M,A,H,K,G,N),
check_ground(E,I,O),
my_term_copy(O,D,P),
F=(P,N),
( A==inthash ->
update_store_type(L/M,multi_inthash([H]))
;
update_store_type(L/M,multi_hash([H]))
).
pick_hash_index(A,B,C,D,E,F) :-
member(D,A),
multi_hash_key_args(D,B,E),
key_in_scope(E,C,F),
!.
key_in_scope([],_,[]).
key_in_scope([A|B],C,[D|E]) :-
term_variables(A,F),
translate(F,C,G),
copy_term(A/F,D/G),
key_in_scope(B,C,E).
existential_lookup(var_assoc_store(A,B),C,D,E,F,G,H,I,J,J) :-
!,
lookup_passive_head(var_assoc_store(A,B),C,D,E,F,K,L),
sbag_member_call(I,L,M),
functor(C,N,O),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(N/O,G),get_static_suspension_field(N/O,G,state,active,P))),
H=(K,M,I=G,P).
existential_lookup(global_singleton,A,_,_,_,B,C,D,E,E) :-
!,
functor(A,F,G),
global_singleton_store_name(F/G,H),
make_get_store_goal(H,D,I),
C=(I,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_inthash(A),B,_,C,D,E,F,G,H,I) :-
!,
existential_hash_lookup(inthash,A,B,C,D,E,F,G,H,I).
existential_lookup(multi_hash(A),B,_,C,D,E,F,G,H,I) :-
!,
existential_hash_lookup(hash,A,B,C,D,E,F,G,H,I).
existential_lookup(identifier_store(A),B,C,D,E,F,G,H,I,J) :-
!,
lookup_passive_head(identifier_store(A),B,C,D,E,K,L),
hash_index_filter(I,A,J),
functor(B,M,N),
( check_fd_lookup_condition(M,N,B,_) ->
O=(L=[H])
;
sbag_member_call(H,L,O)
),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(M/N,F),get_static_suspension_field(M/N,F,state,active,P))),
G=(K,O,H=F,P).
existential_lookup(type_indexed_identifier_store(A,B),C,D,E,F,G,H,I,J,K) :-
!,
lookup_passive_head(type_indexed_identifier_store(A,B),C,D,E,F,L,M),
hash_index_filter(J,A,K),
functor(C,N,O),
( check_fd_lookup_condition(N,O,C,_) ->
P=(M=[I])
;
sbag_member_call(I,M,P)
),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(N/O,G),get_static_suspension_field(N/O,G,state,active,Q))),
H=(L,P,I=G,Q).
existential_lookup(A,B,C,D,E,F,G,H,I,I) :-
lookup_passive_head(A,B,C,D,E,J,K),
sbag_member_call(H,K,L),
functor(B,M,N),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(M/N,F),get_static_suspension_field(M/N,F,state,active,O))),
G=(J,L,H=F,O).
existential_hash_lookup(A,B,C,D,E,F,G,H,I,J) :-
hash_lookup_passive_head(A,B,C,D,E,K,L,M),
hash_index_filter(I,M,J),
functor(C,N,O),
( check_fd_lookup_condition(N,O,C,_) ->
P=(L=[H])
;
sbag_member_call(H,L,P)
),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(N/O,F),get_static_suspension_field(N/O,F,state,active,Q))),
G=(K,P,H=F,Q).
hash_index_filter(A,B,C) :-
hash_index_filter(A,B,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=[silent(A)|I],
hash_index_filter(B,G,H,I)
)
)
;
E=[A|B]
).
assume_constraint_stores([]).
assume_constraint_stores([A|B]) :-
( chr_pp_flag(debugable,off),
(
only_ground_indexed_arguments(A)
;
chr_pp_flag(mixed_stores,on)
),
is_stored(A),
get_store_type(A,default) ->
get_indexed_arguments(A,C),
get_constraint_mode(A,D),
aggregate_all(bag(E)-count,(member(E,C),nth1(E,D,+)),F-G),
( G>10 ->
findall([E],member(E,F),H)
;
findall(E,(sublist(E,F),E\==[]),I),
predsort(longer_list,I,H)
),
( get_functional_dependency(A,1,J,K),
all_distinct_var_args(J),
K==[] ->
assumed_store_type(A,global_singleton)
;
(
(
only_ground_indexed_arguments(A)
;
G>0
) ->
get_constraint_type_det(A,L),
partition_indexes(H,L,M,N,O,P),
( N=[] ->
Q=R
;
Q=[multi_inthash(N)|R]
),
( M=[] ->
R=S
;
R=[multi_hash(M)|S]
),
( O=[] ->
S=T
;
maplist(wrap_in_functor(identifier_store),O,U),
append(U,T,S)
),
append(P,V,T),
( only_ground_indexed_arguments(A) ->
V=[global_ground]
;
V=[default]
),
assumed_store_type(A,multi_store(Q))
)
;
true
)
;
true
),
assume_constraint_stores(B).
partition_indexes([],_,[],[],[],[]).
partition_indexes([A|B],C,D,E,F,G) :-
( A=[H],
nth1(H,C,I),
unalias_type(I,J),
J==chr_identifier ->
F=[H|K],
E=L,
D=M,
G=N
;
( A=[H],
nth1(H,C,I),
unalias_type(I,J),
nonvar(J),
J=chr_identifier(O) ->
G=[type_indexed_identifier_store(H,O)|N],
F=K,
E=L,
D=M
)
;
( A=[H],
nth1(H,C,I),
unalias_type(I,J),
J==dense_int ->
E=[A|L],
D=M,
F=K,
G=N
)
;
( member(H,A),
nth1(H,C,I),
unalias_type(I,J),
nonvar(J),
J=chr_identifier(_) ->
E=L,
D=M,
F=K,
G=N
)
;
E=L,
D=[A|M],
F=K,
G=N
),
partition_indexes(B,C,M,L,K,N).
longer_list(A,B,C) :-
length(B,D),
length(C,E),
compare(F,E,D),
( F== = ->
compare(A,B,C)
;
A=F
).
all_distinct_var_args(A) :-
copy_term_nat(A,B),
functor(A,C,D),
functor(E,C,D),
E=@=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,J) :-
D=rule(_,_,K,L),
gen_var_susp_list_for_b(B,[A,C,K,L],_,M,N,_,O),
universal_search_iterator_failure_vars(B,H,M,N,O,P,Q),
flatten(M,R),
S=[[]|R],
build_head(E,F,[G|H],S,T),
( Q=[_] ->
get_success_continuation_code_id(E/F,G,U),
V=[U]
;
V=[G|Q]
),
build_head(E,F,V,P,W),
X=(T:-W),
add_dummy_location(X,Y),
I=[Y|J].
universal_search_iterator_failure_vars(A,B,C,D,E,F,G) :-
( B=[0|_] ->
next_id(B,G),
F=D
;
C=[_|H],
dec_id(B,I),
( A=[J|K],
functor(J,L,M),
check_fd_lookup_condition(L,M,J,K) ->
E=[_|N],
universal_search_iterator_failure_vars(K,I,H,D,N,F,G)
;
G=I,
flatten(H,O),
E=[P|_],
F=[P|O]
)
).
universal_search_iterator([A|B],[C|D],E,F/G,H,I,J,K) :-
E=rule(_,_,L,M),
gen_var_susp_list_for_b(D,[C,A,B,L,M],N,O,P,Q,R),
init(Q,S),
flatten(O,T),
gen_var(U),
functor(C,V,W),
gen_vars(W,X),
head_info(C,W,X,Y,_,Z),
get_constraint_mode(V/W,A1),
head_arg_matches(Z,A1,N,B1,C1),
delay_phase_end(validate_store_type_assumptions,(static_suspension_term(V/W,D1),get_static_suspension_field(V/W,D1,state,active,E1),get_static_suspension_term_field(arguments,V/W,D1,X))),
different_from_other_susps(C,Y,D,S,F1),
G1=(Y=D1,E1,F1,B1),
add_heads_ground_variables([C|D],[],H1),
lookup_passive_head(A,[C|D],C1,H1,I1,J1),
inc_id(I,K1),
L1=[[Y|U]|T],
build_head(F,G,[H|I],L1,M1),
passive_delegate_variables(C,D,[A,B,L,M],C1,N1),
append([J1|N1],[Y,U|T],O1),
build_head(F,G,[H|K1],O1,P1),
( check_fd_lookup_condition(V,W,C,D) ->
universal_search_iterator_failure_vars(D,I,O,P,R,Q1,R1),
S1=Q1
;
S1=[U|T],
R1=I
),
( R1=[_] ->
T1=R1
;
T1=[H|R1]
),
build_head(F,G,T1,S1,U1),
V1=(M1:-G1,I1->P1;U1),
add_dummy_location(V1,W1),
J=[W1|K].
ai_observation_analysis(A) :-
( chr_pp_flag(ai_observation_analysis,on),
get_target_module(_),
'$chr_compiled_with_version'(3) ->
list_to_ord_set(A,B),
abstract_constraints(B),
ai_observation_schedule_initial_calls(B,B),
ai_observation_gather_results
;
true
).
ai_observation_schedule_initial_calls([],_).
ai_observation_schedule_initial_calls([A|B],C) :-
ai_observation_schedule_initial_call(A,C),
ai_observation_schedule_initial_calls(B,C).
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_intersection(B,C,D).
ai_observation_bot(A,B,odom(A,B)).
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_set(A,B,C) :-
ord_subtract(A,B,C).
ai_observation_abstract_constraint(A,B,C) :-
functor(A,D,E),
C=D/E,
memberchk(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,D,E,F) :-
term_variables((A,B,C),G),
append(A,B,H),
ground_vars(H,I),
list_difference_eq(G,I,J),
ai_observation_abstract_goal(D,E,F,[],J),
!.
ground_vars([],[]).
ground_vars([A|B],C) :-
functor(A,D,E),
get_constraint_mode(D/E,F),
head_info(A,E,_,_,_,G),
head_arg_matches(G,F,[],_,_,[],H),
ground_vars(B,I),
append(H,I,C).
ai_observation_abstract_goal((A,B),C,D,E,F) :-
!,
ai_observation_abstract_goal(A,C,D,G,F),
ai_observation_abstract_goal(B,C,G,E,F).
ai_observation_abstract_goal((A;B),C,[(D;E)|F],F,G) :-
!,
ai_observation_abstract_goal(A,C,D,[],G),
ai_observation_abstract_goal(B,C,E,[],G).
ai_observation_abstract_goal((A->B),C,D,E,F) :-
!,
ai_observation_abstract_goal(A,C,D,G,F),
ai_observation_abstract_goal(B,C,G,E,F).
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,C) :-
builtin_binds_b(A,D),
intersect_eq(D,C,[]),
!.
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))),
all_distinct_var_args(J).
partial_wake_args([],_,_,_).
partial_wake_args([A|B],[C|D],E,F) :-
( C\== + ->
( nonvar(A) ->
no_partial_wake(F)
;
( memberchk_eq(A,E) ->
no_partial_wake(F)
)
;
true
)
;
true
),
partial_wake_args(B,D,E,F).
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).
static_suspension_term(A/B,C) :-
suspension_term_base(A/B,D),
E is D+B,
functor(C,suspension,E).
has_suspension_field(A,B) :-
suspension_term_base_fields(A,C),
memberchk(B,C).
suspension_term_base(A,B) :-
suspension_term_base_fields(A,C),
length(C,B).
suspension_term_base_fields(A,B) :-
( chr_pp_flag(debugable,on) ->
B=[id,state,history,generation,continuation,functor]
;
( uses_history(A) ->
B=[id,state,history|C]
;
( only_ground_indexed_arguments(A),
get_functional_dependency(A,1,_,_) ->
B=[state|C]
)
;
B=[id,state|C]
),
( only_ground_indexed_arguments(A) ->
get_store_type(A,D),
basic_store_types(D,E),
( memberchk(global_ground,E) ->
C=[global_list_prev|F]
;
C=F
),
( chr_pp_flag(ht_removal,on) ->
ht_prev_fields(E,F)
;
F=[]
)
;
( may_trigger(A) ->
( uses_field(A,generation) ->
C=[generation,global_list_prev|F]
;
C=[global_list_prev|F]
),
( chr_pp_flag(mixed_stores,on),
chr_pp_flag(ht_removal,on) ->
get_store_type(A,D),
basic_store_types(D,E),
ht_prev_fields(E,F)
;
F=[]
)
)
;
C=[global_list_prev|F],
( chr_pp_flag(mixed_stores,on),
chr_pp_flag(ht_removal,on) ->
get_store_type(A,D),
basic_store_types(D,E),
ht_prev_fields(E,F)
;
F=[]
)
)
).
ht_prev_fields(A,B) :-
ht_prev_fields_int(A,C),
append(C,B).
ht_prev_fields_int([],[]).
ht_prev_fields_int([A|B],C) :-
( A=multi_hash(D) ->
maplist(ht_prev_field,D,E),
C=[E|F]
;
C=F
),
ht_prev_fields_int(B,F).
ht_prev_field(A,B) :-
concat_atom(['multi_hash_prev-'|A],B).
get_static_suspension_term_field(A,B,C,D) :-
suspension_term_base_fields(B,E),
nth1(F,E,A),
!,
arg(F,C,D).
get_static_suspension_term_field(arguments,A,B,C) :-
!,
suspension_term_base(A,D),
B=..[_|E],
drop(D,E,C).
get_static_suspension_term_field(A,B,_,_) :-
chr_error(internal,'Trying to obtain field ~w of ~w, wich does not have it!',[A,B]).
get_dynamic_suspension_term_field(A,B,C,D,E) :-
suspension_term_base_fields(B,F),
nth1(G,F,A),
!,
E=arg(G,C,D).
get_dynamic_suspension_term_field(arguments,A,B,C,D) :-
!,
static_suspension_term(A,E),
get_static_suspension_term_field(arguments,A,E,C),
D=(B=E).
get_dynamic_suspension_term_field(argument(A),B,C,D,E) :-
!,
suspension_term_base(B,F),
G is A+F,
E=arg(G,C,D).
get_dynamic_suspension_term_field(A,B,_,_,_) :-
chr_error(internal,'Dynamic goal to get ~w of ~w, which does not have this field!',[A,B]).
set_dynamic_suspension_term_field(A,B,C,D,E) :-
suspension_term_base_fields(B,F),
nth1(G,F,A),
!,
E=setarg(G,C,D).
set_dynamic_suspension_term_field(A,B,_,_,_) :-
chr_error(internal,'Dynamic goal to set ~w of ~w, which does not have this field!',[A,B]).
basic_store_types(multi_store(A),A) :-
!.
basic_store_types(A,[A]).
generate_never_stored_rules(A,B) :-
( chr_pp_flag(declare_stored_constraints,on) ->
never_stored_rules(A,B)
;
B=[]
).
check_storedness_assertions(A) :-
( chr_pp_flag(storage_analysis,on),
chr_pp_flag(declare_stored_constraints,on) ->
forall(B,A,check_storedness_assertion(B))
;
true
).
continuation_analysis(A) :-
maplist(analyse_continuations,A).
analyse_continuations(A) :-
continuation_analysis(A,1),
get_max_occurrence(A,B),
C is B+1,
bulk_propagation(A,1,C),
set_occurrence_code_id(A,1,0).
continuation_analysis(A,B) :-
get_max_occurrence(A,C),
( B>C ->
true
;
( B==C ->
D is B+1,
continuation_occurrence(A,B,D)
)
;
constraint_continuation(A,B,C,D),
continuation_occurrence(A,B,D),
E is B+1,
continuation_analysis(A,E)
).
constraint_continuation(A,B,C,D) :-
( get_occurrence_head(A,B,E) ->
F is B+1,
( between(F,C,D),
get_occurrence_head(A,D,G),
unifiable(E,G,_) ->
true
;
D is C+1
)
;
D=C
).
get_occurrence_head(A,B,C) :-
get_occurrence(A,B,D,E),
\+is_passive(D,E),
get_rule(D,F),
F=pragma(rule(G,H,_,_),ids(I,J),_,_,_),
( select2(E,C,I,G,_,_) ->
true
;
select2(E,C,J,H,_,_)
).
get_success_continuation_code_id(A,B,C) :-
get_success_continuation_occurrence(A,B,D),
get_occurrence_code_id(A,D,C).
collect_constants(A,B,C) :-
( not_restarted ->
maplist(collect_rule_constants(B),A),
( chr_pp_flag(verbose,on) ->
print_chr_constants
;
true
),
( chr_pp_flag(experiment,on) ->
flattening_dictionary(B,D),
copy_term_nat(C,E),
flatten_clauses(E,D,F),
install_new_declarations_and_restart(F)
;
true
)
;
true
).
collect_rule_constants(A,B) :-
B=pragma(rule(C,D,_,E),_,_,_,_),
maplist(collect_head_constants,C),
maplist(collect_head_constants,D),
collect_body_constants(E,A).
collect_body_constants(A,B) :-
conj2list(A,C),
maplist(collect_goal_constants(B),C).
collect_goal_constants(A,B) :-
( nonvar(B),
functor(B,C,D),
memberchk(C/D,A) ->
collect_head_constants(B)
;
( nonvar(B),
B=E:F,
get_target_module(G),
E==G,
nonvar(F),
functor(F,C,D),
memberchk(C/D,A) ->
collect_head_constants(F)
)
;
true
).
collect_head_constants(A) :-
functor(A,B,C),
get_constraint_type_det(B/C,D),
A=..[_|E],
maplist(collect_arg_constants,E,D).
collect_arg_constants(A,B) :-
( ground(A),
unalias_type(B,C),
is_chr_constants_type(C,D,_) ->
add_chr_constant(D,A)
;
true
).
flattening_dictionary([],[]).
flattening_dictionary([A|B],C) :-
( flattening_dictionary_entry(A,D) ->
C=[D|E]
;
C=E
),
flattening_dictionary(B,E).
flattening_dictionary_entry(A,B) :-
get_constraint_arg_type(A,C,D),
( is_chr_constants_type(D,E,F) ->
get_chr_constants(E,G)
;
( D=chr_enum(G) ->
F=no
)
),
B=A-C-H-F,
maplist(flat_spec(A,C),G,H).
flat_spec(A/B,C,D,E) :-
E=D-F,
term_to_atom(D,G),
atom_concat_list(['$flat_',A,/,B,'___',C,'___',G],F).
restart_after_flattening(A,A) :-
nb_setval('$chr_restart_after_flattening',started).
restart_after_flattening(_,A) :-
nb_getval('$chr_restart_after_flattening',restart(A)),
nb_setval('$chr_restart_after_flattening',restarted).
not_restarted :-
nb_getval('$chr_restart_after_flattening',started).
install_new_declarations_and_restart(A) :-
nb_setval('$chr_restart_after_flattening',restart(A)),
fail.
flatten_clauses(A,B,C) :-
flatten_readcontent(A,D,E,F,_,G,H),
flatten_clauses_(B,D,H,E,F,G,C).
flatten_clauses_(A,B,C,D,E,F,G) :-
auxiliary_constraints_declarations(A,E,F,H),
dispatching_rules(A,I),
declarations(D,A,E,F,J),
flatten_rules(B,A,K),
append([C,H,I,J,K],G).
declarations(A,B,C,D,E) :-
findall(F,(member(F,A),\+memberchk(F-_-_-_,B)),G),
maplist(declaration(C,D),G,H),
flatten(H,E).
declaration(A,B,C,[(:-chr_constraint C),(:-chr_option(mode,D)),(:-chr_option(type_declaration,E))]) :-
C=F/G,
functor(D,F,G),
( memberchk(D,A) ->
true
;
replicate(G,?,H),
D=..[_|H]
),
functor(E,F,G),
( memberchk(E,B) ->
true
;
replicate(G,any,I),
E=..[_|I]
).
flatten_readcontent([],[],[],[],[],[],[]).
flatten_readcontent([A|B],C,D,E,F,G,H) :-
( A==end_of_file ->
C=[],
D=[],
E=[],
G=[],
F=[],
H=[]
;
( crude_is_rule(A) ->
C=[A|I],
flatten_readcontent(B,I,D,E,F,G,H)
)
;
( pure_is_declaration(A,J,K,L) ->
append(J,M,D),
append(K,N,E),
append(L,O,G),
flatten_readcontent(B,C,M,N,F,O,H)
)
;
( is_mode_declaration(A,P) ->
E=[P|N],
flatten_readcontent(B,C,D,N,F,G,H)
)
;
( is_type_declaration(A,Q) ->
G=[Q|O],
flatten_readcontent(B,C,D,E,F,O,H)
)
;
( is_type_definition(A,R) ->
H=[A|S],
F=[R|T],
flatten_readcontent(B,C,D,E,T,G,S)
)
;
( A=(:-op(U,V,W)) ->
op(U,V,W)
;
true
),
H=[A|S],
flatten_readcontent(B,C,D,E,F,G,S)
).
crude_is_rule((_@_)).
crude_is_rule((_ pragma _)).
crude_is_rule((_==>_)).
crude_is_rule((_<=>_)).
pure_is_declaration(A,B,C,D) :-
A=(:-E),
E=..[F,G],
F==chr_constraint,
conj2list(G,H),
pure_extract_type_mode(H,B,C,D).
pure_extract_type_mode([],[],[],[]).
pure_extract_type_mode([A/B|C],[A/B|D],E,F) :-
!,
pure_extract_type_mode(C,D,E,F).
pure_extract_type_mode([A|B],[C|D],[E|F],G) :-
functor(A,H,I),
C=H/I,
A=..[_|J],
extract_types_and_modes(J,K,L),
E=..[H|L],
( forall(member(M,K),M==any) ->
G=N
;
G=[O|N],
O=..[H|K]
),
pure_extract_type_mode(B,D,F,N).
is_mode_declaration((:-chr_option(mode,A)),A).
is_type_declaration((:-chr_option(type_declaration,A)),A).
auxiliary_constraints_declarations(A,B,C,D) :-
findall(E,auxiliary_constraints_declaration(A,B,C,E),F),
flatten(F,D).
auxiliary_constraints_declaration(A,B,C,[(:-chr_constraint D),(:-chr_option(mode,E)),(:-chr_option(type_declaration,F))]) :-
member(G/H-I-J-_,A),
arg_modes(G,H,B,K),
specialize_modes(K,I,L),
arg_types(G,H,C,M),
specialize_types(M,I,N),
O is H-1,
member(_-P,J),
D=P/O,
E=..[P|L],
F=..[P|N].
arg_modes(A,B,C,D) :-
functor(E,A,B),
( memberchk(E,C) ->
E=..[_|D]
;
replicate(B,?,D)
).
specialize_modes(A,B,C) :-
split(A,B,D,_,E),
append(D,E,C).
arg_types(A,B,C,D) :-
functor(E,A,B),
( memberchk(E,C) ->
E=..[_|D]
;
replicate(B,any,D)
).
specialize_types(A,B,C) :-
split(A,B,D,_,E),
append(D,E,C).
dispatching_rules([],[]).
dispatching_rules([A-B-C-D|E],F) :-
constraint_dispatching_rule(C,A,B,D,F,G),
dispatching_rules(E,G).
constraint_dispatching_rule(A,B/C,D,E,F,G) :-
( D==1 ->
H=F,
I=B/C
;
functor(J,B,C),
J=..[_|K],
split(K,D,L,M,N),
append([M|L],N,O),
atom_concat(B,'_$shuffled',P),
Q=..[P|O],
[(J:-Q)|H]=F,
I=P/C
),
R=swap(B,D),
dispatching_rule_term_cases(A,I,E,R,H,G).
dispatching_rule_term_cases(A,B/C,D,E,F,G) :-
once(pairup(H,I,A)),
length(H,J),
replicate(J,[],K),
L is C-1,
maplist(wrap_in_functor(dispatching_action),I,M),
dispatch_trie_index([H|K],L,D,E,M,B,F,G).
dispatching_action(A,B,C) :-
C=..[A|B].
dispatch_trie_index([A|B],C,D,E,F,G,H,I) :-
dispatch_trie_step(A,G,G,B,C,D,E,F,H,I).
dispatch_trie_step([],_,_,_,[],_,_,[],A,A) :-
!.
dispatch_trie_step(A,B,C,D,E,F,G,H,I,J) :-
D=[K|_],
length(K,L),
aggregate_all(set(M/N),(member(O,A),functor(O,M,N)),P),
Q is L+1,
dispatch_trie_step_cases(P,Q,A,D,E,F,G,H,B,C,I,J).
dispatch_trie_step_cases([],A,_,_,B,C,D,_,E,_,F,G) :-
( C=yes(H) ->
F=[I|G],
I=(J:-K),
L is A+B,
functor(J,E,L),
reconstruct_original_term(D,J,M),
K=..[H,M]
;
F=G
).
dispatch_trie_step_cases([A|B],C,D,E,F,G,H,I,J,K,L,M) :-
dispatch_trie_step_case(A,C,D,E,F,G,H,I,J,K,L,N),
dispatch_trie_step_cases(B,C,D,E,F,G,H,I,J,K,N,M).
dispatch_trie_step_case(A/B,C,D,E,F,G,H,I,J,K,[L|M],N) :-
L=(O:-P,Q),
( G=yes(_) ->
P=!
;
P=true
),
R is C+F,
functor(O,J,R),
arg(1,O,S),
O=..[_,_|T],
length(U,F),
once(append(V,U,T)),
functor(S,A,B),
W=index_functor(A,B,H),
S=..[_|X],
append(X,T,Y),
( Y==U ->
M=N,
rec_cases(D,_,I,A/B,_,_,Z),
Z=[A1],
call(A1,U,Q)
;
rec_cases(D,E,I,A/B,B1,C1,Z),
( Z=[D1] ->
M=N,
call(D1,U,Q)
;
pairup(B1,C1,E1),
common_pattern(E1,F1,G1,H1),
append(X,V,[I1|J1]),
I1-J1=F1,
K1=gct(V,W),
gensym(K,L1),
append(G1,U,M1),
Q=..[L1|M1],
findall(N1-O1,member([N1|O1],H1),P1),
once(pairup(Q1,R1,P1)),
dispatch_trie_step(Q1,L1,K,R1,F,G,K1,Z,M,N)
)
).
split([A|B],C,D,E,F) :-
( C==1 ->
D=[],
E=A,
F=B
;
G is C-1,
D=[A|H],
split(B,G,H,E,F)
).
reconstruct_original_term(swap(A,B),C,D) :-
C=..[_,E|F],
G is B-1,
split_at(G,F,H,I),
append(H,[E|I],J),
D=..[A|J].
reconstruct_original_term(index_functor(A,B,C),D,E) :-
D=..[F|G],
split_at(B,G,H,I),
J=..[A|H],
K=..[F,J|I],
reconstruct_original_term(C,K,E).
reconstruct_original_term(gct(A,B),C,D) :-
copy_term_nat(A,E),
term_variables(E,F),
C=..[G|H],
append(F,I,H),
append(E,I,J),
K=..[G|J],
reconstruct_original_term(B,K,D).
flatten_rules(A,B,C) :-
flatten_rules1(A,B,D),
flatten(D,C).
flatten_rules1([],_,[]).
flatten_rules1([A|B],C,[D|E]) :-
findall(F,flatten_rule(A,C,F),D),
flatten_rules1(B,C,E).
flatten_rule((A@B),C,(A@D)) :-
!,
flatten_rule(B,C,D).
flatten_rule((A pragma B),C,(D pragma B)) :-
!,
flatten_rule(A,C,D).
flatten_rule((A==>B),C,(D==>E)) :-
!,
flatten_heads(A,C,D),
flatten_body(B,C,E).
flatten_rule((A\B<=>C),D,(E\F<=>G)) :-
!,
flatten_heads((A,B),D,(E,F)),
flatten_body(C,D,G).
flatten_rule((A<=>B),C,(D<=>E)) :-
flatten_heads(A,C,D),
flatten_body(B,C,E).
flatten_heads((A,B),C,(D,E)) :-
!,
flatten_heads(A,C,D),
flatten_heads(B,C,E).
flatten_heads(A#B,C,D#B) :-
!,
flatten_heads(A,C,D).
flatten_heads(A,B,C) :-
( functor(A,D,E),
memberchk(D/E-F-G-_,B) ->
A=..[_|H],
split(H,F,I,J,K),
member(L-M,G),
J=L,
append(I,K,N),
C=..[M|N]
;
C=A
).
flatten_body((A '|' B),C,(D '|' E)) :-
!,
conj2list(A,F),
maplist(flatten_goal(C),F,G),
list2conj(G,D),
conj2list(B,H),
maplist(flatten_goal(C),H,I),
list2conj(I,E).
flatten_body(A,B,C) :-
conj2list(A,D),
maplist(flatten_goal(B),D,E),
list2conj(E,C).
flatten_goal(_,A,B) :-
var(A),
!,
B=A.
flatten_goal(A,B,C) :-
( is_specializable_goal(B,A,D) ->
specialize_goal(B,D,C)
;
( B=E:F,
get_target_module(G),
E==G,
nonvar(F),
is_specializable_goal(F,A,D) ->
specialize_goal(F,D,H),
C=E:H
)
;
( partial_eval(B,C) ->
true
)
;
C=B
).
is_specializable_goal(A,B,C) :-
functor(A,D,E),
memberchk(D/E-C-_-_,B),
arg(C,A,F),
ground(F).
specialize_goal(A,B,C) :-
functor(A,D,E),
A=..[_|F],
split(F,B,G,H,I),
append(G,I,J),
flat_spec(D/E,B,H,_-K),
C=..[K|J].
partial_eval(append(A,B,C),D) :-
( A==[] ->
D=(C=B)
;
( B==[] ->
D=(C=A)
)
).
partial_eval(flatten_path(A,B),C) :-
( nonvar(A),
flatten(A,D),
D\==A ->
C=flatten_path(D,B)
).
dump_code(A) :-
( chr_pp_flag(dump,on) ->
maplist(portray_clause,A)
;
true
).
chr_banner :-
chr_info(banner,' The K.U.Leuven CHR System
Contributors: Tom Schrijvers, Jon Sneyers, Bart Demoen,
Jan Wielemaker
Copyright: K.U.Leuven, Belgium
URL: http://www.cs.kuleuven.be/~~toms/CHR/
',[]).
:-use_module(chr(chr_runtime)).
:-use_module(chr(chr_hashtable_store)).
attach_generate_empty_named_history_initialisation___1([],_).
attach_generate_empty_named_history_initialisation___1([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\1=:=1 ->
Q=v(N,[C|D],E,F,G,H,I,J,K,L,M)
;
O is N\/1,
Q=v(O,[C],E,F,G,H,I,J,K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(1,[C],[],[],[],[],[],[],[],[],[]))
),
attach_generate_empty_named_history_initialisation___1(B,C).
detach_generate_empty_named_history_initialisation___1([],_).
detach_generate_empty_named_history_initialisation___1([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\1=:=1 ->
'chr sbag_del_element'(D,C,P),
( P==[] ->
O is N/\ -2,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,[],E,F,G,H,I,J,K,L,M))
)
;
put_attr(A,chr_translate,v(N,P,E,F,G,H,I,J,K,L,M))
)
;
true
)
;
true
),
detach_generate_empty_named_history_initialisation___1(B,C).
attach_background_info___2([],_).
attach_background_info___2([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\2=:=2 ->
Q=v(N,D,[C|E],F,G,H,I,J,K,L,M)
;
O is N\/2,
Q=v(O,D,[C],F,G,H,I,J,K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(2,[],[C],[],[],[],[],[],[],[],[]))
),
attach_background_info___2(B,C).
detach_background_info___2([],_).
detach_background_info___2([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\2=:=2 ->
'chr sbag_del_element'(E,C,P),
( P==[] ->
O is N/\ -3,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,[],F,G,H,I,J,K,L,M))
)
;
put_attr(A,chr_translate,v(N,D,P,F,G,H,I,J,K,L,M))
)
;
true
)
;
true
),
detach_background_info___2(B,C).
attach_get_bg_info___2([],_).
attach_get_bg_info___2([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\4=:=4 ->
Q=v(N,D,E,[C|F],G,H,I,J,K,L,M)
;
O is N\/4,
Q=v(O,D,E,[C],G,H,I,J,K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(4,[],[],[C],[],[],[],[],[],[],[]))
),
attach_get_bg_info___2(B,C).
detach_get_bg_info___2([],_).
detach_get_bg_info___2([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\4=:=4 ->
'chr sbag_del_element'(F,C,P),
( P==[] ->
O is N/\ -5,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,[],G,H,I,J,K,L,M))
)
;
put_attr(A,chr_translate,v(N,D,E,P,G,H,I,J,K,L,M))
)
;
true
)
;
true
),
detach_get_bg_info___2(B,C).
attach_type_definition___2([],_).
attach_type_definition___2([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\8=:=8 ->
Q=v(N,D,E,F,[C|G],H,I,J,K,L,M)
;
O is N\/8,
Q=v(O,D,E,F,[C],H,I,J,K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(8,[],[],[],[C],[],[],[],[],[],[]))
),
attach_type_definition___2(B,C).
detach_type_definition___2([],_).
detach_type_definition___2([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\8=:=8 ->
'chr sbag_del_element'(G,C,P),
( P==[] ->
O is N/\ -9,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,[],H,I,J,K,L,M))
)
;
put_attr(A,chr_translate,v(N,D,E,F,P,H,I,J,K,L,M))
)
;
true
)
;
true
),
detach_type_definition___2(B,C).
attach_type_alias___2([],_).
attach_type_alias___2([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\16=:=16 ->
Q=v(N,D,E,F,G,[C|H],I,J,K,L,M)
;
O is N\/16,
Q=v(O,D,E,F,G,[C],I,J,K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(16,[],[],[],[],[C],[],[],[],[],[]))
),
attach_type_alias___2(B,C).
detach_type_alias___2([],_).
detach_type_alias___2([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\16=:=16 ->
'chr sbag_del_element'(H,C,P),
( P==[] ->
O is N/\ -17,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,G,[],I,J,K,L,M))
)
;
put_attr(A,chr_translate,v(N,D,E,F,G,P,I,J,K,L,M))
)
;
true
)
;
true
),
detach_type_alias___2(B,C).
attach_unalias_type___2([],_).
attach_unalias_type___2([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\32=:=32 ->
Q=v(N,D,E,F,G,H,[C|I],J,K,L,M)
;
O is N\/32,
Q=v(O,D,E,F,G,H,[C],J,K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(32,[],[],[],[],[],[C],[],[],[],[]))
),
attach_unalias_type___2(B,C).
detach_unalias_type___2([],_).
detach_unalias_type___2([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\32=:=32 ->
'chr sbag_del_element'(I,C,P),
( P==[] ->
O is N/\ -33,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,G,H,[],J,K,L,M))
)
;
put_attr(A,chr_translate,v(N,D,E,F,G,H,P,J,K,L,M))
)
;
true
)
;
true
),
detach_unalias_type___2(B,C).
attach_static_type_check_var___3([],_).
attach_static_type_check_var___3([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\64=:=64 ->
Q=v(N,D,E,F,G,H,I,[C|J],K,L,M)
;
O is N\/64,
Q=v(O,D,E,F,G,H,I,[C],K,L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(64,[],[],[],[],[],[],[C],[],[],[]))
),
attach_static_type_check_var___3(B,C).
detach_static_type_check_var___3([],_).
detach_static_type_check_var___3([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\64=:=64 ->
'chr sbag_del_element'(J,C,P),
( P==[] ->
O is N/\ -65,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,G,H,I,[],K,L,M))
)
;
put_attr(A,chr_translate,v(N,D,E,F,G,H,I,P,K,L,M))
)
;
true
)
;
true
),
detach_static_type_check_var___3(B,C).
attach_static_atomic_builtin_type_check_var___3([],_).
attach_static_atomic_builtin_type_check_var___3([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\128=:=128 ->
Q=v(N,D,E,F,G,H,I,J,[C|K],L,M)
;
O is N\/128,
Q=v(O,D,E,F,G,H,I,J,[C],L,M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(128,[],[],[],[],[],[],[],[C],[],[]))
),
attach_static_atomic_builtin_type_check_var___3(B,C).
detach_static_atomic_builtin_type_check_var___3([],_).
detach_static_atomic_builtin_type_check_var___3([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\128=:=128 ->
'chr sbag_del_element'(K,C,P),
( P==[] ->
O is N/\ -129,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,G,H,I,J,[],L,M))
)
;
put_attr(A,chr_translate,v(N,D,E,F,G,H,I,J,P,L,M))
)
;
true
)
;
true
),
detach_static_atomic_builtin_type_check_var___3(B,C).
attach_atomic_type___1([],_).
attach_atomic_type___1([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\256=:=256 ->
Q=v(N,D,E,F,G,H,I,J,K,[C|L],M)
;
O is N\/256,
Q=v(O,D,E,F,G,H,I,J,K,[C],M)
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(256,[],[],[],[],[],[],[],[],[C],[]))
),
attach_atomic_type___1(B,C).
detach_atomic_type___1([],_).
detach_atomic_type___1([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\256=:=256 ->
'chr sbag_del_element'(L,C,P),
( P==[] ->
O is N/\ -257,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,G,H,I,J,K,[],M))
)
;
put_attr(A,chr_translate,v(N,D,E,F,G,H,I,J,K,P,M))
)
;
true
)
;
true
),
detach_atomic_type___1(B,C).
attach_enumerated_atomic_type___2([],_).
attach_enumerated_atomic_type___2([A|B],C) :-
( get_attr(A,chr_translate,P) ->
P=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\512=:=512 ->
Q=v(N,D,E,F,G,H,I,J,K,L,[C|M])
;
O is N\/512,
Q=v(O,D,E,F,G,H,I,J,K,L,[C])
),
put_attr(A,chr_translate,Q)
;
put_attr(A,chr_translate,v(512,[],[],[],[],[],[],[],[],[],[C]))
),
attach_enumerated_atomic_type___2(B,C).
detach_enumerated_atomic_type___2([],_).
detach_enumerated_atomic_type___2([A|B],C) :-
( get_attr(A,chr_translate,Q) ->
Q=v(N,D,E,F,G,H,I,J,K,L,M),
( N/\512=:=512 ->
'chr sbag_del_element'(M,C,P),
( P==[] ->
O is N/\ -513,
( O==0 ->
del_attr(A,chr_translate)
;
put_attr(A,chr_translate,v(O,D,E,F,G,H,I,J,K,L,[]))
)
;
put_attr(A,chr_translate,v(N,D,E,F,G,H,I,J,K,L,P))
)
;
true
)
;
true
),
detach_enumerated_atomic_type___2(B,C).
attach_increment([],_).
attach_increment([B|C],A) :-
( get_attr(B,chr_translate,U1) ->
A=v(N,D,E,F,G,H,I,J,K,L,M),
U1=v(Y,O,P,Q,R,S,T,U,V,W,X),
sort(O,Z),
'chr merge_attributes'(D,Z,A1),
sort(P,B1),
'chr merge_attributes'(E,B1,C1),
sort(Q,D1),
'chr merge_attributes'(F,D1,E1),
sort(R,F1),
'chr merge_attributes'(G,F1,G1),
sort(S,H1),
'chr merge_attributes'(H,H1,I1),
sort(T,J1),
'chr merge_attributes'(I,J1,K1),
sort(U,L1),
'chr merge_attributes'(J,L1,M1),
sort(V,N1),
'chr merge_attributes'(K,N1,O1),
sort(W,P1),
'chr merge_attributes'(L,P1,Q1),
sort(X,R1),
'chr merge_attributes'(M,R1,S1),
T1 is N\/Y,
put_attr(B,chr_translate,v(T1,A1,C1,E1,G1,I1,K1,M1,O1,Q1,S1))
;
put_attr(B,chr_translate,A)
),
attach_increment(C,A).
attr_unify_hook(v(L,B,C,D,E,F,G,H,I,J,K),A) :-
sort(B,M),
sort(C,N),
sort(D,O),
sort(E,P),
sort(F,Q),
sort(G,R),
sort(H,S),
sort(I,T),
sort(J,U),
sort(K,V),
( var(A) ->
( get_attr(A,chr_translate,C2) ->
C2=v(G1,W,X,Y,Z,A1,B1,C1,D1,E1,F1),
sort(W,H1),
'chr merge_attributes'(M,H1,I1),
sort(X,J1),
'chr merge_attributes'(N,J1,K1),
sort(Y,L1),
'chr merge_attributes'(O,L1,M1),
sort(Z,N1),
'chr merge_attributes'(P,N1,O1),
sort(A1,P1),
'chr merge_attributes'(Q,P1,Q1),
sort(B1,R1),
'chr merge_attributes'(R,R1,S1),
sort(C1,T1),
'chr merge_attributes'(S,T1,U1),
sort(D1,V1),
'chr merge_attributes'(T,V1,W1),
sort(E1,X1),
'chr merge_attributes'(U,X1,Y1),
sort(F1,Z1),
'chr merge_attributes'(V,Z1,A2),
B2 is L\/G1,
put_attr(A,chr_translate,v(B2,I1,K1,M1,O1,Q1,S1,U1,W1,Y1,A2)),
'$run_suspensions_generate_empty_named_history_initialisation___1'(M),
'$run_suspensions_background_info___2'(K1),
'$run_suspensions_get_bg_info___2'(M1),
'$run_suspensions_type_definition___2'(O1),
'$run_suspensions_type_alias___2'(Q1),
'$run_suspensions_unalias_type___2'(S1),
'$run_suspensions_static_type_check_var___3'(U1),
'$run_suspensions_static_atomic_builtin_type_check_var___3'(W1),
'$run_suspensions_atomic_type___1'(Y1),
'$run_suspensions_enumerated_atomic_type___2'(A2)
;
put_attr(A,chr_translate,v(L,M,N,O,P,Q,R,S,T,U,V)),
'$run_suspensions_generate_empty_named_history_initialisation___1'(M),
'$run_suspensions_background_info___2'(N),
'$run_suspensions_get_bg_info___2'(O),
'$run_suspensions_type_definition___2'(P),
'$run_suspensions_type_alias___2'(Q),
'$run_suspensions_unalias_type___2'(R),
'$run_suspensions_static_type_check_var___3'(S),
'$run_suspensions_static_atomic_builtin_type_check_var___3'(T),
'$run_suspensions_atomic_type___1'(U),
'$run_suspensions_enumerated_atomic_type___2'(V)
)
;
( compound(A) ->
term_variables(A,D2),
attach_increment(D2,v(L,M,N,O,P,Q,R,S,T,U,V))
;
true
),
'$run_suspensions_generate_empty_named_history_initialisation___1'(M),
'$run_suspensions_background_info___2'(N),
'$run_suspensions_get_bg_info___2'(O),
'$run_suspensions_type_definition___2'(P),
'$run_suspensions_type_alias___2'(Q),
'$run_suspensions_unalias_type___2'(R),
'$run_suspensions_static_type_check_var___3'(S),
'$run_suspensions_static_atomic_builtin_type_check_var___3'(T),
'$run_suspensions_atomic_type___1'(U),
'$run_suspensions_enumerated_atomic_type___2'(V)
).
'$novel_production'(A,B) :-
arg(3,A,C),
( hprolog:get_ds(B,C,_) ->
fail
;
true
).
'$extend_history'(A,B) :-
arg(3,A,C),
hprolog:put_ds(B,C,x,D),
setarg(3,A,D).
'$run_suspensions_generate_empty_named_history_initialisation___1'([]).
'$run_suspensions_generate_empty_named_history_initialisation___1'([A|B]) :-
A=suspension(_,C,D,_,E),
( C==active ->
setarg(2,A,triggered),
F is D+1,
setarg(3,A,F),
generate_empty_named_history_initialisation___1__0(E,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_generate_empty_named_history_initialisation___1'(B).
'$run_suspensions_background_info___2'([]).
'$run_suspensions_background_info___2'([A|B]) :-
A=suspension(_,C,_,D,_,E,F),
setarg(2,A,triggered),
G is D+1,
setarg(4,A,G),
background_info___2__0(E,F,A),
( C==triggered ->
setarg(2,A,active)
;
true
),
'$run_suspensions_background_info___2'(B).
'$run_suspensions_get_bg_info___2'([]).
'$run_suspensions_get_bg_info___2'([A|B]) :-
A=suspension(_,C,_,D,_,E,F),
( C==active ->
setarg(2,A,triggered),
G is D+1,
setarg(4,A,G),
get_bg_info___2__0(E,F,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_get_bg_info___2'(B).
'$run_suspensions_type_definition___2'([]).
'$run_suspensions_type_definition___2'([A|B]) :-
A=suspension(_,C,_,D,_,E,F),
( C==active ->
setarg(2,A,triggered),
G is D+1,
setarg(4,A,G),
type_definition___2__0(E,F,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_type_definition___2'(B).
'$run_suspensions_type_alias___2'([]).
'$run_suspensions_type_alias___2'([A|B]) :-
A=suspension(_,C,_,D,_,E,F),
( C==active ->
setarg(2,A,triggered),
G is D+1,
setarg(4,A,G),
type_alias___2__0(E,F,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_type_alias___2'(B).
'$run_suspensions_unalias_type___2'([]).
'$run_suspensions_unalias_type___2'([A|B]) :-
A=suspension(_,C,_,D,E),
( C==active ->
setarg(2,A,triggered),
unalias_type___2__0(D,E,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_unalias_type___2'(B).
'$run_suspensions_static_type_check_var___3'([]).
'$run_suspensions_static_type_check_var___3'([A|B]) :-
A=suspension(_,C,_,D,E,F),
( C==active ->
setarg(2,A,triggered),
static_type_check_var___3__0(D,E,F,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_static_type_check_var___3'(B).
'$run_suspensions_static_atomic_builtin_type_check_var___3'([]).
'$run_suspensions_static_atomic_builtin_type_check_var___3'([A|B]) :-
A=suspension(_,C,_,D,E,F),
( C==active ->
setarg(2,A,triggered),
static_atomic_builtin_type_check_var___3__0(D,E,F,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_static_atomic_builtin_type_check_var___3'(B).
'$run_suspensions_atomic_type___1'([]).
'$run_suspensions_atomic_type___1'([A|B]) :-
A=suspension(_,C,_,D),
( C==active ->
setarg(2,A,triggered),
atomic_type___1__0(D,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_atomic_type___1'(B).
'$run_suspensions_enumerated_atomic_type___2'([]).
'$run_suspensions_enumerated_atomic_type___2'([A|B]) :-
A=suspension(_,C,_,D,E),
( C==active ->
setarg(2,A,triggered),
enumerated_atomic_type___2__0(D,E,A),
( C==triggered ->
setarg(2,A,active)
;
true
)
;
true
),
'$run_suspensions_enumerated_atomic_type___2'(B).
'$enumerate_constraints'(A) :-
( nonvar(A) ->
functor(A,B,_),
'$enumerate_constraints'(B,A)
;
'$enumerate_constraints'(_,A)
).
'$enumerate_constraints'(chr_source_file,A) :-
nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=chr_source_file(D).
'$enumerate_constraints'(target_module,A) :-
nb_getval('$chr_store_global_ground_chr_translate____target_module___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=target_module(D).
'$enumerate_constraints'(line_number,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=line_number(D,E).
'$enumerate_constraints'(indexed_argument,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=indexed_argument(D,E).
'$enumerate_constraints'(constraint_mode,A) :-
nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D,E),
A=constraint_mode(D,E).
'$enumerate_constraints'(none_suspended_on_variables,A) :-
nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_),
A=none_suspended_on_variables.
'$enumerate_constraints'(store_type,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=store_type(D,E).
'$enumerate_constraints'(actual_store_types,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=actual_store_types(D,E).
'$enumerate_constraints'(assumed_store_type,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=assumed_store_type(D,E).
'$enumerate_constraints'(validate_store_type_assumption,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=validate_store_type_assumption(D).
'$enumerate_constraints'(rule_count,A) :-
nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=rule_count(D).
'$enumerate_constraints'(passive,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=passive(D,E).
'$enumerate_constraints'(occurrence,A) :-
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D,E,F,G,H),
A=occurrence(D,E,F,G,H).
'$enumerate_constraints'(max_occurrence,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=max_occurrence(D,E).
'$enumerate_constraints'(allocation_occurrence,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=allocation_occurrence(D,E).
'$enumerate_constraints'(rule,A) :-
nb_getval('$chr_store_global_ground_chr_translate____rule___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D,E),
A=rule(D,E).
'$enumerate_constraints'(least_occurrence,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=least_occurrence(D,E).
'$enumerate_constraints'(constraint_index,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=constraint_index(D,E).
'$enumerate_constraints'(max_constraint_index,A) :-
nb_getval('$chr_store_global_ground_chr_translate____max_constraint_index___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=max_constraint_index(D).
'$enumerate_constraints'(identifier_size,A) :-
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=identifier_size(D).
'$enumerate_constraints'(identifier_index,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=identifier_index(D,E,F).
'$enumerate_constraints'(type_indexed_identifier_size,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=type_indexed_identifier_size(D,E).
'$enumerate_constraints'(type_indexed_identifier_index,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',B),
value_ht(B,C),
C=suspension(_,_,D,E,F,G),
A=type_indexed_identifier_index(D,E,F,G).
'$enumerate_constraints'(no_history,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=no_history(D).
'$enumerate_constraints'(history,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',B),
value_ht(B,C),
C=suspension(_,_,_,D,E,F),
A=history(D,E,F).
'$enumerate_constraints'(indexing_spec,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=indexing_spec(D,E).
'$enumerate_constraints'(observation_analysis,A) :-
nb_getval('$chr_store_global_ground_chr_translate____observation_analysis___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=observation_analysis(D).
'$enumerate_constraints'(spawns,A) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D,E,F),
A=spawns(D,E,F).
'$enumerate_constraints'(spawns_all,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=spawns_all(D,E).
'$enumerate_constraints'(spawns_all_triggers,A) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D,E),
A=spawns_all_triggers(D,E).
'$enumerate_constraints'(spawns_all_triggers_implies_spawns_all,A) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_),
A=spawns_all_triggers_implies_spawns_all.
'$enumerate_constraints'(empty_named_history_initialisations,A) :-
nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=empty_named_history_initialisations(D,E).
'$enumerate_constraints'(generate_empty_named_history_initialisation,A) :-
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D),
A=generate_empty_named_history_initialisation(D).
'$enumerate_constraints'(find_empty_named_histories,A) :-
nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_),
A=find_empty_named_histories.
'$enumerate_constraints'(module_initializer,A) :-
nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=module_initializer(D).
'$enumerate_constraints'(actual_atomic_multi_hash_keys,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=actual_atomic_multi_hash_keys(D,E,F).
'$enumerate_constraints'(actual_ground_multi_hash_keys,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=actual_ground_multi_hash_keys(D,E,F).
'$enumerate_constraints'(actual_non_ground_multi_hash_key,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=actual_non_ground_multi_hash_key(D,E).
'$enumerate_constraints'(prolog_global_variable,A) :-
nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=prolog_global_variable(D).
'$enumerate_constraints'(background_info,A) :-
nb_getval('$chr_store_global_ground_chr_translate____background_info___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=background_info(D).
'$enumerate_constraints'(background_info,A) :-
nb_getval('$chr_store_global_list_chr_translate____background_info___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,_,D,E),
A=background_info(D,E).
'$enumerate_constraints'(get_bg_info,A) :-
nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,_,D,E),
A=get_bg_info(D,E).
'$enumerate_constraints'(get_bg_info_answer,A) :-
nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=get_bg_info_answer(D).
'$enumerate_constraints'(prev_guard_list,A) :-
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,D,E,F,G,H,I),
A=prev_guard_list(D,E,F,G,H,I).
'$enumerate_constraints'(set_all_passive,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',B),
value_ht(B,C),
C=suspension(_,_,_,D),
A=set_all_passive(D).
'$enumerate_constraints'(precompute_head_matchings,A) :-
nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_),
A=precompute_head_matchings.
'$enumerate_constraints'(make_head_matchings_explicit_memo_table,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=make_head_matchings_explicit_memo_table(D,E,F).
'$enumerate_constraints'(multiple_occ_constraints_checked,A) :-
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=multiple_occ_constraints_checked(D).
'$enumerate_constraints'(type_definition,A) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,_,D,E),
A=type_definition(D,E).
'$enumerate_constraints'(type_alias,A) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_,_,D,E),
A=type_alias(D,E).
'$enumerate_constraints'(constraint_type,A) :-
nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=constraint_type(D,E).
'$enumerate_constraints'(unalias_type,A) :-
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=unalias_type(D,E).
'$enumerate_constraints'(types_modes_condition,A) :-
nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E,F),
A=types_modes_condition(D,E,F).
'$enumerate_constraints'(static_type_check,A) :-
nb_getval('$chr_store_global_ground_chr_translate____static_type_check___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_),
A=static_type_check.
'$enumerate_constraints'(static_type_check_var,A) :-
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E,F),
A=static_type_check_var(D,E,F).
'$enumerate_constraints'(static_atomic_builtin_type_check_var,A) :-
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E,F),
A=static_atomic_builtin_type_check_var(D,E,F).
'$enumerate_constraints'(dynamic_type_check,A) :-
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_),
A=dynamic_type_check.
'$enumerate_constraints'(dynamic_type_check_clauses,A) :-
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=dynamic_type_check_clauses(D).
'$enumerate_constraints'(atomic_type,A) :-
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=atomic_type(D).
'$enumerate_constraints'(enumerated_atomic_type,A) :-
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=enumerated_atomic_type(D,E).
'$enumerate_constraints'(stored,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=stored(D,E,F).
'$enumerate_constraints'(stored_complete,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',B),
value_ht(B,C),
C=suspension(_,_,_,D,E,F),
A=stored_complete(D,E,F).
'$enumerate_constraints'(check_all_passive,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=check_all_passive(D,E).
'$enumerate_constraints'(constraints_code1,A) :-
nb_getval('$chr_store_global_ground_chr_translate____constraints_code1___3',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E,F),
A=constraints_code1(D,E,F).
'$enumerate_constraints'(memo_has_active_occurrence,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=memo_has_active_occurrence(D).
'$enumerate_constraints'(use_auxiliary_predicate,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=use_auxiliary_predicate(D).
'$enumerate_constraints'(use_auxiliary_predicate,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=use_auxiliary_predicate(D,E).
'$enumerate_constraints'(use_auxiliary_module,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=use_auxiliary_module(D).
'$enumerate_constraints'(functional_dependency,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',B),
value_ht(B,C),
C=suspension(_,_,D,E,F,G),
A=functional_dependency(D,E,F,G).
'$enumerate_constraints'(initial_call_pattern,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',B),
value_ht(B,C),
C=suspension(_,_,_,D),
A=initial_call_pattern(D).
'$enumerate_constraints'(call_pattern,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=call_pattern(D).
'$enumerate_constraints'(final_answer_pattern,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=final_answer_pattern(D,E).
'$enumerate_constraints'(abstract_constraints,A) :-
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D),
A=abstract_constraints(D).
'$enumerate_constraints'(depends_on,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=depends_on(D,E).
'$enumerate_constraints'(depends_on_ap,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',B),
value_ht(B,C),
C=suspension(_,_,_,D,E,F,G),
A=depends_on_ap(D,E,F,G).
'$enumerate_constraints'(depends_on_goal,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=depends_on_goal(D,E).
'$enumerate_constraints'(ai_observed_internal,A) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=ai_observed_internal(D,E).
'$enumerate_constraints'(ai_not_observed_internal,A) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=ai_not_observed_internal(D,E).
'$enumerate_constraints'(ai_not_observed,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=ai_not_observed(D,E).
'$enumerate_constraints'(depends_on_as,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',B),
value_ht(B,C),
C=suspension(_,_,_,D,E,F),
A=depends_on_as(D,E,F).
'$enumerate_constraints'(ai_observation_gather_results,A) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_),
A=ai_observation_gather_results.
'$enumerate_constraints'(ai_observation_memoed_simplification_rest_heads,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=ai_observation_memoed_simplification_rest_heads(D,E,F).
'$enumerate_constraints'(ai_observation_memoed_propagation_rest_heads,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=ai_observation_memoed_propagation_rest_heads(D,E,F).
'$enumerate_constraints'(ai_observation_memoed_abstract_goal,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=ai_observation_memoed_abstract_goal(D,E).
'$enumerate_constraints'(ai_observation_memo_abstract_goal,A) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=ai_observation_memo_abstract_goal(D,E).
'$enumerate_constraints'(partial_wake_analysis,A) :-
nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,_),
A=partial_wake_analysis.
'$enumerate_constraints'(no_partial_wake,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=no_partial_wake(D).
'$enumerate_constraints'(phase_end,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=phase_end(D).
'$enumerate_constraints'(delay_phase_end,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=delay_phase_end(D,E).
'$enumerate_constraints'(does_use_history,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=does_use_history(D,E).
'$enumerate_constraints'(does_use_field,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=does_use_field(D,E).
'$enumerate_constraints'(uses_state,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=uses_state(D,E).
'$enumerate_constraints'(if_used_state,A) :-
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E,F,G,H),
A=if_used_state(D,E,F,G,H).
'$enumerate_constraints'(used_states_known,A) :-
nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_),
A=used_states_known.
'$enumerate_constraints'(stored_assertion,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',B),
value_ht(B,C),
C=suspension(_,_,D),
A=stored_assertion(D).
'$enumerate_constraints'(never_stored_default,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',B),
value_ht(B,C),
C=suspension(_,_,D,E),
A=never_stored_default(D,E).
'$enumerate_constraints'(never_stored_rules,A) :-
nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=never_stored_rules(D,E).
'$enumerate_constraints'(continuation_occurrence,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=continuation_occurrence(D,E,F).
'$enumerate_constraints'(skip_to_next_id,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',B),
value_ht(B,C),
C=suspension(_,_,_,D,E),
A=skip_to_next_id(D,E).
'$enumerate_constraints'(set_occurrence_code_id,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=set_occurrence_code_id(D,E,F).
'$enumerate_constraints'(occurrence_code_id,A) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',B),
value_ht(B,C),
C=suspension(_,_,D,E,F),
A=occurrence_code_id(D,E,F).
'$enumerate_constraints'(chr_constants,A) :-
nb_getval('$chr_store_global_ground_chr_translate____chr_constants___2',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_,D,E),
A=chr_constants(D,E).
'$enumerate_constraints'(print_chr_constants,A) :-
nb_getval('$chr_store_global_ground_chr_translate____print_chr_constants___0',C),
'chr sbag_member'(B,C),
B=suspension(_,_,_),
A=print_chr_constants.
'$via1_multi_hash_line_number___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',C),
lookup_ht1(C,A,A,B).
'$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).
'$via1_multi_hash_indexed_argument___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',C),
lookup_ht(C,A,B).
'$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).
'$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).
'$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).
'$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).
'$via1_multi_hash_validate_store_type_assumption___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_passive___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_occurrence___5-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_occurrence___5-3'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',C),
lookup_ht1(C,A,A,B).
'$via1_multi_hash_occurrence___5-34'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',C),
lookup_ht(C,A,B).
'$via1_multi_hash_occurrence___5-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',C),
lookup_ht(C,A,B).
'$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).
'$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).
'$via1_multi_hash_allocation_occurrence___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_rule___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',C),
lookup_ht1(C,A,A,B).
'$via1_multi_hash_least_occurrence___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_constraint_index___2-2'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',C),
D is abs(A),
lookup_ht1(C,D,A,B).
'$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).
'$via1_multi_hash_identifier_index___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_type_indexed_identifier_size___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_type_indexed_identifier_index___4-123'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',C),
lookup_ht(C,A,B).
'$via1_multi_hash_type_indexed_identifier_index___4-23'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',C),
lookup_ht(C,A,B).
'$via1_multi_hash_no_history___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',C),
D is abs(A),
lookup_ht1(C,D,A,B).
'$chr_store_constants_chr_translate____history___3___[3]'([],'$chr_store_constants_chr_translate____history___3___[3]___[]').
'$via1_multi_hash_history___3-2'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',C),
lookup_ht(C,A,B).
'$via1_multi_hash_history___3-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_indexing_spec___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns___3-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns___3-3'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns___3-123'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns_all___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns_all___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns_all_triggers___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_spawns_all_triggers___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_actual_atomic_multi_hash_keys___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_actual_atomic_multi_hash_keys___3-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_actual_ground_multi_hash_keys___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_actual_ground_multi_hash_keys___3-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_actual_non_ground_multi_hash_key___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_prolog_global_variable___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_prev_guard_list___6-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_make_head_matchings_explicit_memo_table___3-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',C),
lookup_ht(C,A,B).
'$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).
'$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).
'$via1_multi_hash_stored___3-123'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_check_all_passive___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_memo_has_active_occurrence___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_use_auxiliary_predicate___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_use_auxiliary_predicate___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_use_auxiliary_module___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',C),
lookup_ht(C,A,B).
'$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).
'$via1_multi_hash_functional_dependency___4-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',C),
lookup_ht(C,A,B).
'$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).
'$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).
'$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).
'$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).
'$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).
'$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).
'$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).
'$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).
'$via1_multi_hash_ai_observed_internal___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_ai_not_observed_internal___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_ai_not_observed___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',C),
lookup_ht(C,A,B).
'$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).
'$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).
'$via1_multi_hash_ai_observation_memoed_simplification_rest_heads___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_ai_observation_memoed_propagation_rest_heads___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_ai_observation_memoed_abstract_goal___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_no_partial_wake___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_phase_end___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_delay_phase_end___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_does_use_history___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_does_use_history___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_does_use_field___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_uses_state___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_if_used_state___5-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_stored_assertion___1-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_never_stored_default___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',C),
lookup_ht(C,A,B).
'$via1_multi_hash_continuation_occurrence___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_skip_to_next_id___2-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_set_occurrence_code_id___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_occurrence_code_id___3-12'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',C),
lookup_ht(C,A,B).
'$via1_multi_hash_chr_constants___2-1'(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____chr_constants___2-1',C),
lookup_ht(C,A,B).
'$chr_initialization' :-
nb_setval('$chr_store_global_ground_chr_translate____print_chr_constants___0',[]),
new_ht(M3),
nb_setval('$chr_store_multi_hash_chr_translate____chr_constants___2-1',M3),
nb_setval('$chr_store_global_ground_chr_translate____chr_constants___2',[]),
new_ht(L3),
nb_setval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',L3),
new_ht(K3),
nb_setval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',K3),
new_ht(J3),
nb_setval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',J3),
new_ht(I3),
nb_setval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',I3),
nb_setval('$chr_store_global_ground_chr_translate____never_stored_rules___2',[]),
new_ht(H3),
nb_setval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',H3),
new_ht(G3),
nb_setval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',G3),
nb_setval('$chr_store_global_ground_chr_translate____used_states_known___0',[]),
new_ht(F3),
nb_setval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',F3),
nb_setval('$chr_store_global_ground_chr_translate____if_used_state___5',[]),
new_ht(E3),
nb_setval('$chr_store_multi_hash_chr_translate____uses_state___2-12',E3),
new_ht(D3),
nb_setval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',D3),
new_ht(C3),
nb_setval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',C3),
new_ht(B3),
nb_setval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',B3),
new_ht(A3),
nb_setval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',A3),
new_ht(Z2),
nb_setval('$chr_store_multi_hash_chr_translate____phase_end___1-1',Z2),
new_ht(Y2),
nb_setval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',Y2),
nb_setval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',[]),
nb_setval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',[]),
new_ht(X2),
nb_setval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',X2),
new_ht(W2),
nb_setval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',W2),
new_ht(V2),
nb_setval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',V2),
nb_setval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',[]),
new_ht(U2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',U2),
new_ht(T2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',T2),
new_ht(S2),
nb_setval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',S2),
new_ht(R2),
nb_setval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',R2),
nb_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',[]),
new_ht(Q2),
nb_setval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',Q2),
nb_setval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',[]),
new_ht(P2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',P2),
new_ht(O2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',O2),
new_ht(N2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',N2),
new_ht(M2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on___2-2',M2),
new_ht(L2),
nb_setval('$chr_store_multi_hash_chr_translate____depends_on___2-1',L2),
nb_setval('$chr_store_global_ground_chr_translate____abstract_constraints___1',[]),
new_ht(K2),
nb_setval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',K2),
new_ht(J2),
nb_setval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',J2),
new_ht(I2),
nb_setval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',I2),
new_ht(H2),
nb_setval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',H2),
new_ht(G2),
nb_setval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',G2),
new_ht(F2),
nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',F2),
new_ht(E2),
nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',E2),
new_ht(D2),
nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',D2),
new_ht(C2),
nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',C2),
new_ht(B2),
nb_setval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',B2),
nb_setval('$chr_store_global_ground_chr_translate____constraints_code1___3',[]),
new_ht(A2),
nb_setval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',A2),
new_ht(Z1),
nb_setval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',Z1),
new_ht(Y1),
nb_setval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',Y1),
new_ht(X1),
nb_setval('$chr_store_multi_hash_chr_translate____stored___3-123',X1),
new_ht(W1),
nb_setval('$chr_store_multi_hash_chr_translate____stored___3-1',W1),
nb_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',[]),
nb_setval('$chr_store_global_list_chr_translate____atomic_type___1',[]),
nb_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',[]),
nb_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',[]),
nb_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',[]),
nb_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',[]),
nb_setval('$chr_store_global_ground_chr_translate____static_type_check___0',[]),
nb_setval('$chr_store_global_ground_chr_translate____types_modes_condition___3',[]),
nb_setval('$chr_store_global_list_chr_translate____unalias_type___2',[]),
new_ht(V1),
nb_setval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',V1),
nb_setval('$chr_store_global_ground_chr_translate____constraint_type___2',[]),
nb_setval('$chr_store_global_list_chr_translate____type_alias___2',[]),
nb_setval('$chr_store_global_list_chr_translate____type_definition___2',[]),
nb_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',[]),
new_ht(U1),
nb_setval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',U1),
nb_setval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',[]),
new_ht(T1),
nb_setval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',T1),
new_ht(S1),
nb_setval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',S1),
nb_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',[]),
nb_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',[]),
nb_setval('$chr_store_global_list_chr_translate____get_bg_info___2',[]),
nb_setval('$chr_store_global_list_chr_translate____background_info___2',[]),
nb_setval('$chr_store_global_ground_chr_translate____background_info___1',[]),
new_ht(R1),
nb_setval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',R1),
nb_setval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',[]),
new_ht(Q1),
nb_setval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',Q1),
new_ht(P1),
nb_setval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',P1),
new_ht(O1),
nb_setval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',O1),
new_ht(N1),
nb_setval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',N1),
new_ht(M1),
nb_setval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',M1),
nb_setval('$chr_store_global_ground_chr_translate____module_initializer___1',[]),
nb_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',[]),
nb_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',[]),
nb_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',[]),
nb_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',[]),
new_ht(L1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',L1),
new_ht(K1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',K1),
nb_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',[]),
new_ht(J1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',J1),
new_ht(I1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',I1),
new_ht(H1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-123',H1),
new_ht(G1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-3',G1),
new_ht(F1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-1',F1),
new_ht(E1),
nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-12',E1),
nb_setval('$chr_store_global_ground_chr_translate____spawns___3',[]),
nb_setval('$chr_store_global_ground_chr_translate____observation_analysis___1',[]),
new_ht(D1),
nb_setval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',D1),
new_ht(C1),
nb_setval('$chr_store_multi_hash_chr_translate____history___3-1',C1),
new_ht(B1),
nb_setval('$chr_store_multi_hash_chr_translate____history___3-2',B1),
nb_setval('$chr_store_constants_chr_translate____history___3___[3]___[]',[]),
new_ht(A1),
nb_setval('$chr_store_multi_hash_chr_translate____no_history___1-1',A1),
new_ht(Z),
nb_setval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',Z),
new_ht(Y),
nb_setval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',Y),
new_ht(X),
nb_setval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',X),
new_ht(W),
nb_setval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',W),
nb_setval('$chr_store_global_ground_chr_translate____identifier_size___1',[]),
nb_setval('$chr_store_global_ground_chr_translate____max_constraint_index___1',[]),
new_ht(V),
nb_setval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',V),
new_ht(U),
nb_setval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',U),
new_ht(T),
nb_setval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',T),
new_ht(S),
nb_setval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',S),
new_ht(R),
nb_setval('$chr_store_multi_hash_chr_translate____rule___2-1',R),
nb_setval('$chr_store_global_ground_chr_translate____rule___2',[]),
new_ht(Q),
nb_setval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',Q),
new_ht(P),
nb_setval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',P),
new_ht(O),
nb_setval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',O),
new_ht(N),
nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-1',N),
new_ht(M),
nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-34',M),
new_ht(L),
nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-3',L),
new_ht(K),
nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-12',K),
nb_setval('$chr_store_global_ground_chr_translate____occurrence___5',[]),
new_ht(J),
nb_setval('$chr_store_multi_hash_chr_translate____passive___2-12',J),
new_ht(I),
nb_setval('$chr_store_multi_hash_chr_translate____passive___2-1',I),
nb_setval('$chr_store_global_ground_chr_translate____rule_count___1',[]),
new_ht(H),
nb_setval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',H),
new_ht(G),
nb_setval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',G),
new_ht(F),
nb_setval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',F),
new_ht(E),
nb_setval('$chr_store_multi_hash_chr_translate____store_type___2-1',E),
nb_setval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',[]),
new_ht(D),
nb_setval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',D),
nb_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',[]),
new_ht(C),
nb_setval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',C),
new_ht(B),
nb_setval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',B),
new_ht(A),
nb_setval('$chr_store_multi_hash_chr_translate____line_number___2-1',A),
nb_setval('$chr_store_global_ground_chr_translate____target_module___1',[]),
nb_setval('$chr_store_global_ground_chr_translate____chr_source_file___1',[]).
:-initialization '$chr_initialization'.
:-dynamic user:exception/3.
:-multifile user:exception/3.
user:exception(undefined_global_variable,A,retry) :-
'$chr_prolog_global_variable'(A),
'$chr_initialization'.
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____print_chr_constants___0').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____chr_constants___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____chr_constants___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____never_stored_rules___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____never_stored_default___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored_assertion___1-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____used_states_known___0').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____if_used_state___5-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____if_used_state___5').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____uses_state___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____does_use_field___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____does_use_history___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____does_use_history___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____phase_end___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____partial_wake_analysis___0').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_as___3-2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_as___3-3').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_observed_internal___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on___2-2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____abstract_constraints___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____call_pattern___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____functional_dependency___4-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____functional_dependency___4-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____constraints_code1___3').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____check_all_passive___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____check_all_passive___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored_complete___3-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored___3-123').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored___3-1').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____enumerated_atomic_type___2').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____atomic_type___1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____dynamic_type_check___0').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____static_type_check_var___3').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____static_type_check___0').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____types_modes_condition___3').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____unalias_type___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_type___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____constraint_type___2').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____type_alias___2').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____type_definition___2').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____precompute_head_matchings___0').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____set_all_passive___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____prev_guard_list___6').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____get_bg_info_answer___1').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____get_bg_info___2').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____background_info___2').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____background_info___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____prolog_global_variable___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____module_initializer___1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____find_empty_named_histories___0').
'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____spawns_all_triggers___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-123').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-3').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____spawns___3').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____observation_analysis___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____indexing_spec___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____history___3-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____history___3-2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____no_history___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____identifier_index___3-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____identifier_size___1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____max_constraint_index___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_index___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_index___2-2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____least_occurrence___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____least_occurrence___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____rule___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____rule___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____max_occurrence___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-34').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-3').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-12').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____occurrence___5').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____passive___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____passive___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____rule_count___1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_store_types___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____store_type___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_mode___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____constraint_mode___2').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____indexed_argument___2-12').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____indexed_argument___2-1').
'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____line_number___2-1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____target_module___1').
'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____chr_source_file___1').
chr_source_file(A) :-
nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',C),
(
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!
;
!,
chr_source_file___1__0__0__2(C,A)
).
chr_source_file___1__0__0__2([],A) :-
chr_source_file___1__1(A).
chr_source_file___1__0__0__2([B|C],A) :-
( B=suspension(_,active,_,_) ->
setarg(2,B,removed),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',E),
E=[_|F],
b_setval('$chr_store_global_ground_chr_translate____chr_source_file___1',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
chr_source_file___1__0__0__2(C,A)
;
chr_source_file___1__0__0__2(C,A)
).
chr_source_file(A) :-
chr_source_file___1__1(A).
chr_source_file___1__1(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____chr_source_file___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
get_chr_source_file(A) :-
nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
A=C.
get_chr_source_file(user).
target_module(A) :-
nb_getval('$chr_store_global_ground_chr_translate____target_module___1',C),
(
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!
;
!,
target_module___1__0__0__2(C,A)
).
target_module___1__0__0__2([],A) :-
target_module___1__1(A).
target_module___1__0__0__2([B|C],A) :-
( B=suspension(_,active,_,_) ->
setarg(2,B,removed),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_ground_chr_translate____target_module___1',E),
E=[_|F],
b_setval('$chr_store_global_ground_chr_translate____target_module___1',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
target_module___1__0__0__2(C,A)
;
target_module___1__0__0__2(C,A)
).
target_module(A) :-
target_module___1__1(A).
target_module___1__1(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____target_module___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____target_module___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
get_target_module(A) :-
nb_getval('$chr_store_global_ground_chr_translate____target_module___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
A=C.
get_target_module(user).
line_number(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',E),
lookup_ht1(E,A,A,D),
(
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!
;
!,
line_number___2__0__0__2(D,A,B)
).
line_number___2__0__0__2([],A,B) :-
line_number___2__1(A,B).
line_number___2__0__0__2([D|E],A,B) :-
( D=suspension(_,active,C,_),
C==A ->
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',F),
delete_ht(F,A,D),
line_number___2__0__0__2(E,A,B)
;
line_number___2__0__0__2(E,A,B)
).
line_number(A,B) :-
line_number___2__1(A,B).
line_number___2__1(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',E),
insert_ht(E,A,C).
get_line_number(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',F),
lookup_ht1(F,A,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
get_line_number(_,0).
indexed_argument(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
indexed_argument(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',F),
insert_ht(F,k(A,B),C).
is_indexed_argument(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
is_indexed_argument(_,_) :-
fail.
constraint_mode(A,B) :-
constraint_mode___2__0(A,B,_).
constraint_mode___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',F),
lookup_ht(F,A,E),
(
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_,_),
!
;
!,
constraint_mode___2__0__0__2(E,A,B,C)
).
constraint_mode___2__0__0__2([],B,C,A) :-
constraint_mode___2__1(B,C,A).
constraint_mode___2__0__0__2([E|F],A,B,C) :-
( E=suspension(_,active,_,_,D,_),
D==A ->
setarg(2,E,removed),
arg(4,E,G),
( var(G) ->
nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',H),
H=[_|I],
b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',I),
( I=[J|_] ->
setarg(4,J,_)
;
true
)
;
G=[_,_|I],
setarg(2,G,I),
( I=[J|_] ->
setarg(4,J,G)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',K),
delete_ht(K,A,E),
constraint_mode___2__0__0__2(F,A,B,C)
;
constraint_mode___2__0__0__2(F,A,B,C)
).
constraint_mode___2__0(A,B,C) :-
constraint_mode___2__1(A,B,C).
constraint_mode___2__1(A,B,C) :-
A=D/E,
nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',F),
!,
C=suspension(G,not_stored_yet,t,_,A,B),
'chr gen_id'(G),
constraint_mode___2__1__0__7(F,A,B,C,D,E).
constraint_mode___2__1__0__7([],B,C,A,_,_) :-
constraint_mode___2__2(B,C,A).
constraint_mode___2__1__0__7([I|N],A,B,C,D,E) :-
( I=suspension(_,active,_,F,G,H),
F=[J|K],
G=[L|M],
functor(J,D,E) ->
setarg(2,I,removed),
arg(3,I,Z),
( var(Z) ->
nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',A1),
A1=[_|B1],
b_setval('$chr_store_global_ground_chr_translate____types_modes_condition___3',B1),
( B1=[C1|_] ->
setarg(3,C1,_)
;
true
)
;
Z=[_,_|B1],
setarg(2,Z,B1),
( B1=[C1|_] ->
setarg(3,C1,Z)
;
true
)
),
arg(2,C,U),
setarg(2,C,active),
( U==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',V),
W=[C|V],
b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',W),
( V=[X|_] ->
setarg(4,X,W)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',Y),
insert_ht(Y,A,C)
;
true
),
J=..[_|O],
H=(P,Q,R),
modes_condition(B,O,P),
get_constraint_type_det(D/E,S),
L=..[_|T],
types_condition(S,O,T,B,Q),
types_modes_condition(K,M,R),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
constraint_mode___2__1__0__7(N,A,B,C,D,E)
;
true
)
;
constraint_mode___2__1__0__7(N,A,B,C,D,E)
).
constraint_mode___2__1(A,B,C) :-
C=suspension(D,not_stored_yet,t,_,A,B),
'chr gen_id'(D),
constraint_mode___2__2(A,B,C).
constraint_mode___2__2(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',E),
lookup_ht(E,A,D),
!,
constraint_mode___2__2__0__8(D,A,B,C).
constraint_mode___2__2__0__8([],B,C,A) :-
constraint_mode___2__3(B,C,A).
constraint_mode___2__2__0__8([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,_,E,F,G),
D==B,
nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',I) ->
constraint_mode___2__2__1__8(I,E,F,G,H,J,B,C,A)
;
constraint_mode___2__2__0__8(J,B,C,A)
).
constraint_mode___2__2__1__8([],_,_,_,_,A,C,D,B) :-
constraint_mode___2__2__0__8(A,C,D,B).
constraint_mode___2__2__1__8([I|K],F,G,H,A,B,D,E,C) :-
( I=suspension(_,active,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',L),
lookup_ht1(L,F,F,J) ->
constraint_mode___2__2__2__8(J,I,K,F,G,H,A,B,D,E,C)
;
constraint_mode___2__2__1__8(K,F,G,H,A,B,D,E,C)
).
constraint_mode___2__2__2__8([],_,A,G,H,I,B,C,E,F,D) :-
constraint_mode___2__2__1__8(A,G,H,I,B,C,E,F,D).
constraint_mode___2__2__2__8([M|N],A,B,H,I,J,C,D,F,G,E) :-
( M=suspension(_,active,_,_,K,L),
K==H,
U=t(325,A,C,M,E),
'$novel_production'(A,U),
'$novel_production'(C,U),
'$novel_production'(M,U),
'$novel_production'(E,U) ->
'$extend_history'(E,U),
arg(2,E,V),
setarg(2,E,active),
( V==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',W),
X=[E|W],
b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',X),
( W=[Y|_] ->
setarg(4,Y,X)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',Z),
insert_ht(Z,F,E)
;
true
),
L=pragma(rule(O,P,Q,_),_,_,_,_),
( is_passive(H,I) ->
true
;
( J==simplification ->
select(R,O,_),
R=..[_|S],
term_variables(Q,T),
partial_wake_args(S,G,T,F)
)
;
select(R,P,_),
R=..[_|S],
term_variables(Q,T),
partial_wake_args(S,G,T,F)
),
( E=suspension(_,active,_,_,_,_) ->
setarg(2,E,inactive),
constraint_mode___2__2__2__8(N,A,B,H,I,J,C,D,F,G,E)
;
true
)
;
constraint_mode___2__2__2__8(N,A,B,H,I,J,C,D,F,G,E)
).
constraint_mode___2__2(A,B,C) :-
constraint_mode___2__3(A,B,C).
constraint_mode___2__3(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',E),
( D=[F|_] ->
setarg(4,F,E)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',G),
insert_ht(G,A,B)
;
true
).
get_constraint_mode(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,D),
!,
B=D.
get_constraint_mode(_/B,A) :-
replicate(B,?,A).
may_trigger(A) :-
\+has_active_occurrence(A),
!,
fail.
may_trigger(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',J),
lookup_ht(J,A,D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,_,C),
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',I),
lookup_ht(I,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,F),
nth1(F,C,H),
H\== +,
!,
is_stored(A).
may_trigger(_) :-
chr_pp_flag(debugable,on).
only_ground_indexed_arguments(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',J),
lookup_ht(J,A,D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,_,C),
nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',I),
lookup_ht(I,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,F),
nth1(F,C,H),
H\== +,
!,
fail.
only_ground_indexed_arguments(_).
none_suspended_on_variables :-
nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',B),
'chr sbag_member'(A,B),
A=suspension(_,active,_),
!.
none_suspended_on_variables :-
A=suspension(B,active,_),
'chr gen_id'(B),
nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',C),
D=[A|C],
b_setval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',D),
( C=[E|_] ->
setarg(3,E,D)
;
true
).
are_none_suspended_on_variables :-
nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',B),
'chr sbag_member'(A,B),
A=suspension(_,active,_),
!.
are_none_suspended_on_variables :-
fail.
store_type(A,B) :-
store_type___2__0(A,B,_).
store_type___2__0(A,B,C) :-
chr_pp_flag(verbose,on),
!,
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',E),
insert_ht(E,A,C),
format('The indexes for ~w are:
',[A]),
format_storetype(B),
( C=suspension(_,active,_,_) ->
setarg(2,C,inactive),
store_type___2__1(A,B,C)
;
true
).
store_type___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,A,B),
'chr gen_id'(D),
store_type___2__1(A,B,C).
store_type___2__1(A,_,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',M),
lookup_ht(M,A,D),
'chr sbag_member'(C,D),
C=suspension(_,active,_),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',L),
lookup_ht(L,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,F),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',K),
delete_ht(K,A,C),
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',J),
delete_ht(J,A,E),
( var(B) ->
true
;
arg(2,B,I),
setarg(2,B,removed),
( I==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',H),
delete_ht(H,A,B)
)
),
store_type(A,multi_store(F)).
store_type___2__1(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',D),
insert_ht(D,A,B)
;
true
).
get_store_type(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
get_store_type(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
get_store_type(_,default).
update_store_type(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',G),
lookup_ht(G,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
(
memberchk(B,D),
!
;
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',F),
delete_ht(F,A,C),
actual_store_types(A,[B|D])
).
update_store_type(A,B) :-
actual_store_types(A,[B]).
actual_store_types(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',R),
lookup_ht(R,A,F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,D,E),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',Q),
lookup_ht(Q,A,H),
'chr sbag_member'(G,H),
G=suspension(_,active,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',O),
delete_ht(O,k(A,D),C),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',P),
delete_ht(P,A,C),
delete(B,multi_hash([D]),I),
D=[J],
( get_constraint_arg_type(A,J,K),
enumerated_atomic_type(K,L) ->
M=L,
N=complete
;
M=E,
N=incomplete
),
actual_store_types(A,[atomic_constants(D,M,N)|I]).
actual_store_types(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',R),
lookup_ht(R,A,F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,D,E),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',Q),
lookup_ht(Q,A,H),
'chr sbag_member'(G,H),
G=suspension(_,active,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',O),
delete_ht(O,k(A,D),C),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',P),
delete_ht(P,A,C),
( D=[I],
get_constraint_arg_type(A,I,J),
( is_chr_constants_type(J,K,_) ->
get_chr_constants(K,L)
;
( J=chr_enum(L) ->
true
)
) ->
M=complete
;
L=E,
M=incomplete
),
delete(B,multi_hash([D]),N),
actual_store_types(A,[ground_constants(D,L,M)|N]).
actual_store_types(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',V),
lookup_ht(V,A,D),
'chr sbag_member'(C,D),
C=suspension(_,active,_),
(
(
memberchk(multi_hash([[E]]),B),
(
get_constraint_type(A,F),
nth1(E,F,G),
enumerated_atomic_type(G,H),
!,
delete(B,multi_hash([[E]]),I),
actual_store_types(A,[atomic_constants([E],H,complete)|I])
;
get_constraint_arg_type(A,E,J),
( J=chr_enum(K) ->
true
;
( is_chr_constants_type(J,L,_) ->
get_chr_constants(L,K)
)
),
!,
delete(B,multi_hash([[E]]),M),
actual_store_types(A,[ground_constants([E],K,complete)|M])
)
;
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',Y),
lookup_ht(Y,A,O),
'chr sbag_member'(N,O),
N=suspension(_,active,_,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',X),
delete_ht(X,A,C),
setarg(2,N,removed),
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',W),
delete_ht(W,A,N),
( maplist(partial_store,B) ->
P=[global_ground|B]
;
P=B
),
store_type(A,multi_store(P))
)
;
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',U),
lookup_ht(U,A,R),
'chr sbag_member'(Q,R),
Q=suspension(_,active,_,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',T),
delete_ht(T,A,C),
setarg(2,Q,removed),
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',S),
delete_ht(S,A,Q),
store_type(A,multi_store(B))
).
actual_store_types(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',E),
insert_ht(E,A,C).
assumed_store_type(A,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',I),
lookup_ht(I,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
(
(
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',M),
lookup_ht(M,A,F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,E),
!,
setarg(2,B,removed),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',L),
delete_ht(L,A,B),
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',K),
delete_ht(K,A,D),
( maplist(partial_store,E) ->
G=[global_ground|E]
;
G=E
),
store_type(A,multi_store(G))
;
chr_pp_flag(debugable,on),
!,
setarg(2,B,removed),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',J),
delete_ht(J,A,B),
store_type(A,default)
)
;
!,
setarg(2,B,removed),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',H),
delete_ht(H,A,B),
store_type(A,global_ground)
).
assumed_store_type(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',E),
insert_ht(E,A,C).
validate_store_type_assumption(A) :-
validate_store_type_assumption___1__0(A,_).
validate_store_type_assumption___1__0(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',E),
lookup_ht(E,A,C),
!,
B=suspension(D,not_stored_yet,A),
'chr gen_id'(D),
validate_store_type_assumption___1__0__0__1(C,A,B).
validate_store_type_assumption___1__0__0__1([],B,A) :-
validate_store_type_assumption___1__1(B,A).
validate_store_type_assumption___1__0__0__1([E|F],A,B) :-
( E=suspension(_,active,C,D),
C==A,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',V),
lookup_ht(V,A,J),
'chr sbag_member'(G,J),
G=suspension(_,active,_,H,I) ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',U),
delete_ht(U,A,E),
setarg(2,G,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',S),
delete_ht(S,k(A,H),G),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',T),
delete_ht(T,A,G),
arg(2,B,Q),
setarg(2,B,active),
( Q==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',R),
insert_ht(R,A,B)
;
true
),
delete(D,multi_hash([H]),K),
H=[L],
( get_constraint_arg_type(A,L,M),
enumerated_atomic_type(M,N) ->
O=N,
P=complete
;
O=I,
P=incomplete
),
actual_store_types(A,[atomic_constants(H,O,P)|K]),
( B=suspension(_,active,_) ->
setarg(2,B,inactive),
validate_store_type_assumption___1__0__0__1(F,A,B)
;
true
)
;
validate_store_type_assumption___1__0__0__1(F,A,B)
).
validate_store_type_assumption___1__0(A,B) :-
B=suspension(C,not_stored_yet,A),
'chr gen_id'(C),
validate_store_type_assumption___1__1(A,B).
validate_store_type_assumption___1__1(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',D),
lookup_ht(D,A,C),
!,
validate_store_type_assumption___1__1__0__2(C,A,B).
validate_store_type_assumption___1__1__0__2([],B,A) :-
validate_store_type_assumption___1__2(B,A).
validate_store_type_assumption___1__1__0__2([E|F],A,B) :-
( E=suspension(_,active,C,D),
C==A,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',V),
lookup_ht(V,A,J),
'chr sbag_member'(G,J),
G=suspension(_,active,_,H,I) ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',U),
delete_ht(U,A,E),
setarg(2,G,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',S),
delete_ht(S,k(A,H),G),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',T),
delete_ht(T,A,G),
arg(2,B,Q),
setarg(2,B,active),
( Q==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',R),
insert_ht(R,A,B)
;
true
),
( H=[K],
get_constraint_arg_type(A,K,L),
( is_chr_constants_type(L,M,_) ->
get_chr_constants(M,N)
;
( L=chr_enum(N) ->
true
)
) ->
O=complete
;
N=I,
O=incomplete
),
delete(D,multi_hash([H]),P),
actual_store_types(A,[ground_constants(H,N,O)|P]),
( B=suspension(_,active,_) ->
setarg(2,B,inactive),
validate_store_type_assumption___1__1__0__2(F,A,B)
;
true
)
;
validate_store_type_assumption___1__1__0__2(F,A,B)
).
validate_store_type_assumption___1__1(A,B) :-
validate_store_type_assumption___1__2(A,B).
validate_store_type_assumption___1__2(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',D),
lookup_ht(D,A,C),
!,
validate_store_type_assumption___1__2__0__3(C,A,B).
validate_store_type_assumption___1__2__0__3([],B,A) :-
validate_store_type_assumption___1__3(B,A).
validate_store_type_assumption___1__2__0__3([E|F],A,B) :-
( E=suspension(_,active,C,D),
C==A,
memberchk(multi_hash([[G]]),D),
get_constraint_type(A,H),
nth1(G,H,I),
enumerated_atomic_type(I,J) ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',N),
delete_ht(N,A,E),
arg(2,B,L),
setarg(2,B,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',M),
insert_ht(M,A,B)
;
true
),
delete(D,multi_hash([[G]]),K),
actual_store_types(A,[atomic_constants([G],J,complete)|K]),
( B=suspension(_,active,_) ->
setarg(2,B,inactive),
validate_store_type_assumption___1__2__0__3(F,A,B)
;
true
)
;
validate_store_type_assumption___1__2__0__3(F,A,B)
).
validate_store_type_assumption___1__2(A,B) :-
validate_store_type_assumption___1__3(A,B).
validate_store_type_assumption___1__3(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',D),
lookup_ht(D,A,C),
!,
validate_store_type_assumption___1__3__0__4(C,A,B).
validate_store_type_assumption___1__3__0__4([],B,A) :-
validate_store_type_assumption___1__4(B,A).
validate_store_type_assumption___1__3__0__4([E|F],A,B) :-
( E=suspension(_,active,C,D),
C==A,
memberchk(multi_hash([[G]]),D),
get_constraint_arg_type(A,G,H),
( H=chr_enum(I) ->
true
;
( is_chr_constants_type(H,J,_) ->
get_chr_constants(J,I)
)
) ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',N),
delete_ht(N,A,E),
arg(2,B,L),
setarg(2,B,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',M),
insert_ht(M,A,B)
;
true
),
delete(D,multi_hash([[G]]),K),
actual_store_types(A,[ground_constants([G],I,complete)|K]),
( B=suspension(_,active,_) ->
setarg(2,B,inactive),
validate_store_type_assumption___1__3__0__4(F,A,B)
;
true
)
;
validate_store_type_assumption___1__3__0__4(F,A,B)
).
validate_store_type_assumption___1__3(A,B) :-
validate_store_type_assumption___1__4(A,B).
validate_store_type_assumption___1__4(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',P),
lookup_ht(P,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
(
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',U),
lookup_ht(U,A,G),
'chr sbag_member'(F,G),
F=suspension(_,active,_,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',T),
delete_ht(T,A,C),
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',S),
delete_ht(S,A,F),
( var(B) ->
true
;
arg(2,B,R),
setarg(2,B,removed),
( R==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',Q),
delete_ht(Q,A,B)
)
),
( maplist(partial_store,D) ->
H=[global_ground|D]
;
H=D
),
store_type(A,multi_store(H))
;
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',O),
lookup_ht(O,A,J),
'chr sbag_member'(I,J),
I=suspension(_,active,_,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',N),
delete_ht(N,A,C),
setarg(2,I,removed),
nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',M),
delete_ht(M,A,I),
( var(B) ->
true
;
arg(2,B,L),
setarg(2,B,removed),
( L==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',K),
delete_ht(K,A,B)
)
),
store_type(A,multi_store(D))
).
validate_store_type_assumption___1__4(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',H),
lookup_ht(H,A,D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
(
chr_pp_flag(debugable,on),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',K),
delete_ht(K,A,C),
( var(B) ->
true
;
arg(2,B,J),
setarg(2,B,removed),
( J==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',I),
delete_ht(I,A,B)
)
),
store_type(A,default)
;
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',G),
delete_ht(G,A,C),
( var(B) ->
true
;
arg(2,B,F),
setarg(2,B,removed),
( F==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',E),
delete_ht(E,A,B)
)
),
store_type(A,global_ground)
).
validate_store_type_assumption___1__4(A,B) :-
( var(B) ->
true
;
arg(2,B,D),
setarg(2,B,removed),
( D==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',C),
delete_ht(C,A,B)
)
).
rule_count(A) :-
nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',C),
(
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!
;
!,
rule_count___1__0__0__2(C,A)
).
rule_count___1__0__0__2([],A) :-
rule_count___1__1(A).
rule_count___1__0__0__2([B|C],A) :-
( B=suspension(_,active,_,_) ->
setarg(2,B,removed),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',E),
E=[_|F],
b_setval('$chr_store_global_ground_chr_translate____rule_count___1',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
rule_count___1__0__0__2(C,A)
;
rule_count___1__0__0__2(C,A)
).
rule_count(A) :-
rule_count___1__1(A).
rule_count___1__1(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____rule_count___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
inc_rule_count(A) :-
nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,E),
( var(E) ->
nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',F),
F=[_|G],
b_setval('$chr_store_global_ground_chr_translate____rule_count___1',G),
( G=[H|_] ->
setarg(3,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(3,H,E)
;
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,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
passive___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',F),
lookup_ht(F,A,D),
!,
C=suspension(E,not_stored_yet,t,A,B),
'chr gen_id'(E),
passive___2__0__0__6(D,A,B,C).
passive___2__0__0__6([],B,C,A) :-
passive___2__1(B,C,A).
passive___2__0__0__6([F|I],A,B,C) :-
( F=suspension(_,active,D,E),
D==A,
E=[G|H],
G==B,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',Q),
lookup_ht1(Q,A,A,K),
'chr sbag_member'(J,K),
J=suspension(_,active,_,_,_,_) ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',O),
delete_ht(O,k(A,[B|H]),F),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',P),
delete_ht(P,A,F),
arg(2,C,L),
setarg(2,C,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',M),
insert_ht(M,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',N),
insert_ht(N,k(A,B),C)
;
true
),
least_occurrence(A,H),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
passive___2__0__0__6(I,A,B,C)
;
true
)
;
passive___2__0__0__6(I,A,B,C)
).
passive___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
passive___2__1(A,B,C).
passive___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',E),
lookup_ht(E,k(A,B),D),
!,
passive___2__1__0__8(D,A,B,C).
passive___2__1__0__8([],B,C,A) :-
passive___2__2(B,C,A).
passive___2__1__0__8([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,E,F,G,_),
F==B,
G==C,
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',K),
lookup_ht(K,D,I) ->
passive___2__1__1__8(I,D,E,H,J,B,C,A)
;
passive___2__1__0__8(J,B,C,A)
).
passive___2__1__1__8([],_,_,_,A,C,D,B) :-
passive___2__1__0__8(A,C,D,B).
passive___2__1__1__8([K|L],E,F,A,G,B,C,D) :-
( K=suspension(_,active,_,H,I,J),
H==E,
F<I,
ground(E),
ground(F),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',V),
hash_term(k(E,F,1887087),W),
lookup_ht1(V,W,k(E,F,yes),N),
'chr sbag_member'(M,N),
M=suspension(_,active,_,_,_) ->
setarg(2,K,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',U),
delete_ht(U,E,K),
setarg(2,M,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',S),
delete_ht(S,E,M),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',T),
delete_ht(T,k(E,F,yes),M),
arg(2,D,P),
setarg(2,D,active),
( P==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',Q),
insert_ht(Q,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',R),
insert_ht(R,k(B,C),D)
;
true
),
O is J-1,
stored(E,F,maybe),
stored_complete(E,I,O),
( D=suspension(_,active,_,_,_) ->
setarg(2,D,inactive),
passive___2__1__1__8(L,E,F,A,G,B,C,D)
;
true
)
;
passive___2__1__1__8(L,E,F,A,G,B,C,D)
).
passive___2__1(A,B,C) :-
passive___2__2(A,B,C).
passive___2__2(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',E),
lookup_ht1(E,A,A,D),
!,
passive___2__2__0__9(D,A,B,C).
passive___2__2__0__9([],B,C,A) :-
passive___2__3(B,C,A).
passive___2__2__0__9([F|G],B,C,A) :-
( F=suspension(_,active,_,_,D,E),
D==B,
K=t(246,F,A),
'$novel_production'(F,K),
'$novel_production'(A,K),
E=pragma(rule(_,_,_,_),ids([C|I],H),_,_,B) ->
'$extend_history'(A,K),
arg(2,A,L),
setarg(2,A,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',M),
insert_ht(M,B,A),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',N),
insert_ht(N,k(B,C),A)
;
true
),
append(I,H,J),
check_all_passive(B,J),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
passive___2__2__0__9(G,B,C,A)
;
true
)
;
passive___2__2__0__9(G,B,C,A)
).
passive___2__2(A,B,C) :-
passive___2__3(A,B,C).
passive___2__3(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',E),
lookup_ht1(E,A,A,D),
!,
passive___2__3__0__10(D,A,B,C).
passive___2__3__0__10([],B,C,A) :-
passive___2__4(B,C,A).
passive___2__3__0__10([F|G],B,C,A) :-
( F=suspension(_,active,_,_,D,E),
D==B,
I=t(247,F,A),
'$novel_production'(F,I),
'$novel_production'(A,I),
E=pragma(rule(_,_,_,_),ids([],[C|H]),_,_,B) ->
'$extend_history'(A,I),
arg(2,A,J),
setarg(2,A,active),
( J==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',K),
insert_ht(K,B,A),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',L),
insert_ht(L,k(B,C),A)
;
true
),
check_all_passive(B,H),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
passive___2__3__0__10(G,B,C,A)
;
true
)
;
passive___2__3__0__10(G,B,C,A)
).
passive___2__3(A,B,C) :-
passive___2__4(A,B,C).
passive___2__4(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',E),
lookup_ht(E,A,D),
!,
passive___2__4__0__11(D,A,B,C).
passive___2__4__0__11([],B,C,A) :-
passive___2__5(B,C,A).
passive___2__4__0__11([F|I],A,B,C) :-
( F=suspension(_,active,D,E),
D==A,
E=[G|H],
G==B ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',M),
delete_ht(M,k(A,[B|H]),F),
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',N),
delete_ht(N,A,F),
arg(2,C,J),
setarg(2,C,active),
( J==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',K),
insert_ht(K,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',L),
insert_ht(L,k(A,B),C)
;
true
),
check_all_passive(A,H),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
passive___2__4__0__11(I,A,B,C)
;
true
)
;
passive___2__4__0__11(I,A,B,C)
).
passive___2__4(A,B,C) :-
passive___2__5(A,B,C).
passive___2__5(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',E),
lookup_ht(E,k(A,B),D),
!,
passive___2__5__0__14(D,A,B,C).
passive___2__5__0__14([],B,C,A) :-
passive___2__6(B,C,A).
passive___2__5__0__14([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,E,F,G,_),
F==B,
G==C,
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',K),
lookup_ht(K,k(D,E),I) ->
passive___2__5__1__14(I,D,E,H,J,B,C,A)
;
passive___2__5__0__14(J,B,C,A)
).
passive___2__5__1__14([],_,_,_,A,C,D,B) :-
passive___2__5__0__14(A,C,D,B).
passive___2__5__1__14([J|K],F,G,A,B,D,E,C) :-
( J=suspension(_,active,_,H,I),
H==F,
I==G,
M=t(357,A,C,J),
'$novel_production'(A,M),
'$novel_production'(C,M),
'$novel_production'(J,M),
G>1 ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',O),
insert_ht(O,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',P),
insert_ht(P,k(D,E),C)
;
true
),
L is G-1,
skip_to_next_id(F,L),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
passive___2__5__1__14(K,F,G,A,B,D,E,C)
;
true
)
;
passive___2__5__1__14(K,F,G,A,B,D,E,C)
).
passive___2__5(A,B,C) :-
passive___2__6(A,B,C).
passive___2__6(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',E),
lookup_ht(E,k(A,B),D),
!,
passive___2__6__0__15(D,A,B,C).
passive___2__6__0__15([],B,C,A) :-
passive___2__7(B,C,A).
passive___2__6__0__15([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,E,F,G,_),
F==B,
G==C,
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',K),
lookup_ht(K,k(D,E),I) ->
passive___2__6__1__15(I,D,E,H,J,B,C,A)
;
passive___2__6__0__15(J,B,C,A)
).
passive___2__6__1__15([],_,_,_,A,C,D,B) :-
passive___2__6__0__15(A,C,D,B).
passive___2__6__1__15([K|L],E,F,A,G,B,C,D) :-
( K=suspension(_,active,H,I,J),
H==E,
I==F ->
setarg(2,K,removed),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',Q),
delete_ht(Q,k(E,F),K),
arg(2,D,N),
setarg(2,D,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',O),
insert_ht(O,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',P),
insert_ht(P,k(B,C),D)
;
true
),
occurrence_code_id(E,F,J),
M is F+1,
set_occurrence_code_id(E,M,J),
( D=suspension(_,active,_,_,_) ->
setarg(2,D,inactive),
passive___2__6__1__15(L,E,F,A,G,B,C,D)
;
true
)
;
passive___2__6__1__15(L,E,F,A,G,B,C,D)
).
passive___2__6(A,B,C) :-
passive___2__7(A,B,C).
passive___2__7(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',F),
insert_ht(F,k(A,B),C)
;
true
).
is_passive(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
is_passive(_,_) :-
fail.
any_passive_head(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_,_),
!.
any_passive_head(_) :-
fail.
new_occurrence(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',J),
lookup_ht(J,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,_,F),
!,
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',I),
delete_ht(I,A,E),
H is F+1,
occurrence(A,H,B,C,D),
max_occurrence(A,H).
new_occurrence(A,B,_,_) :-
chr_error(internal,'new_occurrence: missing max_occurrence for ~w in rule ~w
',[A,B]).
occurrence(A,B,C,D,E) :-
occurrence___5__0(A,B,C,D,E,_).
occurrence___5__0(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',I),
lookup_ht1(I,C,C,G),
!,
F=suspension(H,not_stored_yet,t,_,A,B,C,D,E),
'chr gen_id'(H),
occurrence___5__0__0__3(G,A,B,C,D,E,F).
occurrence___5__0__0__3([],B,C,D,E,F,A) :-
occurrence___5__1(B,C,D,E,F,A).
occurrence___5__0__0__3([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,_,G,H),
G==D,
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',L),
lookup_ht(L,k(B,C),J) ->
occurrence___5__0__1__3(J,H,I,K,B,C,D,E,F,A)
;
occurrence___5__0__0__3(K,B,C,D,E,F,A)
).
occurrence___5__0__1__3([],_,_,A,C,D,E,F,G,B) :-
occurrence___5__0__0__3(A,C,D,E,F,G,B).
occurrence___5__0__1__3([L|M],I,A,B,D,E,F,G,H,C) :-
( L=suspension(_,active,_,J,K),
J==D,
K==E,
N=t(58,A,C,L),
'$novel_production'(A,N),
'$novel_production'(C,N),
'$novel_production'(L,N) ->
'$extend_history'(C,N),
arg(2,C,O),
setarg(2,C,active),
( O==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',P),
Q=[C|P],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',Q),
( P=[R|_] ->
setarg(4,R,Q)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',S),
insert_ht(S,k(D,E),C),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',T),
insert_ht(T,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',U),
insert_ht(U,k(F,G),C),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',V),
insert_ht(V,D,C)
;
true
),
\+is_passive(F,G),
H==propagation,
( stored_in_guard_before_next_kept_occurrence(D,E) ->
true
;
( I=pragma(rule([_|_],_,_,_),_,_,_,_) ->
is_observed(D,E)
)
;
( is_least_occurrence(F) ->
is_observed(D,E)
)
;
true
),
( C=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,C,inactive),
occurrence___5__0__1__3(M,I,A,B,D,E,F,G,H,C)
;
true
)
;
occurrence___5__0__1__3(M,I,A,B,D,E,F,G,H,C)
).
occurrence___5__0(A,B,C,D,E,F) :-
F=suspension(G,not_stored_yet,t,_,A,B,C,D,E),
'chr gen_id'(G),
occurrence___5__1(A,B,C,D,E,F).
occurrence___5__1(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',H),
lookup_ht(H,C,G),
!,
occurrence___5__1__0__6(G,A,B,C,D,E,F).
occurrence___5__1__0__6([],B,C,D,E,F,A) :-
occurrence___5__2(B,C,D,E,F,A).
occurrence___5__1__0__6([I|L],A,B,C,D,E,F) :-
( I=suspension(_,active,G,H),
G==C,
H=[J|K],
J==D,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',C1),
lookup_ht(C1,A,O),
'chr sbag_member'(M,O),
M=suspension(_,active,_,_,N),
N>=B,
ground(C),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',B1),
lookup_ht1(B1,C,C,Q),
'chr sbag_member'(P,Q),
P=suspension(_,active,_,_,_,_),
\+may_trigger(A) ->
setarg(2,I,removed),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',Z),
delete_ht(Z,k(C,[D|K]),I),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',A1),
delete_ht(A1,C,I),
arg(2,F,R),
setarg(2,F,active),
( R==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',S),
T=[F|S],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',T),
( S=[U|_] ->
setarg(4,U,T)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',V),
insert_ht(V,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',W),
insert_ht(W,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',X),
insert_ht(X,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',Y),
insert_ht(Y,A,F)
;
true
),
least_occurrence(C,K),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__1__0__6(L,A,B,C,D,E,F)
;
true
)
;
occurrence___5__1__0__6(L,A,B,C,D,E,F)
).
occurrence___5__1(A,B,C,D,E,F) :-
occurrence___5__2(A,B,C,D,E,F).
occurrence___5__2(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',H),
lookup_ht(H,C,G),
!,
occurrence___5__2__0__28(G,A,B,C,D,E,F).
occurrence___5__2__0__28([],B,C,D,E,F,A) :-
occurrence___5__3(B,C,D,E,F,A).
occurrence___5__2__0__28([H|I],B,C,D,E,F,A) :-
( H=suspension(_,active,_,G),
G==D,
J=t(176,H,A),
'$novel_production'(H,J),
'$novel_production'(A,J) ->
'$extend_history'(A,J),
arg(2,A,K),
setarg(2,A,active),
( K==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',L),
M=[A|L],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',M),
( L=[N|_] ->
setarg(4,N,M)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',O),
insert_ht(O,k(B,C),A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',P),
insert_ht(P,D,A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',Q),
insert_ht(Q,k(D,E),A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',R),
insert_ht(R,B,A)
;
true
),
passive(D,E),
( A=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,A,inactive),
occurrence___5__2__0__28(I,B,C,D,E,F,A)
;
true
)
;
occurrence___5__2__0__28(I,B,C,D,E,F,A)
).
occurrence___5__2(A,B,C,D,E,F) :-
occurrence___5__3(A,B,C,D,E,F).
occurrence___5__3(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',H),
lookup_ht1(H,C,C,G),
!,
occurrence___5__3__0__29(G,A,B,C,D,E,F).
occurrence___5__3__0__29([],B,C,D,E,F,A) :-
occurrence___5__4(B,C,D,E,F,A).
occurrence___5__3__0__29([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,_,G,H),
G==D,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',L),
lookup_ht(L,B,J) ->
occurrence___5__3__1__29(J,H,I,K,B,C,D,E,F,A)
;
occurrence___5__3__0__29(K,B,C,D,E,F,A)
).
occurrence___5__3__1__29([],_,_,A,C,D,E,F,G,B) :-
occurrence___5__3__0__29(A,C,D,E,F,G,B).
occurrence___5__3__1__29([M|O],I,A,B,D,E,F,G,H,C) :-
( M=suspension(_,active,_,_,J,K,L,_,_),
J==D,
L==F,
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',P),
lookup_ht(P,F,N) ->
occurrence___5__3__2__29(N,K,M,O,I,A,B,D,E,F,G,H,C)
;
occurrence___5__3__1__29(O,I,A,B,D,E,F,G,H,C)
).
occurrence___5__3__2__29([],_,_,A,J,B,C,E,F,G,H,I,D) :-
occurrence___5__3__1__29(A,J,B,C,E,F,G,H,I,D).
occurrence___5__3__2__29([N|P],L,A,B,K,C,D,F,G,H,I,J,E) :-
( N=suspension(_,active,_,_,M,_,_,_,_,_),
M==H,
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',O) ->
occurrence___5__3__3__29(O,N,P,L,A,B,K,C,D,F,G,H,I,J,E)
;
occurrence___5__3__2__29(P,L,A,B,K,C,D,F,G,H,I,J,E)
).
occurrence___5__3__3__29([],_,A,M,B,C,L,D,E,G,H,I,J,K,F) :-
occurrence___5__3__2__29(A,M,B,C,L,D,E,G,H,I,J,K,F).
occurrence___5__3__3__29([P|Q],A,N,L,B,M,J,C,K,D,E,F,G,H,I) :-
( P=suspension(_,active,_,O),
E<L,
chr_pp_flag(occurrence_subsumption,on),
J=pragma(rule(R,_,_,_),_,_,_,_),
R\==[],
\+tree_set_memberchk(D,O) ->
setarg(2,P,removed),
arg(3,P,B1),
( var(B1) ->
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',C1),
C1=[_|D1],
b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',D1),
( D1=[E1|_] ->
setarg(3,E1,_)
;
true
)
;
B1=[_,_|D1],
setarg(2,B1,D1),
( D1=[E1|_] ->
setarg(3,E1,B1)
;
true
)
),
arg(2,I,T),
setarg(2,I,active),
( T==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',U),
V=[I|U],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',V),
( U=[W|_] ->
setarg(4,W,V)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',X),
insert_ht(X,k(D,E),I),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',Y),
insert_ht(Y,F,I),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',Z),
insert_ht(Z,k(F,G),I),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',A1),
insert_ht(A1,D,I)
;
true
),
first_occ_in_rule(F,D,E,G),
tree_set_add(O,D,S),
multiple_occ_constraints_checked(S),
( I=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,I,inactive),
occurrence___5__3__3__29(Q,A,N,L,B,M,J,C,K,D,E,F,G,H,I)
;
true
)
;
occurrence___5__3__3__29(Q,A,N,L,B,M,J,C,K,D,E,F,G,H,I)
).
occurrence___5__3(A,B,C,D,E,F) :-
occurrence___5__4(A,B,C,D,E,F).
occurrence___5__4(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',H),
lookup_ht1(H,C,C,G),
!,
occurrence___5__4__0__30(G,A,B,C,D,E,F).
occurrence___5__4__0__30([],B,C,D,E,F,A) :-
occurrence___5__5(B,C,D,E,F,A).
occurrence___5__4__0__30([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,_,G,H),
G==D,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',L),
lookup_ht(L,B,J) ->
occurrence___5__4__1__30(J,H,I,K,B,C,D,E,F,A)
;
occurrence___5__4__0__30(K,B,C,D,E,F,A)
).
occurrence___5__4__1__30([],_,_,A,C,D,E,F,G,B) :-
occurrence___5__4__0__30(A,C,D,E,F,G,B).
occurrence___5__4__1__30([N|P],I,A,B,D,E,F,G,H,C) :-
( N=suspension(_,active,_,_,J,K,L,M,_),
J==D,
L==F,
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',Q),
lookup_ht(Q,F,O) ->
occurrence___5__4__2__30(O,K,M,N,P,I,A,B,D,E,F,G,H,C)
;
occurrence___5__4__1__30(P,I,A,B,D,E,F,G,H,C)
).
occurrence___5__4__2__30([],_,_,_,A,J,B,C,E,F,G,H,I,D) :-
occurrence___5__4__1__30(A,J,B,C,E,F,G,H,I,D).
occurrence___5__4__2__30([O|Q],L,M,A,B,K,C,D,F,G,H,I,J,E) :-
( O=suspension(_,active,_,_,N,_,_,_,_,_),
N==H,
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',P) ->
occurrence___5__4__3__30(P,O,Q,L,M,A,B,K,C,D,F,G,H,I,J,E)
;
occurrence___5__4__2__30(Q,L,M,A,B,K,C,D,F,G,H,I,J,E)
).
occurrence___5__4__3__30([],_,A,M,N,B,C,L,D,E,G,H,I,J,K,F) :-
occurrence___5__4__2__30(A,M,N,B,C,L,D,E,G,H,I,J,K,F).
occurrence___5__4__3__30([Q|R],A,O,L,M,B,N,J,C,K,D,E,F,G,H,I) :-
( Q=suspension(_,active,_,P),
L<E,
chr_pp_flag(occurrence_subsumption,on),
J=pragma(rule(S,_,_,_),_,_,_,_),
S\==[],
\+tree_set_memberchk(D,P) ->
setarg(2,Q,removed),
arg(3,Q,C1),
( var(C1) ->
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',D1),
D1=[_|E1],
b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',E1),
( E1=[F1|_] ->
setarg(3,F1,_)
;
true
)
;
C1=[_,_|E1],
setarg(2,C1,E1),
( E1=[F1|_] ->
setarg(3,F1,C1)
;
true
)
),
arg(2,I,U),
setarg(2,I,active),
( U==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',V),
W=[I|V],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',W),
( V=[X|_] ->
setarg(4,X,W)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',Y),
insert_ht(Y,k(D,E),I),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',Z),
insert_ht(Z,F,I),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',A1),
insert_ht(A1,k(F,G),I),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',B1),
insert_ht(B1,D,I)
;
true
),
first_occ_in_rule(F,D,L,M),
tree_set_add(P,D,T),
multiple_occ_constraints_checked(T),
( I=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,I,inactive),
occurrence___5__4__3__30(R,A,O,L,M,B,N,J,C,K,D,E,F,G,H,I)
;
true
)
;
occurrence___5__4__3__30(R,A,O,L,M,B,N,J,C,K,D,E,F,G,H,I)
).
occurrence___5__4(A,B,C,D,E,F) :-
occurrence___5__5(A,B,C,D,E,F).
occurrence___5__5(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',H),
hash_term(k(A,B,1887087),I),
lookup_ht1(H,I,k(A,B,yes),G),
!,
occurrence___5__5__0__34(G,A,B,C,D,E,F).
occurrence___5__5__0__34([],B,C,D,E,F,A) :-
occurrence___5__6(B,C,D,E,F,A).
occurrence___5__5__0__34([J|K],A,B,C,D,E,F) :-
( J=suspension(_,active,G,H,I),
G==A,
H==B,
I=yes,
ground(C),
ground(D),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',E1),
lookup_ht(E1,k(C,D),M),
'chr sbag_member'(L,M),
L=suspension(_,active,_,_,_),
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',D1),
lookup_ht(D1,A,Q),
'chr sbag_member'(N,Q),
N=suspension(_,active,_,_,O,P),
B<O ->
setarg(2,J,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',B1),
delete_ht(B1,A,J),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',C1),
delete_ht(C1,k(A,B,yes),J),
setarg(2,N,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',A1),
delete_ht(A1,A,N),
arg(2,F,S),
setarg(2,F,active),
( S==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',T),
U=[F|T],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',U),
( T=[V|_] ->
setarg(4,V,U)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',W),
insert_ht(W,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',X),
insert_ht(X,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',Y),
insert_ht(Y,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',Z),
insert_ht(Z,A,F)
;
true
),
R is P-1,
stored(A,B,maybe),
stored_complete(A,O,R),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__5__0__34(K,A,B,C,D,E,F)
;
true
)
;
occurrence___5__5__0__34(K,A,B,C,D,E,F)
).
occurrence___5__5(A,B,C,D,E,F) :-
occurrence___5__6(A,B,C,D,E,F).
occurrence___5__6(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',H),
lookup_ht1(H,C,C,G),
!,
occurrence___5__6__0__35(G,A,B,C,D,E,F).
occurrence___5__6__0__35([],B,C,D,E,F,A) :-
occurrence___5__7(B,C,D,E,F,A).
occurrence___5__6__0__35([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,_,G,_,H,_,_),
H==D,
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',L),
lookup_ht(L,G,J) ->
occurrence___5__6__1__35(J,G,I,K,B,C,D,E,F,A)
;
occurrence___5__6__0__35(K,B,C,D,E,F,A)
).
occurrence___5__6__1__35([],_,_,A,C,D,E,F,G,B) :-
occurrence___5__6__0__35(A,C,D,E,F,G,B).
occurrence___5__6__1__35([L|N],I,A,B,D,E,F,G,H,C) :-
( L=suspension(_,active,_,J,K),
J==I,
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',O),
lookup_ht(O,I,M) ->
occurrence___5__6__2__35(M,K,L,N,I,A,B,D,E,F,G,H,C)
;
occurrence___5__6__1__35(N,I,A,B,D,E,F,G,H,C)
).
occurrence___5__6__2__35([],_,_,A,J,B,C,E,F,G,H,I,D) :-
occurrence___5__6__1__35(A,J,B,C,E,F,G,H,I,D).
occurrence___5__6__2__35([P|Q],L,A,B,K,C,D,F,G,H,I,J,E) :-
( P=suspension(_,active,_,M,N,O),
M==K,
O=0,
R=t(245,E,C,P,A),
'$novel_production'(E,R),
'$novel_production'(C,R),
'$novel_production'(P,R),
'$novel_production'(A,R),
N=<L ->
'$extend_history'(E,R),
arg(2,E,S),
setarg(2,E,active),
( S==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',T),
U=[E|T],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',U),
( T=[V|_] ->
setarg(4,V,U)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',W),
insert_ht(W,k(F,G),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',X),
insert_ht(X,H,E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',Y),
insert_ht(Y,k(H,I),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',Z),
insert_ht(Z,F,E)
;
true
),
passive(H,I),
( E=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,E,inactive),
occurrence___5__6__2__35(Q,L,A,B,K,C,D,F,G,H,I,J,E)
;
true
)
;
occurrence___5__6__2__35(Q,L,A,B,K,C,D,F,G,H,I,J,E)
).
occurrence___5__6(A,B,C,D,E,F) :-
occurrence___5__7(A,B,C,D,E,F).
occurrence___5__7(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',H),
lookup_ht1(H,C,C,G),
!,
occurrence___5__7__0__36(G,A,B,C,D,E,F).
occurrence___5__7__0__36([],B,C,D,E,F,A) :-
occurrence___5__8(B,C,D,E,F,A).
occurrence___5__7__0__36([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,_,_,_,G,H,_),
G==D,
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',L),
lookup_ht(L,B,J) ->
occurrence___5__7__1__36(J,H,I,K,B,C,D,E,F,A)
;
occurrence___5__7__0__36(K,B,C,D,E,F,A)
).
occurrence___5__7__1__36([],_,_,A,C,D,E,F,G,B) :-
occurrence___5__7__0__36(A,C,D,E,F,G,B).
occurrence___5__7__1__36([L|N],I,A,B,D,E,F,G,H,C) :-
( L=suspension(_,active,_,J,K),
J==D,
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',O),
lookup_ht(O,D,M) ->
occurrence___5__7__2__36(M,K,L,N,I,A,B,D,E,F,G,H,C)
;
occurrence___5__7__1__36(N,I,A,B,D,E,F,G,H,C)
).
occurrence___5__7__2__36([],_,_,A,J,B,C,E,F,G,H,I,D) :-
occurrence___5__7__1__36(A,J,B,C,E,F,G,H,I,D).
occurrence___5__7__2__36([P|Q],L,A,B,K,C,D,F,G,H,I,J,E) :-
( P=suspension(_,active,_,M,N,O),
M==F,
O=0,
R=t(245,C,E,P,A),
'$novel_production'(C,R),
'$novel_production'(E,R),
'$novel_production'(P,R),
'$novel_production'(A,R),
N=<L ->
'$extend_history'(E,R),
arg(2,E,S),
setarg(2,E,active),
( S==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',T),
U=[E|T],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',U),
( T=[V|_] ->
setarg(4,V,U)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',W),
insert_ht(W,k(F,G),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',X),
insert_ht(X,H,E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',Y),
insert_ht(Y,k(H,I),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',Z),
insert_ht(Z,F,E)
;
true
),
passive(H,K),
( E=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,E,inactive),
occurrence___5__7__2__36(Q,L,A,B,K,C,D,F,G,H,I,J,E)
;
true
)
;
occurrence___5__7__2__36(Q,L,A,B,K,C,D,F,G,H,I,J,E)
).
occurrence___5__7(A,B,C,D,E,F) :-
occurrence___5__8(A,B,C,D,E,F).
occurrence___5__8(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',H),
lookup_ht(H,A,G),
!,
occurrence___5__8__0__37(G,A,B,C,D,E,F).
occurrence___5__8__0__37([],B,C,D,E,F,A) :-
occurrence___5__9(B,C,D,E,F,A).
occurrence___5__8__0__37([I|J],B,C,D,E,F,A) :-
( I=suspension(_,active,_,G,H,_),
G==B,
K=t(254,I,A),
'$novel_production'(I,K),
'$novel_production'(A,K),
C>H ->
'$extend_history'(A,K),
arg(2,A,L),
setarg(2,A,active),
( L==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',M),
N=[A|M],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',N),
( M=[O|_] ->
setarg(4,O,N)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',P),
insert_ht(P,k(B,C),A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',Q),
insert_ht(Q,D,A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',R),
insert_ht(R,k(D,E),A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',S),
insert_ht(S,B,A)
;
true
),
passive(D,E),
( A=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,A,inactive),
occurrence___5__8__0__37(J,B,C,D,E,F,A)
;
true
)
;
occurrence___5__8__0__37(J,B,C,D,E,F,A)
).
occurrence___5__8(A,B,C,D,E,F) :-
occurrence___5__9(A,B,C,D,E,F).
occurrence___5__9(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',H),
lookup_ht(H,k(A,C),G),
!,
occurrence___5__9__0__41(G,A,B,C,D,E,F).
occurrence___5__9__0__41([],B,C,D,E,F,A) :-
occurrence___5__10(B,C,D,E,F,A).
occurrence___5__9__0__41([K|L],A,B,C,D,E,F) :-
( K=suspension(_,active,G,H,I,J),
G==A,
H==C,
C>1,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',Z),
lookup_ht(Z,A,O),
'chr sbag_member'(M,O),
M=suspension(_,active,_,_,N),
N>B ->
setarg(2,K,removed),
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',X),
delete_ht(X,A,K),
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',Y),
delete_ht(Y,k(A,C),K),
arg(2,F,P),
setarg(2,F,active),
( P==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',Q),
R=[F|Q],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',R),
( Q=[S|_] ->
setarg(4,S,R)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',T),
insert_ht(T,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',U),
insert_ht(U,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',V),
insert_ht(V,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',W),
insert_ht(W,A,F)
;
true
),
functional_dependency(A,1,I,J),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__9__0__41(L,A,B,C,D,E,F)
;
true
)
;
occurrence___5__9__0__41(L,A,B,C,D,E,F)
).
occurrence___5__9(A,B,C,D,E,F) :-
occurrence___5__10(A,B,C,D,E,F).
occurrence___5__10(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',H),
lookup_ht(H,A,G),
!,
occurrence___5__10__0__47(G,A,B,C,D,E,F).
occurrence___5__10__0__47([],B,C,D,E,F,A) :-
occurrence___5__11(B,C,D,E,F,A).
occurrence___5__10__0__47([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,_,G,H),
G==B,
nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',J) ->
occurrence___5__10__1__47(J,H,I,K,B,C,D,E,F,A)
;
occurrence___5__10__0__47(K,B,C,D,E,F,A)
).
occurrence___5__10__1__47([],_,_,A,C,D,E,F,G,B) :-
occurrence___5__10__0__47(A,C,D,E,F,G,B).
occurrence___5__10__1__47([J|L],I,A,B,D,E,F,G,H,C) :-
( J=suspension(_,active,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',M),
lookup_ht1(M,F,F,K) ->
occurrence___5__10__2__47(K,J,L,I,A,B,D,E,F,G,H,C)
;
occurrence___5__10__1__47(L,I,A,B,D,E,F,G,H,C)
).
occurrence___5__10__2__47([],_,A,J,B,C,E,F,G,H,I,D) :-
occurrence___5__10__1__47(A,J,B,C,E,F,G,H,I,D).
occurrence___5__10__2__47([N|O],A,B,K,C,D,F,G,H,I,J,E) :-
( N=suspension(_,active,_,_,L,M),
L==H,
V=t(325,A,E,N,C),
'$novel_production'(A,V),
'$novel_production'(E,V),
'$novel_production'(N,V),
'$novel_production'(C,V) ->
'$extend_history'(E,V),
arg(2,E,W),
setarg(2,E,active),
( W==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',X),
Y=[E|X],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',Y),
( X=[Z|_] ->
setarg(4,Z,Y)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',A1),
insert_ht(A1,k(F,G),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',B1),
insert_ht(B1,H,E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',C1),
insert_ht(C1,k(H,I),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',D1),
insert_ht(D1,F,E)
;
true
),
M=pragma(rule(P,Q,R,_),_,_,_,_),
( is_passive(H,I) ->
true
;
( J==simplification ->
select(S,P,_),
S=..[_|T],
term_variables(R,U),
partial_wake_args(T,K,U,F)
)
;
select(S,Q,_),
S=..[_|T],
term_variables(R,U),
partial_wake_args(T,K,U,F)
),
( E=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,E,inactive),
occurrence___5__10__2__47(O,A,B,K,C,D,F,G,H,I,J,E)
;
true
)
;
occurrence___5__10__2__47(O,A,B,K,C,D,F,G,H,I,J,E)
).
occurrence___5__10(A,B,C,D,E,F) :-
occurrence___5__11(A,B,C,D,E,F).
occurrence___5__11(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',H),
lookup_ht(H,k(C,D),G),
!,
occurrence___5__11__0__49(G,A,B,C,D,E,F).
occurrence___5__11__0__49([],B,C,D,E,F,A) :-
occurrence___5__12(B,C,D,E,F,A).
occurrence___5__11__0__49([I|K],B,C,D,E,F,A) :-
( I=suspension(_,active,_,G,H),
G==D,
H==E,
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',L),
lookup_ht(L,k(B,C),J) ->
occurrence___5__11__1__49(J,I,K,B,C,D,E,F,A)
;
occurrence___5__11__0__49(K,B,C,D,E,F,A)
).
occurrence___5__11__1__49([],_,A,C,D,E,F,G,B) :-
occurrence___5__11__0__49(A,C,D,E,F,G,B).
occurrence___5__11__1__49([K|L],A,B,D,E,F,G,H,C) :-
( K=suspension(_,active,_,I,J),
I==D,
J==E,
N=t(357,C,A,K),
'$novel_production'(C,N),
'$novel_production'(A,N),
'$novel_production'(K,N),
E>1 ->
'$extend_history'(C,N),
arg(2,C,O),
setarg(2,C,active),
( O==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',P),
Q=[C|P],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',Q),
( P=[R|_] ->
setarg(4,R,Q)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',S),
insert_ht(S,k(D,E),C),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',T),
insert_ht(T,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',U),
insert_ht(U,k(F,G),C),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',V),
insert_ht(V,D,C)
;
true
),
M is E-1,
skip_to_next_id(D,M),
( C=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,C,inactive),
occurrence___5__11__1__49(L,A,B,D,E,F,G,H,C)
;
true
)
;
occurrence___5__11__1__49(L,A,B,D,E,F,G,H,C)
).
occurrence___5__11(A,B,C,D,E,F) :-
occurrence___5__12(A,B,C,D,E,F).
occurrence___5__12(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',H),
lookup_ht(H,k(A,B),G),
!,
occurrence___5__12__0__50(G,A,B,C,D,E,F).
occurrence___5__12__0__50([],B,C,D,E,F,A) :-
occurrence___5__13(B,C,D,E,F,A).
occurrence___5__12__0__50([J|K],A,B,C,D,E,F) :-
( J=suspension(_,active,G,H,I),
G==A,
H==B,
ground(C),
ground(D),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',X),
lookup_ht(X,k(C,D),M),
'chr sbag_member'(L,M),
L=suspension(_,active,_,_,_) ->
setarg(2,J,removed),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',W),
delete_ht(W,k(A,B),J),
arg(2,F,O),
setarg(2,F,active),
( O==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',P),
Q=[F|P],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',Q),
( P=[R|_] ->
setarg(4,R,Q)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',S),
insert_ht(S,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',T),
insert_ht(T,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',U),
insert_ht(U,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',V),
insert_ht(V,A,F)
;
true
),
occurrence_code_id(A,B,I),
N is B+1,
set_occurrence_code_id(A,N,I),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__12__0__50(K,A,B,C,D,E,F)
;
true
)
;
occurrence___5__12__0__50(K,A,B,C,D,E,F)
).
occurrence___5__12(A,B,C,D,E,F) :-
occurrence___5__13(A,B,C,D,E,F).
occurrence___5__13(A,B,C,D,simplification,E) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',G),
lookup_ht(G,k(A,B),F),
!,
occurrence___5__13__0__51(F,A,B,C,D,simplification,E).
occurrence___5__13__0__51([],B,C,D,E,F,A) :-
occurrence___5__15(B,C,D,E,F,A).
occurrence___5__13__0__51([J|K],A,B,C,D,E,F) :-
( J=suspension(_,active,G,H,I),
G==A,
H==B ->
setarg(2,J,removed),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',U),
delete_ht(U,k(A,B),J),
arg(2,F,M),
setarg(2,F,active),
( M==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',N),
O=[F|N],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',O),
( N=[P|_] ->
setarg(4,P,O)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',Q),
insert_ht(Q,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',R),
insert_ht(R,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',S),
insert_ht(S,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',T),
insert_ht(T,A,F)
;
true
),
occurrence_code_id(A,B,I),
L is B+1,
set_occurrence_code_id(A,L,I),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__13__0__51(K,A,B,C,D,E,F)
;
true
)
;
occurrence___5__13__0__51(K,A,B,C,D,E,F)
).
occurrence___5__13(A,B,C,D,propagation,E) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',G),
lookup_ht(G,k(A,B),F),
!,
occurrence___5__13__0__52(F,A,B,C,D,propagation,E).
occurrence___5__13__0__52([],B,C,D,E,F,A) :-
occurrence___5__14(B,C,D,E,F,A).
occurrence___5__13__0__52([J|K],A,B,C,D,E,F) :-
( J=suspension(_,active,G,H,I),
G==A,
H==B,
ground(A),
ground(B),
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',Y),
lookup_ht(Y,k(A,B),M),
'chr sbag_member'(L,M),
L=suspension(_,active,_,_,_) ->
setarg(2,J,removed),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',X),
delete_ht(X,k(A,B),J),
arg(2,F,P),
setarg(2,F,active),
( P==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',Q),
R=[F|Q],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',R),
( Q=[S|_] ->
setarg(4,S,R)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',T),
insert_ht(T,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',U),
insert_ht(U,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',V),
insert_ht(V,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',W),
insert_ht(W,A,F)
;
true
),
occurrence_code_id(A,B,I),
N is B+1,
O is I+1,
set_occurrence_code_id(A,N,O),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__13__0__52(K,A,B,C,D,E,F)
;
true
)
;
occurrence___5__13__0__52(K,A,B,C,D,E,F)
).
occurrence___5__13(A,B,C,D,E,F) :-
occurrence___5__14(A,B,C,D,E,F).
occurrence___5__14(A,B,C,D,propagation,E) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',G),
lookup_ht(G,k(A,B),F),
!,
occurrence___5__14__0__53(F,A,B,C,D,propagation,E).
occurrence___5__14__0__53([],B,C,D,E,F,A) :-
occurrence___5__15(B,C,D,E,F,A).
occurrence___5__14__0__53([J|K],A,B,C,D,E,F) :-
( J=suspension(_,active,G,H,I),
G==A,
H==B ->
setarg(2,J,removed),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',U),
delete_ht(U,k(A,B),J),
arg(2,F,M),
setarg(2,F,active),
( M==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',N),
O=[F|N],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',O),
( N=[P|_] ->
setarg(4,P,O)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',Q),
insert_ht(Q,k(A,B),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',R),
insert_ht(R,C,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',S),
insert_ht(S,k(C,D),F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',T),
insert_ht(T,A,F)
;
true
),
occurrence_code_id(A,B,I),
L is B+1,
set_occurrence_code_id(A,L,I),
( F=suspension(_,active,_,_,_,_,_,_,_) ->
setarg(2,F,inactive),
occurrence___5__14__0__53(K,A,B,C,D,E,F)
;
true
)
;
occurrence___5__14__0__53(K,A,B,C,D,E,F)
).
occurrence___5__14(A,B,C,D,E,F) :-
occurrence___5__15(A,B,C,D,E,F).
occurrence___5__15(A,B,C,D,_,E) :-
arg(2,E,F),
setarg(2,E,active),
( F==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',G),
H=[E|G],
b_setval('$chr_store_global_ground_chr_translate____occurrence___5',H),
( G=[I|_] ->
setarg(4,I,H)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',J),
insert_ht(J,k(A,B),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',K),
insert_ht(K,C,E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',L),
insert_ht(L,k(C,D),E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',M),
insert_ht(M,A,E)
;
true
).
get_occurrence(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',I),
lookup_ht(I,k(A,B),H),
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,_,_,F,G,_),
!,
F=C,
G=D.
get_occurrence(A,B,_,_) :-
chr_error(internal,'get_occurrence: missing occurrence ~w:~w
',[A,B]).
get_occurrence_from_id(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',I),
lookup_ht(I,k(C,D),H),
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,F,G,_,_,_),
!,
A=F,
B=G.
get_occurrence_from_id(_,_,_,_) :-
chr_error(internal,'get_occurrence_from_id: missing occurrence ~w:~w
',[]).
max_occurrence(A,B) :-
max_occurrence___2__0(A,B,_).
max_occurrence___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',G),
lookup_ht(G,A,F),
(
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
E>=B,
!
;
!,
max_occurrence___2__0__0__2(F,A,B,C)
).
max_occurrence___2__0__0__2([],B,C,A) :-
max_occurrence___2__1(B,C,A).
max_occurrence___2__0__0__2([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
D==A,
B>=E ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',H),
delete_ht(H,A,F),
max_occurrence___2__0__0__2(G,A,B,C)
;
max_occurrence___2__0__0__2(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_multi_hash_chr_translate____stored_complete___3-1',F),
lookup_ht(F,A,D),
!,
C=suspension(E,not_stored_yet,t,A,B),
'chr gen_id'(E),
max_occurrence___2__1__0__5(D,A,B,C).
max_occurrence___2__1__0__5([],B,C,A) :-
max_occurrence___2__2(B,C,A).
max_occurrence___2__1__0__5([G|I],B,C,A) :-
( G=suspension(_,active,_,D,E,F),
D==B,
F=0,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',J),
lookup_ht(J,B,H) ->
max_occurrence___2__1__1__5(H,E,G,I,B,C,A)
;
max_occurrence___2__1__0__5(I,B,C,A)
).
max_occurrence___2__1__1__5([],_,_,A,C,D,B) :-
max_occurrence___2__1__0__5(A,C,D,B).
max_occurrence___2__1__1__5([I|K],F,A,B,D,E,C) :-
( I=suspension(_,active,_,_,G,_,H,_,_),
G==D,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',L),
lookup_ht1(L,H,H,J) ->
max_occurrence___2__1__2__5(J,H,I,K,F,A,B,D,E,C)
;
max_occurrence___2__1__1__5(K,F,A,B,D,E,C)
).
max_occurrence___2__1__2__5([],_,_,A,G,B,C,E,F,D) :-
max_occurrence___2__1__1__5(A,G,B,C,E,F,D).
max_occurrence___2__1__2__5([L|M],I,A,B,H,C,D,F,G,E) :-
( L=suspension(_,active,_,_,_,_,J,K,_),
L\==A,
J==I,
N=t(245,L,A,C,E),
'$novel_production'(L,N),
'$novel_production'(A,N),
'$novel_production'(C,N),
'$novel_production'(E,N),
H=<G ->
'$extend_history'(E,N),
arg(2,E,O),
setarg(2,E,active),
( O==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',P),
insert_ht(P,F,E)
;
true
),
passive(I,K),
( E=suspension(_,active,_,_,_) ->
setarg(2,E,inactive),
max_occurrence___2__1__2__5(M,I,A,B,H,C,D,F,G,E)
;
true
)
;
max_occurrence___2__1__2__5(M,I,A,B,H,C,D,F,G,E)
).
max_occurrence___2__1(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
max_occurrence___2__2(A,B,C).
max_occurrence___2__2(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',D),
insert_ht(D,A,B)
;
true
).
get_max_occurrence(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
!,
B=D.
get_max_occurrence(A,_) :-
chr_error(internal,'get_max_occurrence: missing max occurrence for ~w
',[A]).
allocation_occurrence(A,B) :-
allocation_occurrence___2__0(A,B,_).
allocation_occurrence___2__0(A,0,B) :-
!,
B=suspension(C,active,t,A,0),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',D),
insert_ht(D,A,B),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',E),
insert_ht(E,k(A,0),B),
stored_in_guard_before_next_kept_occurrence(A,0),
( B=suspension(_,active,_,_,_) ->
setarg(2,B,inactive),
allocation_occurrence___2__1(A,0,B)
;
true
).
allocation_occurrence___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
allocation_occurrence___2__1(A,B,C).
allocation_occurrence___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',E),
lookup_ht(E,k(A,B),D),
!,
allocation_occurrence___2__1__0__2(D,A,B,C).
allocation_occurrence___2__1__0__2([],B,C,A) :-
allocation_occurrence___2__2(B,C,A).
allocation_occurrence___2__1__0__2([I|K],B,C,A) :-
( I=suspension(_,active,_,_,D,E,F,G,H),
D==B,
E==C,
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',L),
lookup_ht1(L,F,F,J) ->
allocation_occurrence___2__1__1__2(J,F,G,H,I,K,B,C,A)
;
allocation_occurrence___2__1__0__2(K,B,C,A)
).
allocation_occurrence___2__1__1__2([],_,_,_,_,A,C,D,B) :-
allocation_occurrence___2__1__0__2(A,C,D,B).
allocation_occurrence___2__1__1__2([K|L],F,G,H,A,B,D,E,C) :-
( K=suspension(_,active,_,_,I,J),
I==F,
M=t(58,K,A,C),
'$novel_production'(K,M),
'$novel_production'(A,M),
'$novel_production'(C,M) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',O),
insert_ht(O,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',P),
insert_ht(P,k(D,E),C)
;
true
),
\+is_passive(F,G),
H==propagation,
( stored_in_guard_before_next_kept_occurrence(D,E) ->
true
;
( J=pragma(rule([_|_],_,_,_),_,_,_,_) ->
is_observed(D,E)
)
;
( is_least_occurrence(F) ->
is_observed(D,E)
)
;
true
),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
allocation_occurrence___2__1__1__2(L,F,G,H,A,B,D,E,C)
;
true
)
;
allocation_occurrence___2__1__1__2(L,F,G,H,A,B,D,E,C)
).
allocation_occurrence___2__1(A,B,C) :-
allocation_occurrence___2__2(A,B,C).
allocation_occurrence___2__2(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',E),
lookup_ht(E,A,D),
!,
allocation_occurrence___2__2__0__3(D,A,B,C).
allocation_occurrence___2__2__0__3([],B,C,A) :-
allocation_occurrence___2__3(B,C,A).
allocation_occurrence___2__2__0__3([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,E,F,G,_),
D==B,
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',K),
lookup_ht(K,F,I) ->
allocation_occurrence___2__2__1__3(I,E,F,G,H,J,B,C,A)
;
allocation_occurrence___2__2__0__3(J,B,C,A)
).
allocation_occurrence___2__2__1__3([],_,_,_,_,A,C,D,B) :-
allocation_occurrence___2__2__0__3(A,C,D,B).
allocation_occurrence___2__2__1__3([K|N],E,F,G,A,H,B,C,D) :-
( K=suspension(_,active,I,J),
I==F,
J=[L|M],
L==G,
C>=E,
ground(F),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',V),
lookup_ht1(V,F,F,P),
'chr sbag_member'(O,P),
O=suspension(_,active,_,_,_,_),
\+may_trigger(B) ->
setarg(2,K,removed),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',T),
delete_ht(T,k(F,[G|M]),K),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',U),
delete_ht(U,F,K),
arg(2,D,Q),
setarg(2,D,active),
( Q==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',R),
insert_ht(R,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',S),
insert_ht(S,k(B,C),D)
;
true
),
least_occurrence(F,M),
( D=suspension(_,active,_,_,_) ->
setarg(2,D,inactive),
allocation_occurrence___2__2__1__3(N,E,F,G,A,H,B,C,D)
;
true
)
;
allocation_occurrence___2__2__1__3(N,E,F,G,A,H,B,C,D)
).
allocation_occurrence___2__2(A,B,C) :-
allocation_occurrence___2__3(A,B,C).
allocation_occurrence___2__3(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',E),
lookup_ht(E,A,D),
!,
allocation_occurrence___2__3__0__5(D,A,B,C).
allocation_occurrence___2__3__0__5([],B,C,A) :-
allocation_occurrence___2__4(B,C,A).
allocation_occurrence___2__3__0__5([H|I],A,B,C) :-
( H=suspension(_,active,D,E,F,G),
D==A,
E>1,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',R),
lookup_ht(R,A,L),
'chr sbag_member'(J,L),
J=suspension(_,active,_,_,_,K,E,_,_),
B>K ->
setarg(2,H,removed),
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',P),
delete_ht(P,A,H),
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',Q),
delete_ht(Q,k(A,E),H),
arg(2,C,M),
setarg(2,C,active),
( M==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',N),
insert_ht(N,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',O),
insert_ht(O,k(A,B),C)
;
true
),
functional_dependency(A,1,F,G),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
allocation_occurrence___2__3__0__5(I,A,B,C)
;
true
)
;
allocation_occurrence___2__3__0__5(I,A,B,C)
).
allocation_occurrence___2__3(A,B,C) :-
allocation_occurrence___2__4(A,B,C).
allocation_occurrence___2__4(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',F),
insert_ht(F,k(A,B),C)
;
true
).
get_allocation_occurrence(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,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_multi_hash_chr_translate____occurrence___5-3',F),
lookup_ht1(F,A,A,D),
!,
C=suspension(E,not_stored_yet,t,_,A,B),
'chr gen_id'(E),
rule___2__0__0__1(D,A,B,C).
rule___2__0__0__1([],B,C,A) :-
rule___2__1(B,C,A).
rule___2__0__0__1([I|K],B,C,A) :-
( I=suspension(_,active,_,_,D,E,F,G,H),
F==B,
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',L),
lookup_ht(L,k(D,E),J) ->
rule___2__0__1__1(J,D,E,G,H,I,K,B,C,A)
;
rule___2__0__0__1(K,B,C,A)
).
rule___2__0__1__1([],_,_,_,_,_,A,C,D,B) :-
rule___2__0__0__1(A,C,D,B).
rule___2__0__1__1([L|M],F,G,H,I,A,B,D,E,C) :-
( L=suspension(_,active,_,J,K),
J==F,
K==G,
N=t(58,C,A,L),
'$novel_production'(C,N),
'$novel_production'(A,N),
'$novel_production'(L,N) ->
'$extend_history'(C,N),
arg(2,C,O),
setarg(2,C,active),
( O==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',P),
Q=[C|P],
b_setval('$chr_store_global_ground_chr_translate____rule___2',Q),
( P=[R|_] ->
setarg(4,R,Q)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',S),
insert_ht(S,D,C)
;
true
),
\+is_passive(D,H),
I==propagation,
( stored_in_guard_before_next_kept_occurrence(F,G) ->
true
;
( E=pragma(rule([_|_],_,_,_),_,_,_,_) ->
is_observed(F,G)
)
;
( is_least_occurrence(D) ->
is_observed(F,G)
)
;
true
),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
rule___2__0__1__1(M,F,G,H,I,A,B,D,E,C)
;
true
)
;
rule___2__0__1__1(M,F,G,H,I,A,B,D,E,C)
).
rule___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,t,_,A,B),
'chr gen_id'(D),
rule___2__1(A,B,C).
rule___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',E),
lookup_ht(E,A,D),
!,
rule___2__1__0__2(D,A,B,C).
rule___2__1__0__2([],B,C,A) :-
rule___2__2(B,C,A).
rule___2__1__0__2([F|I],A,B,C) :-
( F=suspension(_,active,D,E),
D==A,
E=[G|H],
ground(A),
ground(G),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',Y),
lookup_ht(Y,k(A,G),M),
'chr sbag_member'(J,M),
J=suspension(_,active,_,_,K,L,_,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',X),
lookup_ht(X,K,P),
'chr sbag_member'(N,P),
N=suspension(_,active,_,_,O),
O>=L,
\+may_trigger(K) ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',V),
delete_ht(V,k(A,[G|H]),F),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',W),
delete_ht(W,A,F),
arg(2,C,Q),
setarg(2,C,active),
( Q==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',R),
S=[C|R],
b_setval('$chr_store_global_ground_chr_translate____rule___2',S),
( R=[T|_] ->
setarg(4,T,S)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',U),
insert_ht(U,A,C)
;
true
),
least_occurrence(A,H),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
rule___2__1__0__2(I,A,B,C)
;
true
)
;
rule___2__1__0__2(I,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_multi_hash_chr_translate____least_occurrence___2-1',E),
lookup_ht(E,A,D),
!,
rule___2__2__0__3(D,A,B,C).
rule___2__2__0__3([],B,C,A) :-
rule___2__3(B,C,A).
rule___2__2__0__3([F|I],A,B,C) :-
( F=suspension(_,active,D,E),
D==A,
E=[G|H],
ground(A),
ground(G),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',S),
lookup_ht(S,k(A,G),K),
'chr sbag_member'(J,K),
J=suspension(_,active,_,_,_) ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',Q),
delete_ht(Q,k(A,[G|H]),F),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',R),
delete_ht(R,A,F),
arg(2,C,L),
setarg(2,C,active),
( L==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',M),
N=[C|M],
b_setval('$chr_store_global_ground_chr_translate____rule___2',N),
( M=[O|_] ->
setarg(4,O,N)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',P),
insert_ht(P,A,C)
;
true
),
least_occurrence(A,H),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
rule___2__2__0__3(I,A,B,C)
;
true
)
;
rule___2__2__0__3(I,A,B,C)
).
rule___2__2(A,B,C) :-
rule___2__3(A,B,C).
rule___2__3(A,B,C) :-
B=pragma(rule([],_,_,_),ids([],D),_,_,_),
!,
arg(2,C,E),
setarg(2,C,active),
( E==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',F),
G=[C|F],
b_setval('$chr_store_global_ground_chr_translate____rule___2',G),
( F=[H|_] ->
setarg(4,H,G)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',I),
insert_ht(I,A,C)
;
true
),
least_occurrence(A,D),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
rule___2__4(A,B,C)
;
true
).
rule___2__3(A,B,C) :-
rule___2__4(A,B,C).
rule___2__4(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',F1),
lookup_ht(F1,A,I),
'chr sbag_member'(D,I),
D=suspension(_,active,_,_,_,E,F,G,H,_),
B=pragma(rule(M,N,F,O),J,K,L,A),
F\==true,
append(H,G,P),
( conj2list(F,Q),
append(P,Q,R),
guard_entailment:entails_guard(R,fail) ->
S=fail
;
simplify_guard(F,O,P,S,T)
),
F\==S,
!,
setarg(2,D,removed),
arg(4,D,A1),
( var(A1) ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',B1),
B1=[_|C1],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',C1),
( C1=[D1|_] ->
setarg(4,D1,_)
;
true
)
;
A1=[_,_|C1],
setarg(2,A1,C1),
( C1=[D1|_] ->
setarg(4,D1,A1)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',E1),
delete_ht(E1,A,D),
( var(C) ->
true
;
arg(2,C,Z),
setarg(2,C,removed),
( Z==not_stored_yet ->
true
;
arg(4,C,U),
( var(U) ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',V),
V=[_|W],
b_setval('$chr_store_global_ground_chr_translate____rule___2',W),
( W=[X|_] ->
setarg(4,X,_)
;
true
)
;
U=[_,_|W],
setarg(2,U,W),
( W=[X|_] ->
setarg(4,X,U)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',Y),
delete_ht(Y,A,C)
)
),
rule(A,pragma(rule(M,N,S,T),J,K,L,A)),
prev_guard_list(A,E,S,G,H,[]).
rule___2__4(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',D),
!,
rule___2__4__0__10(D,A,B,C).
rule___2__4__0__10([],B,C,A) :-
rule___2__5(B,C,A).
rule___2__4__0__10([D|E],B,C,A) :-
( D=suspension(_,active,_,_),
M=t(170,A,D),
'$novel_production'(A,M),
'$novel_production'(D,M) ->
'$extend_history'(A,M),
arg(2,A,N),
setarg(2,A,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',O),
P=[A|O],
b_setval('$chr_store_global_ground_chr_translate____rule___2',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',R),
insert_ht(R,B,A)
;
true
),
C=pragma(rule(F,G,_,_),_,_,_,_),
append(F,G,H),
make_head_matchings_explicit_(H,I,J),
copy_term_nat(I-J,K-L),
make_head_matchings_explicit_memo_table(B,K,L),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
rule___2__4__0__10(E,B,C,A)
;
true
)
;
rule___2__4__0__10(E,B,C,A)
).
rule___2__4(A,B,C) :-
rule___2__5(A,B,C).
rule___2__5(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',E),
lookup_ht(E,A,D),
!,
rule___2__5__0__11(D,A,B,C).
rule___2__5__0__11([],B,C,A) :-
rule___2__6(B,C,A).
rule___2__5__0__11([H|I],B,C,A) :-
( H=suspension(_,active,_,_,D,_,E,F,G,_),
D==B,
M=t(174,H,A),
'$novel_production'(H,M),
'$novel_production'(A,M),
chr_pp_flag(check_impossible_rules,on),
C=pragma(rule(_,_,E,_),_,_,_,B),
conj2list(E,J),
append(G,F,K),
append(K,J,L),
guard_entailment:entails_guard(L,fail) ->
'$extend_history'(A,M),
arg(2,A,N),
setarg(2,A,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',O),
P=[A|O],
b_setval('$chr_store_global_ground_chr_translate____rule___2',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',R),
insert_ht(R,B,A)
;
true
),
chr_warning(weird_program,'Heads will never match or guard will always fail in ~@.
This rule will never fire!
',[format_rule(C)]),
set_all_passive(B),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
rule___2__5__0__11(I,B,C,A)
;
true
)
;
rule___2__5__0__11(I,B,C,A)
).
rule___2__5(A,B,C) :-
rule___2__6(A,B,C).
rule___2__6(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',I1),
lookup_ht(I1,A,I),
'chr sbag_member'(D,I),
D=suspension(_,active,_,_,_,E,F,G,H,_),
B=pragma(rule(M,N,F,O),J,K,L,A),
simplify_heads(H,G,F,O,P,Q),
P\==[],
extract_arguments(M,R),
extract_arguments(N,S),
extract_arguments(E,T),
replace_some_heads(R,S,T,P,U,V,F,O,W),
substitute_arguments(M,U,X),
substitute_arguments(N,V,Y),
append(Q,W,Z),
list2conj(Z,A1),
B1=pragma(rule(X,Y,F,(A1,O)),J,K,L,A),
(
M\==X
;
N\==Y
),
!,
( var(C) ->
true
;
arg(2,C,H1),
setarg(2,C,removed),
( H1==not_stored_yet ->
true
;
arg(4,C,C1),
( var(C1) ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',D1),
D1=[_|E1],
b_setval('$chr_store_global_ground_chr_translate____rule___2',E1),
( E1=[F1|_] ->
setarg(4,F1,_)
;
true
)
;
C1=[_,_|E1],
setarg(2,C1,E1),
( E1=[F1|_] ->
setarg(4,F1,C1)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',G1),
delete_ht(G1,A,C)
)
),
rule(A,B1).
rule___2__6(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',E),
lookup_ht1(E,A,A,D),
!,
rule___2__6__0__13(D,A,B,C).
rule___2__6__0__13([],B,C,A) :-
rule___2__7(B,C,A).
rule___2__6__0__13([G|I],B,C,A) :-
( G=suspension(_,active,_,_,D,E,F,_,_),
F==B,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',J),
lookup_ht(J,D,H) ->
rule___2__6__1__13(H,D,E,G,I,B,C,A)
;
rule___2__6__0__13(I,B,C,A)
).
rule___2__6__1__13([],_,_,_,A,C,D,B) :-
rule___2__6__0__13(A,C,D,B).
rule___2__6__1__13([L|N],F,G,A,B,D,E,C) :-
( L=suspension(_,active,_,_,H,I,J,K,_),
L\==A,
H==F,
J==D,
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',O),
lookup_ht(O,D,M) ->
rule___2__6__2__13(M,I,K,L,N,F,G,A,B,D,E,C)
;
rule___2__6__1__13(N,F,G,A,B,D,E,C)
).
rule___2__6__2__13([],_,_,_,A,G,H,B,C,E,F,D) :-
rule___2__6__1__13(A,G,H,B,C,E,F,D).
rule___2__6__2__13([M|O],J,K,A,B,H,I,C,D,F,G,E) :-
( M=suspension(_,active,_,_,L,_,_,_,_,_),
L==F,
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',N) ->
rule___2__6__3__13(N,M,O,J,K,A,B,H,I,C,D,F,G,E)
;
rule___2__6__2__13(O,J,K,A,B,H,I,C,D,F,G,E)
).
rule___2__6__3__13([],_,A,K,L,B,C,I,J,D,E,G,H,F) :-
rule___2__6__2__13(A,K,L,B,C,I,J,D,E,G,H,F).
rule___2__6__3__13([O|P],A,M,J,K,B,L,G,H,C,I,D,E,F) :-
( O=suspension(_,active,_,N),
J<H,
chr_pp_flag(occurrence_subsumption,on),
E=pragma(rule(Q,_,_,_),_,_,_,_),
Q\==[],
\+tree_set_memberchk(G,N) ->
setarg(2,O,removed),
arg(3,O,X),
( var(X) ->
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',Y),
Y=[_|Z],
b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',Z),
( Z=[A1|_] ->
setarg(3,A1,_)
;
true
)
;
X=[_,_|Z],
setarg(2,X,Z),
( Z=[A1|_] ->
setarg(3,A1,X)
;
true
)
),
arg(2,F,S),
setarg(2,F,active),
( S==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',T),
U=[F|T],
b_setval('$chr_store_global_ground_chr_translate____rule___2',U),
( T=[V|_] ->
setarg(4,V,U)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',W),
insert_ht(W,D,F)
;
true
),
first_occ_in_rule(D,G,J,K),
tree_set_add(N,G,R),
multiple_occ_constraints_checked(R),
( F=suspension(_,active,_,_,_,_) ->
setarg(2,F,inactive),
rule___2__6__3__13(P,A,M,J,K,B,L,G,H,C,I,D,E,F)
;
true
)
;
rule___2__6__3__13(P,A,M,J,K,B,L,G,H,C,I,D,E,F)
).
rule___2__6(A,B,C) :-
rule___2__7(A,B,C).
rule___2__7(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____static_type_check___0',D),
!,
rule___2__7__0__15(D,A,B,C).
rule___2__7__0__15([],B,C,A) :-
rule___2__8(B,C,A).
rule___2__7__0__15([D|E],B,C,A) :-
( D=suspension(_,active,_,_),
T=t(209,A,D),
'$novel_production'(A,T),
'$novel_production'(D,T) ->
'$extend_history'(A,T),
arg(2,A,U),
setarg(2,A,active),
( U==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',V),
W=[A|V],
b_setval('$chr_store_global_ground_chr_translate____rule___2',W),
( V=[X|_] ->
setarg(4,X,W)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',Y),
insert_ht(Y,B,A)
;
true
),
copy_term_nat(C,F),
F=pragma(rule(G,H,_,I),ids(_,_),_,_,_),
(
catch((static_type_check_heads(G),static_type_check_heads(H),conj2list(I,J),static_type_check_body(J)),type_error(K),(K=invalid_functor(L,M,N)->chr_error(type_error,'Invalid functor in ~@ of ~@:
found `~w'',
expected type `~w''!
',[chr_translate:format_src(L),format_rule(C),M,N]);K=type_clash(O,P,Q,R,S)->chr_error(type_error,'Type clash for variable ~w in ~@:
expected type ~w in ~@
expected type ~w in ~@
',[O,format_rule(C),R,chr_translate:format_src(P),S,chr_translate:format_src(Q)]))),
fail
;
true
),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
rule___2__7__0__15(E,B,C,A)
;
true
)
;
rule___2__7__0__15(E,B,C,A)
).
rule___2__7(A,B,C) :-
rule___2__8(A,B,C).
rule___2__8(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',E),
lookup_ht(E,A,D),
!,
rule___2__8__0__16(D,A,B,C).
rule___2__8__0__16([],B,C,A) :-
rule___2__9(B,C,A).
rule___2__8__0__16([F|G],B,C,A) :-
( F=suspension(_,active,_,D,E),
D==B,
K=t(246,A,F),
'$novel_production'(A,K),
'$novel_production'(F,K),
C=pragma(rule(_,_,_,_),ids([E|I],H),_,_,B) ->
'$extend_history'(A,K),
arg(2,A,L),
setarg(2,A,active),
( L==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',M),
N=[A|M],
b_setval('$chr_store_global_ground_chr_translate____rule___2',N),
( M=[O|_] ->
setarg(4,O,N)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',P),
insert_ht(P,B,A)
;
true
),
append(I,H,J),
check_all_passive(B,J),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
rule___2__8__0__16(G,B,C,A)
;
true
)
;
rule___2__8__0__16(G,B,C,A)
).
rule___2__8(A,B,C) :-
rule___2__9(A,B,C).
rule___2__9(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',E),
lookup_ht(E,A,D),
!,
rule___2__9__0__17(D,A,B,C).
rule___2__9__0__17([],B,C,A) :-
rule___2__10(B,C,A).
rule___2__9__0__17([F|G],B,C,A) :-
( F=suspension(_,active,_,D,E),
D==B,
I=t(247,A,F),
'$novel_production'(A,I),
'$novel_production'(F,I),
C=pragma(rule(_,_,_,_),ids([],[E|H]),_,_,B) ->
'$extend_history'(A,I),
arg(2,A,J),
setarg(2,A,active),
( J==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',K),
L=[A|K],
b_setval('$chr_store_global_ground_chr_translate____rule___2',L),
( K=[M|_] ->
setarg(4,M,L)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',N),
insert_ht(N,B,A)
;
true
),
check_all_passive(B,H),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
rule___2__9__0__17(G,B,C,A)
;
true
)
;
rule___2__9__0__17(G,B,C,A)
).
rule___2__9(A,B,C) :-
rule___2__10(A,B,C).
rule___2__10(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',E),
hash_term(k(A,11910),F),
lookup_ht1(E,F,k(A,[]),D),
!,
rule___2__10__0__18(D,A,B,C).
rule___2__10__0__18([],B,C,A) :-
rule___2__11(B,C,A).
rule___2__10__0__18([F|G],A,B,C) :-
( F=suspension(_,active,D,E),
D==A,
E=[] ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',M),
delete_ht(M,k(A,[]),F),
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',N),
delete_ht(N,A,F),
arg(2,C,H),
setarg(2,C,active),
( H==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',I),
J=[C|I],
b_setval('$chr_store_global_ground_chr_translate____rule___2',J),
( I=[K|_] ->
setarg(4,K,J)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',L),
insert_ht(L,A,C)
;
true
),
chr_warning(weird_program,'All heads passive in ~@.
This rule never fires. Please check your program.
',[format_rule(B)]),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
rule___2__10__0__18(G,A,B,C)
;
true
)
;
rule___2__10__0__18(G,A,B,C)
).
rule___2__10(A,B,C) :-
rule___2__11(A,B,C).
rule___2__11(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',E),
lookup_ht1(E,A,A,D),
!,
rule___2__11__0__23(D,A,B,C).
rule___2__11__0__23([],B,C,A) :-
rule___2__12(B,C,A).
rule___2__11__0__23([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,_,E,F,G),
E==B,
nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',I) ->
rule___2__11__1__23(I,D,F,G,H,J,B,C,A)
;
rule___2__11__0__23(J,B,C,A)
).
rule___2__11__1__23([],_,_,_,_,A,C,D,B) :-
rule___2__11__0__23(A,C,D,B).
rule___2__11__1__23([I|K],F,G,H,A,B,D,E,C) :-
( I=suspension(_,active,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',L),
lookup_ht(L,F,J) ->
rule___2__11__2__23(J,I,K,F,G,H,A,B,D,E,C)
;
rule___2__11__1__23(K,F,G,H,A,B,D,E,C)
).
rule___2__11__2__23([],_,A,G,H,I,B,C,E,F,D) :-
rule___2__11__1__23(A,G,H,I,B,C,E,F,D).
rule___2__11__2__23([M|N],A,B,H,I,J,C,D,F,G,E) :-
( M=suspension(_,active,_,_,K,L),
K==H,
U=t(325,A,C,E,M),
'$novel_production'(A,U),
'$novel_production'(C,U),
'$novel_production'(E,U),
'$novel_production'(M,U) ->
'$extend_history'(E,U),
arg(2,E,V),
setarg(2,E,active),
( V==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',W),
X=[E|W],
b_setval('$chr_store_global_ground_chr_translate____rule___2',X),
( W=[Y|_] ->
setarg(4,Y,X)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',Z),
insert_ht(Z,F,E)
;
true
),
G=pragma(rule(O,P,Q,_),_,_,_,_),
( is_passive(F,I) ->
true
;
( J==simplification ->
select(R,O,_),
R=..[_|S],
term_variables(Q,T),
partial_wake_args(S,L,T,H)
)
;
select(R,P,_),
R=..[_|S],
term_variables(Q,T),
partial_wake_args(S,L,T,H)
),
( E=suspension(_,active,_,_,_,_) ->
setarg(2,E,inactive),
rule___2__11__2__23(N,A,B,H,I,J,C,D,F,G,E)
;
true
)
;
rule___2__11__2__23(N,A,B,H,I,J,C,D,F,G,E)
).
rule___2__11(A,B,C) :-
rule___2__12(A,B,C).
rule___2__12(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____rule___2',E),
( D=[F|_] ->
setarg(4,F,E)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',G),
insert_ht(G,A,B)
;
true
).
get_rule(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',F),
lookup_ht1(F,A,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,D),
!,
B=D.
get_rule(_,_) :-
fail.
least_occurrence(A,[B|C]) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',P),
lookup_ht1(P,A,A,E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_,_),
(
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',R),
lookup_ht(R,k(A,B),I),
'chr sbag_member'(F,I),
F=suspension(_,active,_,_,G,H,_,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',Q),
lookup_ht(Q,G,L),
'chr sbag_member'(J,L),
J=suspension(_,active,_,_,K),
K>=H,
\+may_trigger(G),
!,
least_occurrence(A,C)
;
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',O),
lookup_ht(O,k(A,B),N),
'chr sbag_member'(M,N),
M=suspension(_,active,_,_,_),
!,
least_occurrence(A,C)
).
least_occurrence(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',E),
insert_ht(E,k(A,B),C),
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',F),
insert_ht(F,A,C).
is_least_occurrence(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',D),
hash_term(k(A,11910),E),
lookup_ht1(D,E,k(A,[]),C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!.
is_least_occurrence(_) :-
fail.
stored_in_guard_lookahead(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',L),
lookup_ht(L,k(A,B),G),
'chr sbag_member'(C,G),
C=suspension(_,active,_,_,_,_,D,E,F),
(
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',M),
lookup_ht(M,k(D,E),I),
'chr sbag_member'(H,I),
H=suspension(_,active,_,_,_),
!,
J is B+1,
stored_in_guard_lookahead(A,J)
;
!,
F==simplification,
( is_stored_in_guard(A,D) ->
true
;
K is B+1,
stored_in_guard_lookahead(A,K)
)
).
stored_in_guard_lookahead(_,_) :-
fail.
constraint_index(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',E),
insert_ht(E,B,C),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',F),
insert_ht(F,A,C).
get_constraint_index(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
get_constraint_index(_,_) :-
fail.
get_indexed_constraint(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',F),
G is abs(A),
lookup_ht1(F,G,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,D,_),
!,
B=D.
get_indexed_constraint(_,_) :-
fail.
max_constraint_index(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____max_constraint_index___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____max_constraint_index___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
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(_,active,_,C),
!,
A=C.
get_max_constraint_index(0).
identifier_size(A) :-
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',C),
(
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!
;
!,
identifier_size___1__0__0__2(C,A)
).
identifier_size___1__0__0__2([],A) :-
identifier_size___1__1(A).
identifier_size___1__0__0__2([B|C],A) :-
( B=suspension(_,active,_,_) ->
setarg(2,B,removed),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',E),
E=[_|F],
b_setval('$chr_store_global_ground_chr_translate____identifier_size___1',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
identifier_size___1__0__0__2(C,A)
;
identifier_size___1__0__0__2(C,A)
).
identifier_size(A) :-
identifier_size___1__1(A).
identifier_size___1__1(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____identifier_size___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
get_identifier_size(A) :-
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
A=C.
get_identifier_size(1).
identifier_index(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',F),
lookup_ht(F,k(A,B),E),
(
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_),
!
;
!,
identifier_index___3__0__0__2(E,A,B,C)
).
identifier_index___3__0__0__2([],A,B,C) :-
identifier_index___3__1(A,B,C).
identifier_index___3__0__0__2([F|G],A,B,C) :-
( F=suspension(_,active,D,E,_),
D==A,
E==B ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',H),
delete_ht(H,k(A,B),F),
identifier_index___3__0__0__2(G,A,B,C)
;
identifier_index___3__0__0__2(G,A,B,C)
).
identifier_index(A,B,C) :-
identifier_index___3__1(A,B,C).
identifier_index___3__1(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',F),
insert_ht(F,k(A,B),D).
get_identifier_index(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
C=E.
get_identifier_index(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,E),
!,
setarg(2,D,removed),
arg(3,D,H),
( var(H) ->
nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',I),
I=[_|J],
b_setval('$chr_store_global_ground_chr_translate____identifier_size___1',J),
( J=[K|_] ->
setarg(3,K,_)
;
true
)
;
H=[_,_|J],
setarg(2,H,J),
( J=[K|_] ->
setarg(3,K,H)
;
true
)
),
G is E+1,
identifier_index(A,B,G),
identifier_size(G),
C=G.
get_identifier_index(A,B,C) :-
identifier_index(A,B,2),
identifier_size(2),
C=2.
type_indexed_identifier_size(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',E),
lookup_ht(E,A,D),
(
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!
;
!,
type_indexed_identifier_size___2__0__0__2(D,A,B)
).
type_indexed_identifier_size___2__0__0__2([],A,B) :-
type_indexed_identifier_size___2__1(A,B).
type_indexed_identifier_size___2__0__0__2([D|E],A,B) :-
( D=suspension(_,active,C,_),
C==A ->
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',F),
delete_ht(F,A,D),
type_indexed_identifier_size___2__0__0__2(E,A,B)
;
type_indexed_identifier_size___2__0__0__2(E,A,B)
).
type_indexed_identifier_size(A,B) :-
type_indexed_identifier_size___2__1(A,B).
type_indexed_identifier_size___2__1(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',E),
insert_ht(E,A,C).
get_type_indexed_identifier_size(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
get_type_indexed_identifier_size(_,1).
type_indexed_identifier_index(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',G),
lookup_ht(G,k(B,C),F),
(
'chr sbag_member'(E,F),
E=suspension(_,active,_,_,_,_),
!
;
!,
type_indexed_identifier_index___4__0__0__2(F,A,B,C,D)
).
type_indexed_identifier_index___4__0__0__2([],A,B,C,D) :-
type_indexed_identifier_index___4__1(A,B,C,D).
type_indexed_identifier_index___4__0__0__2([H|I],A,B,C,D) :-
( H=suspension(_,active,E,F,G,_),
F==B,
G==C ->
setarg(2,H,removed),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',J),
delete_ht(J,k(E,B,C),H),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',K),
delete_ht(K,k(B,C),H),
type_indexed_identifier_index___4__0__0__2(I,A,B,C,D)
;
type_indexed_identifier_index___4__0__0__2(I,A,B,C,D)
).
type_indexed_identifier_index(A,B,C,D) :-
type_indexed_identifier_index___4__1(A,B,C,D).
type_indexed_identifier_index___4__1(A,B,C,D) :-
E=suspension(F,active,A,B,C,D),
'chr gen_id'(F),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',G),
insert_ht(G,k(A,B,C),E),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',H),
insert_ht(H,k(B,C),E).
get_type_indexed_identifier_index(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',H),
lookup_ht(H,k(A,B,C),G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,_,_,F),
!,
D=F.
get_type_indexed_identifier_index(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',J),
lookup_ht(J,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,F),
!,
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',I),
delete_ht(I,A,E),
H is F+1,
type_indexed_identifier_index(A,B,C,H),
type_indexed_identifier_size(A,H),
D=H.
get_type_indexed_identifier_index(A,B,C,D) :-
type_indexed_identifier_index(A,B,C,2),
type_indexed_identifier_size(A,2),
D=2.
no_history(A) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',D),
insert_ht(D,A,B).
has_no_history(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',D),
E is abs(A),
lookup_ht1(D,E,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
has_no_history(_) :-
fail.
history(A,B,C) :-
history___3__0(A,B,C,_).
history___3__0(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',G),
lookup_ht(G,A,E),
!,
D=suspension(F,not_stored_yet,t,A,B,C),
'chr gen_id'(F),
history___3__0__0__1(E,A,B,C,D).
history___3__0__0__1([],B,C,D,A) :-
history___3__1(B,C,D,A).
history___3__0__0__1([F|G],B,C,D,A) :-
( F=suspension(_,active,_,E,_,_),
E==B,
H=t(93,A,F),
'$novel_production'(A,H),
'$novel_production'(F,H) ->
'$extend_history'(A,H),
arg(2,A,I),
setarg(2,A,active),
( I==not_stored_yet ->
( '$chr_store_constants_chr_translate____history___3___[3]'(D,J) ->
nb_getval(J,K),
b_setval(J,[A|K])
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',L),
insert_ht(L,C,A),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',M),
insert_ht(M,B,A)
;
true
),
chr_error(syntax,'Only one pragma history allowed per rule (rule number ~w)
',[B]),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
history___3__0__0__1(G,B,C,D,A)
;
true
)
;
history___3__0__0__1(G,B,C,D,A)
).
history___3__0(A,B,C,D) :-
D=suspension(E,not_stored_yet,t,A,B,C),
'chr gen_id'(E),
history___3__1(A,B,C,D).
history___3__1(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',F),
lookup_ht(F,A,E),
!,
history___3__1__0__2(E,A,B,C,D).
history___3__1__0__2([],B,C,D,A) :-
history___3__2(B,C,D,A).
history___3__1__0__2([F|G],B,C,D,A) :-
( F=suspension(_,active,_,E,_,_),
E==B,
H=t(93,F,A),
'$novel_production'(F,H),
'$novel_production'(A,H) ->
'$extend_history'(A,H),
arg(2,A,I),
setarg(2,A,active),
( I==not_stored_yet ->
( '$chr_store_constants_chr_translate____history___3___[3]'(D,J) ->
nb_getval(J,K),
b_setval(J,[A|K])
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',L),
insert_ht(L,C,A),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',M),
insert_ht(M,B,A)
;
true
),
chr_error(syntax,'Only one pragma history allowed per rule (rule number ~w)
',[B]),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
history___3__1__0__2(G,B,C,D,A)
;
true
)
;
history___3__1__0__2(G,B,C,D,A)
).
history___3__1(A,B,C,D) :-
history___3__2(A,B,C,D).
history___3__2(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',F),
lookup_ht(F,B,E),
!,
history___3__2__0__3(E,A,B,C,D).
history___3__2__0__3([],B,C,D,A) :-
history___3__3(B,C,D,A).
history___3__2__0__3([H|I],B,C,D,A) :-
( H=suspension(_,active,_,E,F,G),
F==C,
L=t(94,A,H),
'$novel_production'(A,L),
'$novel_production'(H,L) ->
'$extend_history'(A,L),
arg(2,A,M),
setarg(2,A,active),
( M==not_stored_yet ->
( '$chr_store_constants_chr_translate____history___3___[3]'(D,N) ->
nb_getval(N,O),
b_setval(N,[A|O])
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',P),
insert_ht(P,C,A),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',Q),
insert_ht(Q,B,A)
;
true
),
length(D,J),
length(G,K),
( J\==K ->
chr_error(syntax,'The history named ~w does not always range over an equal amount of occurrences.
',[C])
;
test_named_history_id_pairs(B,D,E,G)
),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
history___3__2__0__3(I,B,C,D,A)
;
true
)
;
history___3__2__0__3(I,B,C,D,A)
).
history___3__2(A,B,C,D) :-
history___3__3(A,B,C,D).
history___3__3(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',F),
lookup_ht(F,B,E),
!,
history___3__3__0__4(E,A,B,C,D).
history___3__3__0__4([],B,C,D,A) :-
history___3__4(B,C,D,A).
history___3__3__0__4([H|I],B,C,D,A) :-
( H=suspension(_,active,_,E,F,G),
F==C,
L=t(94,H,A),
'$novel_production'(H,L),
'$novel_production'(A,L) ->
'$extend_history'(A,L),
arg(2,A,M),
setarg(2,A,active),
( M==not_stored_yet ->
( '$chr_store_constants_chr_translate____history___3___[3]'(D,N) ->
nb_getval(N,O),
b_setval(N,[A|O])
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',P),
insert_ht(P,C,A),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',Q),
insert_ht(Q,B,A)
;
true
),
length(G,J),
length(D,K),
( J\==K ->
chr_error(syntax,'The history named ~w does not always range over an equal amount of occurrences.
',[C])
;
test_named_history_id_pairs(E,G,B,D)
),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
history___3__3__0__4(I,B,C,D,A)
;
true
)
;
history___3__3__0__4(I,B,C,D,A)
).
history___3__3(A,B,C,D) :-
history___3__4(A,B,C,D).
history___3__4(A,B,[],C) :-
nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',D),
!,
history___3__4__0__6(D,A,B,[],C).
history___3__4__0__6([],B,C,D,A) :-
history___3__5(B,C,D,A).
history___3__4__0__6([E|F],B,C,D,A) :-
( E=suspension(_,active,_,_),
G=t(140,E,A),
'$novel_production'(E,G),
'$novel_production'(A,G) ->
'$extend_history'(A,G),
arg(2,A,H),
setarg(2,A,active),
( H==not_stored_yet ->
( '$chr_store_constants_chr_translate____history___3___[3]'(D,I) ->
nb_getval(I,J),
b_setval(I,[A|J])
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',K),
insert_ht(K,C,A),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',L),
insert_ht(L,B,A)
;
true
),
generate_empty_named_history_initialisation(C),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
history___3__4__0__6(F,B,C,D,A)
;
true
)
;
history___3__4__0__6(F,B,C,D,A)
).
history___3__4(A,B,C,D) :-
history___3__5(A,B,C,D).
history___3__5(A,B,C,D) :-
arg(2,D,E),
setarg(2,D,active),
( E==not_stored_yet ->
( '$chr_store_constants_chr_translate____history___3___[3]'(C,F) ->
nb_getval(F,G),
b_setval(F,[D|G])
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',H),
insert_ht(H,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',I),
insert_ht(I,A,D)
;
true
).
named_history(A,B,C) :-
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',H),
lookup_ht(H,A,G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
!,
B=E,
C=F.
named_history(_,_,_) :-
fail.
test_named_history_id_pair(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',L),
lookup_ht(L,k(A,B),G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,_,F,_,_,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',K),
lookup_ht(K,k(C,D),J),
'chr sbag_member'(H,J),
H=suspension(_,active,_,_,I,_,_,_,_),
H\==E,
I=F,
!.
test_named_history_id_pair(A,_,B,_) :-
chr_error(syntax,'Occurrences of shared history in rules number ~w and ~w do not correspond
',[B,A]).
indexing_spec(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',H),
lookup_ht(H,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',G),
delete_ht(G,A,C),
append(B,D,F),
indexing_spec(A,F).
indexing_spec(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',E),
insert_ht(E,A,C).
get_indexing_spec(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
get_indexing_spec(_,[]).
observation_analysis(A) :-
observation_analysis___1__0(A,_).
observation_analysis___1__0(A,B) :-
nb_getval('$chr_store_global_ground_chr_translate____rule___2',C),
!,
B=suspension(D,not_stored_yet,_,A),
'chr gen_id'(D),
observation_analysis___1__0__0__1(C,A,B).
observation_analysis___1__0__0__1([],B,A) :-
observation_analysis___1__1(B,A).
observation_analysis___1__0__0__1([E|F],B,A) :-
( E=suspension(_,active,_,_,C,D) ->
D=pragma(rule(_,_,G,H),_,_,_,_),
( chr_pp_flag(store_in_guards,on) ->
observation_analysis(C,G,guard,B)
;
true
),
observation_analysis(C,H,body,B),
observation_analysis___1__0__0__1(F,B,A)
;
observation_analysis___1__0__0__1(F,B,A)
).
observation_analysis___1__0(A,B) :-
B=suspension(C,not_stored_yet,_,A),
'chr gen_id'(C),
observation_analysis___1__1(A,B).
observation_analysis___1__1(_,A) :-
( var(A) ->
true
;
arg(2,A,F),
setarg(2,A,removed),
( F==not_stored_yet ->
true
;
arg(3,A,B),
( var(B) ->
nb_getval('$chr_store_global_ground_chr_translate____observation_analysis___1',C),
C=[_|D],
b_setval('$chr_store_global_ground_chr_translate____observation_analysis___1',D),
( D=[E|_] ->
setarg(3,E,_)
;
true
)
;
B=[_,_|D],
setarg(2,B,D),
( D=[E|_] ->
setarg(3,E,B)
;
true
)
)
)
).
spawns(A,B,C) :-
spawns___3__0(A,B,C,_).
spawns___3__0(A,B,C,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',F),
lookup_ht(F,k(A,B,C),E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_,_,_),
!.
spawns___3__0(A,body,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',E),
hash_term(k(A,1612897,B),F),
lookup_ht1(E,F,k(A,guard,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_,_,_),
!.
spawns___3__0(A,guard,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',E),
hash_term(k(A,1640016,B),F),
lookup_ht1(E,F,k(A,body,B),D),
!,
spawns___3__0__0__4(D,A,guard,B,C).
spawns___3__0__0__4([],B,C,D,A) :-
spawns___3__1(B,C,D,A).
spawns___3__0__0__4([H|I],A,B,C,D) :-
( H=suspension(_,active,_,_,E,F,G),
E==A,
F=body,
G==C ->
setarg(2,H,removed),
arg(4,H,J),
( var(J) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',K),
K=[_|L],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',L),
( L=[M|_] ->
setarg(4,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(4,M,J)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',N),
delete_ht(N,k(A,body),H),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',O),
delete_ht(O,A,H),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',P),
delete_ht(P,C,H),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',Q),
delete_ht(Q,k(A,body,C),H),
spawns___3__0__0__4(I,A,B,C,D)
;
spawns___3__0__0__4(I,A,B,C,D)
).
spawns___3__0(A,B,C,D) :-
spawns___3__1(A,B,C,D).
spawns___3__1(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',P),
lookup_ht(P,k(A,B),F),
'chr sbag_member'(E,F),
E=suspension(_,active,_,_),
!,
( var(D) ->
true
;
arg(2,D,O),
setarg(2,D,removed),
( O==not_stored_yet ->
true
;
arg(4,D,G),
( var(G) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',H),
H=[_|I],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',I),
( I=[J|_] ->
setarg(4,J,_)
;
true
)
;
G=[_,_|I],
setarg(2,G,I),
( I=[J|_] ->
setarg(4,J,G)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',K),
delete_ht(K,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',L),
delete_ht(L,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',M),
delete_ht(M,C,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',N),
delete_ht(N,k(A,B,C),D)
)
).
spawns___3__1(A,body,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',O),
hash_term(k(A,1612897),P),
lookup_ht1(O,P,k(A,guard),E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_),
!,
( var(C) ->
true
;
arg(2,C,N),
setarg(2,C,removed),
( N==not_stored_yet ->
true
;
arg(4,C,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',H),
( H=[I|_] ->
setarg(4,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(4,I,F)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',J),
delete_ht(J,k(A,body),C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',K),
delete_ht(K,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',L),
delete_ht(L,B,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',M),
delete_ht(M,k(A,body,B),C)
)
).
spawns___3__1(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',P),
lookup_ht(P,k(A,B),F),
'chr sbag_member'(E,F),
E=suspension(_,active,_,_,_,_),
may_trigger(C),
!,
( var(D) ->
true
;
arg(2,D,O),
setarg(2,D,removed),
( O==not_stored_yet ->
true
;
arg(4,D,G),
( var(G) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',H),
H=[_|I],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',I),
( I=[J|_] ->
setarg(4,J,_)
;
true
)
;
G=[_,_|I],
setarg(2,G,I),
( I=[J|_] ->
setarg(4,J,G)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',K),
delete_ht(K,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',L),
delete_ht(L,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',M),
delete_ht(M,C,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',N),
delete_ht(N,k(A,B,C),D)
)
).
spawns___3__1(A,body,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',O),
hash_term(k(A,1612897),P),
lookup_ht1(O,P,k(A,guard),E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_,_),
may_trigger(B),
!,
( var(C) ->
true
;
arg(2,C,N),
setarg(2,C,removed),
( N==not_stored_yet ->
true
;
arg(4,C,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',H),
( H=[I|_] ->
setarg(4,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(4,I,F)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',J),
delete_ht(J,k(A,body),C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',K),
delete_ht(K,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',L),
delete_ht(L,B,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',M),
delete_ht(M,k(A,body,B),C)
)
).
spawns___3__1(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',N),
lookup_ht(N,C,H),
(
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,_,_,F,G,_),
(
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',H1),
lookup_ht(H1,F,J),
'chr sbag_member'(I,J),
I=suspension(_,active,_,_),
\+is_passive(F,G),
!,
( var(D) ->
true
;
arg(2,D,G1),
setarg(2,D,removed),
( G1==not_stored_yet ->
true
;
arg(4,D,Y),
( var(Y) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',Z),
Z=[_|A1],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',A1),
( A1=[B1|_] ->
setarg(4,B1,_)
;
true
)
;
Y=[_,_|A1],
setarg(2,Y,A1),
( A1=[B1|_] ->
setarg(4,B1,Y)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',C1),
delete_ht(C1,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',D1),
delete_ht(D1,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',E1),
delete_ht(E1,C,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',F1),
delete_ht(F1,k(A,B,C),D)
)
),
spawns_all(A,B)
;
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',X),
lookup_ht(X,F,L),
'chr sbag_member'(K,L),
K=suspension(_,active,_,_,_,_),
may_trigger(C),
\+is_passive(F,G),
!,
( var(D) ->
true
;
arg(2,D,W),
setarg(2,D,removed),
( W==not_stored_yet ->
true
;
arg(4,D,O),
( var(O) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',P),
P=[_|Q],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',Q),
( Q=[R|_] ->
setarg(4,R,_)
;
true
)
;
O=[_,_|Q],
setarg(2,O,Q),
( Q=[R|_] ->
setarg(4,R,O)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',S),
delete_ht(S,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',T),
delete_ht(T,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',U),
delete_ht(U,C,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',V),
delete_ht(V,k(A,B,C),D)
)
),
spawns_all_triggers(A,B)
)
;
!,
D=suspension(M,not_stored_yet,t,_,A,B,C),
'chr gen_id'(M),
spawns___3__1__0__11(H,A,B,C,D)
).
spawns___3__1__0__11([],B,C,D,A) :-
spawns___3__2(B,C,D,A).
spawns___3__1__0__11([H|J],B,C,D,A) :-
( H=suspension(_,active,_,_,E,_,F,G,_),
E==D,
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',K),
lookup_ht(K,F,I) ->
spawns___3__1__1__11(I,F,G,H,J,B,C,D,A)
;
spawns___3__1__0__11(J,B,C,D,A)
).
spawns___3__1__1__11([],_,_,_,A,C,D,E,B) :-
spawns___3__1__0__11(A,C,D,E,B).
spawns___3__1__1__11([J|K],G,H,A,B,D,E,F,C) :-
( J=suspension(_,active,_,_,I,_),
I==G,
L=t(121,J,A,C),
'$novel_production'(J,L),
'$novel_production'(C,L),
\+may_trigger(F),
\+is_passive(G,H) ->
'$extend_history'(C,L),
arg(2,C,M),
setarg(2,C,active),
( M==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',N),
O=[C|N],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',O),
( N=[P|_] ->
setarg(4,P,O)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',Q),
insert_ht(Q,k(D,E),C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',R),
insert_ht(R,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',S),
insert_ht(S,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',T),
insert_ht(T,k(D,E,F),C)
;
true
),
spawns_all_triggers(D,E),
( C=suspension(_,active,_,_,_,_,_) ->
setarg(2,C,inactive),
spawns___3__1__1__11(K,G,H,A,B,D,E,F,C)
;
true
)
;
spawns___3__1__1__11(K,G,H,A,B,D,E,F,C)
).
spawns___3__1(A,B,C,D) :-
D=suspension(E,not_stored_yet,t,_,A,B,C),
'chr gen_id'(E),
spawns___3__2(A,B,C,D).
spawns___3__2(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',F),
lookup_ht1(F,A,A,E),
!,
spawns___3__2__0__12(E,A,B,C,D).
spawns___3__2__0__12([],B,C,D,A) :-
spawns___3__3(B,C,D,A).
spawns___3__2__0__12([H|J],B,C,D,A) :-
( H=suspension(_,active,_,_,E,_,F,G,_),
F==B,
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',K),
lookup_ht(K,E,I) ->
spawns___3__2__1__12(I,E,G,H,J,B,C,D,A)
;
spawns___3__2__0__12(J,B,C,D,A)
).
spawns___3__2__1__12([],_,_,_,A,C,D,E,B) :-
spawns___3__2__0__12(A,C,D,E,B).
spawns___3__2__1__12([L|M],G,H,A,B,D,E,F,C) :-
( L=suspension(_,active,_,_,I,J,K),
K==G,
N=t(122,C,A,L),
'$novel_production'(C,N),
'$novel_production'(L,N),
I\==D,
G\==F,
\+is_passive(D,H) ->
'$extend_history'(C,N),
arg(2,C,O),
setarg(2,C,active),
( O==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',P),
Q=[C|P],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',Q),
( P=[R|_] ->
setarg(4,R,Q)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',S),
insert_ht(S,k(D,E),C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',T),
insert_ht(T,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',U),
insert_ht(U,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',V),
insert_ht(V,k(D,E,F),C)
;
true
),
spawns(I,J,F),
( C=suspension(_,active,_,_,_,_,_) ->
setarg(2,C,inactive),
spawns___3__2__1__12(M,G,H,A,B,D,E,F,C)
;
true
)
;
spawns___3__2__1__12(M,G,H,A,B,D,E,F,C)
).
spawns___3__2(A,B,C,D) :-
spawns___3__3(A,B,C,D).
spawns___3__3(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',F),
lookup_ht(F,C,E),
!,
spawns___3__3__0__13(E,A,B,C,D).
spawns___3__3__0__13([],B,C,D,A) :-
spawns___3__4(B,C,D,A).
spawns___3__3__0__13([H|J],B,C,D,A) :-
( H=suspension(_,active,_,_,E,_,F,G,_),
E==D,
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',K),
lookup_ht(K,F,I) ->
spawns___3__3__1__13(I,F,G,H,J,B,C,D,A)
;
spawns___3__3__0__13(J,B,C,D,A)
).
spawns___3__3__1__13([],_,_,_,A,C,D,E,B) :-
spawns___3__3__0__13(A,C,D,E,B).
spawns___3__3__1__13([K|L],G,H,A,B,D,E,F,C) :-
( K=suspension(_,active,_,_,I,_,J),
I==G,
M=t(122,K,A,C),
'$novel_production'(K,M),
'$novel_production'(C,M),
D\==G,
F\==J,
\+is_passive(G,H) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',O),
P=[C|O],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',R),
insert_ht(R,k(D,E),C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',S),
insert_ht(S,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',T),
insert_ht(T,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',U),
insert_ht(U,k(D,E,F),C)
;
true
),
spawns(D,E,J),
( C=suspension(_,active,_,_,_,_,_) ->
setarg(2,C,inactive),
spawns___3__3__1__13(L,G,H,A,B,D,E,F,C)
;
true
)
;
spawns___3__3__1__13(L,G,H,A,B,D,E,F,C)
).
spawns___3__3(A,B,C,D) :-
spawns___3__4(A,B,C,D).
spawns___3__4(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',F),
lookup_ht1(F,A,A,E),
!,
spawns___3__4__0__14(E,A,B,C,D).
spawns___3__4__0__14([],B,C,D,A) :-
spawns___3__5(B,C,D,A).
spawns___3__4__0__14([H|J],B,C,D,A) :-
( H=suspension(_,active,_,_,E,_,F,G,_),
F==B,
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',I) ->
spawns___3__4__1__14(I,E,G,H,J,B,C,D,A)
;
spawns___3__4__0__14(J,B,C,D,A)
).
spawns___3__4__1__14([],_,_,_,A,C,D,E,B) :-
spawns___3__4__0__14(A,C,D,E,B).
spawns___3__4__1__14([K|L],G,H,A,B,D,E,F,C) :-
( K=suspension(_,active,_,_,I,J),
M=t(123,C,A,K),
'$novel_production'(C,M),
'$novel_production'(K,M),
\+is_passive(D,H),
may_trigger(G),
\+may_trigger(F) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',O),
P=[C|O],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',R),
insert_ht(R,k(D,E),C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',S),
insert_ht(S,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',T),
insert_ht(T,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',U),
insert_ht(U,k(D,E,F),C)
;
true
),
spawns(I,J,F),
( C=suspension(_,active,_,_,_,_,_) ->
setarg(2,C,inactive),
spawns___3__4__1__14(L,G,H,A,B,D,E,F,C)
;
true
)
;
spawns___3__4__1__14(L,G,H,A,B,D,E,F,C)
).
spawns___3__4(A,B,C,D) :-
spawns___3__5(A,B,C,D).
spawns___3__5(A,B,C,D) :-
arg(2,D,E),
setarg(2,D,active),
( E==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',F),
G=[D|F],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',G),
( F=[H|_] ->
setarg(4,H,G)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',I),
insert_ht(I,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',J),
insert_ht(J,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',K),
insert_ht(K,C,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',L),
insert_ht(L,k(A,B,C),D)
;
true
).
spawns_all(A,B) :-
spawns_all___2__0(A,B,_).
spawns_all___2__0(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
spawns_all___2__0(A,body,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',D),
hash_term(k(A,1612897),E),
lookup_ht1(D,E,k(A,guard),C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!.
spawns_all___2__0(A,guard,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',D),
hash_term(k(A,1640016),E),
lookup_ht1(D,E,k(A,body),C),
!,
spawns_all___2__0__0__4(C,A,guard,B).
spawns_all___2__0__0__4([],B,C,A) :-
spawns_all___2__1(B,C,A).
spawns_all___2__0__0__4([F|G],A,B,C) :-
( F=suspension(_,active,D,E),
D==A,
E=body ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',H),
delete_ht(H,A,F),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',I),
delete_ht(I,k(A,body),F),
spawns_all___2__0__0__4(G,A,B,C)
;
spawns_all___2__0__0__4(G,A,B,C)
).
spawns_all___2__0(A,B,C) :-
spawns_all___2__1(A,B,C).
spawns_all___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',E),
lookup_ht(E,k(A,B),D),
!,
spawns_all___2__1__0__5(D,A,B,C).
spawns_all___2__1__0__5([],B,C,A) :-
spawns_all___2__2(B,C,A).
spawns_all___2__1__0__5([G|H],A,B,C) :-
( G=suspension(_,active,_,_,D,E,F),
D==A,
E==B ->
setarg(2,G,removed),
arg(4,G,I),
( var(I) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',J),
J=[_|K],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',K),
( K=[L|_] ->
setarg(4,L,_)
;
true
)
;
I=[_,_|K],
setarg(2,I,K),
( K=[L|_] ->
setarg(4,L,I)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',M),
delete_ht(M,k(A,B),G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',N),
delete_ht(N,A,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',O),
delete_ht(O,F,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',P),
delete_ht(P,k(A,B,F),G),
spawns_all___2__1__0__5(H,A,B,C)
;
spawns_all___2__1__0__5(H,A,B,C)
).
spawns_all___2__1(A,B,C) :-
spawns_all___2__2(A,B,C).
spawns_all___2__2(A,guard,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',D),
hash_term(k(A,1640016),E),
lookup_ht1(D,E,k(A,body),C),
!,
spawns_all___2__2__0__6(C,A,guard,B).
spawns_all___2__2__0__6([],B,C,A) :-
spawns_all___2__3(B,C,A).
spawns_all___2__2__0__6([G|H],A,B,C) :-
( G=suspension(_,active,_,_,D,E,F),
D==A,
E=body ->
setarg(2,G,removed),
arg(4,G,I),
( var(I) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',J),
J=[_|K],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',K),
( K=[L|_] ->
setarg(4,L,_)
;
true
)
;
I=[_,_|K],
setarg(2,I,K),
( K=[L|_] ->
setarg(4,L,I)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',M),
delete_ht(M,k(A,body),G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',N),
delete_ht(N,A,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',O),
delete_ht(O,F,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',P),
delete_ht(P,k(A,body,F),G),
spawns_all___2__2__0__6(H,A,B,C)
;
spawns_all___2__2__0__6(H,A,B,C)
).
spawns_all___2__2(A,B,C) :-
spawns_all___2__3(A,B,C).
spawns_all___2__3(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',E),
lookup_ht(E,k(A,B),D),
!,
spawns_all___2__3__0__7(D,A,B,C).
spawns_all___2__3__0__7([],B,C,A) :-
spawns_all___2__4(B,C,A).
spawns_all___2__3__0__7([F|G],A,B,C) :-
( F=suspension(_,active,_,_,D,E),
D==A,
E==B ->
setarg(2,F,removed),
arg(4,F,H),
( var(H) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',I),
I=[_|J],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',J),
( J=[K|_] ->
setarg(4,K,_)
;
true
)
;
H=[_,_|J],
setarg(2,H,J),
( J=[K|_] ->
setarg(4,K,H)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',L),
delete_ht(L,A,F),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',M),
delete_ht(M,k(A,B),F),
spawns_all___2__3__0__7(G,A,B,C)
;
spawns_all___2__3__0__7(G,A,B,C)
).
spawns_all___2__3(A,B,C) :-
spawns_all___2__4(A,B,C).
spawns_all___2__4(A,guard,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',D),
hash_term(k(A,1640016),E),
lookup_ht1(D,E,k(A,body),C),
!,
spawns_all___2__4__0__8(C,A,guard,B).
spawns_all___2__4__0__8([],B,C,A) :-
spawns_all___2__5(B,C,A).
spawns_all___2__4__0__8([F|G],A,B,C) :-
( F=suspension(_,active,_,_,D,E),
D==A,
E=body ->
setarg(2,F,removed),
arg(4,F,H),
( var(H) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',I),
I=[_|J],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',J),
( J=[K|_] ->
setarg(4,K,_)
;
true
)
;
H=[_,_|J],
setarg(2,H,J),
( J=[K|_] ->
setarg(4,K,H)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',L),
delete_ht(L,A,F),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',M),
delete_ht(M,k(A,body),F),
spawns_all___2__4__0__8(G,A,B,C)
;
spawns_all___2__4__0__8(G,A,B,C)
).
spawns_all___2__4(A,B,C) :-
spawns_all___2__5(A,B,C).
spawns_all___2__5(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',F),
lookup_ht1(F,A,A,D),
!,
C=suspension(E,not_stored_yet,A,B),
'chr gen_id'(E),
spawns_all___2__5__0__9(D,A,B,C).
spawns_all___2__5__0__9([],B,C,A) :-
spawns_all___2__6(B,C,A).
spawns_all___2__5__0__9([G|I],B,C,A) :-
( G=suspension(_,active,_,_,D,_,E,F,_),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',J),
lookup_ht(J,D,H) ->
spawns_all___2__5__1__9(H,D,F,G,I,B,C,A)
;
spawns_all___2__5__0__9(I,B,C,A)
).
spawns_all___2__5__1__9([],_,_,_,A,C,D,B) :-
spawns_all___2__5__0__9(A,C,D,B).
spawns_all___2__5__1__9([K|L],E,F,A,G,B,C,D) :-
( K=suspension(_,active,_,_,H,I,J),
J==E,
\+is_passive(B,F) ->
setarg(2,K,removed),
arg(4,K,P),
( var(P) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',Q),
Q=[_|R],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',R),
( R=[S|_] ->
setarg(4,S,_)
;
true
)
;
P=[_,_|R],
setarg(2,P,R),
( R=[S|_] ->
setarg(4,S,P)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',T),
delete_ht(T,k(H,I),K),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',U),
delete_ht(U,H,K),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',V),
delete_ht(V,E,K),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',W),
delete_ht(W,k(H,I,E),K),
arg(2,D,M),
setarg(2,D,active),
( M==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',N),
insert_ht(N,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',O),
insert_ht(O,k(B,C),D)
;
true
),
spawns_all(H,I),
( D=suspension(_,active,_,_) ->
setarg(2,D,inactive),
spawns_all___2__5__1__9(L,E,F,A,G,B,C,D)
;
true
)
;
spawns_all___2__5__1__9(L,E,F,A,G,B,C,D)
).
spawns_all___2__5(A,B,C) :-
C=suspension(D,not_stored_yet,A,B),
'chr gen_id'(D),
spawns_all___2__6(A,B,C).
spawns_all___2__6(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',E),
lookup_ht1(E,A,A,D),
!,
spawns_all___2__6__0__10(D,A,B,C).
spawns_all___2__6__0__10([],B,C,A) :-
spawns_all___2__7(B,C,A).
spawns_all___2__6__0__10([G|H],B,C,A) :-
( G=suspension(_,active,_,_,D,_,E,F,_),
E==B,
\+ \+spawns_all_triggers_implies_spawns_all,
\+is_passive(B,F),
may_trigger(D) ->
arg(2,A,I),
setarg(2,A,active),
( I==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',J),
insert_ht(J,B,A),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',K),
insert_ht(K,k(B,C),A)
;
true
),
spawns_all_triggers_implies_spawns_all,
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
spawns_all___2__6__0__10(H,B,C,A)
;
true
)
;
spawns_all___2__6__0__10(H,B,C,A)
).
spawns_all___2__6(A,B,C) :-
spawns_all___2__7(A,B,C).
spawns_all___2__7(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',F),
insert_ht(F,k(A,B),C)
;
true
).
spawns_all_triggers(A,B) :-
spawns_all_triggers___2__0(A,B,_).
spawns_all_triggers___2__0(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_,_),
!.
spawns_all_triggers___2__0(A,body,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',D),
hash_term(k(A,1612897),E),
lookup_ht1(D,E,k(A,guard),C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_,_,_),
!.
spawns_all_triggers___2__0(A,guard,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',D),
hash_term(k(A,1640016),E),
lookup_ht1(D,E,k(A,body),C),
!,
spawns_all_triggers___2__0__0__4(C,A,guard,B).
spawns_all_triggers___2__0__0__4([],B,C,A) :-
spawns_all_triggers___2__1(B,C,A).
spawns_all_triggers___2__0__0__4([F|G],A,B,C) :-
( F=suspension(_,active,_,_,D,E),
D==A,
E=body ->
setarg(2,F,removed),
arg(4,F,H),
( var(H) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',I),
I=[_|J],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',J),
( J=[K|_] ->
setarg(4,K,_)
;
true
)
;
H=[_,_|J],
setarg(2,H,J),
( J=[K|_] ->
setarg(4,K,H)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',L),
delete_ht(L,A,F),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',M),
delete_ht(M,k(A,body),F),
spawns_all_triggers___2__0__0__4(G,A,B,C)
;
spawns_all_triggers___2__0__0__4(G,A,B,C)
).
spawns_all_triggers___2__0(A,B,C) :-
spawns_all_triggers___2__1(A,B,C).
spawns_all_triggers___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',M),
lookup_ht(M,k(A,B),E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_),
!,
( var(C) ->
true
;
arg(2,C,L),
setarg(2,C,removed),
( L==not_stored_yet ->
true
;
arg(4,C,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',H),
( H=[I|_] ->
setarg(4,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(4,I,F)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',J),
delete_ht(J,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',K),
delete_ht(K,k(A,B),C)
)
).
spawns_all_triggers___2__1(A,body,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',L),
hash_term(k(A,1612897),M),
lookup_ht1(L,M,k(A,guard),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!,
( var(B) ->
true
;
arg(2,B,K),
setarg(2,B,removed),
( K==not_stored_yet ->
true
;
arg(4,B,E),
( var(E) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',F),
F=[_|G],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',G),
( G=[H|_] ->
setarg(4,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(4,H,E)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',I),
delete_ht(I,A,B),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',J),
delete_ht(J,k(A,body),B)
)
).
spawns_all_triggers___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',E),
lookup_ht(E,k(A,B),D),
!,
spawns_all_triggers___2__1__0__7(D,A,B,C).
spawns_all_triggers___2__1__0__7([],B,C,A) :-
spawns_all_triggers___2__2(B,C,A).
spawns_all_triggers___2__1__0__7([G|H],A,B,C) :-
( G=suspension(_,active,_,_,D,E,F),
D==A,
E==B,
may_trigger(F) ->
setarg(2,G,removed),
arg(4,G,I),
( var(I) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',J),
J=[_|K],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',K),
( K=[L|_] ->
setarg(4,L,_)
;
true
)
;
I=[_,_|K],
setarg(2,I,K),
( K=[L|_] ->
setarg(4,L,I)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',M),
delete_ht(M,k(A,B),G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',N),
delete_ht(N,A,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',O),
delete_ht(O,F,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',P),
delete_ht(P,k(A,B,F),G),
spawns_all_triggers___2__1__0__7(H,A,B,C)
;
spawns_all_triggers___2__1__0__7(H,A,B,C)
).
spawns_all_triggers___2__1(A,B,C) :-
spawns_all_triggers___2__2(A,B,C).
spawns_all_triggers___2__2(A,guard,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',D),
hash_term(k(A,1640016),E),
lookup_ht1(D,E,k(A,body),C),
!,
spawns_all_triggers___2__2__0__8(C,A,guard,B).
spawns_all_triggers___2__2__0__8([],B,C,A) :-
spawns_all_triggers___2__3(B,C,A).
spawns_all_triggers___2__2__0__8([G|H],A,B,C) :-
( G=suspension(_,active,_,_,D,E,F),
D==A,
E=body,
may_trigger(F) ->
setarg(2,G,removed),
arg(4,G,I),
( var(I) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',J),
J=[_|K],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',K),
( K=[L|_] ->
setarg(4,L,_)
;
true
)
;
I=[_,_|K],
setarg(2,I,K),
( K=[L|_] ->
setarg(4,L,I)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',M),
delete_ht(M,k(A,body),G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',N),
delete_ht(N,A,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',O),
delete_ht(O,F,G),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',P),
delete_ht(P,k(A,body,F),G),
spawns_all_triggers___2__2__0__8(H,A,B,C)
;
spawns_all_triggers___2__2__0__8(H,A,B,C)
).
spawns_all_triggers___2__2(A,B,C) :-
spawns_all_triggers___2__3(A,B,C).
spawns_all_triggers___2__3(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',E),
'chr sbag_member'(D,E),
D=suspension(_,active,_),
!,
( var(C) ->
true
;
arg(2,C,L),
setarg(2,C,removed),
( L==not_stored_yet ->
true
;
arg(4,C,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',H),
( H=[I|_] ->
setarg(4,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(4,I,F)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',J),
delete_ht(J,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',K),
delete_ht(K,k(A,B),C)
)
),
spawns_all(A,B).
spawns_all_triggers___2__3(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',F),
lookup_ht1(F,A,A,D),
!,
C=suspension(E,not_stored_yet,t,_,A,B),
'chr gen_id'(E),
spawns_all_triggers___2__3__0__10(D,A,B,C).
spawns_all_triggers___2__3__0__10([],B,C,A) :-
spawns_all_triggers___2__4(B,C,A).
spawns_all_triggers___2__3__0__10([G|I],B,C,A) :-
( G=suspension(_,active,_,_,D,_,E,F,_),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',J),
lookup_ht(J,D,H) ->
spawns_all_triggers___2__3__1__10(H,D,F,G,I,B,C,A)
;
spawns_all_triggers___2__3__0__10(I,B,C,A)
).
spawns_all_triggers___2__3__1__10([],_,_,_,A,C,D,B) :-
spawns_all_triggers___2__3__0__10(A,C,D,B).
spawns_all_triggers___2__3__1__10([K|L],E,F,A,G,B,C,D) :-
( K=suspension(_,active,_,_,H,I,J),
J==E,
may_trigger(E),
\+is_passive(B,F) ->
setarg(2,K,removed),
arg(4,K,S),
( var(S) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',T),
T=[_|U],
b_setval('$chr_store_global_ground_chr_translate____spawns___3',U),
( U=[V|_] ->
setarg(4,V,_)
;
true
)
;
S=[_,_|U],
setarg(2,S,U),
( U=[V|_] ->
setarg(4,V,S)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',W),
delete_ht(W,k(H,I),K),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',X),
delete_ht(X,H,K),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',Y),
delete_ht(Y,E,K),
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',Z),
delete_ht(Z,k(H,I,E),K),
arg(2,D,M),
setarg(2,D,active),
( M==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',N),
O=[D|N],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',O),
( N=[P|_] ->
setarg(4,P,O)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',Q),
insert_ht(Q,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',R),
insert_ht(R,k(B,C),D)
;
true
),
spawns_all_triggers(H,I),
( D=suspension(_,active,_,_,_,_) ->
setarg(2,D,inactive),
spawns_all_triggers___2__3__1__10(L,E,F,A,G,B,C,D)
;
true
)
;
spawns_all_triggers___2__3__1__10(L,E,F,A,G,B,C,D)
).
spawns_all_triggers___2__3(A,B,C) :-
C=suspension(D,not_stored_yet,t,_,A,B),
'chr gen_id'(D),
spawns_all_triggers___2__4(A,B,C).
spawns_all_triggers___2__4(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',E),
lookup_ht1(E,A,A,D),
!,
spawns_all_triggers___2__4__0__11(D,A,B,C).
spawns_all_triggers___2__4__0__11([],B,C,A) :-
spawns_all_triggers___2__5(B,C,A).
spawns_all_triggers___2__4__0__11([G|I],B,C,A) :-
( G=suspension(_,active,_,_,D,_,E,F,_),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',J),
lookup_ht(J,D,H) ->
spawns_all_triggers___2__4__1__11(H,D,F,G,I,B,C,A)
;
spawns_all_triggers___2__4__0__11(I,B,C,A)
).
spawns_all_triggers___2__4__1__11([],_,_,_,A,C,D,B) :-
spawns_all_triggers___2__4__0__11(A,C,D,B).
spawns_all_triggers___2__4__1__11([K|L],F,G,A,B,D,E,C) :-
( K=suspension(_,active,_,_,H,I,J),
J==F,
M=t(121,C,A,K),
'$novel_production'(C,M),
'$novel_production'(K,M),
\+may_trigger(F),
\+is_passive(D,G) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',O),
P=[C|O],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',R),
insert_ht(R,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',S),
insert_ht(S,k(D,E),C)
;
true
),
spawns_all_triggers(H,I),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
spawns_all_triggers___2__4__1__11(L,F,G,A,B,D,E,C)
;
true
)
;
spawns_all_triggers___2__4__1__11(L,F,G,A,B,D,E,C)
).
spawns_all_triggers___2__4(A,B,C) :-
spawns_all_triggers___2__5(A,B,C).
spawns_all_triggers___2__5(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns___3',D),
!,
spawns_all_triggers___2__5__0__12(D,A,B,C).
spawns_all_triggers___2__5__0__12([],B,C,A) :-
spawns_all_triggers___2__6(B,C,A).
spawns_all_triggers___2__5__0__12([F|H],B,C,A) :-
( F=suspension(_,active,_,_,D,_,E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',I),
lookup_ht1(I,D,D,G) ->
spawns_all_triggers___2__5__1__12(G,D,E,F,H,B,C,A)
;
spawns_all_triggers___2__5__0__12(H,B,C,A)
).
spawns_all_triggers___2__5__1__12([],_,_,_,A,C,D,B) :-
spawns_all_triggers___2__5__0__12(A,C,D,B).
spawns_all_triggers___2__5__1__12([K|L],F,G,A,B,D,E,C) :-
( K=suspension(_,active,_,_,H,_,I,J,_),
I==F,
M=t(123,A,K,C),
'$novel_production'(A,M),
'$novel_production'(C,M),
\+is_passive(F,J),
may_trigger(H),
\+may_trigger(G) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',O),
P=[C|O],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',R),
insert_ht(R,D,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',S),
insert_ht(S,k(D,E),C)
;
true
),
spawns(D,E,G),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
spawns_all_triggers___2__5__1__12(L,F,G,A,B,D,E,C)
;
true
)
;
spawns_all_triggers___2__5__1__12(L,F,G,A,B,D,E,C)
).
spawns_all_triggers___2__5(A,B,C) :-
spawns_all_triggers___2__6(A,B,C).
spawns_all_triggers___2__6(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',F),
( E=[G|_] ->
setarg(4,G,F)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',H),
insert_ht(H,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',I),
insert_ht(I,k(A,B),C)
;
true
).
spawns_all_triggers_implies_spawns_all :-
spawns_all_triggers_implies_spawns_all___0__0(_).
spawns_all_triggers_implies_spawns_all___0__0(_) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',B),
'chr sbag_member'(A,B),
A=suspension(_,active,_),
!,
setarg(2,A,removed),
arg(3,A,C),
( var(C) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',D),
D=[_|E],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',E),
( E=[F|_] ->
setarg(3,F,_)
;
true
)
;
C=[_,_|E],
setarg(2,C,E),
( E=[F|_] ->
setarg(3,F,C)
;
true
)
),
fail.
spawns_all_triggers_implies_spawns_all___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',B),
!,
A=suspension(C,not_stored_yet,_),
'chr gen_id'(C),
spawns_all_triggers_implies_spawns_all___0__0__0__3(B,A).
spawns_all_triggers_implies_spawns_all___0__0__0__3([],A) :-
spawns_all_triggers_implies_spawns_all___0__1(A).
spawns_all_triggers_implies_spawns_all___0__0__0__3([D|E],A) :-
( D=suspension(_,active,_,_,B,C) ->
setarg(2,D,removed),
arg(4,D,J),
( var(J) ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',K),
K=[_|L],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',L),
( L=[M|_] ->
setarg(4,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(4,M,J)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',N),
delete_ht(N,B,D),
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',O),
delete_ht(O,k(B,C),D),
arg(2,A,F),
setarg(2,A,active),
( F==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',G),
H=[A|G],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',H),
( G=[I|_] ->
setarg(3,I,H)
;
true
)
;
true
),
spawns_all(B,C),
( A=suspension(_,active,_) ->
setarg(2,A,inactive),
spawns_all_triggers_implies_spawns_all___0__0__0__3(E,A)
;
true
)
;
spawns_all_triggers_implies_spawns_all___0__0__0__3(E,A)
).
spawns_all_triggers_implies_spawns_all___0__0(A) :-
A=suspension(B,not_stored_yet,_),
'chr gen_id'(B),
spawns_all_triggers_implies_spawns_all___0__1(A).
spawns_all_triggers_implies_spawns_all___0__1(A) :-
arg(2,A,B),
setarg(2,A,active),
( B==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',C),
D=[A|C],
b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',D),
( C=[E|_] ->
setarg(3,E,D)
;
true
)
;
true
).
all_spawned(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',G),
(
hash_term(k(A,1612897),H),
lookup_ht1(G,H,k(A,guard),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!
;
lookup_ht(G,k(A,B),F),
'chr sbag_member'(E,F),
E=suspension(_,active,_,_),
!
).
all_spawned(_,_) :-
fail.
is_observed(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,_,_,E,_,_),
!,
do_is_observed(A,E,C).
is_observed(_,_,_) :-
fail.
do_is_observed(A,B,C) :-
var(C),
!,
do_is_observed(A,B).
do_is_observed(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',S),
lookup_ht(S,A,F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,_,_,E,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',R),
lookup_ht1(R,E,E,J),
'chr sbag_member'(G,J),
G=suspension(_,active,_,_,H,_,_,I,_),
G\==D,
ground(C),
(
(
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',U),
lookup_ht(U,k(B,C),L),
'chr sbag_member'(K,L),
K=suspension(_,active,_,_),
\+is_passive(E,I),
!
;
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',T),
lookup_ht(T,k(B,C,H),N),
'chr sbag_member'(M,N),
M=suspension(_,active,_,_,_,_,_),
\+is_passive(E,I),
!
)
;
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',Q),
lookup_ht(Q,k(B,C),P),
'chr sbag_member'(O,P),
O=suspension(_,active,_,_,_,_),
\+is_passive(E,I),
may_trigger(H),
!
).
do_is_observed(_,_,_) :-
chr_pp_flag(observation_analysis,off).
do_is_observed(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',S),
lookup_ht(S,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,_,D,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',R),
lookup_ht1(R,D,D,I),
'chr sbag_member'(F,I),
F=suspension(_,active,_,_,G,_,_,H,_),
F\==C,
(
(
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',U),
lookup_ht(U,B,K),
'chr sbag_member'(J,K),
J=suspension(_,active,_,_),
\+is_passive(D,H),
!
;
nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',T),
lookup_ht(T,B,N),
'chr sbag_member'(L,N),
L=suspension(_,active,_,_,_,_,M),
M=G,
\+is_passive(D,H),
!
)
;
nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',Q),
lookup_ht(Q,B,P),
'chr sbag_member'(O,P),
O=suspension(_,active,_,_,_,_),
\+is_passive(D,H),
may_trigger(G),
!
).
do_is_observed(_,_) :-
chr_pp_flag(observation_analysis,off).
generate_indexed_variables_body(D/E,A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',N),
lookup_ht(N,D/E,H),
'chr sbag_member'(F,H),
F=suspension(_,active,_,_,_,G),
!,
get_indexing_spec(D/E,I),
( chr_pp_flag(term_indexing,on) ->
spectermvars(I,A,D,E,B,C)
;
get_constraint_type_det(D/E,J),
create_indexed_variables_body(A,G,J,C,1,D/E,K,L),
( K==empty ->
B=true,
C=[]
;
( L==0 ->
( A=[M] ->
true
;
M=..[term|A]
),
B=term_variables(M,C)
)
;
K=B
)
).
generate_indexed_variables_body(A,_,_,_) :-
chr_error(internal,'generate_indexed_variables_body: missing mode info for ~w.
',[A]).
empty_named_history_initialisations(A,B) :-
C=suspension(D,active,_,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
).
generate_empty_named_history_initialisation(A) :-
generate_empty_named_history_initialisation___1__0(A,_).
generate_empty_named_history_initialisation___1__0(A,B) :-
( 'chr newvia_1'(A,F) ->
get_attr(F,chr_translate,G),
G=v(_,E,_,_,_,_,_,_,_,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',E)
),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
D==A,
!,
( var(B) ->
true
;
B=suspension(_,M,_,_,N),
setarg(2,B,removed),
( M==not_stored_yet ->
H=[]
;
term_variables(N,H),
arg(4,B,I),
( var(I) ->
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',J),
J=[_|K],
b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',K),
( K=[L|_] ->
setarg(4,L,_)
;
true
)
;
I=[_,_|K],
setarg(2,I,K),
( K=[L|_] ->
setarg(4,L,I)
;
true
)
),
detach_generate_empty_named_history_initialisation___1(H,B)
)
).
generate_empty_named_history_initialisation___1__0(A,B) :-
nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',C),
!,
( var(B) ->
B=suspension(D,not_stored_yet,0,_,A),
'chr gen_id'(D)
;
true
),
generate_empty_named_history_initialisation___1__0__0__3(C,A,B).
generate_empty_named_history_initialisation___1__0__0__3([],B,A) :-
generate_empty_named_history_initialisation___1__1(B,A).
generate_empty_named_history_initialisation___1__0__0__3([E|F],A,B) :-
( E=suspension(_,active,_,C,D) ->
setarg(2,E,removed),
arg(3,E,Q),
( var(Q) ->
nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',R),
R=[_|S],
b_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',S),
( S=[T|_] ->
setarg(3,T,_)
;
true
)
;
Q=[_,_|S],
setarg(2,Q,S),
( S=[T|_] ->
setarg(3,T,Q)
;
true
)
),
arg(2,B,L),
setarg(2,B,active),
arg(3,B,K),
J is K+1,
setarg(3,B,J),
( L==not_stored_yet ->
B=suspension(_,_,_,_,M),
term_variables(M,I),
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',N),
O=[B|N],
b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',O),
( N=[P|_] ->
setarg(4,P,O)
;
true
),
attach_generate_empty_named_history_initialisation___1(I,B)
;
true
),
empty_named_history_global_variable(A,G),
C=[(:-nb_setval(G,0))|H],
empty_named_history_initialisations(H,D),
( B=suspension(_,active,J,_,_) ->
setarg(2,B,inactive),
generate_empty_named_history_initialisation___1__0__0__3(F,A,B)
;
true
)
;
generate_empty_named_history_initialisation___1__0__0__3(F,A,B)
).
generate_empty_named_history_initialisation___1__0(A,B) :-
( var(B) ->
B=suspension(C,not_stored_yet,0,_,A),
'chr gen_id'(C)
;
true
),
generate_empty_named_history_initialisation___1__1(A,B).
generate_empty_named_history_initialisation___1__1(_,A) :-
arg(2,A,E),
setarg(2,A,active),
arg(3,A,D),
C is D+1,
setarg(3,A,C),
( E==not_stored_yet ->
A=suspension(_,_,_,_,F),
term_variables(F,B),
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',G),
H=[A|G],
b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',H),
( G=[I|_] ->
setarg(4,I,H)
;
true
),
attach_generate_empty_named_history_initialisation___1(B,A)
;
true
).
find_empty_named_histories :-
find_empty_named_histories___0__0(_).
find_empty_named_histories___0__0(A) :-
nb_getval('$chr_store_constants_chr_translate____history___3___[3]___[]',B),
!,
A=suspension(C,not_stored_yet,t,_),
'chr gen_id'(C),
find_empty_named_histories___0__0__0__1(B,A).
find_empty_named_histories___0__0__0__1([],A) :-
find_empty_named_histories___0__1(A).
find_empty_named_histories___0__0__0__1([D|E],A) :-
( D=suspension(_,active,_,_,B,C),
C=[],
F=t(140,A,D),
'$novel_production'(A,F),
'$novel_production'(D,F) ->
'$extend_history'(A,F),
arg(2,A,G),
setarg(2,A,active),
( G==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',H),
I=[A|H],
b_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',I),
( H=[J|_] ->
setarg(4,J,I)
;
true
)
;
true
),
generate_empty_named_history_initialisation(B),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
find_empty_named_histories___0__0__0__1(E,A)
;
true
)
;
find_empty_named_histories___0__0__0__1(E,A)
).
find_empty_named_histories___0__0(A) :-
A=suspension(B,not_stored_yet,t,_),
'chr gen_id'(B),
find_empty_named_histories___0__1(A).
find_empty_named_histories___0__1(A) :-
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',B),
!,
find_empty_named_histories___0__1__0__2(B,A).
find_empty_named_histories___0__1__0__2([],A) :-
find_empty_named_histories___0__2(A).
find_empty_named_histories___0__1__0__2([B|C],A) :-
( B=suspension(_,active,_,_,_) ->
B=suspension(_,_,_,_,I),
setarg(2,B,removed),
term_variables(I,D),
arg(4,B,E),
( var(E) ->
nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',F),
F=[_|G],
b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',G),
( G=[H|_] ->
setarg(4,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(4,H,E)
;
true
)
),
detach_generate_empty_named_history_initialisation___1(D,B),
find_empty_named_histories___0__1__0__2(C,A)
;
find_empty_named_histories___0__1__0__2(C,A)
).
find_empty_named_histories___0__1(A) :-
find_empty_named_histories___0__2(A).
find_empty_named_histories___0__2(A) :-
nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',E),
'chr sbag_member'(B,E),
B=suspension(_,active,_,C,D),
!,
setarg(2,B,removed),
arg(3,B,K),
( var(K) ->
nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',L),
L=[_|M],
b_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
( var(A) ->
true
;
arg(2,A,J),
setarg(2,A,removed),
( J==not_stored_yet ->
true
;
arg(4,A,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',H),
( H=[I|_] ->
setarg(4,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(4,I,F)
;
true
)
)
)
),
C=D.
find_empty_named_histories___0__2(A) :-
( var(A) ->
true
;
arg(2,A,F),
setarg(2,A,removed),
( F==not_stored_yet ->
true
;
arg(4,A,B),
( var(B) ->
nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',C),
C=[_|D],
b_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',D),
( D=[E|_] ->
setarg(4,E,_)
;
true
)
;
B=[_,_|D],
setarg(2,B,D),
( D=[E|_] ->
setarg(4,E,B)
;
true
)
)
)
),
chr_error(internal,'find_empty_named_histories was not removed',[]).
module_initializer(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____module_initializer___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
module_initializers(A) :-
nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____module_initializer___1',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
A=(C,E),
module_initializers(E).
module_initializers(true).
actual_atomic_multi_hash_keys(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',Q),
lookup_ht(Q,A,F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,E),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',P),
lookup_ht(P,A,H),
'chr sbag_member'(G,H),
G=suspension(_,active,_),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',O),
delete_ht(O,A,D),
delete(E,multi_hash([B]),I),
B=[J],
( get_constraint_arg_type(A,J,K),
enumerated_atomic_type(K,L) ->
M=L,
N=complete
;
M=C,
N=incomplete
),
actual_store_types(A,[atomic_constants(B,M,N)|I]).
actual_atomic_multi_hash_keys(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',K),
lookup_ht(K,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',I),
delete_ht(I,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',J),
delete_ht(J,A,D),
append(C,E,G),
sort(G,H),
actual_atomic_multi_hash_keys(A,B,H).
actual_atomic_multi_hash_keys(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',K),
lookup_ht(K,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',I),
delete_ht(I,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',J),
delete_ht(J,A,D),
append(E,C,G),
sort(G,H),
actual_ground_multi_hash_keys(A,B,H).
actual_atomic_multi_hash_keys(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
actual_atomic_multi_hash_keys(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',F),
insert_ht(F,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',G),
insert_ht(G,A,D).
actual_ground_multi_hash_keys(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',Q),
lookup_ht(Q,A,F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,E),
nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',P),
lookup_ht(P,A,H),
'chr sbag_member'(G,H),
G=suspension(_,active,_),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',O),
delete_ht(O,A,D),
( B=[I],
get_constraint_arg_type(A,I,J),
( is_chr_constants_type(J,K,_) ->
get_chr_constants(K,L)
;
( J=chr_enum(L) ->
true
)
) ->
M=complete
;
L=C,
M=incomplete
),
delete(E,multi_hash([B]),N),
actual_store_types(A,[ground_constants(B,L,M)|N]).
actual_ground_multi_hash_keys(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',K),
lookup_ht(K,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',I),
delete_ht(I,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',J),
delete_ht(J,A,D),
append(C,E,G),
sort(G,H),
actual_ground_multi_hash_keys(A,B,H).
actual_ground_multi_hash_keys(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',K),
lookup_ht(K,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',I),
delete_ht(I,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',J),
delete_ht(J,A,D),
append(C,E,G),
sort(G,H),
actual_ground_multi_hash_keys(A,B,H).
actual_ground_multi_hash_keys(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
actual_ground_multi_hash_keys(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',F),
insert_ht(F,k(A,B),D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',G),
insert_ht(G,A,D).
actual_non_ground_multi_hash_key(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
actual_non_ground_multi_hash_key(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',D),
lookup_ht(D,k(A,B),C),
!,
actual_non_ground_multi_hash_key___2__0__0__3(C,A,B).
actual_non_ground_multi_hash_key___2__0__0__3([],A,B) :-
actual_non_ground_multi_hash_key___2__1(A,B).
actual_non_ground_multi_hash_key___2__0__0__3([E|F],A,B) :-
( E=suspension(_,active,C,D,_),
C==A,
D==B ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',G),
delete_ht(G,k(A,B),E),
nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',H),
delete_ht(H,A,E),
actual_non_ground_multi_hash_key___2__0__0__3(F,A,B)
;
actual_non_ground_multi_hash_key___2__0__0__3(F,A,B)
).
actual_non_ground_multi_hash_key(A,B) :-
actual_non_ground_multi_hash_key___2__1(A,B).
actual_non_ground_multi_hash_key___2__1(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',D),
lookup_ht(D,k(A,B),C),
!,
actual_non_ground_multi_hash_key___2__1__0__4(C,A,B).
actual_non_ground_multi_hash_key___2__1__0__4([],A,B) :-
actual_non_ground_multi_hash_key___2__2(A,B).
actual_non_ground_multi_hash_key___2__1__0__4([E|F],A,B) :-
( E=suspension(_,active,C,D,_),
C==A,
D==B ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',G),
delete_ht(G,k(A,B),E),
nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',H),
delete_ht(H,A,E),
actual_non_ground_multi_hash_key___2__1__0__4(F,A,B)
;
actual_non_ground_multi_hash_key___2__1__0__4(F,A,B)
).
actual_non_ground_multi_hash_key___2__1(A,B) :-
actual_non_ground_multi_hash_key___2__2(A,B).
actual_non_ground_multi_hash_key___2__2(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',E),
insert_ht(E,k(A,B),C).
prolog_global_variable(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!.
prolog_global_variable(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',G),
insert_ht(G,A,B).
prolog_global_variables(A) :-
nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',J),
delete_ht(J,C,B),
A=[C|E],
prolog_global_variables(E).
prolog_global_variables([]).
background_info(A) :-
nb_getval('$chr_store_global_ground_chr_translate____background_info___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____background_info___1',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____background_info___1',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
append(A,C,E),
background_info(E).
background_info(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____background_info___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____background_info___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
background_info(A,B) :-
background_info___2__0(A,B,_).
background_info___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',D),
!,
( var(C) ->
C=suspension(E,not_stored_yet,t,0,_,A,B),
'chr gen_id'(E)
;
true
),
background_info___2__0__0__1(D,A,B,C).
background_info___2__0__0__1([],B,C,A) :-
background_info___2__1(B,C,A).
background_info___2__0__0__1([E|F],B,C,A) :-
( E=suspension(_,active,_,_,_,D,_),
K=t(160,A,E),
'$novel_production'(A,K),
'$novel_production'(E,K),
copy_term_nat(B,G),
subsumes_chk(G,D) ->
'$extend_history'(A,K),
arg(2,A,M),
setarg(2,A,active),
arg(4,A,L),
J is L+1,
setarg(4,A,J),
( M==not_stored_yet ->
A=suspension(_,_,_,_,_,N,_),
term_variables(N,I),
nb_getval('$chr_store_global_list_chr_translate____background_info___2',O),
P=[A|O],
b_setval('$chr_store_global_list_chr_translate____background_info___2',P),
( O=[Q|_] ->
setarg(5,Q,P)
;
true
),
attach_background_info___2(I,A)
;
true
),
copy_term_nat(B-C,D-H),
get_bg_info_answer([H]),
( A=suspension(_,active,_,J,_,_,_) ->
setarg(2,A,inactive),
background_info___2__0__0__1(F,B,C,A)
;
true
)
;
background_info___2__0__0__1(F,B,C,A)
).
background_info___2__0(A,B,C) :-
( var(C) ->
C=suspension(D,not_stored_yet,t,0,_,A,B),
'chr gen_id'(D)
;
true
),
background_info___2__1(A,B,C).
background_info___2__1(_,_,A) :-
arg(2,A,E),
setarg(2,A,active),
arg(4,A,D),
C is D+1,
setarg(4,A,C),
( E==not_stored_yet ->
A=suspension(_,_,_,_,_,F,_),
term_variables(F,B),
nb_getval('$chr_store_global_list_chr_translate____background_info___2',G),
H=[A|G],
b_setval('$chr_store_global_list_chr_translate____background_info___2',H),
( G=[I|_] ->
setarg(5,I,H)
;
true
),
attach_background_info___2(B,A)
;
true
).
get_bg_info(A) :-
nb_getval('$chr_store_global_ground_chr_translate____background_info___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
A=C.
get_bg_info([]).
get_bg_info(A,B) :-
get_bg_info___2__0(A,B,_).
get_bg_info___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____background_info___2',D),
!,
( var(C) ->
C=suspension(E,not_stored_yet,t,0,_,A,B),
'chr gen_id'(E)
;
true
),
get_bg_info___2__0__0__1(D,A,B,C).
get_bg_info___2__0__0__1([],B,C,A) :-
get_bg_info___2__1(B,C,A).
get_bg_info___2__0__0__1([F|G],B,C,A) :-
( F=suspension(_,active,_,_,_,D,E),
L=t(160,F,A),
'$novel_production'(F,L),
'$novel_production'(A,L),
copy_term_nat(D,H),
subsumes_chk(H,B) ->
'$extend_history'(A,L),
arg(2,A,N),
setarg(2,A,active),
arg(4,A,M),
K is M+1,
setarg(4,A,K),
( N==not_stored_yet ->
A=suspension(_,_,_,_,_,O,_),
term_variables(O,J),
nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',P),
Q=[A|P],
b_setval('$chr_store_global_list_chr_translate____get_bg_info___2',Q),
( P=[R|_] ->
setarg(5,R,Q)
;
true
),
attach_get_bg_info___2(J,A)
;
true
),
copy_term_nat(D-E,B-I),
get_bg_info_answer([I]),
( A=suspension(_,active,_,K,_,_,_) ->
setarg(2,A,inactive),
get_bg_info___2__0__0__1(G,B,C,A)
;
true
)
;
get_bg_info___2__0__0__1(G,B,C,A)
).
get_bg_info___2__0(A,B,C) :-
( var(C) ->
C=suspension(D,not_stored_yet,t,0,_,A,B),
'chr gen_id'(D)
;
true
),
get_bg_info___2__1(A,B,C).
get_bg_info___2__1(_,A,B) :-
nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
setarg(2,C,removed),
arg(3,C,M),
( var(M) ->
nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',N),
N=[_|O],
b_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',O),
( O=[P|_] ->
setarg(3,P,_)
;
true
)
;
M=[_,_|O],
setarg(2,M,O),
( O=[P|_] ->
setarg(3,P,M)
;
true
)
),
( var(B) ->
true
;
B=suspension(_,K,_,_,_,L,_),
setarg(2,B,removed),
( K==not_stored_yet ->
F=[]
;
term_variables(L,F),
arg(5,B,G),
( var(G) ->
nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',H),
H=[_|I],
b_setval('$chr_store_global_list_chr_translate____get_bg_info___2',I),
( I=[J|_] ->
setarg(5,J,_)
;
true
)
;
G=[_,_|I],
setarg(2,G,I),
( I=[J|_] ->
setarg(5,J,G)
;
true
)
),
detach_get_bg_info___2(F,B)
)
),
A=D.
get_bg_info___2__1(_,A,B) :-
( var(B) ->
true
;
B=suspension(_,H,_,_,_,I,_),
setarg(2,B,removed),
( H==not_stored_yet ->
C=[]
;
term_variables(I,C),
arg(5,B,D),
( var(D) ->
nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',E),
E=[_|F],
b_setval('$chr_store_global_list_chr_translate____get_bg_info___2',F),
( F=[G|_] ->
setarg(5,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(5,G,D)
;
true
)
),
detach_get_bg_info___2(C,B)
)
),
A=[].
get_bg_info_answer(A) :-
nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
append(A,C,E),
get_bg_info_answer(E).
get_bg_info_answer(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
prev_guard_list(A,B,C,D,E,F,G,H) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',B1),
lookup_ht1(B1,B,B,K),
'chr sbag_member'(I,K),
I=suspension(_,active,_,_,_,J),
J=pragma(rule(L,M,N,_),_,_,_,_),
L\==[],
make_head_matchings_explicit(B,O,P),
setof(Q,chr_translate:head_subset(O,D,Q),R),
!,
append(L,M,S),
compute_derived_info(R,P,O,S,N,G,D,H,T,U),
append(F,T,V),
normalize_conj_list(V,W),
append(U,H,X),
normalize_conj_list(X,Y),
next_prev_rule(C,Z,A1),
prev_guard_list(A,Z,A1,D,E,W,G,Y).
prev_guard_list(A,B,C,D,E,F,G,H) :-
( B>0 ->
next_prev_rule(C,I,J),
prev_guard_list(A,I,J,D,E,F,G,H)
;
prev_guard_list(A,D,E,F,G,H)
).
prev_guard_list(A,B,C,D,E,F) :-
prev_guard_list___6__0(A,B,C,D,E,F,_).
prev_guard_list___6__0(A,B,C,D,E,F,_) :-
F\==[],
!,
head_types_modes_condition(F,B,G),
conj2list(G,H),
term_variables(B,I),
append([chr_pp_headvariables(I)|H],D,J),
normalize_conj_list(J,K),
append(B,K,L),
add_background_info([C|L],M),
append(K,M,N),
normalize_conj_list(N,O),
prev_guard_list(A,B,C,O,E,[]).
prev_guard_list___6__0(A,B,C,D,E,F,G) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',W),
lookup_ht1(W,A,A,J),
(
'chr sbag_member'(H,J),
H=suspension(_,active,_,_,_,I),
I=pragma(rule(N,O,C,P),K,L,M,A),
C\==true,
append(E,D,Q),
( conj2list(C,R),
append(Q,R,S),
guard_entailment:entails_guard(S,fail) ->
T=fail
;
simplify_guard(C,P,Q,T,U)
),
C\==T,
!,
setarg(2,H,removed),
arg(4,H,X),
( var(X) ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',Y),
Y=[_|Z],
b_setval('$chr_store_global_ground_chr_translate____rule___2',Z),
( Z=[A1|_] ->
setarg(4,A1,_)
;
true
)
;
X=[_,_|Z],
setarg(2,X,Z),
( Z=[A1|_] ->
setarg(4,A1,X)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',B1),
delete_ht(B1,A,H),
rule(A,pragma(rule(N,O,T,U),K,L,M,A)),
prev_guard_list(A,B,T,D,E,[])
;
!,
G=suspension(V,not_stored_yet,t,_,A,B,C,D,E,F),
'chr gen_id'(V),
prev_guard_list___6__0__0__3(J,A,B,C,D,E,F,G)
).
prev_guard_list___6__0__0__3([],B,C,D,E,F,G,A) :-
prev_guard_list___6__1(B,C,D,E,F,G,A).
prev_guard_list___6__0__0__3([J|K],B,C,D,E,F,G,A) :-
( J=suspension(_,active,_,_,H,I),
H==B,
O=t(174,A,J),
'$novel_production'(A,O),
'$novel_production'(J,O),
chr_pp_flag(check_impossible_rules,on),
I=pragma(rule(_,_,D,_),_,_,_,B),
conj2list(D,L),
append(F,E,M),
append(M,L,N),
guard_entailment:entails_guard(N,fail) ->
'$extend_history'(A,O),
arg(2,A,P),
setarg(2,A,active),
( P==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',Q),
R=[A|Q],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',R),
( Q=[S|_] ->
setarg(4,S,R)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',T),
insert_ht(T,B,A)
;
true
),
chr_warning(weird_program,'Heads will never match or guard will always fail in ~@.
This rule will never fire!
',[format_rule(I)]),
set_all_passive(B),
( A=suspension(_,active,_,_,_,_,_,_,_,_) ->
setarg(2,A,inactive),
prev_guard_list___6__0__0__3(K,B,C,D,E,F,G,A)
;
true
)
;
prev_guard_list___6__0__0__3(K,B,C,D,E,F,G,A)
).
prev_guard_list___6__0(A,B,C,D,E,F,G) :-
G=suspension(H,not_stored_yet,t,_,A,B,C,D,E,F),
'chr gen_id'(H),
prev_guard_list___6__1(A,B,C,D,E,F,G).
prev_guard_list___6__1(A,B,C,D,E,F,G) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',I),
lookup_ht1(I,A,A,H),
!,
prev_guard_list___6__1__0__4(H,A,B,C,D,E,F,G).
prev_guard_list___6__1__0__4([],B,C,D,E,F,G,A) :-
prev_guard_list___6__2(B,C,D,E,F,G,A).
prev_guard_list___6__1__0__4([J|K],A,B,C,D,E,F,G) :-
( J=suspension(_,active,_,_,H,I),
H==A,
I=pragma(rule(O,P,C,Q),L,M,N,A),
simplify_heads(E,D,C,Q,R,S),
R\==[],
extract_arguments(O,T),
extract_arguments(P,U),
extract_arguments(B,V),
replace_some_heads(T,U,V,R,W,X,C,Q,Y),
substitute_arguments(O,W,Z),
substitute_arguments(P,X,A1),
append(S,Y,B1),
list2conj(B1,C1),
D1=pragma(rule(Z,A1,C,(C1,Q)),L,M,N,A),
(
O\==Z
;
P\==A1
) ->
setarg(2,J,removed),
arg(4,J,J1),
( var(J1) ->
nb_getval('$chr_store_global_ground_chr_translate____rule___2',K1),
K1=[_|L1],
b_setval('$chr_store_global_ground_chr_translate____rule___2',L1),
( L1=[M1|_] ->
setarg(4,M1,_)
;
true
)
;
J1=[_,_|L1],
setarg(2,J1,L1),
( L1=[M1|_] ->
setarg(4,M1,J1)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',N1),
delete_ht(N1,A,J),
arg(2,G,E1),
setarg(2,G,active),
( E1==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',F1),
G1=[G|F1],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',G1),
( F1=[H1|_] ->
setarg(4,H1,G1)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',I1),
insert_ht(I1,A,G)
;
true
),
rule(A,D1),
( G=suspension(_,active,_,_,_,_,_,_,_,_) ->
setarg(2,G,inactive),
prev_guard_list___6__1__0__4(K,A,B,C,D,E,F,G)
;
true
)
;
prev_guard_list___6__1__0__4(K,A,B,C,D,E,F,G)
).
prev_guard_list___6__1(A,B,C,D,E,F,G) :-
prev_guard_list___6__2(A,B,C,D,E,F,G).
prev_guard_list___6__2(A,B,C,D,E,F,G) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',I),
lookup_ht1(I,A,A,H),
!,
prev_guard_list___6__2__0__5(H,A,B,C,D,E,F,G).
prev_guard_list___6__2__0__5([],B,C,D,E,F,G,A) :-
prev_guard_list___6__3(B,C,D,E,F,G,A).
prev_guard_list___6__2__0__5([J|L],B,C,D,E,F,G,A) :-
( J=suspension(_,active,_,_,H,I),
H==B,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',M),
lookup_ht1(M,B,B,K) ->
prev_guard_list___6__2__1__5(K,I,J,L,B,C,D,E,F,G,A)
;
prev_guard_list___6__2__0__5(L,B,C,D,E,F,G,A)
).
prev_guard_list___6__2__1__5([],_,_,A,C,D,E,F,G,H,B) :-
prev_guard_list___6__2__0__5(A,C,D,E,F,G,H,B).
prev_guard_list___6__2__1__5([N|P],J,A,B,D,E,F,G,H,I,C) :-
( N=suspension(_,active,_,_,K,L,M,_,_),
M==D,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',Q),
lookup_ht(Q,K,O) ->
prev_guard_list___6__2__2__5(O,K,L,N,P,J,A,B,D,E,F,G,H,I,C)
;
prev_guard_list___6__2__1__5(P,J,A,B,D,E,F,G,H,I,C)
).
prev_guard_list___6__2__2__5([],_,_,_,A,K,B,C,E,F,G,H,I,J,D) :-
prev_guard_list___6__2__1__5(A,K,B,C,E,F,G,H,I,J,D).
prev_guard_list___6__2__2__5([S|U],M,N,A,B,L,C,D,F,G,H,I,J,K,E) :-
( S=suspension(_,active,_,_,O,P,Q,R,_),
S\==A,
O==M,
Q==F,
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',T) ->
prev_guard_list___6__2__3__5(T,P,R,S,U,M,N,A,B,L,C,D,F,G,H,I,J,K,E)
;
prev_guard_list___6__2__2__5(U,M,N,A,B,L,C,D,F,G,H,I,J,K,E)
).
prev_guard_list___6__2__3__5([],_,_,_,A,N,O,B,C,M,D,E,G,H,I,J,K,L,F) :-
prev_guard_list___6__2__2__5(A,N,O,B,C,M,D,E,G,H,I,J,K,L,F).
prev_guard_list___6__2__3__5([T|U],P,Q,A,R,M,N,B,O,K,C,L,D,E,F,G,H,I,J) :-
( T=suspension(_,active,_,S),
P<N,
chr_pp_flag(occurrence_subsumption,on),
K=pragma(rule(V,_,_,_),_,_,_,_),
V\==[],
\+tree_set_memberchk(M,S) ->
setarg(2,T,removed),
arg(3,T,C1),
( var(C1) ->
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',D1),
D1=[_|E1],
b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',E1),
( E1=[F1|_] ->
setarg(3,F1,_)
;
true
)
;
C1=[_,_|E1],
setarg(2,C1,E1),
( E1=[F1|_] ->
setarg(3,F1,C1)
;
true
)
),
arg(2,J,X),
setarg(2,J,active),
( X==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',Y),
Z=[J|Y],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',Z),
( Y=[A1|_] ->
setarg(4,A1,Z)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',B1),
insert_ht(B1,D,J)
;
true
),
first_occ_in_rule(D,M,P,Q),
tree_set_add(S,M,W),
multiple_occ_constraints_checked(W),
( J=suspension(_,active,_,_,_,_,_,_,_,_) ->
setarg(2,J,inactive),
prev_guard_list___6__2__3__5(U,P,Q,A,R,M,N,B,O,K,C,L,D,E,F,G,H,I,J)
;
true
)
;
prev_guard_list___6__2__3__5(U,P,Q,A,R,M,N,B,O,K,C,L,D,E,F,G,H,I,J)
).
prev_guard_list___6__2(A,B,C,D,E,F,G) :-
prev_guard_list___6__3(A,B,C,D,E,F,G).
prev_guard_list___6__3(A,_,_,_,_,_,B) :-
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!,
setarg(2,C,removed),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',L),
L=[_|M],
b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
( var(B) ->
true
;
arg(2,B,J),
setarg(2,B,removed),
( J==not_stored_yet ->
true
;
arg(4,B,E),
( var(E) ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',F),
F=[_|G],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',G),
( G=[H|_] ->
setarg(4,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(4,H,E)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',I),
delete_ht(I,A,B)
)
).
prev_guard_list___6__3(A,_,_,_,_,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',E),
( D=[F|_] ->
setarg(4,F,E)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',G),
insert_ht(G,A,B)
;
true
).
simplify_guards(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',Z),
lookup_ht1(Z,A,A,D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,_,C),
!,
C=pragma(rule(E,F,G,_),ids(H,I),_,_,A),
append(E,F,J),
make_head_matchings_explicit_not_negated(J,K,L),
tree_set_empty(M),
multiple_occ_constraints_checked(M),
apply_guard_wrt_term(J,G,N),
append(H,I,O),
findall(tuple(Q,R,A)-(-A),(member(S,O),get_occurrence_from_id(Q,R,A,S)),P),
empty_q(T),
insert_list_q(P,T,U),
next_prev_rule(U,_,V),
next_prev_rule(V,W,X),
prev_guard_list(A,W,X,K,G,[],L,[N]),
Y is A+1,
simplify_guards(Y).
simplify_guards(_).
set_all_passive(A) :-
set_all_passive___1__0(A,_).
set_all_passive___1__0(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',E),
lookup_ht1(E,A,A,C),
!,
B=suspension(D,not_stored_yet,t,A),
'chr gen_id'(D),
set_all_passive___1__0__0__1(C,A,B).
set_all_passive___1__0__0__1([],B,A) :-
set_all_passive___1__1(B,A).
set_all_passive___1__0__0__1([E|F],B,A) :-
( E=suspension(_,active,_,_,_,_,C,D,_),
C==B,
G=t(176,A,E),
'$novel_production'(A,G),
'$novel_production'(E,G) ->
'$extend_history'(A,G),
arg(2,A,H),
setarg(2,A,active),
( H==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',I),
insert_ht(I,B,A)
;
true
),
passive(B,D),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
set_all_passive___1__0__0__1(F,B,A)
;
true
)
;
set_all_passive___1__0__0__1(F,B,A)
).
set_all_passive___1__0(A,B) :-
B=suspension(C,not_stored_yet,t,A),
'chr gen_id'(C),
set_all_passive___1__1(A,B).
set_all_passive___1__1(A,B) :-
( var(B) ->
true
;
arg(2,B,D),
setarg(2,B,removed),
( D==not_stored_yet ->
true
;
nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',C),
delete_ht(C,A,B)
)
).
precompute_head_matchings :-
precompute_head_matchings___0__0(_).
precompute_head_matchings___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____rule___2',B),
!,
A=suspension(C,not_stored_yet,t,_),
'chr gen_id'(C),
precompute_head_matchings___0__0__0__1(B,A).
precompute_head_matchings___0__0__0__1([],A) :-
precompute_head_matchings___0__1(A).
precompute_head_matchings___0__0__0__1([D|E],A) :-
( D=suspension(_,active,_,_,B,C),
M=t(170,D,A),
'$novel_production'(D,M),
'$novel_production'(A,M) ->
'$extend_history'(A,M),
arg(2,A,N),
setarg(2,A,active),
( N==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',O),
P=[A|O],
b_setval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',P),
( O=[Q|_] ->
setarg(4,Q,P)
;
true
)
;
true
),
C=pragma(rule(F,G,_,_),_,_,_,_),
append(F,G,H),
make_head_matchings_explicit_(H,I,J),
copy_term_nat(I-J,K-L),
make_head_matchings_explicit_memo_table(B,K,L),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
precompute_head_matchings___0__0__0__1(E,A)
;
true
)
;
precompute_head_matchings___0__0__0__1(E,A)
).
precompute_head_matchings___0__0(A) :-
A=suspension(B,not_stored_yet,t,_),
'chr gen_id'(B),
precompute_head_matchings___0__1(A).
precompute_head_matchings___0__1(A) :-
( var(A) ->
true
;
arg(2,A,F),
setarg(2,A,removed),
( F==not_stored_yet ->
true
;
arg(4,A,B),
( var(B) ->
nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',C),
C=[_|D],
b_setval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',D),
( D=[E|_] ->
setarg(4,E,_)
;
true
)
;
B=[_,_|D],
setarg(2,B,D),
( D=[E|_] ->
setarg(4,E,B)
;
true
)
)
)
).
make_head_matchings_explicit_memo_table(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',F),
insert_ht(F,A,D).
make_head_matchings_explicit_memo_lookup(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',H),
lookup_ht(H,A,G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,E,F),
!,
B=E,
C=F.
make_head_matchings_explicit_memo_lookup(_,_,_) :-
fail.
first_occ_in_rule(A,B,C,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',I),
lookup_ht(I,B,H),
'chr sbag_member'(D,H),
D=suspension(_,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) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',N),
lookup_ht(N,A,H),
'chr sbag_member'(F,H),
F=suspension(_,active,_,_,G),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',M),
lookup_ht(M,k(A,G),L),
'chr sbag_member'(I,L),
I=suspension(_,active,_,_,J,K,_,_,_),
J=B,
K is C+1,
!,
next_occ_in_rule(A,B,K,D,_,E).
next_occ_in_rule(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',S1),
lookup_ht(S1,A,L),
'chr sbag_member'(G,L),
G=suspension(_,active,_,_,_,H,I,J,K,_),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',R1),
lookup_ht1(R1,A,A,O),
'chr sbag_member'(M,O),
M=suspension(_,active,_,_,_,N),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',Q1),
lookup_ht(Q1,B,T),
'chr sbag_member'(P,T),
P=suspension(_,active,_,_,_,Q,R,S,_),
R=A,
Q is C+1,
N=pragma(rule(U,V,I,_),ids(_,_),_,_,A),
!,
append(U,V,W),
add_failing_occ(N,W,H,D,X,F,K,B,Y),
( X==[chr_pp_void_info] ->
next_occ_in_rule(A,B,Q,S,E,F)
;
append(X,E,Z),
add_failing_occ(N,W,H,S,A1,F,K,B,B1),
copy_term(J,C1),
variable_replacement(J,C1,D1),
copy_with_variable_replacement(J,E1,Y),
copy_with_variable_replacement(J,F1,B1),
copy_with_variable_replacement(F1,G1,D1),
append(Z,E1,H1),
append(H1,G1,I1),
copy_with_variable_replacement(K,J1,Y),
copy_with_variable_replacement(K,K1,B1),
append(K1,I1,L1),
append([chr_pp_active_constraint(F)|J1],L1,M1),
list2conj(A1,N1),
copy_term((Z,I1,M1,N1,F),(_,_,O1,P1,_)),
( N1\=chr_pp_void_info ->
( guard_entailment:entails_guard(O1,P1) ->
passive(A,S)
;
true
)
;
true
),
!,
next_occ_in_rule(A,B,Q,S,Z,F)
).
next_occ_in_rule(_,_,_,_,_,_).
multiple_occ_constraints_checked(A) :-
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,C,_,_,_,_,_),
(
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',Z),
lookup_ht1(Z,C,C,H),
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,F,G,_,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',Y),
lookup_ht1(Y,C,C,K),
'chr sbag_member'(I,K),
I=suspension(_,active,_,_,_,J),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',X),
lookup_ht(X,F,P),
'chr sbag_member'(L,P),
L=suspension(_,active,_,_,_,M,N,O,_),
L\==E,
N=C,
M<G,
chr_pp_flag(occurrence_subsumption,on),
J=pragma(rule(Q,_,_,_),_,_,_,_),
Q\==[],
\+tree_set_memberchk(F,A),
!,
first_occ_in_rule(C,F,M,O),
tree_set_add(A,F,R),
multiple_occ_constraints_checked(R)
;
!,
setarg(2,B,removed),
arg(4,B,S),
( var(S) ->
nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',T),
T=[_|U],
b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',U),
( U=[V|_] ->
setarg(4,V,_)
;
true
)
;
S=[_,_|U],
setarg(2,S,U),
( U=[V|_] ->
setarg(4,V,S)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',W),
delete_ht(W,C,B)
).
multiple_occ_constraints_checked(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
type_definition(A,B) :-
type_definition___2__0(A,B,_).
type_definition___2__0(A,_,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,D,_),
(
functor(A,F,G),
functor(D,F,G),
!,
C=suspension(_,_,_,_,_,L1,M1),
setarg(2,C,removed),
term_variables(term(L1,M1),H),
arg(5,C,H1),
( var(H1) ->
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',I1),
I1=[_|J1],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',J1),
( J1=[K1|_] ->
setarg(5,K1,_)
;
true
)
;
H1=[_,_|J1],
setarg(2,H1,J1),
( J1=[K1|_] ->
setarg(5,K1,H1)
;
true
)
),
detach_type_definition___2(H,C),
( var(B) ->
true
;
B=suspension(_,E1,_,_,_,F1,G1),
setarg(2,B,removed),
( E1==not_stored_yet ->
I=[]
;
term_variables(term(F1,G1),I),
arg(5,B,A1),
( var(A1) ->
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',B1),
B1=[_|C1],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',C1),
( C1=[D1|_] ->
setarg(5,D1,_)
;
true
)
;
A1=[_,_|C1],
setarg(2,A1,C1),
( C1=[D1|_] ->
setarg(5,D1,A1)
;
true
)
),
detach_type_definition___2(I,B)
)
),
chr_error(type_error,'Multiple definitions for type: ~w/~w.
',[F,G])
;
functor(D,J,K),
functor(A,J,K),
!,
C=suspension(_,_,_,_,_,Y,Z),
setarg(2,C,removed),
term_variables(term(Y,Z),L),
arg(5,C,U),
( var(U) ->
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',V),
V=[_|W],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',W),
( W=[X|_] ->
setarg(5,X,_)
;
true
)
;
U=[_,_|W],
setarg(2,U,W),
( W=[X|_] ->
setarg(5,X,U)
;
true
)
),
detach_type_definition___2(L,C),
( var(B) ->
true
;
B=suspension(_,R,_,_,_,S,T),
setarg(2,B,removed),
( R==not_stored_yet ->
M=[]
;
term_variables(term(S,T),M),
arg(5,B,N),
( var(N) ->
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',O),
O=[_|P],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',P),
( P=[Q|_] ->
setarg(5,Q,_)
;
true
)
;
N=[_,_|P],
setarg(2,N,P),
( P=[Q|_] ->
setarg(5,Q,N)
;
true
)
),
detach_type_definition___2(M,B)
)
),
chr_error(type_error,'Multiple definitions for type: ~w/~w.
',[J,K])
).
type_definition___2__0(A,_,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,D,_),
functor(A,F,G),
functor(D,F,G),
!,
C=suspension(_,_,_,_,_,U,V),
setarg(2,C,removed),
term_variables(term(U,V),H),
arg(5,C,Q),
( var(Q) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',R),
R=[_|S],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',S),
( S=[T|_] ->
setarg(5,T,_)
;
true
)
;
Q=[_,_|S],
setarg(2,Q,S),
( S=[T|_] ->
setarg(5,T,Q)
;
true
)
),
detach_type_alias___2(H,C),
( var(B) ->
true
;
B=suspension(_,N,_,_,_,O,P),
setarg(2,B,removed),
( N==not_stored_yet ->
I=[]
;
term_variables(term(O,P),I),
arg(5,B,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',L),
( L=[M|_] ->
setarg(5,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(5,M,J)
;
true
)
),
detach_type_definition___2(I,B)
)
),
chr_error(type_error,'Multiple definitions for type, once in a type definition and once as a type alias: ~w/~w.
',[F,G]).
type_definition___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',D),
!,
( var(C) ->
C=suspension(E,not_stored_yet,t,0,_,A,B),
'chr gen_id'(E)
;
true
),
type_definition___2__0__0__5(D,A,B,C).
type_definition___2__0__0__5([],B,C,A) :-
type_definition___2__1(B,C,A).
type_definition___2__0__0__5([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
nonvar(A),
functor(A,I,J),
functor(D,I,J) ->
F=suspension(_,_,_,X,_),
setarg(2,F,removed),
term_variables(X,H),
arg(3,F,T),
( var(T) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',U),
U=[_|V],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',V),
( V=[W|_] ->
setarg(3,W,_)
;
true
)
;
T=[_,_|V],
setarg(2,T,V),
( V=[W|_] ->
setarg(3,W,T)
;
true
)
),
detach_unalias_type___2(H,F),
arg(2,C,N),
setarg(2,C,active),
arg(4,C,M),
L is M+1,
setarg(4,C,L),
( N==not_stored_yet ->
C=suspension(_,_,_,_,_,O,P),
term_variables(term(O,P),K),
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',Q),
R=[C|Q],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',R),
( Q=[S|_] ->
setarg(5,S,R)
;
true
),
attach_type_definition___2(K,C)
;
true
),
E=D,
( C=suspension(_,active,_,L,_,_,_) ->
setarg(2,C,inactive),
type_definition___2__0__0__5(G,A,B,C)
;
true
)
;
type_definition___2__0__0__5(G,A,B,C)
).
type_definition___2__0(A,B,C) :-
( var(C) ->
C=suspension(D,not_stored_yet,t,0,_,A,B),
'chr gen_id'(D)
;
true
),
type_definition___2__1(A,B,C).
type_definition___2__1(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',D),
!,
type_definition___2__1__0__7(D,A,B,C).
type_definition___2__1__0__7([],B,C,A) :-
type_definition___2__2(B,C,A).
type_definition___2__1__0__7([D|E],B,C,A) :-
( D=suspension(_,active,_,_),
K=t(231,A,D),
'$novel_production'(A,K),
'$novel_production'(D,K) ->
'$extend_history'(A,K),
arg(2,A,M),
setarg(2,A,active),
arg(4,A,L),
J is L+1,
setarg(4,A,J),
( M==not_stored_yet ->
A=suspension(_,_,_,_,_,N,O),
term_variables(term(N,O),I),
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',P),
Q=[A|P],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',Q),
( P=[R|_] ->
setarg(5,R,Q)
;
true
),
attach_type_definition___2(I,A)
;
true
),
copy_term_nat(B-C,F-G),
maplist(dynamic_type_check_clause(F),G,H),
dynamic_type_check_clauses(H),
( A=suspension(_,active,_,J,_,_,_) ->
setarg(2,A,inactive),
type_definition___2__1__0__7(E,B,C,A)
;
true
)
;
type_definition___2__1__0__7(E,B,C,A)
).
type_definition___2__1(A,B,C) :-
type_definition___2__2(A,B,C).
type_definition___2__2(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',D),
!,
type_definition___2__2__0__8(D,A,B,C).
type_definition___2__2__0__8([],B,C,A) :-
type_definition___2__3(B,C,A).
type_definition___2__2__0__8([E|F],A,B,C) :-
( E=suspension(_,active,_,D),
functor(D,H,I),
functor(A,H,I) ->
E=suspension(_,_,_,W),
setarg(2,E,removed),
term_variables(W,G),
arg(3,E,S),
( var(S) ->
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',T),
T=[_|U],
b_setval('$chr_store_global_list_chr_translate____atomic_type___1',U),
( U=[V|_] ->
setarg(3,V,_)
;
true
)
;
S=[_,_|U],
setarg(2,S,U),
( U=[V|_] ->
setarg(3,V,S)
;
true
)
),
detach_atomic_type___1(G,E),
arg(2,C,M),
setarg(2,C,active),
arg(4,C,L),
K is L+1,
setarg(4,C,K),
( M==not_stored_yet ->
C=suspension(_,_,_,_,_,N,O),
term_variables(term(N,O),J),
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',P),
Q=[C|P],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',Q),
( P=[R|_] ->
setarg(5,R,Q)
;
true
),
attach_type_definition___2(J,C)
;
true
),
maplist(atomic,B),
( C=suspension(_,active,_,K,_,_,_) ->
setarg(2,C,inactive),
type_definition___2__2__0__8(F,A,B,C)
;
true
)
;
type_definition___2__2__0__8(F,A,B,C)
).
type_definition___2__2(A,B,C) :-
type_definition___2__3(A,B,C).
type_definition___2__3(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',D),
!,
type_definition___2__3__0__9(D,A,B,C).
type_definition___2__3__0__9([],B,C,A) :-
type_definition___2__4(B,C,A).
type_definition___2__3__0__9([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
functor(D,I,J),
functor(A,I,J) ->
F=suspension(_,_,_,X,_),
setarg(2,F,removed),
term_variables(X,H),
arg(3,F,T),
( var(T) ->
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',U),
U=[_|V],
b_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',V),
( V=[W|_] ->
setarg(3,W,_)
;
true
)
;
T=[_,_|V],
setarg(2,T,V),
( V=[W|_] ->
setarg(3,W,T)
;
true
)
),
detach_enumerated_atomic_type___2(H,F),
arg(2,C,N),
setarg(2,C,active),
arg(4,C,M),
L is M+1,
setarg(4,C,L),
( N==not_stored_yet ->
C=suspension(_,_,_,_,_,O,P),
term_variables(term(O,P),K),
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',Q),
R=[C|Q],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',R),
( Q=[S|_] ->
setarg(5,S,R)
;
true
),
attach_type_definition___2(K,C)
;
true
),
maplist(atomic,B),
E=B,
( C=suspension(_,active,_,L,_,_,_) ->
setarg(2,C,inactive),
type_definition___2__3__0__9(G,A,B,C)
;
true
)
;
type_definition___2__3__0__9(G,A,B,C)
).
type_definition___2__3(A,B,C) :-
type_definition___2__4(A,B,C).
type_definition___2__4(_,_,A) :-
arg(2,A,E),
setarg(2,A,active),
arg(4,A,D),
C is D+1,
setarg(4,A,C),
( E==not_stored_yet ->
A=suspension(_,_,_,_,_,F,G),
term_variables(term(F,G),B),
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',H),
I=[A|H],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',I),
( H=[J|_] ->
setarg(5,J,I)
;
true
),
attach_type_definition___2(B,A)
;
true
).
type_alias(A,B) :-
type_alias___2__0(A,B,_).
type_alias___2__0(A,B,C) :-
var(A),
!,
( var(C) ->
true
;
C=suspension(_,I,_,_,_,J,K),
setarg(2,C,removed),
( I==not_stored_yet ->
D=[]
;
term_variables(term(J,K),D),
arg(5,C,E),
( var(E) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',F),
F=[_|G],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',G),
( G=[H|_] ->
setarg(5,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(5,H,E)
;
true
)
),
detach_type_alias___2(D,C)
)
),
chr_error(type_error,'Variable alias definition: "~w".
',[(:-chr_type A==B)]).
type_alias___2__0(A,B,C) :-
var(B),
!,
( var(C) ->
true
;
C=suspension(_,I,_,_,_,J,K),
setarg(2,C,removed),
( I==not_stored_yet ->
D=[]
;
term_variables(term(J,K),D),
arg(5,C,E),
( var(E) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',F),
F=[_|G],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',G),
( G=[H|_] ->
setarg(5,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(5,H,E)
;
true
)
),
detach_type_alias___2(D,C)
)
),
chr_error(type_error,'Variable alias definition: "~w".
',[(:-chr_type A==B)]).
type_alias___2__0(A,B,C) :-
functor(A,D,E),
functor(B,D,E),
copy_term((A,B),(F,G)),
subsumes(F,G),
!,
( var(C) ->
true
;
C=suspension(_,M,_,_,_,N,O),
setarg(2,C,removed),
( M==not_stored_yet ->
H=[]
;
term_variables(term(N,O),H),
arg(5,C,I),
( var(I) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',J),
J=[_|K],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',K),
( K=[L|_] ->
setarg(5,L,_)
;
true
)
;
I=[_,_|K],
setarg(2,I,K),
( K=[L|_] ->
setarg(5,L,I)
;
true
)
),
detach_type_alias___2(H,C)
)
),
chr_error(type_error,'Cyclic alias definition: "~w".
',[A==B]).
type_alias___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',G),
(
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,E,F),
(
(
functor(A,H,I),
functor(E,H,I),
\+A\=E,
!,
D=suspension(_,_,_,_,_,G2,H2),
setarg(2,D,removed),
term_variables(term(G2,H2),L),
arg(5,D,C2),
( var(C2) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',D2),
D2=[_|E2],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',E2),
( E2=[F2|_] ->
setarg(5,F2,_)
;
true
)
;
C2=[_,_|E2],
setarg(2,C2,E2),
( E2=[F2|_] ->
setarg(5,F2,C2)
;
true
)
),
detach_type_alias___2(L,D),
( var(C) ->
true
;
C=suspension(_,Z1,_,_,_,A2,B2),
setarg(2,C,removed),
( Z1==not_stored_yet ->
M=[]
;
term_variables(term(A2,B2),M),
arg(5,C,V1),
( var(V1) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',W1),
W1=[_|X1],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',X1),
( X1=[Y1|_] ->
setarg(5,Y1,_)
;
true
)
;
V1=[_,_|X1],
setarg(2,V1,X1),
( X1=[Y1|_] ->
setarg(5,Y1,V1)
;
true
)
),
detach_type_alias___2(M,C)
)
),
copy_term_nat(A,J),
copy_term_nat(E,K),
J=K,
chr_error(type_error,'Ambiguous type aliases: you have defined
`~w''
`~w''
resulting in two definitions for "~w".
',[A==B,E==F,J])
;
functor(E,N,O),
functor(A,N,O),
\+E\=A,
!,
D=suspension(_,_,_,_,_,T1,U1),
setarg(2,D,removed),
term_variables(term(T1,U1),R),
arg(5,D,P1),
( var(P1) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',Q1),
Q1=[_|R1],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',R1),
( R1=[S1|_] ->
setarg(5,S1,_)
;
true
)
;
P1=[_,_|R1],
setarg(2,P1,R1),
( R1=[S1|_] ->
setarg(5,S1,P1)
;
true
)
),
detach_type_alias___2(R,D),
( var(C) ->
true
;
C=suspension(_,M1,_,_,_,N1,O1),
setarg(2,C,removed),
( M1==not_stored_yet ->
S=[]
;
term_variables(term(N1,O1),S),
arg(5,C,I1),
( var(I1) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',J1),
J1=[_|K1],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',K1),
( K1=[L1|_] ->
setarg(5,L1,_)
;
true
)
;
I1=[_,_|K1],
setarg(2,I1,K1),
( K1=[L1|_] ->
setarg(5,L1,I1)
;
true
)
),
detach_type_alias___2(S,C)
)
),
copy_term_nat(E,P),
copy_term_nat(A,Q),
P=Q,
chr_error(type_error,'Ambiguous type aliases: you have defined
`~w''
`~w''
resulting in two definitions for "~w".
',[E==F,A==B,P])
)
;
functor(E,T,U),
functor(B,T,U),
copy_term_nat((A,B,E,F),(V,W,X,Y)),
subsumes(X,W),
!,
( var(C) ->
true
;
C=suspension(_,F1,_,_,_,G1,H1),
setarg(2,C,removed),
( F1==not_stored_yet ->
Z=[]
;
term_variables(term(G1,H1),Z),
arg(5,C,B1),
( var(B1) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',C1),
C1=[_|D1],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',D1),
( D1=[E1|_] ->
setarg(5,E1,_)
;
true
)
;
B1=[_,_|D1],
setarg(2,B1,D1),
( D1=[E1|_] ->
setarg(5,E1,B1)
;
true
)
),
detach_type_alias___2(Z,C)
)
),
type_alias(V,Y)
)
;
!,
( var(C) ->
C=suspension(A1,not_stored_yet,t,0,_,A,B),
'chr gen_id'(A1)
;
true
),
type_alias___2__0__0__7(G,A,B,C)
).
type_alias___2__0__0__7([],B,C,A) :-
type_alias___2__1(B,C,A).
type_alias___2__0__0__7([F|G],A,B,C) :-
( F=suspension(_,active,_,_,_,D,E),
functor(A,I,J),
functor(E,I,J),
copy_term_nat((D,E,A,B),(K,L,M,N)),
subsumes(M,L) ->
F=suspension(_,_,_,_,_,B1,C1),
setarg(2,F,removed),
term_variables(term(B1,C1),H),
arg(5,F,X),
( var(X) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',Y),
Y=[_|Z],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',Z),
( Z=[A1|_] ->
setarg(5,A1,_)
;
true
)
;
X=[_,_|Z],
setarg(2,X,Z),
( Z=[A1|_] ->
setarg(5,A1,X)
;
true
)
),
detach_type_alias___2(H,F),
arg(2,C,R),
setarg(2,C,active),
arg(4,C,Q),
P is Q+1,
setarg(4,C,P),
( R==not_stored_yet ->
C=suspension(_,_,_,_,_,S,T),
term_variables(term(S,T),O),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',U),
V=[C|U],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',V),
( U=[W|_] ->
setarg(5,W,V)
;
true
),
attach_type_alias___2(O,C)
;
true
),
type_alias(K,N),
( C=suspension(_,active,_,P,_,_,_) ->
setarg(2,C,inactive),
type_alias___2__0__0__7(G,A,B,C)
;
true
)
;
type_alias___2__0__0__7(G,A,B,C)
).
type_alias___2__0(A,B,C) :-
( var(C) ->
C=suspension(D,not_stored_yet,t,0,_,A,B),
'chr gen_id'(D)
;
true
),
type_alias___2__1(A,B,C).
type_alias___2__1(A,_,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,D,_),
functor(D,F,G),
functor(A,F,G),
!,
C=suspension(_,_,_,_,_,U,V),
setarg(2,C,removed),
term_variables(term(U,V),H),
arg(5,C,Q),
( var(Q) ->
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',R),
R=[_|S],
b_setval('$chr_store_global_list_chr_translate____type_definition___2',S),
( S=[T|_] ->
setarg(5,T,_)
;
true
)
;
Q=[_,_|S],
setarg(2,Q,S),
( S=[T|_] ->
setarg(5,T,Q)
;
true
)
),
detach_type_definition___2(H,C),
( var(B) ->
true
;
B=suspension(_,N,_,_,_,O,P),
setarg(2,B,removed),
( N==not_stored_yet ->
I=[]
;
term_variables(term(O,P),I),
arg(5,B,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',L),
( L=[M|_] ->
setarg(5,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(5,M,J)
;
true
)
),
detach_type_alias___2(I,B)
)
),
chr_error(type_error,'Multiple definitions for type, once in a type definition and once as a type alias: ~w/~w.
',[F,G]).
type_alias___2__1(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',D),
!,
type_alias___2__1__0__10(D,A,B,C).
type_alias___2__1__0__10([],B,C,A) :-
type_alias___2__2(B,C,A).
type_alias___2__1__0__10([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
functor(A,I,J),
functor(D,I,J),
copy_term_nat((A,B),(K,L)),
D=K ->
F=suspension(_,_,_,Z,_),
setarg(2,F,removed),
term_variables(Z,H),
arg(3,F,V),
( var(V) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',W),
W=[_|X],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',X),
( X=[Y|_] ->
setarg(3,Y,_)
;
true
)
;
V=[_,_|X],
setarg(2,V,X),
( X=[Y|_] ->
setarg(3,Y,V)
;
true
)
),
detach_unalias_type___2(H,F),
arg(2,C,P),
setarg(2,C,active),
arg(4,C,O),
N is O+1,
setarg(4,C,N),
( P==not_stored_yet ->
C=suspension(_,_,_,_,_,Q,R),
term_variables(term(Q,R),M),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',S),
T=[C|S],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',T),
( S=[U|_] ->
setarg(5,U,T)
;
true
),
attach_type_alias___2(M,C)
;
true
),
unalias_type(L,E),
( C=suspension(_,active,_,N,_,_,_) ->
setarg(2,C,inactive),
type_alias___2__1__0__10(G,A,B,C)
;
true
)
;
type_alias___2__1__0__10(G,A,B,C)
).
type_alias___2__1(A,B,C) :-
type_alias___2__2(A,B,C).
type_alias___2__2(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',D),
!,
type_alias___2__2__0__12(D,A,B,C).
type_alias___2__2__0__12([],B,C,A) :-
type_alias___2__3(B,C,A).
type_alias___2__2__0__12([G|H],A,B,C) :-
( G=suspension(_,active,_,D,E,F),
functor(A,J,K),
functor(F,J,K) ->
G=suspension(_,_,_,_,Z,A1),
setarg(2,G,removed),
I=[Z|B1],
term_variables(A1,B1),
arg(3,G,V),
( var(V) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',W),
W=[_|X],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',X),
( X=[Y|_] ->
setarg(3,Y,_)
;
true
)
;
V=[_,_|X],
setarg(2,V,X),
( X=[Y|_] ->
setarg(3,Y,V)
;
true
)
),
detach_static_type_check_var___3(I,G),
arg(2,C,P),
setarg(2,C,active),
arg(4,C,O),
N is O+1,
setarg(4,C,N),
( P==not_stored_yet ->
C=suspension(_,_,_,_,_,Q,R),
term_variables(term(Q,R),M),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',S),
T=[C|S],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',T),
( S=[U|_] ->
setarg(5,U,T)
;
true
),
attach_type_alias___2(M,C)
;
true
),
copy_term_nat(A-B,F-L),
static_type_check_var(D,E,L),
( C=suspension(_,active,_,N,_,_,_) ->
setarg(2,C,inactive),
type_alias___2__2__0__12(H,A,B,C)
;
true
)
;
type_alias___2__2__0__12(H,A,B,C)
).
type_alias___2__2(A,B,C) :-
type_alias___2__3(A,B,C).
type_alias___2__3(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',D),
!,
type_alias___2__3__0__13(D,A,B,C).
type_alias___2__3__0__13([],B,C,A) :-
type_alias___2__4(B,C,A).
type_alias___2__3__0__13([D|E],B,C,A) :-
( D=suspension(_,active,_,_),
K=t(232,A,D),
'$novel_production'(A,K),
'$novel_production'(D,K) ->
'$extend_history'(A,K),
arg(2,A,M),
setarg(2,A,active),
arg(4,A,L),
J is L+1,
setarg(4,A,J),
( M==not_stored_yet ->
A=suspension(_,_,_,_,_,N,O),
term_variables(term(N,O),I),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',P),
Q=[A|P],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',Q),
( P=[R|_] ->
setarg(5,R,Q)
;
true
),
attach_type_alias___2(I,A)
;
true
),
copy_term_nat(B-C,F-G),
dynamic_type_check_alias_clause(F,G,H),
dynamic_type_check_clauses([H]),
( A=suspension(_,active,_,J,_,_,_) ->
setarg(2,A,inactive),
type_alias___2__3__0__13(E,B,C,A)
;
true
)
;
type_alias___2__3__0__13(E,B,C,A)
).
type_alias___2__3(A,B,C) :-
type_alias___2__4(A,B,C).
type_alias___2__4(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',D),
!,
type_alias___2__4__0__14(D,A,B,C).
type_alias___2__4__0__14([],B,C,A) :-
type_alias___2__5(B,C,A).
type_alias___2__4__0__14([E|F],A,B,C) :-
( E=suspension(_,active,_,D),
functor(D,H,I),
functor(A,H,I) ->
E=suspension(_,_,_,X),
setarg(2,E,removed),
term_variables(X,G),
arg(3,E,T),
( var(T) ->
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',U),
U=[_|V],
b_setval('$chr_store_global_list_chr_translate____atomic_type___1',V),
( V=[W|_] ->
setarg(3,W,_)
;
true
)
;
T=[_,_|V],
setarg(2,T,V),
( V=[W|_] ->
setarg(3,W,T)
;
true
)
),
detach_atomic_type___1(G,E),
arg(2,C,N),
setarg(2,C,active),
arg(4,C,M),
L is M+1,
setarg(4,C,L),
( N==not_stored_yet ->
C=suspension(_,_,_,_,_,O,P),
term_variables(term(O,P),K),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',Q),
R=[C|Q],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',R),
( Q=[S|_] ->
setarg(5,S,R)
;
true
),
attach_type_alias___2(K,C)
;
true
),
atomic(B),
copy_term_nat(A-B,D-J),
atomic_type(J),
( C=suspension(_,active,_,L,_,_,_) ->
setarg(2,C,inactive),
type_alias___2__4__0__14(F,A,B,C)
;
true
)
;
type_alias___2__4__0__14(F,A,B,C)
).
type_alias___2__4(A,B,C) :-
type_alias___2__5(A,B,C).
type_alias___2__5(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',D),
!,
type_alias___2__5__0__15(D,A,B,C).
type_alias___2__5__0__15([],B,C,A) :-
type_alias___2__6(B,C,A).
type_alias___2__5__0__15([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
functor(D,I,J),
functor(A,I,J) ->
F=suspension(_,_,_,Y,_),
setarg(2,F,removed),
term_variables(Y,H),
arg(3,F,U),
( var(U) ->
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',V),
V=[_|W],
b_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',W),
( W=[X|_] ->
setarg(3,X,_)
;
true
)
;
U=[_,_|W],
setarg(2,U,W),
( W=[X|_] ->
setarg(3,X,U)
;
true
)
),
detach_enumerated_atomic_type___2(H,F),
arg(2,C,O),
setarg(2,C,active),
arg(4,C,N),
M is N+1,
setarg(4,C,M),
( O==not_stored_yet ->
C=suspension(_,_,_,_,_,P,Q),
term_variables(term(P,Q),L),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',R),
S=[C|R],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',S),
( R=[T|_] ->
setarg(5,T,S)
;
true
),
attach_type_alias___2(L,C)
;
true
),
atomic(B),
copy_term_nat(A-B,D-K),
enumerated_atomic_type(K,E),
( C=suspension(_,active,_,M,_,_,_) ->
setarg(2,C,inactive),
type_alias___2__5__0__15(G,A,B,C)
;
true
)
;
type_alias___2__5__0__15(G,A,B,C)
).
type_alias___2__5(A,B,C) :-
type_alias___2__6(A,B,C).
type_alias___2__6(_,_,A) :-
arg(2,A,E),
setarg(2,A,active),
arg(4,A,D),
C is D+1,
setarg(4,A,C),
( E==not_stored_yet ->
A=suspension(_,_,_,_,_,F,G),
term_variables(term(F,G),B),
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',H),
I=[A|H],
b_setval('$chr_store_global_list_chr_translate____type_alias___2',I),
( H=[J|_] ->
setarg(5,J,I)
;
true
),
attach_type_alias___2(B,A)
;
true
).
constraint_type(A,B) :-
constraint_type___2__0(A,B,_).
constraint_type___2__0(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____static_type_check___0',D),
!,
C=suspension(E,not_stored_yet,_,A,B),
'chr gen_id'(E),
constraint_type___2__0__0__2(D,A,B,C).
constraint_type___2__0__0__2([],B,C,A) :-
constraint_type___2__1(B,C,A).
constraint_type___2__0__0__2([D|E],B,C,A) :-
( D=suspension(_,active,_,_) ->
arg(2,A,H),
setarg(2,A,active),
( H==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',I),
J=[A|I],
b_setval('$chr_store_global_ground_chr_translate____constraint_type___2',J),
( I=[K|_] ->
setarg(3,K,J)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',L),
insert_ht(L,B,A)
;
true
),
forall((member(F,C),sub_term(F,G)),(get_type_definition(G,_)->true;chr_error(type_error,'Undefined type "~w" used in type declaration of "~w".
',[G,B]))),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
constraint_type___2__0__0__2(E,B,C,A)
;
true
)
;
constraint_type___2__0__0__2(E,B,C,A)
).
constraint_type___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,_,A,B),
'chr gen_id'(D),
constraint_type___2__1(A,B,C).
constraint_type___2__1(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____constraint_type___2',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',G),
insert_ht(G,A,B)
;
true
).
get_type_definition(A,_) :-
\+ground(A),
!,
chr_error(type_error,'Non-ground type in constraint definition: "~w".
',[A]).
get_type_definition(A,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,D,E),
functor(D,G,H),
functor(A,G,H),
copy_term_nat((D,E),(I,J)),
I=A,
!,
( get_type_definition(J,B) ->
true
;
chr_error(type_error,'Could not find type definition for "~w" (accessed via alias "~w").
',[J,I]),
fail
).
get_type_definition(A,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,D,E),
nonvar(D),
functor(D,G,H),
functor(A,G,H),
copy_term_nat((D,E),(I,J)),
I=A,
!,
B=J.
get_type_definition(A,B) :-
atomic_builtin_type(A,_,_),
!,
B=[A].
get_type_definition(A,B) :-
compound_builtin_type(A,_,_,_),
!,
B=[A].
get_type_definition(_,_) :-
fail.
get_constraint_type(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
!,
B=D.
get_constraint_type(_,_) :-
fail.
unalias_type(A,B) :-
unalias_type___2__0(A,B,_).
unalias_type___2__0(A,B,C) :-
var(A),
!,
( var(C) ->
true
;
C=suspension(_,_,_,I,_),
setarg(2,C,removed),
term_variables(I,D),
arg(3,C,E),
( var(E) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',F),
F=[_|G],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',G),
( G=[H|_] ->
setarg(3,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(3,H,E)
;
true
)
),
detach_unalias_type___2(D,C)
),
B=A.
unalias_type___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,E,F),
functor(E,H,I),
functor(A,H,I),
copy_term_nat((E,F),(J,K)),
A=J,
!,
( var(C) ->
true
;
C=suspension(_,_,_,Q,_),
setarg(2,C,removed),
term_variables(Q,L),
arg(3,C,M),
( var(M) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',N),
N=[_|O],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',O),
( O=[P|_] ->
setarg(3,P,_)
;
true
)
;
M=[_,_|O],
setarg(2,M,O),
( O=[P|_] ->
setarg(3,P,M)
;
true
)
),
detach_unalias_type___2(L,C)
),
unalias_type(K,B).
unalias_type___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,_,E,_),
nonvar(E),
functor(E,G,H),
functor(A,G,H),
!,
( var(C) ->
true
;
C=suspension(_,_,_,N,_),
setarg(2,C,removed),
term_variables(N,I),
arg(3,C,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_unalias_type___2(I,C)
),
B=A.
unalias_type___2__0(A,B,C) :-
atomic_builtin_type(A,_,_),
!,
( var(C) ->
true
;
C=suspension(_,_,_,I,_),
setarg(2,C,removed),
term_variables(I,D),
arg(3,C,E),
( var(E) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',F),
F=[_|G],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',G),
( G=[H|_] ->
setarg(3,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(3,H,E)
;
true
)
),
detach_unalias_type___2(D,C)
),
B=A.
unalias_type___2__0(A,B,C) :-
compound_builtin_type(A,_,_,_),
!,
( var(C) ->
true
;
C=suspension(_,_,_,I,_),
setarg(2,C,removed),
term_variables(I,D),
arg(3,C,E),
( var(E) ->
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',F),
F=[_|G],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',G),
( G=[H|_] ->
setarg(3,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(3,H,E)
;
true
)
),
detach_unalias_type___2(D,C)
),
B=A.
unalias_type___2__0(A,B,C) :-
( var(C) ->
C=suspension(E,active,_,A,B),
term_variables(A,D),
'chr gen_id'(E),
nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',F),
G=[C|F],
b_setval('$chr_store_global_list_chr_translate____unalias_type___2',G),
( F=[H|_] ->
setarg(3,H,G)
;
true
),
attach_unalias_type___2(D,C)
;
setarg(2,C,active)
).
types_modes_condition([],[],A) :-
!,
A=true.
types_modes_condition([B|C],[D|E],A) :-
nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',I),
'chr sbag_member'(F,I),
F=suspension(_,active,_,_,G,H),
G=J/K,
functor(B,J,K),
!,
B=..[_|L],
A=(M,N,O),
modes_condition(H,L,M),
get_constraint_type_det(J/K,P),
D=..[_|Q],
types_condition(P,L,Q,H,N),
types_modes_condition(C,E,O).
types_modes_condition([A|_],_,_) :-
!,
functor(A,B,C),
chr_error(internal,'Mode information missing for ~w.
',[B/C]).
types_modes_condition(A,B,C) :-
D=suspension(E,active,_,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',F),
G=[D|F],
b_setval('$chr_store_global_ground_chr_translate____types_modes_condition___3',G),
( F=[H|_] ->
setarg(3,H,G)
;
true
).
static_type_check :-
static_type_check___0__0(_).
static_type_check___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',B),
!,
A=suspension(C,not_stored_yet,t,_),
'chr gen_id'(C),
static_type_check___0__0__0__1(B,A).
static_type_check___0__0__0__1([],A) :-
static_type_check___0__1(A).
static_type_check___0__0__0__1([D|E],A) :-
( D=suspension(_,active,_,B,C) ->
arg(2,A,H),
setarg(2,A,active),
( H==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____static_type_check___0',I),
J=[A|I],
b_setval('$chr_store_global_ground_chr_translate____static_type_check___0',J),
( I=[K|_] ->
setarg(4,K,J)
;
true
)
;
true
),
forall((member(F,C),sub_term(F,G)),(get_type_definition(G,_)->true;chr_error(type_error,'Undefined type "~w" used in type declaration of "~w".
',[G,B]))),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
static_type_check___0__0__0__1(E,A)
;
true
)
;
static_type_check___0__0__0__1(E,A)
).
static_type_check___0__0(A) :-
A=suspension(B,not_stored_yet,t,_),
'chr gen_id'(B),
static_type_check___0__1(A).
static_type_check___0__1(A) :-
nb_getval('$chr_store_global_ground_chr_translate____rule___2',B),
!,
static_type_check___0__1__0__2(B,A).
static_type_check___0__1__0__2([],A) :-
static_type_check___0__2(A).
static_type_check___0__1__0__2([C|D],A) :-
( C=suspension(_,active,_,_,_,B),
S=t(209,C,A),
'$novel_production'(C,S),
'$novel_production'(A,S) ->
'$extend_history'(A,S),
arg(2,A,T),
setarg(2,A,active),
( T==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____static_type_check___0',U),
V=[A|U],
b_setval('$chr_store_global_ground_chr_translate____static_type_check___0',V),
( U=[W|_] ->
setarg(4,W,V)
;
true
)
;
true
),
copy_term_nat(B,E),
E=pragma(rule(F,G,_,H),ids(_,_),_,_,_),
(
catch((static_type_check_heads(F),static_type_check_heads(G),conj2list(H,I),static_type_check_body(I)),type_error(J),(J=invalid_functor(K,L,M)->chr_error(type_error,'Invalid functor in ~@ of ~@:
found `~w'',
expected type `~w''!
',[chr_translate:format_src(K),format_rule(B),L,M]);J=type_clash(N,O,P,Q,R)->chr_error(type_error,'Type clash for variable ~w in ~@:
expected type ~w in ~@
expected type ~w in ~@
',[N,format_rule(B),Q,chr_translate:format_src(O),R,chr_translate:format_src(P)]))),
fail
;
true
),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
static_type_check___0__1__0__2(D,A)
;
true
)
;
static_type_check___0__1__0__2(D,A)
).
static_type_check___0__1(A) :-
static_type_check___0__2(A).
static_type_check___0__2(A) :-
( var(A) ->
true
;
arg(2,A,F),
setarg(2,A,removed),
( F==not_stored_yet ->
true
;
arg(4,A,B),
( var(B) ->
nb_getval('$chr_store_global_ground_chr_translate____static_type_check___0',C),
C=[_|D],
b_setval('$chr_store_global_ground_chr_translate____static_type_check___0',D),
( D=[E|_] ->
setarg(4,E,_)
;
true
)
;
B=[_,_|D],
setarg(2,B,D),
( D=[E|_] ->
setarg(4,E,B)
;
true
)
)
)
).
static_type_check_term(A,B,C) :-
var(B),
!,
static_type_check_var(A,B,C).
static_type_check_term(A,B,C) :-
atomic_builtin_type(C,B,D),
!,
( call(D) ->
true
;
throw(type_error(invalid_functor(A,B,C)))
).
static_type_check_term(A,B,C) :-
compound_builtin_type(C,B,_,D),
!,
( call(D) ->
true
;
throw(type_error(invalid_functor(A,B,C)))
).
static_type_check_term(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,E,F),
functor(C,H,I),
functor(E,H,I),
!,
copy_term_nat(E-F,C-J),
static_type_check_term(A,B,J).
static_type_check_term(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,E,F),
functor(C,H,I),
functor(E,H,I),
!,
copy_term_nat(E-F,C-J),
functor(B,K,L),
( member(M,J),
functor(M,K,L) ->
B=..[_|N],
M=..[_|O],
maplist(static_type_check_term(A),N,O)
;
throw(type_error(invalid_functor(A,B,C)))
).
static_type_check_term(A,B,C) :-
chr_error(internal,'Undefined type ~w while type checking term ~w in ~@.
',[C,B,chr_translate:format_src(A)]).
static_type_check_var(A,B,C) :-
static_type_check_var___3__0(A,B,C,_).
static_type_check_var___3__0(A,B,C,D) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',H),
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,_,F,G),
functor(F,I,J),
functor(C,I,J),
!,
( var(D) ->
true
;
D=suspension(_,_,_,_,Q,R),
setarg(2,D,removed),
L=[Q|S],
term_variables(R,S),
arg(3,D,M),
( var(M) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',N),
N=[_|O],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',O),
( O=[P|_] ->
setarg(3,P,_)
;
true
)
;
M=[_,_|O],
setarg(2,M,O),
( O=[P|_] ->
setarg(3,P,M)
;
true
)
),
detach_static_type_check_var___3(L,D)
),
copy_term_nat(F-G,C-K),
static_type_check_var(A,B,K).
static_type_check_var___3__0(A,B,C,D) :-
atomic_builtin_type(C,_,_),
!,
( var(D) ->
true
;
D=suspension(_,_,_,_,J,K),
setarg(2,D,removed),
E=[J|L],
term_variables(K,L),
arg(3,D,F),
( var(F) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',G),
G=[_|H],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
detach_static_type_check_var___3(E,D)
),
static_atomic_builtin_type_check_var(A,B,C).
static_type_check_var___3__0(_,_,A,B) :-
compound_builtin_type(A,_,_,_),
!,
( var(B) ->
true
;
B=suspension(_,_,_,_,H,I),
setarg(2,B,removed),
C=[H|J],
term_variables(I,J),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',E),
E=[_|F],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
detach_static_type_check_var___3(C,B)
).
static_type_check_var___3__0(A,B,C,D) :-
get_attr(B,chr_translate,J),
J=v(_,_,_,_,_,_,_,I,_,_,_),
'chr sbag_member'(E,I),
E=suspension(_,active,_,F,G,H),
G==B,
(
C\==H,
!,
E=suspension(_,_,_,_,N1,O1),
setarg(2,E,removed),
K=[N1|P1],
term_variables(O1,P1),
arg(3,E,J1),
( var(J1) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',K1),
K1=[_|L1],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',L1),
( L1=[M1|_] ->
setarg(3,M1,_)
;
true
)
;
J1=[_,_|L1],
setarg(2,J1,L1),
( L1=[M1|_] ->
setarg(3,M1,J1)
;
true
)
),
detach_static_type_check_var___3(K,E),
( var(D) ->
true
;
D=suspension(_,_,_,_,G1,H1),
setarg(2,D,removed),
L=[G1|I1],
term_variables(H1,I1),
arg(3,D,C1),
( var(C1) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',D1),
D1=[_|E1],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',E1),
( E1=[F1|_] ->
setarg(3,F1,_)
;
true
)
;
C1=[_,_|E1],
setarg(2,C1,E1),
( E1=[F1|_] ->
setarg(3,F1,C1)
;
true
)
),
detach_static_type_check_var___3(L,D)
),
throw(type_error(type_clash(B,A,F,C,H)))
;
H\==C,
!,
E=suspension(_,_,_,_,Z,A1),
setarg(2,E,removed),
M=[Z|B1],
term_variables(A1,B1),
arg(3,E,V),
( var(V) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',W),
W=[_|X],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',X),
( X=[Y|_] ->
setarg(3,Y,_)
;
true
)
;
V=[_,_|X],
setarg(2,V,X),
( X=[Y|_] ->
setarg(3,Y,V)
;
true
)
),
detach_static_type_check_var___3(M,E),
( var(D) ->
true
;
D=suspension(_,_,_,_,S,T),
setarg(2,D,removed),
N=[S|U],
term_variables(T,U),
arg(3,D,O),
( var(O) ->
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',P),
P=[_|Q],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',Q),
( Q=[R|_] ->
setarg(3,R,_)
;
true
)
;
O=[_,_|Q],
setarg(2,O,Q),
( Q=[R|_] ->
setarg(3,R,O)
;
true
)
),
detach_static_type_check_var___3(N,D)
),
throw(type_error(type_clash(B,F,A,H,C)))
).
static_type_check_var___3__0(A,B,C,D) :-
( var(D) ->
D=suspension(F,active,_,A,B,C),
E=[B|G],
term_variables(C,G),
'chr gen_id'(F),
nb_getval('$chr_store_global_list_chr_translate____static_type_check_var___3',H),
I=[D|H],
b_setval('$chr_store_global_list_chr_translate____static_type_check_var___3',I),
( H=[J|_] ->
setarg(3,J,I)
;
true
),
attach_static_type_check_var___3(E,D)
;
setarg(2,D,active)
).
static_atomic_builtin_type_check_var(A,B,C) :-
static_atomic_builtin_type_check_var___3__0(A,B,C,_).
static_atomic_builtin_type_check_var___3__0(_,_,A,B) :-
A==any,
!,
( var(B) ->
true
;
B=suspension(_,_,_,_,H,I),
setarg(2,B,removed),
term_variables(H,C,J),
term_variables(I,J),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E),
E=[_|F],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(C,B)
).
static_atomic_builtin_type_check_var___3__0(A,B,C,D) :-
( 'chr newvia_2'(B,C,I) ->
get_attr(I,chr_translate,J),
J=v(_,_,_,_,_,_,_,_,H,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',H)
),
(
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,F,G),
F==B,
G==C,
!,
( var(D) ->
true
;
D=suspension(_,_,_,_,P,Q),
setarg(2,D,removed),
term_variables(P,K,R),
term_variables(Q,R),
arg(3,D,L),
( var(L) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
M=[_|N],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',N),
( N=[O|_] ->
setarg(3,O,_)
;
true
)
;
L=[_,_|N],
setarg(2,L,N),
( N=[O|_] ->
setarg(3,O,L)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(K,D)
)
;
!,
static_atomic_builtin_type_check_var___3__0__0__3(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__0__0__3([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__1(B,C,D,A).
static_atomic_builtin_type_check_var___3__0__0__3([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==C ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__0__0__3(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__0__0__3(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__0(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__1(A,B,C,D).
static_atomic_builtin_type_check_var___3__1(_,A,B,C) :-
B==number,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==float,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__1(A,B,C,D) :-
C==float,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__1__0__5(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__1__0__5([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__8(B,C,D,A).
static_atomic_builtin_type_check_var___3__1__0__5([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==number ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__1__0__5(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__1__0__5(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__1(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__2(A,B,C,D).
static_atomic_builtin_type_check_var___3__2(_,A,B,C) :-
B==number,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==int,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__2(A,B,C,D) :-
C==int,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__2__0__7(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__2__0__7([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__5(B,C,D,A).
static_atomic_builtin_type_check_var___3__2__0__7([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==number ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__2__0__7(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__2__0__7(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__2(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__3(A,B,C,D).
static_atomic_builtin_type_check_var___3__3(_,A,B,C) :-
B==number,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==natural,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__3(A,B,C,D) :-
C==natural,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__3__0__9(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__3__0__9([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__5(B,C,D,A).
static_atomic_builtin_type_check_var___3__3__0__9([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==number ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__3__0__9(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__3__0__9(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__3(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__4(A,B,C,D).
static_atomic_builtin_type_check_var___3__4(_,A,B,C) :-
B==number,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==dense_int,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__4(A,B,C,D) :-
C==dense_int,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__4__0__11(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__4__0__11([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__6(B,C,D,A).
static_atomic_builtin_type_check_var___3__4__0__11([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==number ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__4__0__11(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__4__0__11(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__4(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__5(A,B,C,D).
static_atomic_builtin_type_check_var___3__5(_,A,B,C) :-
B==int,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==natural,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__5(A,B,C,D) :-
C==natural,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__5__0__13(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__5__0__13([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__7(B,C,D,A).
static_atomic_builtin_type_check_var___3__5__0__13([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==int ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__5__0__13(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__5__0__13(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__5(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__6(A,B,C,D).
static_atomic_builtin_type_check_var___3__6(_,A,B,C) :-
B==int,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==dense_int,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__6(A,B,C,D) :-
C==dense_int,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__6__0__15(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__6__0__15([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__7(B,C,D,A).
static_atomic_builtin_type_check_var___3__6__0__15([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==int ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__6__0__15(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__6__0__15(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__6(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__7(A,B,C,D).
static_atomic_builtin_type_check_var___3__7(_,A,B,C) :-
B==natural,
( 'chr newvia_1'(A,H) ->
get_attr(H,chr_translate,I),
I=v(_,_,_,_,_,_,_,_,G,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',G)
),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,E,F),
E==A,
F==dense_int,
!,
( var(C) ->
true
;
C=suspension(_,_,_,_,O,P),
setarg(2,C,removed),
term_variables(O,J,Q),
term_variables(P,Q),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(J,C)
).
static_atomic_builtin_type_check_var___3__7(A,B,C,D) :-
C==dense_int,
( 'chr newvia_1'(B,F) ->
get_attr(F,chr_translate,G),
G=v(_,_,_,_,_,_,_,_,E,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',E)
),
!,
static_atomic_builtin_type_check_var___3__7__0__17(E,A,B,C,D).
static_atomic_builtin_type_check_var___3__7__0__17([],B,C,D,A) :-
static_atomic_builtin_type_check_var___3__8(B,C,D,A).
static_atomic_builtin_type_check_var___3__7__0__17([G|H],A,B,C,D) :-
( G=suspension(_,active,_,_,E,F),
E==B,
F==natural ->
G=suspension(_,_,_,_,N,O),
setarg(2,G,removed),
term_variables(N,I,P),
term_variables(O,P),
arg(3,G,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(I,G),
static_atomic_builtin_type_check_var___3__7__0__17(H,A,B,C,D)
;
static_atomic_builtin_type_check_var___3__7__0__17(H,A,B,C,D)
).
static_atomic_builtin_type_check_var___3__7(A,B,C,D) :-
static_atomic_builtin_type_check_var___3__8(A,B,C,D).
static_atomic_builtin_type_check_var___3__8(A,B,C,D) :-
( 'chr newvia_1'(B,J) ->
get_attr(J,chr_translate,K),
K=v(_,_,_,_,_,_,_,_,I,_,_)
;
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',I)
),
'chr sbag_member'(E,I),
E=suspension(_,active,_,F,G,H),
G==B,
!,
E=suspension(_,_,_,_,Y,Z),
setarg(2,E,removed),
term_variables(Y,L,A1),
term_variables(Z,A1),
arg(3,E,U),
( var(U) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',V),
V=[_|W],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',W),
( W=[X|_] ->
setarg(3,X,_)
;
true
)
;
U=[_,_|W],
setarg(2,U,W),
( W=[X|_] ->
setarg(3,X,U)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(L,E),
( var(D) ->
true
;
D=suspension(_,_,_,_,R,S),
setarg(2,D,removed),
term_variables(R,M,T),
term_variables(S,T),
arg(3,D,N),
( var(N) ->
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',O),
O=[_|P],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',P),
( P=[Q|_] ->
setarg(3,Q,_)
;
true
)
;
N=[_,_|P],
setarg(2,N,P),
( P=[Q|_] ->
setarg(3,Q,N)
;
true
)
),
detach_static_atomic_builtin_type_check_var___3(M,D)
),
throw(type_error(type_clash(B,A,F,C,H))).
static_atomic_builtin_type_check_var___3__8(A,B,C,D) :-
( var(D) ->
D=suspension(F,active,_,A,B,C),
term_variables(B,E,G),
term_variables(C,G),
'chr gen_id'(F),
nb_getval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',H),
I=[D|H],
b_setval('$chr_store_global_list_chr_translate____static_atomic_builtin_type_check_var___3',I),
( H=[J|_] ->
setarg(3,J,I)
;
true
),
attach_static_atomic_builtin_type_check_var___3(E,D)
;
setarg(2,D,active)
).
dynamic_type_check :-
dynamic_type_check___0__0(_).
dynamic_type_check___0__0(A) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',B),
!,
A=suspension(C,not_stored_yet,t,_),
'chr gen_id'(C),
dynamic_type_check___0__0__0__1(B,A).
dynamic_type_check___0__0__0__1([],A) :-
dynamic_type_check___0__1(A).
dynamic_type_check___0__0__0__1([D|E],A) :-
( D=suspension(_,active,_,_,_,B,C),
I=t(231,D,A),
'$novel_production'(D,I),
'$novel_production'(A,I) ->
'$extend_history'(A,I),
arg(2,A,J),
setarg(2,A,active),
( J==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',K),
L=[A|K],
b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',L),
( K=[M|_] ->
setarg(4,M,L)
;
true
)
;
true
),
copy_term_nat(B-C,F-G),
maplist(dynamic_type_check_clause(F),G,H),
dynamic_type_check_clauses(H),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
dynamic_type_check___0__0__0__1(E,A)
;
true
)
;
dynamic_type_check___0__0__0__1(E,A)
).
dynamic_type_check___0__0(A) :-
A=suspension(B,not_stored_yet,t,_),
'chr gen_id'(B),
dynamic_type_check___0__1(A).
dynamic_type_check___0__1(A) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',B),
!,
dynamic_type_check___0__1__0__2(B,A).
dynamic_type_check___0__1__0__2([],A) :-
dynamic_type_check___0__2(A).
dynamic_type_check___0__1__0__2([D|E],A) :-
( D=suspension(_,active,_,_,_,B,C),
I=t(232,D,A),
'$novel_production'(D,I),
'$novel_production'(A,I) ->
'$extend_history'(A,I),
arg(2,A,J),
setarg(2,A,active),
( J==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',K),
L=[A|K],
b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',L),
( K=[M|_] ->
setarg(4,M,L)
;
true
)
;
true
),
copy_term_nat(B-C,F-G),
dynamic_type_check_alias_clause(F,G,H),
dynamic_type_check_clauses([H]),
( A=suspension(_,active,_,_) ->
setarg(2,A,inactive),
dynamic_type_check___0__1__0__2(E,A)
;
true
)
;
dynamic_type_check___0__1__0__2(E,A)
).
dynamic_type_check___0__1(A) :-
dynamic_type_check___0__2(A).
dynamic_type_check___0__2(A) :-
( var(A) ->
true
;
arg(2,A,J),
setarg(2,A,removed),
( J==not_stored_yet ->
true
;
arg(4,A,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',H),
( H=[I|_] ->
setarg(4,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(4,I,F)
;
true
)
)
)
),
findall(('$dynamic_type_check'(D,E):-C),(atomic_builtin_type(D,E,C);compound_builtin_type(D,E,C,_)),B),
dynamic_type_check_clauses(B).
dynamic_type_check_clauses(A) :-
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
append(A,C,E),
dynamic_type_check_clauses(E).
dynamic_type_check_clauses(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
get_dynamic_type_check_clauses(A) :-
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,C),
!,
setarg(2,B,removed),
arg(3,B,E),
( var(E) ->
nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',F),
F=[_|G],
b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',G),
( G=[H|_] ->
setarg(3,H,_)
;
true
)
;
E=[_,_|G],
setarg(2,E,G),
( G=[H|_] ->
setarg(3,H,E)
;
true
)
),
A=C.
get_dynamic_type_check_clauses([]).
atomic_type(A) :-
atomic_type___1__0(A,_).
atomic_type___1__0(A,B) :-
atomic_builtin_type(A,_,_),
!,
( var(B) ->
true
;
B=suspension(_,_,_,H),
setarg(2,B,removed),
term_variables(H,C),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',E),
E=[_|F],
b_setval('$chr_store_global_list_chr_translate____atomic_type___1',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
detach_atomic_type___1(C,B)
),
A\==any.
atomic_type___1__0(A,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,D,E),
functor(A,G,H),
functor(D,G,H),
!,
( var(B) ->
true
;
B=suspension(_,_,_,N),
setarg(2,B,removed),
term_variables(N,I),
arg(3,B,J),
( var(J) ->
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',K),
K=[_|L],
b_setval('$chr_store_global_list_chr_translate____atomic_type___1',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
detach_atomic_type___1(I,B)
),
maplist(atomic,E).
atomic_type___1__0(A,B) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,D,E),
functor(A,G,H),
functor(D,G,H),
!,
( var(B) ->
true
;
B=suspension(_,_,_,O),
setarg(2,B,removed),
term_variables(O,J),
arg(3,B,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____atomic_type___1',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_atomic_type___1(J,B)
),
atomic(E),
copy_term_nat(D-E,A-I),
atomic_type(I).
atomic_type___1__0(A,B) :-
( var(B) ->
B=suspension(D,active,_,A),
term_variables(A,C),
'chr gen_id'(D),
nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',E),
F=[B|E],
b_setval('$chr_store_global_list_chr_translate____atomic_type___1',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
),
attach_atomic_type___1(C,B)
;
setarg(2,B,active)
).
enumerated_atomic_type(A,B) :-
enumerated_atomic_type___2__0(A,B,_).
enumerated_atomic_type___2__0(A,_,B) :-
atomic_builtin_type(A,_,_),
!,
( var(B) ->
true
;
B=suspension(_,_,_,H,_),
setarg(2,B,removed),
term_variables(H,C),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',E),
E=[_|F],
b_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
detach_enumerated_atomic_type___2(C,B)
),
fail.
enumerated_atomic_type___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_definition___2',G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,E,F),
functor(A,H,I),
functor(E,H,I),
!,
( var(C) ->
true
;
C=suspension(_,_,_,O,_),
setarg(2,C,removed),
term_variables(O,J),
arg(3,C,K),
( var(K) ->
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',L),
L=[_|M],
b_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',M),
( M=[N|_] ->
setarg(3,N,_)
;
true
)
;
K=[_,_|M],
setarg(2,K,M),
( M=[N|_] ->
setarg(3,N,K)
;
true
)
),
detach_enumerated_atomic_type___2(J,C)
),
maplist(atomic,F),
B=F.
enumerated_atomic_type___2__0(A,B,C) :-
nb_getval('$chr_store_global_list_chr_translate____type_alias___2',G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,E,F),
functor(A,H,I),
functor(E,H,I),
!,
( var(C) ->
true
;
C=suspension(_,_,_,P,_),
setarg(2,C,removed),
term_variables(P,K),
arg(3,C,L),
( var(L) ->
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',M),
M=[_|N],
b_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',N),
( N=[O|_] ->
setarg(3,O,_)
;
true
)
;
L=[_,_|N],
setarg(2,L,N),
( N=[O|_] ->
setarg(3,O,L)
;
true
)
),
detach_enumerated_atomic_type___2(K,C)
),
atomic(F),
copy_term_nat(E-F,A-J),
enumerated_atomic_type(J,B).
enumerated_atomic_type___2__0(A,B,C) :-
( var(C) ->
C=suspension(E,active,_,A,B),
term_variables(A,D),
'chr gen_id'(E),
nb_getval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',F),
G=[C|F],
b_setval('$chr_store_global_list_chr_translate____enumerated_atomic_type___2',G),
( F=[H|_] ->
setarg(3,H,G)
;
true
),
attach_enumerated_atomic_type___2(D,C)
;
setarg(2,C,active)
).
stored(A,B,yes) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',Q),
lookup_ht(Q,k(A,B),F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,_,D,E,_),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',P),
lookup_ht(P,k(D,E),H),
'chr sbag_member'(G,H),
G=suspension(_,active,_,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',O),
lookup_ht(O,A,L),
'chr sbag_member'(I,L),
I=suspension(_,active,_,_,J,K),
B<J,
!,
setarg(2,I,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',N),
delete_ht(N,A,I),
M is K-1,
stored(A,B,maybe),
stored_complete(A,J,M).
stored(A,B,yes) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',L),
lookup_ht(L,A,F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,D,E),
B<D,
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',K),
lookup_ht(K,k(A,B),H),
'chr sbag_member'(G,H),
G=suspension(_,active,_,_),
!,
setarg(2,C,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',J),
delete_ht(J,A,C),
I is E-1,
stored(A,B,maybe),
stored_complete(A,D,I).
stored(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',F),
insert_ht(F,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',G),
insert_ht(G,k(A,B,C),D).
stored_completing(A,B,C) :-
ground(A),
ground(B),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',M),
(
(
hash_term(k(A,B,1887087),P),
lookup_ht1(M,P,k(A,B,yes),E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_),
!,
F is B+1,
G is C+1,
stored_completing(A,F,G)
;
hash_term(k(A,B,2007024),O),
lookup_ht1(M,O,k(A,B,maybe),I),
'chr sbag_member'(H,I),
H=suspension(_,active,_,_,_),
!,
J is B+1,
stored_completing(A,J,C)
)
;
hash_term(k(A,B,14209),N),
lookup_ht1(M,N,k(A,B,no),L),
'chr sbag_member'(K,L),
K=suspension(_,active,_,_,_),
!,
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,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',S),
lookup_ht(S,A,H),
'chr sbag_member'(D,H),
D=suspension(_,active,_,_,_,E,F,G,_),
E<B,
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',R),
lookup_ht(R,k(F,G),J),
'chr sbag_member'(I,J),
I=suspension(_,active,_,_,_),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',P),
hash_term(k(A,E,1887087),Q),
lookup_ht1(P,Q,k(A,E,yes),L),
'chr sbag_member'(K,L),
K=suspension(_,active,_,_,_),
!,
setarg(2,K,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',N),
delete_ht(N,A,K),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',O),
delete_ht(O,k(A,E,yes),K),
M is C-1,
stored(A,E,maybe),
stored_complete(A,B,M).
stored_complete___3__0(A,B,C,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',N),
lookup_ht(N,A,G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,E,F),
F=yes,
E<B,
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',M),
lookup_ht(M,k(A,E),I),
'chr sbag_member'(H,I),
H=suspension(_,active,_,_),
!,
setarg(2,D,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',K),
delete_ht(K,A,D),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',L),
delete_ht(L,k(A,E,yes),D),
J is C-1,
stored(A,E,maybe),
stored_complete(A,B,J).
stored_complete___3__0(A,B,0,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',F),
lookup_ht(F,A,D),
!,
C=suspension(E,not_stored_yet,t,A,B,0),
'chr gen_id'(E),
stored_complete___3__0__0__3(D,A,B,0,C).
stored_complete___3__0__0__3([],B,C,D,A) :-
stored_complete___3__1(B,C,D,A).
stored_complete___3__0__0__3([G|I],B,C,D,A) :-
( G=suspension(_,active,_,E,F),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',J),
lookup_ht(J,B,H) ->
stored_complete___3__0__1__3(H,F,G,I,B,C,D,A)
;
stored_complete___3__0__0__3(I,B,C,D,A)
).
stored_complete___3__0__1__3([],_,_,A,C,D,E,B) :-
stored_complete___3__0__0__3(A,C,D,E,B).
stored_complete___3__0__1__3([J|L],G,A,B,D,E,F,C) :-
( J=suspension(_,active,_,_,H,_,I,_,_),
H==D,
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',M),
lookup_ht1(M,I,I,K) ->
stored_complete___3__0__2__3(K,I,J,L,G,A,B,D,E,F,C)
;
stored_complete___3__0__1__3(L,G,A,B,D,E,F,C)
).
stored_complete___3__0__2__3([],_,_,A,H,B,C,E,F,G,D) :-
stored_complete___3__0__1__3(A,H,B,C,E,F,G,D).
stored_complete___3__0__2__3([M|N],J,A,B,I,C,D,F,G,H,E) :-
( M=suspension(_,active,_,_,_,_,K,L,_),
M\==A,
K==J,
O=t(245,M,A,E,C),
'$novel_production'(M,O),
'$novel_production'(A,O),
'$novel_production'(E,O),
'$novel_production'(C,O),
G=<I ->
'$extend_history'(E,O),
arg(2,E,P),
setarg(2,E,active),
( P==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',Q),
insert_ht(Q,F,E)
;
true
),
passive(J,L),
( E=suspension(_,active,_,_,_,_) ->
setarg(2,E,inactive),
stored_complete___3__0__2__3(N,J,A,B,I,C,D,F,G,H,E)
;
true
)
;
stored_complete___3__0__2__3(N,J,A,B,I,C,D,F,G,H,E)
).
stored_complete___3__0(A,B,C,D) :-
D=suspension(E,not_stored_yet,t,A,B,C),
'chr gen_id'(E),
stored_complete___3__1(A,B,C,D).
stored_complete___3__1(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',F),
lookup_ht(F,A,E),
!,
stored_complete___3__1__0__4(E,A,B,C,D).
stored_complete___3__1__0__4([],B,C,D,A) :-
stored_complete___3__2(B,C,D,A).
stored_complete___3__1__0__4([I|J],B,C,D,A) :-
( I=suspension(_,active,_,_,E,F,G,H,_),
E==B,
K=t(254,A,I),
'$novel_production'(A,K),
'$novel_production'(I,K),
F>C ->
'$extend_history'(A,K),
arg(2,A,L),
setarg(2,A,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',M),
insert_ht(M,B,A)
;
true
),
passive(G,H),
( A=suspension(_,active,_,_,_,_) ->
setarg(2,A,inactive),
stored_complete___3__1__0__4(J,B,C,D,A)
;
true
)
;
stored_complete___3__1__0__4(J,B,C,D,A)
).
stored_complete___3__1(A,B,C,D) :-
stored_complete___3__2(A,B,C,D).
stored_complete___3__2(A,_,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',D),
insert_ht(D,A,B)
;
true
).
is_stored(A) :-
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',J),
lookup_ht(J,A,D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,C),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',I),
lookup_ht(I,A,H),
'chr sbag_member'(E,H),
E=suspension(_,active,_,_,F,G),
G=0,
F=<C,
!,
fail.
is_stored(_).
is_finally_stored(A) :-
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',I),
lookup_ht(I,A,D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,C),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',H),
lookup_ht(H,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,_,F,_),
F=<C,
!,
fail.
is_finally_stored(_).
check_all_passive(A,[B|C]) :-
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',F),
lookup_ht(F,k(A,B),E),
'chr sbag_member'(D,E),
D=suspension(_,active,_,_,_),
!,
check_all_passive(A,C).
check_all_passive(A,[]) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',E),
lookup_ht1(E,A,A,D),
'chr sbag_member'(B,D),
B=suspension(_,active,_,_,_,C),
!,
chr_warning(weird_program,'All heads passive in ~@.
This rule never fires. Please check your program.
',[format_rule(C)]).
check_all_passive(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',E),
insert_ht(E,k(A,B),C),
nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',F),
insert_ht(F,A,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) :-
D=suspension(E,active,_,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_global_ground_chr_translate____constraints_code1___3',F),
G=[D|F],
b_setval('$chr_store_global_ground_chr_translate____constraints_code1___3',G),
( F=[H|_] ->
setarg(3,H,G)
;
true
).
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),
add_dummy_location(F,G),
B=[G|H]
;
B=H
),
I=[0],
occurrences_code(A,1,I,J,H,K),
gen_cond_attach_clause(A,J,K,C).
has_active_occurrence(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
has_active_occurrence(A) :-
has_active_occurrence(A,1),
memo_has_active_occurrence(A).
has_active_occurrence(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
B>D,
!,
fail.
has_active_occurrence(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',K),
lookup_ht(K,k(A,B),F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,_,D,E,_),
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',J),
lookup_ht(J,k(D,E),H),
'chr sbag_member'(G,H),
G=suspension(_,active,_,_,_),
!,
I is B+1,
has_active_occurrence(A,I).
has_active_occurrence(_,_).
memo_has_active_occurrence(A) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',D),
insert_ht(D,A,B).
use_auxiliary_predicate(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
use_auxiliary_predicate(A) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',D),
insert_ht(D,A,B).
use_auxiliary_predicate(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
use_auxiliary_predicate(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',F),
insert_ht(F,k(A,B),C).
is_used_auxiliary_predicate(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
is_used_auxiliary_predicate(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!.
is_used_auxiliary_predicate(_) :-
fail.
is_used_auxiliary_predicate(A,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
is_used_auxiliary_predicate(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
is_used_auxiliary_predicate(_,_) :-
fail.
use_auxiliary_module(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
use_auxiliary_module(A) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',D),
insert_ht(D,A,B).
is_used_auxiliary_module(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
is_used_auxiliary_module(_) :-
fail.
occurrences_code(A,B,C,D,E,F) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',J),
lookup_ht(J,A,I),
'chr sbag_member'(G,I),
G=suspension(_,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) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',B1),
lookup_ht(B1,k(A,B),J),
'chr sbag_member'(G,J),
G=suspension(_,active,_,_,_,_,H,I,_),
(
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',C1),
lookup_ht(C1,k(H,I),L),
'chr sbag_member'(K,L),
K=suspension(_,active,_,_,_),
!,
( named_history(H,_,_) ->
does_use_history(A,B)
;
true
),
D=C,
E=F
;
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',A1),
lookup_ht1(A1,H,H,O),
'chr sbag_member'(M,O),
M=suspension(_,active,_,_,_,N),
!,
N=pragma(rule(P,Q,_,_),ids(R,S),_,_,_),
( select2(I,T,R,P,U,V) ->
D=C,
head1_code(T,I,V,U,N,A,B,C,E,F)
;
( select2(I,W,S,Q,X,Y) ->
head2_code(W,I,Y,X,N,A,B,C,E,Z),
( should_skip_to_next_id(A,B) ->
inc_id(C,D),
( unconditional_occurrence(A,B) ->
Z=F
;
gen_alloc_inc_clause(A,B,C,Z,F)
)
;
D=C,
Z=F
)
)
)
).
occurrence_code(A,B,_,_,_,_) :-
chr_error(internal,'occurrence_code/6: missing information to compile ~w:~w
',[A,B]).
functional_dependency(A,B,C,D) :-
B>1,
nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',M),
lookup_ht(M,A,G),
'chr sbag_member'(E,G),
E=suspension(_,active,_,_,F),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',L),
lookup_ht(L,A,K),
'chr sbag_member'(H,K),
H=suspension(_,active,_,_,_,I,J,_,_),
J=B,
F>I,
!,
functional_dependency(A,1,C,D).
functional_dependency(A,B,C,D) :-
E=suspension(F,active,A,B,C,D),
'chr gen_id'(F),
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',G),
insert_ht(G,A,E),
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',H),
insert_ht(H,k(A,B),E).
get_functional_dependency(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',J),
lookup_ht(J,A,I),
'chr sbag_member'(E,I),
E=suspension(_,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,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!.
initial_call_pattern___1__0(A,B) :-
B=suspension(C,active,t,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',D),
insert_ht(D,A,B),
call_pattern(A),
( B=suspension(_,active,_,_) ->
setarg(2,B,inactive),
initial_call_pattern___1__1(A,B)
;
true
).
initial_call_pattern___1__1(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',D),
lookup_ht(D,A,C),
!,
initial_call_pattern___1__1__0__4(C,A,B).
initial_call_pattern___1__1__0__4([],B,A) :-
initial_call_pattern___1__2(B,A).
initial_call_pattern___1__1__0__4([E|G],B,A) :-
( E=suspension(_,active,_,C,D),
C==B,
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',F) ->
initial_call_pattern___1__1__1__4(F,D,E,G,B,A)
;
initial_call_pattern___1__1__0__4(G,B,A)
).
initial_call_pattern___1__1__1__4([],_,_,A,C,B) :-
initial_call_pattern___1__1__0__4(A,C,B).
initial_call_pattern___1__1__1__4([G|H],E,A,B,D,C) :-
( G=suspension(_,active,_,F),
I=t(298,C,A,G),
'$novel_production'(C,I),
'$novel_production'(A,I) ->
'$extend_history'(C,I),
setarg(2,C,active),
ai_observation_schedule_new_calls(F,E),
( C=suspension(_,active,_,_) ->
setarg(2,C,inactive),
initial_call_pattern___1__1__1__4(H,E,A,B,D,C)
;
true
)
;
initial_call_pattern___1__1__1__4(H,E,A,B,D,C)
).
initial_call_pattern___1__1(A,B) :-
initial_call_pattern___1__2(A,B).
initial_call_pattern___1__2(_,A) :-
setarg(2,A,active).
call_pattern(A) :-
call_pattern___1__0(A,_).
call_pattern___1__0(A,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
call_pattern___1__0(A,B) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',D),
insert_ht(D,A,B),
call_pattern_worker(A),
( B=suspension(_,active,_) ->
setarg(2,B,inactive),
call_pattern___1__1(A,B)
;
true
).
call_pattern___1__1(_,A) :-
setarg(2,A,active).
call_pattern_worker(odom([],A)) :-
!,
final_answer_pattern(odom([],A),odom([],A)).
call_pattern_worker(odom([B|C],A)) :-
!,
D=odom(B,A),
depends_on_goal(odom([B|C],A),D),
call_pattern(D).
call_pattern_worker(odom((B;C),A)) :-
!,
D=odom((B;C),A),
E=odom([],A),
final_answer_pattern(D,E),
F=odom(B,A),
G=odom(C,A),
call_pattern(F),
call_pattern(G),
depends_on_as(D,F,G).
call_pattern_worker(odom(builtin,A)) :-
!,
ord_empty(B),
final_answer_pattern(odom(builtin,A),odom([],B)).
call_pattern_worker(odom(occ(B,C),A)) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',G),
lookup_ht(G,B,F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
C>E,
!,
final_answer_pattern(odom(occ(B,C),A),odom([],A)).
call_pattern_worker(odom(A,B)) :-
A=_/_,
!,
C=odom(occ(A,1),B),
call_pattern(C),
depends_on(odom(A,B),C).
call_pattern_worker(odom(occ(B,C),A)) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',W),
lookup_ht(W,k(B,C),H),
'chr sbag_member'(D,H),
D=suspension(_,active,_,_,_,_,E,F,G),
(
(
is_passive(E,F),
!,
I is C+1,
J=odom(occ(B,I),A),
call_pattern(J),
final_answer_pattern(odom(occ(B,C),A),odom([],A)),
depends_on(odom(occ(B,C),A),J)
;
G=simplification,
\+is_passive(E,F),
!,
ai_observation_memo_simplification_rest_heads(B,C,K),
ai_observation_observe_set(A,K,L),
ai_observation_memo_abstract_goal(E,M),
call_pattern(odom(M,L)),
N is C+1,
O=odom(occ(B,N),A),
call_pattern(O),
depends_on_as(odom(occ(B,C),A),odom(M,L),O),
final_answer_pattern(odom(occ(B,C),A),odom([],A))
)
;
G=propagation,
\+is_passive(E,F),
!,
ai_observation_memo_propagation_rest_heads(B,C,P),
ai_observation_observe_set(A,P,Q),
ord_add_element(Q,B,R),
ai_observation_memo_abstract_goal(E,S),
call_pattern(odom(S,R)),
( ord_memberchk(B,Q) ->
T=no
;
T=yes
),
U is C+1,
V=odom(occ(B,U),A),
call_pattern(V),
depends_on_ap(odom(occ(B,C),A),odom(S,R),V,T)
).
call_pattern_worker(A) :-
chr_error(internal,'AI observation analysis: unexpected abstract state ~w
',[A]).
final_answer_pattern(A,B) :-
final_answer_pattern___2__0(A,B,_).
final_answer_pattern___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',G),
lookup_ht(G,A,F),
(
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
ai_observation_leq(B,E),
!
;
!,
final_answer_pattern___2__0__0__2(F,A,B,C)
).
final_answer_pattern___2__0__0__2([],B,C,A) :-
final_answer_pattern___2__1(B,C,A).
final_answer_pattern___2__0__0__2([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
D==A,
ai_observation_leq(E,B) ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',H),
delete_ht(H,A,F),
final_answer_pattern___2__0__0__2(G,A,B,C)
;
final_answer_pattern___2__0__0__2(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) :-
nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',F),
lookup_ht(F,A,D),
!,
C=suspension(E,not_stored_yet,t,A,B),
'chr gen_id'(E),
final_answer_pattern___2__1__0__3(D,A,B,C).
final_answer_pattern___2__1__0__3([],B,C,A) :-
final_answer_pattern___2__2(B,C,A).
final_answer_pattern___2__1__0__3([E|G],B,C,A) :-
( E=suspension(_,active,_,D),
D==B,
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',F) ->
final_answer_pattern___2__1__1__3(F,E,G,B,C,A)
;
final_answer_pattern___2__1__0__3(G,B,C,A)
).
final_answer_pattern___2__1__1__3([],_,A,C,D,B) :-
final_answer_pattern___2__1__0__3(A,C,D,B).
final_answer_pattern___2__1__1__3([G|H],A,B,D,E,C) :-
( G=suspension(_,active,_,F),
I=t(298,A,C,G),
'$novel_production'(A,I),
'$novel_production'(C,I) ->
'$extend_history'(C,I),
arg(2,C,J),
setarg(2,C,active),
( J==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',K),
insert_ht(K,D,C)
;
true
),
ai_observation_schedule_new_calls(F,E),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
final_answer_pattern___2__1__1__3(H,A,B,D,E,C)
;
true
)
;
final_answer_pattern___2__1__1__3(H,A,B,D,E,C)
).
final_answer_pattern___2__1(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
final_answer_pattern___2__2(A,B,C).
final_answer_pattern___2__2(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__2__0__4(D,A,B,C).
final_answer_pattern___2__2__0__4([],B,C,A) :-
final_answer_pattern___2__3(B,C,A).
final_answer_pattern___2__2__0__4([F|G],B,C,A) :-
( F=suspension(_,active,_,D,E),
E==B,
H=t(300,F,A),
'$novel_production'(F,H),
'$novel_production'(A,H) ->
'$extend_history'(A,H),
arg(2,A,I),
setarg(2,A,active),
( I==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',J),
insert_ht(J,B,A)
;
true
),
final_answer_pattern(D,C),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
final_answer_pattern___2__2__0__4(G,B,C,A)
;
true
)
;
final_answer_pattern___2__2__0__4(G,B,C,A)
).
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_multi_hash_chr_translate____depends_on_goal___2-2',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__3__0__5(D,A,B,C).
final_answer_pattern___2__3__0__5([],B,C,A) :-
final_answer_pattern___2__4(B,C,A).
final_answer_pattern___2__3__0__5([F|H],B,C,A) :-
( F=suspension(_,active,_,D,E),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',I),
lookup_ht(I,D,G) ->
final_answer_pattern___2__3__1__5(G,D,F,H,B,C,A)
;
final_answer_pattern___2__3__0__5(H,B,C,A)
).
final_answer_pattern___2__3__1__5([],_,_,A,C,D,B) :-
final_answer_pattern___2__3__0__5(A,C,D,B).
final_answer_pattern___2__3__1__5([I|J],E,A,F,B,C,D) :-
( I=suspension(_,active,_,G,H),
G==E ->
setarg(2,I,removed),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',K),
delete_ht(K,E,I),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',L),
delete_ht(L,H,I),
final_answer_pattern___2__3__1__5(J,E,A,F,B,C,D)
;
final_answer_pattern___2__3__1__5(J,E,A,F,B,C,D)
).
final_answer_pattern___2__3(A,B,C) :-
final_answer_pattern___2__4(A,B,C).
final_answer_pattern___2__4(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__4__0__6(D,A,B,C).
final_answer_pattern___2__4__0__6([],B,C,A) :-
final_answer_pattern___2__5(B,C,A).
final_answer_pattern___2__4__0__6([F|G],B,C,A) :-
( F=suspension(_,active,_,D,E),
E==B,
K=t(305,F,A),
'$novel_production'(F,K),
'$novel_production'(A,K) ->
'$extend_history'(A,K),
arg(2,A,L),
setarg(2,A,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',M),
insert_ht(M,B,A)
;
true
),
D=odom([_|H],_),
C=odom([],I),
J=odom(H,I),
call_pattern(J),
depends_on(D,J),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
final_answer_pattern___2__4__0__6(G,B,C,A)
;
true
)
;
final_answer_pattern___2__4__0__6(G,B,C,A)
).
final_answer_pattern___2__4(A,B,C) :-
final_answer_pattern___2__5(A,B,C).
final_answer_pattern___2__5(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__5__0__7(D,A,B,C).
final_answer_pattern___2__5__0__7([],B,C,A) :-
final_answer_pattern___2__6(B,C,A).
final_answer_pattern___2__5__0__7([G|I],B,C,A) :-
( G=suspension(_,active,_,D,E,F),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',J),
lookup_ht(J,F,H) ->
final_answer_pattern___2__5__1__7(H,D,F,G,I,B,C,A)
;
final_answer_pattern___2__5__0__7(I,B,C,A)
).
final_answer_pattern___2__5__1__7([],_,_,_,A,C,D,B) :-
final_answer_pattern___2__5__0__7(A,C,D,B).
final_answer_pattern___2__5__1__7([J|K],F,G,A,B,D,E,C) :-
( J=suspension(_,active,_,H,I),
H==G,
M=t(312,A,C,J),
'$novel_production'(A,M),
'$novel_production'(C,M),
'$novel_production'(J,M) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',O),
insert_ht(O,D,C)
;
true
),
ai_observation_lub(E,I,L),
final_answer_pattern(F,L),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
final_answer_pattern___2__5__1__7(K,F,G,A,B,D,E,C)
;
true
)
;
final_answer_pattern___2__5__1__7(K,F,G,A,B,D,E,C)
).
final_answer_pattern___2__5(A,B,C) :-
final_answer_pattern___2__6(A,B,C).
final_answer_pattern___2__6(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__6__0__8(D,A,B,C).
final_answer_pattern___2__6__0__8([],B,C,A) :-
final_answer_pattern___2__7(B,C,A).
final_answer_pattern___2__6__0__8([G|I],B,C,A) :-
( G=suspension(_,active,_,D,E,F),
F==B,
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',J),
lookup_ht(J,E,H) ->
final_answer_pattern___2__6__1__8(H,D,E,G,I,B,C,A)
;
final_answer_pattern___2__6__0__8(I,B,C,A)
).
final_answer_pattern___2__6__1__8([],_,_,_,A,C,D,B) :-
final_answer_pattern___2__6__0__8(A,C,D,B).
final_answer_pattern___2__6__1__8([J|K],F,G,A,B,D,E,C) :-
( J=suspension(_,active,_,H,I),
H==G,
M=t(312,A,J,C),
'$novel_production'(A,M),
'$novel_production'(J,M),
'$novel_production'(C,M) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',O),
insert_ht(O,D,C)
;
true
),
ai_observation_lub(I,E,L),
final_answer_pattern(F,L),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
final_answer_pattern___2__6__1__8(K,F,G,A,B,D,E,C)
;
true
)
;
final_answer_pattern___2__6__1__8(K,F,G,A,B,D,E,C)
).
final_answer_pattern___2__6(A,B,C) :-
final_answer_pattern___2__7(A,B,C).
final_answer_pattern___2__7(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__7__0__9(D,A,B,C).
final_answer_pattern___2__7__0__9([],B,C,A) :-
final_answer_pattern___2__8(B,C,A).
final_answer_pattern___2__7__0__9([F|G],B,C,A) :-
( F=suspension(_,active,_,D,_,E,_),
E==B,
H=t(320,F,A),
'$novel_production'(F,H),
'$novel_production'(A,H) ->
'$extend_history'(A,H),
arg(2,A,I),
setarg(2,A,active),
( I==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',J),
insert_ht(J,B,A)
;
true
),
final_answer_pattern(D,C),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
final_answer_pattern___2__7__0__9(G,B,C,A)
;
true
)
;
final_answer_pattern___2__7__0__9(G,B,C,A)
).
final_answer_pattern___2__7(A,B,C) :-
final_answer_pattern___2__8(A,B,C).
final_answer_pattern___2__8(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__8__0__10(D,A,B,C).
final_answer_pattern___2__8__0__10([],B,C,A) :-
final_answer_pattern___2__9(B,C,A).
final_answer_pattern___2__8__0__10([H|J],B,C,A) :-
( H=suspension(_,active,_,D,E,F,G),
E==B,
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',K),
lookup_ht(K,F,I) ->
final_answer_pattern___2__8__1__10(I,D,F,G,H,J,B,C,A)
;
final_answer_pattern___2__8__0__10(J,B,C,A)
).
final_answer_pattern___2__8__1__10([],_,_,_,_,A,C,D,B) :-
final_answer_pattern___2__8__0__10(A,C,D,B).
final_answer_pattern___2__8__1__10([K|L],F,G,H,A,B,D,E,C) :-
( K=suspension(_,active,_,I,J),
I==G,
S=t(321,A,C,K),
'$novel_production'(A,S),
'$novel_production'(C,S),
'$novel_production'(K,S) ->
'$extend_history'(C,S),
arg(2,C,T),
setarg(2,C,active),
( T==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',U),
insert_ht(U,D,C)
;
true
),
F=odom(occ(M,N),_),
( ai_observation_is_observed(E,M) ->
ai_observed_internal(M,N)
;
ai_not_observed_internal(M,N)
),
( H==yes ->
E=odom([],O),
ord_del_element(O,M,P),
Q=odom([],P)
;
Q=E
),
ai_observation_lub(Q,J,R),
final_answer_pattern(F,R),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
final_answer_pattern___2__8__1__10(L,F,G,H,A,B,D,E,C)
;
true
)
;
final_answer_pattern___2__8__1__10(L,F,G,H,A,B,D,E,C)
).
final_answer_pattern___2__8(A,B,C) :-
final_answer_pattern___2__9(A,B,C).
final_answer_pattern___2__9(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',E),
lookup_ht(E,A,D),
!,
final_answer_pattern___2__9__0__11(D,A,B,C).
final_answer_pattern___2__9__0__11([],B,C,A) :-
final_answer_pattern___2__10(B,C,A).
final_answer_pattern___2__9__0__11([H|J],B,C,A) :-
( H=suspension(_,active,_,D,E,F,G),
F==B,
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',K),
lookup_ht(K,E,I) ->
final_answer_pattern___2__9__1__11(I,D,E,G,H,J,B,C,A)
;
final_answer_pattern___2__9__0__11(J,B,C,A)
).
final_answer_pattern___2__9__1__11([],_,_,_,_,A,C,D,B) :-
final_answer_pattern___2__9__0__11(A,C,D,B).
final_answer_pattern___2__9__1__11([K|L],F,G,H,A,B,D,E,C) :-
( K=suspension(_,active,_,I,J),
I==G,
S=t(321,A,K,C),
'$novel_production'(A,S),
'$novel_production'(K,S),
'$novel_production'(C,S) ->
'$extend_history'(C,S),
arg(2,C,T),
setarg(2,C,active),
( T==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',U),
insert_ht(U,D,C)
;
true
),
F=odom(occ(M,N),_),
( ai_observation_is_observed(J,M) ->
ai_observed_internal(M,N)
;
ai_not_observed_internal(M,N)
),
( H==yes ->
J=odom([],O),
ord_del_element(O,M,P),
Q=odom([],P)
;
Q=J
),
ai_observation_lub(Q,E,R),
final_answer_pattern(F,R),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
final_answer_pattern___2__9__1__11(L,F,G,H,A,B,D,E,C)
;
true
)
;
final_answer_pattern___2__9__1__11(L,F,G,H,A,B,D,E,C)
).
final_answer_pattern___2__9(A,B,C) :-
final_answer_pattern___2__10(A,B,C).
final_answer_pattern___2__10(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',D),
insert_ht(D,A,B)
;
true
).
abstract_constraints(A) :-
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',C),
(
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!
;
!,
abstract_constraints___1__0__0__2(C,A)
).
abstract_constraints___1__0__0__2([],A) :-
abstract_constraints___1__1(A).
abstract_constraints___1__0__0__2([B|C],A) :-
( B=suspension(_,active,_,_) ->
setarg(2,B,removed),
arg(3,B,D),
( var(D) ->
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',E),
E=[_|F],
b_setval('$chr_store_global_ground_chr_translate____abstract_constraints___1',F),
( F=[G|_] ->
setarg(3,G,_)
;
true
)
;
D=[_,_|F],
setarg(2,D,F),
( F=[G|_] ->
setarg(3,G,D)
;
true
)
),
abstract_constraints___1__0__0__2(C,A)
;
abstract_constraints___1__0__0__2(C,A)
).
abstract_constraints(A) :-
abstract_constraints___1__1(A).
abstract_constraints___1__1(A) :-
B=suspension(C,active,_,A),
'chr gen_id'(C),
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',D),
E=[B|D],
b_setval('$chr_store_global_ground_chr_translate____abstract_constraints___1',E),
( D=[F|_] ->
setarg(3,F,E)
;
true
).
depends_on(A,B) :-
depends_on___2__0(A,B,_).
depends_on___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',F),
lookup_ht(F,B,D),
!,
C=suspension(E,not_stored_yet,t,A,B),
'chr gen_id'(E),
depends_on___2__0__0__1(D,A,B,C).
depends_on___2__0__0__1([],B,C,A) :-
depends_on___2__1(B,C,A).
depends_on___2__0__0__1([F|G],B,C,A) :-
( F=suspension(_,active,_,D,E),
D==C,
H=t(300,A,F),
'$novel_production'(A,H),
'$novel_production'(F,H) ->
'$extend_history'(A,H),
arg(2,A,I),
setarg(2,A,active),
( I==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',J),
insert_ht(J,B,A),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',K),
insert_ht(K,C,A)
;
true
),
final_answer_pattern(B,E),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
depends_on___2__0__0__1(G,B,C,A)
;
true
)
;
depends_on___2__0__0__1(G,B,C,A)
).
depends_on___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
depends_on___2__1(A,B,C).
depends_on___2__1(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',F),
insert_ht(F,B,C)
;
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) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',H),
lookup_ht(H,C,F),
!,
E=suspension(G,not_stored_yet,t,A,B,C,D),
'chr gen_id'(G),
depends_on_ap___4__0__0__1(F,A,B,C,D,E).
depends_on_ap___4__0__0__1([],B,C,D,E,A) :-
depends_on_ap___4__1(B,C,D,E,A).
depends_on_ap___4__0__0__1([H|I],B,C,D,E,A) :-
( H=suspension(_,active,_,F,G),
F==D,
J=t(320,A,H),
'$novel_production'(A,J),
'$novel_production'(H,J) ->
'$extend_history'(A,J),
arg(2,A,K),
setarg(2,A,active),
( K==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',L),
insert_ht(L,C,A),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',M),
insert_ht(M,D,A)
;
true
),
final_answer_pattern(B,G),
( A=suspension(_,active,_,_,_,_,_) ->
setarg(2,A,inactive),
depends_on_ap___4__0__0__1(I,B,C,D,E,A)
;
true
)
;
depends_on_ap___4__0__0__1(I,B,C,D,E,A)
).
depends_on_ap___4__0(A,B,C,D,E) :-
E=suspension(F,not_stored_yet,t,A,B,C,D),
'chr gen_id'(F),
depends_on_ap___4__1(A,B,C,D,E).
depends_on_ap___4__1(A,B,C,D,E) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',G),
lookup_ht(G,B,F),
!,
depends_on_ap___4__1__0__2(F,A,B,C,D,E).
depends_on_ap___4__1__0__2([],B,C,D,E,A) :-
depends_on_ap___4__2(B,C,D,E,A).
depends_on_ap___4__1__0__2([H|J],B,C,D,E,A) :-
( H=suspension(_,active,_,F,G),
F==C,
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',K),
lookup_ht(K,D,I) ->
depends_on_ap___4__1__1__2(I,G,H,J,B,C,D,E,A)
;
depends_on_ap___4__1__0__2(J,B,C,D,E,A)
).
depends_on_ap___4__1__1__2([],_,_,A,C,D,E,F,B) :-
depends_on_ap___4__1__0__2(A,C,D,E,F,B).
depends_on_ap___4__1__1__2([K|L],H,A,B,D,E,F,G,C) :-
( K=suspension(_,active,_,I,J),
K\==A,
I==F,
S=t(321,C,A,K),
'$novel_production'(C,S),
'$novel_production'(A,S),
'$novel_production'(K,S) ->
'$extend_history'(C,S),
arg(2,C,T),
setarg(2,C,active),
( T==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',U),
insert_ht(U,E,C),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',V),
insert_ht(V,F,C)
;
true
),
D=odom(occ(M,N),_),
( ai_observation_is_observed(H,M) ->
ai_observed_internal(M,N)
;
ai_not_observed_internal(M,N)
),
( G==yes ->
H=odom([],O),
ord_del_element(O,M,P),
Q=odom([],P)
;
Q=H
),
ai_observation_lub(Q,J,R),
final_answer_pattern(D,R),
( C=suspension(_,active,_,_,_,_,_) ->
setarg(2,C,inactive),
depends_on_ap___4__1__1__2(L,H,A,B,D,E,F,G,C)
;
true
)
;
depends_on_ap___4__1__1__2(L,H,A,B,D,E,F,G,C)
).
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,B,_,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',F),
insert_ht(F,B,C)
;
true
).
depends_on_goal(A,B) :-
depends_on_goal___2__0(A,B,_).
depends_on_goal___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',E),
lookup_ht(E,A,D),
!,
depends_on_goal___2__0__0__1(D,A,B,C).
depends_on_goal___2__0__0__1([],B,C,A) :-
depends_on_goal___2__1(B,C,A).
depends_on_goal___2__0__0__1([F|G],A,B,C) :-
( F=suspension(_,active,_,D,E),
D==A,
ground(B),
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',L),
lookup_ht(L,B,I),
'chr sbag_member'(H,I),
H=suspension(_,active,_,_,_) ->
setarg(2,F,removed),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',J),
delete_ht(J,A,F),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',K),
delete_ht(K,E,F),
depends_on_goal___2__0__0__1(G,A,B,C)
;
depends_on_goal___2__0__0__1(G,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) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',F),
lookup_ht(F,B,D),
!,
C=suspension(E,not_stored_yet,t,A,B),
'chr gen_id'(E),
depends_on_goal___2__1__0__2(D,A,B,C).
depends_on_goal___2__1__0__2([],B,C,A) :-
depends_on_goal___2__2(B,C,A).
depends_on_goal___2__1__0__2([F|G],B,C,A) :-
( F=suspension(_,active,_,D,E),
D==C,
K=t(305,A,F),
'$novel_production'(A,K),
'$novel_production'(F,K) ->
'$extend_history'(A,K),
arg(2,A,L),
setarg(2,A,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',M),
insert_ht(M,C,A)
;
true
),
B=odom([_|H],_),
E=odom([],I),
J=odom(H,I),
call_pattern(J),
depends_on(B,J),
( A=suspension(_,active,_,_,_) ->
setarg(2,A,inactive),
depends_on_goal___2__1__0__2(G,B,C,A)
;
true
)
;
depends_on_goal___2__1__0__2(G,B,C,A)
).
depends_on_goal___2__1(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
depends_on_goal___2__2(A,B,C).
depends_on_goal___2__2(_,A,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',D),
insert_ht(D,A,B)
;
true
).
ai_observed_internal(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',D),
lookup_ht(D,k(A,B),C),
!,
ai_observed_internal___2__0__0__1(C,A,B).
ai_observed_internal___2__0__0__1([],A,B) :-
ai_observed_internal___2__1(A,B).
ai_observed_internal___2__0__0__1([E|F],A,B) :-
( E=suspension(_,active,_,C,D),
C==A,
D==B ->
setarg(2,E,removed),
arg(3,E,G),
( var(G) ->
nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',H),
H=[_|I],
b_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',I),
( I=[J|_] ->
setarg(3,J,_)
;
true
)
;
G=[_,_|I],
setarg(2,G,I),
( I=[J|_] ->
setarg(3,J,G)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',K),
delete_ht(K,k(A,B),E),
ai_observed_internal___2__0__0__1(F,A,B)
;
ai_observed_internal___2__0__0__1(F,A,B)
).
ai_observed_internal(A,B) :-
ai_observed_internal___2__1(A,B).
ai_observed_internal___2__1(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
ai_observed_internal___2__1(_,_) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',B),
'chr sbag_member'(A,B),
A=suspension(_,active,_),
!.
ai_observed_internal___2__1(A,B) :-
C=suspension(D,active,_,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',H),
insert_ht(H,k(A,B),C).
ai_not_observed_internal(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
ai_not_observed_internal(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
ai_not_observed_internal(A,B) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',D),
'chr sbag_member'(C,D),
C=suspension(_,active,_),
!,
ai_not_observed(A,B).
ai_not_observed_internal(A,B) :-
C=suspension(D,active,_,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',H),
insert_ht(H,k(A,B),C).
ai_not_observed(A,B) :-
ai_not_observed___2__0(A,B,_).
ai_not_observed___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',F),
hash_term(k(A,B,1887087),G),
lookup_ht1(F,G,k(A,B,yes),D),
!,
C=suspension(E,not_stored_yet,A,B),
'chr gen_id'(E),
ai_not_observed___2__0__0__1(D,A,B,C).
ai_not_observed___2__0__0__1([],B,C,A) :-
ai_not_observed___2__1(B,C,A).
ai_not_observed___2__0__0__1([G|H],A,B,C) :-
( G=suspension(_,active,D,E,F),
D==A,
E==B,
F=yes,
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',S),
lookup_ht(S,A,L),
'chr sbag_member'(I,L),
I=suspension(_,active,_,_,J,K),
B<J ->
setarg(2,G,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-1',Q),
delete_ht(Q,A,G),
nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',R),
delete_ht(R,k(A,B,yes),G),
setarg(2,I,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',P),
delete_ht(P,A,I),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',O),
insert_ht(O,k(A,B),C)
;
true
),
M is K-1,
stored(A,B,maybe),
stored_complete(A,J,M),
( C=suspension(_,active,_,_) ->
setarg(2,C,inactive),
ai_not_observed___2__0__0__1(H,A,B,C)
;
true
)
;
ai_not_observed___2__0__0__1(H,A,B,C)
).
ai_not_observed___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,A,B),
'chr gen_id'(D),
ai_not_observed___2__1(A,B,C).
ai_not_observed___2__1(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',E),
insert_ht(E,k(A,B),C)
;
true
).
ai_is_observed(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!,
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) :-
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',G),
lookup_ht(G,B,E),
!,
D=suspension(F,not_stored_yet,t,A,B,C),
'chr gen_id'(F),
depends_on_as___3__0__0__1(E,A,B,C,D).
depends_on_as___3__0__0__1([],B,C,D,A) :-
depends_on_as___3__1(B,C,D,A).
depends_on_as___3__0__0__1([G|I],B,C,D,A) :-
( G=suspension(_,active,_,E,F),
E==C,
nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',J),
lookup_ht(J,D,H) ->
depends_on_as___3__0__1__1(H,F,G,I,B,C,D,A)
;
depends_on_as___3__0__0__1(I,B,C,D,A)
).
depends_on_as___3__0__1__1([],_,_,A,C,D,E,B) :-
depends_on_as___3__0__0__1(A,C,D,E,B).
depends_on_as___3__0__1__1([J|K],G,A,B,D,E,F,C) :-
( J=suspension(_,active,_,H,I),
J\==A,
H==F,
M=t(312,C,A,J),
'$novel_production'(C,M),
'$novel_production'(A,M),
'$novel_production'(J,M) ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',O),
insert_ht(O,F,C),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',P),
insert_ht(P,E,C)
;
true
),
ai_observation_lub(G,I,L),
final_answer_pattern(D,L),
( C=suspension(_,active,_,_,_,_) ->
setarg(2,C,inactive),
depends_on_as___3__0__1__1(K,G,A,B,D,E,F,C)
;
true
)
;
depends_on_as___3__0__1__1(K,G,A,B,D,E,F,C)
).
depends_on_as___3__0(A,B,C,D) :-
D=suspension(E,not_stored_yet,t,A,B,C),
'chr gen_id'(E),
depends_on_as___3__1(A,B,C,D).
depends_on_as___3__1(_,A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',E),
insert_ht(E,B,C),
nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',F),
insert_ht(F,A,C)
;
true
).
ai_observation_gather_results :-
ai_observation_gather_results___0__0(_).
ai_observation_gather_results___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',B),
!,
ai_observation_gather_results___0__0__0__1(B,A).
ai_observation_gather_results___0__0__0__1([],A) :-
ai_observation_gather_results___0__1(A).
ai_observation_gather_results___0__0__0__1([D|E],A) :-
( D=suspension(_,active,_,B,C) ->
setarg(2,D,removed),
arg(3,D,F),
( var(F) ->
nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',G),
G=[_|H],
b_setval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',H),
( H=[I|_] ->
setarg(3,I,_)
;
true
)
;
F=[_,_|H],
setarg(2,F,H),
( H=[I|_] ->
setarg(3,I,F)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',J),
delete_ht(J,k(B,C),D),
ai_observation_gather_results___0__0__0__1(E,A)
;
ai_observation_gather_results___0__0__0__1(E,A)
).
ai_observation_gather_results___0__0(A) :-
ai_observation_gather_results___0__1(A).
ai_observation_gather_results___0__1(A) :-
nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',B),
!,
A=suspension(C,not_stored_yet,_),
'chr gen_id'(C),
ai_observation_gather_results___0__1__0__2(B,A).
ai_observation_gather_results___0__1__0__2([],A) :-
ai_observation_gather_results___0__2(A).
ai_observation_gather_results___0__1__0__2([D|E],A) :-
( D=suspension(_,active,_,B,C) ->
setarg(2,D,removed),
arg(3,D,J),
( var(J) ->
nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',K),
K=[_|L],
b_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',L),
( L=[M|_] ->
setarg(3,M,_)
;
true
)
;
J=[_,_|L],
setarg(2,J,L),
( L=[M|_] ->
setarg(3,M,J)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',N),
delete_ht(N,k(B,C),D),
arg(2,A,F),
setarg(2,A,active),
( F==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',G),
H=[A|G],
b_setval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',H),
( G=[I|_] ->
setarg(3,I,H)
;
true
)
;
true
),
ai_not_observed(B,C),
( A=suspension(_,active,_) ->
setarg(2,A,inactive),
ai_observation_gather_results___0__1__0__2(E,A)
;
true
)
;
ai_observation_gather_results___0__1__0__2(E,A)
).
ai_observation_gather_results___0__1(A) :-
A=suspension(B,not_stored_yet,_),
'chr gen_id'(B),
ai_observation_gather_results___0__2(A).
ai_observation_gather_results___0__2(A) :-
( var(A) ->
true
;
arg(2,A,F),
setarg(2,A,removed),
( F==not_stored_yet ->
true
;
arg(3,A,B),
( var(B) ->
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',C),
C=[_|D],
b_setval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',D),
( D=[E|_] ->
setarg(3,E,_)
;
true
)
;
B=[_,_|D],
setarg(2,B,D),
( D=[E|_] ->
setarg(3,E,B)
;
true
)
)
)
).
ai_observation_memo_simplification_rest_heads(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
C=E.
ai_observation_memo_simplification_rest_heads(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',V),
lookup_ht(V,k(A,B),G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,_,E,F,_),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',U),
lookup_ht1(U,E,E,J),
'chr sbag_member'(H,J),
H=suspension(_,active,_,_,_,I),
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',M),
'chr sbag_member'(K,M),
K=suspension(_,active,_,L),
!,
I=pragma(rule(N,O,_,_),ids(P,_),_,_,_),
once(select2(F,_,P,N,_,Q)),
ai_observation_abstract_constraints(Q,L,R),
ai_observation_abstract_constraints(O,L,S),
append(R,S,T),
sort(T,C),
ai_observation_memoed_simplification_rest_heads(A,B,C).
ai_observation_memo_simplification_rest_heads(_,_,_) :-
fail.
ai_observation_memoed_simplification_rest_heads(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',F),
insert_ht(F,k(A,B),D).
ai_observation_memo_propagation_rest_heads(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
C=E.
ai_observation_memo_propagation_rest_heads(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',V),
lookup_ht(V,k(A,B),G),
'chr sbag_member'(D,G),
D=suspension(_,active,_,_,_,_,E,F,_),
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',U),
lookup_ht1(U,E,E,J),
'chr sbag_member'(H,J),
H=suspension(_,active,_,_,_,I),
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',M),
'chr sbag_member'(K,M),
K=suspension(_,active,_,L),
!,
I=pragma(rule(N,O,_,_),ids(_,P),_,_,_),
once(select2(F,_,P,O,_,Q)),
ai_observation_abstract_constraints(Q,L,R),
ai_observation_abstract_constraints(N,L,S),
append(R,S,T),
sort(T,C),
ai_observation_memoed_propagation_rest_heads(A,B,C).
ai_observation_memo_propagation_rest_heads(_,_,_) :-
fail.
ai_observation_memoed_propagation_rest_heads(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',F),
insert_ht(F,k(A,B),D).
ai_observation_memoed_abstract_goal(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',E),
insert_ht(E,A,C).
ai_observation_memo_abstract_goal(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,D),
!,
B=D.
ai_observation_memo_abstract_goal(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',N),
lookup_ht1(N,A,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,_,D),
nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',H),
'chr sbag_member'(F,H),
F=suspension(_,active,_,G),
!,
D=pragma(rule(I,J,K,L),_,_,_,_),
ai_observation_abstract_goal_(I,J,K,L,G,M),
B=M,
ai_observation_memoed_abstract_goal(A,M).
ai_observation_memo_abstract_goal(A,B) :-
C=suspension(D,active,_,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
).
partial_wake_analysis :-
partial_wake_analysis___0__0(_).
partial_wake_analysis___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',B),
!,
A=suspension(C,not_stored_yet,t,_),
'chr gen_id'(C),
partial_wake_analysis___0__0__0__1(B,A).
partial_wake_analysis___0__0__0__1([],A) :-
partial_wake_analysis___0__1(A).
partial_wake_analysis___0__0__0__1([F|H],A) :-
( F=suspension(_,active,_,_,B,_,C,D,E),
nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',I),
lookup_ht(I,B,G) ->
partial_wake_analysis___0__0__1__1(G,B,C,D,E,F,H,A)
;
partial_wake_analysis___0__0__0__1(H,A)
).
partial_wake_analysis___0__0__1__1([],_,_,_,_,_,A,B) :-
partial_wake_analysis___0__0__0__1(A,B).
partial_wake_analysis___0__0__1__1([J|L],D,E,F,G,A,B,C) :-
( J=suspension(_,active,_,_,H,I),
H==D,
nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',M),
lookup_ht1(M,E,E,K) ->
partial_wake_analysis___0__0__2__1(K,I,J,L,D,E,F,G,A,B,C)
;
partial_wake_analysis___0__0__1__1(L,D,E,F,G,A,B,C)
).
partial_wake_analysis___0__0__2__1([],_,_,A,E,F,G,H,B,C,D) :-
partial_wake_analysis___0__0__1__1(A,E,F,G,H,B,C,D).
partial_wake_analysis___0__0__2__1([M|N],J,A,B,F,G,H,I,C,D,E) :-
( M=suspension(_,active,_,_,K,L),
K==G,
U=t(325,E,C,M,A),
'$novel_production'(E,U),
'$novel_production'(C,U),
'$novel_production'(M,U),
'$novel_production'(A,U) ->
'$extend_history'(E,U),
arg(2,E,V),
setarg(2,E,active),
( V==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',W),
X=[E|W],
b_setval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',X),
( W=[Y|_] ->
setarg(4,Y,X)
;
true
)
;
true
),
L=pragma(rule(O,P,Q,_),_,_,_,_),
( is_passive(G,H) ->
true
;
( I==simplification ->
select(R,O,_),
R=..[_|S],
term_variables(Q,T),
partial_wake_args(S,J,T,F)
)
;
select(R,P,_),
R=..[_|S],
term_variables(Q,T),
partial_wake_args(S,J,T,F)
),
( E=suspension(_,active,_,_) ->
setarg(2,E,inactive),
partial_wake_analysis___0__0__2__1(N,J,A,B,F,G,H,I,C,D,E)
;
true
)
;
partial_wake_analysis___0__0__2__1(N,J,A,B,F,G,H,I,C,D,E)
).
partial_wake_analysis___0__0(A) :-
A=suspension(B,not_stored_yet,t,_),
'chr gen_id'(B),
partial_wake_analysis___0__1(A).
partial_wake_analysis___0__1(A) :-
arg(2,A,B),
setarg(2,A,active),
( B==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',C),
D=[A|C],
b_setval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',D),
( C=[E|_] ->
setarg(4,E,D)
;
true
)
;
true
).
no_partial_wake(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!.
no_partial_wake(A) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',D),
insert_ht(D,A,B).
wakes_partially(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!,
fail.
wakes_partially(_).
phase_end(A) :-
phase_end___1__0(A,_).
phase_end___1__0(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',E),
lookup_ht(E,A,C),
!,
B=suspension(D,not_stored_yet,A),
'chr gen_id'(D),
phase_end___1__0__0__1(C,A,B).
phase_end___1__0__0__1([],B,A) :-
phase_end___1__1(B,A).
phase_end___1__0__0__1([E|F],A,B) :-
( E=suspension(_,active,C,D),
C==A ->
setarg(2,E,removed),
nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',I),
delete_ht(I,A,E),
arg(2,B,G),
setarg(2,B,active),
( G==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',H),
insert_ht(H,A,B)
;
true
),
call(D),
( B=suspension(_,active,_) ->
setarg(2,B,inactive),
phase_end___1__0__0__1(F,A,B)
;
true
)
;
phase_end___1__0__0__1(F,A,B)
).
phase_end___1__0(A,B) :-
B=suspension(C,not_stored_yet,A),
'chr gen_id'(C),
phase_end___1__1(A,B).
phase_end___1__1(A,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',D),
insert_ht(D,A,B)
;
true
).
delay_phase_end(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',E),
lookup_ht(E,A,D),
'chr sbag_member'(C,D),
C=suspension(_,active,_),
!,
call(B).
delay_phase_end(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',E),
insert_ht(E,A,C).
does_use_history(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
does_use_history(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',E),
insert_ht(E,A,C),
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',F),
insert_ht(F,k(A,B),C).
uses_history(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!.
uses_history(_) :-
fail.
novel_production_call(A,B,C,D) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(E,F),
E=suspension(_,active,_,_),
!,
D=C.
novel_production_call(_,_,_,true).
does_use_field(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
does_use_field(A,B) :-
C=suspension(D,active,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',E),
insert_ht(E,k(A,B),C).
uses_field(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
uses_field(_,_) :-
fail.
uses_state(A,B) :-
uses_state___2__0(A,B,_).
uses_state___2__0(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_),
!.
uses_state___2__0(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',D),
!,
C=suspension(E,not_stored_yet,A,B),
'chr gen_id'(E),
uses_state___2__0__0__3(D,A,B,C).
uses_state___2__0__0__3([],B,C,A) :-
uses_state___2__1(B,C,A).
uses_state___2__0__0__3([D|F],B,C,A) :-
( D=suspension(_,active,_),
nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',G),
lookup_ht(G,k(B,C),E) ->
uses_state___2__0__1__3(E,D,F,B,C,A)
;
uses_state___2__0__0__3(F,B,C,A)
).
uses_state___2__0__1__3([],_,A,C,D,B) :-
uses_state___2__0__0__3(A,C,D,B).
uses_state___2__0__1__3([J|K],A,E,B,C,D) :-
( J=suspension(_,active,_,F,G,H,_,I),
F==B,
G==C ->
setarg(2,J,removed),
arg(3,J,N),
( var(N) ->
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',O),
O=[_|P],
b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',P),
( P=[Q|_] ->
setarg(3,Q,_)
;
true
)
;
N=[_,_|P],
setarg(2,N,P),
( P=[Q|_] ->
setarg(3,Q,N)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',R),
delete_ht(R,k(B,C),J),
arg(2,D,L),
setarg(2,D,active),
( L==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',M),
insert_ht(M,k(B,C),D)
;
true
),
I=H,
( D=suspension(_,active,_,_) ->
setarg(2,D,inactive),
uses_state___2__0__1__3(K,A,E,B,C,D)
;
true
)
;
uses_state___2__0__1__3(K,A,E,B,C,D)
).
uses_state___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,A,B),
'chr gen_id'(D),
uses_state___2__1(A,B,C).
uses_state___2__1(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',E),
insert_ht(E,k(A,B),C)
;
true
).
if_used_state(A,B,C,D,E) :-
nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',G),
'chr sbag_member'(F,G),
F=suspension(_,active,_),
(
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',J),
lookup_ht(J,k(A,B),I),
'chr sbag_member'(H,I),
H=suspension(_,active,_,_),
!,
E=C
;
!,
E=D
).
if_used_state(A,B,C,D,E) :-
F=suspension(G,active,_,A,B,C,D,E),
'chr gen_id'(G),
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',H),
I=[F|H],
b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',I),
( H=[J|_] ->
setarg(3,J,I)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',K),
insert_ht(K,k(A,B),F).
used_states_known :-
used_states_known___0__0(_).
used_states_known___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',B),
!,
A=suspension(C,not_stored_yet,_),
'chr gen_id'(C),
used_states_known___0__0__0__1(B,A).
used_states_known___0__0__0__1([],A) :-
used_states_known___0__1(A).
used_states_known___0__0__0__1([F|G],A) :-
( F=suspension(_,active,_,B,C,D,_,E),
ground(B),
ground(C),
nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',S),
lookup_ht(S,k(B,C),I),
'chr sbag_member'(H,I),
H=suspension(_,active,_,_) ->
setarg(2,F,removed),
arg(3,F,N),
( var(N) ->
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',O),
O=[_|P],
b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',P),
( P=[Q|_] ->
setarg(3,Q,_)
;
true
)
;
N=[_,_|P],
setarg(2,N,P),
( P=[Q|_] ->
setarg(3,Q,N)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',R),
delete_ht(R,k(B,C),F),
arg(2,A,J),
setarg(2,A,active),
( J==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',K),
L=[A|K],
b_setval('$chr_store_global_ground_chr_translate____used_states_known___0',L),
( K=[M|_] ->
setarg(3,M,L)
;
true
)
;
true
),
E=D,
( A=suspension(_,active,_) ->
setarg(2,A,inactive),
used_states_known___0__0__0__1(G,A)
;
true
)
;
used_states_known___0__0__0__1(G,A)
).
used_states_known___0__0(A) :-
A=suspension(B,not_stored_yet,_),
'chr gen_id'(B),
used_states_known___0__1(A).
used_states_known___0__1(A) :-
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',B),
!,
used_states_known___0__1__0__2(B,A).
used_states_known___0__1__0__2([],A) :-
used_states_known___0__2(A).
used_states_known___0__1__0__2([F|G],A) :-
( F=suspension(_,active,_,B,C,_,D,E) ->
setarg(2,F,removed),
arg(3,F,L),
( var(L) ->
nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',M),
M=[_|N],
b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',N),
( N=[O|_] ->
setarg(3,O,_)
;
true
)
;
L=[_,_|N],
setarg(2,L,N),
( N=[O|_] ->
setarg(3,O,L)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',P),
delete_ht(P,k(B,C),F),
arg(2,A,H),
setarg(2,A,active),
( H==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',I),
J=[A|I],
b_setval('$chr_store_global_ground_chr_translate____used_states_known___0',J),
( I=[K|_] ->
setarg(3,K,J)
;
true
)
;
true
),
E=D,
( A=suspension(_,active,_) ->
setarg(2,A,inactive),
used_states_known___0__1__0__2(G,A)
;
true
)
;
used_states_known___0__1__0__2(G,A)
).
used_states_known___0__1(A) :-
used_states_known___0__2(A).
used_states_known___0__2(A) :-
arg(2,A,B),
setarg(2,A,active),
( B==not_stored_yet ->
nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',C),
D=[A|C],
b_setval('$chr_store_global_ground_chr_translate____used_states_known___0',D),
( C=[E|_] ->
setarg(3,E,D)
;
true
)
;
true
).
stored_assertion(A) :-
B=suspension(C,active,A),
'chr gen_id'(C),
nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',D),
insert_ht(D,A,B).
never_stored_default(A,B) :-
never_stored_default___2__0(A,B,_).
never_stored_default___2__0(A,B,C) :-
nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',D),
!,
C=suspension(E,not_stored_yet,A,B),
'chr gen_id'(E),
never_stored_default___2__0__0__1(D,A,B,C).
never_stored_default___2__0__0__1([],B,C,A) :-
never_stored_default___2__1(B,C,A).
never_stored_default___2__0__0__1([F|I],A,B,C) :-
( F=suspension(_,active,_,D,E),
D=[G|H],
G==A ->
setarg(2,F,removed),
arg(3,F,R),
( var(R) ->
nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',S),
S=[_|T],
b_setval('$chr_store_global_ground_chr_translate____never_stored_rules___2',T),
( T=[U|_] ->
setarg(3,U,_)
;
true
)
;
R=[_,_|T],
setarg(2,R,T),
( T=[U|_] ->
setarg(3,U,R)
;
true
)
),
arg(2,C,P),
setarg(2,C,active),
( P==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',Q),
insert_ht(Q,A,C)
;
true
),
A=J/K,
functor(L,J,K),
inc_rule_count(M),
N=pragma(rule([L],[],true,B),ids([0],[]),[],no,M),
E=[N|O],
never_stored_rules(H,O),
( C=suspension(_,active,_,_) ->
setarg(2,C,inactive),
never_stored_default___2__0__0__1(I,A,B,C)
;
true
)
;
never_stored_default___2__0__0__1(I,A,B,C)
).
never_stored_default___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,A,B),
'chr gen_id'(D),
never_stored_default___2__1(A,B,C).
never_stored_default___2__1(A,_,B) :-
arg(2,B,C),
setarg(2,B,active),
( C==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',D),
insert_ht(D,A,B)
;
true
).
never_stored_rules([],A) :-
!,
A=[].
never_stored_rules([B|C],A) :-
nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',M),
lookup_ht(M,B,F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,E),
!,
B=G/H,
functor(I,G,H),
inc_rule_count(J),
K=pragma(rule([I],[],true,E),ids([0],[]),[],no,J),
A=[K|L],
never_stored_rules(C,L).
never_stored_rules([_|B],A) :-
!,
never_stored_rules(B,A).
never_stored_rules(A,B) :-
C=suspension(D,active,_,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____never_stored_rules___2',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
).
check_storedness_assertion(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',E),
lookup_ht(E,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_),
!,
setarg(2,B,removed),
nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',D),
delete_ht(D,A,B),
( is_stored(A) ->
true
;
chr_warning(assertion_failed,'Constraint ~w is not stored. However, it was asserted to be stored.
',[A])
).
check_storedness_assertion(A) :-
nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',D),
lookup_ht(D,A,C),
'chr sbag_member'(B,C),
B=suspension(_,active,_,_),
!,
( is_finally_stored(A) ->
chr_warning(assertion_failed,'Constraint ~w is stored. However, it was asserted not to be stored.
',[A])
;
( is_stored(A) ->
chr_warning(assertion_failed,'Constraint ~w is temporarily stored. However, it was asserted not to be stored.
',[A])
)
;
true
).
check_storedness_assertion(A) :-
( is_finally_stored(A) ->
chr_warning(assertion_failed,'Constraint ~w is stored. However, it was asserted not to be stored.
',[A])
;
( is_stored(A) ->
chr_warning(assertion_failed,'Constraint ~w is temporarily stored. However, it was asserted not to be stored.
',[A])
)
;
true
).
continuation_occurrence(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',F),
insert_ht(F,k(A,B),D).
get_success_continuation_occurrence(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
C=E.
get_success_continuation_occurrence(A,B,_) :-
chr_error(internal,'Success continuation not found for ~w.
',[A:B]).
skip_to_next_id(A,B) :-
skip_to_next_id___2__0(A,B,_).
skip_to_next_id___2__0(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
skip_to_next_id___2__0(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',F),
lookup_ht(F,k(A,B),D),
!,
C=suspension(E,not_stored_yet,t,A,B),
'chr gen_id'(E),
skip_to_next_id___2__0__0__4(D,A,B,C).
skip_to_next_id___2__0__0__4([],B,C,A) :-
skip_to_next_id___2__1(B,C,A).
skip_to_next_id___2__0__0__4([H|J],B,C,A) :-
( H=suspension(_,active,_,_,D,E,F,G,_),
D==B,
E==C,
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',K),
lookup_ht(K,k(F,G),I) ->
skip_to_next_id___2__0__1__4(I,F,G,H,J,B,C,A)
;
skip_to_next_id___2__0__0__4(J,B,C,A)
).
skip_to_next_id___2__0__1__4([],_,_,_,A,C,D,B) :-
skip_to_next_id___2__0__0__4(A,C,D,B).
skip_to_next_id___2__0__1__4([J|K],F,G,A,B,D,E,C) :-
( J=suspension(_,active,_,H,I),
H==F,
I==G,
M=t(357,A,J,C),
'$novel_production'(A,M),
'$novel_production'(J,M),
'$novel_production'(C,M),
E>1 ->
'$extend_history'(C,M),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',O),
insert_ht(O,k(D,E),C)
;
true
),
L is E-1,
skip_to_next_id(D,L),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
skip_to_next_id___2__0__1__4(K,F,G,A,B,D,E,C)
;
true
)
;
skip_to_next_id___2__0__1__4(K,F,G,A,B,D,E,C)
).
skip_to_next_id___2__0(A,B,C) :-
C=suspension(D,not_stored_yet,t,A,B),
'chr gen_id'(D),
skip_to_next_id___2__1(A,B,C).
skip_to_next_id___2__1(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',E),
lookup_ht(E,k(A,B),D),
!,
skip_to_next_id___2__1__0__5(D,A,B,C).
skip_to_next_id___2__1__0__5([],B,C,A) :-
skip_to_next_id___2__2(B,C,A).
skip_to_next_id___2__1__0__5([G|H],A,B,C) :-
( G=suspension(_,active,D,E,F),
D==A,
E==B,
ground(A),
ground(B),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',Q),
lookup_ht(Q,k(A,B),K),
'chr sbag_member'(I,K),
I=suspension(_,active,_,_,_,_,_,_,J),
J=propagation ->
setarg(2,G,removed),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',P),
delete_ht(P,k(A,B),G),
arg(2,C,N),
setarg(2,C,active),
( N==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',O),
insert_ht(O,k(A,B),C)
;
true
),
occurrence_code_id(A,B,F),
L is B+1,
M is F+1,
set_occurrence_code_id(A,L,M),
( C=suspension(_,active,_,_,_) ->
setarg(2,C,inactive),
skip_to_next_id___2__1__0__5(H,A,B,C)
;
true
)
;
skip_to_next_id___2__1__0__5(H,A,B,C)
).
skip_to_next_id___2__1(A,B,C) :-
skip_to_next_id___2__2(A,B,C).
skip_to_next_id___2__2(A,B,C) :-
arg(2,C,D),
setarg(2,C,active),
( D==not_stored_yet ->
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',E),
insert_ht(E,k(A,B),C)
;
true
).
should_skip_to_next_id(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',E),
lookup_ht(E,k(A,B),D),
'chr sbag_member'(C,D),
C=suspension(_,active,_,_,_),
!.
should_skip_to_next_id(_,_) :-
fail.
bulk_propagation(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
B>=D,
!,
skip_to_next_id(A,B).
bulk_propagation(A,B,C) :-
C=:=B+1,
!,
skip_to_next_id(A,B),
get_max_occurrence(A,D),
E is D+1,
bulk_propagation(A,C,E).
bulk_propagation(A,B,_) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',I),
lookup_ht(I,A,F),
'chr sbag_member'(C,F),
C=suspension(_,active,_,_,_,D,_,_,E),
E=simplification,
D=:=B+1,
!,
skip_to_next_id(A,B),
get_max_occurrence(A,G),
H is G+1,
bulk_propagation(A,D,H).
bulk_propagation(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',I),
lookup_ht(I,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
E>B+1,
!,
G is min(C,E),
H is B+1,
bulk_propagation(A,H,G).
bulk_propagation(A,B,_) :-
skip_to_next_id(A,B),
get_max_occurrence(A,C),
D is C+1,
E is B+1,
bulk_propagation(A,E,D).
set_occurrence_code_id(A,B,C) :-
get_max_occurrence(A,D),
B>D,
!,
occurrence_code_id(A,B,C).
set_occurrence_code_id(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',R),
lookup_ht(R,k(A,B),H),
'chr sbag_member'(D,H),
D=suspension(_,active,_,_,_,_,E,F,G),
(
(
(
nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',T),
lookup_ht(T,k(E,F),J),
'chr sbag_member'(I,J),
I=suspension(_,active,_,_,_),
!,
occurrence_code_id(A,B,C),
K is B+1,
set_occurrence_code_id(A,K,C)
;
G=simplification,
!,
occurrence_code_id(A,B,C),
L is B+1,
set_occurrence_code_id(A,L,C)
)
;
G=propagation,
nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',S),
lookup_ht(S,k(A,B),N),
'chr sbag_member'(M,N),
M=suspension(_,active,_,_,_),
!,
occurrence_code_id(A,B,C),
O is B+1,
P is C+1,
set_occurrence_code_id(A,O,P)
)
;
G=propagation,
!,
occurrence_code_id(A,B,C),
Q is B+1,
set_occurrence_code_id(A,Q,C)
).
set_occurrence_code_id(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',F),
insert_ht(F,k(A,B),D).
occurrence_code_id(A,B,C) :-
D=suspension(E,active,A,B,C),
'chr gen_id'(E),
nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',F),
insert_ht(F,k(A,B),D).
get_occurrence_code_id(A,B,C) :-
nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',G),
lookup_ht(G,k(A,B),F),
'chr sbag_member'(D,F),
D=suspension(_,active,_,_,E),
!,
C=E.
get_occurrence_code_id(A,B,_) :-
( B==0 ->
true
;
format('no occurrence code for ~w!
',[A:B])
).
chr_constants(A,B) :-
C=suspension(D,active,_,A,B),
'chr gen_id'(D),
nb_getval('$chr_store_global_ground_chr_translate____chr_constants___2',E),
F=[C|E],
b_setval('$chr_store_global_ground_chr_translate____chr_constants___2',F),
( E=[G|_] ->
setarg(3,G,F)
;
true
),
nb_getval('$chr_store_multi_hash_chr_translate____chr_constants___2-1',H),
insert_ht(H,A,C).
get_chr_constants(A,B) :-
ground(A),
nb_getval('$chr_store_multi_hash_chr_translate____chr_constants___2-1',F),
lookup_ht(F,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
!,
B=D.
get_chr_constants(A,B) :-
chr_warning(internal,'No constants found for key ~w.
',[A]),
B=[].
add_chr_constant(A,B) :-
nb_getval('$chr_store_multi_hash_chr_translate____chr_constants___2-1',L),
lookup_ht(L,A,E),
'chr sbag_member'(C,E),
C=suspension(_,active,_,_,D),
!,
setarg(2,C,removed),
arg(3,C,G),
( var(G) ->
nb_getval('$chr_store_global_ground_chr_translate____chr_constants___2',H),
H=[_|I],
b_setval('$chr_store_global_ground_chr_translate____chr_constants___2',I),
( I=[J|_] ->
setarg(3,J,_)
;
true
)
;
G=[_,_|I],
setarg(2,G,I),
( I=[J|_] ->
setarg(3,J,G)
;
true
)
),
nb_getval('$chr_store_multi_hash_chr_translate____chr_constants___2-1',K),
delete_ht(K,A,C),
sort([B|D],F),
chr_constants(A,F).
add_chr_constant(A,B) :-
chr_constants(A,[B]).
print_chr_constants :-
print_chr_constants___0__0(_).
print_chr_constants___0__0(A) :-
nb_getval('$chr_store_global_ground_chr_translate____chr_constants___2',B),
!,
A=suspension(C,not_stored_yet,_),
'chr gen_id'(C),
print_chr_constants___0__0__0__1(B,A).
print_chr_constants___0__0__0__1([],A) :-
print_chr_constants___0__1(A).
print_chr_constants___0__0__0__1([D|E],A) :-
( D=suspension(_,active,_,B,C) ->
format(' * chr_constants ~w : ~w.
',[B,C]),
print_chr_constants___0__0__0__1(E,A)
;
print_chr_constants___0__0__0__1(E,A)
).
print_chr_constants___0__0(A) :-
A=suspension(B,not_stored_yet,_),
'chr gen_id'(B),
print_chr_constants___0__1(A).
print_chr_constants___0__1(A) :-
( var(A) ->
true
;
arg(2,A,F),
setarg(2,A,removed),
( F==not_stored_yet ->
true
;
arg(3,A,B),
( var(B) ->
nb_getval('$chr_store_global_ground_chr_translate____print_chr_constants___0',C),
C=[_|D],
b_setval('$chr_store_global_ground_chr_translate____print_chr_constants___0',D),
( D=[E|_] ->
setarg(3,E,_)
;
true
)
;
B=[_,_|D],
setarg(2,B,D),
( D=[E|_] ->
setarg(3,E,B)
;
true
)
)
)
).
end_of_file.