7
8:- module(chr_translate,
9 [ chr_translate/2,
10 chr_translate_line_info/3
11 ]). 12:- use_module(chr_runtime). 13:- style_check(- (discontiguous)). 14:- style_check(-singleton). 15:- style_check(-no_effect). 16:- use_module(library(lists),
17 [ member/2,
18 append/3,
19 reverse/2,
20 permutation/2,
21 last/2
22 ]). 23:- use_module(library(ordsets)). 24:- use_module(library(aggregate)). 25:- use_module(library(apply_macros)). 26:- use_module(library(occurs)). 27:- use_module(library(assoc)). 28:- use_module(library(dialect/hprolog)). 29:- use_module(pairlist). 30:- use_module(a_star). 31:- use_module(listmap). 32:- use_module(clean_code). 33:- use_module(builtins). 34:- use_module(find). 35:- use_module(binomialheap). 36:- use_module(guard_entailment). 37:- use_module(chr_compiler_options). 38:- use_module(chr_compiler_utility). 39:- use_module(chr_compiler_errors). 40:- include(chr_op). 41:- op(1150, fx, chr_type). 42:- op(1150, fx, chr_declaration). 43:- op(1130, xfx, --->). 44:- op(980, fx, +). 45:- op(980, fx, -). 46:- op(980, fx, ?). 47:- op(1150, fx, constraints). 48:- op(1150, fx, chr_constraint). 49format_storetype(multi_store(A)) :- !,
50 maplist(format_storetype, A).
51format_storetype(atomic_constants(A, B, _)) :-
52 format('\t* a trie index on the argument(s) ~w for the ground terms ~w\n',
53 [A, B]).
54format_storetype(ground_constants(A, B, _)) :-
55 format('\t* a trie index on the argument(s) ~w for the ground terms ~w\n',
56 [A, B]).
57format_storetype(A) :-
58 format('\t* ~w\n', [A]).
59get_constraint_arg_type(A, B, E) :-
60 get_constraint_type(A, C),
61 nth1(B, C, D),
62 unalias_type(D, E).
63partial_store(ground_constants(_, _, incomplete)).
64partial_store(atomic_constants(_, _, incomplete)).
65late_allocation_analysis(A) :-
66 ( chr_pp_flag(late_allocation, on)
67 -> maplist(late_allocation, A)
68 ; true
69 ).
70late_allocation(A) :-
71 late_allocation(A, 0).
72late_allocation(A, B) :-
73 allocation_occurrence(A, B), !.
74late_allocation(B, A) :-
75 C is A+1,
76 late_allocation(B, C).
77stored_in_guard_before_next_kept_occurrence(B, A) :-
78 chr_pp_flag(store_in_guards, on),
79 C is A+1,
80 stored_in_guard_lookahead(B, C).
81set_constraint_indices(A) :-
82 set_constraint_indices(A, 1).
83set_constraint_indices([], A) :-
84 B is A-1,
85 max_constraint_index(B).
86set_constraint_indices([A|C], B) :-
87 ( ( chr_pp_flag(debugable, on)
88 ; \+ only_ground_indexed_arguments(A),
89 is_stored(A)
90 ; is_stored(A),
91 get_store_type(A, default)
92 ; get_store_type(A, var_assoc_store(_, _))
93 )
94 -> constraint_index(A, B),
95 D is B+1,
96 set_constraint_indices(C, D)
97 ; set_constraint_indices(C, B)
98 ).
99type_indexed_identifier_structure(A, B) :-
100 type_indexed_identifier_name(A,
101 type_indexed_identifier_struct,
102 C),
103 get_type_indexed_identifier_size(A, D),
104 functor(B, C, D).
105type_indexed_identifier_name(A, C, D) :-
106 ( atom(A)
107 -> B=A
108 ; term_to_atom(A, B)
109 ),
110 atom_concat_list([C, '_', B], D).
111chr_translate(A, B) :-
112 chr_translate_line_info(A, bootstrap, B).
113chr_translate_line_info(A, B, Q) :-
114 chr_banner,
115 restart_after_flattening(A, C),
116 init_chr_pp_flags,
117 chr_source_file(B),
118 partition_clauses(C, D, E, J),
119 chr_compiler_options:sanity_check,
120 dump_code(C),
121 check_declared_constraints(D),
122 generate_show_constraint(D, F, E, G),
123 add_constraints(F),
124 add_rules(G),
125 generate_never_stored_rules(F, H),
126 add_rules(H),
127 append(G, H, I),
128 chr_analysis(I, F, C),
129 time('constraint code generation',
130 chr_translate:constraints_code(F, L)),
131 time('validate store assumptions',
132 chr_translate:validate_store_type_assumptions(F)),
133 phase_end(validate_store_type_assumptions),
134 used_states_known,
135 time('store code generation',
136 chr_translate:store_management_preds(F, K)),
137 insert_declarations(J, O),
138 chr_module_declaration(M),
139 append([K, L, M, [end_of_file]], N),
140 clean_clauses(N, P),
141 append([O, P], Q),
142 dump_code(Q), !.
143chr_analysis(A, C, D) :-
144 maplist(pragma_rule_to_ast_rule, A, B),
145 check_rules(A, B, C),
146 time('type checking', chr_translate:static_type_check(A, B)),
147 collect_constants(A, B, C, D),
148 add_occurrences(A, B),
149 time('functional dependency',
150 chr_translate:functional_dependency_analysis(A)),
151 time('set semantics', chr_translate:set_semantics_rules(A)),
152 time('symmetry analysis', chr_translate:symmetry_analysis(A)),
153 time('guard simplification', chr_translate:guard_simplification),
154 time('late storage', chr_translate:storage_analysis(C)),
155 time(observation, chr_translate:observation_analysis(C)),
156 time('ai observation', chr_translate:ai_observation_analysis(C)),
157 time('late allocation', chr_translate:late_allocation_analysis(C)),
158 partial_wake_analysis,
159 time('assume constraint stores',
160 chr_translate:assume_constraint_stores(C)),
161 time('default constraint indices',
162 chr_translate:set_constraint_indices(C)),
163 time('check storedness assertions',
164 chr_translate:check_storedness_assertions(C)),
165 time('continuation analysis',
166 chr_translate:continuation_analysis(C)).
167store_management_preds(A, J) :-
168 generate_attach_detach_a_constraint_all(A, B),
169 generate_attr_unify_hook(D),
170 generate_attach_increment(C),
171 generate_extra_clauses(A, E),
172 generate_insert_delete_constraints(A, F),
173 generate_attach_code(A, G),
174 generate_counter_code(H),
175 generate_dynamic_type_check_clauses(I),
176 append(
177 [ B,
178 C,
179 D,
180 E,
181 F,
182 G,
183 H,
184 I
185 ],
186 J).
187insert_declarations(B, D) :-
188 findall((:-use_module(chr(A))),
189 ( auxiliary_module(A),
190 is_used_auxiliary_module(A)
191 ),
192 C),
193 append(B, [(:-use_module(chr(chr_runtime)))|C], D).
194auxiliary_module(chr_hashtable_store).
195auxiliary_module(chr_integertable_store).
196auxiliary_module(chr_assoc_store).
197generate_counter_code(A) :-
198 ( chr_pp_flag(store_counter, on)
199 -> 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))]
200 ; A=[]
201 ).
202chr_module_declaration([]) :-
203 tmp_module, !.
204chr_module_declaration(B) :-
205 get_target_module(A),
206 ( A\==chr_translate,
207 chr_pp_flag(toplevel_show_store, on)
208 -> B=[(:-multifile chr:'$chr_module'/1), chr:'$chr_module'(A)]
209 ; B=[]
210 ).
211partition_clauses([], [], [], []).
212partition_clauses([A|M], B, C, E) :-
213 ( parse_rule(A, D)
214 -> B=G,
215 C=[D|H],
216 E=I
217 ; is_declaration(A, F)
218 -> append(F, G, B),
219 C=H,
220 E=I
221 ; is_module_declaration(A, J)
222 -> target_module(J),
223 B=G,
224 C=H,
225 E=[A|I]
226 ; is_type_definition(A)
227 -> B=G,
228 C=H,
229 E=I
230 ; is_chr_declaration(A)
231 -> B=G,
232 C=H,
233 E=I
234 ; A=handler(_)
235 -> chr_warning(deprecated(A),
236 'Backward compatibility: ignoring handler/1 declaration.\n',
237 []),
238 B=G,
239 C=H,
240 E=I
241 ; A=rules(_)
242 -> chr_warning(deprecated(A),
243 'Backward compatibility: ignoring rules/1 declaration.\n',
244 []),
245 B=G,
246 C=H,
247 E=I
248 ; A=option(K, L)
249 -> chr_warning(deprecated(A),
250 'Instead use `:-chr_option(~w,~w).\'\n',
251 [K, L]),
252 handle_option(K, L),
253 B=G,
254 C=H,
255 E=I
256 ; A=(:-chr_option(K, L))
257 -> handle_option(K, L),
258 B=G,
259 C=H,
260 E=I
261 ; A='$chr_compiled_with_version'(_)
262 -> B=G,
263 C=H,
264 E=['$chr_compiled_with_version'(3)|I]
265 ; B=G,
266 C=H,
267 E=[A|I]
268 ),
269 partition_clauses(M, G, H, I).
270'$chr_compiled_with_version'(3).
271is_declaration(A, F) :-
272 ( A=(:-B),
273 B=..[C, D],
274 C==(chr_constraint)
275 -> conj2list(D, E)
276 ; ( A=(:-B)
277 -> B=..[constraints, D]
278 ; A=..[constraints, D]
279 ),
280 conj2list(D, E),
281 chr_warning(deprecated(A),
282 'Instead use :- chr_constraint ~w.\n',
283 [D])
284 ),
285 extract_type_mode(E, F).
([], []).
287extract_type_mode([A/B|C], [A/B|D]) :- !,
288 extract_type_mode(C, D).
289extract_type_mode([A|J], [F|K]) :-
290 ( A= #(B, C)
291 -> functor(B, D, E),
292 extract_annotation(C, D/E)
293 ; A=B,
294 functor(B, D, E)
295 ),
296 F=D/E,
297 B=..[_|G],
298 extract_types_and_modes(G, H, I),
299 assert_constraint_type(F, H),
300 constraint_mode(F, I),
301 extract_type_mode(J, K).
(stored, A) :-
303 stored_assertion(A).
304extract_annotation(default(B), A) :-
305 never_stored_default(A, B).
306extract_types_and_modes([], [], []).
307extract_types_and_modes([A|D], [B|E], [C|F]) :-
308 extract_type_and_mode(A, B, C),
309 extract_types_and_modes(D, E, F).
310extract_type_and_mode(+A, A, +) :- !.
311extract_type_and_mode(?A, A, ?) :- !.
312extract_type_and_mode(-A, A, -) :- !.
313extract_type_and_mode(+, any, +) :- !.
314extract_type_and_mode(?, any, ?) :- !.
315extract_type_and_mode(-, any, -) :- !.
316extract_type_and_mode(A, _, _) :-
317 chr_error(syntax(A),
318 'Illegal mode/type declaration.\n\tCorrect syntax is +type, -type or ?type\n\tor +, - or ?.\n',
319 []).
320is_chr_declaration(A) :-
321 A=(:-chr_declaration B),
322 ( B=(C--->D)
323 -> background_info(C, D)
324 ; B=D
325 -> background_info([D])
326 ).
327is_type_definition(A) :-
328 is_type_definition(A, B),
329 assert_type_definition(B).
330assert_type_definition(typedef(A, B)) :-
331 type_definition(A, B).
332assert_type_definition(alias(A, B)) :-
333 type_alias(A, B).
334is_type_definition(A, E) :-
335 ( A=(:-B)
336 -> true
337 ; A=B
338 ),
339 B=..[chr_type, C],
340 ( C=(F--->D)
341 -> tdisj2list(D, G),
342 E=typedef(F, G)
343 ; C=(H==F)
344 -> E=alias(H, F)
345 ; E=typedef(C, []),
346 chr_warning(syntax,
347 'Empty type definition `~w\'.\nAre you sure you want to declare a phantom type?\n',
348 [A])
349 ).
350tdisj2list(A, B) :-
351 tdisj2list(A, B, []).
352tdisj2list(A, C, F) :-
353 A=(B;D), !,
354 tdisj2list(B, C, E),
355 tdisj2list(D, E, F).
356tdisj2list(A, [A|B], B).
357parse_rule(A, D) :-
358 A= @(C, B), !,
359 rule(B, yes(C), D).
360parse_rule(A, B) :-
361 rule(A, no, B).
362rule(A, E, D) :-
363 A=pragma(G, B), !,
364 ( var(B)
365 -> C=[_]
366 ; conj2list(B, C)
367 ),
368 inc_rule_count(F),
369 D=pragma(H, I, C, E, F),
370 is_rule(G, H, I, D).
371rule(D, B, A) :-
372 inc_rule_count(C),
373 A=pragma(E, F, [], B, C),
374 is_rule(D, E, F, A).
375is_rule(A, H, E, D) :-
376 A= ==>(B, G), !,
377 conj2list(B, C),
378 get_ids(C, F, I, D),
379 E=ids([], F),
380 ( G=(J| K)
381 -> H=rule([], I, J, K)
382 ; H=rule([], I, true, G)
383 ).
384is_rule(A, S, N, K) :-
385 A= <=>(G, B), !,
386 ( B=(C| D)
387 -> E=C,
388 F=D
389 ; E=true,
390 F=B
391 ),
392 ( G= \(H, I)
393 -> conj2list(H, J),
394 conj2list(I, L),
395 get_ids(J, P, Q, 0, M, K),
396 get_ids(L, O, R, M, _, K),
397 N=ids(O, P)
398 ; conj2list(G, L),
399 Q=[],
400 get_ids(L, O, R, K),
401 N=ids(O, [])
402 ),
403 S=rule(R, Q, E, F).
404get_ids(A, B, C, D) :-
405 get_ids(A, B, C, 0, _, D).
406get_ids([], [], [], A, A, _).
407get_ids([B|F], [A|G], [C|H], A, J, E) :-
408 ( B= #(C, D)
409 -> ( var(D)
410 -> D=A
411 ; check_direct_pragma(D, A, E)
412 )
413 ; C=B
414 ),
415 I is A+1,
416 get_ids(F, G, H, I, J, E).
417check_direct_pragma(passive, C, A) :- !,
418 A=pragma(_, _, _, _, B),
419 passive(B, C).
420check_direct_pragma(A, _, C) :-
421 ( direct_pragma(B),
422 atom_concat(A, _, B)
423 -> chr_warning(problem_pragma(A, C),
424 'completed `~w\' to `~w\'\n',
425 [A, B])
426 ; chr_warning(unsupported_pragma(A, C), '', [])
427 ).
428direct_pragma(passive).
429is_module_declaration((:-module(A)), A).
430is_module_declaration((:-module(A, _)), A).
431add_constraints([]).
432add_constraints([A|D]) :-
433 max_occurrence(A, 0),
434 A=_/B,
435 length(C, B),
436 set_elems(C, ?),
437 constraint_mode(A, C),
438 add_constraints(D).
439add_rules([]).
440add_rules([A|C]) :-
441 A=pragma(_, _, _, _, B),
442 rule(B, A),
443 add_rules(C).
444check_declared_constraints(A) :-
445 tree_set_empty(B),
446 check_declared_constraints(A, B).
447check_declared_constraints([], _).
448check_declared_constraints([A|C], B) :-
449 ( tree_set_memberchk(A, B)
450 -> chr_error(syntax(A),
451 'Constraint multiply defined: ~w.\n\tRemove redundant declaration!\n',
452 [A])
453 ; true
454 ),
455 tree_set_add(B, A, D),
456 check_declared_constraints(C, D).
457check_rules(B, C, A) :-
458 maplist(check_rule(A), B, C).
459check_rule(C, A, B) :-
460 A=pragma(_, _, D, _, _),
461 check_ast_rule_indexing(B, A),
462 check_ast_trivial_propagation_rule(B, A),
463 check_ast_head_constraints(B, C, A),
464 check_pragmas(D, A).
465check_ast_trivial_propagation_rule(A, D) :-
466 A=ast_rule(B, _, _, C, _),
467 ( B=propagation(_),
468 C==[]
469 -> chr_warning(weird_program,
470 'Ignoring propagation rule with empty body: ~@.\n\t\n',
471 [format_rule(D)]),
472 set_rule_passive(D)
473 ; true
474 ).
475set_rule_passive(A) :-
476 A=pragma(_, _, _, _, B),
477 set_all_passive(B).
478check_trivial_propagation_rule(A) :-
479 A=pragma(B, _, _, _, C),
480 ( B=rule([], _, _, true)
481 -> chr_warning(weird_program,
482 'Ignoring propagation rule with empty body: ~@.\n\t\n',
483 [format_rule(A)]),
484 set_all_passive(C)
485 ; true
486 ).
487check_ast_head_constraints(ast_rule(A, _, _, _, _), B, C) :-
488 check_ast_head_constraints_(A, B, C).
489check_ast_head_constraints_(simplification(C), A, B) :-
490 maplist(check_ast_head_constraint(A, B), C).
491check_ast_head_constraints_(propagation(C), A, B) :-
492 maplist(check_ast_head_constraint(A, B), C).
493check_ast_head_constraints_(simpagation(C, D), A, B) :-
494 maplist(check_ast_head_constraint(A, B), C),
495 maplist(check_ast_head_constraint(A, B), D).
496check_ast_head_constraint(B, D, chr_constraint(A, _, C)) :-
497 ( memberchk(A, B)
498 -> true
499 ; chr_error(syntax(C),
500 'Undeclared constraint ~w in head of ~@.\n\tConstraint should be one of ~w.\n',
501 [_/_, format_rule(D), B])
502 ).
503check_head_constraints([], _, _).
504check_head_constraints([A|E], D, F) :-
505 functor(A, B, C),
506 ( memberchk(B/C, D)
507 -> check_head_constraints(E, D, F)
508 ; chr_error(syntax(A),
509 'Undeclared constraint ~w in head of ~@.\n\tConstraint should be one of ~w.\n',
510 [B/C, format_rule(F), D])
511 ).
512check_pragmas([], _).
513check_pragmas([A|C], B) :-
514 check_pragma(A, B),
515 check_pragmas(C, B).
516check_pragma(A, B) :-
517 var(A), !,
518 chr_error(syntax(A),
519 'Invalid pragma ~w in ~@.\n\tPragma should not be a variable!\n',
520 [A, format_rule(B)]).
521check_pragma(passive(B), A) :- !,
522 A=pragma(_, ids(C, D), _, _, E),
523 ( memberchk_eq(B, C)
524 -> true
525 ; memberchk_eq(B, D)
526 -> true
527 ; chr_error(syntax(B),
528 'Invalid identifier ~w in pragma passive in ~@.\n',
529 [B, format_rule(A)])
530 ),
531 passive(E, B).
532check_pragma(mpassive(B), A) :- !,
533 A=pragma(_, _, _, _, C),
534 chr_warning(experimental,
535 'Experimental pragma ~w. Use with care!\n',
536 [mpassive(B)]),
537 maplist(passive(C), B).
538check_pragma(A, B) :-
539 A=already_in_heads, !,
540 chr_warning(unsupported_pragma(A, B),
541 'Termination and correctness may be affected.\n',
542 []).
543check_pragma(A, B) :-
544 A=already_in_head(_), !,
545 chr_warning(unsupported_pragma(A, B),
546 'Termination and correctness may be affected.\n',
547 []).
548check_pragma(A, B) :-
549 A=no_history, !,
550 chr_warning(experimental,
551 'Experimental pragma no_history. Use with care!\n',
552 []),
553 B=pragma(_, _, _, _, C),
554 no_history(C).
555check_pragma(A, B) :-
556 A=history(D, F), !,
557 B=pragma(_, ids(C, G), _, _, E),
558 chr_warning(experimental,
559 'Experimental pragma ~w. Use with care!\n',
560 [A]),
561 ( C\==[]
562 -> chr_error(syntax(A),
563 'Pragma history only implemented for propagation rules.\n',
564 [])
565 ; \+ atom(D)
566 -> chr_error(syntax(A),
567 'Illegal argument for pragma history: ~w is not an atom (rule number ~w).\n',
568 [D, E])
569 ; \+ is_set(F)
570 -> chr_error(syntax(A),
571 'Illegal argument for pragma history: ~w is not a set (rule number ~w).\n',
572 [F, E])
573 ; check_history_pragma_ids(F, C, G)
574 -> history(E, D, F)
575 ; chr_error(syntax(A),
576 'Invalid identifier(s) in pragma ~w of rule number ~w.\n',
577 [A, E])
578 ).
579check_pragma(A, B) :-
580 A=line_number(D), !,
581 B=pragma(_, _, _, _, C),
582 line_number(C, D).
583check_history_pragma_ids([], _, _).
584check_history_pragma_ids([A|D], C, B) :-
585 ( memberchk_eq(A, B)
586 ; memberchk_eq(A, C)
587 ),
588 check_history_pragma_ids(D, C, B).
589check_pragma(A, B) :-
590 chr_error(syntax(A),
591 'Unknown pragma ~w in ~@.\n',
592 [A, format_rule(B)]).
593test_named_history_id_pairs(_, [], _, []).
594test_named_history_id_pairs(A, [B|E], C, [D|F]) :-
595 test_named_history_id_pair(A, B, C, D),
596 test_named_history_id_pairs(A, E, C, F).
597format_rule(A) :-
598 A=pragma(_, _, _, B, D),
599 ( B=yes(C)
600 -> write('rule '),
601 write(C)
602 ; write('rule number '),
603 write(D)
604 ),
605 get_line_number(D, E),
606 write(' (line '),
607 write(E),
608 write(')').
609check_ast_rule_indexing(A, H) :-
610 A=ast_rule(B, D, _, _, _),
611 tree_set_empty(C),
612 ast_head_variables(B, C, E),
613 ast_remove_anti_monotonic_guards(D, E, F),
614 ast_term_list_variables(F, C, G),
615 check_ast_head_indexing(B, G),
616 ( chr_pp_flag(term_indexing, on)
617 -> H=pragma(I, _, _, _, _),
618 I=rule(J, K, L, _),
619 term_variables(J-K, M),
620 remove_anti_monotonic_guards(L, M, N),
621 term_variables(N, P),
622 append(J, K, O),
623 check_specs_indexing(O, P, _)
624 ; true
625 ).
626check_ast_head_indexing(simplification(A), B) :-
627 check_ast_indexing(A, B).
628check_ast_head_indexing(propagation(A), B) :-
629 check_ast_indexing(A, B).
630check_ast_head_indexing(simpagation(C, A), B) :-
631 ast_constraint_list_variables(A, B, D),
632 check_ast_indexing(C, D),
633 ast_constraint_list_variables(C, B, E),
634 check_ast_indexing(A, E).
635check_rule_indexing(A) :-
636 A=pragma(B, _, _, _, _),
637 B=rule(C, D, E, _),
638 term_variables(C-D, F),
639 remove_anti_monotonic_guards(E, F, G),
640 check_indexing(C, G-D),
641 check_indexing(D, G-C),
642 ( chr_pp_flag(term_indexing, on)
643 -> term_variables(G, I),
644 append(C, D, H),
645 check_specs_indexing(H, I, _)
646 ; true
647 ).
648remove_anti_monotonic_guards(A, C, E) :-
649 conj2list(A, B),
650 remove_anti_monotonic_guard_list(B, C, D),
651 list2conj(D, E).
652remove_anti_monotonic_guard_list([], _, []).
653remove_anti_monotonic_guard_list([A|F], C, D) :-
654 ( A=var(B),
655 memberchk_eq(B, C)
656 -> D=E
657 ; D=[A|E]
658 ),
659 remove_anti_monotonic_guard_list(F, C, E).
660ast_remove_anti_monotonic_guards([], _, []).
661ast_remove_anti_monotonic_guards([A|F], C, D) :-
662 ( A=compound(var, 1, [B], _),
663 ast_var_memberchk(B, C)
664 -> D=E
665 ; D=[A|E]
666 ),
667 ast_remove_anti_monotonic_guards(F, C, E).
668check_ast_indexing([], _).
669check_ast_indexing([A|B], C) :-
670 A=chr_constraint(E, D, _),
671 ast_constraint_list_variables(B, C, F),
672 check_ast_indexing(D, 1, E, F),
673 ast_constraint_variables(A, C, G),
674 check_ast_indexing(B, G).
675check_ast_indexing([], _, _, _).
676check_ast_indexing([C|D], B, A, E) :-
677 ( is_indexed_argument(A, B)
678 -> true
679 ; ast_nonvar(C)
680 -> indexed_argument(A, B)
681 ; ast_term_list_variables(D, E, F),
682 ( ast_var_memberchk(C, F)
683 -> indexed_argument(A, B)
684 ; true
685 )
686 ),
687 G is B+1,
688 ast_term_variables(C, E, H),
689 check_ast_indexing(D, G, A, H).
690check_indexing([], _).
691check_indexing([A|B], C) :-
692 functor(A, E, F),
693 A=..[_|D],
694 term_variables(B-C, G),
695 check_indexing(D, 1, E/F, G),
696 check_indexing(B, [A|C]).
697check_indexing([], _, _, _).
698check_indexing([C|D], B, A, F) :-
699 ( is_indexed_argument(A, B)
700 -> true
701 ; nonvar(C)
702 -> indexed_argument(A, B)
703 ; term_variables(D, E),
704 append(E, F, G),
705 ( memberchk_eq(C, G)
706 -> indexed_argument(A, B)
707 ; true
708 )
709 ),
710 I is B+1,
711 term_variables(C, H),
712 append(H, F, J),
713 check_indexing(D, I, A, J).
714check_specs_indexing([], _, []).
715check_specs_indexing([D|B], C, A) :-
716 A=[F|H],
717 term_variables(B, E, C),
718 check_spec_indexing(D, E, F),
719 term_variables(D, G, C),
720 check_specs_indexing(B, G, H).
721check_spec_indexing(A, F, B) :-
722 functor(A, C, D),
723 B=spec(C, D, G),
724 A=..[_|E],
725 check_args_spec_indexing(E, 1, F, G),
726 indexing_spec(C/D, [G]).
727check_args_spec_indexing([], _, _, []).
728check_args_spec_indexing([C|A], D, B, F) :-
729 term_variables(A, E, B),
730 ( check_arg_spec_indexing(C, D, E, G)
731 -> F=[G|H]
732 ; F=H
733 ),
734 I is D+1,
735 term_variables(C, J, B),
736 check_args_spec_indexing(A, I, J, H).
737check_arg_spec_indexing(A, D, B, C) :-
738 ( var(A)
739 -> memberchk_eq(A, B),
740 C=specinfo(D, any, [])
741 ; functor(A, E, F),
742 C=specinfo(D, E/F, [H]),
743 A=..[_|G],
744 check_args_spec_indexing(G, 1, B, H)
745 ).
746add_occurrences(A, B) :-
747 maplist(add_rule_occurrences, A, B).
748add_rule_occurrences(A, B) :-
749 A=pragma(_, D, _, _, E),
750 B=ast_rule(C, _, _, _, _),
751 add_head_occurrences(C, D, E).
752add_head_occurrences(simplification(B), ids(C, _), A) :-
753 maplist(add_constraint_occurrence(A, simplification),
754 B,
755 C).
756add_head_occurrences(propagation(B), ids(_, C), A) :-
757 maplist(add_constraint_occurrence(A, propagation),
758 B,
759 C).
760add_head_occurrences(simpagation(B, D), ids(C, E), A) :-
761 maplist(add_constraint_occurrence(A, simplification),
762 B,
763 C),
764 maplist(add_constraint_occurrence(A, propagation),
765 D,
766 E).
767add_constraint_occurrence(C, E, A, D) :-
768 A=chr_constraint(B, _, _),
769 new_occurrence(B, C, D, E).
770observation_analysis(A, C, B, E) :-
771 ( all_spawned(A, B)
772 -> true
773 ; var(C)
774 -> spawns_all(A, B)
775 ; C=true
776 -> true
777 ; C=fail
778 -> true
779 ; C=!
780 -> true
781 ; C=(D, F)
782 -> observation_analysis(A, D, B, E),
783 observation_analysis(A, F, B, E)
784 ; C=(D;F)
785 -> observation_analysis(A, D, B, E),
786 observation_analysis(A, F, B, E)
787 ; C=(D->F)
788 -> observation_analysis(A, D, B, E),
789 observation_analysis(A, F, B, E)
790 ; C=(\+G)
791 -> observation_analysis(A, G, B, E)
792 ; functor(C, H, I),
793 memberchk(H/I, E)
794 -> spawns(A, B, H/I)
795 ; C=(_=_)
796 -> spawns_all_triggers(A, B)
797 ; C=(_ is _)
798 -> spawns_all_triggers(A, B)
799 ; builtin_binds_b(C, J)
800 -> ( J==[]
801 -> true
802 ; spawns_all_triggers(A, B)
803 )
804 ; spawns_all(A, B)
805 ).
806is_observed(A, B) :-
807 is_observed(A, B, _),
808 ai_is_observed(A, B).
809is_stored_in_guard(A, B) :-
810 chr_pp_flag(store_in_guards, on),
811 do_is_observed(A, B, guard).
812generate_attach_detach_a_constraint_all([], []).
813generate_attach_detach_a_constraint_all([A|D], F) :-
814 ( ( chr_pp_flag(debugable, on)
815 ; is_stored(A),
816 \+ only_ground_indexed_arguments(A),
817 \+ get_store_type(A, var_assoc_store(_, _))
818 )
819 -> generate_attach_a_constraint(A, B),
820 generate_detach_a_constraint(A, C)
821 ; B=[],
822 C=[]
823 ),
824 generate_attach_detach_a_constraint_all(D, E),
825 append([B, C, E], F).
826generate_attach_a_constraint(A, [B, C]) :-
827 generate_attach_a_constraint_nil(A, B),
828 generate_attach_a_constraint_cons(A, C).
829attach_constraint_atom(A, D, E, B) :-
830 make_name(attach_, A, C),
831 B=..[C, D, E].
832generate_attach_a_constraint_nil(B, A) :-
833 A=(C:-true),
834 attach_constraint_atom(B, [], _, C).
835generate_attach_a_constraint_cons(B, A) :-
836 A=(C:-F),
837 attach_constraint_atom(B, [I|D], E, C),
838 attach_constraint_atom(B, D, E, G),
839 F=(J, L, G),
840 get_max_constraint_index(H),
841 ( H==1
842 -> generate_attach_body_1(B, I, E, J)
843 ; generate_attach_body_n(B, I, E, J)
844 ),
845 chr_pp_flag(solver_events, K),
846 ( K\==none
847 -> _=[[I|_], E],
848 get_target_module(M),
849 use_auxiliary_predicate(run_suspensions),
850 L=clp_events:subscribe(I, K, M, M:'$run_suspensions'([E]))
851 ; L=true
852 ).
853generate_attach_body_1(_, B, D, A) :-
854 get_target_module(C),
855 A=(get_attr(B, C, E)->put_attr(B, C, [D|E]);put_attr(B, C, [D])).
856generate_attach_body_n(A/B, G, D, F) :-
857 chr_pp_flag(experiment, off), !,
858 get_constraint_index(A/B, E),
859 get_max_constraint_index(C),
860 get_target_module(H),
861 add_attr(C, D, E, I, J, K),
862 singleton_attr(C, D, E, L),
863 F=(get_attr(G, H, I)->J, put_attr(G, H, K);put_attr(G, H, L)), !.
864generate_attach_body_n(A/B, G, E, F) :-
865 chr_pp_flag(experiment, on), !,
866 get_constraint_index(A/B, C),
867 or_pattern(C, L),
868 J is C+1,
869 get_max_constraint_index(D),
870 get_target_module(H),
871 singleton_attr(D, E, C, O),
872 F=(get_attr(G, H, I)->arg(1, I, K), arg(J, I, N), M is K\/L, setarg(1, I, M), setarg(J, I, [E|N]);put_attr(G, H, O)), !.
873generate_detach_a_constraint(A, [B, C]) :-
874 generate_detach_a_constraint_nil(A, B),
875 generate_detach_a_constraint_cons(A, C).
876detach_constraint_atom(A, D, E, B) :-
877 make_name(detach_, A, C),
878 B=..[C, D, E].
879generate_detach_a_constraint_nil(B, A) :-
880 A=(C:-true),
881 detach_constraint_atom(B, [], _, C).
882generate_detach_a_constraint_cons(B, A) :-
883 A=(C:-F),
884 detach_constraint_atom(B, [I|D], E, C),
885 detach_constraint_atom(B, D, E, G),
886 F=(J, G),
887 get_max_constraint_index(H),
888 ( H==1
889 -> generate_detach_body_1(B, I, E, J)
890 ; generate_detach_body_n(B, I, E, J)
891 ).
892generate_detach_body_1(_, B, E, A) :-
893 get_target_module(C),
894 A=(get_attr(B, C, D)->'chr sbag_del_element'(D, E, F), (F==[]->del_attr(B, C);put_attr(B, C, F));true).
895generate_detach_body_n(A/B, D, E, G) :-
896 get_constraint_index(A/B, F),
897 get_max_constraint_index(C),
898 rem_attr(C, D, E, F, I, J),
899 get_target_module(H),
900 G=(get_attr(D, H, I)->J;true), !.
901create_indexed_variables_body([], [], [], _, _, _, empty, 0).
902create_indexed_variables_body([J|B], [G|C], [H|D], K, A, F, I, O) :-
903 E is A+1,
904 create_indexed_variables_body(B,
905 C,
906 D,
907 L,
908 E,
909 F,
910 M,
911 P),
912 ( G==(?),
913 is_indexed_argument(F, A)
914 -> ( atomic_type(H)
915 -> I=((var(J)->K=[J|L];K=L), N),
916 ( M==empty
917 -> N=true,
918 L=[]
919 ; N=M
920 )
921 ; M==empty
922 -> I=term_variables(J, K)
923 ; I=(term_variables(J, K, L), M)
924 ),
925 O=P
926 ; G==(-),
927 is_indexed_argument(F, A)
928 -> ( M==empty
929 -> I=(K=[J])
930 ; I=(K=[J|L], M)
931 ),
932 O is P+1
933 ; K=L,
934 I=M,
935 O is P+1
936 ).
937spectermvars(B, A, C, D, F, E) :-
938 spectermvars(A, 1, B, C, D, E, [], F).
939spectermvars([], B, _, _, C, A, A, true) :-
940 B>C, !.
941spectermvars([F|I], C, B, L, M, H, O, A) :-
942 A=(G, P),
943 argspecs(B, C, D, K),
944 merge_argspecs(D, E),
945 arggoal(E, F, G, H, N),
946 J is C+1,
947 spectermvars(I,
948 J,
949 K,
950 L,
951 M,
952 N,
953 O,
954 P).
955argspecs([], _, [], []).
956argspecs([[]|A], B, C, D) :-
957 argspecs(A, B, C, D).
958argspecs([[specinfo(B, D, E)|F]|J], A, C, G) :-
959 ( A==B
960 -> C=[specinfo(B, D, E)|I],
961 ( F=[]
962 -> H=G
963 ; G=[F|H]
964 )
965 ; C=I,
966 G=[[specinfo(B, D, E)|F]|H]
967 ),
968 argspecs(J, A, I, H).
969merge_argspecs(A, C) :-
970 sort(A, B),
971 merge_argspecs_(B, C).
972merge_argspecs_([], []).
973merge_argspecs_([B], A) :- !,
974 A=[B].
975merge_argspecs_([specinfo(A, B, F), specinfo(A, C, G)|D], E) :-
976 ( ( B==any
977 ; C==any
978 )
979 -> merge_argspecs_([specinfo(A, any, [])|D], E)
980 ; B==C
981 -> append(F, G, H),
982 merge_argspecs_([specinfo(A, B, H)|D],
983 E)
984 ; E=[specinfo(A, B, F)|I],
985 merge_argspecs_([specinfo(A, C, G)|D],
986 I)
987 ).
988arggoal(A, E, D, B, C) :-
989 ( A==[]
990 -> B=C,
991 D=true
992 ; A=[specinfo(_, any, _)]
993 -> D=term_variables(E, B, C)
994 ; D=(var(E)->B=[E|C];F),
995 arggoal_cases(A, E, B, C, F)
996 ).
997arggoal_cases([], _, A, B, A=B).
998arggoal_cases([specinfo(_, D, A)|N], I, K, L, B) :-
999 ( A==[]
1000 -> B=C
1001 ; A==[[]]
1002 -> B=C
1003 ; D=E/F
1004 -> B=(H;C),
1005 functor(G, E, F),
1006 G=..[_|J],
1007 H=(I=G->M),
1008 spectermvars(J,
1009 1,
1010 A,
1011 E,
1012 F,
1013 K,
1014 L,
1015 M)
1016 ),
1017 arggoal_cases(N, I, K, L, C).
(A, B) :-
1019 generate_activate_clauses(A, B, C),
1020 generate_remove_clauses(A, C, D),
1021 generate_allocate_clauses(A, D, E),
1022 generate_insert_constraint_internal_clauses(A, E, F),
1023 generate_novel_production(F, G),
1024 generate_extend_history(G, H),
1025 generate_run_suspensions_clauses(A, H, I),
1026 generate_empty_named_history_initialisations(I, J),
1027 J=[].
1028generate_remove_clauses([], A, A).
1029generate_remove_clauses([A|C], B, E) :-
1030 generate_remove_clause(A, B, D),
1031 generate_remove_clauses(C, D, E).
1032remove_constraint_goal(A, E, F, D, C, I, B) :-
1033 uses_state(A, removed),
1034 ( chr_pp_flag(inline_insertremove, off)
1035 -> use_auxiliary_predicate(remove_constraint_internal, A),
1036 B=(H, (G==yes->C;D)),
1037 remove_constraint_atom(A, E, F, G, H)
1038 ; delay_phase_end(validate_store_type_assumptions,
1039 generate_remove_body(A,
1040 E,
1041 F,
1042 D,
1043 C,
1044 I,
1045 B))
1046 ).
1047remove_constraint_atom(A, D, F, E, B) :-
1048 make_name('$remove_constraint_internal_', A, C),
1049 ( chr_pp_flag(debugable, off),
1050 ( only_ground_indexed_arguments(A)
1051 ; get_store_type(A, var_assoc_store(_, _))
1052 )
1053 -> B=..[C, D, E]
1054 ; B=..[C, D, F, E]
1055 ).
1056generate_remove_clause(A, B, C) :-
1057 ( is_used_auxiliary_predicate(remove_constraint_internal, A)
1058 -> B=[D|C],
1059 D=(E:-I),
1060 remove_constraint_atom(A, F, G, H, E),
1061 generate_remove_body(A,
1062 F,
1063 G,
1064 H=no,
1065 H=yes,
1066 active,
1067 I)
1068 ; B=C
1069 ).
1070generate_remove_body(A, C, O, F, G, B, L) :-
1071 ( chr_pp_flag(debugable, off),
1072 ( only_ground_indexed_arguments(A)
1073 ; get_store_type(A, var_assoc_store(_, _))
1074 )
1075 -> ( B==active
1076 -> get_update_suspension_field(A,
1077 C,
1078 state,
1079 E,
1080 removed,
1081 H,
1082 D,
1083 I),
1084 if_used_state(A, not_stored_yet, D, true, J),
1085 if_used_state(A,
1086 not_stored_yet,
1087 (E==not_stored_yet->F;G),
1088 G,
1089 K)
1090 ; B==partner
1091 -> get_update_suspension_field(A,
1092 C,
1093 state,
1094 E,
1095 removed,
1096 H,
1097 _,
1098 I),
1099 J=true,
1100 K=G
1101 ),
1102 L=(H, J, I, K)
1103 ; static_suspension_term(A, M),
1104 get_static_suspension_term_field(arguments,
1105 A,
1106 M,
1107 N),
1108 generate_indexed_variables_body(A,
1109 N,
1110 Q,
1111 O),
1112 ( chr_pp_flag(debugable, on)
1113 -> A=P/_,
1114 get_static_suspension_term_field(functor,
1115 A,
1116 M,
1117 P)
1118 ; true
1119 ),
1120 ( B==active
1121 -> get_update_static_suspension_field(A,
1122 C,
1123 M,
1124 state,
1125 E,
1126 removed,
1127 D,
1128 I),
1129 if_used_state(A, not_stored_yet, D, true, J),
1130 if_used_state(A,
1131 not_stored_yet,
1132 (E==not_stored_yet->O=[], F;Q, G),
1133 (Q, G),
1134 K)
1135 ; B==partner
1136 -> get_update_static_suspension_field(A,
1137 C,
1138 M,
1139 state,
1140 E,
1141 removed,
1142 _,
1143 I),
1144 J=true,
1145 K=(Q, G)
1146 ),
1147 L=(C=M, J, I, K)
1148 ).
1149generate_activate_clauses([], A, A).
1150generate_activate_clauses([A|C], B, E) :-
1151 generate_activate_clause(A, B, D),
1152 generate_activate_clauses(C, D, E).
1153activate_constraint_goal(A, C, E, F, G, B) :-
1154 ( chr_pp_flag(inline_insertremove, off)
1155 -> use_auxiliary_predicate(activate_constraint, A),
1156 B=(H, (D==yes->C;true)),
1157 activate_constraint_atom(A,
1158 D,
1159 E,
1160 F,
1161 G,
1162 H)
1163 ; delay_phase_end(validate_store_type_assumptions,
1164 activate_constraint_body(A,
1165 C,
1166 true,
1167 E,
1168 F,
1169 G,
1170 B))
1171 ).
1172activate_constraint_atom(A, D, G, E, F, B) :-
1173 make_name('$activate_constraint_', A, C),
1174 ( chr_pp_flag(debugable, off),
1175 only_ground_indexed_arguments(A)
1176 -> B=..[C, D, E]
1177 ; chr_pp_flag(debugable, off),
1178 may_trigger(A),
1179 get_store_type(A, var_assoc_store(_, _))
1180 -> B=..[C, D, E, F]
1181 ; chr_pp_flag(debugable, off),
1182 may_trigger(A),
1183 get_store_type(A, var_assoc_store(_, _))
1184 -> B=..[C, D, G, E, F]
1185 ; B=..[C, D, G, E]
1186 ).
1187generate_activate_clause(A, B, C) :-
1188 ( is_used_auxiliary_predicate(activate_constraint, A)
1189 -> B=[D|C],
1190 D=(E:-J),
1191 activate_constraint_atom(A,
1192 F,
1193 G,
1194 H,
1195 I,
1196 E),
1197 activate_constraint_body(A,
1198 F=yes,
1199 F=no,
1200 G,
1201 H,
1202 I,
1203 J)
1204 ; B=C
1205 ).
1206activate_constraint_body(A, K, L, N, B, C, S) :-
1207 ( chr_pp_flag(debugable, off),
1208 may_trigger(A),
1209 uses_field(A, generation)
1210 -> get_update_suspension_field(A,
1211 B,
1212 generation,
1213 F,
1214 C,
1215 D,
1216 E,
1217 G),
1218 H=(D, E, C is F+1, G)
1219 ; H=true
1220 ),
1221 get_update_suspension_field(A,
1222 B,
1223 state,
1224 J,
1225 active,
1226 T,
1227 I,
1228 V),
1229 if_used_state(A, not_stored_yet, I, true, U),
1230 ( chr_pp_flag(debugable, off),
1231 ( only_ground_indexed_arguments(A)
1232 ; get_store_type(A, var_assoc_store(_, _))
1233 )
1234 -> if_used_state(A,
1235 not_stored_yet,
1236 (J==not_stored_yet->K;L),
1237 L,
1238 R)
1239 ; get_dynamic_suspension_term_field(arguments,
1240 A,
1241 B,
1242 M,
1243 O),
1244 generate_indexed_variables_body(A,
1245 M,
1246 P,
1247 N),
1248 chr_none_locked(N, Q),
1249 if_used_state(A,
1250 not_stored_yet,
1251 (J==not_stored_yet->O, P, Q, K;L),
1252 L,
1253 R)
1254 ),
1255 S=(T, U, V, H, R).
1256generate_allocate_clauses([], A, A).
1257generate_allocate_clauses([A|C], B, E) :-
1258 generate_allocate_clause(A, B, D),
1259 generate_allocate_clauses(C, D, E).
1260allocate_constraint_goal(A, B, C, D) :-
1261 uses_state(A, not_stored_yet),
1262 ( chr_pp_flag(inline_insertremove, off)
1263 -> use_auxiliary_predicate(allocate_constraint, A),
1264 allocate_constraint_atom(A, B, C, D)
1265 ; D=(B=E, F),
1266 delay_phase_end(validate_store_type_assumptions,
1267 allocate_constraint_body(A,
1268 E,
1269 C,
1270 F))
1271 ).
1272allocate_constraint_atom(A, D, E, B) :-
1273 make_name('$allocate_constraint_', A, C),
1274 B=..[C, D|E].
1275generate_allocate_clause(A, B, C) :-
1276 ( is_used_auxiliary_predicate(allocate_constraint, A)
1277 -> B=[D|C],
1278 D=(G:-I),
1279 A=_/E,
1280 length(F, E),
1281 allocate_constraint_atom(A, H, F, G),
1282 allocate_constraint_body(A, H, F, I)
1283 ; B=C
1284 ).
1285allocate_constraint_body(A, E, C, P) :-
1286 static_suspension_term(A, B),
1287 get_static_suspension_term_field(arguments, A, B, C),
1288 ( chr_pp_flag(debugable, on)
1289 -> A=D/_,
1290 get_static_suspension_term_field(functor, A, B, D)
1291 ; true
1292 ),
1293 ( chr_pp_flag(debugable, on)
1294 -> ( may_trigger(A)
1295 -> append(C, [E], F),
1296 build_head(_, _, [0], F, H),
1297 get_target_module(G),
1298 I=G:H
1299 ; I=true
1300 ),
1301 K=(E=B),
1302 create_static_suspension_field(A,
1303 B,
1304 continuation,
1305 I,
1306 L),
1307 create_static_suspension_field(A,
1308 B,
1309 generation,
1310 0,
1311 J)
1312 ; may_trigger(A),
1313 uses_field(A, generation)
1314 -> create_static_suspension_field(A,
1315 B,
1316 generation,
1317 0,
1318 J),
1319 E=B,
1320 K=true,
1321 L=true
1322 ; J=true,
1323 E=B,
1324 K=true,
1325 L=true
1326 ),
1327 ( uses_history(A)
1328 -> create_static_suspension_field(A, B, history, t, M)
1329 ; M=true
1330 ),
1331 create_static_suspension_field(A,
1332 B,
1333 state,
1334 not_stored_yet,
1335 Q),
1336 ( has_suspension_field(A, id)
1337 -> get_static_suspension_term_field(id, A, B, N),
1338 gen_id(N, O)
1339 ; O=true
1340 ),
1341 P=(K, L, J, M, Q, O).
1342gen_id(A, 'chr gen_id'(A)).
1343generate_insert_constraint_internal_clauses([], A, A).
1344generate_insert_constraint_internal_clauses([A|C], B, E) :-
1345 generate_insert_constraint_internal_clause(A, B, D),
1346 generate_insert_constraint_internal_clauses(C, D, E).
1347insert_constraint_internal_constraint_goal(A, B, C, D, E, F) :-
1348 ( chr_pp_flag(inline_insertremove, off)
1349 -> use_auxiliary_predicate(remove_constraint_internal, A),
1350 insert_constraint_internal_constraint_atom(A,
1351 B,
1352 C,
1353 D,
1354 E,
1355 F)
1356 ; delay_phase_end(validate_store_type_assumptions,
1357 generate_insert_constraint_internal_body(A,
1358 C,
1359 D,
1360 E,
1361 B,
1362 F))
1363 ).
1364insert_constraint_internal_constraint_atom(A, D, E, F, G, B) :-
1365 insert_constraint_internal_constraint_name(A, C),
1366 ( chr_pp_flag(debugable, on)
1367 -> B=..[C, D, E, F|G]
1368 ; ( only_ground_indexed_arguments(A)
1369 ; get_store_type(A, var_assoc_store(_, _))
1370 )
1371 -> B=..[C, E|G]
1372 ; B=..[C, D, E|G]
1373 ).
1374insert_constraint_internal_constraint_name(A, B) :-
1375 make_name('$insert_constraint_internal_', A, B).
1376generate_insert_constraint_internal_clause(A, B, C) :-
1377 ( is_used_auxiliary_predicate(insert_constraint_internal, A)
1378 -> B=[D|C],
1379 D=(G:-K),
1380 A=_/E,
1381 length(F, E),
1382 insert_constraint_internal_constraint_atom(A,
1383 J,
1384 H,
1385 I,
1386 F,
1387 G),
1388 generate_insert_constraint_internal_body(A,
1389 H,
1390 I,
1391 F,
1392 J,
1393 K)
1394 ; B=C
1395 ).
1396generate_insert_constraint_internal_body(A, K, C, G, M, J) :-
1397 static_suspension_term(A, B),
1398 create_static_suspension_field(A, B, state, active, L),
1399 ( chr_pp_flag(debugable, on)
1400 -> get_static_suspension_term_field(continuation,
1401 A,
1402 B,
1403 C),
1404 create_static_suspension_field(A,
1405 B,
1406 generation,
1407 0,
1408 D)
1409 ; may_trigger(A),
1410 uses_field(A, generation)
1411 -> create_static_suspension_field(A,
1412 B,
1413 generation,
1414 0,
1415 D)
1416 ; D=true
1417 ),
1418 ( chr_pp_flag(debugable, on)
1419 -> A=E/_,
1420 get_static_suspension_term_field(functor, A, B, E)
1421 ; true
1422 ),
1423 ( uses_history(A)
1424 -> create_static_suspension_field(A, B, history, t, F)
1425 ; F=true
1426 ),
1427 get_static_suspension_term_field(arguments, A, B, G),
1428 _=[_|_],
1429 ( chr_pp_flag(debugable, off),
1430 ( only_ground_indexed_arguments(A)
1431 ; get_store_type(A, var_assoc_store(_, _))
1432 )
1433 -> suspension_term_base_fields(A, _),
1434 ( has_suspension_field(A, id)
1435 -> get_static_suspension_term_field(id, A, B, H),
1436 gen_id(H, I)
1437 ; I=true
1438 ),
1439 J=(K=B, L, D, F, I)
1440 ; ( has_suspension_field(A, id)
1441 -> get_static_suspension_term_field(id, A, B, H),
1442 gen_id(H, I)
1443 ; I=true
1444 ),
1445 generate_indexed_variables_body(A, G, N, M),
1446 chr_none_locked(M, O),
1447 J=(K=B, N, O, L, D, F, I)
1448 ).
1449generate_novel_production(A, B) :-
1450 ( is_used_auxiliary_predicate(novel_production)
1451 -> A=[C|B],
1452 C=('$novel_production'(D, E):-arg(3, D, F), (hprolog:get_ds(E, F, _)->fail;true))
1453 ; A=B
1454 ).
1455generate_extend_history(A, B) :-
1456 ( is_used_auxiliary_predicate(extend_history)
1457 -> A=[C|B],
1458 C=('$extend_history'(D, E):-arg(3, D, F), hprolog:put_ds(E, F, x, G), setarg(3, D, G))
1459 ; A=B
1460 ).
1461generate_empty_named_history_initialisations(A, B) :-
1462 empty_named_history_initialisations(A, B),
1463 find_empty_named_histories.
1464empty_named_history_global_variable(A, B) :-
1465 atom_concat('chr empty named history ', A, B).
1466empty_named_history_novel_production(A, nb_getval(B, 0)) :-
1467 empty_named_history_global_variable(A, B).
1468empty_named_history_extend_history(A, b_setval(B, 1)) :-
1469 empty_named_history_global_variable(A, B).
1470generate_run_suspensions_clauses([], A, A).
1471generate_run_suspensions_clauses([A|C], B, E) :-
1472 generate_run_suspensions_clause(A, B, D),
1473 generate_run_suspensions_clauses(C, D, E).
1474run_suspensions_goal(A, D, B) :-
1475 make_name('$run_suspensions_', A, C),
1476 B=..[C, D].
1477generate_run_suspensions_clause(A, B, C) :-
1478 ( is_used_auxiliary_predicate(run_suspensions, A)
1479 -> B=[D, G|C],
1480 run_suspensions_goal(A, [], D),
1481 ( chr_pp_flag(debugable, on)
1482 -> run_suspensions_goal(A, [E|F], H),
1483 get_update_suspension_field(A,
1484 E,
1485 state,
1486 K,
1487 triggered,
1488 I,
1489 J,
1490 L),
1491 get_update_suspension_field(A,
1492 E,
1493 state,
1494 V,
1495 active,
1496 T,
1497 U,
1498 W),
1499 get_update_suspension_field(A,
1500 E,
1501 generation,
1502 P,
1503 O,
1504 M,
1505 N,
1506 Q),
1507 get_dynamic_suspension_term_field(continuation,
1508 A,
1509 E,
1510 S,
1511 R),
1512 run_suspensions_goal(A, F, X),
1513 G=(H:-I, J, (K==active->L, M, N, O is P+1, Q, R, ('chr debugging'->('chr debug_event'(wake(E)), call(S);'chr debug_event'(fail(E)), !, fail), ('chr debug_event'(exit(E));'chr debug_event'(redo(E)), fail);call(S)), T, U, (V==triggered->W;true);true), X)
1514 ; run_suspensions_goal(A, [E|F], H),
1515 static_suspension_term(A, Y),
1516 get_static_suspension_term_field(arguments,
1517 A,
1518 Y,
1519 Z),
1520 append(Z, [E], A1),
1521 make_suspension_continuation_goal(A, A1, S),
1522 run_suspensions_goal(A, F, X),
1523 ( uses_field(A, generation)
1524 -> get_update_static_suspension_field(A,
1525 E,
1526 Y,
1527 generation,
1528 P,
1529 O,
1530 M,
1531 Q),
1532 B1=(M, O is P+1, Q)
1533 ; B1=true
1534 ),
1535 get_update_static_suspension_field(A,
1536 E,
1537 Y,
1538 state,
1539 K,
1540 triggered,
1541 I,
1542 L),
1543 get_update_static_suspension_field(A,
1544 E,
1545 Y,
1546 state,
1547 V,
1548 active,
1549 D1,
1550 E1),
1551 if_used_state(A,
1552 removed,
1553 (I, (K==active->C1;true)),
1554 C1,
1555 F1),
1556 C1=(L, B1, S, D1, (V==triggered->E1;true)),
1557 G=(H:-E=Y, F1, X)
1558 )
1559 ; B=C
1560 ).
1561generate_attach_increment(B) :-
1562 get_max_constraint_index(A),
1563 ( is_used_auxiliary_predicate(attach_increment),
1564 A>0
1565 -> B=[C, D],
1566 generate_attach_increment_empty(C),
1567 ( A==1
1568 -> generate_attach_increment_one(D)
1569 ; generate_attach_increment_many(A, D)
1570 )
1571 ; B=[]
1572 ).
1573generate_attach_increment_empty((attach_increment([], _):-true)).
1574generate_attach_increment_one(I) :-
1575 J=attach_increment([A|H], E),
1576 get_target_module(C),
1577 chr_not_locked(A, B),
1578 K=(B, (get_attr(A, C, D)->sort(D, F), 'chr merge_attributes'(E, F, G), put_attr(A, C, G);put_attr(A, C, E)), attach_increment(H, E)),
1579 I=(J:-K).
1580generate_attach_increment_many(A, J) :-
1581 K=attach_increment([C|I], B),
1582 merge_attributes(A, B, F, G, H),
1583 get_target_module(E),
1584 chr_not_locked(C, D),
1585 L=(D, (get_attr(C, E, F)->G, put_attr(C, E, H);put_attr(C, E, B)), attach_increment(I, B)),
1586 J=(K:-L).
1587generate_attr_unify_hook(B) :-
1588 get_max_constraint_index(A),
1589 ( A==0
1590 -> B=[]
1591 ; B=[C|E],
1592 C=attribute_goals(_, D, D),
1593 ( A==1
1594 -> generate_attr_unify_hook_one(E)
1595 ; generate_attr_unify_hook_many(A, E)
1596 )
1597 ).
1598generate_attr_unify_hook_one([S]) :-
1599 T=attr_unify_hook(E, N),
1600 get_target_module(P),
1601 get_indexed_constraint(1, A),
1602 ( get_store_type(A, B),
1603 ( B=default
1604 ; B=multi_store(C),
1605 memberchk(default, C)
1606 )
1607 -> make_run_suspensions(H, D, Q),
1608 make_run_suspensions(D, D, R),
1609 ( atomic_types_suspended_constraint(A)
1610 -> I=true,
1611 D=E,
1612 J=true,
1613 K=F,
1614 L=(append(E, F, G), sort(G, H)),
1615 M=true
1616 ; I=sort(E, D),
1617 J=sort(F, K),
1618 L='chr merge_attributes'(D, K, H),
1619 use_auxiliary_predicate(attach_increment),
1620 M=(compound(N)->term_variables(N, O), attach_increment(O, D);true)
1621 ),
1622 U=(I, (var(N)->(get_attr(N, P, F)->J, L, put_attr(N, P, H), Q;put_attr(N, P, D), R);M, R)),
1623 S=(T:-U)
1624 ; get_store_type(A, var_assoc_store(_, _))
1625 -> make_run_suspensions(G, G, Q),
1626 L=merge_into_assoc_store(E, F, G),
1627 U=(get_attr(N, P, F)->L, Q;put_attr(N, P, E)),
1628 S=(T:-U)
1629 ).
1630generate_attr_unify_hook_many(A, [X]) :-
1631 chr_pp_flag(dynattr, off), !,
1632 Y=attr_unify_hook(B, O),
1633 get_target_module(S),
1634 make_attr(A, H, D, B),
1635 bagof(E,
1636 C^F^(member(C, D), E=sort(C, F)),
1637 G),
1638 list2conj(G, R),
1639 bagof(F, C^member(sort(C, F), G), I),
1640 merge_attributes2(A, H, I, T, U, J),
1641 get_all_suspensions2(A, J, K),
1642 make_attr(A, H, I, Q),
1643 make_run_suspensions_loop(K, I, V),
1644 make_run_suspensions_loop(I, I, W),
1645 ( forall(( between(1, A, L),
1646 get_indexed_constraint(L, M)
1647 ),
1648 atomic_types_suspended_constraint(M))
1649 -> N=true
1650 ; use_auxiliary_predicate(attach_increment),
1651 N=(compound(O)->term_variables(O, P), attach_increment(P, Q);true)
1652 ),
1653 Z=(R, (var(O)->(get_attr(O, S, T)->U, put_attr(O, S, J), V;put_attr(O, S, Q), W);N, W)),
1654 X=(Y:-Z).
1655generate_attr_unify_hook_many(B, R) :-
1656 P=attr_unify_hook(A, H),
1657 get_target_module(K),
1658 normalize_attr(A, J, C),
1659 normalize_attr(L, M, D),
1660 merge_attributes(B, C, D, N, O),
1661 make_run_suspensions(B),
1662 ( forall(( between(1, B, E),
1663 get_indexed_constraint(E, F)
1664 ),
1665 atomic_types_suspended_constraint(F))
1666 -> G=true
1667 ; use_auxiliary_predicate(attach_increment),
1668 G=(compound(H)->term_variables(H, I), attach_increment(I, C);true)
1669 ),
1670 Q=(J, (var(H)->(get_attr(H, K, L)->M, N, put_attr(H, K, O), '$dispatch_run_suspensions'(O);put_attr(H, K, C), '$dispatch_run_suspensions'(C));G, '$dispatch_run_suspensions'(C))),
1671 S=(P:-Q),
1672 R=[S, T, U|Y],
1673 T='$dispatch_run_suspensions'([]),
1674 U=('$dispatch_run_suspensions'([V-W|X]):-'$dispatch_run_suspensions'(V, W), '$dispatch_run_suspensions'(X)),
1675 run_suspensions_dispatchers(B, [], Y).
1676run_suspensions_dispatchers(A, B, H) :-
1677 ( A>0
1678 -> get_indexed_constraint(A, C),
1679 G=[('$dispatch_run_suspensions'(A, D):-E)|B],
1680 ( may_trigger(C)
1681 -> run_suspensions_goal(C, D, E)
1682 ; E=true
1683 ),
1684 F is A-1,
1685 run_suspensions_dispatchers(F, G, H)
1686 ; H=B
1687 ).
1688make_run_suspensions(A) :-
1689 ( A>0
1690 -> ( get_indexed_constraint(A, B),
1691 may_trigger(B)
1692 -> use_auxiliary_predicate(run_suspensions, B)
1693 ; true
1694 ),
1695 C is A-1,
1696 make_run_suspensions(C)
1697 ; true
1698 ).
1699make_run_suspensions(A, B, C) :-
1700 make_run_suspensions(1, A, B, C).
1701make_run_suspensions(A, E, C, D) :-
1702 ( get_indexed_constraint(A, B),
1703 may_trigger(B)
1704 -> use_auxiliary_predicate(run_suspensions, B),
1705 ( wakes_partially(B)
1706 -> run_suspensions_goal(B, C, D)
1707 ; run_suspensions_goal(B, E, D)
1708 )
1709 ; D=true
1710 ).
1711make_run_suspensions_loop(A, B, C) :-
1712 make_run_suspensions_loop(A, B, 1, C).
1713make_run_suspensions_loop([], [], _, true).
1714make_run_suspensions_loop([B|E], [C|F], A, (D, H)) :-
1715 make_run_suspensions(A, B, C, D),
1716 G is A+1,
1717 make_run_suspensions_loop(E, F, G, H).
1718generate_insert_delete_constraints([], []).
1719generate_insert_delete_constraints([A|D], B) :-
1720 ( is_stored(A)
1721 -> generate_insert_delete_constraint(A, B, C)
1722 ; B=C
1723 ),
1724 generate_insert_delete_constraints(D, C).
1725generate_insert_delete_constraint(A, B, D) :-
1726 insert_constraint_clause(A, B, C),
1727 delete_constraint_clause(A, C, D).
1728insert_constraint_goal(A, B, E, C) :-
1729 ( chr_pp_flag(inline_insertremove, off)
1730 -> use_auxiliary_predicate(insert_in_store, A),
1731 insert_constraint_atom(A, B, C)
1732 ; delay_phase_end(validate_store_type_assumptions,
1733 (insert_constraint_body(A, B, D, C), insert_constraint_direct_used_vars(D, E)))
1734 ).
1735insert_constraint_direct_used_vars([], _).
1736insert_constraint_direct_used_vars([A-C|D], B) :-
1737 nth1(A, B, C),
1738 insert_constraint_direct_used_vars(D, B).
1739insert_constraint_atom(A, D, B) :-
1740 make_name('$insert_in_store_', A, C),
1741 B=..[C, D].
1742insert_constraint_clause(A, B, C) :-
1743 ( is_used_auxiliary_predicate(insert_in_store, A)
1744 -> B=[D|C],
1745 D=(E:-J, I, G),
1746 insert_constraint_atom(A, F, E),
1747 insert_constraint_body(A, F, H, G),
1748 insert_constraint_used_vars(H, A, F, I),
1749 ( chr_pp_flag(store_counter, on)
1750 -> J='$insert_counter_inc'
1751 ; J=true
1752 )
1753 ; B=C
1754 ).
1755insert_constraint_used_vars([], _, _, true).
1756insert_constraint_used_vars([A-D|F], B, C, (E, G)) :-
1757 get_dynamic_suspension_term_field(argument(A),
1758 B,
1759 C,
1760 D,
1761 E),
1762 insert_constraint_used_vars(F, B, C, G).
1763insert_constraint_body(A, C, D, E) :-
1764 get_store_type(A, B),
1765 insert_constraint_body(B, A, C, D, E).
1766insert_constraint_body(default, A, D, [], F) :-
1767 global_list_store_name(A, B),
1768 make_get_store_goal(B, E, G),
1769 make_update_store_goal(B, C, H),
1770 ( chr_pp_flag(debugable, on)
1771 -> C=[D|E],
1772 F=(G, H)
1773 ; set_dynamic_suspension_term_field(global_list_prev,
1774 A,
1775 I,
1776 C,
1777 J),
1778 F=(G, C=[D|E], H, (E=[I|_]->J;true))
1779 ).
1780insert_constraint_body(multi_inthash(A), B, C, [], D) :-
1781 generate_multi_inthash_insert_constraint_bodies(A,
1782 B,
1783 C,
1784 D).
1785insert_constraint_body(multi_hash(A), B, C, E, D) :-
1786 generate_multi_hash_insert_constraint_bodies(A,
1787 B,
1788 C,
1789 D,
1790 E),
1791 sort_out_used_vars(E, _).
1792insert_constraint_body(atomic_constants(B, _, _), A, C, D, G) :-
1793 multi_hash_key_direct(A, B, C, F, D),
1794 constants_store_index_name(A, B, E),
1795 H=..[E, F, I],
1796 G=(H->nb_getval(I, J), b_setval(I, [C|J]);true).
1797insert_constraint_body(ground_constants(B, _, _), A, C, D, G) :-
1798 multi_hash_key_direct(A, B, C, F, D),
1799 constants_store_index_name(A, B, E),
1800 H=..[E, F, I],
1801 G=(H->nb_getval(I, J), b_setval(I, [C|J]);true).
1802insert_constraint_body(global_ground, A, D, [], F) :-
1803 global_ground_store_name(A, B),
1804 make_get_store_goal(B, E, G),
1805 make_update_store_goal(B, C, H),
1806 ( chr_pp_flag(debugable, on)
1807 -> C=[D|E],
1808 F=(G, H)
1809 ; set_dynamic_suspension_term_field(global_list_prev,
1810 A,
1811 I,
1812 C,
1813 J),
1814 F=(G, C=[D|E], H, (E=[I|_]->J;true))
1815 ).
1816insert_constraint_body(var_assoc_store(A, B), _, H, [A-D, B-G], C) :-
1817 get_target_module(E),
1818 C=(get_attr(D, E, F)->insert_assoc_store(F, G, H);new_assoc_store(F), put_attr(D, E, F), insert_assoc_store(F, G, H)).
1819insert_constraint_body(global_singleton, A, C, [], D) :-
1820 global_singleton_store_name(A, B),
1821 make_update_store_goal(B, C, E),
1822 D=E.
1823insert_constraint_body(multi_store(C), A, B, G, E) :-
1824 maplist(insert_constraint_body1(A, B),
1825 C,
1826 F,
1827 D),
1828 list2conj(D, E),
1829 sort_out_used_vars(F, G).
1830insert_constraint_body1(B, C, A, D, E) :-
1831 insert_constraint_body(A, B, C, D, E).
1832insert_constraint_body(identifier_store(B), D, I, A, G) :-
1833 A=[B-H],
1834 get_identifier_size(C),
1835 functor(F, struct, C),
1836 get_identifier_index(D, B, E),
1837 arg(E, F, J),
1838 G=(H=F, setarg(E, H, [I|J])).
1839insert_constraint_body(type_indexed_identifier_store(B, C), D, I, A, G) :-
1840 A=[B-H],
1841 type_indexed_identifier_structure(C, F),
1842 get_type_indexed_identifier_index(C, D, B, E),
1843 arg(E, F, J),
1844 G=(H=F, setarg(E, H, [I|J])).
1845sort_out_used_vars(A, D) :-
1846 flatten(A, B),
1847 sort(B, C),
1848 sort_out_used_vars1(C, D).
1849sort_out_used_vars1([], []).
1850sort_out_used_vars1([B-C], A) :- !,
1851 A=[B-C].
1852sort_out_used_vars1([A-C, B-D|E], F) :-
1853 ( A==B
1854 -> C=D,
1855 sort_out_used_vars1([A-C|E], F)
1856 ; F=[A-C|G],
1857 sort_out_used_vars1([B-D|E], G)
1858 ).
1859generate_multi_inthash_insert_constraint_bodies([], _, _, true).
1860generate_multi_inthash_insert_constraint_bodies([B|I], A, C, (D, J)) :-
1861 multi_hash_store_name(A, B, F),
1862 multi_hash_key(A, B, C, E, H),
1863 D=(E, nb_getval(F, G), insert_iht(G, H, C)),
1864 generate_multi_inthash_insert_constraint_bodies(I,
1865 A,
1866 C,
1867 J).
1868generate_multi_hash_insert_constraint_bodies([], _, _, true, []).
1869generate_multi_hash_insert_constraint_bodies([B|N], A, C, (G, O), [D|P]) :-
1870 multi_hash_store_name(A, B, E),
1871 multi_hash_key_direct(A, B, C, J, D),
1872 make_get_store_goal(E, I, H),
1873 ( chr_pp_flag(ht_removal, on)
1874 -> ht_prev_field(B, F),
1875 set_dynamic_suspension_term_field(F,
1876 A,
1877 L,
1878 K,
1879 M),
1880 G=(H, insert_ht(I, J, C, K), (K=[_, L|_]->M;true))
1881 ; G=(H, insert_ht(I, J, C))
1882 ),
1883 generate_multi_hash_insert_constraint_bodies(N,
1884 A,
1885 C,
1886 O,
1887 P).
1888delete_constraint_clause(A, B, C) :-
1889 ( is_used_auxiliary_predicate(delete_from_store, A)
1890 -> B=[D|C],
1891 D=(E:-I),
1892 delete_constraint_atom(A, H, E),
1893 A=F/G,
1894 functor(E, F, G),
1895 delete_constraint_body(A, E, H, [], I)
1896 ; B=C
1897 ).
1898delete_constraint_goal(A, E, G, F) :-
1899 functor(A, B, C),
1900 D=B/C,
1901 ( chr_pp_flag(inline_insertremove, off)
1902 -> use_auxiliary_predicate(delete_from_store, D),
1903 delete_constraint_atom(D, E, F)
1904 ; delay_phase_end(validate_store_type_assumptions,
1905 delete_constraint_body(D,
1906 A,
1907 E,
1908 G,
1909 F))
1910 ).
1911delete_constraint_atom(A, D, B) :-
1912 make_name('$delete_from_store_', A, C),
1913 B=..[C, D].
1914delete_constraint_body(C, E, F, G, A) :-
1915 A=(B, H),
1916 ( chr_pp_flag(store_counter, on)
1917 -> B='$delete_counter_inc'
1918 ; B=true
1919 ),
1920 get_store_type(C, D),
1921 delete_constraint_body(D,
1922 C,
1923 E,
1924 F,
1925 G,
1926 H).
1927delete_constraint_body(default, A, _, F, _, C) :-
1928 ( chr_pp_flag(debugable, on)
1929 -> global_list_store_name(A, B),
1930 make_get_store_goal(B, E, D),
1931 make_update_store_goal(B, G, H),
1932 C=(D, 'chr sbag_del_element'(E, F, G), H)
1933 ; get_dynamic_suspension_term_field(global_list_prev,
1934 A,
1935 F,
1936 J,
1937 K),
1938 global_list_store_name(A, B),
1939 make_get_store_goal(B, E, D),
1940 make_update_store_goal(B, L, H),
1941 set_dynamic_suspension_term_field(global_list_prev,
1942 A,
1943 I,
1944 _,
1945 M),
1946 set_dynamic_suspension_term_field(global_list_prev,
1947 A,
1948 I,
1949 J,
1950 N),
1951 C=(K, (var(J)->D, E=[_|L], H, (L=[I|_]->M;true);J=[_, _|L], setarg(2, J, L), (L=[I|_]->N;true)))
1952 ).
1953delete_constraint_body(multi_inthash(A), B, _, C, _, D) :-
1954 generate_multi_inthash_delete_constraint_bodies(A,
1955 B,
1956 C,
1957 D).
1958delete_constraint_body(multi_hash(A), B, C, D, E, F) :-
1959 generate_multi_hash_delete_constraint_bodies(A,
1960 B,
1961 C,
1962 D,
1963 E,
1964 F).
1965delete_constraint_body(atomic_constants(C, _, _), A, B, D, E, H) :-
1966 multi_hash_key(A,
1967 B,
1968 C,
1969 D,
1970 E,
1971 I,
1972 G),
1973 constants_store_index_name(A, C, F),
1974 J=..[F, G, K],
1975 H=(I, (J->nb_getval(K, L), 'chr sbag_del_element'(L, D, M), b_setval(K, M);true)).
1976delete_constraint_body(ground_constants(C, _, _), A, B, D, E, H) :-
1977 multi_hash_key(A,
1978 B,
1979 C,
1980 D,
1981 E,
1982 I,
1983 G),
1984 constants_store_index_name(A, C, F),
1985 J=..[F, G, K],
1986 H=(I, (J->nb_getval(K, L), 'chr sbag_del_element'(L, D, M), b_setval(K, M);true)).
1987delete_constraint_body(global_ground, A, _, F, _, C) :-
1988 ( chr_pp_flag(debugable, on)
1989 -> global_ground_store_name(A, B),
1990 make_get_store_goal(B, E, D),
1991 make_update_store_goal(B, G, H),
1992 C=(D, 'chr sbag_del_element'(E, F, G), H)
1993 ; get_dynamic_suspension_term_field(global_list_prev,
1994 A,
1995 F,
1996 J,
1997 K),
1998 global_ground_store_name(A, B),
1999 make_get_store_goal(B, E, D),
2000 make_update_store_goal(B, L, H),
2001 set_dynamic_suspension_term_field(global_list_prev,
2002 A,
2003 I,
2004 _,
2005 M),
2006 set_dynamic_suspension_term_field(global_list_prev,
2007 A,
2008 I,
2009 J,
2010 N),
2011 C=(K, (var(J)->D, E=[_|L], H, (L=[I|_]->M;true);J=[_, _|L], setarg(2, J, L), (L=[I|_]->N;true)))
2012 ).
2013delete_constraint_body(var_assoc_store(A, D), B, _, C, _, E) :-
2014 get_target_module(H),
2015 get_dynamic_suspension_term_field(argument(A),
2016 B,
2017 C,
2018 G,
2019 F),
2020 get_dynamic_suspension_term_field(argument(D),
2021 B,
2022 C,
2023 K,
2024 I),
2025 E=(F, get_attr(G, H, J), I, delete_assoc_store(J, K, C)).
2026delete_constraint_body(global_singleton, A, _, _, _, C) :-
2027 global_singleton_store_name(A, B),
2028 make_update_store_goal(B, [], D),
2029 C=D.
2030delete_constraint_body(multi_store(E), A, B, C, D, G) :-
2031 maplist(delete_constraint_body1(A, B, C, D),
2032 E,
2033 F),
2034 list2conj(F, G).
2035delete_constraint_body1(B, C, D, E, A, F) :-
2036 delete_constraint_body(A,
2037 B,
2038 C,
2039 D,
2040 E,
2041 F).
2042delete_constraint_body(identifier_store(D), F, A, C, B, I) :-
2043 get_suspension_argument_possibly_in_scope(A,
2044 B,
2045 C,
2046 D,
2047 K,
2048 J),
2049 get_identifier_size(E),
2050 functor(H, struct, E),
2051 get_identifier_index(F, D, G),
2052 arg(G, H, L),
2053 I=(J, K=H, 'chr sbag_del_element'(L, C, M), setarg(G, K, M)).
2054delete_constraint_body(type_indexed_identifier_store(D, E), F, A, C, B, I) :-
2055 get_suspension_argument_possibly_in_scope(A,
2056 B,
2057 C,
2058 D,
2059 K,
2060 J),
2061 type_indexed_identifier_structure(E, H),
2062 get_type_indexed_identifier_index(E, F, D, G),
2063 arg(G, H, L),
2064 I=(J, K=H, 'chr sbag_del_element'(L, C, M), setarg(G, K, M)).
2065generate_multi_inthash_delete_constraint_bodies([], _, _, true).
2066generate_multi_inthash_delete_constraint_bodies([B|I], A, C, (D, J)) :-
2067 multi_hash_store_name(A, B, F),
2068 multi_hash_key(A, B, C, E, H),
2069 D=(E, nb_getval(F, G), delete_iht(G, H, C)),
2070 generate_multi_inthash_delete_constraint_bodies(I,
2071 A,
2072 C,
2073 J).
2074generate_multi_hash_delete_constraint_bodies([], _, _, _, _, true).
2075generate_multi_hash_delete_constraint_bodies([B|S], A, C, D, E, (J, T)) :-
2076 multi_hash_store_name(A, B, F),
2077 multi_hash_key(A,
2078 C,
2079 B,
2080 D,
2081 E,
2082 M,
2083 O),
2084 make_get_store_goal(F, N, L),
2085 ( chr_pp_flag(ht_removal, on)
2086 -> ht_prev_field(B, G),
2087 get_dynamic_suspension_term_field(G,
2088 A,
2089 D,
2090 I,
2091 K),
2092 set_dynamic_suspension_term_field(G,
2093 A,
2094 H,
2095 _,
2096 Q),
2097 set_dynamic_suspension_term_field(G,
2098 A,
2099 H,
2100 I,
2101 R),
2102 J=(K, (var(I)->L, M, delete_first_ht(N, O, P), (P=[H|_]->Q;true);I=[_, _|P], setarg(2, I, P), (P=[H|_]->R;true)))
2103 ; J=(M, L, delete_ht(N, O, D))
2104 ),
2105 generate_multi_hash_delete_constraint_bodies(S,
2106 _,
2107 C,
2108 D,
2109 E,
2110 T).
2111generate_attach_code(A, C) :-
2112 enumerate_stores_code(A, B),
2113 append(B, D, C),
2114 generate_attach_code(A, D, E),
2115 module_initializers(F),
2116 prolog_global_variables_code(G),
2117 E=[('$chr_initialization':-F), (:-initialization'$chr_initialization')|G].
2118generate_attach_code([], A, A).
2119generate_attach_code([A|D], C, F) :-
2120 get_store_type(A, B),
2121 generate_attach_code(B, A, C, E),
2122 generate_attach_code(D, E, F).
2123generate_attach_code(default, A, B, C) :-
2124 global_list_store_initialisation(A, B, C).
2125generate_attach_code(multi_inthash(A), B, C, E) :-
2126 multi_inthash_store_initialisations(A, B, C, D),
2127 multi_inthash_via_lookups(A, B, D, E).
2128generate_attach_code(multi_hash(A), B, C, E) :-
2129 multi_hash_store_initialisations(A, B, C, D),
2130 multi_hash_lookups(A, B, D, E).
2131generate_attach_code(atomic_constants(B, C, _), A, D, E) :-
2132 constants_initializers(A, B, C),
2133 atomic_constants_code(A, B, C, D, E).
2134generate_attach_code(ground_constants(B, C, _), A, D, E) :-
2135 constants_initializers(A, B, C),
2136 ground_constants_code(A, B, C, D, E).
2137generate_attach_code(global_ground, A, B, C) :-
2138 global_ground_store_initialisation(A, B, C).
2139generate_attach_code(var_assoc_store(_, _), _, A, A) :-
2140 use_auxiliary_module(chr_assoc_store).
2141generate_attach_code(global_singleton, A, B, C) :-
2142 global_singleton_store_initialisation(A, B, C).
2143generate_attach_code(multi_store(A), B, C, D) :-
2144 multi_store_generate_attach_code(A, B, C, D).
2145generate_attach_code(identifier_store(B), A, L, P) :-
2146 get_identifier_index(A, B, C),
2147 ( C==2
2148 -> get_identifier_size(D),
2149 functor(E, struct, D),
2150 E=..[_, G|F],
2151 set_elems(F, []),
2152 M=new_identifier(G, E),
2153 functor(H, struct, D),
2154 arg(1, H, I),
2155 N=(user:portray(H):-write('<id:'), print(I), write(>)),
2156 functor(J, struct, D),
2157 arg(1, J, K),
2158 O=identifier_label(J, K),
2159 L=[M, N, O|P]
2160 ; L=P
2161 ).
2162generate_attach_code(type_indexed_identifier_store(C, A), B, E, S1) :-
2163 get_type_indexed_identifier_index(A, B, C, D),
2164 ( D==2
2165 -> identifier_store_initialization(A, E, K1),
2166 get_type_indexed_identifier_size(A, _),
2167 type_indexed_identifier_structure(A, F),
2168 F=..[_, I|G],
2169 set_elems(G, []),
2170 type_indexed_identifier_name(A, new_identifier, H),
2171 L1=..[H, I, F],
2172 N=..[H, K, M],
2173 type_indexed_identifier_structure(A, J),
2174 J=..[_, K|L],
2175 set_elems(L, []),
2176 O=(M=J),
2177 M1=user:goal_expansion(N, O),
2178 type_indexed_identifier_structure(A, P),
2179 arg(1, P, Q),
2180 N1=(user:portray(P):-write('<id:'), print(Q), write(>)),
2181 type_indexed_identifier_structure(A, R),
2182 arg(1, R, T),
2183 type_indexed_identifier_name(A, identifier_label, S),
2184 O1=..[S, R, T],
2185 X=..[S, W, V],
2186 type_indexed_identifier_structure(A, U),
2187 arg(1, U, V),
2188 Y=(W=U),
2189 P1=(user:goal_expansion(X, Y):-writeln(expanding)),
2190 identifier_store_name(A, D1),
2191 lookup_identifier_atom(A, A1, B1, C1),
2192 type_indexed_identifier_name(A, new_identifier, Z),
2193 F1=..[Z, A1, B1],
2194 Q1=(C1:-nb_getval(D1, E1), (lookup_ht(E1, A1, [B1])->true;F1, insert_ht(E1, A1, B1))),
2195 lookup_only_identifier_atom(A, I1, J1, G1),
2196 R1=(G1:-nb_getval(D1, H1), lookup_ht(H1, I1, [J1])),
2197 K1=[(:-multifile goal_expansion/2), (:-dynamic goal_expansion/2), L1, M1, N1, O1, P1, Q1, R1|S1]
2198 ; E=S1
2199 ).
2200constants_initializers(A, B, C) :-
2201 maplist(constant_initializer(A, B), C).
2202constant_initializer(A, B, C) :-
2203 constants_store_name(A, B, C, D),
2204 prolog_global_variable(D),
2205 module_initializer(nb_setval(D, [])).
2206lookup_identifier_atom(A, D, E, B) :-
2207 atom_concat(lookup_identifier_, A, C),
2208 B=..[C, D, E].
2209lookup_only_identifier_atom(A, D, E, B) :-
2210 atom_concat(lookup_only_identifier_, A, C),
2211 B=..[C, D, E].
2212identifier_label_atom(A, D, E, B) :-
2213 type_indexed_identifier_name(A, identifier_label, C),
2214 B=..[C, D, E].
2215multi_store_generate_attach_code([], _, A, A).
2216multi_store_generate_attach_code([A|D], B, C, F) :-
2217 generate_attach_code(A, B, C, E),
2218 multi_store_generate_attach_code(D, B, E, F).
2219multi_inthash_store_initialisations([], _, A, A).
2220multi_inthash_store_initialisations([B|F], A, E, H) :-
2221 use_auxiliary_module(chr_integertable_store),
2222 multi_hash_store_name(A, B, C),
2223 module_initializer((new_iht(D), nb_setval(C, D))),
2224 G=E,
2225 multi_inthash_store_initialisations(F, A, G, H).
2226multi_hash_store_initialisations([], _, A, A).
2227multi_hash_store_initialisations([B|G], A, F, I) :-
2228 use_auxiliary_module(chr_hashtable_store),
2229 multi_hash_store_name(A, B, C),
2230 prolog_global_variable(C),
2231 make_init_store_goal(C, D, E),
2232 module_initializer((new_ht(D), E)),
2233 H=F,
2234 multi_hash_store_initialisations(G, A, H, I).
2235global_list_store_initialisation(A, D, E) :-
2236 ( is_stored(A)
2237 -> global_list_store_name(A, B),
2238 prolog_global_variable(B),
2239 make_init_store_goal(B, [], C),
2240 module_initializer(C)
2241 ; true
2242 ),
2243 D=E.
2244global_ground_store_initialisation(A, D, E) :-
2245 global_ground_store_name(A, B),
2246 prolog_global_variable(B),
2247 make_init_store_goal(B, [], C),
2248 module_initializer(C),
2249 D=E.
2250global_singleton_store_initialisation(A, D, E) :-
2251 global_singleton_store_name(A, B),
2252 prolog_global_variable(B),
2253 make_init_store_goal(B, [], C),
2254 module_initializer(C),
2255 D=E.
2256identifier_store_initialization(A, E, F) :-
2257 use_auxiliary_module(chr_hashtable_store),
2258 identifier_store_name(A, B),
2259 prolog_global_variable(B),
2260 make_init_store_goal(B, C, D),
2261 module_initializer((new_ht(C), D)),
2262 E=F.
2263multi_inthash_via_lookups([], _, A, A).
2264multi_inthash_via_lookups([B|H], A, E, J) :-
2265 multi_hash_lookup_head(A, B, C, D, F),
2266 multi_hash_lookup_body(A,
2267 inthash,
2268 B,
2269 C,
2270 D,
2271 G),
2272 E=[(F:-G)|I],
2273 multi_inthash_via_lookups(H, A, I, J).
2274multi_hash_lookups([], _, A, A).
2275multi_hash_lookups([B|H], A, E, J) :-
2276 multi_hash_lookup_head(A, B, C, D, F),
2277 multi_hash_lookup_body(A, hash, B, C, D, G),
2278 E=[(F:-G)|I],
2279 multi_hash_lookups(H, A, I, J).
2280multi_hash_lookup_head(A, B, E, F, C) :-
2281 multi_hash_lookup_name(A, B, D),
2282 C=..[D, E, F].
2283multi_hash_lookup_body(A, K, B, D, G, E) :-
2284 get_store_type(A, multi_store(C)),
2285 ( memberchk(atomic_constants(B, J, _), C)
2286 -> ( ground(D)
2287 -> constants_store_name(A, B, D, F),
2288 E=nb_getval(F, G)
2289 ; constants_store_index_name(A, B, H),
2290 I=..[H, D, F],
2291 E=(I, nb_getval(F, G))
2292 )
2293 ; memberchk(ground_constants(B, J, _), C)
2294 -> ( ground(D)
2295 -> constants_store_name(A, B, D, F),
2296 E=nb_getval(F, G)
2297 ; constants_store_index_name(A, B, H),
2298 I=..[H, D, F],
2299 E=(I, nb_getval(F, G))
2300 )
2301 ; memberchk(multi_hash([B]), C)
2302 -> multi_hash_store_name(A, B, F),
2303 make_get_store_goal(F, N, L),
2304 ( K==hash,
2305 specialized_hash_term_call(A,
2306 B,
2307 D,
2308 O,
2309 M)
2310 -> E=(L, M, lookup_ht1(N, O, D, G))
2311 ; lookup_hash_call(K, N, D, G, I),
2312 E=(L, I)
2313 )
2314 ; K==inthash
2315 -> multi_hash_store_name(A, B, F),
2316 make_get_store_goal(F, N, L),
2317 lookup_hash_call(K, N, D, G, I),
2318 E=(L, I)
2319 ).
2320lookup_hash_call(hash, A, B, C, lookup_ht(A, B, C)).
2321lookup_hash_call(inthash, A, B, C, lookup_iht(A, B, C)).
2322specialized_hash_term_call(_, _, A, B, C) :-
2323 ( ground(A)
2324 -> term_hash(A, B),
2325 C=true
2326 ).
2327multi_hash_lookup_goal(B, F, C, A, G, H) :-
2328 ( atomic(A)
2329 -> actual_atomic_multi_hash_keys(B, C, [A])
2330 ; ground(A)
2331 -> actual_ground_multi_hash_keys(B, C, [A])
2332 ; C=[D],
2333 get_constraint_arg_type(B, D, E),
2334 is_chr_constants_type(E, _, _)
2335 -> true
2336 ; actual_non_ground_multi_hash_key(B, C)
2337 ),
2338 delay_phase_end(validate_store_type_assumptions,
2339 multi_hash_lookup_body(B,
2340 F,
2341 C,
2342 A,
2343 G,
2344 H)).
2345multi_hash_lookup_name(B/C, A, E) :-
2346 atom_concat_list(A, D),
2347 atom_concat_list(['$via1_multi_hash_', B, '___', C, -, D],
2348 E).
2349multi_hash_store_name(C/D, A, F) :-
2350 get_target_module(B),
2351 atom_concat_list(A, E),
2352 atom_concat_list(
2353 [ '$chr_store_multi_hash_',
2354 B,
2355 '____',
2356 C,
2357 '___',
2358 D,
2359 (-),
2360 E
2361 ],
2362 F).
2363multi_hash_key(C, A, D, F, E) :-
2364 ( A=[B]
2365 -> get_dynamic_suspension_term_field(argument(B),
2366 C,
2367 D,
2368 E,
2369 F)
2370 ; maplist(get_dynamic_suspension_term_field1(C, D),
2371 A,
2372 G,
2373 H),
2374 E=..[k|G],
2375 list2conj(H, F)
2376 ).
2377get_dynamic_suspension_term_field1(B, C, A, D, E) :-
2378 get_dynamic_suspension_term_field(argument(A),
2379 B,
2380 C,
2381 D,
2382 E).
2383multi_hash_key(_, B, A, D, C, G, F) :-
2384 ( A=[E]
2385 -> get_suspension_argument_possibly_in_scope(B,
2386 C,
2387 D,
2388 E,
2389 F,
2390 G)
2391 ; maplist(get_suspension_argument_possibly_in_scope(B,
2392 C,
2393 D),
2394 A,
2395 H,
2396 I),
2397 F=..[k|H],
2398 list2conj(I, G)
2399 ).
2400get_suspension_argument_possibly_in_scope(B, I, N, A, F, G) :-
2401 arg(A, B, C),
2402 ( ground(C),
2403 C='$chr_identifier_match'(E, D)
2404 -> functor(B, K, L),
2405 lookup_identifier_atom(D, E, F, G)
2406 ; term_variables(C, H),
2407 copy_term_nat(C-H, F-J),
2408 translate(H, I, J)
2409 -> G=true
2410 ; functor(B, K, L),
2411 M=K/L,
2412 get_dynamic_suspension_term_field(argument(A),
2413 M,
2414 N,
2415 F,
2416 G)
2417 ).
2418multi_hash_key_direct(_, A, _, D, B) :-
2419 ( A=[C]
2420 -> B=[C-D]
2421 ; pairup(A, E, B),
2422 D=..[k|E]
2423 ).
2424args(B, A, C) :-
2425 maplist(arg1(A), B, C).
2426split_args(A, B, C, D) :-
2427 split_args(A, B, 1, C, D).
2428split_args([], A, _, [], A).
2429split_args([B|E], [D|F], A, C, I) :-
2430 G is A+1,
2431 ( B==A
2432 -> C=[D|H],
2433 split_args(E, F, G, H, I)
2434 ; I=[D|H],
2435 split_args([B|E], F, G, C, H)
2436 ).
2437atomic_constants_code(A, B, D, G, F) :-
2438 constants_store_index_name(A, B, C),
2439 maplist(atomic_constant_code(A, B, C), D, E),
2440 append(E, F, G).
2441atomic_constant_code(A, B, E, C, D) :-
2442 constants_store_name(A, B, C, F),
2443 D=..[E, C, F].
2444ground_constants_code(A, B, C, H, I) :-
2445 constants_store_index_name(A, B, G),
2446 maplist(constants_store_name(A, B), C, F),
2447 length(C, D),
2448 replicate(D, [], E),
2449 trie_index([C|E], F, G, H, I).
2450constants_store_name(D/E, B, A, H) :-
2451 get_target_module(C),
2452 term_to_atom(A, G),
2453 term_to_atom(B, F),
2454 atom_concat_list(
2455 [ '$chr_store_constants_',
2456 C,
2457 '____',
2458 D,
2459 '___',
2460 E,
2461 '___',
2462 F,
2463 '___',
2464 G
2465 ],
2466 H).
2467constants_store_index_name(C/D, A, F) :-
2468 get_target_module(B),
2469 term_to_atom(A, E),
2470 atom_concat_list(
2471 [ '$chr_store_constants_',
2472 B,
2473 '____',
2474 C,
2475 '___',
2476 D,
2477 '___',
2478 E
2479 ],
2480 F).
2481trie_index([A|C], D, B, E, F) :-
2482 trie_step(A, B, B, C, D, E, F).
2483trie_step([], _, _, [], [], A, A) :- !.
2484trie_step(C, K, L, A, J, M, N) :-
2485 A=[B|_],
2486 length(B, G),
2487 aggregate_all(set(E/F),
2488 ( member(D, C),
2489 functor(D, E, F)
2490 ),
2491 H),
2492 I is G+1,
2493 trie_step_cases(H,
2494 I,
2495 C,
2496 A,
2497 J,
2498 K,
2499 L,
2500 M,
2501 N).
2502trie_step_cases([], _, _, _, _, _, _, A, A).
2503trie_step_cases([A|I], B, C, D, E, F, G, H, K) :-
2504 trie_step_case(A,
2505 B,
2506 C,
2507 D,
2508 E,
2509 F,
2510 G,
2511 H,
2512 J),
2513 trie_step_cases(I,
2514 B,
2515 C,
2516 D,
2517 E,
2518 F,
2519 G,
2520 J,
2521 K).
2522trie_step_case(H/I, B, P, S, Q, D, B1, [A|M], N) :-
2523 A=(C:-O),
2524 E is B+1,
2525 functor(C, D, E),
2526 arg(1, C, G),
2527 C=..[_, _|F],
2528 once(append(X, [L], F)),
2529 functor(G, H, I),
2530 G=..[_|J],
2531 append(J, F, K),
2532 ( K==[L]
2533 -> M=N,
2534 O=true,
2535 rec_cases(P,
2536 _,
2537 Q,
2538 H/I,
2539 _,
2540 _,
2541 R),
2542 R=[L]
2543 ; rec_cases(P,
2544 S,
2545 Q,
2546 H/I,
2547 U,
2548 T,
2549 R),
2550 ( T=[V]
2551 -> M=N,
2552 O=true,
2553 append([U, V, R], K)
2554 ; pairup(U, T, W),
2555 common_pattern(W, A1, C1, F1),
2556 append(J, X, [Y|Z]),
2557 Y-Z=A1,
2558 fresh_symbol(B1, D1),
2559 append(C1, [L], E1),
2560 O=..[D1|E1],
2561 maplist(head_tail, F1, G1, H1),
2562 trie_step(G1,
2563 D1,
2564 B1,
2565 H1,
2566 R,
2567 M,
2568 N)
2569 )
2570 ).
2571head_tail([A|B], A, B).
2572rec_cases([], [], [], _, [], [], []).
2573rec_cases([A|L], [E|M], [K|N], B/C, F, H, J) :-
2574 ( functor(A, B, C),
2575 A=..[_|D],
2576 append(D, E, [G|I])
2577 -> F=[G|O],
2578 H=[I|P],
2579 J=[K|Q],
2580 rec_cases(L,
2581 M,
2582 N,
2583 B/C,
2584 O,
2585 P,
2586 Q)
2587 ; rec_cases(L,
2588 M,
2589 N,
2590 B/C,
2591 F,
2592 H,
2593 J)
2594 ).
2595common_pattern(A, B, C, D) :-
2596 fold1(chr_translate:gct, A, B),
2597 term_variables(B, C),
2598 findall(C, member(B, A), D).
2599gct(A, B, C) :-
2600 gct_(A, B, C, [], _).
2601gct_(A, B, G, K, L) :-
2602 ( nonvar(A),
2603 nonvar(B),
2604 functor(A, C, E),
2605 functor(B, D, F),
2606 C==D,
2607 E==F
2608 -> functor(G, C, E),
2609 A=..[_|H],
2610 B=..[_|I],
2611 G=..[_|J],
2612 maplist_dcg(chr_translate:gct_,
2613 H,
2614 I,
2615 J,
2616 K,
2617 L)
2618 ; lookup_eq(K, A+B, G)
2619 -> L=K
2620 ; L=[A+B-G|K]
2621 ).
2622global_list_store_name(B/C, D) :-
2623 get_target_module(A),
2624 atom_concat_list(
2625 [ '$chr_store_global_list_',
2626 A,
2627 '____',
2628 B,
2629 '___',
2630 C
2631 ],
2632 D).
2633global_ground_store_name(B/C, D) :-
2634 get_target_module(A),
2635 atom_concat_list(
2636 [ '$chr_store_global_ground_',
2637 A,
2638 '____',
2639 B,
2640 '___',
2641 C
2642 ],
2643 D).
2644global_singleton_store_name(B/C, D) :-
2645 get_target_module(A),
2646 atom_concat_list(
2647 [ '$chr_store_global_singleton_',
2648 A,
2649 '____',
2650 B,
2651 '___',
2652 C
2653 ],
2654 D).
2655identifier_store_name(B, C) :-
2656 get_target_module(A),
2657 atom_concat_list(['$chr_identifier_lookup_', A, '____', B],
2658 C).
2659:- if(current_predicate(user:exception/3)). 2660prolog_global_variables_code([]) :-
2661 tmp_module, !.
2662prolog_global_variables_code(B) :-
2663 prolog_global_variables(A),
2664 ( A==[]
2665 -> B=[]
2666 ; maplist(wrap_in_functor('$chr_prolog_global_variable'),
2667 A,
2668 D),
2669 B=[(:-dynamic user:exception/3), (:-multifile user:exception/3), (user:exception(undefined_global_variable, C, retry):-'$chr_prolog_global_variable'(C), '$chr_initialization')|D]
2670 ).
2671tmp_module :-
2672 prolog_load_context(module, A),
2673 module_property(A, class(temporary)).
2674:- else. 2675prolog_global_variables_code([]).
2676:- endif. 2677sbag_member_call(A, B, member(A, B)).
2678update_mutable_call(A, B, 'chr update_mutable'(A, B)).
2679create_mutable_call(B, A, true) :-
2680 A=mutable(B).
2681get_suspension_field(B, C, A, D, E) :-
2682 get_dynamic_suspension_term_field(A,
2683 B,
2684 C,
2685 D,
2686 E).
2687update_suspension_field(B, C, A, D, E) :-
2688 set_dynamic_suspension_term_field(A,
2689 B,
2690 C,
2691 D,
2692 E).
2693get_update_suspension_field(B, C, A, D, F, true, E, G) :-
2694 get_dynamic_suspension_term_field(A,
2695 B,
2696 C,
2697 D,
2698 E),
2699 set_dynamic_suspension_term_field(A,
2700 B,
2701 C,
2702 F,
2703 G).
2704create_static_suspension_field(B, C, A, D, true) :-
2705 get_static_suspension_term_field(A, B, C, D).
2706get_static_suspension_field(B, C, A, D, true) :-
2707 get_static_suspension_term_field(A, B, C, D).
2708get_update_static_suspension_field(B, E, C, A, D, F, true, G) :-
2709 get_static_suspension_term_field(A, B, C, D),
2710 set_dynamic_suspension_term_field(A,
2711 B,
2712 E,
2713 F,
2714 G).
2715enumerate_stores_code(C, [A|E]) :-
2716 B='$enumerate_constraints'(D),
2717 A=(B:-F),
2718 enumerate_store_bodies(C, D, E),
2719 ( E=[]
2720 -> F=fail
2721 ; F=(nonvar(D)->functor(D, G, _), '$enumerate_constraints'(G, D);'$enumerate_constraints'(_, D))
2722 ).
2723enumerate_store_bodies([], _, []).
2724enumerate_store_bodies([A|N], F, J) :-
2725 ( is_stored(A)
2726 -> get_store_type(A, B),
2727 ( enumerate_store_body(B, A, C, G)
2728 -> true
2729 ; chr_error(internal,
2730 'Could not generate enumeration code for constraint ~w.\n',
2731 [A])
2732 ),
2733 get_dynamic_suspension_term_field(arguments,
2734 A,
2735 C,
2736 E,
2737 H),
2738 A=D/_,
2739 I=..[D|E],
2740 K='$enumerate_constraints'(D, F),
2741 L=(G, H, F=I),
2742 J=[(K:-L)|M]
2743 ; J=M
2744 ),
2745 enumerate_store_bodies(N, F, M).
2746enumerate_store_body(default, A, B, E) :-
2747 global_list_store_name(A, C),
2748 sbag_member_call(B, D, G),
2749 make_get_store_goal_no_error(C, D, F),
2750 E=(F, G).
2751enumerate_store_body(multi_inthash([A|_]), B, C, D) :-
2752 multi_inthash_enumerate_store_body(A, B, C, D).
2753enumerate_store_body(multi_hash([A|_]), B, C, D) :-
2754 multi_hash_enumerate_store_body(A, B, C, D).
2755enumerate_store_body(atomic_constants(C, D, A), B, H, F) :-
2756 A==complete,
2757 maplist(enumerate_constant_store_body(B, C, I),
2758 D,
2759 E),
2760 list2disj(E, G),
2761 F=(G, member(H, I)).
2762enumerate_constant_store_body(B, C, A, D, nb_getval(E, A)) :-
2763 constants_store_name(B, C, D, E).
2764enumerate_store_body(ground_constants(A, B, C), D, E, F) :-
2765 enumerate_store_body(atomic_constants(A, B, C),
2766 D,
2767 E,
2768 F).
2769enumerate_store_body(global_ground, A, B, E) :-
2770 global_ground_store_name(A, C),
2771 sbag_member_call(B, D, G),
2772 make_get_store_goal(C, D, F),
2773 E=(F, G).
2774enumerate_store_body(var_assoc_store(_, _), _, _, A) :-
2775 A=fail.
2776enumerate_store_body(global_singleton, A, C, D) :-
2777 global_singleton_store_name(A, B),
2778 make_get_store_goal(B, C, E),
2779 D=(E, C\==[]).
2780enumerate_store_body(multi_store(A), B, C, D) :-
2781 ( memberchk(global_ground, A)
2782 -> enumerate_store_body(global_ground, B, C, D)
2783 ; once(( member(E, A),
2784 enumerate_store_body(E, B, C, D)
2785 ))
2786 ).
2787enumerate_store_body(identifier_store(_), _, _, A) :-
2788 A=fail.
2789enumerate_store_body(type_indexed_identifier_store(_, _), _, _, A) :-
2790 A=fail.
2791multi_inthash_enumerate_store_body(B, A, F, C) :-
2792 multi_hash_store_name(A, B, D),
2793 C=(nb_getval(D, E), value_iht(E, F)).
2794multi_hash_enumerate_store_body(B, A, G, D) :-
2795 multi_hash_store_name(A, B, C),
2796 make_get_store_goal(C, F, E),
2797 D=(E, value_ht(F, G)).
2798guard_simplification :-
2799 ( chr_pp_flag(guard_simplification, on)
2800 -> precompute_head_matchings,
2801 simplify_guards(1)
2802 ; true
2803 ).
2804next_prev_rule(A, C, D) :-
2805 ( find_min_q(A, _-B)
2806 -> B=(-C),
2807 normalize_heap(A, B, D)
2808 ; C=0,
2809 D=A
2810 ).
2811normalize_heap(A, B, I) :-
2812 ( find_min_q(A, _-B)
2813 -> delete_min_q(A,
2814 F,
2815 tuple(D, C, _)-_),
2816 ( C>1
2817 -> E is C-1,
2818 get_occurrence(D, E, G, _),
2819 insert_q(F,
2820 tuple(D, E, G)-(-G),
2821 H)
2822 ; H=F
2823 ),
2824 normalize_heap(H, B, I)
2825 ; I=A
2826 ).
2827head_types_modes_condition([], _, true).
2828head_types_modes_condition([B|D], A, (C, E)) :-
2829 types_modes_condition(A, B, C),
2830 head_types_modes_condition(D, A, E).
2831add_background_info(A, D) :-
2832 get_bg_info(B),
2833 add_background_info2(A, C),
2834 append(B, C, D).
2835add_background_info2(A, []) :-
2836 var(A), !.
2837add_background_info2([], []) :- !.
2838add_background_info2([A|B], E) :- !,
2839 add_background_info2(A, C),
2840 add_background_info2(B, D),
2841 append(C, D, E).
2842add_background_info2(A, F) :-
2843 ( functor(A, _, B),
2844 B>0
2845 -> A=..[_|C],
2846 add_background_info2(C, D)
2847 ; D=[]
2848 ),
2849 get_bg_info(A, E),
2850 append(E, D, F).
2851normalize_conj_list(A, C) :-
2852 list2conj(A, B),
2853 conj2list(B, C).
2854compute_derived_info([], _, _, _, _, _, _, _, [], []).
2855compute_derived_info([D|Z], A, H, G, B, A1, U, B1, [R|C1], [Y|D1]) :-
2856 copy_term(A-B, C),
2857 variable_replacement(A-B, C, E),
2858 append(D, E, J),
2859 list2conj(A, F),
2860 negate_b(F, N),
2861 make_head_matchings_explicit_not_negated2(G, H, I),
2862 list2conj(I, P),
2863 term_variables(J, L),
2864 term_variables(A-B-I, K),
2865 new_vars(K, L, M),
2866 append(J, M, S),
2867 ( B==true
2868 -> O=N
2869 ; negate_b(B, Q),
2870 O=(N;P, Q)
2871 ),
2872 copy_with_variable_replacement(O, R, S),
2873 copy_with_variable_replacement(B, V, S),
2874 copy_with_variable_replacement(A, T, S),
2875 list2conj(T, X),
2876 apply_guard_wrt_term(U, V, W),
2877 apply_guard_wrt_term(W, X, Y),
2878 compute_derived_info(Z,
2879 A,
2880 H,
2881 G,
2882 B,
2883 A1,
2884 U,
2885 B1,
2886 C1,
2887 D1).
2888simplify_guard(A, C, B, G, E) :-
2889 conj2list(A, D),
2890 guard_entailment:simplify_guards(B, C, D, F, E),
2891 list2conj(F, G).
2892new_vars([], _, []).
2893new_vars([A|C], B, D) :-
2894 ( memberchk_eq(A, B)
2895 -> new_vars(C, B, D)
2896 ; D=[A-E, E-A|F],
2897 new_vars(C, B, F)
2898 ).
2899head_subset(A, B, C) :-
2900 head_subset(A, B, C, [], _).
2901head_subset([], B, A, A, B).
2902head_subset([B|D], A, F, C, H) :-
2903 head_member(A, B, G, C, E),
2904 head_subset(D, E, F, G, H).
2905head_member([B|F], A, D, C, E) :-
2906 ( variable_replacement(A, B, C, D),
2907 E=F
2908 ; E=[B|G],
2909 head_member(F, A, D, C, G)
2910 ).
2911make_head_matchings_explicit(A, D, E) :-
2912 make_head_matchings_explicit_memo_lookup(A, B, C),
2913 copy_term_nat(B-C, D-E).
2914make_head_matchings_explicit_(A, E, C) :-
2915 extract_arguments(A, B),
2916 make_matchings_explicit(B, D, [], [], _, C),
2917 substitute_arguments(A, D, E).
2918make_head_matchings_explicit_not_negated(A, E, C) :-
2919 extract_arguments(A, B),
2920 make_matchings_explicit_not_negated(B, D, C),
2921 substitute_arguments(A, D, E).
2922make_head_matchings_explicit_not_negated2(A, B, E) :-
2923 extract_arguments(A, C),
2924 extract_arguments(B, D),
2925 make_matchings_explicit_not_negated(C, D, E).
([], []).
2927extract_arguments([A|D], C) :-
2928 A=..[_|B],
2929 append(B, E, C),
2930 extract_arguments(D, E).
2931substitute_arguments([], [], []).
2932substitute_arguments([A|G], C, [D|I]) :-
2933 functor(A, E, B),
2934 split_at(B, C, F, H),
2935 D=..[E|F],
2936 substitute_arguments(G, H, I).
2937make_matchings_explicit([], [], _, A, A, []).
2938make_matchings_explicit([A|S], [F|U], B, C, V, D) :-
2939 ( var(A)
2940 -> ( memberchk_eq(A, B)
2941 -> list2disj(C, E),
2942 D=[(E;F==A)|G],
2943 H=B
2944 ; D=G,
2945 F=A,
2946 H=[A|B]
2947 ),
2948 Q=C
2949 ; functor(A, I, M),
2950 A=..[I|J],
2951 make_matchings_explicit(J,
2952 K,
2953 B,
2954 C,
2955 R,
2956 L),
2957 N=..[I|K],
2958 ( L==[]
2959 -> D=[functor(F, I, M)|G]
2960 ; list2conj(L, O),
2961 list2disj(C, E),
2962 P=(F\=N;E;O),
2963 D=[functor(F, I, M), P|G]
2964 ),
2965 Q=[F\=N|R],
2966 term_variables(S, T),
2967 append(T, B, H)
2968 ),
2969 make_matchings_explicit(S,
2970 U,
2971 H,
2972 Q,
2973 V,
2974 G).
2975make_matchings_explicit_not_negated([], [], []).
2976make_matchings_explicit_not_negated([C|D], [B|E], A) :-
2977 A=[B=C|F],
2978 make_matchings_explicit_not_negated(D, E, F).
2979apply_guard_wrt_term([], _, []).
2980apply_guard_wrt_term([A|G], B, [C|H]) :-
2981 ( var(A)
2982 -> apply_guard_wrt_variable(B, A, C)
2983 ; A=..[E|D],
2984 apply_guard_wrt_term(D, B, F),
2985 C=..[E|F]
2986 ),
2987 apply_guard_wrt_term(G, B, H).
2988apply_guard_wrt_variable((A, C), B, E) :- !,
2989 apply_guard_wrt_variable(A, B, D),
2990 apply_guard_wrt_variable(C, D, E).
2991apply_guard_wrt_variable(A, B, D) :-
2992 ( A=(C=E),
2993 B==C
2994 -> D=E
2995 ; A=functor(F, G, H),
2996 B==F,
2997 ground(G),
2998 ground(H)
2999 -> functor(D, G, H)
3000 ; D=B
3001 ).
3002replace_some_heads(A, B, _, [], A, B, _, _, []) :- !.
3003replace_some_heads([], [M|D], [A|E], [B|F], [], [C|G], H, I, J) :- !,
3004 ( A==B
3005 -> C=B,
3006 replace_some_heads([],
3007 D,
3008 E,
3009 F,
3010 [],
3011 G,
3012 H,
3013 I,
3014 J)
3015 ; B=functor(K, N, L),
3016 A==K
3017 -> length(O, L),
3018 ( var(M)
3019 -> Q=[],
3020 C=..[N|O]
3021 ; M=..[N|P],
3022 use_same_args(P,
3023 O,
3024 R,
3025 H,
3026 I,
3027 Q),
3028 C=..[N|R]
3029 ),
3030 replace_some_heads([],
3031 D,
3032 E,
3033 F,
3034 [],
3035 G,
3036 H,
3037 I,
3038 S),
3039 append(Q, S, J)
3040 ; C=M,
3041 replace_some_heads([],
3042 D,
3043 E,
3044 [B|F],
3045 [],
3046 G,
3047 H,
3048 I,
3049 J)
3050 ).
3051replace_some_heads([O|D], E, [A|F], [B|G], [C|H], I, J, K, L) :- !,
3052 ( A==B
3053 -> C=B,
3054 replace_some_heads(D,
3055 E,
3056 F,
3057 G,
3058 H,
3059 I,
3060 J,
3061 K,
3062 L)
3063 ; B=functor(M, P, N),
3064 A==M
3065 -> length(Q, N),
3066 ( var(O)
3067 -> S=[],
3068 C=..[P|Q]
3069 ; O=..[P|R],
3070 use_same_args(R,
3071 Q,
3072 T,
3073 J,
3074 K,
3075 S),
3076 C=..[P|T]
3077 ),
3078 replace_some_heads(D,
3079 E,
3080 F,
3081 G,
3082 H,
3083 I,
3084 J,
3085 K,
3086 U),
3087 append(S, U, L)
3088 ; C=O,
3089 replace_some_heads(D,
3090 E,
3091 F,
3092 [B|G],
3093 H,
3094 I,
3095 J,
3096 K,
3097 L)
3098 ).
3099use_same_args([], [], [], _, _, []).
3100use_same_args([A|C], [_|D], [B|E], F, G, H) :-
3101 var(A), !,
3102 B=A,
3103 use_same_args(C, D, E, F, G, H).
3104use_same_args([A|G], [D|H], [F|I], J, B, C) :-
3105 nonvar(A), !,
3106 ( common_variables(A, B)
3107 -> C=[D=A|E]
3108 ; C=E
3109 ),
3110 F=D,
3111 use_same_args(G, H, I, J, B, E).
3112simplify_heads([], _, _, _, [], []).
3113simplify_heads([A|C], D, F, I, H, G) :-
3114 A=(E=B),
3115 ( ( nonvar(B)
3116 ; common_variables(B, C-D)
3117 ),
3118 guard_entailment:entails_guard(D, E=B)
3119 -> ( common_variables(B, F-C-D)
3120 -> G=J,
3121 H=K
3122 ; ( common_variables(B, I)
3123 -> G=[E=B|J]
3124 ; G=J
3125 ),
3126 H=[E|K]
3127 )
3128 ; nonvar(B),
3129 functor(B, L, M),
3130 guard_entailment:entails_guard([functor(E, L, M)|D], E=B)
3131 -> G=J,
3132 ( common_variables(B, F-C-D)
3133 -> H=K
3134 ; H=[functor(E, L, M)|K]
3135 )
3136 ; H=K,
3137 G=J
3138 ),
3139 simplify_heads(C,
3140 [A|D],
3141 F,
3142 I,
3143 K,
3144 J).
3145common_variables(A, B) :-
3146 term_variables(A, C),
3147 term_variables(B, D),
3148 intersect_eq(C, D, E),
3149 E\==[].
3150add_failing_occ(A, D, E, G, S, R, _, H, M) :-
3151 A=pragma(rule(_, _, N, _), ids(C, B), _, _, _),
3152 append(B, C, F),
3153 missing_partner_cond(D,
3154 E,
3155 F,
3156 G,
3157 Q,
3158 I,
3159 H),
3160 copy_term((I, D, E), (J, K, L)),
3161 variable_replacement((I, D, E),
3162 (J, K, L),
3163 M),
3164 copy_with_variable_replacement(N, O, M),
3165 extract_explicit_matchings(O, P),
3166 negate_b(P, T),
3167 copy_with_variable_replacement(Q, U, M),
3168 ( subsumes_term(R, J),
3169 R=J
3170 -> S=[(T;U)]
3171 ; S=[chr_pp_void_info]
3172 ).
3173missing_partner_cond([], [], [], _, fail, _, _).
3174missing_partner_cond([B|C], [_|D], [A|E], A, F, B, G) :- !,
3175 missing_partner_cond(C,
3176 D,
3177 E,
3178 A,
3179 F,
3180 B,
3181 G).
3182missing_partner_cond([B|C], [_|D], [_|E], F, A, H, I/J) :-
3183 A=(chr_pp_not_in_store(B);G),
3184 missing_partner_cond(C,
3185 D,
3186 E,
3187 F,
3188 G,
3189 H,
3190 I/J).
((A, B), C) :- !,
3192 ( extract_explicit_matchings(A)
3193 -> extract_explicit_matchings(B, C)
3194 ; C=(A, D),
3195 extract_explicit_matchings(B, D)
3196 ).
3197extract_explicit_matchings(A, B) :- !,
3198 ( extract_explicit_matchings(A)
3199 -> B=true
3200 ; B=A
3201 ).
(A=B) :-
3203 var(A),
3204 var(B), !,
3205 A=B.
3206extract_explicit_matchings(A==B) :-
3207 var(A),
3208 var(B), !,
3209 A=B.
3210assert_constraint_type(B, A) :-
3211 ( ground(A)
3212 -> constraint_type(B, A)
3213 ; chr_error(type_error,
3214 'Declared argument types "~w" for constraint "~w" must be ground!\n',
3215 [A, B])
3216 ).
3217get_type_definition_det(A, B) :-
3218 ( get_type_definition(A, B)
3219 -> true
3220 ; chr_error(type,
3221 'Could not find type definition for type `~w\'.\n',
3222 [A])
3223 ).
3224get_constraint_type_det(A, B) :-
3225 ( get_constraint_type(A, B)
3226 -> true
3227 ; A=_/C,
3228 replicate(C, any, B)
3229 ).
3230modes_condition([], [], true).
3231modes_condition([A|E], [C|F], B) :-
3232 ( A==(+)
3233 -> B=(ground(C), D)
3234 ; A==(-)
3235 -> B=(var(C), D)
3236 ; B=D
3237 ),
3238 modes_condition(E, F, D).
3239types_condition([], [], [], [], true).
3240types_condition([B|I], [D|J], [E|K], [A|L], (H, M)) :-
3241 ( A==(-)
3242 -> F=[true]
3243 ; get_type_definition_det(B, C),
3244 type_condition(C, D, E, A, G),
3245 ( A==(+)
3246 -> F=G
3247 ; F=[\+ground(D)|G]
3248 )
3249 ),
3250 list2disj(F, H),
3251 types_condition(I, J, K, L, M).
3252type_condition([], _, _, _, []).
3253type_condition([A|F], B, D, E, [C|G]) :-
3254 ( var(A)
3255 -> chr_error(type, 'Unexpected variable type in type definition!\n', [])
3256 ; atomic_builtin_type(A, B, C)
3257 -> true
3258 ; compound_builtin_type(A, B, C, _)
3259 -> true
3260 ; type_def_case_condition(A, B, D, E, C)
3261 ),
3262 type_condition(F, B, D, E, G).
3263ast_atomic_builtin_type(B, A, D) :-
3264 ast_term_to_term(A, C),
3265 atomic_builtin_type(B, C, D).
3266ast_compound_builtin_type(B, A, D) :-
3267 ast_term_to_term(A, C),
3268 compound_builtin_type(B, C, _, D).
3269atomic_builtin_type(any, _, true).
3270atomic_builtin_type(dense_int, A, (integer(A), A>=0)).
3271atomic_builtin_type(int, A, integer(A)).
3272atomic_builtin_type(number, A, number(A)).
3273atomic_builtin_type(float, A, float(A)).
3274atomic_builtin_type(natural, A, (integer(A), A>=0)).
3275atomic_builtin_type(chr_identifier, _, true).
3276compound_builtin_type(chr_constants(_), _, true, true).
3277compound_builtin_type(chr_constants(_, _), _, true, true).
3278compound_builtin_type(chr_identifier(_), _, true, true).
3279compound_builtin_type(chr_enum(B), A, (ground(A), memberchk(A, B)), once((member(C, B), unifiable(A, C, _)))).
3280compound_builtin_type(chr_enum(_, _), _, true, true).
3281is_chr_constants_type(chr_constants(A), A, no).
3282is_chr_constants_type(chr_constants(A, B), A, yes(B)).
3283is_chr_enum_type(chr_enum(A), A, no).
3284is_chr_enum_type(chr_enum(A, B), A, yes(B)).
3285type_def_case_condition(A, D, E, H, C) :-
3286 ( nonvar(A)
3287 -> functor(A, F, B),
3288 ( B==0
3289 -> C=(D=A)
3290 ; var(E)
3291 -> C=functor(D, F, B)
3292 ; functor(E, F, B)
3293 -> C=(functor(D, F, B), D=G, M),
3294 A=..[_|I],
3295 E=..[_|K],
3296 functor(G, F, B),
3297 G=..[_|J],
3298 replicate(B, H, L),
3299 types_condition(I, J, K, L, M)
3300 ; C=functor(D, F, B)
3301 )
3302 ; chr_error(internal, 'Illegal type definition (must be nonvar).\n', [])
3303 ).
3304static_type_check_rule(F, A) :-
3305 A=ast_rule(B, _, _, C, _),
3306 ( catch(( ast_static_type_check_head(B),
3307 ast_static_type_check_body(C)
3308 ),
3309 type_error(D),
3310 ( D=invalid_functor(E, G, H)
3311 -> chr_error(type_error,
3312 'Invalid functor in ~@ of ~@:\n\t\tfound `~w\',\n\t\texpected type `~w\'!\n',
3313
3314 [ chr_translate:format_src(E),
3315 format_rule(F),
3316 G,
3317 H
3318 ])
3319 ; D=type_clash(I, K, M, J, L)
3320 -> chr_error(type_error,
3321 'Type clash for variable ~w in ~@:\n\t\texpected type ~w in ~@\n\t\texpected type ~w in ~@\n',
3322
3323 [ I,
3324 format_rule(F),
3325 J,
3326 chr_translate:format_src(K),
3327 L,
3328 chr_translate:format_src(M)
3329 ])
3330 )),
3331 fail
3332 ; true
3333 ).
3334ast_static_type_check_head(simplification(A)) :-
3335 maplist(ast_static_type_check_head_constraint, A).
3336ast_static_type_check_head(propagation(A)) :-
3337 maplist(ast_static_type_check_head_constraint, A).
3338ast_static_type_check_head(simpagation(A, B)) :-
3339 maplist(ast_static_type_check_head_constraint, A),
3340 maplist(ast_static_type_check_head_constraint, B).
3341ast_static_type_check_head_constraint(A) :-
3342 A=chr_constraint(B, C, _),
3343 get_constraint_type_det(B, D),
3344 maplist(ast_static_type_check_term(head(_)), C, D).
3345ast_static_type_check_body([]).
3346ast_static_type_check_body([A|E]) :-
3347 ast_symbol(A, B),
3348 get_constraint_type_det(B, D),
3349 ast_args(A, C),
3350 maplist(ast_static_type_check_term(body(A)), C, D),
3351 ast_static_type_check_body(E).
3352format_src(head(A)) :-
3353 format('head ~w', [A]).
3354format_src(body(A)) :-
3355 format('body goal ~w', [A]).
3356generate_dynamic_type_check_clauses(D) :-
3357 ( chr_pp_flag(debugable, on)
3358 -> dynamic_type_check,
3359 get_dynamic_type_check_clauses(A),
3360 append(A,
3361
3362 [ ('$dynamic_type_check'(B, C):-throw(error(type_error(B, C), context(_, 'CHR Runtime Type Error'))))
3363 ],
3364 D)
3365 ; D=[]
3366 ).
3367dynamic_type_check_clause(A, B, J) :-
3368 copy_term(A-B, K-C),
3369 functor(C, D, E),
3370 functor(F, D, E),
3371 C=..[_|G],
3372 F=..[_|H],
3373 maplist(dynamic_type_check_call, G, H, I),
3374 list2conj(I, L),
3375 J=('$dynamic_type_check'(K, F):-L).
3376dynamic_type_check_alias_clause(B, C, A) :-
3377 A=('$dynamic_type_check'(B, D):-'$dynamic_type_check'(C, D)).
3378dynamic_type_check_call(A, C, B) :-
3379 ( A==any
3380 -> B=true
3381 ; B=when(nonvar(C), once('$dynamic_type_check'(A, C)))
3382 ).
3383atomic_types_suspended_constraint(A) :-
3384 A=_/B,
3385 get_constraint_type(A, C),
3386 get_constraint_mode(A, D),
3387 numlist(1, B, E),
3388 maplist(atomic_types_suspended_constraint(A),
3389 C,
3390 D,
3391 E).
3392atomic_types_suspended_constraint(A, D, C, B) :-
3393 ( is_indexed_argument(A, B)
3394 -> ( C==(?)
3395 -> atomic_type(D)
3396 ; true
3397 )
3398 ; true
3399 ).
3400storage_analysis(A) :-
3401 ( chr_pp_flag(storage_analysis, on)
3402 -> check_constraint_storages(A)
3403 ; true
3404 ).
3405check_constraint_storages(A) :-
3406 maplist(check_constraint_storage, A).
3407check_constraint_storage(A) :-
3408 get_max_occurrence(A, B),
3409 check_occurrences_storage(A, 1, B).
3410check_occurrences_storage(C, A, B) :-
3411 ( A>B
3412 -> stored_completing(C, 1, 0)
3413 ; check_occurrence_storage(C, A),
3414 D is A+1,
3415 check_occurrences_storage(C, D, B)
3416 ).
3417check_occurrence_storage(A, B) :-
3418 get_occurrence(A, B, C, D, F),
3419 ( is_passive(C, D)
3420 -> stored(A, B, maybe)
3421 ; get_rule(C, E),
3422 E=pragma(rule(H, J, K, N), ids(G, L), _, _, _),
3423 ( F==simplification,
3424 select2(D, I, G, H, _, _)
3425 -> check_storage_head1(I, B, H, J, K)
3426 ; F==propagation,
3427 select2(D, M, L, J, _, _)
3428 -> check_storage_head2(M, B, H, N)
3429 )
3430 ).
3431check_storage_head1(A, I, D, E, F) :-
3432 functor(A, B, C),
3433 H=B/C,
3434 ( D==[A],
3435 E==[],
3436 guard_entailment:entails_guard([chr_pp_headvariables(A)], F),
3437 A=..[_|G],
3438 no_matching(G, [])
3439 -> stored(H, I, no)
3440 ; stored(H, I, maybe)
3441 ).
3442no_matching([], _).
3443no_matching([A|C], B) :-
3444 var(A),
3445 \+ memberchk_eq(A, B),
3446 no_matching(C, [A|B]).
3447check_storage_head2(A, G, D, E) :-
3448 functor(A, B, C),
3449 F=B/C,
3450 ( D\==[],
3451 E==true
3452 -> stored(F, G, maybe)
3453 ; stored(F, G, yes)
3454 ).
3455constraints_code(A, C) :-
3456 ( chr_pp_flag(reduced_indexing, on),
3457 forall(B,
3458 A,
3459 chr_translate:only_ground_indexed_arguments(B))
3460 -> none_suspended_on_variables
3461 ; true
3462 ),
3463 constraints_code1(A, C, []).
3464constraint_prelude(B/A, K) :-
3465 vars_susp(A, C, E, D),
3466 L=..[B|C],
3467 make_suspension_continuation_goal(B/A, D, G),
3468 build_head(B, A, [0], D, Q),
3469 ( chr_pp_flag(debugable, on)
3470 -> insert_constraint_goal(B/A, E, C, N),
3471 attach_constraint_atom(B/A, F, E, O),
3472 delay_phase_end(validate_store_type_assumptions,
3473 chr_translate:update_suspension_field(B/A, E, state, inactive, P)),
3474 insert_constraint_internal_constraint_goal(B/A,
3475 F,
3476 E,
3477 G,
3478 C,
3479 M),
3480 ( get_constraint_type(B/A, H)
3481 -> maplist(dynamic_type_check_call, H, C, I),
3482 list2conj(I, J)
3483 ; J=true
3484 ),
3485 K=(L:-J, M, N, O, P, 'chr debug_event'(insert(#(L, E))), ('chr debugging'->('chr debug_event'(call(E)), Q;'chr debug_event'(fail(E)), !, fail), ('chr debug_event'(exit(E));'chr debug_event'(redo(E)), fail);Q))
3486 ; get_allocation_occurrence(B/A, 0)
3487 -> gen_insert_constraint_internal_goal(B/A,
3488 R,
3489 D,
3490 C,
3491 E),
3492 delay_phase_end(validate_store_type_assumptions,
3493 chr_translate:update_suspension_field(B/A, E, state, inactive, P)),
3494 K=(L:-R, P, Q)
3495 ; K=(L:-Q)
3496 ).
3497make_suspension_continuation_goal(A/B, C, D) :-
3498 ( may_trigger(A/B)
3499 -> build_head(A, B, [0], C, E),
3500 ( chr_pp_flag(debugable, off)
3501 -> D=E
3502 ; get_target_module(F),
3503 D=F:E
3504 )
3505 ; D=true
3506 ).
3507gen_cond_attach_clause(A/B, I, L, N) :-
3508 ( is_finally_stored(A/B)
3509 -> get_allocation_occurrence(A/B, D),
3510 get_max_occurrence(A/B, C),
3511 ( chr_pp_flag(debugable, off),
3512 C<D
3513 -> ( only_ground_indexed_arguments(A/B)
3514 -> gen_insert_constraint_internal_goal(A/B,
3515 E,
3516 F,
3517 G,
3518 H)
3519 ; gen_cond_attach_goal(A/B,
3520 E,
3521 F,
3522 G,
3523 H)
3524 )
3525 ; vars_susp(B, G, H, F),
3526 gen_uncond_attach_goal(A/B,
3527 H,
3528 G,
3529 E,
3530 _)
3531 ),
3532 build_head(A, B, I, F, J),
3533 K=(J:-E),
3534 add_dummy_location(K, M),
3535 L=[M|N]
3536 ; L=N
3537 ).
3538gen_cond_attach_goal(E/A, J, D, B, C) :-
3539 vars_susp(A, B, C, D),
3540 make_suspension_continuation_goal(E/A, D, H),
3541 ( get_store_type(E/A, var_assoc_store(_, _))
3542 -> F=true
3543 ; attach_constraint_atom(E/A, G, C, F)
3544 ),
3545 _=..[E|B],
3546 insert_constraint_goal(E/A, C, B, I),
3547 insert_constraint_internal_constraint_goal(E/A,
3548 G,
3549 C,
3550 H,
3551 B,
3552 K),
3553 ( may_trigger(E/A)
3554 -> activate_constraint_goal(E/A,
3555 (I, F),
3556 G,
3557 C,
3558 _,
3559 L),
3560 J=(var(C)->K, I, F;L)
3561 ; J=(K, I, F)
3562 ).
3563gen_insert_constraint_internal_goal(E/A, I, D, B, C) :-
3564 vars_susp(A, B, C, D),
3565 make_suspension_continuation_goal(E/A, D, H),
3566 ( \+ only_ground_indexed_arguments(E/A),
3567 \+ get_store_type(E/A,
3568 var_assoc_store(_, _))
3569 -> attach_constraint_atom(E/A, G, C, F)
3570 ; F=true
3571 ),
3572 _=..[E|B],
3573 insert_constraint_goal(E/A, C, B, K),
3574 insert_constraint_internal_constraint_goal(E/A,
3575 G,
3576 C,
3577 H,
3578 B,
3579 J),
3580 ( only_ground_indexed_arguments(E/A),
3581 chr_pp_flag(debugable, off)
3582 -> I=(J, K)
3583 ; I=(J, K, F)
3584 ).
3585gen_uncond_attach_goal(A, B, D, H, G) :-
3586 ( \+ only_ground_indexed_arguments(A),
3587 \+ get_store_type(A, var_assoc_store(_, _))
3588 -> attach_constraint_atom(A, F, B, C)
3589 ; C=true
3590 ),
3591 insert_constraint_goal(A, B, D, E),
3592 ( chr_pp_flag(late_allocation, on)
3593 -> activate_constraint_goal(A,
3594 (E, C),
3595 F,
3596 B,
3597 G,
3598 H)
3599 ; activate_constraint_goal(A,
3600 true,
3601 F,
3602 B,
3603 G,
3604 H)
3605 ).
3606head1_code(E, H, F, G, A, K, L, M, N, O) :-
3607 A=pragma(B, _, _, _, D),
3608 B=rule(_, C, _, _),
3609 ( C==[]
3610 -> reorder_heads(D, E, F, G, I, J),
3611 simplification_code(E,
3612 H,
3613 I,
3614 J,
3615 A,
3616 K,
3617 L,
3618 M,
3619 N,
3620 O)
3621 ; simpagation_head1_code(E,
3622 H,
3623 F,
3624 G,
3625 A,
3626 K,
3627 L,
3628 M,
3629 N,
3630 O)
3631 ).
3632head2_code(E, H, F, G, A, K, L, M, N, O) :-
3633 A=pragma(B, _, _, _, D),
3634 B=rule(C, _, _, _),
3635 ( C==[]
3636 -> reorder_heads(D, E, F, G, I, J),
3637 propagation_code(E,
3638 H,
3639 I,
3640 J,
3641 B,
3642 D,
3643 K,
3644 L,
3645 M,
3646 N,
3647 O)
3648 ; simpagation_head2_code(E,
3649 H,
3650 F,
3651 G,
3652 A,
3653 K,
3654 L,
3655 M,
3656 N,
3657 O)
3658 ).
3659gen_alloc_inc_clause(B/A, F, C, M, O) :-
3660 vars_susp(A, G, H, D),
3661 build_head(B, A, C, D, I),
3662 inc_id(C, E),
3663 build_head(B, A, E, D, K),
3664 gen_occ_allocation(B/A, F, G, H, J),
3665 L=(I:-J, K),
3666 add_dummy_location(L, N),
3667 M=[N|O].
3668gen_occ_allocation(A, C, G, F, H) :-
3669 get_allocation_occurrence(A, B),
3670 get_occurrence_code_id(A, B, E),
3671 get_occurrence_code_id(A, C, D),
3672 ( chr_pp_flag(debugable, off),
3673 D==E
3674 -> allocate_constraint_goal(A, F, G, I),
3675 ( may_trigger(A)
3676 -> H=(var(F)->I;true)
3677 ; H=I
3678 )
3679 ; H=true
3680 ).
3681gen_occ_allocation_in_guard(A, B, E, D, F) :-
3682 get_allocation_occurrence(A, C),
3683 ( chr_pp_flag(debugable, off),
3684 B<C
3685 -> allocate_constraint_goal(A, D, E, G),
3686 ( may_trigger(A)
3687 -> F=(var(D)->G;true)
3688 ; F=G
3689 )
3690 ; F=true
3691 ).
3692guard_via_reschedule_new(A, B, C, D, E, G) :-
3693 ( chr_pp_flag(guard_via_reschedule, on)
3694 -> guard_via_reschedule_main_new(A,
3695 B,
3696 C,
3697 D,
3698 E,
3699 F),
3700 list2conj(F, G)
3701 ; length(A, H),
3702 length(E, H),
3703 length(B, I),
3704 length(D, I),
3705 append(E, D, J),
3706 list2conj(J, G)
3707 ).
3708guard_via_reschedule_main_new(B, C, A, M, I, J) :-
3709 initialize_unit_dictionary(A, F),
3710 maplist(wrap_in_functor(lookup), B, D),
3711 maplist(wrap_in_functor(guard), C, E),
3712 build_units(D, E, F, G),
3713 dependency_reorder(G, H),
3714 wrappedunits2lists(H, K, I, J),
3715 sort(K, L),
3716 snd_of_pairs(L, M).
3717wrappedunits2lists([], [], [], []).
3718wrappedunits2lists([unit(G, B, _, _)|J], E, C, A) :-
3719 A=[D|K],
3720 ( B=lookup(F)
3721 -> C=[D|I],
3722 E=H
3723 ; B=guard(F)
3724 -> E=[G-D|H],
3725 C=I
3726 ),
3727 wrappedunits2lists(J, H, I, K).
3728guard_splitting(A, I) :-
3729 A=rule(B, C, D, _),
3730 append(B, C, E),
3731 conj2list(D, F),
3732 term_variables(E, G),
3733 split_off_simple_guard_new(F, G, H, J),
3734 append(H, [Q], I),
3735 term_variables(J, M),
3736 ground_vars(E, K),
3737 list_difference_eq(G, K, L),
3738 intersect_eq(L, M, N),
3739 maplist(chr_lock, N, O),
3740 maplist(chr_unlock, N, P),
3741 list2conj(O, R),
3742 list2conj(P, T),
3743 list2conj(J, S),
3744 Q=(R, S, T).
3745guard_body_copies3(A, B, C, D, G) :-
3746 A=rule(_, _, _, E),
3747 my_term_copy(B, C, F, D),
3748 my_term_copy(E, F, G).
3749split_off_simple_guard_new([], _, [], []).
3750split_off_simple_guard_new([A|D], B, C, F) :-
3751 ( simple_guard_new(A, B)
3752 -> C=[A|E],
3753 split_off_simple_guard_new(D, B, E, F)
3754 ; C=[],
3755 F=[A|D]
3756 ).
3757simple_guard_new(A, D) :-
3758 builtin_binds_b(A, B),
3759 not(( member(C, B),
3760 memberchk_eq(C, D)
3761 )).
3762dependency_reorder(A, B) :-
3763 dependency_reorder(A, [], B).
3764dependency_reorder([], A, B) :-
3765 reverse(A, B).
3766dependency_reorder([A|F], C, G) :-
3767 A=unit(_, _, B, D),
3768 ( B==fixed
3769 -> E=[A|C]
3770 ; dependency_insert(C, A, D, E)
3771 ),
3772 dependency_reorder(F, E, G).
3773dependency_insert([], A, _, [A]).
3774dependency_insert([A|F], E, C, D) :-
3775 A=unit(B, _, _, _),
3776 ( memberchk(B, C)
3777 -> D=[E, A|F]
3778 ; D=[A|G],
3779 dependency_insert(F, E, C, G)
3780 ).
3781build_units(A, D, B, C) :-
3782 build_retrieval_units(A,
3783 1,
3784 E,
3785 B,
3786 F,
3787 C,
3788 G),
3789 build_guard_units(D, E, F, G).
3790build_retrieval_units([], A, A, B, B, C, C).
3791build_retrieval_units([A|G], C, I, D, K, E, M) :-
3792 term_variables(A, B),
3793 update_unit_dictionary(B, C, D, J, [], F),
3794 E=[unit(C, A, fixed, F)|L],
3795 H is C+1,
3796 build_retrieval_units(G,
3797 H,
3798 I,
3799 J,
3800 K,
3801 L,
3802 M).
3803initialize_unit_dictionary(A, C) :-
3804 term_variables(A, B),
3805 pair_all_with(B, 0, C).
3806update_unit_dictionary([], _, A, A, B, B).
3807update_unit_dictionary([B|H], D, A, I, E, J) :-
3808 ( lookup_eq(A, B, C)
3809 -> ( ( C==D
3810 ; memberchk(C, E)
3811 )
3812 -> F=E
3813 ; F=[C|E]
3814 ),
3815 G=A
3816 ; G=[B-D|A],
3817 F=E
3818 ),
3819 update_unit_dictionary(H,
3820 D,
3821 G,
3822 I,
3823 F,
3824 J).
3825build_guard_units(A, C, F, B) :-
3826 ( A=[D]
3827 -> B=[unit(C, D, fixed, [])]
3828 ; A=[D|H]
3829 -> term_variables(D, E),
3830 update_unit_dictionary2(E,
3831 C,
3832 F,
3833 J,
3834 [],
3835 G),
3836 B=[unit(C, D, movable, G)|K],
3837 I is C+1,
3838 build_guard_units(H, I, J, K)
3839 ).
3840update_unit_dictionary2([], _, A, A, B, B).
3841update_unit_dictionary2([B|H], D, A, I, E, J) :-
3842 ( lookup_eq(A, B, C)
3843 -> ( ( C==D
3844 ; memberchk(C, E)
3845 )
3846 -> F=E
3847 ; F=[C|E]
3848 ),
3849 G=[B-D|A]
3850 ; G=[B-D|A],
3851 F=E
3852 ),
3853 update_unit_dictionary2(H,
3854 D,
3855 G,
3856 I,
3857 F,
3858 J).
3859functional_dependency_analysis(A) :-
3860 ( fail,
3861 chr_pp_flag(functional_dependency_analysis, on)
3862 -> functional_dependency_analysis_main(A)
3863 ; true
3864 ).
3865functional_dependency_analysis_main([]).
3866functional_dependency_analysis_main([A|F]) :-
3867 ( discover_unique_pattern(A, B, C, D, E)
3868 -> functional_dependency(B, C, D, E)
3869 ; true
3870 ),
3871 functional_dependency_analysis_main(F).
3872discover_unique_pattern(A, P/Q, B, N, O) :-
3873 A=pragma(C, _, _, _, B),
3874 C=rule(D, E, H, _),
3875 ( D=[F],
3876 E=[G]
3877 -> true
3878 ; D=[F, G],
3879 E==[]
3880 -> true
3881 ),
3882 check_unique_constraints(F, G, H, B, J),
3883 term_variables(F, I),
3884 \+ ( member(K, I),
3885 lookup_eq(J, K, L),
3886 memberchk_eq(L, I)
3887 ),
3888 select_pragma_unique_variables(I, J, M),
3889 copy_term_nat(F-M, N-O),
3890 functor(F, P, Q).
3891select_pragma_unique_variables([], _, []).
3892select_pragma_unique_variables([B|E], A, C) :-
3893 ( lookup_eq(A, B, _)
3894 -> C=D
3895 ; C=[B|D]
3896 ),
3897 select_pragma_unique_variables(E, A, D).
3898set_semantics_rules(A) :-
3899 ( fail,
3900 chr_pp_flag(set_semantics_rule, on)
3901 -> set_semantics_rules_main(A)
3902 ; true
3903 ).
3904set_semantics_rules_main([]).
3905set_semantics_rules_main([A|B]) :-
3906 set_semantics_rule_main(A),
3907 set_semantics_rules_main(B).
3908set_semantics_rule_main(A) :-
3909 A=pragma(B, C, _, _, D),
3910 ( B=rule([F], [K], true, _),
3911 C=ids([E], [N]),
3912 \+ is_passive(D, E),
3913 functor(F, G, H),
3914 get_functional_dependency(G/H,
3915 D,
3916 I,
3917 J),
3918 copy_term_nat(I-J, F-L),
3919 copy_term_nat(I-J, K-M),
3920 L==M
3921 -> passive(D, N)
3922 ; true
3923 ).
3924check_unique_constraints(B, C, E, A, D) :-
3925 \+ any_passive_head(A),
3926 variable_replacement(B-C, C-B, D),
3927 copy_with_variable_replacement(E, G, D),
3928 negate_b(E, F),
3929 once(entails_b(F, G)).
3930symmetry_analysis(A) :-
3931 ( chr_pp_flag(check_unnecessary_active, off)
3932 -> true
3933 ; symmetry_analysis_main(A)
3934 ).
3935symmetry_analysis_main([]).
3936symmetry_analysis_main([A|H]) :-
3937 A=pragma(B, ids(E, G), _, _, F),
3938 B=rule(D, C, _, _),
3939 ( ( \+ chr_pp_flag(check_unnecessary_active, simplification)
3940 ; C==[]
3941 ),
3942 D\==[]
3943 -> symmetry_analysis_heads_simplification(D,
3944 E,
3945 [],
3946 [],
3947 B,
3948 F),
3949 symmetry_analysis_heads_propagation(C,
3950 G,
3951 [],
3952 [],
3953 B,
3954 F)
3955 ; true
3956 ),
3957 symmetry_analysis_main(H).
3958symmetry_analysis_heads_simplification([], [], _, _, _, _).
3959symmetry_analysis_heads_simplification([G|K], [B|L], C, D, H, A) :-
3960 ( \+ is_passive(A, B),
3961 member2(C, D, F-E),
3962 \+ is_passive(A, E),
3963 variable_replacement(F, G, I),
3964 copy_with_variable_replacement(H, J, I),
3965 identical_guarded_rules(H, J)
3966 -> passive(A, B)
3967 ; true
3968 ),
3969 symmetry_analysis_heads_simplification(K,
3970 L,
3971 [G|C],
3972 [B|D],
3973 H,
3974 A).
3975symmetry_analysis_heads_propagation([], [], _, _, _, _).
3976symmetry_analysis_heads_propagation([G|K], [B|L], C, D, H, A) :-
3977 ( \+ is_passive(A, B),
3978 member2(C, D, F-E),
3979 \+ is_passive(A, E),
3980 variable_replacement(F, G, I),
3981 copy_with_variable_replacement(H, J, I),
3982 identical_rules(H, J)
3983 -> passive(A, B)
3984 ; true
3985 ),
3986 symmetry_analysis_heads_propagation(K,
3987 L,
3988 [G|C],
3989 [B|D],
3990 H,
3991 A).
3992simplification_code(B, B1, L, M, A, C, S, D, Q1, S1) :-
3993 A=pragma(H, _, _, _, I),
3994 head_info1(B, C, _, T, E, F),
3995 build_head(C, D, E, J1),
3996 get_constraint_mode(C, G),
3997 head_arg_matches(F, G, [], K1, O, [], P),
3998 guard_splitting(H, J),
3999 ( is_stored_in_guard(C, I)
4000 -> K=[_|J]
4001 ; K=J
4002 ),
4003 guard_via_reschedule_new(L,
4004 K,
4005 B,
4006 R,
4007 N,
4008 L1),
4009 rest_heads_retrieval_and_matching(L,
4010 M,
4011 B,
4012 N,
4013 Y,
4014 O,
4015 Q,
4016 [],
4017 [],
4018 [],
4019 P,
4020 _),
4021 guard_body_copies3(H, K, Q, R, O1),
4022 ( is_stored_in_guard(C, I)
4023 -> gen_occ_allocation_in_guard(C,
4024 S,
4025 U,
4026 T,
4027 W),
4028 gen_uncond_attach_goal(C, T, U, X, _),
4029 R=[V|_],
4030 V=(W, X)
4031 ; true
4032 ),
4033 partner_constraint_detachments(Y, L, Q, M1),
4034 active_constraint_detachment(D,
4035 T,
4036 B,
4037 Q,
4038 N1),
4039 ( chr_pp_flag(debugable, on)
4040 -> H=rule(_, _, Z, A1),
4041 my_term_copy(Z-A1, Q, D1-E1),
4042 sort_by_key([T|Y], [B1|M], C1),
4043 F1='chr debug_event'(try(C1, [], D1, E1)),
4044 G1='chr debug_event'(apply(C1, [], D1, E1)),
4045 instrument_goal(I1, F1, G1, H1)
4046 ; H1=I1
4047 ),
4048 actual_cut(C, S, I1),
4049 P1=(J1:-K1, L1, H1, M1, N1, O1),
4050 add_location(P1, I, R1),
4051 Q1=[R1|S1].
4052actual_cut(A, B, C) :-
4053 ( unconditional_occurrence(A, B),
4054 chr_pp_flag(late_allocation, on)
4055 -> C=true
4056 ; C=!
4057 ).
4058add_location(E, A, B) :-
4059 ( chr_pp_flag(line_numbers, on)
4060 -> get_chr_source_file(C),
4061 get_line_number(A, D),
4062 B='$source_location'(C, D):E
4063 ; B=E
4064 ).
4065add_dummy_location(C, A) :-
4066 ( chr_pp_flag(line_numbers, on)
4067 -> get_chr_source_file(B),
4068 A='$source_location'(B, 1):C
4069 ; A=C
4070 ).
4071head_arg_matches(A, B, C, D, E) :-
4072 head_arg_matches(A, B, C, D, E, [], _).
4073head_arg_matches(A, B, C, H, E, D, F) :-
4074 head_arg_matches_(A,
4075 B,
4076 C,
4077 D,
4078 G,
4079 E,
4080 F),
4081 list2conj(G, H).
4082head_arg_matches_([], [], A, B, [], A, B).
4083head_arg_matches_([silent(B-_)|D], [A|E], F, C, H, I, J) :- !,
4084 ( A==(+)
4085 -> term_variables(B, G, C),
4086 head_arg_matches_(D,
4087 E,
4088 F,
4089 G,
4090 H,
4091 I,
4092 J)
4093 ; head_arg_matches_(D,
4094 E,
4095 F,
4096 C,
4097 H,
4098 I,
4099 J)
4100 ).
4101head_arg_matches_([A-F|K], [C|L], B, D, E, Z, A1) :-
4102 ( var(A)
4103 -> ( lookup_eq(B, A, G)
4104 -> ( C=(+)
4105 -> ( memberchk_eq(A, D)
4106 -> E=[F=G|H],
4107 I=D
4108 ; E=[F==G|H],
4109 I=[A|D]
4110 )
4111 ; E=[F==G|H],
4112 I=D
4113 ),
4114 J=B
4115 ; J=[A-F|B],
4116 E=H,
4117 ( C=(+)
4118 -> I=[A|D]
4119 ; I=D
4120 )
4121 ),
4122 P=K,
4123 Q=L
4124 ; ground(A),
4125 A='$chr_identifier_match'(N, M)
4126 -> identifier_label_atom(M, F, N, O),
4127 E=[O|H],
4128 B=J,
4129 I=D,
4130 P=K,
4131 Q=L
4132 ; atomic(A)
4133 -> ( C=(+)
4134 -> E=[F=A|H]
4135 ; E=[F==A|H]
4136 ),
4137 B=J,
4138 I=D,
4139 P=K,
4140 Q=L
4141 ; C==(+),
4142 is_ground(D, A)
4143 -> copy_with_variable_replacement(A, R, B),
4144 E=[F=R|H],
4145 B=J,
4146 I=D,
4147 P=K,
4148 Q=L
4149 ; C==(?),
4150 is_ground(D, A)
4151 -> copy_with_variable_replacement(A, R, B),
4152 E=[F==R|H],
4153 B=J,
4154 I=D,
4155 P=K,
4156 Q=L
4157 ; A=..[_|V],
4158 functor(A, S, T),
4159 functor(U, S, T),
4160 U=..[_|W],
4161 ( C=(+)
4162 -> E=[F=U|H]
4163 ; E=[nonvar(F), F=U|H]
4164 ),
4165 pairup(V, W, X),
4166 append(X, K, P),
4167 replicate(T, C, Y),
4168 append(Y, L, Q),
4169 J=B,
4170 I=D
4171 ),
4172 head_arg_matches_(P,
4173 Q,
4174 J,
4175 I,
4176 H,
4177 Z,
4178 A1).
4179add_heads_types([], A, A).
4180add_heads_types([A|C], B, E) :-
4181 add_head_types(A, B, D),
4182 add_heads_types(C, D, E).
4183add_head_types(A, F, G) :-
4184 functor(A, B, C),
4185 get_constraint_type_det(B/C, E),
4186 A=..[_|D],
4187 add_args_types(D, E, F, G).
4188add_args_types([], [], A, A).
4189add_args_types([A|D], [B|E], C, G) :-
4190 add_arg_types(A, B, C, F),
4191 add_args_types(D, E, F, G).
4192add_arg_types(D, A, C, B) :-
4193 ( A==any
4194 -> B=C
4195 ; var(D)
4196 -> ( lookup_eq(C, D, _)
4197 -> B=C
4198 ; B=[D-A|C]
4199 )
4200 ; B=C
4201 ).
4202add_heads_ground_variables([], A, A).
4203add_heads_ground_variables([A|C], B, E) :-
4204 add_head_ground_variables(A, B, D),
4205 add_heads_ground_variables(C, D, E).
4206add_head_ground_variables(A, F, G) :-
4207 functor(A, B, C),
4208 get_constraint_mode(B/C, E),
4209 A=..[_|D],
4210 add_arg_ground_variables(D, E, F, G).
4211add_arg_ground_variables([], [], A, A).
4212add_arg_ground_variables([B|F], [A|G], D, H) :-
4213 ( A==(+)
4214 -> term_variables(B, C),
4215 add_var_ground_variables(C, D, E)
4216 ; D=E
4217 ),
4218 add_arg_ground_variables(F, G, E, H).
4219add_var_ground_variables([], A, A).
4220add_var_ground_variables([A|D], B, E) :-
4221 ( memberchk_eq(A, B)
4222 -> C=B
4223 ; C=[A|B]
4224 ),
4225 add_var_ground_variables(D, C, E).
4226is_ground(B, A) :-
4227 ( ground(A)
4228 -> true
4229 ; compound(A)
4230 -> A=..[_|C],
4231 maplist(is_ground(B), C)
4232 ; memberchk_eq(A, B)
4233 ).
4234check_ground(C, A, D) :-
4235 term_variables(A, B),
4236 check_ground_variables(B, C, D).
4237check_ground_variables([], _, true).
4238check_ground_variables([A|C], B, D) :-
4239 ( memberchk_eq(A, B)
4240 -> check_ground_variables(C, B, D)
4241 ; D=(ground(A), E),
4242 check_ground_variables(C, B, E)
4243 ).
4244rest_heads_retrieval_and_matching(A, B, C, D, E, F, G, H, I, J) :-
4245 rest_heads_retrieval_and_matching(A,
4246 B,
4247 C,
4248 D,
4249 E,
4250 F,
4251 G,
4252 H,
4253 I,
4254 J,
4255 [],
4256 _).
4257rest_heads_retrieval_and_matching(A, B, E, F, G, H, I, C, D, J, K, L) :-
4258 ( A=[_|_]
4259 -> rest_heads_retrieval_and_matching_n(A,
4260 B,
4261 C,
4262 D,
4263 E,
4264 F,
4265 G,
4266 H,
4267 I,
4268 J,
4269 K,
4270 L)
4271 ; F=[],
4272 G=[],
4273 H=I,
4274 K=L
4275 ).
4276rest_heads_retrieval_and_matching_n([], _, _, _, _, [], [], A, A, _, B, B).
4277rest_heads_retrieval_and_matching_n([A|E1], [_|F1], F, B1, E, [C1|G1], [M|H1], G, I1, _, L, J1) :-
4278 functor(A, C, B),
4279 head_info(A, B, I, _, _, J),
4280 get_store_type(C/B, D),
4281 ( D==default
4282 -> passive_head_via(A,
4283 [E|F],
4284 G,
4285 O,
4286 N),
4287 delay_phase_end(validate_store_type_assumptions,
4288 (static_suspension_term(C/B, H), get_static_suspension_term_field(arguments, C/B, H, I), get_static_suspension_field(C/B, H, state, active, Q))),
4289 get_constraint_mode(C/B, K),
4290 head_arg_matches(J,
4291 K,
4292 G,
4293 R,
4294 V,
4295 L,
4296 W),
4297 T=J,
4298 sbag_member_call(M, N, P),
4299 S=(O, P, M=H, Q),
4300 inline_matching_goal(R, Y)
4301 ; delay_phase_end(validate_store_type_assumptions,
4302 (static_suspension_term(C/B, H), get_static_suspension_term_field(arguments, C/B, H, I))),
4303 existential_lookup(D,
4304 A,
4305 [E|F],
4306 G,
4307 L,
4308 H,
4309 S,
4310 M,
4311 J,
4312 T),
4313 get_constraint_mode(C/B, K),
4314 U=K,
4315 head_arg_matches(T,
4316 U,
4317 G,
4318 R,
4319 V,
4320 L,
4321 W),
4322 filter_append(T, V, X),
4323 translate(W, X, Z),
4324 translate(W, V, A1),
4325 inline_matching_goal(R, Y, Z, A1)
4326 ),
4327 different_from_other_susps(A, M, F, B1, D1),
4328 C1=(S, D1, Y),
4329 rest_heads_retrieval_and_matching_n(E1,
4330 F1,
4331 [A|F],
4332 [M|B1],
4333 E,
4334 G1,
4335 H1,
4336 V,
4337 I1,
4338 _,
4339 W,
4340 J1).
4341inline_matching_goal(A, B) :-
4342 inline_matching_goal(A, B, [], []).
4343inline_matching_goal(A==C, true, B, D) :-
4344 memberchk_eq(A, B),
4345 memberchk_eq(C, D),
4346 A=C, !.
4347inline_matching_goal((A, E), (B, F), C, D) :- !,
4348 inline_matching_goal(A, B, C, D),
4349 inline_matching_goal(E, F, C, D).
4350inline_matching_goal(A, A, _, _).
4351filter_mode([], _, _, []).
4352filter_mode([I-A|E], [_-B|F], [D|G], C) :-
4353 ( A==B
4354 -> C=[D|H],
4355 filter_mode(E, F, G, H)
4356 ; filter_mode([I-A|E], F, G, C)
4357 ).
4358filter_append([], A, A).
4359filter_append([A|B], C, D) :-
4360 ( A=silent(_)
4361 -> filter_append(B, C, D)
4362 ; D=[A|E],
4363 filter_append(B, C, E)
4364 ).
4365check_unique_keys([], _).
4366check_unique_keys([B|C], A) :-
4367 lookup_eq(A, B, _),
4368 check_unique_keys(C, A).
4369different_from_other_susps(C, D, A, B, F) :-
4370 different_from_other_susps_(A, B, C, D, E),
4371 list2conj(E, F).
4372different_from_other_susps_(_, [], _, _, []) :- !.
4373different_from_other_susps_([B|K], [I|L], A, H, G) :-
4374 ( functor(A, C, D),
4375 functor(B, C, D),
4376 copy_term_nat(B-A, E-F),
4377 \+ \+ E=F
4378 -> G=[H\==I|J]
4379 ; G=J
4380 ),
4381 different_from_other_susps_(K, L, A, H, J).
4382passive_head_via(A, D, P, I, H) :-
4383 functor(A, B, C),
4384 get_constraint_index(B/C, _),
4385 common_variables(A, D, E),
4386 ground_vars([A], F),
4387 list_difference_eq(E, F, K),
4388 global_list_store_name(B/C, G),
4389 J=nb_getval(G, H),
4390 get_constraint_mode(B/C, L),
4391 ( S==[]
4392 -> I=J
4393 ; member(O, K),
4394 nth1(M, L, -),
4395 arg(M, A, N),
4396 N==O
4397 -> translate([O], P, [Q]),
4398 gen_get_mod_constraints(B/C,
4399 Q,
4400 R,
4401 H),
4402 I=R
4403 ; translate(K, P, S),
4404 add_heads_types(D, [], T),
4405 my_term_copy(T, P, U),
4406 gen_get_mod_constraints(B/C,
4407 S,
4408 U,
4409 V,
4410 R,
4411 H),
4412 I=(V->R;J)
4413 ).
4414common_variables(A, B, E) :-
4415 term_variables(A, C),
4416 term_variables(B, D),
4417 intersect_eq(C, D, E).
4418gen_get_mod_constraints(K, A, B, C, D, I) :-
4419 via_goal(A, B, C, E),
4420 get_target_module(F),
4421 D=(get_attr(E, F, J), H),
4422 get_max_constraint_index(G),
4423 ( G==1
4424 -> H=true,
4425 I=J
4426 ; get_constraint_index(K, L),
4427 get_suspensions(G, L, J, H, I)
4428 ).
4429via_goal(A, C, B, F) :-
4430 ( A=[]
4431 -> B=fail
4432 ; A=[D]
4433 -> lookup_type(C, D, E),
4434 ( atomic_type(E)
4435 -> B=var(D),
4436 D=F
4437 ; B='chr newvia_1'(D, F)
4438 )
4439 ; A=[D, G]
4440 -> B='chr newvia_2'(D, G, F)
4441 ; B='chr newvia'(A, F)
4442 ).
4443lookup_type(A, B, C) :-
4444 ( lookup_eq(A, B, C)
4445 -> true
4446 ; C=any
4447 ).
4448gen_get_mod_constraints(H, B, A, F) :-
4449 get_target_module(C),
4450 A=(get_attr(B, C, G), E),
4451 get_max_constraint_index(D),
4452 ( D==1
4453 -> E=true,
4454 F=G
4455 ; get_constraint_index(H, I),
4456 get_suspensions(D, I, G, E, F)
4457 ).
4458guard_body_copies(A, B, E, C) :-
4459 guard_body_copies2(A, B, D, C),
4460 list2conj(D, E).
4461guard_body_copies2(A, D, H, B1) :-
4462 A=rule(_, J, B, Z),
4463 conj2list(B, C),
4464 split_off_simple_guard(C, D, E, F),
4465 my_term_copy(E-F, D, A1, G-I),
4466 append(G, [V], H),
4467 term_variables(F, K),
4468 term_variables(I, P),
4469 ground_vars(J, L),
4470 list_difference_eq(K, L, N),
4471 ( chr_pp_flag(guard_locks, off)
4472 -> S=[],
4473 T=[]
4474 ; bagof(Q-R,
4475 M^O^(lists:member(M, N), pairlist:lookup_eq(D, M, O), memberchk_eq(O, P), chr_lock(O, Q), chr_unlock(O, R)),
4476 U)
4477 -> once(pairup(S, T, U))
4478 ; S=[],
4479 T=[]
4480 ),
4481 list2conj(S, W),
4482 list2conj(T, Y),
4483 list2conj(I, X),
4484 V=(W, X, Y),
4485 my_term_copy(Z, A1, B1).
4486split_off_simple_guard([], _, [], []).
4487split_off_simple_guard([A|D], B, C, F) :-
4488 ( simple_guard(A, B)
4489 -> C=[A|E],
4490 split_off_simple_guard(D, B, E, F)
4491 ; C=[],
4492 F=[A|D]
4493 ).
4494simple_guard(A, C) :-
4495 binds_b(A, B),
4496 \+ ( member(D, B),
4497 lookup_eq(C, D, _)
4498 ).
4499active_constraint_detachment(E, I, A, J, H) :-
4500 functor(A, B, C),
4501 D=B/C,
4502 ( is_stored(D)
4503 -> ( ( E==[0],
4504 chr_pp_flag(store_in_guards, off)
4505 ; get_allocation_occurrence(D, G),
4506 get_max_occurrence(D, F),
4507 F<G
4508 ),
4509 only_ground_indexed_arguments(D),
4510 chr_pp_flag(late_allocation, on)
4511 -> H=true
4512 ; gen_uncond_susp_detachment(A,
4513 I,
4514 active,
4515 J,
4516 K),
4517 ( chr_pp_flag(late_allocation, on)
4518 -> H=(var(I)->true;K)
4519 ; H=K
4520 )
4521 )
4522 ; H=true
4523 ).
4524partner_constraint_detachments([], [], _, true).
4525partner_constraint_detachments([B|E], [A|F], C, (D, G)) :-
4526 gen_uncond_susp_detachment(A, B, partner, C, D),
4527 partner_constraint_detachments(E, F, C, G).
4528gen_uncond_susp_detachment(A, G, H, J, E) :-
4529 functor(A, B, C),
4530 D=B/C,
4531 ( is_stored(D)
4532 -> E=(F, I),
4533 ( chr_pp_flag(debugable, on)
4534 -> F='chr debug_event'(remove(G))
4535 ; F=true
4536 ),
4537 remove_constraint_goal(D,
4538 G,
4539 L,
4540 true,
4541 (K, M),
4542 H,
4543 I),
4544 delete_constraint_goal(A, G, J, K),
4545 ( \+ only_ground_indexed_arguments(D),
4546 \+ get_store_type(D, var_assoc_store(_, _))
4547 -> detach_constraint_atom(D, L, G, M)
4548 ; M=true
4549 )
4550 ; E=true
4551 ).
4552simpagation_head1_code(C, J1, J, L, A, E/D, _, H, A2, C2) :-
4553 A=pragma(B, ids(_, M), _, _, N),
4554 B=rule(_, K, H1, I1),
4555 head_info(C, D, B1, A1, I, F),
4556 get_constraint_mode(E/D, G),
4557 head_arg_matches(F, G, [], U1, V, [], W),
4558 build_head(E, D, H, I, T1),
4559 append(J, K, O),
4560 append(L, M, P),
4561 reorder_heads(N, C, O, P, S, T),
4562 guard_splitting(B, Q),
4563 ( is_stored_in_guard(E/D, N)
4564 -> R=[_|Q]
4565 ; R=Q
4566 ),
4567 guard_via_reschedule_new(S,
4568 R,
4569 C,
4570 Z,
4571 U,
4572 V1),
4573 rest_heads_retrieval_and_matching(S,
4574 T,
4575 C,
4576 U,
4577 X,
4578 V,
4579 Y,
4580 [],
4581 [],
4582 [],
4583 W,
4584 _),
4585 split_by_ids(T,
4586 X,
4587 L,
4588 E1,
4589 F1,
4590 K1,
4591 L1),
4592 guard_body_copies3(B, R, Y, Z, Y1),
4593 ( is_stored_in_guard(E/D, N)
4594 -> gen_uncond_attach_goal(E/D,
4595 A1,
4596 B1,
4597 D1,
4598 _),
4599 Z=[C1|_],
4600 C1=D1
4601 ; true
4602 ),
4603 sort_by_key(E1, F1, G1),
4604 partner_constraint_detachments(G1, J, Y, W1),
4605 active_constraint_detachment(H,
4606 A1,
4607 C,
4608 Y,
4609 X1),
4610 ( chr_pp_flag(debugable, on)
4611 -> my_term_copy(H1-I1, Y, O1-P1),
4612 sort_by_key([A1|E1], [J1|F1], M1),
4613 sort_by_key(K1, L1, N1),
4614 Q1='chr debug_event'(try(M1, N1, O1, P1)),
4615 R1='chr debug_event'(apply(M1, N1, O1, P1)),
4616 instrument_goal(!, Q1, R1, S1)
4617 ; S1=!
4618 ),
4619 Z1=(T1:-U1, V1, S1, W1, X1, Y1),
4620 add_location(Z1, N, B2),
4621 A2=[B2|C2].
4622split_by_ids([], [], _, [], []).
4623split_by_ids([A|H], [D|I], B, C, E) :-
4624 ( memberchk_eq(A, B)
4625 -> C=[D|F],
4626 E=G
4627 ; C=F,
4628 E=[D|G]
4629 ),
4630 split_by_ids(H, I, B, F, G).
4631split_by_ids([], [], _, [], [], [], []).
4632split_by_ids([A|L], [D|M], B, C, E, F, G) :-
4633 ( memberchk_eq(A, B)
4634 -> C=[D|H],
4635 E=[A|I],
4636 F=J,
4637 G=K
4638 ; C=H,
4639 E=I,
4640 F=[D|J],
4641 G=[A|K]
4642 ),
4643 split_by_ids(L,
4644 M,
4645 B,
4646 H,
4647 I,
4648 J,
4649 K).
4650simpagation_head2_code(H, C1, D, F, A, O, P, Q, R, E1) :-
4651 A=pragma(B, ids(E, T), _, _, G),
4652 B=rule(C, _, M, N),
4653 append(C, D, I),
4654 append(E, F, J),
4655 reorder_heads(G,
4656 H,
4657 I,
4658 J,
4659 [K|L],
4660 [S|U]),
4661 simpagation_head2_prelude(H,
4662 K,
4663 [L, M, N],
4664 O,
4665 P,
4666 Q,
4667 R,
4668 W),
4669 extend_id(Q, V),
4670 ( memberchk_eq(S, T)
4671 -> simpagation_universal_searches(L,
4672 U,
4673 T,
4674 [K, H],
4675 B,
4676 O,
4677 P,
4678 Z,
4679 A1,
4680 B1,
4681 V,
4682 Y,
4683 W,
4684 X)
4685 ; W=X,
4686 V=Y,
4687 Z=L,
4688 A1=[K, H],
4689 B1=U
4690 ),
4691 universal_search_iterator_end(A1,
4692 Z,
4693 B,
4694 O,
4695 P,
4696 Y,
4697 X,
4698 D1),
4699 simpagation_head2_worker(A1,
4700 Z,
4701 B1,
4702 C1,
4703 A,
4704 O,
4705 P,
4706 Y,
4707 D1,
4708 E1).
4709simpagation_universal_searches([], [], _, A, _, _, _, [], A, [], B, B, C, C).
4710simpagation_universal_searches(A, [I|L], J, C, D, E, F, N, O, P, B, R, G, T) :-
4711 A=[M|K],
4712 inc_id(B, Q),
4713 universal_search_iterator_end(C,
4714 A,
4715 D,
4716 E,
4717 F,
4718 B,
4719 G,
4720 H),
4721 universal_search_iterator(A,
4722 C,
4723 D,
4724 E,
4725 F,
4726 B,
4727 H,
4728 S),
4729 ( memberchk_eq(I, J)
4730 -> simpagation_universal_searches(K,
4731 L,
4732 J,
4733 [M|C],
4734 D,
4735 E,
4736 F,
4737 N,
4738 O,
4739 P,
4740 Q,
4741 R,
4742 S,
4743 T)
4744 ; R=Q,
4745 S=T,
4746 N=K,
4747 O=[M|C],
4748 L=P
4749 ).
4750simpagation_head2_prelude(A, H, N, C/B, K, D, Y, A1) :-
4751 head_info(A, B, L, M, E, F),
4752 build_head(C, B, D, E, S),
4753 get_constraint_mode(C/B, G),
4754 head_arg_matches(F, G, [], T, I, [], J),
4755 lookup_passive_head(H,
4756 [A],
4757 I,
4758 J,
4759 U,
4760 O),
4761 gen_occ_allocation(C/B,
4762 K,
4763 L,
4764 M,
4765 V),
4766 extend_id(D, Q),
4767 extra_active_delegate_variables(A,
4768 [H|N],
4769 I,
4770 P),
4771 append([O|E], P, R),
4772 build_head(C, B, [K|Q], R, W),
4773 X=(S:-T, U, !, V, W),
4774 add_dummy_location(X, Z),
4775 Y=[Z|A1].
(A, B, C, E) :-
4777 A=..[_|D],
4778 delegate_variables(A, B, C, D, E).
4779passive_delegate_variables(B, A, C, D, F) :-
4780 term_variables(A, E),
4781 delegate_variables(B, C, D, E, F).
4782delegate_variables(A, B, H, F, I) :-
4783 term_variables(A, C),
4784 term_variables(B, D),
4785 intersect_eq(C, D, E),
4786 list_difference_eq(E, F, G),
4787 translate(G, H, I).
4788simpagation_head2_worker([D|C], E, D1, _, A, V/W, X, Y, L2, N2) :-
4789 A=pragma(B, ids(H1, _), D2, _, A1),
4790 B=rule(_, _, F, G),
4791 get_prop_inner_loop_vars(C,
4792 [D, E, F, G],
4793 U,
4794 N,
4795 O1,
4796 P1,
4797 P),
4798 gen_var(J),
4799 gen_var(T),
4800 functor(D, K, H),
4801 gen_vars(H, I),
4802 head_info(D, H, I, J, _, L),
4803 get_constraint_mode(K/H, M),
4804 head_arg_matches(L,
4805 M,
4806 N,
4807 S,
4808 F1,
4809 [],
4810 _),
4811 delay_phase_end(validate_store_type_assumptions,
4812 (static_suspension_term(K/H, O), get_static_suspension_field(K/H, O, state, active, Q), get_static_suspension_term_field(arguments, K/H, O, I))),
4813 different_from_other_susps(D, J, C, P, R),
4814 G2=(J=O, Q, R, S),
4815 Z=[[J|T]|U],
4816 build_head(V, W, [X|Y], Z, F2),
4817 guard_splitting(B, B1),
4818 ( is_stored_in_guard(V/W, A1)
4819 -> C1=[_|B1]
4820 ; C1=B1
4821 ),
4822 guard_via_reschedule_new(E,
4823 C1,
4824 [D|C],
4825 N1,
4826 E1,
4827 H2),
4828 rest_heads_retrieval_and_matching(E,
4829 D1,
4830 [D|C],
4831 E1,
4832 G1,
4833 F1,
4834 K1,
4835 [D|C],
4836 [J|P],
4837 []),
4838 split_by_ids(D1, G1, H1, I1, W1),
4839 split_by_ids(D1, E, H1, J1, _),
4840 partner_constraint_detachments([J|I1],
4841 [D|J1],
4842 K1,
4843 I2),
4844 L1=[T|U],
4845 build_head(V, W, [X|Y], L1, Q1),
4846 M1=[[]|U],
4847 build_head(V, W, [X|Y], M1, S1),
4848 guard_body_copies3(B, C1, K1, N1, J2),
4849 ( is_stored_in_guard(V/W, A1)
4850 -> N1=[B2|_]
4851 ; true
4852 ),
4853 ( is_observed(V/W, X)
4854 -> gen_uncond_attach_goal(V/W,
4855 O1,
4856 P1,
4857 T1,
4858 R1),
4859 gen_state_cond_call(O1,
4860 V/W,
4861 Q1,
4862 R1,
4863 U1),
4864 gen_state_cond_call(O1,
4865 V/W,
4866 S1,
4867 R1,
4868 V1)
4869 ; T1=true,
4870 U1=Q1,
4871 V1=S1
4872 ),
4873 ( chr_pp_flag(debugable, on)
4874 -> my_term_copy(F-G, N, X1-Y1),
4875 Z1='chr debug_event'(try([J|I1], [O1|W1], X1, Y1)),
4876 A2='chr debug_event'(apply([J|I1], [O1|W1], X1, Y1))
4877 ; Z1=true,
4878 A2=true
4879 ),
4880 ( is_stored_in_guard(V/W, A1)
4881 -> B2=T1,
4882 C2=true
4883 ; B2=true,
4884 C2=T1
4885 ),
4886 ( member(unique(_, E2), D2),
4887 check_unique_keys(E2, N)
4888 -> K2=(F2:-G2->(H2, Z1->A2, I2, C2, J2, V1;S1);Q1)
4889 ; K2=(F2:-G2, H2, Z1->A2, I2, C2, J2, U1;Q1)
4890 ),
4891 add_location(K2, A1, M2),
4892 L2=[M2|N2].
4893gen_state_cond_call(B, A, J, D, I) :-
4894 ( may_trigger(A)
4895 -> does_use_field(A, generation),
4896 delay_phase_end(validate_store_type_assumptions,
4897 (static_suspension_term(A, C), get_update_static_suspension_field(A, B, C, state, active, inactive, E, F), get_static_suspension_field(A, C, generation, D, H), get_static_suspension_term_field(arguments, A, C, G)))
4898 ; delay_phase_end(validate_store_type_assumptions,
4899 (static_suspension_term(A, C), get_update_static_suspension_field(A, B, C, state, active, inactive, E, F), get_static_suspension_term_field(arguments, A, C, G))),
4900 H=true
4901 ),
4902 I=(B=C, E, H->F, J;true).
4903propagation_code(B, C, A, K, D, E, F, G, H, I, J) :-
4904 ( A==[]
4905 -> propagation_single_headed(B,
4906 C,
4907 D,
4908 E,
4909 F,
4910 G,
4911 H,
4912 I,
4913 J)
4914 ; propagation_multi_headed(B,
4915 A,
4916 K,
4917 D,
4918 E,
4919 F,
4920 G,
4921 H,
4922 I,
4923 J)
4924 ).
4925propagation_single_headed(A, _, I, V, C/B, L, D, R1, T1) :-
4926 head_info(A, B, W, O, E, G),
4927 build_head(C, B, D, E, M1),
4928 inc_id(D, F),
4929 build_head(C, B, F, E, K),
4930 get_constraint_mode(C/B, H),
4931 head_arg_matches(G, H, [], N1, J, [], _),
4932 guard_body_copies(I, J, O1, P1),
4933 C1=K,
4934 actual_cut(C/B, L, R),
4935 I=rule(_, _, M, N),
4936 ( chr_pp_flag(debugable, on)
4937 -> my_term_copy(M-N, J, P-Q),
4938 S='chr debug_event'(try([], [O], P, Q)),
4939 T='chr debug_event'(apply([], [O], P, Q)),
4940 instrument_goal(R, S, T, U)
4941 ; U=R
4942 ),
4943 ( may_trigger(C/B),
4944 \+ has_no_history(V)
4945 -> use_auxiliary_predicate(novel_production),
4946 use_auxiliary_predicate(extend_history),
4947 does_use_history(C/B, L),
4948 gen_occ_allocation(C/B,
4949 L,
4950 W,
4951 O,
4952 G1),
4953 ( named_history(V, Y, X)
4954 -> ( X==[]
4955 -> empty_named_history_novel_production(Y, A1),
4956 empty_named_history_extend_history(Y, B1)
4957 ; Z=Y
4958 )
4959 ; Z=V
4960 ),
4961 ( var(A1)
4962 -> A1='$novel_production'(O, Z),
4963 B1='$extend_history'(O, Z)
4964 ; true
4965 ),
4966 ( is_observed(C/B, L)
4967 -> gen_uncond_attach_goal(C/B,
4968 O,
4969 W,
4970 E1,
4971 D1),
4972 gen_state_cond_call(O,
4973 C/B,
4974 C1,
4975 D1,
4976 F1)
4977 ; E1=true,
4978 F1=C1
4979 )
4980 ; G1=true,
4981 A1=true,
4982 B1=true,
4983 ( is_observed(C/B, L)
4984 -> get_allocation_occurrence(C/B, H1),
4985 ( L==H1
4986 -> gen_insert_constraint_internal_goal(C/B,
4987 E1,
4988 E,
4989 W,
4990 O),
4991 D1=0
4992 ; E1=(I1, J1),
4993 gen_occ_allocation(C/B,
4994 L,
4995 W,
4996 O,
4997 I1),
4998 gen_uncond_attach_goal(C/B,
4999 O,
5000 W,
5001 J1,
5002 D1)
5003 ),
5004 gen_state_cond_call(O,
5005 C/B,
5006 C1,
5007 D1,
5008 F1)
5009 ; gen_occ_allocation(C/B,
5010 L,
5011 W,
5012 O,
5013 E1),
5014 F1=C1
5015 )
5016 ),
5017 ( is_stored_in_guard(C/B, V)
5018 -> K1=E1,
5019 L1=true
5020 ; K1=true,
5021 L1=E1
5022 ),
5023 Q1=(M1:-N1, G1, A1, K1, O1, U, B1, L1, P1, F1),
5024 add_location(Q1, V, S1),
5025 R1=[S1|T1].
5026propagation_multi_headed(B, A, J, C, K, D, E, F, G, N) :-
5027 A=[I|H],
5028 propagation_prelude(B,
5029 A,
5030 C,
5031 D,
5032 E,
5033 F,
5034 G,
5035 M),
5036 extend_id(F, L),
5037 propagation_nested_code(H,
5038 [I, B],
5039 J,
5040 C,
5041 K,
5042 D,
5043 E,
5044 L,
5045 M,
5046 N).
5047propagation_prelude(A, [I|J], H, C/B, O, D, C1, E1) :-
5048 head_info(A, B, P, Q, E, F),
5049 build_head(C, B, D, E, W),
5050 get_constraint_mode(C/B, G),
5051 head_arg_matches(F, G, [], X, M, [], N),
5052 H=rule(_, _, K, L),
5053 extra_active_delegate_variables(A,
5054 [I, J, K, L],
5055 M,
5056 S),
5057 lookup_passive_head(I,
5058 [A],
5059 M,
5060 N,
5061 Y,
5062 R),
5063 gen_occ_allocation(C/B,
5064 O,
5065 P,
5066 Q,
5067 Z),
5068 extend_id(D, T),
5069 append([R|E], S, U),
5070 build_head(C, B, [O|T], U, V),
5071 A1=V,
5072 B1=(W:-X, Y, !, Z, A1),
5073 add_dummy_location(B1, D1),
5074 C1=[D1|E1].
5075propagation_nested_code([], [A|B], H, C, I, D, E, F, G, K) :-
5076 universal_search_iterator_end([A|B],
5077 [],
5078 C,
5079 D,
5080 E,
5081 F,
5082 G,
5083 J),
5084 propagation_body(A,
5085 B,
5086 H,
5087 C,
5088 I,
5089 D,
5090 E,
5091 F,
5092 J,
5093 K).
5094propagation_nested_code([B|C], A, J, D, K, E, F, G, H, N) :-
5095 universal_search_iterator_end(A,
5096 [B|C],
5097 D,
5098 E,
5099 F,
5100 G,
5101 H,
5102 I),
5103 universal_search_iterator([B|C],
5104 A,
5105 D,
5106 E,
5107 F,
5108 G,
5109 I,
5110 M),
5111 inc_id(G, L),
5112 propagation_nested_code(C,
5113 [B|A],
5114 J,
5115 D,
5116 K,
5117 E,
5118 F,
5119 L,
5120 M,
5121 N).
5122check_fd_lookup_condition(A, B, _, _) :-
5123 get_store_type(A/B, global_singleton), !.
5124check_fd_lookup_condition(A, B, E, F) :-
5125 \+ may_trigger(A/B),
5126 get_functional_dependency(A/B, 1, C, D),
5127 copy_term(C-D, E-G),
5128 term_variables(F, H),
5129 intersect_eq(G, H, G), !.
5130propagation_body(C, B, O1, A, N1, P/Q, R, S, S2, U2) :-
5131 A=rule(_, Z1, D, E),
5132 gen_var_susp_list_for_b(B,
5133 [C, D, E],
5134 E1,
5135 F,
5136 U,
5137 G,
5138 V),
5139 flatten(F, O),
5140 init(G, F1),
5141 last(G, H1),
5142 gen_var(L),
5143 gen_var(N),
5144 functor(C, I, H),
5145 gen_vars(H, K),
5146 delay_phase_end(validate_store_type_assumptions,
5147 (static_suspension_term(I/H, J), get_static_suspension_field(I/H, J, state, active, M), get_static_suspension_term_field(arguments, I/H, J, K))),
5148 M2=(L=J, M),
5149 T=[[L|N]|O],
5150 build_head(P, Q, [R|S], T, L2),
5151 ( check_fd_lookup_condition(I, H, C, B)
5152 -> universal_search_iterator_failure_vars(B,
5153 S,
5154 F,
5155 U,
5156 V,
5157 W,
5158 Y),
5159 X=W
5160 ; X=[N|O],
5161 Y=S
5162 ),
5163 ( Y=[_]
5164 -> Z=Y
5165 ; Z=[R|Y]
5166 ),
5167 build_head(P, Q, Z, X, A1),
5168 J1=A1,
5169 C=..[_|B1],
5170 pairup(B1, K, C1),
5171 get_constraint_mode(I/H, D1),
5172 head_arg_matches(C1, D1, E1, O2, G1),
5173 different_from_other_susps(C, L, B, F1, N2),
5174 guard_body_copies(A, G1, P2, Q2),
5175 get_occurrence(P/Q, R, _, R1),
5176 ( is_observed(P/Q, R)
5177 -> init(U, I1),
5178 gen_uncond_attach_goal(P/Q,
5179 H1,
5180 I1,
5181 L1,
5182 K1),
5183 gen_state_cond_call(H1,
5184 P/Q,
5185 J1,
5186 K1,
5187 M1)
5188 ; L1=true,
5189 M1=J1
5190 ),
5191 ( ( is_least_occurrence(N1)
5192 ; has_no_history(N1)
5193 )
5194 -> P1=true,
5195 Q1=true
5196 ; \+ may_trigger(P/Q),
5197 maplist(is_passive(N1), O1)
5198 -> P1=true,
5199 Q1=true
5200 ; get_occurrence(P/Q, R, _, R1),
5201 use_auxiliary_predicate(novel_production),
5202 use_auxiliary_predicate(extend_history),
5203 does_use_history(P/Q, R),
5204 ( named_history(N1, T1, S1)
5205 -> ( S1==[]
5206 -> empty_named_history_novel_production(T1, P1),
5207 empty_named_history_extend_history(T1, Q1)
5208 ; reverse([L|F1], U1),
5209 named_history_susps(S1,
5210 [R1|O1],
5211 [H1|U1],
5212 V1),
5213 V1=[W1|_],
5214 ( length(S1, 1)
5215 -> Q1='$extend_history'(W1, T1),
5216 P1='$novel_production'(W1, T1)
5217 ; findall(X1,
5218 ( member(Y1, S1),
5219 get_occurrence_from_id(X1,
5220 _,
5221 N1,
5222 Y1)
5223 ),
5224 A2),
5225 B2=..[t, T1|V1]
5226 )
5227 )
5228 ; W1=H1,
5229 maplist(extract_symbol, Z1, A2),
5230 sort([R1|O1], S1),
5231 history_susps(O1,
5232 [L|F1],
5233 H1,
5234 R1,
5235 V1),
5236 B2=..[t, N1|V1]
5237 ),
5238 ( var(P1)
5239 -> novel_production_calls(A2,
5240 S1,
5241 V1,
5242 N1,
5243 C2,
5244 D2),
5245 Q1='$extend_history'(W1, C2),
5246 P1=(C2=B2, D2)
5247 ; true
5248 )
5249 ),
5250 ( chr_pp_flag(debugable, on)
5251 -> A=rule(_, _, D, E),
5252 my_term_copy(D-E, G1, F2-G2),
5253 get_occurrence(P/Q, R, _, R1),
5254 sort_by_key([H1, L|F1],
5255 [R1|O1],
5256 E2),
5257 H2='chr debug_event'(try([], E2, F2, G2)),
5258 I2='chr debug_event'(apply([], E2, F2, G2))
5259 ; H2=true,
5260 I2=true
5261 ),
5262 ( is_stored_in_guard(P/Q, N1)
5263 -> J2=L1,
5264 K2=true
5265 ; J2=true,
5266 K2=L1
5267 ),
5268 R2=(L2:-M2, N2, O2, P1, J2, P2, H2->I2, Q1, K2, Q2, M1;J1),
5269 add_location(R2, N1, T2),
5270 S2=[T2|U2].
(A, B/C) :-
5272 functor(A, B, C).
5273novel_production_calls([], [], [], _, _, true).
5274novel_production_calls([A|H], [C|I], [E|J], B, F, (G, K)) :-
5275 get_occurrence_from_id(A, D, B, C),
5276 delay_phase_end(validate_store_type_assumptions,
5277 novel_production_call(A,
5278 D,
5279 '$novel_production'(E,
5280 F),
5281 G)),
5282 novel_production_calls(H,
5283 I,
5284 J,
5285 B,
5286 F,
5287 K).
5288history_susps(E, A, B, D, F) :-
5289 reverse(A, C),
5290 sort_by_key([B|C], [D|E], F).
5291named_history_susps([], _, _, []).
5292named_history_susps([A|E], C, D, [B|H]) :-
5293 select2(A, B, C, D, F, G), !,
5294 named_history_susps(E, F, G, H).
5295gen_var_susp_list_for([A], I, H, K, D, C) :- !,
5296 functor(A, E, B),
5297 head_info(A, B, _, C, D, F),
5298 get_constraint_mode(E/B, G),
5299 head_arg_matches(F, G, [], _, H),
5300 extra_active_delegate_variables(A, I, H, J),
5301 append(D, J, K).
5302gen_var_susp_list_for([B|A], C, K, N, D, E) :-
5303 gen_var_susp_list_for(A,
5304 [B|C],
5305 J,
5306 D,
5307 _,
5308 _),
5309 functor(B, G, F),
5310 gen_var(E),
5311 head_info(B, F, _, M, _, H),
5312 get_constraint_mode(G/F, I),
5313 head_arg_matches(H, I, J, _, K),
5314 passive_delegate_variables(B, A, C, K, L),
5315 append(L, [M, E|D], N).
5316gen_var_susp_list_for_b([A], I, H, [K], D, [C], []) :- !,
5317 functor(A, E, B),
5318 head_info(A, B, _, C, D, F),
5319 get_constraint_mode(E/B, G),
5320 head_arg_matches(F, G, [], _, H),
5321 extra_active_delegate_variables(A, I, H, J),
5322 append(D, J, K).
5323gen_var_susp_list_for_b([B|A], C, O, [Q|D], E, [J|F], [H|G]) :-
5324 gen_var_susp_list_for_b(A,
5325 [B|C],
5326 N,
5327 D,
5328 E,
5329 F,
5330 G),
5331 functor(B, K, I),
5332 gen_var(H),
5333 head_info(B, I, _, J, _, L),
5334 get_constraint_mode(K/I, M),
5335 head_arg_matches(L, M, N, _, O),
5336 passive_delegate_variables(B, A, C, O, P),
5337 append(P, [J, H], Q).
5338get_prop_inner_loop_vars([A], I, L, H, D, C, []) :- !,
5339 functor(A, E, B),
5340 head_info(A, B, C, D, J, F),
5341 get_constraint_mode(E/B, G),
5342 head_arg_matches(F, G, [], _, H),
5343 extra_active_delegate_variables(A, I, H, K),
5344 append(J, K, L).
5345get_prop_inner_loop_vars([B|A], C, Q, M, D, E, [H|F]) :-
5346 get_prop_inner_loop_vars(A,
5347 [B|C],
5348 P,
5349 L,
5350 D,
5351 E,
5352 F),
5353 functor(B, I, G),
5354 gen_var(O),
5355 head_info(B, G, _, H, _, J),
5356 get_constraint_mode(I/G, K),
5357 head_arg_matches(J, K, L, _, M),
5358 passive_delegate_variables(B, A, C, M, N),
5359 append(N, [H, O|P], Q).
5360reorder_heads(C, D, A, E, F, G) :-
5361 ( chr_pp_flag(reorder_heads, on),
5362 length(A, B),
5363 B=<6
5364 -> reorder_heads_main(C,
5365 D,
5366 A,
5367 E,
5368 F,
5369 G)
5370 ; F=A,
5371 G=E
5372 ).
5373reorder_heads_main(E, A, C, D, N, P) :-
5374 term_variables(A, B),
5375 F=entry([], [], B, C, D, E),
5376 copy_term_nat(F, G),
5377 a_star(G,
5378 H^(chr_translate:final_data(H)),
5379 I^J^K^(chr_translate:expand_data(I, J, K)),
5380 L),
5381 G=F,
5382 L=entry(M, O, _, _, _, _),
5383 reverse(M, N),
5384 reverse(O, P).
5385final_data(A) :-
5386 A=entry(_, _, _, _, [], _).
5387expand_data(A, F, N) :-
5388 A=entry(G, I, E, B, C, M),
5389 select2(D, H, B, C, K, L),
5390 term_variables([D|E], J),
5391 F=entry([D|G], [H|I], J, K, L, M),
5392 order_score(D, H, E, K, M, N).
5393order_score(A, E, F, G, H, I) :-
5394 functor(A, B, C),
5395 get_store_type(B/C, D),
5396 order_score(D,
5397 A,
5398 E,
5399 F,
5400 G,
5401 H,
5402 99999,
5403 I).
5404order_score(default, A, _, F, B, _, I, H) :-
5405 term_variables(A, C),
5406 term_variables(B, G),
5407 ground_vars([A], D),
5408 list_difference_eq(C, D, E),
5409 order_score_vars(E, F, G, J),
5410 H is min(I, J).
5411order_score(multi_inthash(C), D, _, E, _, _, A, B) :-
5412 ( A=<100
5413 -> B=A
5414 ; order_score_indexes(C, D, E, B)
5415 ).
5416order_score(multi_hash(C), D, _, E, _, _, A, B) :-
5417 ( A=<100
5418 -> B=A
5419 ; order_score_indexes(C, D, E, B)
5420 ).
5421order_score(global_ground, A, _, D, B, _, H, G) :-
5422 term_variables(A, C),
5423 term_variables(B, E),
5424 order_score_vars(C, D, E, F),
5425 I is F*200,
5426 G is min(H, I).
5427order_score(var_assoc_store(_, _), _, _, _, _, _, _, 1).
5428order_score(global_singleton, _, _, _, _, _, _, A) :-
5429 A=1.
5430order_score(multi_store(A), B, C, D, E, F, G, H) :-
5431 multi_order_score(A,
5432 B,
5433 C,
5434 D,
5435 E,
5436 F,
5437 G,
5438 H).
5439multi_order_score([], _, _, _, _, _, A, A).
5440multi_order_score([A|I], B, C, D, E, F, G, J) :-
5441 ( order_score(A,
5442 B,
5443 C,
5444 D,
5445 E,
5446 F,
5447 G,
5448 H)
5449 -> true
5450 ; H=G
5451 ),
5452 multi_order_score(I,
5453 B,
5454 C,
5455 D,
5456 E,
5457 F,
5458 H,
5459 J).
5460order_score(identifier_store(A), B, _, D, _, _, F, E) :-
5461 arg(A, B, C),
5462 memberchk_eq(C, D),
5463 E is min(F, 10).
5464order_score(type_indexed_identifier_store(A, _), B, _, D, _, _, F, E) :-
5465 arg(A, B, C),
5466 memberchk_eq(C, D),
5467 E is min(F, 10).
5468order_score_indexes(D, A, B, F) :-
5469 copy_term_nat(A+B, E+C),
5470 numbervars(C, 0, _),
5471 order_score_indexes(D, E, F).
5472order_score_indexes([A|E], B, D) :-
5473 args(A, B, C),
5474 ( maplist(ground, C)
5475 -> D=100
5476 ; order_score_indexes(E, B, D)
5477 ).
5478memberchk_eq_flip(B, A) :-
5479 memberchk_eq(A, B).
5480order_score_vars(A, B, C, G) :-
5481 order_score_count_vars(A,
5482 B,
5483 C,
5484 D-E-F),
5485 ( D-E-F==0-0-0
5486 -> G=0
5487 ; D>0
5488 -> G is max(10-D, 0)
5489 ; E>0
5490 -> G is max(10-E, 1)*100
5491 ; G is max(10-F, 1)*1000
5492 ).
5493order_score_count_vars([], _, _, 0-0-0).
5494order_score_count_vars([D|A], B, C, E-G-I) :-
5495 order_score_count_vars(A,
5496 B,
5497 C,
5498 F-H-J),
5499 ( memberchk_eq(D, B)
5500 -> E is F+1,
5501 G=H,
5502 I=J
5503 ; memberchk_eq(D, C)
5504 -> G is H+1,
5505 E=F,
5506 I=J
5507 ; I is J+1,
5508 E=F,
5509 G=H
5510 ).
5511create_get_mutable_ref(C, B, A) :-
5512 A=(B=mutable(C)).
5513create_get_mutable(B, A, C) :-
5514 A=mutable(B),
5515 C=true.
5516gen_var(_).
5517gen_vars(B, A) :-
5518 length(A, B).
5519ast_head_info1(A, C, D, E, G) :-
5520 A=chr_constraint(_/B, F, _),
5521 vars_susp(B, C, D, E),
5522 pairup(F, C, G).
5523head_info1(E, _/A, B, C, D, G) :-
5524 vars_susp(A, B, C, D),
5525 E=..[_|F],
5526 pairup(F, B, G).
5527head_info(E, A, B, C, D, G) :-
5528 vars_susp(A, B, C, D),
5529 E=..[_|F],
5530 pairup(F, B, G).
5531inc_id([C|A], [B|A]) :-
5532 B is C+1.
5533dec_id([C|A], [B|A]) :-
5534 B is C-1.
5535extend_id(A, [0|A]).
5536next_id([_, C|A], [B|A]) :-
5537 B is C+1.
5538build_head(A/B, C, D, E) :-
5539 build_head(A, B, C, D, E).
5540build_head(A, B, C, H, F) :-
5541 buildName(A, B, C, G),
5542 ( ( chr_pp_flag(debugable, on)
5543 ; is_stored(A/B),
5544 ( has_active_occurrence(A/B)
5545 ; chr_pp_flag(late_allocation, off)
5546 ),
5547 ( may_trigger(A/B)
5548 ; get_allocation_occurrence(A/B, E),
5549 get_max_occurrence(A/B, D),
5550 D>=E
5551 )
5552 )
5553 -> F=..[G|H]
5554 ; init(H, I),
5555 F=..[G|I]
5556 ).
5557buildName(A, B, E, H) :-
5558 ( ( chr_pp_flag(debugable, on)
5559 ; once(( is_stored(A/B),
5560 ( has_active_occurrence(A/B)
5561 ; chr_pp_flag(late_allocation, off)
5562 ),
5563 ( may_trigger(A/B)
5564 ; get_allocation_occurrence(A/B,
5565 D),
5566 get_max_occurrence(A/B, C),
5567 C>=D
5568 )
5569 ; E\=[0]
5570 ))
5571 )
5572 -> atom_concat(A, '___', F),
5573 atomic_concat(F, B, G),
5574 buildName_(E, G, H)
5575 ; H=A
5576 ).
5577buildName_([], A, A).
5578buildName_([E|A], B, F) :-
5579 buildName_(A, B, C),
5580 atom_concat(C, '__', D),
5581 atomic_concat(D, E, F).
5582vars_susp(B, A, C, D) :-
5583 length(A, B),
5584 append(A, [C], D).
5585or_pattern(A, B) :-
5586 C is A-1,
5587 B is 1<<C.
5588and_pattern(A, C) :-
5589 B is A-1,
5590 D is 1<<B,
5591 C is -1*(D+1).
5592make_name(A, B/C, D) :-
5593 atom_concat_list([A, B, '___', C], D).
5594make_attr(B, D, A, C) :-
5595 length(A, B),
5596 C=..[v, D|A].
5597get_all_suspensions2(A, C, B) :-
5598 chr_pp_flag(dynattr, off), !,
5599 make_attr(A, _, B, C).
5600get_all_suspensions2(B, D, C, A) :-
5601 length(A, B),
5602 C='chr all_suspensions'(A, 1, D).
5603normalize_attr(B, A, C) :-
5604 A='chr normalize_attr'(B, C).
5605get_suspensions(B, D, A, A=C, F) :-
5606 chr_pp_flag(dynattr, off), !,
5607 make_attr(B, _, E, C),
5608 nth1(D, E, F).
5609get_suspensions(_, B, D, A, C) :-
5610 A=(memberchk(B-C, D)->true;C=[]).
5611singleton_attr(B, F, A, D) :-
5612 chr_pp_flag(dynattr, off), !,
5613 or_pattern(A, C),
5614 make_attr(B, C, E, D),
5615 nth1(A, E, [F], G),
5616 set_elems(G, []).
5617singleton_attr(_, C, B, A) :-
5618 A=[B-[C]].
5619add_attr(A, E, B, J, I, M) :-
5620 chr_pp_flag(dynattr, off), !,
5621 make_attr(A, F, C, K),
5622 or_pattern(B, L),
5623 nth1(B, C, D),
5624 substitute_eq(D, C, [E|D], G),
5625 make_attr(A, F, G, N),
5626 substitute_eq(D, C, [E], H),
5627 make_attr(A, O, H, P),
5628 I=(J=K, (F/\L=:=L->M=N;O is F\/L, M=P)), !.
5629add_attr(_, E, C, B, A, D) :-
5630 A=('chr select'(B, C-F, G)->D=[C-[E|F]|G];D=[C-[E]|B]).
5631rem_attr(B, P, L, A, I, H) :-
5632 chr_pp_flag(dynattr, off),
5633 chr_pp_flag(experiment, off), !,
5634 or_pattern(A, K),
5635 and_pattern(A, O),
5636 make_attr(B, F, C, J),
5637 nth1(A, C, D),
5638 substitute_eq(D, C, [], E),
5639 make_attr(B, N, E, R),
5640 substitute_eq(D, C, M, G),
5641 make_attr(B, F, G, S),
5642 get_target_module(Q),
5643 H=(I=J, (F/\K=:=K->'chr sbag_del_element'(D, L, M), (M==[]->N is F/\O, (N==0->del_attr(P, Q);put_attr(P, Q, R));put_attr(P, Q, S));true)), !.
5644rem_attr(_, L, H, A, C, B) :-
5645 chr_pp_flag(dynattr, off),
5646 chr_pp_flag(experiment, on), !,
5647 or_pattern(A, E),
5648 and_pattern(A, J),
5649 F is A+1,
5650 get_target_module(M),
5651 B=(arg(1, C, D), (D/\E=:=E->arg(F, C, G), 'chr sbag_del_element'(G, H, I), (I==[]->K is D/\J, (K==0->del_attr(L, M);setarg(1, C, K), setarg(F, C, I));setarg(F, C, I));true)), !.
5652rem_attr(_, H, E, C, B, A) :-
5653 get_target_module(I),
5654 A=('chr select'(B, C-D, G)->'chr sbag_del_element'(D, E, F), (F==[]->(G==[]->del_attr(H, I);put_attr(H, I, G));put_attr(H, I, [C-F|G]));true).
5655merge_attributes(A, G, D, F, E) :-
5656 chr_pp_flag(dynattr, off), !,
5657 make_attr(A, B, C, H),
5658 merge_attributes2(A, B, C, D, I, E),
5659 F=(G=H, I).
5660merge_attributes(_, B, C, A, F) :-
5661 A=(sort(B, D), sort(C, E), 'chr new_merge_attributes'(D, E, F)).
5662merge_attributes2(A, U, B, Q, P, O) :-
5663 make_attr(A, V, C, R),
5664 bagof(F,
5665 D^E^G^H^(member2(B, C, D-E), F=(sort(E, G), 'chr merge_attributes'(D, G, H))),
5666 I),
5667 list2conj(I, S),
5668 bagof(M,
5669 J^K^L^member((J, 'chr merge_attributes'(K, L, M)), I),
5670 N),
5671 make_attr(A, T, N, O),
5672 P=(Q=R, S, T is U\/V).
5673lookup_passive_head(A, E, F, G, H) :-
5674 functor(A, B, C),
5675 get_store_type(B/C, D),
5676 lookup_passive_head(D,
5677 A,
5678 E,
5679 F,
5680 [],
5681 G,
5682 H).
5683lookup_passive_head(A, E, F, G, H, I) :-
5684 functor(A, B, C),
5685 get_store_type(B/C, D),
5686 lookup_passive_head(D,
5687 A,
5688 E,
5689 F,
5690 G,
5691 H,
5692 I).
5693lookup_passive_head(default, A, B, C, _, D, E) :-
5694 functor(A, F, G),
5695 passive_head_via(A, B, C, D, E),
5696 update_store_type(F/G, default).
5697lookup_passive_head(multi_inthash(A), B, _, C, D, E, F) :-
5698 hash_lookup_passive_head(inthash,
5699 A,
5700 B,
5701 C,
5702 D,
5703 E,
5704 F,
5705 _).
5706lookup_passive_head(multi_hash(A), B, _, C, D, E, F) :-
5707 hash_lookup_passive_head(hash,
5708 A,
5709 B,
5710 C,
5711 D,
5712 E,
5713 F,
5714 _).
5715lookup_passive_head(global_ground, A, _, _, _, F, E) :-
5716 functor(A, B, C),
5717 global_ground_store_name(B/C, D),
5718 make_get_store_goal(D, E, F),
5719 update_store_type(B/C, global_ground).
5720lookup_passive_head(var_assoc_store(A, C), B, _, F, _, G, L) :-
5721 arg(A, B, D),
5722 arg(C, B, E),
5723 translate([D, E], F, [H, K]),
5724 get_target_module(I),
5725 G=(get_attr(H, I, J), lookup_assoc_store(J, K, L)).
5726lookup_passive_head(global_singleton, A, _, _, _, E, H) :-
5727 functor(A, B, C),
5728 global_singleton_store_name(B/C, D),
5729 make_get_store_goal(D, G, F),
5730 E=(F, G\==[], H=[G]),
5731 update_store_type(B/C, global_singleton).
5732lookup_passive_head(multi_store(A), C, D, E, F, G, H) :-
5733 once(( member(B, A),
5734 lookup_passive_head(B,
5735 C,
5736 D,
5737 E,
5738 F,
5739 G,
5740 H)
5741 )).
5742lookup_passive_head(identifier_store(B), A, _, D, _, I, G) :-
5743 functor(A, E, F),
5744 arg(B, A, C),
5745 translate([C], D, [H]),
5746 delay_phase_end(validate_store_type_assumptions,
5747 identifier_lookup(E/F,
5748 B,
5749 G,
5750 H,
5751 I)),
5752 update_store_type(E/F, identifier_store(B)),
5753 get_identifier_index(E/F, B, _).
5754lookup_passive_head(type_indexed_identifier_store(B, F), A, _, D, _, E, M) :-
5755 functor(A, K, L),
5756 arg(B, A, C),
5757 ( var(C)
5758 -> translate([C], D, [H]),
5759 E=J
5760 ; ground(C),
5761 C='$chr_identifier_match'(G, _)
5762 -> lookup_only_identifier_atom(F, G, H, I),
5763 E=(I, J)
5764 ),
5765 delay_phase_end(validate_store_type_assumptions,
5766 type_indexed_identifier_lookup(K/L,
5767 B,
5768 F,
5769 M,
5770 H,
5771 J)),
5772 update_store_type(K/L,
5773 type_indexed_identifier_store(B, F)),
5774 get_type_indexed_identifier_index(F,
5775 K/L,
5776 B,
5777 _).
5778identifier_lookup(B, C, F, H, G) :-
5779 get_identifier_size(A),
5780 functor(E, struct, A),
5781 get_identifier_index(B, C, D),
5782 arg(D, E, F),
5783 G=(H=E).
5784type_indexed_identifier_lookup(B, C, A, F, H, G) :-
5785 type_indexed_identifier_structure(A, E),
5786 get_type_indexed_identifier_index(A, B, C, D),
5787 arg(D, E, F),
5788 G=(H=E).
5789hash_lookup_passive_head(I, A, B, C, K, N, J, D) :-
5790 pick_hash_index(A, B, C, D, L, E),
5791 ( E=[F]
5792 -> true
5793 ; F=..[k|E]
5794 ),
5795 functor(B, G, H),
5796 multi_hash_lookup_goal(G/H,
5797 I,
5798 D,
5799 F,
5800 J,
5801 P),
5802 check_ground(K, L, M),
5803 my_term_copy(M, C, O),
5804 N=(O, P),
5805 ( I==inthash
5806 -> update_store_type(G/H, multi_inthash([D]))
5807 ; update_store_type(G/H, multi_hash([D]))
5808 ).
5809pick_hash_index(B, C, E, A, D, F) :-
5810 member(A, B),
5811 args(A, C, D),
5812 key_in_scope(D, E, F), !.
5813key_in_scope([], _, []).
5814key_in_scope([A|F], C, [D|G]) :-
5815 term_variables(A, B),
5816 translate(B, C, E),
5817 copy_term(A/B, D/E),
5818 key_in_scope(F, C, G).
5819existential_lookup(var_assoc_store(B, C), D, E, F, G, L, M, H, A, A) :- !,
5820 lookup_passive_head(var_assoc_store(B, C),
5821 D,
5822 E,
5823 F,
5824 G,
5825 N,
5826 I),
5827 sbag_member_call(H, I, O),
5828 functor(D, J, K),
5829 delay_phase_end(validate_store_type_assumptions,
5830 (static_suspension_term(J/K, L), get_static_suspension_field(J/K, L, state, active, P))),
5831 M=(N, O, H=L, P).
5832existential_lookup(global_singleton, B, _, _, _, I, G, F, A, A) :- !,
5833 functor(B, C, D),
5834 global_singleton_store_name(C/D, E),
5835 make_get_store_goal(E, F, H),
5836 G=(H, F\==[], F=I),
5837 update_store_type(C/D, global_singleton).
5838existential_lookup(multi_store(A), C, D, E, F, G, H, I, J, K) :- !,
5839 once(( member(B, A),
5840 existential_lookup(B,
5841 C,
5842 D,
5843 E,
5844 F,
5845 G,
5846 H,
5847 I,
5848 J,
5849 K)
5850 )).
5851existential_lookup(multi_inthash(A), B, _, C, D, E, F, G, H, I) :- !,
5852 existential_hash_lookup(inthash,
5853 A,
5854 B,
5855 C,
5856 D,
5857 E,
5858 F,
5859 G,
5860 H,
5861 I).
5862existential_lookup(multi_hash(A), B, _, C, D, E, F, G, H, I) :- !,
5863 existential_hash_lookup(hash,
5864 A,
5865 B,
5866 C,
5867 D,
5868 E,
5869 F,
5870 G,
5871 H,
5872 I).
5873existential_lookup(identifier_store(A), B, C, D, E, M, N, K, F, G) :- !,
5874 lookup_passive_head(identifier_store(A),
5875 B,
5876 C,
5877 D,
5878 E,
5879 O,
5880 J),
5881 hash_index_filter(F, [A], G),
5882 functor(B, H, I),
5883 ( check_fd_lookup_condition(H, I, B, _)
5884 -> L=(J=[K])
5885 ; sbag_member_call(K, J, L)
5886 ),
5887 delay_phase_end(validate_store_type_assumptions,
5888 (static_suspension_term(H/I, M), get_static_suspension_field(H/I, M, state, active, P))),
5889 N=(O, L, K=M, P).
5890existential_lookup(type_indexed_identifier_store(A, B), C, D, E, F, N, O, L, G, H) :- !,
5891 lookup_passive_head(type_indexed_identifier_store(A, B),
5892 C,
5893 D,
5894 E,
5895 F,
5896 P,
5897 K),
5898 hash_index_filter(G, [A], H),
5899 functor(C, I, J),
5900 ( check_fd_lookup_condition(I, J, C, _)
5901 -> M=(K=[L])
5902 ; sbag_member_call(L, K, M)
5903 ),
5904 delay_phase_end(validate_store_type_assumptions,
5905 (static_suspension_term(I/J, N), get_static_suspension_field(I/J, N, state, active, Q))),
5906 O=(P, M, L=N, Q).
5907existential_lookup(B, C, D, E, F, K, L, G, A, A) :-
5908 lookup_passive_head(B,
5909 C,
5910 D,
5911 E,
5912 F,
5913 M,
5914 H),
5915 sbag_member_call(G, H, N),
5916 functor(C, I, J),
5917 delay_phase_end(validate_store_type_assumptions,
5918 (static_suspension_term(I/J, K), get_static_suspension_field(I/J, K, state, active, O))),
5919 L=(M, N, G=K, O).
5920existential_hash_lookup(A, B, C, D, E, N, O, L, F, H) :-
5921 hash_lookup_passive_head(A,
5922 B,
5923 C,
5924 D,
5925 E,
5926 P,
5927 K,
5928 G),
5929 hash_index_filter(F, G, H),
5930 functor(C, I, J),
5931 ( check_fd_lookup_condition(I, J, C, _)
5932 -> M=(K=[L])
5933 ; sbag_member_call(L, K, M)
5934 ),
5935 delay_phase_end(validate_store_type_assumptions,
5936 (static_suspension_term(I/J, N), get_static_suspension_field(I/J, N, state, active, Q))),
5937 O=(P, M, L=N, Q).
5938hash_index_filter(A, B, C) :-
5939 hash_index_filter(A, B, 1, C).
5940hash_index_filter([], _, _, []).
5941hash_index_filter([E|F], A, B, D) :-
5942 ( A=[C|G]
5943 -> H is B+1,
5944 ( C>B
5945 -> D=[E|I],
5946 hash_index_filter(F, [C|G], H, I)
5947 ; C==B
5948 -> D=[silent(E)|I],
5949 hash_index_filter(F, G, H, I)
5950 )
5951 ; D=[E|F]
5952 ).
5953assume_constraint_stores([]).
5954assume_constraint_stores([A|V]) :-
5955 ( chr_pp_flag(debugable, off),
5956 ( only_ground_indexed_arguments(A)
5957 ; chr_pp_flag(mixed_stores, on)
5958 ),
5959 is_stored(A),
5960 get_store_type(A, default)
5961 -> get_indexed_arguments(A, C),
5962 get_constraint_mode(A, D),
5963 aggregate_all(bag(B)-count,
5964 ( member(B, C),
5965 nth1(B, D, +)
5966 ),
5967 F-E),
5968 ( E>10
5969 -> findall([B], member(B, F), H)
5970 ; findall(B,
5971 ( sublist(B, F),
5972 B\==[]
5973 ),
5974 G),
5975 predsort(longer_list, G, H)
5976 ),
5977 ( get_functional_dependency(A, 1, I, J),
5978 all_distinct_var_args(I),
5979 J==[]
5980 -> assumed_store_type(A, global_singleton)
5981 ; ( only_ground_indexed_arguments(A)
5982 ; E>0
5983 )
5984 -> get_constraint_type_det(A, K),
5985 partition_indexes(H,
5986 K,
5987 O,
5988 L,
5989 Q,
5990 T),
5991 ( L=[]
5992 -> M=N
5993 ; M=[multi_inthash(L)|N]
5994 ),
5995 ( O=[]
5996 -> N=P
5997 ; N=[multi_hash(O)|P]
5998 ),
5999 ( Q=[]
6000 -> P=S
6001 ; maplist(wrap_in_functor(identifier_store),
6002 Q,
6003 R),
6004 append(R, S, P)
6005 ),
6006 append(T, U, S),
6007 ( only_ground_indexed_arguments(A)
6008 -> U=[global_ground]
6009 ; U=[default]
6010 ),
6011 assumed_store_type(A, multi_store(M))
6012 ; true
6013 )
6014 ; true
6015 ),
6016 assume_constraint_stores(V).
6017partition_indexes([], _, [], [], [], []).
6018partition_indexes([A|O], C, H, G, F, I) :-
6019 ( A=[B],
6020 nth1(B, C, D),
6021 unalias_type(D, E),
6022 E==chr_identifier
6023 -> F=[B|L],
6024 G=M,
6025 H=N,
6026 I=K
6027 ; A=[B],
6028 nth1(B, C, D),
6029 unalias_type(D, E),
6030 nonvar(E),
6031 E=chr_identifier(J)
6032 -> I=[type_indexed_identifier_store(B, J)|K],
6033 F=L,
6034 G=M,
6035 H=N
6036 ; A=[B],
6037 nth1(B, C, D),
6038 unalias_type(D, E),
6039 E==dense_int
6040 -> G=[A|M],
6041 H=N,
6042 F=L,
6043 I=K
6044 ; member(B, A),
6045 nth1(B, C, D),
6046 unalias_type(D, E),
6047 nonvar(E),
6048 E=chr_identifier(_)
6049 -> G=M,
6050 H=N,
6051 F=L,
6052 I=K
6053 ; G=M,
6054 H=[A|N],
6055 F=L,
6056 I=K
6057 ),
6058 partition_indexes(O,
6059 C,
6060 N,
6061 M,
6062 L,
6063 K).
6064longer_list(F, A, B) :-
6065 length(A, D),
6066 length(B, C),
6067 compare(E, C, D),
6068 ( E==(=)
6069 -> compare(F, A, B)
6070 ; F=E
6071 ).
6072all_distinct_var_args(A) :-
6073 copy_term_nat(A, E),
6074 functor(A, B, C),
6075 functor(D, B, C),
6076 D=@=E.
6077get_indexed_arguments(A, C) :-
6078 A=_/B,
6079 get_indexed_arguments(1, B, A, C).
6080get_indexed_arguments(A, B, D, C) :-
6081 ( A>B
6082 -> C=[]
6083 ; ( is_indexed_argument(D, A)
6084 -> C=[A|E]
6085 ; C=E
6086 ),
6087 F is A+1,
6088 get_indexed_arguments(F, B, D, E)
6089 ).
6090validate_store_type_assumptions([]).
6091validate_store_type_assumptions([A|B]) :-
6092 validate_store_type_assumption(A),
6093 validate_store_type_assumptions(B).
6094universal_search_iterator_end([C|B], D, A, L/M, N, G, W, Y) :-
6095 A=rule(_, _, E, F),
6096 gen_var_susp_list_for_b(B,
6097 [C, D, E, F],
6098 _,
6099 H,
6100 I,
6101 _,
6102 J),
6103 universal_search_iterator_failure_vars(B,
6104 G,
6105 H,
6106 I,
6107 J,
6108 S,
6109 P),
6110 flatten(H, K),
6111 O=[[]|K],
6112 build_head(L, M, [N|G], O, T),
6113 ( P=[_]
6114 -> get_success_continuation_code_id(L/M,
6115 N,
6116 Q),
6117 R=[Q]
6118 ; R=[N|P]
6119 ),
6120 build_head(L, M, R, S, U),
6121 V=(T:-U),
6122 add_dummy_location(V, X),
6123 W=[X|Y].
6124universal_search_iterator_failure_vars(F, A, E, D, K, C, B) :-
6125 ( A=[0|_]
6126 -> next_id(A, B),
6127 C=D
6128 ; E=[_|M],
6129 dec_id(A, L),
6130 ( F=[G|J],
6131 functor(G, H, I),
6132 check_fd_lookup_condition(H, I, G, J)
6133 -> K=[_|N],
6134 universal_search_iterator_failure_vars(J,
6135 L,
6136 M,
6137 D,
6138 N,
6139 C,
6140 B)
6141 ; B=L,
6142 flatten(M, P),
6143 K=[O|_],
6144 C=[O|P]
6145 )
6146 ).
6147universal_search_iterator([D|E], [C|B], A, A1/B1, C1, X, U1, W1) :-
6148 A=rule(_, _, F, G),
6149 gen_var_susp_list_for_b(B,
6150 [C, D, E, F, G],
6151 O,
6152 I,
6153 I1,
6154 H,
6155 J1),
6156 init(H, R),
6157 flatten(I, Z),
6158 gen_var(Y),
6159 functor(C, L, J),
6160 gen_vars(J, K),
6161 head_info(C, J, K, Q, _, M),
6162 get_constraint_mode(L/J, N),
6163 head_arg_matches(M, N, O, U, V),
6164 delay_phase_end(validate_store_type_assumptions,
6165 (static_suspension_term(L/J, P), get_static_suspension_field(L/J, P, state, active, S), get_static_suspension_term_field(arguments, L/J, P, K))),
6166 different_from_other_susps(C, Q, B, R, T),
6167 P1=(Q=P, S, T, U),
6168 add_heads_ground_variables([C|B], [], W),
6169 lookup_passive_head(D,
6170 [C|B],
6171 V,
6172 W,
6173 Q1,
6174 E1),
6175 inc_id(X, G1),
6176 D1=[[Q|Y]|Z],
6177 build_head(A1, B1, [C1|X], D1, O1),
6178 passive_delegate_variables(C,
6179 B,
6180 [D, E, F, G],
6181 V,
6182 F1),
6183 append([E1|F1], [Q, Y|Z], H1),
6184 build_head(A1, B1, [C1|G1], H1, R1),
6185 ( check_fd_lookup_condition(L, J, C, B)
6186 -> universal_search_iterator_failure_vars(B,
6187 X,
6188 I,
6189 I1,
6190 J1,
6191 K1,
6192 M1),
6193 L1=K1
6194 ; L1=[Y|Z],
6195 M1=X
6196 ),
6197 ( M1=[_]
6198 -> N1=M1
6199 ; N1=[C1|M1]
6200 ),
6201 build_head(A1, B1, N1, L1, S1),
6202 T1=(O1:-P1, Q1->R1;S1),
6203 add_dummy_location(T1, V1),
6204 U1=[V1|W1].
6205ai_observation_analysis(A) :-
6206 ( chr_pp_flag(ai_observation_analysis, on),
6207 get_target_module(_),
6208 '$chr_compiled_with_version'(3)
6209 -> list_to_ord_set(A, B),
6210 abstract_constraints(B),
6211 ai_observation_schedule_initial_calls(B, B),
6212 ai_observation_gather_results
6213 ; true
6214 ).
6215ai_observation_schedule_initial_calls([], _).
6216ai_observation_schedule_initial_calls([A|C], B) :-
6217 ai_observation_schedule_initial_call(A, B),
6218 ai_observation_schedule_initial_calls(C, B).
6219ai_observation_schedule_initial_call(A, _) :-
6220 ai_observation_top(A, B),
6221 initial_call_pattern(B).
6222ai_observation_schedule_new_calls([], _).
6223ai_observation_schedule_new_calls([B|D], A) :-
6224 A=odom(_, C),
6225 initial_call_pattern(odom(B, C)),
6226 ai_observation_schedule_new_calls(D, A).
6227ai_observation_lub(odom(A, B), odom(A, C), odom(A, D)) :-
6228 ord_intersection(B, C, D).
6229ai_observation_bot(A, B, odom(A, B)).
6230ai_observation_top(A, odom(A, B)) :-
6231 ord_empty(B).
6232ai_observation_leq(odom(A, C), odom(A, B)) :-
6233 ord_subset(B, C).
6234ai_observation_observe_set(A, B, C) :-
6235 ord_subtract(A, B, C).
6236ai_observation_abstract_constraint(A, E, B) :-
6237 functor(A, C, D),
6238 B=C/D,
6239 memberchk(B, E).
6240ai_observation_abstract_constraints(A, C, E) :-
6241 findall(D,
6242 ( member(B, A),
6243 ai_observation_abstract_constraint(B, C, D)
6244 ),
6245 E).
6246ai_observation_abstract_goal_(A, B, C, G, H, I) :-
6247 term_variables((A, B, C), E),
6248 append(A, B, D),
6249 ground_vars(D, F),
6250 list_difference_eq(E, F, J),
6251 ai_observation_abstract_goal(G, H, I, [], J), !.
6252ground_vars([], []).
6253ground_vars([A|F], I) :-
6254 functor(A, B, C),
6255 get_constraint_mode(B/C, E),
6256 head_info(A, C, _, _, _, D),
6257 head_arg_matches(D, E, [], _, _, [], G),
6258 ground_vars(F, H),
6259 append(G, H, I).
6260ai_observation_abstract_goal((A, E), B, C, G, D) :- !,
6261 ai_observation_abstract_goal(A, B, C, F, D),
6262 ai_observation_abstract_goal(E, B, F, G, D).
6263ai_observation_abstract_goal((B;F), C, [(D;G)|A], A, E) :- !,
6264 ai_observation_abstract_goal(B, C, D, [], E),
6265 ai_observation_abstract_goal(F, C, G, [], E).
6266ai_observation_abstract_goal((A->E), B, C, G, D) :- !,
6267 ai_observation_abstract_goal(A, B, C, F, D),
6268 ai_observation_abstract_goal(E, B, F, G, D).
6269ai_observation_abstract_goal(B, C, [D|A], A, _) :-
6270 ai_observation_abstract_constraint(B, C, D), !.
6271ai_observation_abstract_goal(true, _, A, A, _) :- !.
6272ai_observation_abstract_goal(writeln(_), _, A, A, _) :- !.
6273ai_observation_abstract_goal(B, _, A, A, D) :-
6274 builtin_binds_b(B, C),
6275 intersect_eq(C, D, []), !.
6276ai_observation_abstract_goal(_, _, [B|A], A, _) :-
6277 B=builtin.
6278ai_observation_is_observed(odom(_, B), A) :-
6279 \+ ord_memberchk(A, B).
6280unconditional_occurrence(A, B) :-
6281 get_occurrence(A, B, C, _),
6282 get_rule(C, D),
6283 D=pragma(E, _, _, _, _),
6284 copy_term_nat(E, F),
6285 F=rule(G, H, I, _),
6286 guard_entailment:entails_guard([chr_pp_headvariables(G, H)], I),
6287 once(( G=[J],
6288 H==[]
6289 ; H=[J],
6290 G==[],
6291 \+ may_trigger(A)
6292 )),
6293 all_distinct_var_args(J).
6294partial_wake_args([], _, _, _).
6295partial_wake_args([B|E], [A|F], D, C) :-
6296 ( A\==(+)
6297 -> ( nonvar(B)
6298 -> no_partial_wake(C)
6299 ; memberchk_eq(B, D)
6300 -> no_partial_wake(C)
6301 ; true
6302 )
6303 ; true
6304 ),
6305 partial_wake_args(E, F, D, C).
6306generate_show_constraint(B, A, D, C) :-
6307 ( chr_pp_flag(show, on)
6308 -> A=['$show'/0|B],
6309 generate_show_rules(B, C, [E|D]),
6310 inc_rule_count(F),
6311 E=pragma(rule(['$show'], [], true, true), ids([0], []), [], no, F)
6312 ; A=B,
6313 C=D
6314 ).
6315generate_show_rules([], A, A).
6316generate_show_rules([A/B|F], [C|G], H) :-
6317 functor(D, A, B),
6318 inc_rule_count(E),
6319 C=pragma(rule([], ['$show', D], true, writeln(D)), ids([], [0, 1]), [passive(1)], no, E),
6320 generate_show_rules(F, G, H).
6321static_suspension_term(A/B, D) :-
6322 suspension_term_base(A/B, C),
6323 E is C+B,
6324 functor(D, suspension, E).
6325has_suspension_field(A, B) :-
6326 suspension_term_base_fields(A, C),
6327 memberchk(B, C).
6328suspension_term_base(A, C) :-
6329 suspension_term_base_fields(A, B),
6330 length(B, C).
6331suspension_term_base_fields(B, A) :-
6332 ( chr_pp_flag(debugable, on)
6333 -> A=[id, state, history, generation, continuation, functor]
6334 ; ( uses_history(B)
6335 -> A=[id, state, history|C]
6336 ; only_ground_indexed_arguments(B),
6337 get_functional_dependency(B, 1, _, _)
6338 -> A=[state|C]
6339 ; A=[id, state|C]
6340 ),
6341 ( only_ground_indexed_arguments(B)
6342 -> get_store_type(B, D),
6343 basic_store_types(D, E),
6344 ( memberchk(global_ground, E)
6345 -> C=[global_list_prev|F]
6346 ; C=F
6347 ),
6348 ( chr_pp_flag(ht_removal, on)
6349 -> ht_prev_fields(E, F)
6350 ; F=[]
6351 )
6352 ; may_trigger(B)
6353 -> ( uses_field(B, generation)
6354 -> C=[generation, global_list_prev|F]
6355 ; C=[global_list_prev|F]
6356 ),
6357 ( chr_pp_flag(mixed_stores, on),
6358 chr_pp_flag(ht_removal, on)
6359 -> get_store_type(B, D),
6360 basic_store_types(D, E),
6361 ht_prev_fields(E, F)
6362 ; F=[]
6363 )
6364 ; C=[global_list_prev|F],
6365 ( chr_pp_flag(mixed_stores, on),
6366 chr_pp_flag(ht_removal, on)
6367 -> get_store_type(B, D),
6368 basic_store_types(D, E),
6369 ht_prev_fields(E, F)
6370 ; F=[]
6371 )
6372 )
6373 ).
6374ht_prev_fields(A, C) :-
6375 ht_prev_fields_int(A, B),
6376 append(B, C).
6377ht_prev_fields_int([], []).
6378ht_prev_fields_int([A|F], C) :-
6379 ( A=multi_hash(B)
6380 -> maplist(ht_prev_field, B, D),
6381 C=[D|E]
6382 ; C=E
6383 ),
6384 ht_prev_fields_int(F, E).
6385ht_prev_field(A, B) :-
6386 atomic_list_concat(['multi_hash_prev-'|A], B).
6387get_static_suspension_term_field(C, A, E, F) :-
6388 suspension_term_base_fields(A, B),
6389 nth1(D, B, C), !,
6390 arg(D, E, F).
6391get_static_suspension_term_field(arguments, A, B, E) :- !,
6392 suspension_term_base(A, C),
6393 B=..[_|D],
6394 drop(C, D, E).
6395get_static_suspension_term_field(A, B, _, _) :-
6396 chr_error(internal,
6397 'Trying to obtain field ~w of ~w, wich does not have it!',
6398 [A, B]).
6399get_dynamic_suspension_term_field(C, A, F, G, D) :-
6400 suspension_term_base_fields(A, B),
6401 nth1(E, B, C), !,
6402 D=arg(E, F, G).
6403get_dynamic_suspension_term_field(arguments, A, E, C, D) :- !,
6404 static_suspension_term(A, B),
6405 get_static_suspension_term_field(arguments, A, B, C),
6406 D=(E=B).
6407get_dynamic_suspension_term_field(argument(B), A, F, G, D) :- !,
6408 suspension_term_base(A, C),
6409 E is B+C,
6410 D=arg(E, F, G).
6411get_dynamic_suspension_term_field(A, B, _, _, _) :-
6412 chr_error(internal,
6413 'Dynamic goal to get ~w of ~w, which does not have this field!',
6414 [A, B]).
6415set_dynamic_suspension_term_field(C, A, F, G, D) :-
6416 suspension_term_base_fields(A, B),
6417 nth1(E, B, C), !,
6418 D=setarg(E, F, G).
6419set_dynamic_suspension_term_field(A, B, _, _, _) :-
6420 chr_error(internal,
6421 'Dynamic goal to set ~w of ~w, which does not have this field!',
6422 [A, B]).
6423basic_store_types(multi_store(A), A) :- !.
6424basic_store_types(A, [A]).
6425generate_never_stored_rules(A, B) :-
6426 ( chr_pp_flag(declare_stored_constraints, on)
6427 -> never_stored_rules(A, B)
6428 ; B=[]
6429 ).
6430check_storedness_assertions(A) :-
6431 ( chr_pp_flag(storage_analysis, on),
6432 chr_pp_flag(declare_stored_constraints, on)
6433 -> forall(B, A, check_storedness_assertion(B))
6434 ; true
6435 ).
6436continuation_analysis(A) :-
6437 maplist(analyse_continuations, A).
6438analyse_continuations(A) :-
6439 continuation_analysis(A, 1),
6440 get_max_occurrence(A, B),
6441 C is B+1,
6442 bulk_propagation(A, 1, C),
6443 set_occurrence_code_id(A, 1, 0).
6444continuation_analysis(A, B) :-
6445 get_max_occurrence(A, C),
6446 ( B>C
6447 -> true
6448 ; B==C
6449 -> D is B+1,
6450 continuation_occurrence(A, B, D)
6451 ; constraint_continuation(A, B, C, D),
6452 continuation_occurrence(A, B, D),
6453 E is B+1,
6454 continuation_analysis(A, E)
6455 ).
6456constraint_continuation(A, B, D, E) :-
6457 ( get_occurrence_head(A, B, F)
6458 -> C is B+1,
6459 ( between(C, D, E),
6460 get_occurrence_head(A, E, G),
6461 unifiable(F, G, _)
6462 -> true
6463 ; E is D+1
6464 )
6465 ; E=D
6466 ).
6467get_occurrence_head(A, B, F) :-
6468 get_occurrence(A, B, C, D),
6469 \+ is_passive(C, D),
6470 get_rule(C, E),
6471 E=pragma(rule(H, J, _, _), ids(G, I), _, _, _),
6472 ( select2(D, F, G, H, _, _)
6473 -> true
6474 ; select2(D, F, I, J, _, _)
6475 ).
6476get_success_continuation_code_id(A, B, D) :-
6477 get_success_continuation_occurrence(A, B, C),
6478 get_occurrence_code_id(A, C, D).
6479collect_constants(_, F, E, A) :-
6480 ( not_restarted,
6481 chr_pp_flag(experiment, on)
6482 -> ( chr_pp_flag(sss, on)
6483 -> C=[fep/4-[2, 3]-[[a, b]-fep1, [c, d]-fep2]-no],
6484 copy_term_nat(A, B),
6485 flatten_clauses(B, C, D),
6486 install_new_declarations_and_restart(D)
6487 ; maplist(collect_rule_constants(E), F),
6488 ( chr_pp_flag(verbose, on)
6489 -> print_chr_constants
6490 ; true
6491 ),
6492 ( chr_pp_flag(experiment, on)
6493 -> flattening_dictionary(E, C),
6494 copy_term_nat(A, B),
6495 flatten_clauses(B, C, D),
6496 install_new_declarations_and_restart(D)
6497 ; true
6498 )
6499 )
6500 ; true
6501 ).
6502collect_rule_constants(D, A) :-
6503 A=ast_rule(B, _, _, C, _),
6504 collect_head_constants(B),
6505 collect_body_constants(C, D).
6506collect_head_constants(simplification(A)) :-
6507 maplist(collect_constraint_constants, A).
6508collect_head_constants(propagation(A)) :-
6509 maplist(collect_constraint_constants, A).
6510collect_head_constants(simpagation(A, B)) :-
6511 maplist(collect_constraint_constants, A),
6512 maplist(collect_constraint_constants, B).
6513collect_body_constants(B, A) :-
6514 maplist(collect_goal_constants(A), B).
6515collect_goal_constants(C, A) :-
6516 ( ast_nonvar(A)
6517 -> ast_symbol(A, B),
6518 ( memberchk(B, C)
6519 -> ast_term_to_term(A, E),
6520 ast_args(A, D),
6521 collect_constraint_constants(chr_constraint(B,
6522 D,
6523 E))
6524 ; B==(:)/2,
6525 ast_args(A, [F, I]),
6526 F=atomic(G),
6527 get_target_module(H),
6528 G==H,
6529 ast_nonvar(I),
6530 ast_symbol(I, J),
6531 memberchk(J, C)
6532 -> ast_term_to_term(I, L),
6533 ast_args(I, K),
6534 collect_constraint_constants(chr_constraint(J,
6535 K,
6536 L))
6537 ; true
6538 )
6539 ; true
6540 ).
6541collect_constraint_constants(A) :-
6542 A=chr_constraint(B, C, _),
6543 get_constraint_type_det(B, D),
6544 collect_all_arg_constants(C, D, []).
6545collect_all_arg_constants([], [], A) :-
6546 ( A\==[]
6547 -> add_chr_constants(A)
6548 ; true
6549 ).
6550collect_all_arg_constants([C|D], [A|E], H) :-
6551 unalias_type(A, B),
6552 ( is_chr_constants_type(B, F, _)
6553 -> ( ast_ground(C)
6554 -> ast_term_to_term(C, G),
6555 collect_all_arg_constants(D,
6556 E,
6557 [F-G|H])
6558 ; true
6559 )
6560 ; collect_all_arg_constants(D, E, H)
6561 ).
6562add_chr_constants(A) :-
6563 keysort(A, B),
6564 add_chr_constants_(B).
6565flattening_dictionary([], []).
6566flattening_dictionary([A|E], B) :-
6567 ( flattening_dictionary_entry(A, C)
6568 -> B=[C|D]
6569 ; B=D
6570 ),
6571 flattening_dictionary(E, D).
6572flattening_dictionary_entry(A, F) :-
6573 get_constraint_type_det(A, B),
6574 constant_positions(B, 1, C, D, G, M),
6575 ( C\==[]
6576 -> pairup(D, J, E),
6577 keysort(E, H),
6578 F=A-C-L-G,
6579 get_chr_constants(I),
6580 findall(K,
6581 ( member(H, I),
6582 flat_spec(A, C, J, K)
6583 ),
6584 L)
6585 ; M==yes
6586 -> enum_positions(B, 1, N, P, O),
6587 F=A-N-L-O,
6588 findall(K,
6589 ( cartesian_product(Q, P),
6590 flat_spec(A, N, Q, K)
6591 ),
6592 L)
6593 ).
6594constant_positions([], _, [], [], no, no).
6595constant_positions([A|N], F, E, G, D, I) :-
6596 unalias_type(A, B),
6597 ( is_chr_constants_type(B, H, C)
6598 -> compose_error_handlers(C, M, D),
6599 E=[F|K],
6600 G=[H|L],
6601 I=J
6602 ; ( is_chr_enum_type(B, _, _)
6603 -> I=yes
6604 ; I=J
6605 ),
6606 K=E,
6607 L=G,
6608 M=D
6609 ),
6610 O is F+1,
6611 constant_positions(N,
6612 O,
6613 K,
6614 L,
6615 M,
6616 J).
6617compose_error_handlers(no, A, A).
6618compose_error_handlers(yes(A), _, yes(A)).
6619enum_positions([], _, [], [], no).
6620enum_positions([A|L], F, E, G, D) :-
6621 unalias_type(A, B),
6622 ( is_chr_enum_type(B, H, C)
6623 -> compose_error_handlers(C, K, D),
6624 E=[F|I],
6625 G=[H|J]
6626 ; E=I,
6627 G=J,
6628 D=K
6629 ),
6630 M is F+1,
6631 enum_positions(L, M, I, J, K).
6632cartesian_product([], []).
6633cartesian_product([A|C], [B|D]) :-
6634 member(A, B),
6635 cartesian_product(C, D).
6636flat_spec(D/E, C, B, A) :-
6637 A=B-H,
6638 term_to_atom(B, G),
6639 term_to_atom(C, F),
6640 atom_concat_list(['$flat_', D, /, E, '___', F, '___', G],
6641 H).
6642restart_after_flattening(A, A) :-
6643 nb_setval('$chr_restart_after_flattening', started).
6644restart_after_flattening(_, A) :-
6645 nb_getval('$chr_restart_after_flattening', restart(A)),
6646 nb_setval('$chr_restart_after_flattening', restarted).
6647not_restarted :-
6648 nb_getval('$chr_restart_after_flattening', started).
6649install_new_declarations_and_restart(A) :-
6650 nb_setval('$chr_restart_after_flattening', restart(A)),
6651 fail.
6652flatten_clauses(A, B, H) :-
6653 flatten_readcontent(A,
6654 C,
6655 E,
6656 F,
6657 _,
6658 G,
6659 D),
6660 flatten_clauses_(B,
6661 C,
6662 D,
6663 E,
6664 F,
6665 G,
6666 H).
6667flatten_clauses_(A, E, F, D, B, C, K) :-
6668 auxiliary_constraints_declarations(A, B, C, G),
6669 dispatching_rules(A, H),
6670 declarations(D, A, B, C, I),
6671 flatten_rules(E, A, J),
6672 append([F, G, H, I, J], K).
6673declarations(B, C, D, E, H) :-
6674 findall(A,
6675 ( member(A, B),
6676 \+ memberchk(A-_-_-_, C)
6677 ),
6678 F),
6679 maplist(declaration(D, E), F, G),
6680 flatten(G, H).
6681declaration(E, H, A, [(:-chr_constraint A), (:-chr_option(mode, B)), (:-chr_option(type_declaration, G))]) :-
6682 A=C/D,
6683 functor(B, C, D),
6684 ( memberchk(B, E)
6685 -> true
6686 ; replicate(D, ?, F),
6687 B=..[_|F]
6688 ),
6689 functor(G, C, D),
6690 ( memberchk(G, H)
6691 -> true
6692 ; replicate(D, any, I),
6693 G=..[_|I]
6694 ).
6695flatten_readcontent([], [], [], [], [], [], []).
6696flatten_readcontent([A|H], B, C, D, F, E, G) :-
6697 ( A==end_of_file
6698 -> B=[],
6699 C=[],
6700 D=[],
6701 E=[],
6702 F=[],
6703 G=[]
6704 ; crude_is_rule(A)
6705 -> B=[A|I],
6706 flatten_readcontent(H,
6707 I,
6708 C,
6709 D,
6710 F,
6711 E,
6712 G)
6713 ; pure_is_declaration(A, J, K, L)
6714 -> append(J, M, C),
6715 append(K, N, D),
6716 append(L, O, E),
6717 flatten_readcontent(H,
6718 B,
6719 M,
6720 N,
6721 F,
6722 O,
6723 G)
6724 ; is_mode_declaration(A, P)
6725 -> D=[P|N],
6726 flatten_readcontent(H,
6727 B,
6728 C,
6729 N,
6730 F,
6731 E,
6732 G)
6733 ; is_type_declaration(A, Q)
6734 -> E=[Q|O],
6735 flatten_readcontent(H,
6736 B,
6737 C,
6738 D,
6739 F,
6740 O,
6741 G)
6742 ; is_type_definition(A, R)
6743 -> G=[A|T],
6744 F=[R|S],
6745 flatten_readcontent(H,
6746 B,
6747 C,
6748 D,
6749 S,
6750 E,
6751 T)
6752 ; ( A=(:-op(U, V, W))
6753 -> op(U, V, W)
6754 ; true
6755 ),
6756 G=[A|T],
6757 flatten_readcontent(H,
6758 B,
6759 C,
6760 D,
6761 F,
6762 E,
6763 T)
6764 ).
6765crude_is_rule(@(_, _)).
6766crude_is_rule(pragma(_, _)).
6767crude_is_rule(==>(_, _)).
6768crude_is_rule(<=>(_, _)).
6769pure_is_declaration(A, F, G, H) :-
6770 A=(:-B),
6771 B=..[C, D],
6772 C==(chr_constraint),
6773 conj2list(D, E),
6774 pure_extract_type_mode(E, F, G, H).
([], [], [], []).
6776pure_extract_type_mode([A/B|C], [A/B|D], E, F) :- !,
6777 pure_extract_type_mode(C, D, E, F).
6778pure_extract_type_mode([A|M], [B|N], [F|O], J) :-
6779 functor(A, C, D),
6780 B=C/D,
6781 A=..[_|E],
6782 extract_types_and_modes(E, H, G),
6783 F=..[C|G],
6784 ( forall(member(I, H), I==any)
6785 -> J=K
6786 ; J=[L|K],
6787 L=..[C|H]
6788 ),
6789 pure_extract_type_mode(M, N, O, K).
6790is_mode_declaration((:-chr_option(mode, A)), A).
6791is_type_declaration((:-chr_option(type_declaration, A)), A).
6792auxiliary_constraints_declarations(A, B, C, F) :-
6793 findall(D,
6794 auxiliary_constraints_declaration(A,
6795 B,
6796 C,
6797 D),
6798 E),
6799 flatten(E, F).
6800auxiliary_constraints_declaration(A, D, G, [(:-chr_constraint K), (:-chr_option(mode, N)), (:-chr_option(type_declaration, P))]) :-
6801 member(B/C-F-J-_, A),
6802 arg_modes(B, C, D, E),
6803 specialize_modes(E, F, O),
6804 arg_types(B, C, G, H),
6805 specialize_types(H, F, Q),
6806 length(F, I),
6807 M is C-I,
6808 member(_-L, J),
6809 K=L/M,
6810 N=..[L|O],
6811 P=..[L|Q].
6812arg_modes(A, B, D, E) :-
6813 functor(C, A, B),
6814 ( memberchk(C, D)
6815 -> C=..[_|E]
6816 ; replicate(B, ?, E)
6817 ).
6818specialize_modes(B, A, C) :-
6819 split_args(A, B, _, C).
6820arg_types(A, B, D, E) :-
6821 functor(C, A, B),
6822 ( memberchk(C, D)
6823 -> C=..[_|E]
6824 ; replicate(B, any, E)
6825 ).
6826specialize_types(B, A, C) :-
6827 split_args(A, B, _, C).
6828dispatching_rules([], []).
6829dispatching_rules([B-C-A-D|F], E) :-
6830 constraint_dispatching_rule(A,
6831 B,
6832 C,
6833 D,
6834 E,
6835 G),
6836 dispatching_rules(F, G).
6837constraint_dispatching_rule(N, C/D, A, O, B, Q) :-
6838 ( increasing_numbers(A, 1)
6839 -> L=B,
6840 M=C/D
6841 ; functor(E, C, D),
6842 E=..[_|F],
6843 split_args(A, F, G, H),
6844 append(G, H, J),
6845 atom_concat(C, '_$shuffled', I),
6846 K=..[I|J],
6847 [(E:-K)|L]=B,
6848 M=I/D
6849 ),
6850 P=swap(C, A),
6851 dispatching_rule_term_cases(N,
6852 A,
6853 M,
6854 O,
6855 P,
6856 L,
6857 Q).
6858increasing_numbers([], _).
6859increasing_numbers([A|B], A) :-
6860 C is A+1,
6861 increasing_numbers(B, C).
6862dispatching_rule_term_cases(B, A, M/D, J, K, N, O) :-
6863 length(A, E),
6864 once(pairup(C, F, B)),
6865 maplist(head_tail, C, G, H),
6866 I is D-E,
6867 maplist(wrap_in_functor(dispatching_action), F, L),
6868 dispatch_trie_index(G,
6869 H,
6870 I,
6871 J,
6872 K,
6873 L,
6874 M,
6875 N,
6876 O).
6877dispatching_action(B, C, A) :-
6878 A=..[B|C].
6879dispatch_trie_index(A, C, D, E, F, G, B, H, I) :-
6880 dispatch_trie_step(A,
6881 B,
6882 B,
6883 C,
6884 D,
6885 E,
6886 F,
6887 G,
6888 H,
6889 I).
6890dispatch_trie_step([], _, _, _, [], _, _, [], A, A) :- !.
6891dispatch_trie_step(C, N, O, A, J, K, L, M, P, Q) :-
6892 A=[B|_],
6893 length(B, G),
6894 aggregate_all(set(E/F),
6895 ( member(D, C),
6896 functor(D, E, F)
6897 ),
6898 H),
6899 I is G+1,
6900 dispatch_trie_step_cases(H,
6901 I,
6902 C,
6903 A,
6904 J,
6905 K,
6906 L,
6907 M,
6908 N,
6909 O,
6910 P,
6911 Q).
6912dispatch_trie_step_cases([], E, _, _, F, A, J, _, H, _, B, C) :-
6913 ( A=yes(L)
6914 -> B=[D|C],
6915 D=(G:-K),
6916 I is E+F,
6917 functor(G, H, I),
6918 reconstruct_original_term(J, G, M),
6919 K=..[L, M]
6920 ; B=C
6921 ).
6922dispatch_trie_step_cases([A|L], B, C, D, E, F, G, H, I, J, K, N) :-
6923 dispatch_trie_step_case(A,
6924 B,
6925 C,
6926 D,
6927 E,
6928 F,
6929 G,
6930 H,
6931 I,
6932 J,
6933 K,
6934 M),
6935 dispatch_trie_step_cases(L,
6936 B,
6937 C,
6938 D,
6939 E,
6940 F,
6941 G,
6942 H,
6943 I,
6944 J,
6945 M,
6946 N).
6947dispatch_trie_step_case(L/M, D, S, X, E, B, N, T, G, I1, [A|Q], R) :-
6948 A=(F:-C, W),
6949 ( B=yes(_)
6950 -> C=!
6951 ; C=true
6952 ),
6953 H is D+E,
6954 functor(F, G, H),
6955 arg(1, F, K),
6956 F=..[_, _|J],
6957 length(I, E),
6958 once(append(D1, I, J)),
6959 functor(K, L, M),
6960 H1=index_functor(L, M, N),
6961 K=..[_|O],
6962 append(O, J, P),
6963 ( P==I
6964 -> Q=R,
6965 rec_cases(S,
6966 _,
6967 T,
6968 L/M,
6969 _,
6970 _,
6971 U),
6972 U=[V],
6973 call(V, I, W)
6974 ; rec_cases(S,
6975 X,
6976 T,
6977 L/M,
6978 Z,
6979 Y,
6980 U),
6981 ( U=[B1]
6982 -> Y=[A1],
6983 append([Z, A1, I], P),
6984 Q=R,
6985 call(B1, I, W)
6986 ; pairup(Z, Y, C1),
6987 common_pattern(C1, G1, J1, O1),
6988 append(O, D1, [E1|F1]),
6989 E1-F1=G1,
6990 S1=gct([E1|F1], H1),
6991 fresh_symbol(I1, K1),
6992 append(J1, I, L1),
6993 W=..[K1|L1],
6994 findall(M1-N1,
6995 member([M1|N1], O1),
6996 P1),
6997 once(pairup(Q1, R1, P1)),
6998 dispatch_trie_step(Q1,
6999 K1,
7000 I1,
7001 R1,
7002 E,
7003 B,
7004 S1,
7005 U,
7006 Q,
7007 R)
7008 )
7009 ).
7010split([D|F], A, B, C, E) :-
7011 ( A==1
7012 -> B=[],
7013 C=D,
7014 E=F
7015 ; G is A-1,
7016 B=[D|H],
7017 split(F, G, H, C, E)
7018 ).
7019reconstruct_original_term(swap(C, E), A, B) :-
7020 functor(A, _, D),
7021 functor(B, C, D),
7022 B=..[_|F],
7023 split_args(E, F, G, H),
7024 A=..[_|I],
7025 append(G, H, I).
7026reconstruct_original_term(index_functor(D, B, I), A, K) :-
7027 A=..[F|C],
7028 split_at(B, C, E, H),
7029 G=..[D|E],
7030 J=..[F, G|H],
7031 reconstruct_original_term(I, J, K).
7032reconstruct_original_term(gct(A, I), C, K) :-
7033 copy_term_nat(A, B),
7034 term_variables(B, D),
7035 C=..[G|E],
7036 append(D, F, E),
7037 append(B, F, H),
7038 J=..[G|H],
7039 reconstruct_original_term(I, J, K).
7040flatten_rules(A, B, D) :-
7041 flatten_rules1(A, B, C),
7042 flatten(C, D).
7043flatten_rules1([], _, []).
7044flatten_rules1([A|E], B, [D|F]) :-
7045 findall(C, flatten_rule(A, B, C), D),
7046 flatten_rules1(E, B, F).
7047flatten_rule(@(A, B), C, @(A, D)) :- !,
7048 flatten_rule(B, C, D).
7049flatten_rule(pragma(B, A), C, pragma(D, A)) :- !,
7050 flatten_rule(B, C, D).
7051flatten_rule(==>(A, D), B, ==>(C, E)) :- !,
7052 flatten_heads(A, B, C),
7053 flatten_body(D, B, E).
7054flatten_rule(<=>(\(A, B), F), C, <=>(\(D, E), G)) :- !,
7055 flatten_heads((A, B), C, (D, E)),
7056 flatten_body(F, C, G).
7057flatten_rule(<=>(A, D), B, <=>(C, E)) :-
7058 flatten_heads(A, B, C),
7059 flatten_body(D, B, E).
7060flatten_heads((A, D), B, (C, E)) :- !,
7061 flatten_heads(A, B, C),
7062 flatten_heads(D, B, E).
7063flatten_heads(#(B, A), C, #(D, A)) :- !,
7064 flatten_heads(B, C, D).
7065flatten_heads(A, D, I) :-
7066 ( functor(A, B, C),
7067 memberchk(B/C-E-H-_, D)
7068 -> A=..[_|F],
7069 split_args(E, F, G, K),
7070 member(G-J, H),
7071 I=..[J|K]
7072 ; I=A
7073 ).
7074flatten_body((A| F), B, (E| I)) :- !,
7075 conj2list(A, C),
7076 maplist(flatten_goal(B), C, D),
7077 list2conj(D, E),
7078 conj2list(F, G),
7079 maplist(flatten_goal(B), G, H),
7080 list2conj(H, I).
7081flatten_body(A, B, E) :-
7082 conj2list(A, C),
7083 maplist(flatten_goal(B), C, D),
7084 list2conj(D, E).
7085flatten_goal(_, A, B) :-
7086 var(A), !,
7087 B=A.
7088flatten_goal(B, A, D) :-
7089 ( is_specializable_goal(A, B, C)
7090 -> specialize_goal(A, C, D)
7091 ; A=E:G,
7092 get_target_module(F),
7093 E==F,
7094 nonvar(G),
7095 is_specializable_goal(G, B, C)
7096 -> specialize_goal(G, C, H),
7097 D=E:H
7098 ; partial_eval(A, D)
7099 -> true
7100 ; D=A
7101 ).
7102is_specializable_goal(A, E, D) :-
7103 functor(A, B, C),
7104 memberchk(B/C-D-_-_, E),
7105 args(D, A, F),
7106 ground(F).
7107specialize_goal(A, B, G) :-
7108 functor(A, D, E),
7109 A=..[_|C],
7110 split_args(B, C, F, I),
7111 flat_spec(D/E, B, F, _-H),
7112 G=..[H|I].
7113partial_eval(append(A, D, C), B) :-
7114 ( A==[]
7115 -> B=(C=D)
7116 ; D==[]
7117 -> B=(C=A)
7118 ).
7119partial_eval(flatten_path(A, D), C) :-
7120 ( nonvar(A),
7121 flatten(A, B),
7122 B\==A
7123 -> C=flatten_path(B, D)
7124 ).
7125dump_code(A) :-
7126 ( chr_pp_flag(dump, on)
7127 -> maplist(portray_clause, A)
7128 ; true
7129 ).
7130chr_banner :-
7131 chr_info(banner,
7132 '\tThe K.U.Leuven CHR System\n\t\tMain Developer:\tTom Schrijvers\n\t\tContributors:\tJon Sneyers, Bart Demoen, Jan Wielemaker\n\t\tCopyright:\tK.U.Leuven, Belgium\n\t\tURL:\t\thttp://www.cs.kuleuven.be/~~toms/CHR/\n',
7133 []).
7134chr_none_locked(C, B) :-
7135 chr_pp_flag(guard_locks, A),
7136 ( A==off
7137 -> B=true
7138 ; A==on
7139 -> B='chr none_locked'(C)
7140 ; A==error
7141 -> B='chr none_error_locked'(C)
7142 ).
7143chr_not_locked(C, B) :-
7144 chr_pp_flag(guard_locks, A),
7145 ( A==off
7146 -> B=true
7147 ; A==on
7148 -> B='chr not_locked'(C)
7149 ; A==error
7150 -> B='chr not_error_locked'(C)
7151 ).
7152chr_lock(C, B) :-
7153 chr_pp_flag(guard_locks, A),
7154 ( A==off
7155 -> B=true
7156 ; A==on
7157 -> B='chr lock'(C)
7158 ; A==error
7159 -> B='chr error_lock'(C)
7160 ).
7161chr_unlock(C, B) :-
7162 chr_pp_flag(guard_locks, A),
7163 ( A==off
7164 -> B=true
7165 ; A==on
7166 -> B='chr unlock'(C)
7167 ; A==error
7168 -> B='chr unerror_lock'(C)
7169 ).
7170term_to_ast_term(A, B, D, C) :-
7171 ( atomic(A)
7172 -> B=atomic(A),
7173 C=D
7174 ; compound(A)
7175 -> functor(A, E, F),
7176 B=compound(E, F, H, A),
7177 A=..[_|G],
7178 maplist_dcg(chr_translate:term_to_ast_term,
7179 G,
7180 H,
7181 D,
7182 C)
7183 ; var(A)
7184 -> var_to_ast_term(A, D, B, C)
7185 ).
7186var_to_ast_term(C, A, D, E) :-
7187 A=B-F,
7188 ( lookup_eq(B, C, D)
7189 -> E=A
7190 ; D=var(F, C),
7191 H is F+1,
7192 G=[C-D|B],
7193 E=G-H
7194 ).
7195chr_constraint_to_ast_constraint(B, A, G, H) :-
7196 A=chr_constraint(C/D, F, B),
7197 functor(B, C, D),
7198 B=..[_|E],
7199 maplist_dcg(chr_translate:term_to_ast_term,
7200 E,
7201 F,
7202 G,
7203 H).
7204rule_to_ast_rule(B, A) :-
7205 A=ast_rule(F, O, C, Q, D),
7206 B=rule(E, G, C, D),
7207 I=[]-1,
7208 ( E==[]
7209 -> F=propagation(H),
7210 maplist_dcg(chr_translate:chr_constraint_to_ast_constraint,
7211 G,
7212 H,
7213 I,
7214 J)
7215 ; G==[]
7216 -> F=simplification(H),
7217 maplist_dcg(chr_translate:chr_constraint_to_ast_constraint,
7218 E,
7219 H,
7220 I,
7221 J)
7222 ; F=simpagation(K, L),
7223 maplist_dcg(chr_translate:chr_constraint_to_ast_constraint,
7224 E,
7225 K,
7226 I,
7227 M),
7228 maplist_dcg(chr_translate:chr_constraint_to_ast_constraint,
7229 G,
7230 L,
7231 M,
7232 J)
7233 ),
7234 conj2list(C, N),
7235 maplist_dcg(chr_translate:term_to_ast_term,
7236 N,
7237 O,
7238 J,
7239 R),
7240 conj2list(D, P),
7241 maplist_dcg(chr_translate:term_to_ast_term,
7242 P,
7243 Q,
7244 R,
7245 _).
7246pragma_rule_to_ast_rule(pragma(A, _, _, _, _), B) :-
7247 rule_to_ast_rule(A, B).
7248check_rule_to_ast_rule(A) :-
7249 ( rule_to_ast_rule(A, B)
7250 -> writeln(B)
7251 ; writeln(failed(rule_to_ast_rule(A, B)))
7252 ).
7253ast_term_to_term(var(_, A), A).
7254ast_term_to_term(atomic(A), A).
7255ast_term_to_term(compound(_, _, _, A), A).
7256ast_nonvar(atomic(_)).
7257ast_nonvar(compound(_, _, _, _)).
7258ast_ground(atomic(_)).
7259ast_ground(compound(_, _, A, _)) :-
7260 maplist(ast_ground, A).
7261ast_is_ground(B, A) :-
7262 ast_is_ground_(A, B).
7263ast_is_ground_(var(A, _), B) :-
7264 tree_set_memberchk(A, B).
7265ast_is_ground_(atomic(_), _).
7266ast_is_ground_(compound(_, _, B, _), A) :-
7267 maplist(ast_is_ground(A), B).
7268ast_functor(atomic(A), A, 0).
7269ast_functor(compound(A, B, _, _), A, B).
7270ast_symbol(atomic(A), A/0).
7271ast_symbol(compound(A, B, _, _), A/B).
7272ast_args(atomic(_), []).
7273ast_args(compound(_, _, A, _), A).
7274ast_term_variables(atomic(_), A, A).
7275ast_term_variables(compound(_, _, A, _), B, C) :-
7276 ast_term_list_variables(A, B, C).
7277ast_term_variables(var(B, _), A, C) :-
7278 tree_set_add(A, B, C).
7279ast_term_list_variables(A, B, C) :-
7280 fold(A, chr_translate:ast_term_variables, B, C).
7281ast_constraint_variables(chr_constraint(_, A, _), B, C) :-
7282 ast_term_list_variables(A, B, C).
7283ast_constraint_list_variables(A, B, C) :-
7284 fold(A, chr_translate:ast_constraint_variables, B, C).
7285ast_head_variables(simplification(A), B, C) :-
7286 ast_constraint_list_variables(A, B, C).
7287ast_head_variables(propagation(A), B, C) :-
7288 ast_constraint_list_variables(A, B, C).
7289ast_head_variables(simpagation(A, C), B, E) :-
7290 ast_constraint_list_variables(A, B, D),
7291 ast_constraint_list_variables(C, D, E).
7292ast_var_memberchk(var(A, _), B) :-
7293 tree_set_memberchk(A, B).
7294ast_instantiate(B, A, C) :-
7295 ast_instantiate_(A, B, C).
7296ast_instantiate_(var(A, _), B, C) :-
7297 get_assoc(A, B, C).
7298ast_instantiate_(atomic(A), _, A).
7299ast_instantiate_(compound(B, C, E, _), D, A) :-
7300 functor(A, B, C),
7301 A=..[_|F],
7302 maplist(ast_instantiate(D), E, F).
7303ast_head_arg_matches_([], [], A, B, [], A, B).
7304ast_head_arg_matches_([silent(B-_)|D], [A|E], F, C, H, I, J) :- !,
7305 ( A==(+)
7306 -> ast_term_variables(B, G, C),
7307 ast_head_arg_matches_(D,
7308 E,
7309 F,
7310 G,
7311 H,
7312 I,
7313 J)
7314 ; ast_head_arg_matches_(D,
7315 E,
7316 F,
7317 C,
7318 H,
7319 I,
7320 J)
7321 ).
7322ast_head_arg_matches_([A-G|L], [D|M], C, E, F, B1, C1) :-
7323 ( A=var(B, _)
7324 -> ( get_assoc(B, C, H)
7325 -> ( D=(+)
7326 -> ( tree_set_memberchk(B, E)
7327 -> F=[G=H|I],
7328 J=E
7329 ; F=[G==H|I],
7330 tree_set_add(E, B, J)
7331 )
7332 ; F=[G==H|I],
7333 J=E
7334 ),
7335 K=C
7336 ; put_assoc(B, C, G, K),
7337 F=I,
7338 ( D=(+)
7339 -> tree_set_add(E, B, J)
7340 ; J=E
7341 )
7342 ),
7343 Q=L,
7344 R=M
7345 ; ground(A),
7346 A='$chr_identifier_match'(O, N)
7347 -> identifier_label_atom(N, G, O, P),
7348 F=[P|I],
7349 C=K,
7350 J=E,
7351 Q=L,
7352 R=M
7353 ; A=atomic(S)
7354 -> ( D=(+)
7355 -> F=[G=S|I]
7356 ; F=[G==S|I]
7357 ),
7358 C=K,
7359 J=E,
7360 Q=L,
7361 R=M
7362 ; D==(+),
7363 ast_is_ground(E, A)
7364 -> ast_instantiate(C, A, T),
7365 F=[G=T|I],
7366 C=K,
7367 J=E,
7368 Q=L,
7369 R=M
7370 ; D==(?),
7371 ast_is_ground(E, A)
7372 -> ast_instantiate(C, A, T),
7373 F=[G==T|I],
7374 C=K,
7375 J=E,
7376 Q=L,
7377 R=M
7378 ; A=compound(U, V, X, _),
7379 functor(W, U, V),
7380 W=..[_|Y],
7381 ( D=(+)
7382 -> F=[G=W|I]
7383 ; F=[nonvar(G), G=W|I]
7384 ),
7385 pairup(X, Y, Z),
7386 append(Z, L, Q),
7387 replicate(_, D, A1),
7388 append(A1, M, R),
7389 K=C,
7390 J=E
7391 ),
7392 ast_head_arg_matches_(Q,
7393 R,
7394 K,
7395 J,
7396 I,
7397 B1,
7398 C1).
7399:- use_module(chr(chr_runtime)). 7400:- use_module(chr(chr_hashtable_store)). 7401attach_generate_empty_named_history_initialisation___1([], _).
7402attach_generate_empty_named_history_initialisation___1([A|Q], D) :-
7403 ( get_attr(A, chr_translate, B)
7404 -> ( B=v(C, E, F, G, H, I, J, K, L, M, N),
7405 ( C/\1=:=1
7406 -> O=v(C, [D|E], F, G, H, I, J, K, L, M, N)
7407 ; P is C\/1,
7408 O=v(P, [D], F, G, H, I, J, K, L, M, N)
7409 )
7410 ),
7411 put_attr(A, chr_translate, O)
7412 ; put_attr(A,
7413 chr_translate,
7414 v(1, [D], [], [], [], [], [], [], [], [], []))
7415 ),
7416 attach_generate_empty_named_history_initialisation___1(Q,
7417 D).
7418detach_generate_empty_named_history_initialisation___1([], _).
7419detach_generate_empty_named_history_initialisation___1([A|Q], E) :-
7420 ( get_attr(A, chr_translate, B)
7421 -> B=v(C, D, H, I, J, K, L, M, N, O, P),
7422 ( C/\1=:=1
7423 -> 'chr sbag_del_element'(D, E, F),
7424 ( F==[]
7425 -> G is C/\ -2,
7426 ( G==0
7427 -> del_attr(A, chr_translate)
7428 ; put_attr(A,
7429 chr_translate,
7430 v(G,
7431 [],
7432 H,
7433 I,
7434 J,
7435 K,
7436 L,
7437 M,
7438 N,
7439 O,
7440 P))
7441 )
7442 ; put_attr(A,
7443 chr_translate,
7444 v(C,
7445 F,
7446 H,
7447 I,
7448 J,
7449 K,
7450 L,
7451 M,
7452 N,
7453 O,
7454 P))
7455 )
7456 ; true
7457 )
7458 ; true
7459 ),
7460 detach_generate_empty_named_history_initialisation___1(Q,
7461 E).
7462attach_symbol_count___2([], _).
7463attach_symbol_count___2([A|Q], E) :-
7464 ( get_attr(A, chr_translate, B)
7465 -> ( B=v(C, D, F, G, H, I, J, K, L, M, N),
7466 ( C/\2=:=2
7467 -> O=v(C, D, [E|F], G, H, I, J, K, L, M, N)
7468 ; P is C\/2,
7469 O=v(P, D, [E], G, H, I, J, K, L, M, N)
7470 )
7471 ),
7472 put_attr(A, chr_translate, O)
7473 ; put_attr(A,
7474 chr_translate,
7475 v(2, [], [E], [], [], [], [], [], [], [], []))
7476 ),
7477 attach_symbol_count___2(Q, E).
7478detach_symbol_count___2([], _).
7479detach_symbol_count___2([A|Q], E) :-
7480 ( get_attr(A, chr_translate, B)
7481 -> B=v(C, H, D, I, J, K, L, M, N, O, P),
7482 ( C/\2=:=2
7483 -> 'chr sbag_del_element'(D, E, F),
7484 ( F==[]
7485 -> G is C/\ -3,
7486 ( G==0
7487 -> del_attr(A, chr_translate)
7488 ; put_attr(A,
7489 chr_translate,
7490 v(G,
7491 H,
7492 [],
7493 I,
7494 J,
7495 K,
7496 L,
7497 M,
7498 N,
7499 O,
7500 P))
7501 )
7502 ; put_attr(A,
7503 chr_translate,
7504 v(C,
7505 H,
7506 F,
7507 I,
7508 J,
7509 K,
7510 L,
7511 M,
7512 N,
7513 O,
7514 P))
7515 )
7516 ; true
7517 )
7518 ; true
7519 ),
7520 detach_symbol_count___2(Q, E).
7521attach_fresh_symbol___2([], _).
7522attach_fresh_symbol___2([A|Q], F) :-
7523 ( get_attr(A, chr_translate, B)
7524 -> ( B=v(C, D, E, G, H, I, J, K, L, M, N),
7525 ( C/\4=:=4
7526 -> O=v(C, D, E, [F|G], H, I, J, K, L, M, N)
7527 ; P is C\/4,
7528 O=v(P, D, E, [F], H, I, J, K, L, M, N)
7529 )
7530 ),
7531 put_attr(A, chr_translate, O)
7532 ; put_attr(A,
7533 chr_translate,
7534 v(4, [], [], [F], [], [], [], [], [], [], []))
7535 ),
7536 attach_fresh_symbol___2(Q, F).
7537detach_fresh_symbol___2([], _).
7538detach_fresh_symbol___2([A|Q], E) :-
7539 ( get_attr(A, chr_translate, B)
7540 -> B=v(C, H, I, D, J, K, L, M, N, O, P),
7541 ( C/\4=:=4
7542 -> 'chr sbag_del_element'(D, E, F),
7543 ( F==[]
7544 -> G is C/\ -5,
7545 ( G==0
7546 -> del_attr(A, chr_translate)
7547 ; put_attr(A,
7548 chr_translate,
7549 v(G,
7550 H,
7551 I,
7552 [],
7553 J,
7554 K,
7555 L,
7556 M,
7557 N,
7558 O,
7559 P))
7560 )
7561 ; put_attr(A,
7562 chr_translate,
7563 v(C,
7564 H,
7565 I,
7566 F,
7567 J,
7568 K,
7569 L,
7570 M,
7571 N,
7572 O,
7573 P))
7574 )
7575 ; true
7576 )
7577 ; true
7578 ),
7579 detach_fresh_symbol___2(Q, E).
7580attach_background_info___2([], _).
7581attach_background_info___2([A|Q], G) :-
7582 ( get_attr(A, chr_translate, B)
7583 -> ( B=v(C, D, E, F, H, I, J, K, L, M, N),
7584 ( C/\8=:=8
7585 -> O=v(C, D, E, F, [G|H], I, J, K, L, M, N)
7586 ; P is C\/8,
7587 O=v(P, D, E, F, [G], I, J, K, L, M, N)
7588 )
7589 ),
7590 put_attr(A, chr_translate, O)
7591 ; put_attr(A,
7592 chr_translate,
7593 v(8, [], [], [], [G], [], [], [], [], [], []))
7594 ),
7595 attach_background_info___2(Q, G).
7596detach_background_info___2([], _).
7597detach_background_info___2([A|Q], E) :-
7598 ( get_attr(A, chr_translate, B)
7599 -> B=v(C, H, I, J, D, K, L, M, N, O, P),
7600 ( C/\8=:=8
7601 -> 'chr sbag_del_element'(D, E, F),
7602 ( F==[]
7603 -> G is C/\ -9,
7604 ( G==0
7605 -> del_attr(A, chr_translate)
7606 ; put_attr(A,
7607 chr_translate,
7608 v(G,
7609 H,
7610 I,
7611 J,
7612 [],
7613 K,
7614 L,
7615 M,
7616 N,
7617 O,
7618 P))
7619 )
7620 ; put_attr(A,
7621 chr_translate,
7622 v(C,
7623 H,
7624 I,
7625 J,
7626 F,
7627 K,
7628 L,
7629 M,
7630 N,
7631 O,
7632 P))
7633 )
7634 ; true
7635 )
7636 ; true
7637 ),
7638 detach_background_info___2(Q, E).
7639attach_get_bg_info___2([], _).
7640attach_get_bg_info___2([A|Q], H) :-
7641 ( get_attr(A, chr_translate, B)
7642 -> ( B=v(C, D, E, F, G, I, J, K, L, M, N),
7643 ( C/\16=:=16
7644 -> O=v(C, D, E, F, G, [H|I], J, K, L, M, N)
7645 ; P is C\/16,
7646 O=v(P, D, E, F, G, [H], J, K, L, M, N)
7647 )
7648 ),
7649 put_attr(A, chr_translate, O)
7650 ; put_attr(A,
7651 chr_translate,
7652 v(16, [], [], [], [], [H], [], [], [], [], []))
7653 ),
7654 attach_get_bg_info___2(Q, H).
7655detach_get_bg_info___2([], _).
7656detach_get_bg_info___2([A|Q], E) :-
7657 ( get_attr(A, chr_translate, B)
7658 -> B=v(C, H, I, J, K, D, L, M, N, O, P),
7659 ( C/\16=:=16
7660 -> 'chr sbag_del_element'(D, E, F),
7661 ( F==[]
7662 -> G is C/\ -17,
7663 ( G==0
7664 -> del_attr(A, chr_translate)
7665 ; put_attr(A,
7666 chr_translate,
7667 v(G,
7668 H,
7669 I,
7670 J,
7671 K,
7672 [],
7673 L,
7674 M,
7675 N,
7676 O,
7677 P))
7678 )
7679 ; put_attr(A,
7680 chr_translate,
7681 v(C,
7682 H,
7683 I,
7684 J,
7685 K,
7686 F,
7687 L,
7688 M,
7689 N,
7690 O,
7691 P))
7692 )
7693 ; true
7694 )
7695 ; true
7696 ),
7697 detach_get_bg_info___2(Q, E).
7698attach_type_definition___2([], _).
7699attach_type_definition___2([A|Q], I) :-
7700 ( get_attr(A, chr_translate, B)
7701 -> ( B=v(C, D, E, F, G, H, J, K, L, M, N),
7702 ( C/\32=:=32
7703 -> O=v(C, D, E, F, G, H, [I|J], K, L, M, N)
7704 ; P is C\/32,
7705 O=v(P, D, E, F, G, H, [I], K, L, M, N)
7706 )
7707 ),
7708 put_attr(A, chr_translate, O)
7709 ; put_attr(A,
7710 chr_translate,
7711 v(32, [], [], [], [], [], [I], [], [], [], []))
7712 ),
7713 attach_type_definition___2(Q, I).
7714detach_type_definition___2([], _).
7715detach_type_definition___2([A|Q], E) :-
7716 ( get_attr(A, chr_translate, B)
7717 -> B=v(C, H, I, J, K, L, D, M, N, O, P),
7718 ( C/\32=:=32
7719 -> 'chr sbag_del_element'(D, E, F),
7720 ( F==[]
7721 -> G is C/\ -33,
7722 ( G==0
7723 -> del_attr(A, chr_translate)
7724 ; put_attr(A,
7725 chr_translate,
7726 v(G,
7727 H,
7728 I,
7729 J,
7730 K,
7731 L,
7732 [],
7733 M,
7734 N,
7735 O,
7736 P))
7737 )
7738 ; put_attr(A,
7739 chr_translate,
7740 v(C,
7741 H,
7742 I,
7743 J,
7744 K,
7745 L,
7746 F,
7747 M,
7748 N,
7749 O,
7750 P))
7751 )
7752 ; true
7753 )
7754 ; true
7755 ),
7756 detach_type_definition___2(Q, E).
7757attach_type_alias___2([], _).
7758attach_type_alias___2([A|Q], J) :-
7759 ( get_attr(A, chr_translate, B)
7760 -> ( B=v(C, D, E, F, G, H, I, K, L, M, N),
7761 ( C/\64=:=64
7762 -> O=v(C, D, E, F, G, H, I, [J|K], L, M, N)
7763 ; P is C\/64,
7764 O=v(P, D, E, F, G, H, I, [J], L, M, N)
7765 )
7766 ),
7767 put_attr(A, chr_translate, O)
7768 ; put_attr(A,
7769 chr_translate,
7770 v(64, [], [], [], [], [], [], [J], [], [], []))
7771 ),
7772 attach_type_alias___2(Q, J).
7773detach_type_alias___2([], _).
7774detach_type_alias___2([A|Q], E) :-
7775 ( get_attr(A, chr_translate, B)
7776 -> B=v(C, H, I, J, K, L, M, D, N, O, P),
7777 ( C/\64=:=64
7778 -> 'chr sbag_del_element'(D, E, F),
7779 ( F==[]
7780 -> G is C/\ -65,
7781 ( G==0
7782 -> del_attr(A, chr_translate)
7783 ; put_attr(A,
7784 chr_translate,
7785 v(G,
7786 H,
7787 I,
7788 J,
7789 K,
7790 L,
7791 M,
7792 [],
7793 N,
7794 O,
7795 P))
7796 )
7797 ; put_attr(A,
7798 chr_translate,
7799 v(C,
7800 H,
7801 I,
7802 J,
7803 K,
7804 L,
7805 M,
7806 F,
7807 N,
7808 O,
7809 P))
7810 )
7811 ; true
7812 )
7813 ; true
7814 ),
7815 detach_type_alias___2(Q, E).
7816attach_unalias_type___2([], _).
7817attach_unalias_type___2([A|Q], K) :-
7818 ( get_attr(A, chr_translate, B)
7819 -> ( B=v(C, D, E, F, G, H, I, J, L, M, N),
7820 ( C/\128=:=128
7821 -> O=v(C, D, E, F, G, H, I, J, [K|L], M, N)
7822 ; P is C\/128,
7823 O=v(P, D, E, F, G, H, I, J, [K], M, N)
7824 )
7825 ),
7826 put_attr(A, chr_translate, O)
7827 ; put_attr(A,
7828 chr_translate,
7829 v(128, [], [], [], [], [], [], [], [K], [], []))
7830 ),
7831 attach_unalias_type___2(Q, K).
7832detach_unalias_type___2([], _).
7833detach_unalias_type___2([A|Q], E) :-
7834 ( get_attr(A, chr_translate, B)
7835 -> B=v(C, H, I, J, K, L, M, N, D, O, P),
7836 ( C/\128=:=128
7837 -> 'chr sbag_del_element'(D, E, F),
7838 ( F==[]
7839 -> G is C/\ -129,
7840 ( G==0
7841 -> del_attr(A, chr_translate)
7842 ; put_attr(A,
7843 chr_translate,
7844 v(G,
7845 H,
7846 I,
7847 J,
7848 K,
7849 L,
7850 M,
7851 N,
7852 [],
7853 O,
7854 P))
7855 )
7856 ; put_attr(A,
7857 chr_translate,
7858 v(C,
7859 H,
7860 I,
7861 J,
7862 K,
7863 L,
7864 M,
7865 N,
7866 F,
7867 O,
7868 P))
7869 )
7870 ; true
7871 )
7872 ; true
7873 ),
7874 detach_unalias_type___2(Q, E).
7875attach_ast_static_type_check_var___4([], _).
7876attach_ast_static_type_check_var___4([A|Q], L) :-
7877 ( get_attr(A, chr_translate, B)
7878 -> ( B=v(C, D, E, F, G, H, I, J, K, M, N),
7879 ( C/\256=:=256
7880 -> O=v(C, D, E, F, G, H, I, J, K, [L|M], N)
7881 ; P is C\/256,
7882 O=v(P, D, E, F, G, H, I, J, K, [L], N)
7883 )
7884 ),
7885 put_attr(A, chr_translate, O)
7886 ; put_attr(A,
7887 chr_translate,
7888 v(256, [], [], [], [], [], [], [], [], [L], []))
7889 ),
7890 attach_ast_static_type_check_var___4(Q, L).
7891detach_ast_static_type_check_var___4([], _).
7892detach_ast_static_type_check_var___4([A|Q], E) :-
7893 ( get_attr(A, chr_translate, B)
7894 -> B=v(C, H, I, J, K, L, M, N, O, D, P),
7895 ( C/\256=:=256
7896 -> 'chr sbag_del_element'(D, E, F),
7897 ( F==[]
7898 -> G is C/\ -257,
7899 ( G==0
7900 -> del_attr(A, chr_translate)
7901 ; put_attr(A,
7902 chr_translate,
7903 v(G,
7904 H,
7905 I,
7906 J,
7907 K,
7908 L,
7909 M,
7910 N,
7911 O,
7912 [],
7913 P))
7914 )
7915 ; put_attr(A,
7916 chr_translate,
7917 v(C,
7918 H,
7919 I,
7920 J,
7921 K,
7922 L,
7923 M,
7924 N,
7925 O,
7926 F,
7927 P))
7928 )
7929 ; true
7930 )
7931 ; true
7932 ),
7933 detach_ast_static_type_check_var___4(Q, E).
7934attach_atomic_type___1([], _).
7935attach_atomic_type___1([A|Q], M) :-
7936 ( get_attr(A, chr_translate, B)
7937 -> ( B=v(C, D, E, F, G, H, I, J, K, L, N),
7938 ( C/\512=:=512
7939 -> O=v(C, D, E, F, G, H, I, J, K, L, [M|N])
7940 ; P is C\/512,
7941 O=v(P, D, E, F, G, H, I, J, K, L, [M])
7942 )
7943 ),
7944 put_attr(A, chr_translate, O)
7945 ; put_attr(A,
7946 chr_translate,
7947 v(512, [], [], [], [], [], [], [], [], [], [M]))
7948 ),
7949 attach_atomic_type___1(Q, M).
7950detach_atomic_type___1([], _).
7951detach_atomic_type___1([A|Q], E) :-
7952 ( get_attr(A, chr_translate, B)
7953 -> B=v(C, H, I, J, K, L, M, N, O, P, D),
7954 ( C/\512=:=512
7955 -> 'chr sbag_del_element'(D, E, F),
7956 ( F==[]
7957 -> G is C/\ -513,
7958 ( G==0
7959 -> del_attr(A, chr_translate)
7960 ; put_attr(A,
7961 chr_translate,
7962 v(G,
7963 H,
7964 I,
7965 J,
7966 K,
7967 L,
7968 M,
7969 N,
7970 O,
7971 P,
7972 []))
7973 )
7974 ; put_attr(A,
7975 chr_translate,
7976 v(C,
7977 H,
7978 I,
7979 J,
7980 K,
7981 L,
7982 M,
7983 N,
7984 O,
7985 P,
7986 F))
7987 )
7988 ; true
7989 )
7990 ; true
7991 ),
7992 detach_atomic_type___1(Q, E).
7993attach_increment([], _).
7994attach_increment([A|U1], B) :-
7995 ( get_attr(A, chr_translate, C)
7996 -> ( B=v(H1, E, H, K, N, Q, T, W, Z, C1, F1),
7997 C=v(I1, D, G, J, M, P, S, V, Y, B1, E1),
7998 ( ( sort(D, F),
7999 'chr merge_attributes'(E, F, K1)
8000 ),
8001 ( sort(G, I),
8002 'chr merge_attributes'(H, I, L1)
8003 ),
8004 ( sort(J, L),
8005 'chr merge_attributes'(K, L, M1)
8006 ),
8007 ( sort(M, O),
8008 'chr merge_attributes'(N, O, N1)
8009 ),
8010 ( sort(P, R),
8011 'chr merge_attributes'(Q, R, O1)
8012 ),
8013 ( sort(S, U),
8014 'chr merge_attributes'(T, U, P1)
8015 ),
8016 ( sort(V, X),
8017 'chr merge_attributes'(W, X, Q1)
8018 ),
8019 ( sort(Y, A1),
8020 'chr merge_attributes'(Z, A1, R1)
8021 ),
8022 ( sort(B1, D1),
8023 'chr merge_attributes'(C1, D1, S1)
8024 ),
8025 sort(E1, G1),
8026 'chr merge_attributes'(F1, G1, T1)
8027 ),
8028 J1 is H1\/I1
8029 ),
8030 put_attr(A,
8031 chr_translate,
8032 v(J1,
8033 K1,
8034 L1,
8035 M1,
8036 N1,
8037 O1,
8038 P1,
8039 Q1,
8040 R1,
8041 S1,
8042 T1))
8043 ; put_attr(A, chr_translate, B)
8044 ),
8045 attach_increment(U1, B).
8046attribute_goals(_, A, A).
8047attr_unify_hook(v(Q1, A, B, C, D, E, F, G, H, I, J), K) :-
8048 sort(A, N),
8049 sort(B, Q),
8050 sort(C, T),
8051 sort(D, W),
8052 sort(E, Z),
8053 sort(F, C1),
8054 sort(G, F1),
8055 sort(H, I1),
8056 sort(I, L1),
8057 sort(J, O1),
8058 ( var(K)
8059 -> ( get_attr(K, chr_translate, L)
8060 -> ( L=v(R1, M, P, S, V, Y, B1, E1, H1, K1, N1),
8061 ( ( sort(M, O),
8062 'chr merge_attributes'(N, O, T1)
8063 ),
8064 ( sort(P, R),
8065 'chr merge_attributes'(Q, R, U1)
8066 ),
8067 ( sort(S, U),
8068 'chr merge_attributes'(T, U, V1)
8069 ),
8070 ( sort(V, X),
8071 'chr merge_attributes'(W, X, W1)
8072 ),
8073 ( sort(Y, A1),
8074 'chr merge_attributes'(Z, A1, X1)
8075 ),
8076 ( sort(B1, D1),
8077 'chr merge_attributes'(C1, D1, Y1)
8078 ),
8079 ( sort(E1, G1),
8080 'chr merge_attributes'(F1, G1, Z1)
8081 ),
8082 ( sort(H1, J1),
8083 'chr merge_attributes'(I1, J1, A2)
8084 ),
8085 ( sort(K1, M1),
8086 'chr merge_attributes'(L1, M1, B2)
8087 ),
8088 sort(N1, P1),
8089 'chr merge_attributes'(O1, P1, C2)
8090 ),
8091 S1 is Q1\/R1
8092 ),
8093 put_attr(K,
8094 chr_translate,
8095 v(S1,
8096 T1,
8097 U1,
8098 V1,
8099 W1,
8100 X1,
8101 Y1,
8102 Z1,
8103 A2,
8104 B2,
8105 C2)),
8106 '$run_suspensions_generate_empty_named_history_initialisation___1'(N),
8107 '$run_suspensions_symbol_count___2'(Q),
8108 '$run_suspensions_fresh_symbol___2'(T),
8109 '$run_suspensions_background_info___2'(W1),
8110 '$run_suspensions_get_bg_info___2'(X1),
8111 '$run_suspensions_type_definition___2'(Y1),
8112 '$run_suspensions_type_alias___2'(Z1),
8113 '$run_suspensions_unalias_type___2'(A2),
8114 '$run_suspensions_ast_static_type_check_var___4'(B2),
8115 '$run_suspensions_atomic_type___1'(C2)
8116 ; put_attr(K,
8117 chr_translate,
8118 v(Q1,
8119 N,
8120 Q,
8121 T,
8122 W,
8123 Z,
8124 C1,
8125 F1,
8126 I1,
8127 L1,
8128 O1)),
8129 '$run_suspensions_generate_empty_named_history_initialisation___1'(N),
8130 '$run_suspensions_symbol_count___2'(Q),
8131 '$run_suspensions_fresh_symbol___2'(T),
8132 '$run_suspensions_background_info___2'(W),
8133 '$run_suspensions_get_bg_info___2'(Z),
8134 '$run_suspensions_type_definition___2'(C1),
8135 '$run_suspensions_type_alias___2'(F1),
8136 '$run_suspensions_unalias_type___2'(I1),
8137 '$run_suspensions_ast_static_type_check_var___4'(L1),
8138 '$run_suspensions_atomic_type___1'(O1)
8139 )
8140 ; ( compound(K)
8141 -> term_variables(K, D2),
8142 attach_increment(D2,
8143 v(Q1,
8144 N,
8145 Q,
8146 T,
8147 W,
8148 Z,
8149 C1,
8150 F1,
8151 I1,
8152 L1,
8153 O1))
8154 ; true
8155 ),
8156 '$run_suspensions_generate_empty_named_history_initialisation___1'(N),
8157 '$run_suspensions_symbol_count___2'(Q),
8158 '$run_suspensions_fresh_symbol___2'(T),
8159 '$run_suspensions_background_info___2'(W),
8160 '$run_suspensions_get_bg_info___2'(Z),
8161 '$run_suspensions_type_definition___2'(C1),
8162 '$run_suspensions_type_alias___2'(F1),
8163 '$run_suspensions_unalias_type___2'(I1),
8164 '$run_suspensions_ast_static_type_check_var___4'(L1),
8165 '$run_suspensions_atomic_type___1'(O1)
8166 ).
8167'$novel_production'(A, B) :-
8168 arg(3, A, C),
8169 ( hprolog:get_ds(B, C, _)
8170 -> fail
8171 ; true
8172 ).
8173'$extend_history'(A, B) :-
8174 arg(3, A, C),
8175 hprolog:put_ds(B, C, x, D),
8176 setarg(3, A, D).
8177'$run_suspensions_generate_empty_named_history_initialisation___1'([]).
8178'$run_suspensions_generate_empty_named_history_initialisation___1'([A|F]) :-
8179 A=suspension(_, B, C, _, E),
8180 ( B==active
8181 -> setarg(2, A, triggered),
8182 ( D is C+1,
8183 setarg(3, A, D)
8184 ),
8185 generate_empty_named_history_initialisation___1__0(E,
8186 A),
8187 ( B==triggered
8188 -> setarg(2, A, active)
8189 ; true
8190 )
8191 ; true
8192 ),
8193 '$run_suspensions_generate_empty_named_history_initialisation___1'(F).
8194'$run_suspensions_symbol_count___2'([]).
8195'$run_suspensions_symbol_count___2'([A|E]) :-
8196 A=suspension(_, B, _, C, D),
8197 ( B==active
8198 -> setarg(2, A, triggered),
8199 symbol_count___2__0(C, D, A),
8200 ( B==triggered
8201 -> setarg(2, A, active)
8202 ; true
8203 )
8204 ; true
8205 ),
8206 '$run_suspensions_symbol_count___2'(E).
8207'$run_suspensions_fresh_symbol___2'([]).
8208'$run_suspensions_fresh_symbol___2'([A|G]) :-
8209 A=suspension(_, B, _, C, _, E, F),
8210 ( B==active
8211 -> setarg(2, A, triggered),
8212 ( D is C+1,
8213 setarg(4, A, D)
8214 ),
8215 fresh_symbol___2__0(E, F, A),
8216 ( B==triggered
8217 -> setarg(2, A, active)
8218 ; true
8219 )
8220 ; true
8221 ),
8222 '$run_suspensions_fresh_symbol___2'(G).
8223'$run_suspensions_background_info___2'([]).
8224'$run_suspensions_background_info___2'([A|G]) :-
8225 A=suspension(_, F, _, B, _, D, E),
8226 setarg(2, A, triggered),
8227 C is B+1,
8228 setarg(4, A, C),
8229 background_info___2__0(D, E, A),
8230 ( F==triggered
8231 -> setarg(2, A, active)
8232 ; true
8233 ),
8234 '$run_suspensions_background_info___2'(G).
8235'$run_suspensions_get_bg_info___2'([]).
8236'$run_suspensions_get_bg_info___2'([A|G]) :-
8237 A=suspension(_, B, _, C, _, E, F),
8238 ( B==active
8239 -> setarg(2, A, triggered),
8240 ( D is C+1,
8241 setarg(4, A, D)
8242 ),
8243 get_bg_info___2__0(E, F, A),
8244 ( B==triggered
8245 -> setarg(2, A, active)
8246 ; true
8247 )
8248 ; true
8249 ),
8250 '$run_suspensions_get_bg_info___2'(G).
8251'$run_suspensions_type_definition___2'([]).
8252'$run_suspensions_type_definition___2'([A|G]) :-
8253 A=suspension(_, B, _, C, _, E, F),
8254 ( B==active
8255 -> setarg(2, A, triggered),
8256 ( D is C+1,
8257 setarg(4, A, D)
8258 ),
8259 type_definition___2__0(E, F, A),
8260 ( B==triggered
8261 -> setarg(2, A, active)
8262 ; true
8263 )
8264 ; true
8265 ),
8266 '$run_suspensions_type_definition___2'(G).
8267'$run_suspensions_type_alias___2'([]).
8268'$run_suspensions_type_alias___2'([A|G]) :-
8269 A=suspension(_, B, _, C, _, E, F),
8270 ( B==active
8271 -> setarg(2, A, triggered),
8272 ( D is C+1,
8273 setarg(4, A, D)
8274 ),
8275 type_alias___2__0(E, F, A),
8276 ( B==triggered
8277 -> setarg(2, A, active)
8278 ; true
8279 )
8280 ; true
8281 ),
8282 '$run_suspensions_type_alias___2'(G).
8283'$run_suspensions_unalias_type___2'([]).
8284'$run_suspensions_unalias_type___2'([A|E]) :-
8285 A=suspension(_, B, _, C, D),
8286 ( B==active
8287 -> setarg(2, A, triggered),
8288 unalias_type___2__0(C, D, A),
8289 ( B==triggered
8290 -> setarg(2, A, active)
8291 ; true
8292 )
8293 ; true
8294 ),
8295 '$run_suspensions_unalias_type___2'(E).
8296'$run_suspensions_ast_static_type_check_var___4'([]).
8297'$run_suspensions_ast_static_type_check_var___4'([A|G]) :-
8298 A=suspension(_, B, _, C, D, E, F),
8299 ( B==active
8300 -> setarg(2, A, triggered),
8301 ast_static_type_check_var___4__0(C,
8302 D,
8303 E,
8304 F,
8305 A),
8306 ( B==triggered
8307 -> setarg(2, A, active)
8308 ; true
8309 )
8310 ; true
8311 ),
8312 '$run_suspensions_ast_static_type_check_var___4'(G).
8313'$run_suspensions_atomic_type___1'([]).
8314'$run_suspensions_atomic_type___1'([A|D]) :-
8315 A=suspension(_, B, _, C),
8316 ( B==active
8317 -> setarg(2, A, triggered),
8318 atomic_type___1__0(C, A),
8319 ( B==triggered
8320 -> setarg(2, A, active)
8321 ; true
8322 )
8323 ; true
8324 ),
8325 '$run_suspensions_atomic_type___1'(D).
8326'$enumerate_constraints'(A) :-
8327 ( nonvar(A)
8328 -> functor(A, B, _),
8329 '$enumerate_constraints'(B, A)
8330 ; '$enumerate_constraints'(_, A)
8331 ).
8332'$enumerate_constraints'(chr_source_file, C) :-
8333 nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',
8334 A),
8335 member(B, A),
8336 B=suspension(_, _, _, D),
8337 C=chr_source_file(D).
8338'$enumerate_constraints'(target_module, C) :-
8339 nb_getval('$chr_store_global_ground_chr_translate____target_module___1',
8340 A),
8341 member(B, A),
8342 B=suspension(_, _, _, D),
8343 C=target_module(D).
8344'$enumerate_constraints'(line_number, C) :-
8345 nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',
8346 A),
8347 value_ht(A, B),
8348 B=suspension(_, _, D, E),
8349 C=line_number(D, E).
8350'$enumerate_constraints'(indexed_argument, C) :-
8351 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',
8352 A),
8353 value_ht(A, B),
8354 B=suspension(_, _, D, E),
8355 C=indexed_argument(D, E).
8356'$enumerate_constraints'(constraint_mode, C) :-
8357 nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',
8358 A),
8359 member(B, A),
8360 B=suspension(_, _, _, _, D, E),
8361 C=constraint_mode(D, E).
8362'$enumerate_constraints'(none_suspended_on_variables, C) :-
8363 nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',
8364 A),
8365 member(B, A),
8366 B=suspension(_, _, _),
8367 C=none_suspended_on_variables.
8368'$enumerate_constraints'(store_type, C) :-
8369 nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
8370 A),
8371 value_ht(A, B),
8372 B=suspension(_, _, D, E),
8373 C=store_type(D, E).
8374'$enumerate_constraints'(actual_store_types, C) :-
8375 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
8376 A),
8377 value_ht(A, B),
8378 B=suspension(_, _, D, E),
8379 C=actual_store_types(D, E).
8380'$enumerate_constraints'(assumed_store_type, C) :-
8381 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
8382 A),
8383 value_ht(A, B),
8384 B=suspension(_, _, D, E),
8385 C=assumed_store_type(D, E).
8386'$enumerate_constraints'(validate_store_type_assumption, C) :-
8387 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
8388 A),
8389 value_ht(A, B),
8390 B=suspension(_, _, D),
8391 C=validate_store_type_assumption(D).
8392'$enumerate_constraints'(rule_count, C) :-
8393 nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',
8394 A),
8395 member(B, A),
8396 B=suspension(_, _, _, D),
8397 C=rule_count(D).
8398'$enumerate_constraints'(passive, C) :-
8399 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
8400 A),
8401 value_ht(A, B),
8402 B=suspension(_, _, _, D, E),
8403 C=passive(D, E).
8404'$enumerate_constraints'(occurrence, C) :-
8405 nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
8406 A),
8407 member(B, A),
8408 B=suspension(_, _, _, _, D, E, F, G, H),
8409 C=occurrence(D, E, F, G, H).
8410'$enumerate_constraints'(max_occurrence, C) :-
8411 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
8412 A),
8413 value_ht(A, B),
8414 B=suspension(_, _, _, D, E),
8415 C=max_occurrence(D, E).
8416'$enumerate_constraints'(allocation_occurrence, C) :-
8417 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
8418 A),
8419 value_ht(A, B),
8420 B=suspension(_, _, _, D, E),
8421 C=allocation_occurrence(D, E).
8422'$enumerate_constraints'(rule, C) :-
8423 nb_getval('$chr_store_global_ground_chr_translate____rule___2', A),
8424 member(B, A),
8425 B=suspension(_, _, _, _, D, E),
8426 C=rule(D, E).
8427'$enumerate_constraints'(least_occurrence, C) :-
8428 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
8429 A),
8430 value_ht(A, B),
8431 B=suspension(_, _, D, E),
8432 C=least_occurrence(D, E).
8433'$enumerate_constraints'(constraint_index, C) :-
8434 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',
8435 A),
8436 value_ht(A, B),
8437 B=suspension(_, _, D, E),
8438 C=constraint_index(D, E).
8439'$enumerate_constraints'(max_constraint_index, C) :-
8440 nb_getval('$chr_store_global_ground_chr_translate____max_constraint_index___1',
8441 A),
8442 member(B, A),
8443 B=suspension(_, _, _, D),
8444 C=max_constraint_index(D).
8445'$enumerate_constraints'(identifier_size, C) :-
8446 nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
8447 A),
8448 member(B, A),
8449 B=suspension(_, _, _, D),
8450 C=identifier_size(D).
8451'$enumerate_constraints'(identifier_index, C) :-
8452 nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
8453 A),
8454 value_ht(A, B),
8455 B=suspension(_, _, D, E, F),
8456 C=identifier_index(D, E, F).
8457'$enumerate_constraints'(type_indexed_identifier_size, C) :-
8458 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
8459 A),
8460 value_ht(A, B),
8461 B=suspension(_, _, D, E),
8462 C=type_indexed_identifier_size(D, E).
8463'$enumerate_constraints'(type_indexed_identifier_index, C) :-
8464 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',
8465 A),
8466 value_ht(A, B),
8467 B=suspension(_, _, D, E, F, G),
8468 C=type_indexed_identifier_index(D, E, F, G).
8469'$enumerate_constraints'(no_history, C) :-
8470 nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',
8471 A),
8472 value_ht(A, B),
8473 B=suspension(_, _, D),
8474 C=no_history(D).
8475'$enumerate_constraints'(history, C) :-
8476 nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
8477 A),
8478 value_ht(A, B),
8479 B=suspension(_, _, _, D, E, F),
8480 C=history(D, E, F).
8481'$enumerate_constraints'(indexing_spec, C) :-
8482 nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
8483 A),
8484 value_ht(A, B),
8485 B=suspension(_, _, D, E),
8486 C=indexing_spec(D, E).
8487'$enumerate_constraints'(observation_analysis, C) :-
8488 nb_getval('$chr_store_global_ground_chr_translate____observation_analysis___1',
8489 A),
8490 member(B, A),
8491 B=suspension(_, _, _, D),
8492 C=observation_analysis(D).
8493'$enumerate_constraints'(spawns, C) :-
8494 nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
8495 A),
8496 member(B, A),
8497 B=suspension(_, _, _, _, D, E, F),
8498 C=spawns(D, E, F).
8499'$enumerate_constraints'(spawns_all, C) :-
8500 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
8501 A),
8502 value_ht(A, B),
8503 B=suspension(_, _, D, E),
8504 C=spawns_all(D, E).
8505'$enumerate_constraints'(spawns_all_triggers, C) :-
8506 nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
8507 A),
8508 member(B, A),
8509 B=suspension(_, _, _, _, D, E),
8510 C=spawns_all_triggers(D, E).
8511'$enumerate_constraints'(spawns_all_triggers_implies_spawns_all, C) :-
8512 nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
8513 A),
8514 member(B, A),
8515 B=suspension(_, _, _),
8516 C=spawns_all_triggers_implies_spawns_all.
8517'$enumerate_constraints'(empty_named_history_initialisations, C) :-
8518 nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
8519 A),
8520 member(B, A),
8521 B=suspension(_, _, _, D, E),
8522 C=empty_named_history_initialisations(D, E).
8523'$enumerate_constraints'(generate_empty_named_history_initialisation, C) :-
8524 nb_current('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
8525 A),
8526 member(B, A),
8527 B=suspension(_, _, _, _, D),
8528 C=generate_empty_named_history_initialisation(D).
8529'$enumerate_constraints'(find_empty_named_histories, C) :-
8530 nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
8531 A),
8532 member(B, A),
8533 B=suspension(_, _, _, _),
8534 C=find_empty_named_histories.
8535'$enumerate_constraints'(module_initializer, C) :-
8536 nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',
8537 A),
8538 member(B, A),
8539 B=suspension(_, _, _, D),
8540 C=module_initializer(D).
8541'$enumerate_constraints'(actual_atomic_multi_hash_keys, C) :-
8542 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
8543 A),
8544 value_ht(A, B),
8545 B=suspension(_, _, D, E, F),
8546 C=actual_atomic_multi_hash_keys(D, E, F).
8547'$enumerate_constraints'(actual_ground_multi_hash_keys, C) :-
8548 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
8549 A),
8550 value_ht(A, B),
8551 B=suspension(_, _, D, E, F),
8552 C=actual_ground_multi_hash_keys(D, E, F).
8553'$enumerate_constraints'(actual_non_ground_multi_hash_key, C) :-
8554 nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
8555 A),
8556 value_ht(A, B),
8557 B=suspension(_, _, D, E),
8558 C=actual_non_ground_multi_hash_key(D, E).
8559'$enumerate_constraints'(symbol_count, C) :-
8560 nb_current('$chr_store_global_list_chr_translate____symbol_count___2',
8561 A),
8562 member(B, A),
8563 B=suspension(_, _, _, D, E),
8564 C=symbol_count(D, E).
8565'$enumerate_constraints'(fresh_symbol, C) :-
8566 nb_current('$chr_store_global_list_chr_translate____fresh_symbol___2',
8567 A),
8568 member(B, A),
8569 B=suspension(_, _, _, _, _, D, E),
8570 C=fresh_symbol(D, E).
8571'$enumerate_constraints'(prolog_global_variable, C) :-
8572 nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
8573 A),
8574 member(B, A),
8575 B=suspension(_, _, _, D),
8576 C=prolog_global_variable(D).
8577'$enumerate_constraints'(background_info, C) :-
8578 nb_getval('$chr_store_global_ground_chr_translate____background_info___1',
8579 A),
8580 member(B, A),
8581 B=suspension(_, _, _, D),
8582 C=background_info(D).
8583'$enumerate_constraints'(background_info, C) :-
8584 nb_current('$chr_store_global_list_chr_translate____background_info___2',
8585 A),
8586 member(B, A),
8587 B=suspension(_, _, _, _, _, D, E),
8588 C=background_info(D, E).
8589'$enumerate_constraints'(get_bg_info, C) :-
8590 nb_current('$chr_store_global_list_chr_translate____get_bg_info___2',
8591 A),
8592 member(B, A),
8593 B=suspension(_, _, _, _, _, D, E),
8594 C=get_bg_info(D, E).
8595'$enumerate_constraints'(get_bg_info_answer, C) :-
8596 nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
8597 A),
8598 member(B, A),
8599 B=suspension(_, _, _, D),
8600 C=get_bg_info_answer(D).
8601'$enumerate_constraints'(prev_guard_list, C) :-
8602 nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
8603 A),
8604 member(B, A),
8605 B=suspension(_, _, _, _, D, E, F, G, H, I),
8606 C=prev_guard_list(D, E, F, G, H, I).
8607'$enumerate_constraints'(set_all_passive, C) :-
8608 nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',
8609 A),
8610 value_ht(A, B),
8611 B=suspension(_, _, _, D),
8612 C=set_all_passive(D).
8613'$enumerate_constraints'(precompute_head_matchings, C) :-
8614 nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
8615 A),
8616 member(B, A),
8617 B=suspension(_, _, _, _),
8618 C=precompute_head_matchings.
8619'$enumerate_constraints'(make_head_matchings_explicit_memo_table, C) :-
8620 nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',
8621 A),
8622 value_ht(A, B),
8623 B=suspension(_, _, D, E, F),
8624 C=make_head_matchings_explicit_memo_table(D, E, F).
8625'$enumerate_constraints'(multiple_occ_constraints_checked, C) :-
8626 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
8627 A),
8628 member(B, A),
8629 B=suspension(_, _, _, D),
8630 C=multiple_occ_constraints_checked(D).
8631'$enumerate_constraints'(type_definition, C) :-
8632 nb_current('$chr_store_global_list_chr_translate____type_definition___2',
8633 A),
8634 member(B, A),
8635 B=suspension(_, _, _, _, _, D, E),
8636 C=type_definition(D, E).
8637'$enumerate_constraints'(type_alias, C) :-
8638 nb_current('$chr_store_global_list_chr_translate____type_alias___2',
8639 A),
8640 member(B, A),
8641 B=suspension(_, _, _, _, _, D, E),
8642 C=type_alias(D, E).
8643'$enumerate_constraints'(constraint_type, C) :-
8644 nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',
8645 A),
8646 member(B, A),
8647 B=suspension(_, _, _, D, E),
8648 C=constraint_type(D, E).
8649'$enumerate_constraints'(unalias_type, C) :-
8650 nb_current('$chr_store_global_list_chr_translate____unalias_type___2',
8651 A),
8652 member(B, A),
8653 B=suspension(_, _, _, D, E),
8654 C=unalias_type(D, E).
8655'$enumerate_constraints'(types_modes_condition, C) :-
8656 nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
8657 A),
8658 member(B, A),
8659 B=suspension(_, _, _, D, E, F),
8660 C=types_modes_condition(D, E, F).
8661'$enumerate_constraints'(static_type_check, C) :-
8662 nb_getval('$chr_store_global_ground_chr_translate____static_type_check___2',
8663 A),
8664 member(B, A),
8665 B=suspension(_, _, _, D, E),
8666 C=static_type_check(D, E).
8667'$enumerate_constraints'(ast_static_type_check_var, C) :-
8668 nb_current('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
8669 A),
8670 member(B, A),
8671 B=suspension(_, _, _, D, E, F, G),
8672 C=ast_static_type_check_var(D, E, F, G).
8673'$enumerate_constraints'(ast_static_atomic_builtin_type_check_var, C) :-
8674 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
8675 A),
8676 value_ht(A, B),
8677 B=suspension(_, _, D, E, F, G),
8678 C=ast_static_atomic_builtin_type_check_var(D, E, F, G).
8679'$enumerate_constraints'(dynamic_type_check, C) :-
8680 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
8681 A),
8682 member(B, A),
8683 B=suspension(_, _, _, _),
8684 C=dynamic_type_check.
8685'$enumerate_constraints'(dynamic_type_check_clauses, C) :-
8686 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
8687 A),
8688 member(B, A),
8689 B=suspension(_, _, _, D),
8690 C=dynamic_type_check_clauses(D).
8691'$enumerate_constraints'(atomic_type, C) :-
8692 nb_current('$chr_store_global_list_chr_translate____atomic_type___1',
8693 A),
8694 member(B, A),
8695 B=suspension(_, _, _, D),
8696 C=atomic_type(D).
8697'$enumerate_constraints'(stored, C) :-
8698 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
8699 A),
8700 value_ht(A, B),
8701 B=suspension(_, _, D, E, F),
8702 C=stored(D, E, F).
8703'$enumerate_constraints'(stored_complete, C) :-
8704 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
8705 A),
8706 value_ht(A, B),
8707 B=suspension(_, _, _, D, E, F),
8708 C=stored_complete(D, E, F).
8709'$enumerate_constraints'(check_all_passive, C) :-
8710 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
8711 A),
8712 value_ht(A, B),
8713 B=suspension(_, _, D, E),
8714 C=check_all_passive(D, E).
8715'$enumerate_constraints'(constraints_code1, C) :-
8716 nb_getval('$chr_store_global_ground_chr_translate____constraints_code1___3',
8717 A),
8718 member(B, A),
8719 B=suspension(_, _, _, D, E, F),
8720 C=constraints_code1(D, E, F).
8721'$enumerate_constraints'(memo_has_active_occurrence, C) :-
8722 nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',
8723 A),
8724 value_ht(A, B),
8725 B=suspension(_, _, D),
8726 C=memo_has_active_occurrence(D).
8727'$enumerate_constraints'(use_auxiliary_predicate, C) :-
8728 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
8729 A),
8730 value_ht(A, B),
8731 B=suspension(_, _, D),
8732 C=use_auxiliary_predicate(D).
8733'$enumerate_constraints'(use_auxiliary_predicate, C) :-
8734 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',
8735 A),
8736 value_ht(A, B),
8737 B=suspension(_, _, D, E),
8738 C=use_auxiliary_predicate(D, E).
8739'$enumerate_constraints'(use_auxiliary_module, C) :-
8740 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',
8741 A),
8742 value_ht(A, B),
8743 B=suspension(_, _, D),
8744 C=use_auxiliary_module(D).
8745'$enumerate_constraints'(functional_dependency, C) :-
8746 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
8747 A),
8748 value_ht(A, B),
8749 B=suspension(_, _, D, E, F, G),
8750 C=functional_dependency(D, E, F, G).
8751'$enumerate_constraints'(initial_call_pattern, C) :-
8752 nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',
8753 A),
8754 value_ht(A, B),
8755 B=suspension(_, _, _, D),
8756 C=initial_call_pattern(D).
8757'$enumerate_constraints'(call_pattern, C) :-
8758 nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',
8759 A),
8760 value_ht(A, B),
8761 B=suspension(_, _, D),
8762 C=call_pattern(D).
8763'$enumerate_constraints'(final_answer_pattern, C) :-
8764 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
8765 A),
8766 value_ht(A, B),
8767 B=suspension(_, _, _, D, E),
8768 C=final_answer_pattern(D, E).
8769'$enumerate_constraints'(abstract_constraints, C) :-
8770 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
8771 A),
8772 member(B, A),
8773 B=suspension(_, _, _, D),
8774 C=abstract_constraints(D).
8775'$enumerate_constraints'(depends_on, C) :-
8776 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
8777 A),
8778 value_ht(A, B),
8779 B=suspension(_, _, _, D, E),
8780 C=depends_on(D, E).
8781'$enumerate_constraints'(depends_on_ap, C) :-
8782 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
8783 A),
8784 value_ht(A, B),
8785 B=suspension(_, _, _, D, E, F, G),
8786 C=depends_on_ap(D, E, F, G).
8787'$enumerate_constraints'(depends_on_goal, C) :-
8788 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
8789 A),
8790 value_ht(A, B),
8791 B=suspension(_, _, _, D, E),
8792 C=depends_on_goal(D, E).
8793'$enumerate_constraints'(ai_observed_internal, C) :-
8794 nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
8795 A),
8796 member(B, A),
8797 B=suspension(_, _, _, D, E),
8798 C=ai_observed_internal(D, E).
8799'$enumerate_constraints'(ai_not_observed_internal, C) :-
8800 nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
8801 A),
8802 member(B, A),
8803 B=suspension(_, _, _, D, E),
8804 C=ai_not_observed_internal(D, E).
8805'$enumerate_constraints'(ai_not_observed, C) :-
8806 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
8807 A),
8808 value_ht(A, B),
8809 B=suspension(_, _, D, E),
8810 C=ai_not_observed(D, E).
8811'$enumerate_constraints'(depends_on_as, C) :-
8812 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',
8813 A),
8814 value_ht(A, B),
8815 B=suspension(_, _, _, D, E, F),
8816 C=depends_on_as(D, E, F).
8817'$enumerate_constraints'(ai_observation_gather_results, C) :-
8818 nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
8819 A),
8820 member(B, A),
8821 B=suspension(_, _, _),
8822 C=ai_observation_gather_results.
8823'$enumerate_constraints'(ai_observation_memoed_simplification_rest_heads, C) :-
8824 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',
8825 A),
8826 value_ht(A, B),
8827 B=suspension(_, _, D, E, F),
8828 C=ai_observation_memoed_simplification_rest_heads(D, E, F).
8829'$enumerate_constraints'(ai_observation_memoed_propagation_rest_heads, C) :-
8830 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',
8831 A),
8832 value_ht(A, B),
8833 B=suspension(_, _, D, E, F),
8834 C=ai_observation_memoed_propagation_rest_heads(D, E, F).
8835'$enumerate_constraints'(ai_observation_memoed_abstract_goal, C) :-
8836 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',
8837 A),
8838 value_ht(A, B),
8839 B=suspension(_, _, D, E),
8840 C=ai_observation_memoed_abstract_goal(D, E).
8841'$enumerate_constraints'(ai_observation_memo_abstract_goal, C) :-
8842 nb_getval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',
8843 A),
8844 member(B, A),
8845 B=suspension(_, _, _, D, E),
8846 C=ai_observation_memo_abstract_goal(D, E).
8847'$enumerate_constraints'(partial_wake_analysis, C) :-
8848 nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
8849 A),
8850 member(B, A),
8851 B=suspension(_, _, _, _),
8852 C=partial_wake_analysis.
8853'$enumerate_constraints'(no_partial_wake, C) :-
8854 nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',
8855 A),
8856 value_ht(A, B),
8857 B=suspension(_, _, D),
8858 C=no_partial_wake(D).
8859'$enumerate_constraints'(phase_end, C) :-
8860 nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',
8861 A),
8862 value_ht(A, B),
8863 B=suspension(_, _, D),
8864 C=phase_end(D).
8865'$enumerate_constraints'(delay_phase_end, C) :-
8866 nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',
8867 A),
8868 value_ht(A, B),
8869 B=suspension(_, _, D, E),
8870 C=delay_phase_end(D, E).
8871'$enumerate_constraints'(does_use_history, C) :-
8872 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',
8873 A),
8874 value_ht(A, B),
8875 B=suspension(_, _, D, E),
8876 C=does_use_history(D, E).
8877'$enumerate_constraints'(does_use_field, C) :-
8878 nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',
8879 A),
8880 value_ht(A, B),
8881 B=suspension(_, _, D, E),
8882 C=does_use_field(D, E).
8883'$enumerate_constraints'(uses_state, C) :-
8884 nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
8885 A),
8886 value_ht(A, B),
8887 B=suspension(_, _, D, E),
8888 C=uses_state(D, E).
8889'$enumerate_constraints'(if_used_state, C) :-
8890 nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
8891 A),
8892 member(B, A),
8893 B=suspension(_, _, _, D, E, F, G, H),
8894 C=if_used_state(D, E, F, G, H).
8895'$enumerate_constraints'(used_states_known, C) :-
8896 nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',
8897 A),
8898 member(B, A),
8899 B=suspension(_, _, _),
8900 C=used_states_known.
8901'$enumerate_constraints'(stored_assertion, C) :-
8902 nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',
8903 A),
8904 value_ht(A, B),
8905 B=suspension(_, _, D),
8906 C=stored_assertion(D).
8907'$enumerate_constraints'(never_stored_default, C) :-
8908 nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
8909 A),
8910 value_ht(A, B),
8911 B=suspension(_, _, D, E),
8912 C=never_stored_default(D, E).
8913'$enumerate_constraints'(never_stored_rules, C) :-
8914 nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
8915 A),
8916 member(B, A),
8917 B=suspension(_, _, _, D, E),
8918 C=never_stored_rules(D, E).
8919'$enumerate_constraints'(continuation_occurrence, C) :-
8920 nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',
8921 A),
8922 value_ht(A, B),
8923 B=suspension(_, _, D, E, F),
8924 C=continuation_occurrence(D, E, F).
8925'$enumerate_constraints'(skip_to_next_id, C) :-
8926 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
8927 A),
8928 value_ht(A, B),
8929 B=suspension(_, _, _, D, E),
8930 C=skip_to_next_id(D, E).
8931'$enumerate_constraints'(set_occurrence_code_id, C) :-
8932 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
8933 A),
8934 value_ht(A, B),
8935 B=suspension(_, _, D, E, F),
8936 C=set_occurrence_code_id(D, E, F).
8937'$enumerate_constraints'(occurrence_code_id, C) :-
8938 nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',
8939 A),
8940 value_ht(A, B),
8941 B=suspension(_, _, D, E, F),
8942 C=occurrence_code_id(D, E, F).
8943'$enumerate_constraints'(chr_constants, C) :-
8944 nb_getval('$chr_store_global_ground_chr_translate____chr_constants___1',
8945 A),
8946 member(B, A),
8947 B=suspension(_, _, _, D),
8948 C=chr_constants(D).
8949'$enumerate_constraints'(print_chr_constants, C) :-
8950 nb_getval('$chr_store_global_ground_chr_translate____print_chr_constants___0',
8951 A),
8952 member(B, A),
8953 B=suspension(_, _, _),
8954 C=print_chr_constants.
8955'$via1_multi_hash_line_number___2-1'(B, C) :-
8956 nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',
8957 A),
8958 lookup_ht(A, B, C).
8959'$via1_multi_hash_indexed_argument___2-1'(B, C) :-
8960 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',
8961 A),
8962 lookup_ht(A, B, C).
8963'$via1_multi_hash_indexed_argument___2-12'(B, C) :-
8964 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',
8965 A),
8966 lookup_ht(A, B, C).
8967'$via1_multi_hash_constraint_mode___2-1'(B, C) :-
8968 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
8969 A),
8970 lookup_ht(A, B, C).
8971'$via1_multi_hash_store_type___2-1'(B, C) :-
8972 nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
8973 A),
8974 lookup_ht(A, B, C).
8975'$via1_multi_hash_actual_store_types___2-1'(B, C) :-
8976 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
8977 A),
8978 lookup_ht(A, B, C).
8979'$via1_multi_hash_assumed_store_type___2-1'(B, C) :-
8980 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
8981 A),
8982 lookup_ht(A, B, C).
8983'$via1_multi_hash_validate_store_type_assumption___1-1'(B, C) :-
8984 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
8985 A),
8986 lookup_ht(A, B, C).
8987'$via1_multi_hash_passive___2-1'(B, C) :-
8988 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
8989 A),
8990 lookup_ht(A, B, C).
8991'$via1_multi_hash_passive___2-12'(B, C) :-
8992 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
8993 A),
8994 lookup_ht(A, B, C).
8995'$via1_multi_hash_occurrence___5-15'(B, C) :-
8996 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
8997 A),
8998 lookup_ht(A, B, C).
8999'$via1_multi_hash_occurrence___5-125'(B, C) :-
9000 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
9001 A),
9002 lookup_ht(A, B, C).
9003'$via1_multi_hash_occurrence___5-134'(B, C) :-
9004 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
9005 A),
9006 lookup_ht(A, B, C).
9007'$via1_multi_hash_occurrence___5-12'(B, C) :-
9008 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
9009 A),
9010 lookup_ht(A, B, C).
9011'$via1_multi_hash_occurrence___5-3'(B, C) :-
9012 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
9013 A),
9014 lookup_ht(A, B, C).
9015'$via1_multi_hash_occurrence___5-13'(B, C) :-
9016 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
9017 A),
9018 lookup_ht(A, B, C).
9019'$via1_multi_hash_occurrence___5-34'(B, C) :-
9020 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
9021 A),
9022 lookup_ht(A, B, C).
9023'$via1_multi_hash_occurrence___5-1'(B, C) :-
9024 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
9025 A),
9026 lookup_ht(A, B, C).
9027'$via1_multi_hash_max_occurrence___2-1'(B, C) :-
9028 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
9029 A),
9030 lookup_ht(A, B, C).
9031'$via1_multi_hash_allocation_occurrence___2-1'(B, C) :-
9032 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
9033 A),
9034 lookup_ht(A, B, C).
9035'$via1_multi_hash_allocation_occurrence___2-12'(B, C) :-
9036 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
9037 A),
9038 lookup_ht(A, B, C).
9039'$via1_multi_hash_rule___2-1'(B, C) :-
9040 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
9041 lookup_ht(A, B, C).
9042'$via1_multi_hash_least_occurrence___2-12'(B, C) :-
9043 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
9044 A),
9045 lookup_ht(A, B, C).
9046'$via1_multi_hash_least_occurrence___2-1'(B, C) :-
9047 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
9048 A),
9049 lookup_ht(A, B, C).
9050'$via1_multi_hash_constraint_index___2-2'(B, C) :-
9051 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',
9052 A),
9053 lookup_ht(A, B, C).
9054'$via1_multi_hash_constraint_index___2-1'(B, C) :-
9055 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',
9056 A),
9057 lookup_ht(A, B, C).
9058'$via1_multi_hash_identifier_index___3-12'(B, C) :-
9059 nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
9060 A),
9061 lookup_ht(A, B, C).
9062'$via1_multi_hash_type_indexed_identifier_size___2-1'(B, C) :-
9063 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
9064 A),
9065 lookup_ht(A, B, C).
9066'$via1_multi_hash_type_indexed_identifier_index___4-123'(B, C) :-
9067 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',
9068 A),
9069 lookup_ht(A, B, C).
9070'$via1_multi_hash_type_indexed_identifier_index___4-23'(B, C) :-
9071 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',
9072 A),
9073 lookup_ht(A, B, C).
9074'$via1_multi_hash_no_history___1-1'(B, C) :-
9075 nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',
9076 A),
9077 lookup_ht(A, B, C).
9078'$chr_store_constants_chr_translate____history___3___[3]'([], '$chr_store_constants_chr_translate____history___3___[3]___[]').
9079'$via1_multi_hash_history___3-2'(B, C) :-
9080 nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
9081 A),
9082 lookup_ht(A, B, C).
9083'$via1_multi_hash_history___3-1'(B, C) :-
9084 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
9085 A),
9086 lookup_ht(A, B, C).
9087'$via1_multi_hash_indexing_spec___2-1'(B, C) :-
9088 nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
9089 A),
9090 lookup_ht(A, B, C).
9091'$via1_multi_hash_spawns___3-13'(B, C) :-
9092 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
9093 A),
9094 lookup_ht(A, B, C).
9095'$via1_multi_hash_spawns___3-12'(B, C) :-
9096 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
9097 A),
9098 lookup_ht(A, B, C).
9099'$via1_multi_hash_spawns___3-1'(B, C) :-
9100 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1', A),
9101 lookup_ht(A, B, C).
9102'$via1_multi_hash_spawns___3-3'(B, C) :-
9103 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3', A),
9104 lookup_ht(A, B, C).
9105'$via1_multi_hash_spawns___3-123'(B, C) :-
9106 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
9107 A),
9108 lookup_ht(A, B, C).
9109'$via1_multi_hash_spawns_all___2-1'(B, C) :-
9110 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
9111 A),
9112 lookup_ht(A, B, C).
9113'$via1_multi_hash_spawns_all___2-12'(B, C) :-
9114 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
9115 A),
9116 lookup_ht(A, B, C).
9117'$via1_multi_hash_spawns_all_triggers___2-1'(B, C) :-
9118 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
9119 A),
9120 lookup_ht(A, B, C).
9121'$via1_multi_hash_spawns_all_triggers___2-12'(B, C) :-
9122 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
9123 A),
9124 lookup_ht(A, B, C).
9125'$via1_multi_hash_actual_atomic_multi_hash_keys___3-12'(B, C) :-
9126 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
9127 A),
9128 lookup_ht(A, B, C).
9129'$via1_multi_hash_actual_atomic_multi_hash_keys___3-1'(B, C) :-
9130 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
9131 A),
9132 lookup_ht(A, B, C).
9133'$via1_multi_hash_actual_ground_multi_hash_keys___3-12'(B, C) :-
9134 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
9135 A),
9136 lookup_ht(A, B, C).
9137'$via1_multi_hash_actual_ground_multi_hash_keys___3-1'(B, C) :-
9138 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
9139 A),
9140 lookup_ht(A, B, C).
9141'$via1_multi_hash_actual_non_ground_multi_hash_key___2-12'(B, C) :-
9142 nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
9143 A),
9144 lookup_ht(A, B, C).
9145'$via1_multi_hash_prolog_global_variable___1-1'(B, C) :-
9146 nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',
9147 A),
9148 lookup_ht(A, B, C).
9149'$via1_multi_hash_prev_guard_list___6-1'(B, C) :-
9150 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
9151 A),
9152 lookup_ht(A, B, C).
9153'$via1_multi_hash_set_all_passive___1-1'(B, C) :-
9154 nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',
9155 A),
9156 lookup_ht(A, B, C).
9157'$via1_multi_hash_make_head_matchings_explicit_memo_table___3-1'(B, C) :-
9158 nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',
9159 A),
9160 lookup_ht(A, B, C).
9161'$via1_multi_hash_constraint_type___2-1'(B, C) :-
9162 nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',
9163 A),
9164 lookup_ht(A, B, C).
9165'$via1_multi_hash_ast_static_atomic_builtin_type_check_var___4-1'(B, C) :-
9166 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
9167 A),
9168 lookup_ht(A, B, C).
9169'$via1_multi_hash_ast_static_atomic_builtin_type_check_var___4-13'(B, C) :-
9170 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
9171 A),
9172 lookup_ht(A, B, C).
9173'$via1_multi_hash_stored___3-13'(B, C) :-
9174 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
9175 A),
9176 lookup_ht(A, B, C).
9177'$via1_multi_hash_stored___3-123'(B, C) :-
9178 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
9179 A),
9180 lookup_ht(A, B, C).
9181'$via1_multi_hash_stored_complete___3-13'(B, C) :-
9182 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
9183 A),
9184 lookup_ht(A, B, C).
9185'$via1_multi_hash_stored_complete___3-1'(B, C) :-
9186 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
9187 A),
9188 lookup_ht(A, B, C).
9189'$via1_multi_hash_check_all_passive___2-12'(B, C) :-
9190 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
9191 A),
9192 lookup_ht(A, B, C).
9193'$via1_multi_hash_check_all_passive___2-1'(B, C) :-
9194 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',
9195 A),
9196 lookup_ht(A, B, C).
9197'$via1_multi_hash_memo_has_active_occurrence___1-1'(B, C) :-
9198 nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',
9199 A),
9200 lookup_ht(A, B, C).
9201'$via1_multi_hash_use_auxiliary_predicate___1-1'(B, C) :-
9202 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
9203 A),
9204 lookup_ht(A, B, C).
9205'$via1_multi_hash_use_auxiliary_predicate___2-1'(B, C) :-
9206 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',
9207 A),
9208 lookup_ht(A, B, C).
9209'$via1_multi_hash_use_auxiliary_predicate___2-12'(B, C) :-
9210 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',
9211 A),
9212 lookup_ht(A, B, C).
9213'$via1_multi_hash_use_auxiliary_module___1-1'(B, C) :-
9214 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',
9215 A),
9216 lookup_ht(A, B, C).
9217'$via1_multi_hash_functional_dependency___4-1'(B, C) :-
9218 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
9219 A),
9220 lookup_ht(A, B, C).
9221'$via1_multi_hash_functional_dependency___4-12'(B, C) :-
9222 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',
9223 A),
9224 lookup_ht(A, B, C).
9225'$via1_multi_hash_initial_call_pattern___1-1'(B, C) :-
9226 nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',
9227 A),
9228 lookup_ht(A, B, C).
9229'$via1_multi_hash_call_pattern___1-1'(B, C) :-
9230 nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',
9231 A),
9232 lookup_ht(A, B, C).
9233'$via1_multi_hash_final_answer_pattern___2-1'(B, C) :-
9234 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
9235 A),
9236 lookup_ht(A, B, C).
9237'$via1_multi_hash_depends_on___2-1'(B, C) :-
9238 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
9239 A),
9240 lookup_ht(A, B, C).
9241'$via1_multi_hash_depends_on___2-2'(B, C) :-
9242 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
9243 A),
9244 lookup_ht(A, B, C).
9245'$via1_multi_hash_depends_on_ap___4-2'(B, C) :-
9246 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
9247 A),
9248 lookup_ht(A, B, C).
9249'$via1_multi_hash_depends_on_ap___4-3'(B, C) :-
9250 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
9251 A),
9252 lookup_ht(A, B, C).
9253'$via1_multi_hash_depends_on_goal___2-2'(B, C) :-
9254 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
9255 A),
9256 lookup_ht(A, B, C).
9257'$via1_multi_hash_ai_observed_internal___2-12'(B, C) :-
9258 nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',
9259 A),
9260 lookup_ht(A, B, C).
9261'$via1_multi_hash_ai_not_observed_internal___2-12'(B, C) :-
9262 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
9263 A),
9264 lookup_ht(A, B, C).
9265'$via1_multi_hash_ai_not_observed___2-12'(B, C) :-
9266 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
9267 A),
9268 lookup_ht(A, B, C).
9269'$via1_multi_hash_depends_on_as___3-3'(B, C) :-
9270 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',
9271 A),
9272 lookup_ht(A, B, C).
9273'$via1_multi_hash_depends_on_as___3-2'(B, C) :-
9274 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',
9275 A),
9276 lookup_ht(A, B, C).
9277'$via1_multi_hash_ai_observation_memoed_simplification_rest_heads___3-12'(B, C) :-
9278 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',
9279 A),
9280 lookup_ht(A, B, C).
9281'$via1_multi_hash_ai_observation_memoed_propagation_rest_heads___3-12'(B, C) :-
9282 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',
9283 A),
9284 lookup_ht(A, B, C).
9285'$via1_multi_hash_ai_observation_memoed_abstract_goal___2-1'(B, C) :-
9286 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',
9287 A),
9288 lookup_ht(A, B, C).
9289'$via1_multi_hash_no_partial_wake___1-1'(B, C) :-
9290 nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',
9291 A),
9292 lookup_ht(A, B, C).
9293'$via1_multi_hash_phase_end___1-1'(B, C) :-
9294 nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',
9295 A),
9296 lookup_ht(A, B, C).
9297'$via1_multi_hash_delay_phase_end___2-1'(B, C) :-
9298 nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',
9299 A),
9300 lookup_ht(A, B, C).
9301'$via1_multi_hash_does_use_history___2-1'(B, C) :-
9302 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',
9303 A),
9304 lookup_ht(A, B, C).
9305'$via1_multi_hash_does_use_history___2-12'(B, C) :-
9306 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',
9307 A),
9308 lookup_ht(A, B, C).
9309'$via1_multi_hash_does_use_field___2-12'(B, C) :-
9310 nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',
9311 A),
9312 lookup_ht(A, B, C).
9313'$via1_multi_hash_uses_state___2-12'(B, C) :-
9314 nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
9315 A),
9316 lookup_ht(A, B, C).
9317'$via1_multi_hash_if_used_state___5-12'(B, C) :-
9318 nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
9319 A),
9320 lookup_ht(A, B, C).
9321'$via1_multi_hash_stored_assertion___1-1'(B, C) :-
9322 nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',
9323 A),
9324 lookup_ht(A, B, C).
9325'$via1_multi_hash_never_stored_default___2-1'(B, C) :-
9326 nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
9327 A),
9328 lookup_ht(A, B, C).
9329'$via1_multi_hash_continuation_occurrence___3-12'(B, C) :-
9330 nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',
9331 A),
9332 lookup_ht(A, B, C).
9333'$via1_multi_hash_skip_to_next_id___2-12'(B, C) :-
9334 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
9335 A),
9336 lookup_ht(A, B, C).
9337'$via1_multi_hash_set_occurrence_code_id___3-12'(B, C) :-
9338 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
9339 A),
9340 lookup_ht(A, B, C).
9341'$via1_multi_hash_occurrence_code_id___3-12'(B, C) :-
9342 nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',
9343 A),
9344 lookup_ht(A, B, C).
9345'$chr_initialization' :-
9346 nb_setval('$chr_store_global_ground_chr_translate____print_chr_constants___0',
9347 []),
9348 nb_setval('$chr_store_global_ground_chr_translate____chr_constants___1',
9349 []),
9350 new_ht(A),
9351 nb_setval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',
9352 A),
9353 new_ht(B),
9354 nb_setval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
9355 B),
9356 new_ht(C),
9357 nb_setval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
9358 C),
9359 new_ht(D),
9360 nb_setval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',
9361 D),
9362 nb_setval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
9363 []),
9364 new_ht(E),
9365 nb_setval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
9366 E),
9367 new_ht(F),
9368 nb_setval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',
9369 F),
9370 nb_setval('$chr_store_global_ground_chr_translate____used_states_known___0',
9371 []),
9372 new_ht(G),
9373 nb_setval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
9374 G),
9375 nb_setval('$chr_store_global_ground_chr_translate____if_used_state___5',
9376 []),
9377 new_ht(H),
9378 nb_setval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
9379 H),
9380 new_ht(I),
9381 nb_setval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',
9382 I),
9383 new_ht(J),
9384 nb_setval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',
9385 J),
9386 new_ht(K),
9387 nb_setval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',
9388 K),
9389 new_ht(L),
9390 nb_setval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',
9391 L),
9392 new_ht(M),
9393 nb_setval('$chr_store_multi_hash_chr_translate____phase_end___1-1',
9394 M),
9395 new_ht(N),
9396 nb_setval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',
9397 N),
9398 nb_setval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
9399 []),
9400 nb_setval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',
9401 []),
9402 new_ht(O),
9403 nb_setval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',
9404 O),
9405 new_ht(P),
9406 nb_setval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',
9407 P),
9408 new_ht(Q),
9409 nb_setval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',
9410 Q),
9411 nb_setval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
9412 []),
9413 new_ht(R),
9414 nb_setval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',
9415 R),
9416 new_ht(S),
9417 nb_setval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',
9418 S),
9419 new_ht(T),
9420 nb_setval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
9421 T),
9422 new_ht(U),
9423 nb_setval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
9424 U),
9425 nb_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
9426 []),
9427 new_ht(V),
9428 nb_setval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',
9429 V),
9430 nb_setval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
9431 []),
9432 new_ht(W),
9433 nb_setval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
9434 W),
9435 new_ht(X),
9436 nb_setval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
9437 X),
9438 new_ht(Y),
9439 nb_setval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
9440 Y),
9441 new_ht(Z),
9442 nb_setval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
9443 Z),
9444 new_ht(A1),
9445 nb_setval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
9446 A1),
9447 nb_setval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
9448 []),
9449 new_ht(B1),
9450 nb_setval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
9451 B1),
9452 new_ht(C1),
9453 nb_setval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',
9454 C1),
9455 new_ht(D1),
9456 nb_setval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',
9457 D1),
9458 new_ht(E1),
9459 nb_setval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',
9460 E1),
9461 new_ht(F1),
9462 nb_setval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
9463 F1),
9464 new_ht(G1),
9465 nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',
9466 G1),
9467 new_ht(H1),
9468 nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',
9469 H1),
9470 new_ht(I1),
9471 nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',
9472 I1),
9473 new_ht(J1),
9474 nb_setval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
9475 J1),
9476 new_ht(K1),
9477 nb_setval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',
9478 K1),
9479 nb_setval('$chr_store_global_ground_chr_translate____constraints_code1___3',
9480 []),
9481 new_ht(L1),
9482 nb_setval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',
9483 L1),
9484 new_ht(M1),
9485 nb_setval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
9486 M1),
9487 new_ht(N1),
9488 nb_setval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
9489 N1),
9490 new_ht(O1),
9491 nb_setval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
9492 O1),
9493 new_ht(P1),
9494 nb_setval('$chr_store_multi_hash_chr_translate____stored___3-123',
9495 P1),
9496 new_ht(Q1),
9497 nb_setval('$chr_store_multi_hash_chr_translate____stored___3-13',
9498 Q1),
9499 nb_setval('$chr_store_global_list_chr_translate____atomic_type___1', []),
9500 nb_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
9501 []),
9502 nb_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
9503 []),
9504 new_ht(R1),
9505 nb_setval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
9506 R1),
9507 new_ht(S1),
9508 nb_setval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
9509 S1),
9510 nb_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
9511 []),
9512 nb_setval('$chr_store_global_ground_chr_translate____static_type_check___2',
9513 []),
9514 nb_setval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
9515 []),
9516 nb_setval('$chr_store_global_list_chr_translate____unalias_type___2', []),
9517 new_ht(T1),
9518 nb_setval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',
9519 T1),
9520 nb_setval('$chr_store_global_ground_chr_translate____constraint_type___2',
9521 []),
9522 nb_setval('$chr_store_global_list_chr_translate____type_alias___2', []),
9523 nb_setval('$chr_store_global_list_chr_translate____type_definition___2',
9524 []),
9525 nb_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
9526 []),
9527 new_ht(U1),
9528 nb_setval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',
9529 U1),
9530 nb_setval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
9531 []),
9532 new_ht(V1),
9533 nb_setval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',
9534 V1),
9535 new_ht(W1),
9536 nb_setval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
9537 W1),
9538 nb_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
9539 []),
9540 nb_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
9541 []),
9542 nb_setval('$chr_store_global_list_chr_translate____get_bg_info___2', []),
9543 nb_setval('$chr_store_global_list_chr_translate____background_info___2',
9544 []),
9545 nb_setval('$chr_store_global_ground_chr_translate____background_info___1',
9546 []),
9547 new_ht(X1),
9548 nb_setval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',
9549 X1),
9550 nb_setval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
9551 []),
9552 nb_setval('$chr_store_global_list_chr_translate____fresh_symbol___2', []),
9553 nb_setval('$chr_store_global_list_chr_translate____symbol_count___2', []),
9554 new_ht(Y1),
9555 nb_setval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
9556 Y1),
9557 new_ht(Z1),
9558 nb_setval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
9559 Z1),
9560 new_ht(A2),
9561 nb_setval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
9562 A2),
9563 new_ht(B2),
9564 nb_setval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
9565 B2),
9566 new_ht(C2),
9567 nb_setval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
9568 C2),
9569 nb_setval('$chr_store_global_ground_chr_translate____module_initializer___1',
9570 []),
9571 nb_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
9572 []),
9573 nb_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
9574 []),
9575 nb_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
9576 []),
9577 nb_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
9578 []),
9579 new_ht(D2),
9580 nb_setval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
9581 D2),
9582 new_ht(E2),
9583 nb_setval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
9584 E2),
9585 nb_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
9586 []),
9587 new_ht(F2),
9588 nb_setval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
9589 F2),
9590 new_ht(G2),
9591 nb_setval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
9592 G2),
9593 new_ht(H2),
9594 nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-123',
9595 H2),
9596 new_ht(I2),
9597 nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-3',
9598 I2),
9599 new_ht(J2),
9600 nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-1',
9601 J2),
9602 new_ht(K2),
9603 nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-12',
9604 K2),
9605 nb_setval('$chr_store_global_ground_chr_translate____spawns___3', []),
9606 new_ht(L2),
9607 nb_setval('$chr_store_multi_hash_chr_translate____spawns___3-13',
9608 L2),
9609 nb_setval('$chr_store_global_ground_chr_translate____observation_analysis___1',
9610 []),
9611 new_ht(M2),
9612 nb_setval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
9613 M2),
9614 new_ht(N2),
9615 nb_setval('$chr_store_multi_hash_chr_translate____history___3-1',
9616 N2),
9617 new_ht(O2),
9618 nb_setval('$chr_store_multi_hash_chr_translate____history___3-2',
9619 O2),
9620 nb_setval('$chr_store_constants_chr_translate____history___3___[3]___[]',
9621 []),
9622 new_ht(P2),
9623 nb_setval('$chr_store_multi_hash_chr_translate____no_history___1-1',
9624 P2),
9625 new_ht(Q2),
9626 nb_setval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',
9627 Q2),
9628 new_ht(R2),
9629 nb_setval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',
9630 R2),
9631 new_ht(S2),
9632 nb_setval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
9633 S2),
9634 new_ht(T2),
9635 nb_setval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
9636 T2),
9637 nb_setval('$chr_store_global_ground_chr_translate____identifier_size___1',
9638 []),
9639 nb_setval('$chr_store_global_ground_chr_translate____max_constraint_index___1',
9640 []),
9641 new_ht(U2),
9642 nb_setval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',
9643 U2),
9644 new_ht(V2),
9645 nb_setval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',
9646 V2),
9647 new_ht(W2),
9648 nb_setval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
9649 W2),
9650 new_ht(X2),
9651 nb_setval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
9652 X2),
9653 new_ht(Y2),
9654 nb_setval('$chr_store_multi_hash_chr_translate____rule___2-1', Y2),
9655 nb_setval('$chr_store_global_ground_chr_translate____rule___2', []),
9656 new_ht(Z2),
9657 nb_setval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
9658 Z2),
9659 new_ht(A3),
9660 nb_setval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
9661 A3),
9662 new_ht(B3),
9663 nb_setval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
9664 B3),
9665 new_ht(C3),
9666 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
9667 C3),
9668 new_ht(D3),
9669 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
9670 D3),
9671 new_ht(E3),
9672 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
9673 E3),
9674 new_ht(F3),
9675 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
9676 F3),
9677 new_ht(G3),
9678 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
9679 G3),
9680 new_ht(H3),
9681 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
9682 H3),
9683 new_ht(I3),
9684 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
9685 I3),
9686 nb_setval('$chr_store_global_ground_chr_translate____occurrence___5', []),
9687 new_ht(J3),
9688 nb_setval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
9689 J3),
9690 new_ht(K3),
9691 nb_setval('$chr_store_multi_hash_chr_translate____passive___2-12',
9692 K3),
9693 new_ht(L3),
9694 nb_setval('$chr_store_multi_hash_chr_translate____passive___2-1',
9695 L3),
9696 nb_setval('$chr_store_global_ground_chr_translate____rule_count___1', []),
9697 new_ht(M3),
9698 nb_setval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
9699 M3),
9700 new_ht(N3),
9701 nb_setval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
9702 N3),
9703 new_ht(O3),
9704 nb_setval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
9705 O3),
9706 new_ht(P3),
9707 nb_setval('$chr_store_multi_hash_chr_translate____store_type___2-1',
9708 P3),
9709 nb_setval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',
9710 []),
9711 new_ht(Q3),
9712 nb_setval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
9713 Q3),
9714 nb_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',
9715 []),
9716 new_ht(R3),
9717 nb_setval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',
9718 R3),
9719 new_ht(S3),
9720 nb_setval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',
9721 S3),
9722 new_ht(T3),
9723 nb_setval('$chr_store_multi_hash_chr_translate____line_number___2-1',
9724 T3),
9725 nb_setval('$chr_store_global_ground_chr_translate____target_module___1',
9726 []),
9727 nb_setval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9728 []).
9729:- (initialization'$chr_initialization'). 9730:- (dynamic user:exception/3). 9731:- (multifile user:exception/3). 9732user:exception(undefined_global_variable, A, retry) :-
9733 '$chr_prolog_global_variable'(A),
9734 '$chr_initialization'.
9735'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____print_chr_constants___0').
9736'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____chr_constants___1').
9737'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12').
9738'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12').
9739'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12').
9740'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12').
9741'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____never_stored_rules___2').
9742'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____never_stored_default___2-1').
9743'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored_assertion___1-1').
9744'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____used_states_known___0').
9745'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____if_used_state___5-12').
9746'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____if_used_state___5').
9747'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____uses_state___2-12').
9748'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____does_use_field___2-12').
9749'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____does_use_history___2-12').
9750'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____does_use_history___2-1').
9751'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1').
9752'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____phase_end___1-1').
9753'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1').
9754'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____partial_wake_analysis___0').
9755'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2').
9756'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1').
9757'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12').
9758'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12').
9759'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0').
9760'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_as___3-2').
9761'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_as___3-3').
9762'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12').
9763'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12').
9764'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2').
9765'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12').
9766'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____ai_observed_internal___2').
9767'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2').
9768'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3').
9769'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2').
9770'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on___2-2').
9771'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____depends_on___2-1').
9772'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____abstract_constraints___1').
9773'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1').
9774'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____call_pattern___1-1').
9775'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1').
9776'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____functional_dependency___4-12').
9777'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____functional_dependency___4-1').
9778'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1').
9779'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12').
9780'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1').
9781'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1').
9782'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1').
9783'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____constraints_code1___3').
9784'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____check_all_passive___2-1').
9785'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____check_all_passive___2-12').
9786'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored_complete___3-1').
9787'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored_complete___3-13').
9788'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored___3-123').
9789'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____stored___3-13').
9790'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____atomic_type___1').
9791'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1').
9792'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____dynamic_type_check___0').
9793'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13').
9794'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1').
9795'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____ast_static_type_check_var___4').
9796'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____static_type_check___2').
9797'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____types_modes_condition___3').
9798'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____unalias_type___2').
9799'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_type___2-1').
9800'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____constraint_type___2').
9801'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____type_alias___2').
9802'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____type_definition___2').
9803'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1').
9804'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1').
9805'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____precompute_head_matchings___0').
9806'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____set_all_passive___1-1').
9807'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1').
9808'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____prev_guard_list___6').
9809'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____get_bg_info_answer___1').
9810'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____get_bg_info___2').
9811'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____background_info___2').
9812'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____background_info___1').
9813'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1').
9814'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____prolog_global_variable___1').
9815'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____fresh_symbol___2').
9816'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____symbol_count___2').
9817'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12').
9818'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1').
9819'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12').
9820'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1').
9821'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12').
9822'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____module_initializer___1').
9823'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____find_empty_named_histories___0').
9824'$chr_prolog_global_variable'('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1').
9825'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2').
9826'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0').
9827'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12').
9828'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1').
9829'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____spawns_all_triggers___2').
9830'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all___2-12').
9831'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns_all___2-1').
9832'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-123').
9833'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-3').
9834'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-1').
9835'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-12').
9836'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____spawns___3').
9837'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____spawns___3-13').
9838'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____observation_analysis___1').
9839'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____indexing_spec___2-1').
9840'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____history___3-1').
9841'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____history___3-2').
9842'$chr_prolog_global_variable'('$chr_store_constants_chr_translate____history___3___[3]___[]').
9843'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____no_history___1-1').
9844'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23').
9845'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123').
9846'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1').
9847'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____identifier_index___3-12').
9848'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____identifier_size___1').
9849'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____max_constraint_index___1').
9850'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_index___2-1').
9851'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_index___2-2').
9852'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____least_occurrence___2-1').
9853'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____least_occurrence___2-12').
9854'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____rule___2-1').
9855'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____rule___2').
9856'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12').
9857'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1').
9858'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____max_occurrence___2-1').
9859'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-1').
9860'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-34').
9861'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-13').
9862'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-3').
9863'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-12').
9864'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-134').
9865'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-125').
9866'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____occurrence___5').
9867'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____occurrence___5-15').
9868'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____passive___2-12').
9869'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____passive___2-1').
9870'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____rule_count___1').
9871'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1').
9872'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1').
9873'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____actual_store_types___2-1').
9874'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____store_type___2-1').
9875'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0').
9876'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____constraint_mode___2-1').
9877'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____constraint_mode___2').
9878'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____indexed_argument___2-12').
9879'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____indexed_argument___2-1').
9880'$chr_prolog_global_variable'('$chr_store_multi_hash_chr_translate____line_number___2-1').
9881'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____target_module___1').
9882'$chr_prolog_global_variable'('$chr_store_global_ground_chr_translate____chr_source_file___1').
9883chr_source_file(C) :-
9884 nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9885 A),
9886 ( member(B, A),
9887 B=suspension(_, active, _, _), !
9888 ; !,
9889 chr_source_file___1__0__0__2(A, C)
9890 ).
9891chr_source_file___1__0__0__2([], A) :-
9892 chr_source_file___1__1(A).
9893chr_source_file___1__0__0__2([A|F], G) :-
9894 ( A=suspension(_, active, _, _)
9895 -> ( setarg(2, A, removed),
9896 arg(3, A, B),
9897 ( var(B)
9898 -> nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9899 C),
9900 C=[_|D],
9901 b_setval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9902 D),
9903 ( D=[E|_]
9904 -> setarg(3, E, _)
9905 ; true
9906 )
9907 ; B=[_, _|D],
9908 setarg(2, B, D),
9909 ( D=[E|_]
9910 -> setarg(3, E, B)
9911 ; true
9912 )
9913 )
9914 ),
9915 chr_source_file___1__0__0__2(F, G)
9916 ; chr_source_file___1__0__0__2(F, G)
9917 ).
9918chr_source_file(A) :-
9919 chr_source_file___1__1(A).
9920chr_source_file___1__1(A) :-
9921 C=suspension(B, active, _, A),
9922 'chr gen_id'(B),
9923 nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9924 D),
9925 E=[C|D],
9926 b_setval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9927 E),
9928 ( D=[F|_]
9929 -> setarg(3, F, E)
9930 ; true
9931 ).
9932get_chr_source_file(C) :-
9933 nb_getval('$chr_store_global_ground_chr_translate____chr_source_file___1',
9934 A),
9935 member(B, A),
9936 B=suspension(_, active, _, D), !,
9937 C=D.
9938get_chr_source_file(user).
9939target_module(C) :-
9940 nb_getval('$chr_store_global_ground_chr_translate____target_module___1',
9941 A),
9942 ( member(B, A),
9943 B=suspension(_, active, _, _), !
9944 ; !,
9945 target_module___1__0__0__2(A, C)
9946 ).
9947target_module___1__0__0__2([], A) :-
9948 target_module___1__1(A).
9949target_module___1__0__0__2([A|F], G) :-
9950 ( A=suspension(_, active, _, _)
9951 -> ( setarg(2, A, removed),
9952 arg(3, A, B),
9953 ( var(B)
9954 -> nb_getval('$chr_store_global_ground_chr_translate____target_module___1',
9955 C),
9956 C=[_|D],
9957 b_setval('$chr_store_global_ground_chr_translate____target_module___1',
9958 D),
9959 ( D=[E|_]
9960 -> setarg(3, E, _)
9961 ; true
9962 )
9963 ; B=[_, _|D],
9964 setarg(2, B, D),
9965 ( D=[E|_]
9966 -> setarg(3, E, B)
9967 ; true
9968 )
9969 )
9970 ),
9971 target_module___1__0__0__2(F, G)
9972 ; target_module___1__0__0__2(F, G)
9973 ).
9974target_module(A) :-
9975 target_module___1__1(A).
9976target_module___1__1(A) :-
9977 C=suspension(B, active, _, A),
9978 'chr gen_id'(B),
9979 nb_getval('$chr_store_global_ground_chr_translate____target_module___1',
9980 D),
9981 E=[C|D],
9982 b_setval('$chr_store_global_ground_chr_translate____target_module___1',
9983 E),
9984 ( D=[F|_]
9985 -> setarg(3, F, E)
9986 ; true
9987 ).
9988get_target_module(C) :-
9989 nb_getval('$chr_store_global_ground_chr_translate____target_module___1',
9990 A),
9991 member(B, A),
9992 B=suspension(_, active, _, D), !,
9993 C=D.
9994get_target_module(user).
9995line_number(B, E) :-
9996 ( nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',
9997 A),
9998 lookup_ht(A, B, C)
9999 ),
10000 ( member(D, C),
10001 D=suspension(_, active, _, _), !
10002 ; !,
10003 line_number___2__0__0__2(C, B, E)
10004 ).
10005line_number___2__0__0__2([], A, B) :-
10006 line_number___2__1(A, B).
10007line_number___2__0__0__2([A|E], C, F) :-
10008 ( A=suspension(_, active, B, _),
10009 B==C
10010 -> ( setarg(2, A, removed),
10011 nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',
10012 D),
10013 delete_ht(D, C, A)
10014 ),
10015 line_number___2__0__0__2(E, C, F)
10016 ; line_number___2__0__0__2(E, C, F)
10017 ).
10018line_number(A, B) :-
10019 line_number___2__1(A, B).
10020line_number___2__1(A, B) :-
10021 E=suspension(C, active, A, B),
10022 'chr gen_id'(C),
10023 nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',
10024 D),
10025 insert_ht(D, A, E).
10026get_line_number(B, E) :-
10027 nb_getval('$chr_store_multi_hash_chr_translate____line_number___2-1',
10028 A),
10029 lookup_ht(A, B, C),
10030 member(D, C),
10031 D=suspension(_, active, _, F), !,
10032 E=F.
10033get_line_number(_, 0).
10034indexed_argument(B, C) :-
10035 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',
10036 A),
10037 lookup_ht(A, k(B, C), D),
10038 member(E, D),
10039 E=suspension(_, active, _, _), !.
10040indexed_argument(A, B) :-
10041 E=suspension(C, active, A, B),
10042 'chr gen_id'(C),
10043 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',
10044 D),
10045 insert_ht(D, A, E),
10046 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',
10047 F),
10048 insert_ht(F, k(A, B), E).
10049is_indexed_argument(B, C) :-
10050 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-12',
10051 A),
10052 lookup_ht(A, k(B, C), D),
10053 member(E, D),
10054 E=suspension(_, active, _, _), !.
10055is_indexed_argument(_, _) :-
10056 fail.
10057constraint_mode(A, B) :-
10058 constraint_mode___2__0(A, B, _).
10059constraint_mode___2__0(B, E, F) :-
10060 ( nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10061 A),
10062 lookup_ht(A, B, C)
10063 ),
10064 ( member(D, C),
10065 D=suspension(_, active, _, _, _, _), !
10066 ; !,
10067 constraint_mode___2__0__0__2(C, B, E, F)
10068 ).
10069constraint_mode___2__0__0__2([], A, B, C) :-
10070 constraint_mode___2__1(A, B, C).
10071constraint_mode___2__0__0__2([A|I], C, J, K) :-
10072 ( A=suspension(_, active, _, _, B, _),
10073 B==C
10074 -> ( setarg(2, A, removed),
10075 ( arg(4, A, D),
10076 ( var(D)
10077 -> nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10078 E),
10079 E=[_|F],
10080 b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10081 F),
10082 ( F=[G|_]
10083 -> setarg(4, G, _)
10084 ; true
10085 )
10086 ; D=[_, _|F],
10087 setarg(2, D, F),
10088 ( F=[G|_]
10089 -> setarg(4, G, D)
10090 ; true
10091 )
10092 )
10093 ),
10094 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10095 H),
10096 delete_ht(H, C, A)
10097 ),
10098 constraint_mode___2__0__0__2(I, C, J, K)
10099 ; constraint_mode___2__0__0__2(I, C, J, K)
10100 ).
10101constraint_mode___2__0(A, B, C) :-
10102 constraint_mode___2__1(A, B, C).
10103constraint_mode___2__1(A, C, B) :-
10104 A=F/G,
10105 nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
10106 E), !,
10107 B=suspension(D, not_stored_yet, t, _, A, C),
10108 'chr gen_id'(D),
10109 constraint_mode___2__1__0__7(E,
10110 A,
10111 C,
10112 B,
10113 F,
10114 G).
10115constraint_mode___2__1__0__7([], A, B, C, _, _) :-
10116 constraint_mode___2__2(A, B, C).
10117constraint_mode___2__1__0__7([A|C1], Q, S, K, E, F) :-
10118 ( ( A=suspension(_, active, _, B, C, R),
10119 B=[D|Z],
10120 C=[V|A1]
10121 ),
10122 functor(D, E, F)
10123 -> ( setarg(2, A, removed),
10124 arg(3, A, G),
10125 ( var(G)
10126 -> nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
10127 H),
10128 H=[_|I],
10129 b_setval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
10130 I),
10131 ( I=[J|_]
10132 -> setarg(3, J, _)
10133 ; true
10134 )
10135 ; G=[_, _|I],
10136 setarg(2, G, I),
10137 ( I=[J|_]
10138 -> setarg(3, J, G)
10139 ; true
10140 )
10141 )
10142 ),
10143 ( arg(2, K, L),
10144 setarg(2, K, active),
10145 ( L==not_stored_yet
10146 -> ( nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10147 M),
10148 N=[K|M],
10149 b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10150 N),
10151 ( M=[O|_]
10152 -> setarg(4, O, N)
10153 ; true
10154 )
10155 ),
10156 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10157 P),
10158 insert_ht(P, Q, K)
10159 ; true
10160 )
10161 ),
10162 ( D=..[_|T],
10163 R=(U, Y, B1),
10164 modes_condition(S, T, U),
10165 get_constraint_type_det(E/F, W),
10166 V=..[_|X],
10167 types_condition(W, T, X, S, Y),
10168 types_modes_condition(Z, A1, B1)
10169 ),
10170 ( K=suspension(_, active, _, _, _, _)
10171 -> setarg(2, K, inactive),
10172 constraint_mode___2__1__0__7(C1,
10173 Q,
10174 S,
10175 K,
10176 E,
10177 F)
10178 ; true
10179 )
10180 ; constraint_mode___2__1__0__7(C1,
10181 Q,
10182 S,
10183 K,
10184 E,
10185 F)
10186 ).
10187constraint_mode___2__1(B, C, A) :-
10188 A=suspension(D, not_stored_yet, t, _, B, C),
10189 'chr gen_id'(D),
10190 constraint_mode___2__2(B, C, A).
10191constraint_mode___2__2(B, D, E) :-
10192 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
10193 A),
10194 lookup_ht(A, B, C), !,
10195 constraint_mode___2__2__0__8(C, B, D, E).
10196constraint_mode___2__2__0__8([], A, B, C) :-
10197 constraint_mode___2__3(A, B, C).
10198constraint_mode___2__2__0__8([A|H], C, I, J) :-
10199 ( ( A=suspension(_, active, _, _, B, _, E, F, G),
10200 B==C
10201 ),
10202 nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
10203 D)
10204 -> constraint_mode___2__2__1__8(D,
10205 E,
10206 F,
10207 G,
10208 A,
10209 H,
10210 C,
10211 I,
10212 J)
10213 ; constraint_mode___2__2__0__8(H, C, I, J)
10214 ).
10215constraint_mode___2__2__1__8([], _, _, _, _, A, B, C, D) :-
10216 constraint_mode___2__2__0__8(A, B, C, D).
10217constraint_mode___2__2__1__8([A|E], C, F, G, H, I, J, K, L) :-
10218 ( A=suspension(_, active, _, _),
10219 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
10220 B),
10221 lookup_ht(B, C, D)
10222 -> constraint_mode___2__2__2__8(D,
10223 A,
10224 E,
10225 C,
10226 F,
10227 G,
10228 H,
10229 I,
10230 J,
10231 K,
10232 L)
10233 ; constraint_mode___2__2__1__8(E,
10234 C,
10235 F,
10236 G,
10237 H,
10238 I,
10239 J,
10240 K,
10241 L)
10242 ).
10243constraint_mode___2__2__2__8([], _, A, B, C, D, E, F, G, H, I) :-
10244 constraint_mode___2__2__1__8(A,
10245 B,
10246 C,
10247 D,
10248 E,
10249 F,
10250 G,
10251 H,
10252 I).
10253constraint_mode___2__2__2__8([A|X], D, Y, C, O, P, E, Z, M, U, F) :-
10254 ( A=suspension(_, active, _, _, B, N),
10255 B==C,
10256 G=t(330, D, E, A, F),
10257 '$novel_production'(D, G),
10258 '$novel_production'(E, G),
10259 '$novel_production'(A, G),
10260 '$novel_production'(F, G)
10261 -> '$extend_history'(F, G),
10262 ( arg(2, F, H),
10263 setarg(2, F, active),
10264 ( H==not_stored_yet
10265 -> ( nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10266 I),
10267 J=[F|I],
10268 b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10269 J),
10270 ( I=[K|_]
10271 -> setarg(4, K, J)
10272 ; true
10273 )
10274 ),
10275 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10276 L),
10277 insert_ht(L, M, F)
10278 ; true
10279 )
10280 ),
10281 ( N=pragma(rule(Q, W, S, _), _, _, _, _),
10282 ( is_passive(C, O)
10283 -> true
10284 ; P==simplification
10285 -> select(R, Q, _),
10286 R=..[_|T],
10287 term_variables(S, V),
10288 partial_wake_args(T, U, V, M)
10289 ; select(R, W, _),
10290 R=..[_|T],
10291 term_variables(S, V),
10292 partial_wake_args(T, U, V, M)
10293 )
10294 ),
10295 ( F=suspension(_, active, _, _, _, _)
10296 -> setarg(2, F, inactive),
10297 constraint_mode___2__2__2__8(X,
10298 D,
10299 Y,
10300 C,
10301 O,
10302 P,
10303 E,
10304 Z,
10305 M,
10306 U,
10307 F)
10308 ; true
10309 )
10310 ; constraint_mode___2__2__2__8(X,
10311 D,
10312 Y,
10313 C,
10314 O,
10315 P,
10316 E,
10317 Z,
10318 M,
10319 U,
10320 F)
10321 ).
10322constraint_mode___2__2(A, B, C) :-
10323 constraint_mode___2__3(A, B, C).
10324constraint_mode___2__3(G, _, A) :-
10325 arg(2, A, B),
10326 setarg(2, A, active),
10327 ( B==not_stored_yet
10328 -> ( nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10329 C),
10330 D=[A|C],
10331 b_setval('$chr_store_global_ground_chr_translate____constraint_mode___2',
10332 D),
10333 ( C=[E|_]
10334 -> setarg(4, E, D)
10335 ; true
10336 )
10337 ),
10338 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10339 F),
10340 insert_ht(F, G, A)
10341 ; true
10342 ).
10343get_constraint_mode(B, E) :-
10344 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10345 A),
10346 lookup_ht(A, B, C),
10347 member(D, C),
10348 D=suspension(_, active, _, _, _, F), !,
10349 E=F.
10350get_constraint_mode(_/A, B) :-
10351 replicate(A, ?, B).
10352may_trigger(A) :-
10353 \+ has_active_occurrence(A), !,
10354 fail.
10355may_trigger(B) :-
10356 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10357 A),
10358 lookup_ht(A, B, C),
10359 member(D, C),
10360 D=suspension(_, active, _, _, _, I),
10361 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',
10362 E),
10363 lookup_ht(E, B, F),
10364 member(G, F),
10365 G=suspension(_, active, _, H),
10366 nth1(H, I, J),
10367 J\==(+), !,
10368 is_stored(B).
10369may_trigger(_) :-
10370 chr_pp_flag(debugable, on).
10371only_ground_indexed_arguments(B) :-
10372 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
10373 A),
10374 lookup_ht(A, B, C),
10375 member(D, C),
10376 D=suspension(_, active, _, _, _, I),
10377 nb_getval('$chr_store_multi_hash_chr_translate____indexed_argument___2-1',
10378 E),
10379 lookup_ht(E, B, F),
10380 member(G, F),
10381 G=suspension(_, active, _, H),
10382 nth1(H, I, J),
10383 J\==(+), !,
10384 fail.
10385only_ground_indexed_arguments(_).
10386none_suspended_on_variables :-
10387 nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',
10388 A),
10389 member(B, A),
10390 B=suspension(_, active, _), !.
10391none_suspended_on_variables :-
10392 B=suspension(A, active, _),
10393 'chr gen_id'(A),
10394 nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',
10395 C),
10396 D=[B|C],
10397 b_setval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',
10398 D),
10399 ( C=[E|_]
10400 -> setarg(3, E, D)
10401 ; true
10402 ).
10403are_none_suspended_on_variables :-
10404 nb_getval('$chr_store_global_ground_chr_translate____none_suspended_on_variables___0',
10405 A),
10406 member(B, A),
10407 B=suspension(_, active, _), !.
10408are_none_suspended_on_variables :-
10409 fail.
10410store_type(A, B) :-
10411 store_type___2__0(A, B, _).
10412store_type___2__0(B, C, A) :-
10413 chr_pp_flag(verbose, on), !,
10414 A=suspension(D, active, B, C),
10415 'chr gen_id'(D),
10416 nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10417 E),
10418 insert_ht(E, B, A),
10419 format('The indexes for ~w are:\n', [B]),
10420 format_storetype(C),
10421 ( A=suspension(_, active, _, _)
10422 -> setarg(2, A, inactive),
10423 store_type___2__1(B, C, A)
10424 ; true
10425 ).
10426store_type___2__0(B, C, A) :-
10427 A=suspension(D, not_stored_yet, B, C),
10428 'chr gen_id'(D),
10429 store_type___2__1(B, C, A).
10430store_type___2__1(B, _, J) :-
10431 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10432 A),
10433 lookup_ht(A, B, C),
10434 member(D, C),
10435 D=suspension(_, active, _),
10436 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10437 E),
10438 lookup_ht(E, B, F),
10439 member(G, F),
10440 G=suspension(_, active, _, M), !,
10441 setarg(2, D, removed),
10442 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10443 H),
10444 delete_ht(H, B, D),
10445 setarg(2, G, removed),
10446 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10447 I),
10448 delete_ht(I, B, G),
10449 ( var(J)
10450 -> true
10451 ; arg(2, J, K),
10452 setarg(2, J, removed),
10453 ( K==not_stored_yet
10454 -> true
10455 ; nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10456 L),
10457 delete_ht(L, B, J)
10458 )
10459 ),
10460 store_type(B, multi_store(M)).
10461store_type___2__1(D, _, A) :-
10462 arg(2, A, B),
10463 setarg(2, A, active),
10464 ( B==not_stored_yet
10465 -> nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10466 C),
10467 insert_ht(C, D, A)
10468 ; true
10469 ).
10470get_store_type(B, E) :-
10471 nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10472 A),
10473 lookup_ht(A, B, C),
10474 member(D, C),
10475 D=suspension(_, active, _, F), !,
10476 E=F.
10477get_store_type(B, E) :-
10478 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10479 A),
10480 lookup_ht(A, B, C),
10481 member(D, C),
10482 D=suspension(_, active, _, F), !,
10483 E=F.
10484get_store_type(_, default).
10485update_store_type(B, E) :-
10486 ( nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10487 A),
10488 lookup_ht(A, B, C),
10489 member(D, C),
10490 D=suspension(_, active, _, F)
10491 ),
10492 ( memberchk(E, F), !
10493 ; !,
10494 setarg(2, D, removed),
10495 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10496 G),
10497 delete_ht(G, B, D),
10498 actual_store_types(B, [E|F])
10499 ).
10500update_store_type(A, B) :-
10501 actual_store_types(A, [B]).
10502actual_store_types(B, K) :-
10503 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
10504 A),
10505 lookup_ht(A, B, C),
10506 member(D, C),
10507 D=suspension(_, active, _, I, P),
10508 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10509 E),
10510 lookup_ht(E, B, F),
10511 member(G, F),
10512 G=suspension(_, active, _), !,
10513 setarg(2, D, removed),
10514 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
10515 H),
10516 delete_ht(H, k(B, I), D),
10517 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
10518 J),
10519 delete_ht(J, B, D),
10520 selectchk(multi_hash([I]), K, R),
10521 I=[L],
10522 ( get_constraint_arg_type(B, L, M),
10523 enumerated_atomic_type(M, N)
10524 -> O=N,
10525 Q=complete
10526 ; O=P,
10527 Q=incomplete
10528 ),
10529 actual_store_types(B,
10530
10531 [ atomic_constants(I, O, Q)
10532 | R
10533 ]).
10534actual_store_types(B, P) :-
10535 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
10536 A),
10537 lookup_ht(A, B, C),
10538 member(D, C),
10539 D=suspension(_, active, _, I, N),
10540 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10541 E),
10542 lookup_ht(E, B, F),
10543 member(G, F),
10544 G=suspension(_, active, _), !,
10545 setarg(2, D, removed),
10546 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
10547 H),
10548 delete_ht(H, k(B, I), D),
10549 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
10550 J),
10551 delete_ht(J, B, D),
10552 ( I=[K],
10553 get_constraint_arg_type(B, K, L),
10554 L=chr_enum(M)
10555 -> O=complete
10556 ; M=N,
10557 O=incomplete
10558 ),
10559 selectchk(multi_hash([I]), P, Q),
10560 actual_store_types(B,
10561
10562 [ ground_constants(I, M, O)
10563 | Q
10564 ]).
10565actual_store_types(B, E) :-
10566 ( nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10567 A),
10568 lookup_ht(A, B, C),
10569 member(D, C),
10570 D=suspension(_, active, _)
10571 ),
10572 ( ( memberchk(multi_hash([[F]]), E),
10573 ( get_constraint_type(B, G),
10574 nth1(F, G, H),
10575 enumerated_atomic_type(H, I), !,
10576 selectchk(multi_hash([[F]]), E, J),
10577 actual_store_types(B,
10578
10579 [ atomic_constants([F],
10580 I,
10581 complete)
10582 | J
10583 ])
10584 ; get_constraint_arg_type(B, F, K),
10585 K=chr_enum(L), !,
10586 selectchk(multi_hash([[F]]), E, M),
10587 actual_store_types(B,
10588
10589 [ ground_constants([F],
10590 L,
10591 complete)
10592 | M
10593 ])
10594 )
10595 ; nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10596 N),
10597 lookup_ht(N, B, O),
10598 member(P, O),
10599 P=suspension(_, active, _, _), !,
10600 setarg(2, D, removed),
10601 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10602 Q),
10603 delete_ht(Q, B, D),
10604 setarg(2, P, removed),
10605 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10606 R),
10607 delete_ht(R, B, P),
10608 ( maplist(partial_store, E)
10609 -> S=[global_ground|E]
10610 ; S=E
10611 ),
10612 store_type(B, multi_store(S))
10613 )
10614 ; nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10615 T),
10616 lookup_ht(T, B, U),
10617 member(V, U),
10618 V=suspension(_, active, _, _), !,
10619 setarg(2, D, removed),
10620 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10621 W),
10622 delete_ht(W, B, D),
10623 setarg(2, V, removed),
10624 nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10625 X),
10626 delete_ht(X, B, V),
10627 store_type(B, multi_store(E))
10628 ).
10629actual_store_types(A, B) :-
10630 E=suspension(C, active, A, B),
10631 'chr gen_id'(C),
10632 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10633 D),
10634 insert_ht(D, A, E).
10635assumed_store_type(B, _) :-
10636 ( nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10637 A),
10638 lookup_ht(A, B, C),
10639 member(D, C),
10640 D=suspension(_, active, _)
10641 ),
10642 ( ( nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10643 E),
10644 lookup_ht(E, B, F),
10645 member(G, F),
10646 G=suspension(_, active, _, J), !,
10647 setarg(2, D, removed),
10648 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10649 H),
10650 delete_ht(H, B, D),
10651 setarg(2, G, removed),
10652 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10653 I),
10654 delete_ht(I, B, G),
10655 ( maplist(partial_store, J)
10656 -> K=[global_ground|J]
10657 ; K=J
10658 ),
10659 store_type(B, multi_store(K))
10660 ; chr_pp_flag(debugable, on), !,
10661 setarg(2, D, removed),
10662 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10663 L),
10664 delete_ht(L, B, D),
10665 store_type(B, default)
10666 )
10667 ; !,
10668 setarg(2, D, removed),
10669 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10670 M),
10671 delete_ht(M, B, D),
10672 store_type(B, global_ground)
10673 ).
10674assumed_store_type(A, B) :-
10675 E=suspension(C, active, A, B),
10676 'chr gen_id'(C),
10677 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10678 D),
10679 insert_ht(D, A, E).
10680validate_store_type_assumption(A) :-
10681 validate_store_type_assumption___1__0(A, _).
10682validate_store_type_assumption___1__0(B, C) :-
10683 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10684 A),
10685 lookup_ht(A, B, E), !,
10686 C=suspension(D, not_stored_yet, B),
10687 'chr gen_id'(D),
10688 validate_store_type_assumption___1__0__0__1(E, B, C).
10689validate_store_type_assumption___1__0__0__1([], A, B) :-
10690 validate_store_type_assumption___1__1(A, B).
10691validate_store_type_assumption___1__0__0__1([A|V], C, K) :-
10692 ( ( A=suspension(_, active, B, N),
10693 B==C
10694 ),
10695 ( ground(C),
10696 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
10697 D),
10698 lookup_ht(D, C, E)
10699 ),
10700 member(F, E),
10701 F=suspension(_, active, _, I, S)
10702 -> ( ( setarg(2, A, removed),
10703 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10704 G),
10705 delete_ht(G, C, A)
10706 ),
10707 setarg(2, F, removed),
10708 ( nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
10709 H),
10710 delete_ht(H, k(C, I), F)
10711 ),
10712 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
10713 J),
10714 delete_ht(J, C, F)
10715 ),
10716 ( arg(2, K, L),
10717 setarg(2, K, active),
10718 ( L==not_stored_yet
10719 -> nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10720 M),
10721 insert_ht(M, C, K)
10722 ; true
10723 )
10724 ),
10725 ( selectchk(multi_hash([I]), N, U),
10726 I=[O],
10727 ( get_constraint_arg_type(C, O, P),
10728 enumerated_atomic_type(P, Q)
10729 -> R=Q,
10730 T=complete
10731 ; R=S,
10732 T=incomplete
10733 ),
10734 actual_store_types(C,
10735
10736 [ atomic_constants(I, R, T)
10737 | U
10738 ])
10739 ),
10740 ( K=suspension(_, active, _)
10741 -> setarg(2, K, inactive),
10742 validate_store_type_assumption___1__0__0__1(V,
10743 C,
10744 K)
10745 ; true
10746 )
10747 ; validate_store_type_assumption___1__0__0__1(V,
10748 C,
10749 K)
10750 ).
10751validate_store_type_assumption___1__0(B, A) :-
10752 A=suspension(C, not_stored_yet, B),
10753 'chr gen_id'(C),
10754 validate_store_type_assumption___1__1(B, A).
10755validate_store_type_assumption___1__1(B, D) :-
10756 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10757 A),
10758 lookup_ht(A, B, C), !,
10759 validate_store_type_assumption___1__1__0__2(C, B, D).
10760validate_store_type_assumption___1__1__0__2([], A, B) :-
10761 validate_store_type_assumption___1__2(A, B).
10762validate_store_type_assumption___1__1__0__2([A|U], C, K) :-
10763 ( ( A=suspension(_, active, B, S),
10764 B==C
10765 ),
10766 ( ground(C),
10767 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
10768 D),
10769 lookup_ht(D, C, E)
10770 ),
10771 member(F, E),
10772 F=suspension(_, active, _, I, Q)
10773 -> ( ( setarg(2, A, removed),
10774 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10775 G),
10776 delete_ht(G, C, A)
10777 ),
10778 setarg(2, F, removed),
10779 ( nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
10780 H),
10781 delete_ht(H, k(C, I), F)
10782 ),
10783 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
10784 J),
10785 delete_ht(J, C, F)
10786 ),
10787 ( arg(2, K, L),
10788 setarg(2, K, active),
10789 ( L==not_stored_yet
10790 -> nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10791 M),
10792 insert_ht(M, C, K)
10793 ; true
10794 )
10795 ),
10796 ( ( I=[N],
10797 get_constraint_arg_type(C, N, O),
10798 O=chr_enum(P)
10799 -> R=complete
10800 ; P=Q,
10801 R=incomplete
10802 ),
10803 selectchk(multi_hash([I]), S, T),
10804 actual_store_types(C,
10805
10806 [ ground_constants(I, P, R)
10807 | T
10808 ])
10809 ),
10810 ( K=suspension(_, active, _)
10811 -> setarg(2, K, inactive),
10812 validate_store_type_assumption___1__1__0__2(U,
10813 C,
10814 K)
10815 ; true
10816 )
10817 ; validate_store_type_assumption___1__1__0__2(U,
10818 C,
10819 K)
10820 ).
10821validate_store_type_assumption___1__1(A, B) :-
10822 validate_store_type_assumption___1__2(A, B).
10823validate_store_type_assumption___1__2(B, D) :-
10824 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10825 A),
10826 lookup_ht(A, B, C), !,
10827 validate_store_type_assumption___1__2__0__3(C, B, D).
10828validate_store_type_assumption___1__2__0__3([], A, B) :-
10829 validate_store_type_assumption___1__3(A, B).
10830validate_store_type_assumption___1__2__0__3([A|N], C, I) :-
10831 ( ( A=suspension(_, active, B, D),
10832 B==C
10833 ),
10834 memberchk(multi_hash([[E]]), D),
10835 get_constraint_type(C, F),
10836 nth1(E, F, G),
10837 enumerated_atomic_type(G, L)
10838 -> ( setarg(2, A, removed),
10839 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10840 H),
10841 delete_ht(H, C, A)
10842 ),
10843 ( arg(2, I, J),
10844 setarg(2, I, active),
10845 ( J==not_stored_yet
10846 -> nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10847 K),
10848 insert_ht(K, C, I)
10849 ; true
10850 )
10851 ),
10852 ( selectchk(multi_hash([[E]]), D, M),
10853 actual_store_types(C,
10854
10855 [ atomic_constants([E],
10856 L,
10857 complete)
10858 | M
10859 ])
10860 ),
10861 ( I=suspension(_, active, _)
10862 -> setarg(2, I, inactive),
10863 validate_store_type_assumption___1__2__0__3(N,
10864 C,
10865 I)
10866 ; true
10867 )
10868 ; validate_store_type_assumption___1__2__0__3(N,
10869 C,
10870 I)
10871 ).
10872validate_store_type_assumption___1__2(A, B) :-
10873 validate_store_type_assumption___1__3(A, B).
10874validate_store_type_assumption___1__3(B, D) :-
10875 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10876 A),
10877 lookup_ht(A, B, C), !,
10878 validate_store_type_assumption___1__3__0__4(C, B, D).
10879validate_store_type_assumption___1__3__0__4([], A, B) :-
10880 validate_store_type_assumption___1__4(A, B).
10881validate_store_type_assumption___1__3__0__4([A|M], C, H) :-
10882 ( ( A=suspension(_, active, B, D),
10883 B==C
10884 ),
10885 memberchk(multi_hash([[E]]), D),
10886 get_constraint_arg_type(C, E, F),
10887 F=chr_enum(K)
10888 -> ( setarg(2, A, removed),
10889 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10890 G),
10891 delete_ht(G, C, A)
10892 ),
10893 ( arg(2, H, I),
10894 setarg(2, H, active),
10895 ( I==not_stored_yet
10896 -> nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10897 J),
10898 insert_ht(J, C, H)
10899 ; true
10900 )
10901 ),
10902 ( selectchk(multi_hash([[E]]), D, L),
10903 actual_store_types(C,
10904
10905 [ ground_constants([E],
10906 K,
10907 complete)
10908 | L
10909 ])
10910 ),
10911 ( H=suspension(_, active, _)
10912 -> setarg(2, H, inactive),
10913 validate_store_type_assumption___1__3__0__4(M,
10914 C,
10915 H)
10916 ; true
10917 )
10918 ; validate_store_type_assumption___1__3__0__4(M,
10919 C,
10920 H)
10921 ).
10922validate_store_type_assumption___1__3(A, B) :-
10923 validate_store_type_assumption___1__4(A, B).
10924validate_store_type_assumption___1__4(B, J) :-
10925 ( nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10926 A),
10927 lookup_ht(A, B, C),
10928 member(D, C),
10929 D=suspension(_, active, _, M)
10930 ),
10931 ( nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10932 E),
10933 lookup_ht(E, B, F),
10934 member(G, F),
10935 G=suspension(_, active, _, _), !,
10936 setarg(2, D, removed),
10937 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10938 H),
10939 delete_ht(H, B, D),
10940 setarg(2, G, removed),
10941 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10942 I),
10943 delete_ht(I, B, G),
10944 ( var(J)
10945 -> true
10946 ; arg(2, J, K),
10947 setarg(2, J, removed),
10948 ( K==not_stored_yet
10949 -> true
10950 ; nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10951 L),
10952 delete_ht(L, B, J)
10953 )
10954 ),
10955 ( maplist(partial_store, M)
10956 -> N=[global_ground|M]
10957 ; N=M
10958 ),
10959 store_type(B, multi_store(N))
10960 ; nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10961 O),
10962 lookup_ht(O, B, P),
10963 member(Q, P),
10964 Q=suspension(_, active, _, _), !,
10965 setarg(2, D, removed),
10966 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
10967 R),
10968 delete_ht(R, B, D),
10969 setarg(2, Q, removed),
10970 nb_getval('$chr_store_multi_hash_chr_translate____store_type___2-1',
10971 S),
10972 delete_ht(S, B, Q),
10973 ( var(J)
10974 -> true
10975 ; arg(2, J, T),
10976 setarg(2, J, removed),
10977 ( T==not_stored_yet
10978 -> true
10979 ; nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
10980 U),
10981 delete_ht(U, B, J)
10982 )
10983 ),
10984 store_type(B, multi_store(M))
10985 ).
10986validate_store_type_assumption___1__4(B, F) :-
10987 ( nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10988 A),
10989 lookup_ht(A, B, C),
10990 member(D, C),
10991 D=suspension(_, active, _, _)
10992 ),
10993 ( chr_pp_flag(debugable, on), !,
10994 setarg(2, D, removed),
10995 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
10996 E),
10997 delete_ht(E, B, D),
10998 ( var(F)
10999 -> true
11000 ; arg(2, F, G),
11001 setarg(2, F, removed),
11002 ( G==not_stored_yet
11003 -> true
11004 ; nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
11005 H),
11006 delete_ht(H, B, F)
11007 )
11008 ),
11009 store_type(B, default)
11010 ; !,
11011 setarg(2, D, removed),
11012 nb_getval('$chr_store_multi_hash_chr_translate____assumed_store_type___2-1',
11013 I),
11014 delete_ht(I, B, D),
11015 ( var(F)
11016 -> true
11017 ; arg(2, F, J),
11018 setarg(2, F, removed),
11019 ( J==not_stored_yet
11020 -> true
11021 ; nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
11022 K),
11023 delete_ht(K, B, F)
11024 )
11025 ),
11026 store_type(B, global_ground)
11027 ).
11028validate_store_type_assumption___1__4(D, A) :-
11029 ( var(A)
11030 -> true
11031 ; arg(2, A, B),
11032 setarg(2, A, removed),
11033 ( B==not_stored_yet
11034 -> true
11035 ; nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
11036 C),
11037 delete_ht(C, D, A)
11038 )
11039 ).
11040rule_count(C) :-
11041 nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',
11042 A),
11043 ( member(B, A),
11044 B=suspension(_, active, _, _), !
11045 ; !,
11046 rule_count___1__0__0__2(A, C)
11047 ).
11048rule_count___1__0__0__2([], A) :-
11049 rule_count___1__1(A).
11050rule_count___1__0__0__2([A|F], G) :-
11051 ( A=suspension(_, active, _, _)
11052 -> ( setarg(2, A, removed),
11053 arg(3, A, B),
11054 ( var(B)
11055 -> nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',
11056 C),
11057 C=[_|D],
11058 b_setval('$chr_store_global_ground_chr_translate____rule_count___1',
11059 D),
11060 ( D=[E|_]
11061 -> setarg(3, E, _)
11062 ; true
11063 )
11064 ; B=[_, _|D],
11065 setarg(2, B, D),
11066 ( D=[E|_]
11067 -> setarg(3, E, B)
11068 ; true
11069 )
11070 )
11071 ),
11072 rule_count___1__0__0__2(F, G)
11073 ; rule_count___1__0__0__2(F, G)
11074 ).
11075rule_count(A) :-
11076 rule_count___1__1(A).
11077rule_count___1__1(A) :-
11078 C=suspension(B, active, _, A),
11079 'chr gen_id'(B),
11080 nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',
11081 D),
11082 E=[C|D],
11083 b_setval('$chr_store_global_ground_chr_translate____rule_count___1',
11084 E),
11085 ( D=[F|_]
11086 -> setarg(3, F, E)
11087 ; true
11088 ).
11089inc_rule_count(G) :-
11090 nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',
11091 A),
11092 member(B, A),
11093 B=suspension(_, active, _, H), !,
11094 setarg(2, B, removed),
11095 arg(3, B, C),
11096 ( var(C)
11097 -> nb_getval('$chr_store_global_ground_chr_translate____rule_count___1',
11098 D),
11099 D=[_|E],
11100 b_setval('$chr_store_global_ground_chr_translate____rule_count___1',
11101 E),
11102 ( E=[F|_]
11103 -> setarg(3, F, _)
11104 ; true
11105 )
11106 ; C=[_, _|E],
11107 setarg(2, C, E),
11108 ( E=[F|_]
11109 -> setarg(3, F, C)
11110 ; true
11111 )
11112 ),
11113 G is H+1,
11114 rule_count(G).
11115inc_rule_count(1) :-
11116 rule_count(1).
11117passive(A, B) :-
11118 passive___2__0(A, B, _).
11119passive___2__0(B, C, _) :-
11120 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11121 A),
11122 lookup_ht(A, k(B, C), D),
11123 member(E, D),
11124 E=suspension(_, active, _, _, _), !.
11125passive___2__0(B, D, C) :-
11126 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
11127 A),
11128 lookup_ht(A, B, F), !,
11129 C=suspension(E, not_stored_yet, t, B, D),
11130 'chr gen_id'(E),
11131 passive___2__0__0__6(F, B, D, C).
11132passive___2__0__0__6([], A, B, C) :-
11133 passive___2__1(A, B, C).
11134passive___2__0__0__6([A|Q], C, F, M) :-
11135 ( ( A=suspension(_, active, B, D),
11136 B==C,
11137 D=[E|K],
11138 E==F
11139 ),
11140 ( ground(C),
11141 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
11142 G),
11143 lookup_ht(G, C, H)
11144 ),
11145 member(I, H),
11146 I=suspension(_, active, _, _, _, _)
11147 -> ( setarg(2, A, removed),
11148 ( nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
11149 J),
11150 delete_ht(J, k(C, [F|K]), A)
11151 ),
11152 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
11153 L),
11154 delete_ht(L, C, A)
11155 ),
11156 ( arg(2, M, N),
11157 setarg(2, M, active),
11158 ( N==not_stored_yet
11159 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11160 O),
11161 insert_ht(O, C, M)
11162 ),
11163 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11164 P),
11165 insert_ht(P, k(C, F), M)
11166 ; true
11167 )
11168 ),
11169 least_occurrence(C, K),
11170 ( M=suspension(_, active, _, _, _)
11171 -> setarg(2, M, inactive),
11172 passive___2__0__0__6(Q, C, F, M)
11173 ; true
11174 )
11175 ; passive___2__0__0__6(Q, C, F, M)
11176 ).
11177passive___2__0(B, C, A) :-
11178 A=suspension(D, not_stored_yet, t, B, C),
11179 'chr gen_id'(D),
11180 passive___2__1(B, C, A).
11181passive___2__1(B, C, E) :-
11182 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
11183 A),
11184 lookup_ht(A, k(B, C), D), !,
11185 passive___2__1__0__8(D, B, C, E).
11186passive___2__1__0__8([], A, B, C) :-
11187 passive___2__2(A, B, C).
11188passive___2__1__0__8([A|J], C, E, K) :-
11189 ( ( A=suspension(_, active, _, _, G, I, B, D, _),
11190 B==C,
11191 D==E
11192 ),
11193 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
11194 F),
11195 lookup_ht(F, G, H)
11196 -> passive___2__1__1__8(H,
11197 G,
11198 I,
11199 A,
11200 J,
11201 C,
11202 E,
11203 K)
11204 ; passive___2__1__0__8(J, C, E, K)
11205 ).
11206passive___2__1__1__8([], _, _, _, A, B, C, D) :-
11207 passive___2__1__0__8(A, B, C, D).
11208passive___2__1__1__8([A|U], C, D, V, W, Q, S, N) :-
11209 ( ( A=suspension(_, active, _, B, E, J),
11210 B==C
11211 ),
11212 D<E,
11213 ( ( ground(C),
11214 ground(D)
11215 ),
11216 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
11217 F),
11218 lookup_ht(F, k(C, D, yes), G)
11219 ),
11220 member(H, G),
11221 H=suspension(_, active, _, _, _)
11222 -> ( ( setarg(2, A, removed),
11223 ( nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
11224 I),
11225 delete_ht(I, k(C, J), A)
11226 ),
11227 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
11228 K),
11229 delete_ht(K, C, A)
11230 ),
11231 setarg(2, H, removed),
11232 ( nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
11233 L),
11234 delete_ht(L, k(C, yes), H)
11235 ),
11236 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
11237 M),
11238 delete_ht(M, k(C, D, yes), H)
11239 ),
11240 ( arg(2, N, O),
11241 setarg(2, N, active),
11242 ( O==not_stored_yet
11243 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11244 P),
11245 insert_ht(P, Q, N)
11246 ),
11247 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11248 R),
11249 insert_ht(R, k(Q, S), N)
11250 ; true
11251 )
11252 ),
11253 ( T is J-1,
11254 stored(C, D, maybe),
11255 stored_complete(C, E, T)
11256 ),
11257 ( N=suspension(_, active, _, _, _)
11258 -> setarg(2, N, inactive),
11259 passive___2__1__1__8(U,
11260 C,
11261 D,
11262 V,
11263 W,
11264 Q,
11265 S,
11266 N)
11267 ; true
11268 )
11269 ; passive___2__1__1__8(U,
11270 C,
11271 D,
11272 V,
11273 W,
11274 Q,
11275 S,
11276 N)
11277 ).
11278passive___2__1(A, B, C) :-
11279 passive___2__2(A, B, C).
11280passive___2__2(B, D, E) :-
11281 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
11282 lookup_ht(A, B, C), !,
11283 passive___2__2__0__9(C, B, D, E).
11284passive___2__2__0__9([], A, B, C) :-
11285 passive___2__3(A, B, C).
11286passive___2__2__0__9([A|N], C, G, D) :-
11287 ( A=suspension(_, active, _, _, B, F),
11288 B==C,
11289 ( E=t(251, A, D),
11290 '$novel_production'(A, E),
11291 '$novel_production'(D, E)
11292 ),
11293 F=pragma(rule(_, _, _, _), ids([G|K], L), _, _, C)
11294 -> '$extend_history'(D, E),
11295 ( arg(2, D, H),
11296 setarg(2, D, active),
11297 ( H==not_stored_yet
11298 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11299 I),
11300 insert_ht(I, C, D)
11301 ),
11302 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11303 J),
11304 insert_ht(J, k(C, G), D)
11305 ; true
11306 )
11307 ),
11308 ( append(K, L, M),
11309 check_all_passive(C, M)
11310 ),
11311 ( D=suspension(_, active, _, _, _)
11312 -> setarg(2, D, inactive),
11313 passive___2__2__0__9(N, C, G, D)
11314 ; true
11315 )
11316 ; passive___2__2__0__9(N, C, G, D)
11317 ).
11318passive___2__2(A, B, C) :-
11319 passive___2__3(A, B, C).
11320passive___2__3(B, D, E) :-
11321 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
11322 lookup_ht(A, B, C), !,
11323 passive___2__3__0__10(C, B, D, E).
11324passive___2__3__0__10([], A, B, C) :-
11325 passive___2__4(A, B, C).
11326passive___2__3__0__10([A|L], C, G, D) :-
11327 ( A=suspension(_, active, _, _, B, F),
11328 B==C,
11329 ( E=t(252, A, D),
11330 '$novel_production'(A, E),
11331 '$novel_production'(D, E)
11332 ),
11333 F=pragma(rule(_, _, _, _), ids([], [G|K]), _, _, C)
11334 -> '$extend_history'(D, E),
11335 ( arg(2, D, H),
11336 setarg(2, D, active),
11337 ( H==not_stored_yet
11338 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11339 I),
11340 insert_ht(I, C, D)
11341 ),
11342 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11343 J),
11344 insert_ht(J, k(C, G), D)
11345 ; true
11346 )
11347 ),
11348 check_all_passive(C, K),
11349 ( D=suspension(_, active, _, _, _)
11350 -> setarg(2, D, inactive),
11351 passive___2__3__0__10(L, C, G, D)
11352 ; true
11353 )
11354 ; passive___2__3__0__10(L, C, G, D)
11355 ).
11356passive___2__3(A, B, C) :-
11357 passive___2__4(A, B, C).
11358passive___2__4(B, D, E) :-
11359 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',
11360 A),
11361 lookup_ht(A, B, C), !,
11362 passive___2__4__0__11(C, B, D, E).
11363passive___2__4__0__11([], A, B, C) :-
11364 passive___2__5(A, B, C).
11365passive___2__4__0__11([A|N], C, F, J) :-
11366 ( A=suspension(_, active, B, D),
11367 B==C,
11368 D=[E|H],
11369 E==F
11370 -> ( setarg(2, A, removed),
11371 ( nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
11372 G),
11373 delete_ht(G, k(C, [F|H]), A)
11374 ),
11375 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',
11376 I),
11377 delete_ht(I, C, A)
11378 ),
11379 ( arg(2, J, K),
11380 setarg(2, J, active),
11381 ( K==not_stored_yet
11382 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11383 L),
11384 insert_ht(L, C, J)
11385 ),
11386 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11387 M),
11388 insert_ht(M, k(C, F), J)
11389 ; true
11390 )
11391 ),
11392 check_all_passive(C, H),
11393 ( J=suspension(_, active, _, _, _)
11394 -> setarg(2, J, inactive),
11395 passive___2__4__0__11(N, C, F, J)
11396 ; true
11397 )
11398 ; passive___2__4__0__11(N, C, F, J)
11399 ).
11400passive___2__4(A, B, C) :-
11401 passive___2__5(A, B, C).
11402passive___2__5(B, C, E) :-
11403 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
11404 A),
11405 lookup_ht(A, k(B, C), D), !,
11406 passive___2__5__0__14(D, B, C, E).
11407passive___2__5__0__14([], A, B, C) :-
11408 passive___2__6(A, B, C).
11409passive___2__5__0__14([A|J], C, E, K) :-
11410 ( ( A=suspension(_, active, _, _, G, H, B, D, _),
11411 B==C,
11412 D==E
11413 ),
11414 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
11415 F),
11416 lookup_ht(F, k(G, H), I)
11417 -> passive___2__5__1__14(I,
11418 G,
11419 H,
11420 A,
11421 J,
11422 C,
11423 E,
11424 K)
11425 ; passive___2__5__0__14(J, C, E, K)
11426 ).
11427passive___2__5__1__14([], _, _, _, A, B, C, D) :-
11428 passive___2__5__0__14(A, B, C, D).
11429passive___2__5__1__14([A|O], C, E, F, P, K, M, G) :-
11430 ( A=suspension(_, active, _, B, D),
11431 ( B==C,
11432 D==E
11433 ),
11434 ( H=t(362, F, G, A),
11435 '$novel_production'(F, H),
11436 '$novel_production'(G, H),
11437 '$novel_production'(A, H)
11438 ),
11439 E>1
11440 -> '$extend_history'(G, H),
11441 ( arg(2, G, I),
11442 setarg(2, G, active),
11443 ( I==not_stored_yet
11444 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11445 J),
11446 insert_ht(J, K, G)
11447 ),
11448 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11449 L),
11450 insert_ht(L, k(K, M), G)
11451 ; true
11452 )
11453 ),
11454 ( N is E-1,
11455 skip_to_next_id(C, N)
11456 ),
11457 ( G=suspension(_, active, _, _, _)
11458 -> setarg(2, G, inactive),
11459 passive___2__5__1__14(O,
11460 C,
11461 E,
11462 F,
11463 P,
11464 K,
11465 M,
11466 G)
11467 ; true
11468 )
11469 ; passive___2__5__1__14(O,
11470 C,
11471 E,
11472 F,
11473 P,
11474 K,
11475 M,
11476 G)
11477 ).
11478passive___2__5(A, B, C) :-
11479 passive___2__6(A, B, C).
11480passive___2__6(B, C, E) :-
11481 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
11482 A),
11483 lookup_ht(A, k(B, C), D), !,
11484 passive___2__6__0__15(D, B, C, E).
11485passive___2__6__0__15([], A, B, C) :-
11486 passive___2__7(A, B, C).
11487passive___2__6__0__15([A|J], C, E, K) :-
11488 ( ( A=suspension(_, active, _, _, G, H, B, D, _),
11489 B==C,
11490 D==E
11491 ),
11492 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
11493 F),
11494 lookup_ht(F, k(G, H), I)
11495 -> passive___2__6__1__15(I,
11496 G,
11497 H,
11498 A,
11499 J,
11500 C,
11501 E,
11502 K)
11503 ; passive___2__6__0__15(J, C, E, K)
11504 ).
11505passive___2__6__1__15([], _, _, _, A, B, C, D) :-
11506 passive___2__6__0__15(A, B, C, D).
11507passive___2__6__1__15([A|O], C, E, P, Q, J, L, G) :-
11508 ( A=suspension(_, active, B, D, M),
11509 B==C,
11510 D==E
11511 -> ( setarg(2, A, removed),
11512 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
11513 F),
11514 delete_ht(F, k(C, E), A)
11515 ),
11516 ( arg(2, G, H),
11517 setarg(2, G, active),
11518 ( H==not_stored_yet
11519 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11520 I),
11521 insert_ht(I, J, G)
11522 ),
11523 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11524 K),
11525 insert_ht(K, k(J, L), G)
11526 ; true
11527 )
11528 ),
11529 ( occurrence_code_id(C, E, M),
11530 N is E+1,
11531 set_occurrence_code_id(C, N, M)
11532 ),
11533 ( G=suspension(_, active, _, _, _)
11534 -> setarg(2, G, inactive),
11535 passive___2__6__1__15(O,
11536 C,
11537 E,
11538 P,
11539 Q,
11540 J,
11541 L,
11542 G)
11543 ; true
11544 )
11545 ; passive___2__6__1__15(O,
11546 C,
11547 E,
11548 P,
11549 Q,
11550 J,
11551 L,
11552 G)
11553 ).
11554passive___2__6(A, B, C) :-
11555 passive___2__7(A, B, C).
11556passive___2__7(D, F, A) :-
11557 arg(2, A, B),
11558 setarg(2, A, active),
11559 ( B==not_stored_yet
11560 -> ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11561 C),
11562 insert_ht(C, D, A)
11563 ),
11564 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11565 E),
11566 insert_ht(E, k(D, F), A)
11567 ; true
11568 ).
11569is_passive(B, C) :-
11570 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
11571 A),
11572 lookup_ht(A, k(B, C), D),
11573 member(E, D),
11574 E=suspension(_, active, _, _, _), !.
11575is_passive(_, _) :-
11576 fail.
11577any_passive_head(B) :-
11578 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
11579 A),
11580 lookup_ht(A, B, C),
11581 member(D, C),
11582 D=suspension(_, active, _, _, _), !.
11583any_passive_head(_) :-
11584 fail.
11585new_occurrence(B, H, I, J) :-
11586 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
11587 A),
11588 lookup_ht(A, B, C),
11589 member(D, C),
11590 D=suspension(_, active, _, _, F), !,
11591 setarg(2, D, removed),
11592 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
11593 E),
11594 delete_ht(E, B, D),
11595 G is F+1,
11596 occurrence(B, G, H, I, J),
11597 max_occurrence(B, G).
11598new_occurrence(A, B, _, _) :-
11599 chr_error(internal,
11600 'new_occurrence: missing max_occurrence for ~w in rule ~w\n',
11601 [A, B]).
11602occurrence(A, B, C, D, E) :-
11603 occurrence___5__0(A, B, C, D, E, _).
11604occurrence___5__0(D, E, B, F, G, C) :-
11605 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
11606 lookup_ht(A, B, I), !,
11607 C=suspension(H, not_stored_yet, t, _, D, E, B, F, G),
11608 'chr gen_id'(H),
11609 occurrence___5__0__0__4(I,
11610 D,
11611 E,
11612 B,
11613 F,
11614 G,
11615 C).
11616occurrence___5__0__0__4([], A, B, C, D, E, F) :-
11617 occurrence___5__1(A, B, C, D, E, F).
11618occurrence___5__0__0__4([A|I], E, F, C, J, K, L) :-
11619 ( ( A=suspension(_, active, _, _, B, H),
11620 B==C
11621 ),
11622 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
11623 D),
11624 lookup_ht(D, k(E, F), G)
11625 -> occurrence___5__0__1__4(G,
11626 H,
11627 A,
11628 I,
11629 E,
11630 F,
11631 C,
11632 J,
11633 K,
11634 L)
11635 ; occurrence___5__0__0__4(I,
11636 E,
11637 F,
11638 C,
11639 J,
11640 K,
11641 L)
11642 ).
11643occurrence___5__0__1__4([], _, _, A, B, C, D, E, F, G) :-
11644 occurrence___5__0__0__4(A,
11645 B,
11646 C,
11647 D,
11648 E,
11649 F,
11650 G).
11651occurrence___5__0__1__4([A|Y], X, F, Z, C, E, Q, R, K, G) :-
11652 ( A=suspension(_, active, _, B, D),
11653 ( B==C,
11654 D==E
11655 ),
11656 H=t(60, F, G, A),
11657 '$novel_production'(F, H),
11658 '$novel_production'(G, H),
11659 '$novel_production'(A, H)
11660 -> '$extend_history'(G, H),
11661 ( arg(2, G, I),
11662 setarg(2, G, active),
11663 ( I==not_stored_yet
11664 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
11665 J),
11666 insert_ht(J, k(C, K), G)
11667 ),
11668 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
11669 L),
11670 M=[G|L],
11671 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
11672 M),
11673 ( L=[N|_]
11674 -> setarg(4, N, M)
11675 ; true
11676 )
11677 ),
11678 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
11679 O),
11680 insert_ht(O, k(C, E, K), G)
11681 ),
11682 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
11683 P),
11684 insert_ht(P, k(C, Q, R), G)
11685 ),
11686 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
11687 S),
11688 insert_ht(S, k(C, E), G)
11689 ),
11690 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
11691 T),
11692 insert_ht(T, Q, G)
11693 ),
11694 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
11695 U),
11696 insert_ht(U, k(C, Q), G)
11697 ),
11698 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
11699 V),
11700 insert_ht(V, k(Q, R), G)
11701 ),
11702 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
11703 W),
11704 insert_ht(W, C, G)
11705 ; true
11706 )
11707 ),
11708 ( \+ is_passive(Q, R),
11709 K==propagation,
11710 ( stored_in_guard_before_next_kept_occurrence(C, E)
11711 -> true
11712 ; X=pragma(rule([_|_], _, _, _), _, _, _, _)
11713 -> is_observed(C, E)
11714 ; is_least_occurrence(Q)
11715 -> is_observed(C, E)
11716 ; true
11717 )
11718 ),
11719 ( G=suspension(_, active, _, _, _, _, _, _, _)
11720 -> setarg(2, G, inactive),
11721 occurrence___5__0__1__4(Y,
11722 X,
11723 F,
11724 Z,
11725 C,
11726 E,
11727 Q,
11728 R,
11729 K,
11730 G)
11731 ; true
11732 )
11733 ; occurrence___5__0__1__4(Y,
11734 X,
11735 F,
11736 Z,
11737 C,
11738 E,
11739 Q,
11740 R,
11741 K,
11742 G)
11743 ).
11744occurrence___5__0(B, C, D, E, F, A) :-
11745 A=suspension(G, not_stored_yet, t, _, B, C, D, E, F),
11746 'chr gen_id'(G),
11747 occurrence___5__1(B, C, D, E, F, A).
11748occurrence___5__1(D, E, B, F, G, H) :-
11749 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
11750 A),
11751 lookup_ht(A, B, C), !,
11752 occurrence___5__1__0__7(C,
11753 D,
11754 E,
11755 B,
11756 F,
11757 G,
11758 H).
11759occurrence___5__1__0__7([], A, B, C, D, E, F) :-
11760 occurrence___5__2(A, B, C, D, E, F).
11761occurrence___5__1__0__7([A|G1], G, L, C, F, V, S) :-
11762 ( ( A=suspension(_, active, B, D),
11763 B==C,
11764 D=[E|Q],
11765 E==F
11766 ),
11767 ( ( ground(G),
11768 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
11769 H),
11770 lookup_ht(H, G, I)
11771 ),
11772 member(J, I),
11773 J=suspension(_, active, _, _, K)
11774 ),
11775 K>=L,
11776 ( ( ground(C),
11777 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
11778 M),
11779 lookup_ht(M, C, N)
11780 ),
11781 member(O, N),
11782 O=suspension(_, active, _, _, _, _)
11783 ),
11784 \+ may_trigger(G)
11785 -> ( setarg(2, A, removed),
11786 ( nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
11787 P),
11788 delete_ht(P, k(C, [F|Q]), A)
11789 ),
11790 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
11791 R),
11792 delete_ht(R, C, A)
11793 ),
11794 ( arg(2, S, T),
11795 setarg(2, S, active),
11796 ( T==not_stored_yet
11797 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
11798 U),
11799 insert_ht(U, k(G, V), S)
11800 ),
11801 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
11802 W),
11803 X=[S|W],
11804 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
11805 X),
11806 ( W=[Y|_]
11807 -> setarg(4, Y, X)
11808 ; true
11809 )
11810 ),
11811 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
11812 Z),
11813 insert_ht(Z, k(G, L, V), S)
11814 ),
11815 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
11816 A1),
11817 insert_ht(A1, k(G, C, F), S)
11818 ),
11819 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
11820 B1),
11821 insert_ht(B1, k(G, L), S)
11822 ),
11823 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
11824 C1),
11825 insert_ht(C1, C, S)
11826 ),
11827 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
11828 D1),
11829 insert_ht(D1, k(G, C), S)
11830 ),
11831 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
11832 E1),
11833 insert_ht(E1, k(C, F), S)
11834 ),
11835 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
11836 F1),
11837 insert_ht(F1, G, S)
11838 ; true
11839 )
11840 ),
11841 least_occurrence(C, Q),
11842 ( S=suspension(_, active, _, _, _, _, _, _, _)
11843 -> setarg(2, S, inactive),
11844 occurrence___5__1__0__7(G1,
11845 G,
11846 L,
11847 C,
11848 F,
11849 V,
11850 S)
11851 ; true
11852 )
11853 ; occurrence___5__1__0__7(G1,
11854 G,
11855 L,
11856 C,
11857 F,
11858 V,
11859 S)
11860 ).
11861occurrence___5__1(A, B, C, D, E, F) :-
11862 occurrence___5__2(A, B, C, D, E, F).
11863occurrence___5__2(D, E, B, F, G, H) :-
11864 nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',
11865 A),
11866 lookup_ht(A, B, C), !,
11867 occurrence___5__2__0__29(C,
11868 D,
11869 E,
11870 B,
11871 F,
11872 G,
11873 H).
11874occurrence___5__2__0__29([], A, B, C, D, E, F) :-
11875 occurrence___5__3(A, B, C, D, E, F).
11876occurrence___5__2__0__29([A|V], H, N, C, P, I, D) :-
11877 ( A=suspension(_, active, _, B),
11878 B==C,
11879 E=t(180, A, D),
11880 '$novel_production'(A, E),
11881 '$novel_production'(D, E)
11882 -> '$extend_history'(D, E),
11883 ( arg(2, D, F),
11884 setarg(2, D, active),
11885 ( F==not_stored_yet
11886 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
11887 G),
11888 insert_ht(G, k(H, I), D)
11889 ),
11890 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
11891 J),
11892 K=[D|J],
11893 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
11894 K),
11895 ( J=[L|_]
11896 -> setarg(4, L, K)
11897 ; true
11898 )
11899 ),
11900 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
11901 M),
11902 insert_ht(M, k(H, N, I), D)
11903 ),
11904 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
11905 O),
11906 insert_ht(O, k(H, C, P), D)
11907 ),
11908 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
11909 Q),
11910 insert_ht(Q, k(H, N), D)
11911 ),
11912 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
11913 R),
11914 insert_ht(R, C, D)
11915 ),
11916 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
11917 S),
11918 insert_ht(S, k(H, C), D)
11919 ),
11920 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
11921 T),
11922 insert_ht(T, k(C, P), D)
11923 ),
11924 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
11925 U),
11926 insert_ht(U, H, D)
11927 ; true
11928 )
11929 ),
11930 passive(C, P),
11931 ( D=suspension(_, active, _, _, _, _, _, _, _)
11932 -> setarg(2, D, inactive),
11933 occurrence___5__2__0__29(V,
11934 H,
11935 N,
11936 C,
11937 P,
11938 I,
11939 D)
11940 ; true
11941 )
11942 ; occurrence___5__2__0__29(V,
11943 H,
11944 N,
11945 C,
11946 P,
11947 I,
11948 D)
11949 ).
11950occurrence___5__2(A, B, C, D, E, F) :-
11951 occurrence___5__3(A, B, C, D, E, F).
11952occurrence___5__3(D, E, B, F, G, H) :-
11953 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
11954 lookup_ht(A, B, C), !,
11955 occurrence___5__3__0__30(C,
11956 D,
11957 E,
11958 B,
11959 F,
11960 G,
11961 H).
11962occurrence___5__3__0__30([], A, B, C, D, E, F) :-
11963 occurrence___5__4(A, B, C, D, E, F).
11964occurrence___5__3__0__30([A|H], E, I, C, J, K, L) :-
11965 ( ( A=suspension(_, active, _, _, B, G),
11966 B==C
11967 ),
11968 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
11969 D),
11970 lookup_ht(D, k(E, C), F)
11971 -> occurrence___5__3__1__30(F,
11972 G,
11973 A,
11974 H,
11975 E,
11976 I,
11977 C,
11978 J,
11979 K,
11980 L)
11981 ; occurrence___5__3__0__30(H,
11982 E,
11983 I,
11984 C,
11985 J,
11986 K,
11987 L)
11988 ).
11989occurrence___5__3__1__30([], _, _, A, B, C, D, E, F, G) :-
11990 occurrence___5__3__0__30(A,
11991 B,
11992 C,
11993 D,
11994 E,
11995 F,
11996 G).
11997occurrence___5__3__1__30([A|I], J, K, L, C, M, E, N, O, P) :-
11998 ( ( A=suspension(_, active, _, _, B, H, D, _, _),
11999 B==C,
12000 D==E
12001 ),
12002 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
12003 F),
12004 lookup_ht(F, E, G)
12005 -> occurrence___5__3__2__30(G,
12006 H,
12007 A,
12008 I,
12009 J,
12010 K,
12011 L,
12012 C,
12013 M,
12014 E,
12015 N,
12016 O,
12017 P)
12018 ; occurrence___5__3__1__30(I,
12019 J,
12020 K,
12021 L,
12022 C,
12023 M,
12024 E,
12025 N,
12026 O,
12027 P)
12028 ).
12029occurrence___5__3__2__30([], _, _, A, B, C, D, E, F, G, H, I, J) :-
12030 occurrence___5__3__1__30(A,
12031 B,
12032 C,
12033 D,
12034 E,
12035 F,
12036 G,
12037 H,
12038 I,
12039 J).
12040occurrence___5__3__2__30([A|E], F, G, H, I, J, K, L, M, C, N, O, P) :-
12041 ( ( A=suspension(_, active, _, _, B, _, _, _, _, _),
12042 B==C
12043 ),
12044 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
12045 D)
12046 -> occurrence___5__3__3__30(D,
12047 A,
12048 E,
12049 F,
12050 G,
12051 H,
12052 I,
12053 J,
12054 K,
12055 L,
12056 M,
12057 C,
12058 N,
12059 O,
12060 P)
12061 ; occurrence___5__3__2__30(E,
12062 F,
12063 G,
12064 H,
12065 I,
12066 J,
12067 K,
12068 L,
12069 M,
12070 C,
12071 N,
12072 O,
12073 P)
12074 ).
12075occurrence___5__3__3__30([], _, A, B, C, D, E, F, G, H, I, J, K, L, M) :-
12076 occurrence___5__3__2__30(A,
12077 B,
12078 C,
12079 D,
12080 E,
12081 F,
12082 G,
12083 H,
12084 I,
12085 J,
12086 K,
12087 L,
12088 M).
12089occurrence___5__3__3__30([A|C1], D1, E1, C, F1, G1, D, H1, I1, F, B, U, V, O, L) :-
12090 ( A=suspension(_, active, _, G),
12091 B<C,
12092 chr_pp_flag(occurrence_subsumption, on),
12093 D=pragma(rule(E, _, _, _), _, _, _, _),
12094 E\==[],
12095 \+ tree_set_memberchk(F, G)
12096 -> ( setarg(2, A, removed),
12097 arg(3, A, H),
12098 ( var(H)
12099 -> nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
12100 I),
12101 I=[_|J],
12102 b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
12103 J),
12104 ( J=[K|_]
12105 -> setarg(3, K, _)
12106 ; true
12107 )
12108 ; H=[_, _|J],
12109 setarg(2, H, J),
12110 ( J=[K|_]
12111 -> setarg(3, K, H)
12112 ; true
12113 )
12114 )
12115 ),
12116 ( arg(2, L, M),
12117 setarg(2, L, active),
12118 ( M==not_stored_yet
12119 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
12120 N),
12121 insert_ht(N, k(F, O), L)
12122 ),
12123 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
12124 P),
12125 Q=[L|P],
12126 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
12127 Q),
12128 ( P=[R|_]
12129 -> setarg(4, R, Q)
12130 ; true
12131 )
12132 ),
12133 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
12134 S),
12135 insert_ht(S, k(F, B, O), L)
12136 ),
12137 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
12138 T),
12139 insert_ht(T, k(F, U, V), L)
12140 ),
12141 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
12142 W),
12143 insert_ht(W, k(F, B), L)
12144 ),
12145 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12146 X),
12147 insert_ht(X, U, L)
12148 ),
12149 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
12150 Y),
12151 insert_ht(Y, k(F, U), L)
12152 ),
12153 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
12154 Z),
12155 insert_ht(Z, k(U, V), L)
12156 ),
12157 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
12158 A1),
12159 insert_ht(A1, F, L)
12160 ; true
12161 )
12162 ),
12163 ( first_occ_in_rule(U, F, B, V),
12164 tree_set_add(G, F, B1),
12165 multiple_occ_constraints_checked(B1)
12166 ),
12167 ( L=suspension(_, active, _, _, _, _, _, _, _)
12168 -> setarg(2, L, inactive),
12169 occurrence___5__3__3__30(C1,
12170 D1,
12171 E1,
12172 C,
12173 F1,
12174 G1,
12175 D,
12176 H1,
12177 I1,
12178 F,
12179 B,
12180 U,
12181 V,
12182 O,
12183 L)
12184 ; true
12185 )
12186 ; occurrence___5__3__3__30(C1,
12187 D1,
12188 E1,
12189 C,
12190 F1,
12191 G1,
12192 D,
12193 H1,
12194 I1,
12195 F,
12196 B,
12197 U,
12198 V,
12199 O,
12200 L)
12201 ).
12202occurrence___5__3(A, B, C, D, E, F) :-
12203 occurrence___5__4(A, B, C, D, E, F).
12204occurrence___5__4(D, E, B, F, G, H) :-
12205 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
12206 lookup_ht(A, B, C), !,
12207 occurrence___5__4__0__31(C,
12208 D,
12209 E,
12210 B,
12211 F,
12212 G,
12213 H).
12214occurrence___5__4__0__31([], A, B, C, D, E, F) :-
12215 occurrence___5__5(A, B, C, D, E, F).
12216occurrence___5__4__0__31([A|H], E, I, C, J, K, L) :-
12217 ( ( A=suspension(_, active, _, _, B, G),
12218 B==C
12219 ),
12220 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
12221 D),
12222 lookup_ht(D, k(E, C), F)
12223 -> occurrence___5__4__1__31(F,
12224 G,
12225 A,
12226 H,
12227 E,
12228 I,
12229 C,
12230 J,
12231 K,
12232 L)
12233 ; occurrence___5__4__0__31(H,
12234 E,
12235 I,
12236 C,
12237 J,
12238 K,
12239 L)
12240 ).
12241occurrence___5__4__1__31([], _, _, A, B, C, D, E, F, G) :-
12242 occurrence___5__4__0__31(A,
12243 B,
12244 C,
12245 D,
12246 E,
12247 F,
12248 G).
12249occurrence___5__4__1__31([A|J], K, L, M, C, N, E, O, P, Q) :-
12250 ( ( A=suspension(_, active, _, _, B, H, D, I, _),
12251 B==C,
12252 D==E
12253 ),
12254 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
12255 F),
12256 lookup_ht(F, E, G)
12257 -> occurrence___5__4__2__31(G,
12258 H,
12259 I,
12260 A,
12261 J,
12262 K,
12263 L,
12264 M,
12265 C,
12266 N,
12267 E,
12268 O,
12269 P,
12270 Q)
12271 ; occurrence___5__4__1__31(J,
12272 K,
12273 L,
12274 M,
12275 C,
12276 N,
12277 E,
12278 O,
12279 P,
12280 Q)
12281 ).
12282occurrence___5__4__2__31([], _, _, _, A, B, C, D, E, F, G, H, I, J) :-
12283 occurrence___5__4__1__31(A,
12284 B,
12285 C,
12286 D,
12287 E,
12288 F,
12289 G,
12290 H,
12291 I,
12292 J).
12293occurrence___5__4__2__31([A|E], F, G, H, I, J, K, L, M, N, C, O, P, Q) :-
12294 ( ( A=suspension(_, active, _, _, B, _, _, _, _, _),
12295 B==C
12296 ),
12297 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
12298 D)
12299 -> occurrence___5__4__3__31(D,
12300 A,
12301 E,
12302 F,
12303 G,
12304 H,
12305 I,
12306 J,
12307 K,
12308 L,
12309 M,
12310 N,
12311 C,
12312 O,
12313 P,
12314 Q)
12315 ; occurrence___5__4__2__31(E,
12316 F,
12317 G,
12318 H,
12319 I,
12320 J,
12321 K,
12322 L,
12323 M,
12324 N,
12325 C,
12326 O,
12327 P,
12328 Q)
12329 ).
12330occurrence___5__4__3__31([], _, A, B, C, D, E, F, G, H, I, J, K, L, M, N) :-
12331 occurrence___5__4__2__31(A,
12332 B,
12333 C,
12334 D,
12335 E,
12336 F,
12337 G,
12338 H,
12339 I,
12340 J,
12341 K,
12342 L,
12343 M,
12344 N).
12345occurrence___5__4__3__31([A|D1], E1, F1, B, B1, G1, H1, D, I1, J1, F, C, U, V, O, L) :-
12346 ( A=suspension(_, active, _, G),
12347 B<C,
12348 chr_pp_flag(occurrence_subsumption, on),
12349 D=pragma(rule(E, _, _, _), _, _, _, _),
12350 E\==[],
12351 \+ tree_set_memberchk(F, G)
12352 -> ( setarg(2, A, removed),
12353 arg(3, A, H),
12354 ( var(H)
12355 -> nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
12356 I),
12357 I=[_|J],
12358 b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
12359 J),
12360 ( J=[K|_]
12361 -> setarg(3, K, _)
12362 ; true
12363 )
12364 ; H=[_, _|J],
12365 setarg(2, H, J),
12366 ( J=[K|_]
12367 -> setarg(3, K, H)
12368 ; true
12369 )
12370 )
12371 ),
12372 ( arg(2, L, M),
12373 setarg(2, L, active),
12374 ( M==not_stored_yet
12375 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
12376 N),
12377 insert_ht(N, k(F, O), L)
12378 ),
12379 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
12380 P),
12381 Q=[L|P],
12382 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
12383 Q),
12384 ( P=[R|_]
12385 -> setarg(4, R, Q)
12386 ; true
12387 )
12388 ),
12389 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
12390 S),
12391 insert_ht(S, k(F, C, O), L)
12392 ),
12393 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
12394 T),
12395 insert_ht(T, k(F, U, V), L)
12396 ),
12397 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
12398 W),
12399 insert_ht(W, k(F, C), L)
12400 ),
12401 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12402 X),
12403 insert_ht(X, U, L)
12404 ),
12405 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
12406 Y),
12407 insert_ht(Y, k(F, U), L)
12408 ),
12409 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
12410 Z),
12411 insert_ht(Z, k(U, V), L)
12412 ),
12413 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
12414 A1),
12415 insert_ht(A1, F, L)
12416 ; true
12417 )
12418 ),
12419 ( first_occ_in_rule(U, F, B, B1),
12420 tree_set_add(G, F, C1),
12421 multiple_occ_constraints_checked(C1)
12422 ),
12423 ( L=suspension(_, active, _, _, _, _, _, _, _)
12424 -> setarg(2, L, inactive),
12425 occurrence___5__4__3__31(D1,
12426 E1,
12427 F1,
12428 B,
12429 B1,
12430 G1,
12431 H1,
12432 D,
12433 I1,
12434 J1,
12435 F,
12436 C,
12437 U,
12438 V,
12439 O,
12440 L)
12441 ; true
12442 )
12443 ; occurrence___5__4__3__31(D1,
12444 E1,
12445 F1,
12446 B,
12447 B1,
12448 G1,
12449 H1,
12450 D,
12451 I1,
12452 J1,
12453 F,
12454 C,
12455 U,
12456 V,
12457 O,
12458 L)
12459 ).
12460occurrence___5__4(A, B, C, D, E, F) :-
12461 occurrence___5__5(A, B, C, D, E, F).
12462occurrence___5__5(B, C, E, F, G, H) :-
12463 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
12464 A),
12465 lookup_ht(A, k(B, C, yes), D), !,
12466 occurrence___5__5__0__35(D,
12467 B,
12468 C,
12469 E,
12470 F,
12471 G,
12472 H).
12473occurrence___5__5__0__35([], A, B, C, D, E, F) :-
12474 occurrence___5__6(A, B, C, D, E, F).
12475occurrence___5__5__0__35([A|J1], C, E, G, H, X, U) :-
12476 ( ( A=suspension(_, active, B, D, F),
12477 B==C,
12478 D==E,
12479 F=yes
12480 ),
12481 ( ( ( ground(G),
12482 ground(H)
12483 ),
12484 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
12485 I),
12486 lookup_ht(I, k(G, H), J)
12487 ),
12488 member(K, J),
12489 K=suspension(_, active, _, _, _)
12490 ),
12491 ( ( ground(C),
12492 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
12493 L),
12494 lookup_ht(L, C, M)
12495 ),
12496 member(N, M),
12497 N=suspension(_, active, _, _, O, S)
12498 ),
12499 E<O
12500 -> ( ( setarg(2, A, removed),
12501 ( nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
12502 P),
12503 delete_ht(P, k(C, yes), A)
12504 ),
12505 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
12506 Q),
12507 delete_ht(Q, k(C, E, yes), A)
12508 ),
12509 setarg(2, N, removed),
12510 ( nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
12511 R),
12512 delete_ht(R, k(C, S), N)
12513 ),
12514 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
12515 T),
12516 delete_ht(T, C, N)
12517 ),
12518 ( arg(2, U, V),
12519 setarg(2, U, active),
12520 ( V==not_stored_yet
12521 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
12522 W),
12523 insert_ht(W, k(C, X), U)
12524 ),
12525 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
12526 Y),
12527 Z=[U|Y],
12528 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
12529 Z),
12530 ( Y=[A1|_]
12531 -> setarg(4, A1, Z)
12532 ; true
12533 )
12534 ),
12535 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
12536 B1),
12537 insert_ht(B1, k(C, E, X), U)
12538 ),
12539 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
12540 C1),
12541 insert_ht(C1, k(C, G, H), U)
12542 ),
12543 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
12544 D1),
12545 insert_ht(D1, k(C, E), U)
12546 ),
12547 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12548 E1),
12549 insert_ht(E1, G, U)
12550 ),
12551 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
12552 F1),
12553 insert_ht(F1, k(C, G), U)
12554 ),
12555 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
12556 G1),
12557 insert_ht(G1, k(G, H), U)
12558 ),
12559 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
12560 H1),
12561 insert_ht(H1, C, U)
12562 ; true
12563 )
12564 ),
12565 ( I1 is S-1,
12566 stored(C, E, maybe),
12567 stored_complete(C, O, I1)
12568 ),
12569 ( U=suspension(_, active, _, _, _, _, _, _, _)
12570 -> setarg(2, U, inactive),
12571 occurrence___5__5__0__35(J1,
12572 C,
12573 E,
12574 G,
12575 H,
12576 X,
12577 U)
12578 ; true
12579 )
12580 ; occurrence___5__5__0__35(J1,
12581 C,
12582 E,
12583 G,
12584 H,
12585 X,
12586 U)
12587 ).
12588occurrence___5__5(A, B, C, D, E, F) :-
12589 occurrence___5__6(A, B, C, D, E, F).
12590occurrence___5__6(D, E, B, F, G, H) :-
12591 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12592 A),
12593 lookup_ht(A, B, C), !,
12594 occurrence___5__6__0__36(C,
12595 D,
12596 E,
12597 B,
12598 F,
12599 G,
12600 H).
12601occurrence___5__6__0__36([], A, B, C, D, E, F) :-
12602 occurrence___5__7(A, B, C, D, E, F).
12603occurrence___5__6__0__36([A|G], H, I, C, J, K, L) :-
12604 ( ( A=suspension(_, active, _, _, E, _, B, _, _),
12605 B==C
12606 ),
12607 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
12608 D),
12609 lookup_ht(D, E, F)
12610 -> occurrence___5__6__1__36(F,
12611 E,
12612 A,
12613 G,
12614 H,
12615 I,
12616 C,
12617 J,
12618 K,
12619 L)
12620 ; occurrence___5__6__0__36(G,
12621 H,
12622 I,
12623 C,
12624 J,
12625 K,
12626 L)
12627 ).
12628occurrence___5__6__1__36([], _, _, A, B, C, D, E, F, G) :-
12629 occurrence___5__6__0__36(A,
12630 B,
12631 C,
12632 D,
12633 E,
12634 F,
12635 G).
12636occurrence___5__6__1__36([A|G], C, H, I, J, K, L, M, N, O) :-
12637 ( ( A=suspension(_, active, _, B, F),
12638 B==C
12639 ),
12640 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
12641 D),
12642 lookup_ht(D, k(C, 0), E)
12643 -> occurrence___5__6__2__36(E,
12644 F,
12645 A,
12646 G,
12647 C,
12648 H,
12649 I,
12650 J,
12651 K,
12652 L,
12653 M,
12654 N,
12655 O)
12656 ; occurrence___5__6__1__36(G,
12657 C,
12658 H,
12659 I,
12660 J,
12661 K,
12662 L,
12663 M,
12664 N,
12665 O)
12666 ).
12667occurrence___5__6__2__36([], _, _, A, B, C, D, E, F, G, H, I, J) :-
12668 occurrence___5__6__1__36(A,
12669 B,
12670 C,
12671 D,
12672 E,
12673 F,
12674 G,
12675 H,
12676 I,
12677 J).
12678occurrence___5__6__2__36([A|B1], J, G, C1, C, F, D1, M, S, U, V, N, E) :-
12679 ( A=suspension(_, active, _, B, I, D),
12680 ( B==C,
12681 D=0
12682 ),
12683 ( H=t(250, E, F, A, G),
12684 '$novel_production'(E, H),
12685 '$novel_production'(F, H),
12686 '$novel_production'(A, H),
12687 '$novel_production'(G, H)
12688 ),
12689 I=<J
12690 -> '$extend_history'(E, H),
12691 ( arg(2, E, K),
12692 setarg(2, E, active),
12693 ( K==not_stored_yet
12694 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
12695 L),
12696 insert_ht(L, k(M, N), E)
12697 ),
12698 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
12699 O),
12700 P=[E|O],
12701 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
12702 P),
12703 ( O=[Q|_]
12704 -> setarg(4, Q, P)
12705 ; true
12706 )
12707 ),
12708 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
12709 R),
12710 insert_ht(R, k(M, S, N), E)
12711 ),
12712 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
12713 T),
12714 insert_ht(T, k(M, U, V), E)
12715 ),
12716 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
12717 W),
12718 insert_ht(W, k(M, S), E)
12719 ),
12720 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12721 X),
12722 insert_ht(X, U, E)
12723 ),
12724 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
12725 Y),
12726 insert_ht(Y, k(M, U), E)
12727 ),
12728 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
12729 Z),
12730 insert_ht(Z, k(U, V), E)
12731 ),
12732 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
12733 A1),
12734 insert_ht(A1, M, E)
12735 ; true
12736 )
12737 ),
12738 passive(U, V),
12739 ( E=suspension(_, active, _, _, _, _, _, _, _)
12740 -> setarg(2, E, inactive),
12741 occurrence___5__6__2__36(B1,
12742 J,
12743 G,
12744 C1,
12745 C,
12746 F,
12747 D1,
12748 M,
12749 S,
12750 U,
12751 V,
12752 N,
12753 E)
12754 ; true
12755 )
12756 ; occurrence___5__6__2__36(B1,
12757 J,
12758 G,
12759 C1,
12760 C,
12761 F,
12762 D1,
12763 M,
12764 S,
12765 U,
12766 V,
12767 N,
12768 E)
12769 ).
12770occurrence___5__6(A, B, C, D, E, F) :-
12771 occurrence___5__7(A, B, C, D, E, F).
12772occurrence___5__7(D, E, B, F, G, H) :-
12773 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12774 A),
12775 lookup_ht(A, B, C), !,
12776 occurrence___5__7__0__37(C,
12777 D,
12778 E,
12779 B,
12780 F,
12781 G,
12782 H).
12783occurrence___5__7__0__37([], A, B, C, D, E, F) :-
12784 occurrence___5__8(A, B, C, D, E, F).
12785occurrence___5__7__0__37([A|H], E, I, C, J, K, L) :-
12786 ( ( A=suspension(_, active, _, _, _, _, B, G, _),
12787 B==C
12788 ),
12789 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
12790 D),
12791 lookup_ht(D, E, F)
12792 -> occurrence___5__7__1__37(F,
12793 G,
12794 A,
12795 H,
12796 E,
12797 I,
12798 C,
12799 J,
12800 K,
12801 L)
12802 ; occurrence___5__7__0__37(H,
12803 E,
12804 I,
12805 C,
12806 J,
12807 K,
12808 L)
12809 ).
12810occurrence___5__7__1__37([], _, _, A, B, C, D, E, F, G) :-
12811 occurrence___5__7__0__37(A,
12812 B,
12813 C,
12814 D,
12815 E,
12816 F,
12817 G).
12818occurrence___5__7__1__37([A|G], H, I, J, C, K, L, M, N, O) :-
12819 ( ( A=suspension(_, active, _, B, F),
12820 B==C
12821 ),
12822 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
12823 D),
12824 lookup_ht(D, k(C, 0), E)
12825 -> occurrence___5__7__2__37(E,
12826 F,
12827 A,
12828 G,
12829 H,
12830 I,
12831 J,
12832 C,
12833 K,
12834 L,
12835 M,
12836 N,
12837 O)
12838 ; occurrence___5__7__1__37(G,
12839 H,
12840 I,
12841 J,
12842 C,
12843 K,
12844 L,
12845 M,
12846 N,
12847 O)
12848 ).
12849occurrence___5__7__2__37([], _, _, A, B, C, D, E, F, G, H, I, J) :-
12850 occurrence___5__7__1__37(A,
12851 B,
12852 C,
12853 D,
12854 E,
12855 F,
12856 G,
12857 H,
12858 I,
12859 J).
12860occurrence___5__7__2__37([A|B1], J, G, C1, A1, E, D1, C, R, T, U, M, F) :-
12861 ( A=suspension(_, active, _, B, I, D),
12862 ( B==C,
12863 D=0
12864 ),
12865 ( H=t(250, E, F, A, G),
12866 '$novel_production'(E, H),
12867 '$novel_production'(F, H),
12868 '$novel_production'(A, H),
12869 '$novel_production'(G, H)
12870 ),
12871 I=<J
12872 -> '$extend_history'(F, H),
12873 ( arg(2, F, K),
12874 setarg(2, F, active),
12875 ( K==not_stored_yet
12876 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
12877 L),
12878 insert_ht(L, k(C, M), F)
12879 ),
12880 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
12881 N),
12882 O=[F|N],
12883 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
12884 O),
12885 ( N=[P|_]
12886 -> setarg(4, P, O)
12887 ; true
12888 )
12889 ),
12890 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
12891 Q),
12892 insert_ht(Q, k(C, R, M), F)
12893 ),
12894 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
12895 S),
12896 insert_ht(S, k(C, T, U), F)
12897 ),
12898 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
12899 V),
12900 insert_ht(V, k(C, R), F)
12901 ),
12902 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
12903 W),
12904 insert_ht(W, T, F)
12905 ),
12906 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
12907 X),
12908 insert_ht(X, k(C, T), F)
12909 ),
12910 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
12911 Y),
12912 insert_ht(Y, k(T, U), F)
12913 ),
12914 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
12915 Z),
12916 insert_ht(Z, C, F)
12917 ; true
12918 )
12919 ),
12920 passive(T, A1),
12921 ( F=suspension(_, active, _, _, _, _, _, _, _)
12922 -> setarg(2, F, inactive),
12923 occurrence___5__7__2__37(B1,
12924 J,
12925 G,
12926 C1,
12927 A1,
12928 E,
12929 D1,
12930 C,
12931 R,
12932 T,
12933 U,
12934 M,
12935 F)
12936 ; true
12937 )
12938 ; occurrence___5__7__2__37(B1,
12939 J,
12940 G,
12941 C1,
12942 A1,
12943 E,
12944 D1,
12945 C,
12946 R,
12947 T,
12948 U,
12949 M,
12950 F)
12951 ).
12952occurrence___5__7(A, B, C, D, E, F) :-
12953 occurrence___5__8(A, B, C, D, E, F).
12954occurrence___5__8(B, D, E, F, G, H) :-
12955 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
12956 A),
12957 lookup_ht(A, B, C), !,
12958 occurrence___5__8__0__38(C,
12959 B,
12960 D,
12961 E,
12962 F,
12963 G,
12964 H).
12965occurrence___5__8__0__38([], A, B, C, D, E, F) :-
12966 occurrence___5__9(A, B, C, D, E, F).
12967occurrence___5__8__0__38([A|W], C, F, P, Q, J, D) :-
12968 ( A=suspension(_, active, _, B, G, _),
12969 B==C,
12970 ( E=t(259, A, D),
12971 '$novel_production'(A, E),
12972 '$novel_production'(D, E)
12973 ),
12974 F>G
12975 -> '$extend_history'(D, E),
12976 ( arg(2, D, H),
12977 setarg(2, D, active),
12978 ( H==not_stored_yet
12979 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
12980 I),
12981 insert_ht(I, k(C, J), D)
12982 ),
12983 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
12984 K),
12985 L=[D|K],
12986 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
12987 L),
12988 ( K=[M|_]
12989 -> setarg(4, M, L)
12990 ; true
12991 )
12992 ),
12993 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
12994 N),
12995 insert_ht(N, k(C, F, J), D)
12996 ),
12997 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
12998 O),
12999 insert_ht(O, k(C, P, Q), D)
13000 ),
13001 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13002 R),
13003 insert_ht(R, k(C, F), D)
13004 ),
13005 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13006 S),
13007 insert_ht(S, P, D)
13008 ),
13009 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13010 T),
13011 insert_ht(T, k(C, P), D)
13012 ),
13013 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13014 U),
13015 insert_ht(U, k(P, Q), D)
13016 ),
13017 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13018 V),
13019 insert_ht(V, C, D)
13020 ; true
13021 )
13022 ),
13023 passive(P, Q),
13024 ( D=suspension(_, active, _, _, _, _, _, _, _)
13025 -> setarg(2, D, inactive),
13026 occurrence___5__8__0__38(W,
13027 C,
13028 F,
13029 P,
13030 Q,
13031 J,
13032 D)
13033 ; true
13034 )
13035 ; occurrence___5__8__0__38(W,
13036 C,
13037 F,
13038 P,
13039 Q,
13040 J,
13041 D)
13042 ).
13043occurrence___5__8(A, B, C, D, E, F) :-
13044 occurrence___5__9(A, B, C, D, E, F).
13045occurrence___5__9(B, E, C, F, G, H) :-
13046 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',
13047 A),
13048 lookup_ht(A, k(B, C), D), !,
13049 occurrence___5__9__0__42(D,
13050 B,
13051 E,
13052 C,
13053 F,
13054 G,
13055 H).
13056occurrence___5__9__0__42([], A, B, C, D, E, F) :-
13057 occurrence___5__10(A, B, C, D, E, F).
13058occurrence___5__9__0__42([A|D1], C, J, E, V, P, M) :-
13059 ( ( A=suspension(_, active, B, D, B1, C1),
13060 B==C,
13061 D==E
13062 ),
13063 E>1,
13064 ( ( ground(C),
13065 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
13066 F),
13067 lookup_ht(F, C, G)
13068 ),
13069 member(H, G),
13070 H=suspension(_, active, _, _, I)
13071 ),
13072 I>J
13073 -> ( setarg(2, A, removed),
13074 ( nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
13075 K),
13076 delete_ht(K, C, A)
13077 ),
13078 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',
13079 L),
13080 delete_ht(L, k(C, E), A)
13081 ),
13082 ( arg(2, M, N),
13083 setarg(2, M, active),
13084 ( N==not_stored_yet
13085 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13086 O),
13087 insert_ht(O, k(C, P), M)
13088 ),
13089 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13090 Q),
13091 R=[M|Q],
13092 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13093 R),
13094 ( Q=[S|_]
13095 -> setarg(4, S, R)
13096 ; true
13097 )
13098 ),
13099 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13100 T),
13101 insert_ht(T, k(C, J, P), M)
13102 ),
13103 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13104 U),
13105 insert_ht(U, k(C, E, V), M)
13106 ),
13107 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13108 W),
13109 insert_ht(W, k(C, J), M)
13110 ),
13111 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13112 X),
13113 insert_ht(X, E, M)
13114 ),
13115 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13116 Y),
13117 insert_ht(Y, k(C, E), M)
13118 ),
13119 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13120 Z),
13121 insert_ht(Z, k(E, V), M)
13122 ),
13123 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13124 A1),
13125 insert_ht(A1, C, M)
13126 ; true
13127 )
13128 ),
13129 functional_dependency(C, 1, B1, C1),
13130 ( M=suspension(_, active, _, _, _, _, _, _, _)
13131 -> setarg(2, M, inactive),
13132 occurrence___5__9__0__42(D1,
13133 C,
13134 J,
13135 E,
13136 V,
13137 P,
13138 M)
13139 ; true
13140 )
13141 ; occurrence___5__9__0__42(D1,
13142 C,
13143 J,
13144 E,
13145 V,
13146 P,
13147 M)
13148 ).
13149occurrence___5__9(A, B, C, D, E, F) :-
13150 occurrence___5__10(A, B, C, D, E, F).
13151occurrence___5__10(B, D, E, F, G, H) :-
13152 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
13153 A),
13154 lookup_ht(A, B, C), !,
13155 occurrence___5__10__0__48(C,
13156 B,
13157 D,
13158 E,
13159 F,
13160 G,
13161 H).
13162occurrence___5__10__0__48([], A, B, C, D, E, F) :-
13163 occurrence___5__11(A, B, C, D, E, F).
13164occurrence___5__10__0__48([A|F], C, G, H, I, J, K) :-
13165 ( ( A=suspension(_, active, _, _, B, E),
13166 B==C
13167 ),
13168 nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
13169 D)
13170 -> occurrence___5__10__1__48(D,
13171 E,
13172 A,
13173 F,
13174 C,
13175 G,
13176 H,
13177 I,
13178 J,
13179 K)
13180 ; occurrence___5__10__0__48(F,
13181 C,
13182 G,
13183 H,
13184 I,
13185 J,
13186 K)
13187 ).
13188occurrence___5__10__1__48([], _, _, A, B, C, D, E, F, G) :-
13189 occurrence___5__10__0__48(A,
13190 B,
13191 C,
13192 D,
13193 E,
13194 F,
13195 G).
13196occurrence___5__10__1__48([A|E], F, G, H, I, J, C, K, L, M) :-
13197 ( A=suspension(_, active, _, _),
13198 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
13199 B),
13200 lookup_ht(B, C, D)
13201 -> occurrence___5__10__2__48(D,
13202 A,
13203 E,
13204 F,
13205 G,
13206 H,
13207 I,
13208 J,
13209 C,
13210 K,
13211 L,
13212 M)
13213 ; occurrence___5__10__1__48(E,
13214 F,
13215 G,
13216 H,
13217 I,
13218 J,
13219 C,
13220 K,
13221 L,
13222 M)
13223 ).
13224occurrence___5__10__2__48([], _, A, B, C, D, E, F, G, H, I, J) :-
13225 occurrence___5__10__1__48(A,
13226 B,
13227 C,
13228 D,
13229 E,
13230 F,
13231 G,
13232 H,
13233 I,
13234 J).
13235occurrence___5__10__2__48([A|F1], D, G1, C1, F, H1, J, P, C, R, K, E) :-
13236 ( A=suspension(_, active, _, _, B, X),
13237 B==C,
13238 G=t(330, D, E, A, F),
13239 '$novel_production'(D, G),
13240 '$novel_production'(E, G),
13241 '$novel_production'(A, G),
13242 '$novel_production'(F, G)
13243 -> '$extend_history'(E, G),
13244 ( arg(2, E, H),
13245 setarg(2, E, active),
13246 ( H==not_stored_yet
13247 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13248 I),
13249 insert_ht(I, k(J, K), E)
13250 ),
13251 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13252 L),
13253 M=[E|L],
13254 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13255 M),
13256 ( L=[N|_]
13257 -> setarg(4, N, M)
13258 ; true
13259 )
13260 ),
13261 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13262 O),
13263 insert_ht(O, k(J, P, K), E)
13264 ),
13265 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13266 Q),
13267 insert_ht(Q, k(J, C, R), E)
13268 ),
13269 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13270 S),
13271 insert_ht(S, k(J, P), E)
13272 ),
13273 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13274 T),
13275 insert_ht(T, C, E)
13276 ),
13277 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13278 U),
13279 insert_ht(U, k(J, C), E)
13280 ),
13281 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13282 V),
13283 insert_ht(V, k(C, R), E)
13284 ),
13285 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13286 W),
13287 insert_ht(W, J, E)
13288 ; true
13289 )
13290 ),
13291 ( X=pragma(rule(Y, E1, A1, _), _, _, _, _),
13292 ( is_passive(C, R)
13293 -> true
13294 ; K==simplification
13295 -> select(Z, Y, _),
13296 Z=..[_|B1],
13297 term_variables(A1, D1),
13298 partial_wake_args(B1, C1, D1, J)
13299 ; select(Z, E1, _),
13300 Z=..[_|B1],
13301 term_variables(A1, D1),
13302 partial_wake_args(B1, C1, D1, J)
13303 )
13304 ),
13305 ( E=suspension(_, active, _, _, _, _, _, _, _)
13306 -> setarg(2, E, inactive),
13307 occurrence___5__10__2__48(F1,
13308 D,
13309 G1,
13310 C1,
13311 F,
13312 H1,
13313 J,
13314 P,
13315 C,
13316 R,
13317 K,
13318 E)
13319 ; true
13320 )
13321 ; occurrence___5__10__2__48(F1,
13322 D,
13323 G1,
13324 C1,
13325 F,
13326 H1,
13327 J,
13328 P,
13329 C,
13330 R,
13331 K,
13332 E)
13333 ).
13334occurrence___5__10(A, B, C, D, E, F) :-
13335 occurrence___5__11(A, B, C, D, E, F).
13336occurrence___5__11(E, F, B, C, G, H) :-
13337 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
13338 A),
13339 lookup_ht(A, k(B, C), D), !,
13340 occurrence___5__11__0__50(D,
13341 E,
13342 F,
13343 B,
13344 C,
13345 G,
13346 H).
13347occurrence___5__11__0__50([], A, B, C, D, E, F) :-
13348 occurrence___5__12(A, B, C, D, E, F).
13349occurrence___5__11__0__50([A|J], G, H, C, E, K, L) :-
13350 ( ( A=suspension(_, active, _, B, D),
13351 B==C,
13352 D==E
13353 ),
13354 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
13355 F),
13356 lookup_ht(F, k(G, H), I)
13357 -> occurrence___5__11__1__50(I,
13358 A,
13359 J,
13360 G,
13361 H,
13362 C,
13363 E,
13364 K,
13365 L)
13366 ; occurrence___5__11__0__50(J,
13367 G,
13368 H,
13369 C,
13370 E,
13371 K,
13372 L)
13373 ).
13374occurrence___5__11__1__50([], _, A, B, C, D, E, F, G) :-
13375 occurrence___5__11__0__50(A,
13376 B,
13377 C,
13378 D,
13379 E,
13380 F,
13381 G).
13382occurrence___5__11__1__50([A|Y], G, Z, C, E, Q, R, K, F) :-
13383 ( A=suspension(_, active, _, B, D),
13384 ( B==C,
13385 D==E
13386 ),
13387 ( H=t(362, F, G, A),
13388 '$novel_production'(F, H),
13389 '$novel_production'(G, H),
13390 '$novel_production'(A, H)
13391 ),
13392 E>1
13393 -> '$extend_history'(F, H),
13394 ( arg(2, F, I),
13395 setarg(2, F, active),
13396 ( I==not_stored_yet
13397 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13398 J),
13399 insert_ht(J, k(C, K), F)
13400 ),
13401 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13402 L),
13403 M=[F|L],
13404 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13405 M),
13406 ( L=[N|_]
13407 -> setarg(4, N, M)
13408 ; true
13409 )
13410 ),
13411 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13412 O),
13413 insert_ht(O, k(C, E, K), F)
13414 ),
13415 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13416 P),
13417 insert_ht(P, k(C, Q, R), F)
13418 ),
13419 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13420 S),
13421 insert_ht(S, k(C, E), F)
13422 ),
13423 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13424 T),
13425 insert_ht(T, Q, F)
13426 ),
13427 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13428 U),
13429 insert_ht(U, k(C, Q), F)
13430 ),
13431 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13432 V),
13433 insert_ht(V, k(Q, R), F)
13434 ),
13435 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13436 W),
13437 insert_ht(W, C, F)
13438 ; true
13439 )
13440 ),
13441 ( X is E-1,
13442 skip_to_next_id(C, X)
13443 ),
13444 ( F=suspension(_, active, _, _, _, _, _, _, _)
13445 -> setarg(2, F, inactive),
13446 occurrence___5__11__1__50(Y,
13447 G,
13448 Z,
13449 C,
13450 E,
13451 Q,
13452 R,
13453 K,
13454 F)
13455 ; true
13456 )
13457 ; occurrence___5__11__1__50(Y,
13458 G,
13459 Z,
13460 C,
13461 E,
13462 Q,
13463 R,
13464 K,
13465 F)
13466 ).
13467occurrence___5__11(A, B, C, D, E, F) :-
13468 occurrence___5__12(A, B, C, D, E, F).
13469occurrence___5__12(B, C, E, F, G, H) :-
13470 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13471 A),
13472 lookup_ht(A, k(B, C), D), !,
13473 occurrence___5__12__0__51(D,
13474 B,
13475 C,
13476 E,
13477 F,
13478 G,
13479 H).
13480occurrence___5__12__0__51([], A, B, C, D, E, F) :-
13481 occurrence___5__13(A, B, C, D, E, F).
13482occurrence___5__12__0__51([A|B1], C, E, F, G, O, L) :-
13483 ( ( A=suspension(_, active, B, D, Z),
13484 B==C,
13485 D==E
13486 ),
13487 ( ( ground(F),
13488 ground(G)
13489 ),
13490 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
13491 H),
13492 lookup_ht(H, k(F, G), I)
13493 ),
13494 member(J, I),
13495 J=suspension(_, active, _, _, _)
13496 -> ( setarg(2, A, removed),
13497 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13498 K),
13499 delete_ht(K, k(C, E), A)
13500 ),
13501 ( arg(2, L, M),
13502 setarg(2, L, active),
13503 ( M==not_stored_yet
13504 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13505 N),
13506 insert_ht(N, k(C, O), L)
13507 ),
13508 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13509 P),
13510 Q=[L|P],
13511 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13512 Q),
13513 ( P=[R|_]
13514 -> setarg(4, R, Q)
13515 ; true
13516 )
13517 ),
13518 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13519 S),
13520 insert_ht(S, k(C, E, O), L)
13521 ),
13522 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13523 T),
13524 insert_ht(T, k(C, F, G), L)
13525 ),
13526 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13527 U),
13528 insert_ht(U, k(C, E), L)
13529 ),
13530 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13531 V),
13532 insert_ht(V, F, L)
13533 ),
13534 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13535 W),
13536 insert_ht(W, k(C, F), L)
13537 ),
13538 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13539 X),
13540 insert_ht(X, k(F, G), L)
13541 ),
13542 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13543 Y),
13544 insert_ht(Y, C, L)
13545 ; true
13546 )
13547 ),
13548 ( occurrence_code_id(C, E, Z),
13549 A1 is E+1,
13550 set_occurrence_code_id(C, A1, Z)
13551 ),
13552 ( L=suspension(_, active, _, _, _, _, _, _, _)
13553 -> setarg(2, L, inactive),
13554 occurrence___5__12__0__51(B1,
13555 C,
13556 E,
13557 F,
13558 G,
13559 O,
13560 L)
13561 ; true
13562 )
13563 ; occurrence___5__12__0__51(B1,
13564 C,
13565 E,
13566 F,
13567 G,
13568 O,
13569 L)
13570 ).
13571occurrence___5__12(A, B, C, D, E, F) :-
13572 occurrence___5__13(A, B, C, D, E, F).
13573occurrence___5__13(B, C, E, F, simplification, G) :-
13574 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13575 A),
13576 lookup_ht(A, k(B, C), D), !,
13577 occurrence___5__13__0__52(D,
13578 B,
13579 C,
13580 E,
13581 F,
13582 simplification,
13583 G).
13584occurrence___5__13__0__52([], A, B, C, D, E, F) :-
13585 occurrence___5__15(A, B, C, D, E, F).
13586occurrence___5__13__0__52([A|Y], C, E, P, Q, J, G) :-
13587 ( A=suspension(_, active, B, D, W),
13588 B==C,
13589 D==E
13590 -> ( setarg(2, A, removed),
13591 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13592 F),
13593 delete_ht(F, k(C, E), A)
13594 ),
13595 ( arg(2, G, H),
13596 setarg(2, G, active),
13597 ( H==not_stored_yet
13598 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13599 I),
13600 insert_ht(I, k(C, J), G)
13601 ),
13602 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13603 K),
13604 L=[G|K],
13605 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13606 L),
13607 ( K=[M|_]
13608 -> setarg(4, M, L)
13609 ; true
13610 )
13611 ),
13612 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13613 N),
13614 insert_ht(N, k(C, E, J), G)
13615 ),
13616 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13617 O),
13618 insert_ht(O, k(C, P, Q), G)
13619 ),
13620 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13621 R),
13622 insert_ht(R, k(C, E), G)
13623 ),
13624 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13625 S),
13626 insert_ht(S, P, G)
13627 ),
13628 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13629 T),
13630 insert_ht(T, k(C, P), G)
13631 ),
13632 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13633 U),
13634 insert_ht(U, k(P, Q), G)
13635 ),
13636 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13637 V),
13638 insert_ht(V, C, G)
13639 ; true
13640 )
13641 ),
13642 ( occurrence_code_id(C, E, W),
13643 X is E+1,
13644 set_occurrence_code_id(C, X, W)
13645 ),
13646 ( G=suspension(_, active, _, _, _, _, _, _, _)
13647 -> setarg(2, G, inactive),
13648 occurrence___5__13__0__52(Y,
13649 C,
13650 E,
13651 P,
13652 Q,
13653 J,
13654 G)
13655 ; true
13656 )
13657 ; occurrence___5__13__0__52(Y,
13658 C,
13659 E,
13660 P,
13661 Q,
13662 J,
13663 G)
13664 ).
13665occurrence___5__13(B, C, E, F, propagation, G) :-
13666 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13667 A),
13668 lookup_ht(A, k(B, C), D), !,
13669 occurrence___5__13__0__53(D,
13670 B,
13671 C,
13672 E,
13673 F,
13674 propagation,
13675 G).
13676occurrence___5__13__0__53([], A, B, C, D, E, F) :-
13677 occurrence___5__14(A, B, C, D, E, F).
13678occurrence___5__13__0__53([A|C1], C, E, S, T, M, J) :-
13679 ( ( A=suspension(_, active, B, D, Z),
13680 B==C,
13681 D==E
13682 ),
13683 ( ( ground(C),
13684 ground(E)
13685 ),
13686 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
13687 F),
13688 lookup_ht(F, k(C, E), G)
13689 ),
13690 member(H, G),
13691 H=suspension(_, active, _, _, _)
13692 -> ( setarg(2, A, removed),
13693 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13694 I),
13695 delete_ht(I, k(C, E), A)
13696 ),
13697 ( arg(2, J, K),
13698 setarg(2, J, active),
13699 ( K==not_stored_yet
13700 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13701 L),
13702 insert_ht(L, k(C, M), J)
13703 ),
13704 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13705 N),
13706 O=[J|N],
13707 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13708 O),
13709 ( N=[P|_]
13710 -> setarg(4, P, O)
13711 ; true
13712 )
13713 ),
13714 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13715 Q),
13716 insert_ht(Q, k(C, E, M), J)
13717 ),
13718 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13719 R),
13720 insert_ht(R, k(C, S, T), J)
13721 ),
13722 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13723 U),
13724 insert_ht(U, k(C, E), J)
13725 ),
13726 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13727 V),
13728 insert_ht(V, S, J)
13729 ),
13730 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13731 W),
13732 insert_ht(W, k(C, S), J)
13733 ),
13734 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13735 X),
13736 insert_ht(X, k(S, T), J)
13737 ),
13738 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13739 Y),
13740 insert_ht(Y, C, J)
13741 ; true
13742 )
13743 ),
13744 ( occurrence_code_id(C, E, Z),
13745 A1 is E+1,
13746 B1 is Z+1,
13747 set_occurrence_code_id(C, A1, B1)
13748 ),
13749 ( J=suspension(_, active, _, _, _, _, _, _, _)
13750 -> setarg(2, J, inactive),
13751 occurrence___5__13__0__53(C1,
13752 C,
13753 E,
13754 S,
13755 T,
13756 M,
13757 J)
13758 ; true
13759 )
13760 ; occurrence___5__13__0__53(C1,
13761 C,
13762 E,
13763 S,
13764 T,
13765 M,
13766 J)
13767 ).
13768occurrence___5__13(A, B, C, D, E, F) :-
13769 occurrence___5__14(A, B, C, D, E, F).
13770occurrence___5__14(B, C, E, F, propagation, G) :-
13771 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13772 A),
13773 lookup_ht(A, k(B, C), D), !,
13774 occurrence___5__14__0__54(D,
13775 B,
13776 C,
13777 E,
13778 F,
13779 propagation,
13780 G).
13781occurrence___5__14__0__54([], A, B, C, D, E, F) :-
13782 occurrence___5__15(A, B, C, D, E, F).
13783occurrence___5__14__0__54([A|Y], C, E, P, Q, J, G) :-
13784 ( A=suspension(_, active, B, D, W),
13785 B==C,
13786 D==E
13787 -> ( setarg(2, A, removed),
13788 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
13789 F),
13790 delete_ht(F, k(C, E), A)
13791 ),
13792 ( arg(2, G, H),
13793 setarg(2, G, active),
13794 ( H==not_stored_yet
13795 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13796 I),
13797 insert_ht(I, k(C, J), G)
13798 ),
13799 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13800 K),
13801 L=[G|K],
13802 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13803 L),
13804 ( K=[M|_]
13805 -> setarg(4, M, L)
13806 ; true
13807 )
13808 ),
13809 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13810 N),
13811 insert_ht(N, k(C, E, J), G)
13812 ),
13813 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13814 O),
13815 insert_ht(O, k(C, P, Q), G)
13816 ),
13817 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13818 R),
13819 insert_ht(R, k(C, E), G)
13820 ),
13821 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13822 S),
13823 insert_ht(S, P, G)
13824 ),
13825 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13826 T),
13827 insert_ht(T, k(C, P), G)
13828 ),
13829 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13830 U),
13831 insert_ht(U, k(P, Q), G)
13832 ),
13833 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13834 V),
13835 insert_ht(V, C, G)
13836 ; true
13837 )
13838 ),
13839 ( occurrence_code_id(C, E, W),
13840 X is E+1,
13841 set_occurrence_code_id(C, X, W)
13842 ),
13843 ( G=suspension(_, active, _, _, _, _, _, _, _)
13844 -> setarg(2, G, inactive),
13845 occurrence___5__14__0__54(Y,
13846 C,
13847 E,
13848 P,
13849 Q,
13850 J,
13851 G)
13852 ; true
13853 )
13854 ; occurrence___5__14__0__54(Y,
13855 C,
13856 E,
13857 P,
13858 Q,
13859 J,
13860 G)
13861 ).
13862occurrence___5__14(A, B, C, D, E, F) :-
13863 occurrence___5__15(A, B, C, D, E, F).
13864occurrence___5__15(D, J, L, M, E, A) :-
13865 arg(2, A, B),
13866 setarg(2, A, active),
13867 ( B==not_stored_yet
13868 -> ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
13869 C),
13870 insert_ht(C, k(D, E), A)
13871 ),
13872 ( nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
13873 F),
13874 G=[A|F],
13875 b_setval('$chr_store_global_ground_chr_translate____occurrence___5',
13876 G),
13877 ( F=[H|_]
13878 -> setarg(4, H, G)
13879 ; true
13880 )
13881 ),
13882 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
13883 I),
13884 insert_ht(I, k(D, J, E), A)
13885 ),
13886 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
13887 K),
13888 insert_ht(K, k(D, L, M), A)
13889 ),
13890 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13891 N),
13892 insert_ht(N, k(D, J), A)
13893 ),
13894 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
13895 O),
13896 insert_ht(O, L, A)
13897 ),
13898 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
13899 P),
13900 insert_ht(P, k(D, L), A)
13901 ),
13902 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13903 Q),
13904 insert_ht(Q, k(L, M), A)
13905 ),
13906 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13907 R),
13908 insert_ht(R, D, A)
13909 ; true
13910 ).
13911get_occurrence(B, C, G, I) :-
13912 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13913 A),
13914 lookup_ht(A, k(B, C), D),
13915 member(E, D),
13916 E=suspension(_, active, _, _, _, _, F, H, _), !,
13917 F=G,
13918 H=I.
13919get_occurrence(A, B, _, _) :-
13920 chr_error(internal,
13921 'get_occurrence: missing occurrence ~w:~w\n',
13922 [A, B]).
13923get_occurrence(B, C, G, I, K) :-
13924 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
13925 A),
13926 lookup_ht(A, k(B, C), D),
13927 member(E, D),
13928 E=suspension(_, active, _, _, _, _, F, H, J), !,
13929 F=G,
13930 H=I,
13931 J=K.
13932get_occurrence(A, B, _, _, _) :-
13933 chr_error(internal,
13934 'get_occurrence: missing occurrence ~w:~w\n',
13935 [A, B]).
13936get_occurrence_from_id(F, H, B, C) :-
13937 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
13938 A),
13939 lookup_ht(A, k(B, C), D),
13940 member(E, D),
13941 E=suspension(_, active, _, _, G, I, _, _, _), !,
13942 F=G,
13943 H=I.
13944get_occurrence_from_id(_, _, _, _) :-
13945 chr_error(internal,
13946 'get_occurrence_from_id: missing occurrence ~w:~w\n',
13947 []).
13948max_occurrence(A, B) :-
13949 max_occurrence___2__0(A, B, _).
13950max_occurrence___2__0(B, F, G) :-
13951 ( nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
13952 A),
13953 lookup_ht(A, B, C)
13954 ),
13955 ( member(D, C),
13956 D=suspension(_, active, _, _, E),
13957 E>=F, !
13958 ; !,
13959 max_occurrence___2__0__0__2(C, B, F, G)
13960 ).
13961max_occurrence___2__0__0__2([], A, B, C) :-
13962 max_occurrence___2__1(A, B, C).
13963max_occurrence___2__0__0__2([A|G], C, D, H) :-
13964 ( ( A=suspension(_, active, _, B, E),
13965 B==C
13966 ),
13967 D>=E
13968 -> ( setarg(2, A, removed),
13969 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
13970 F),
13971 delete_ht(F, C, A)
13972 ),
13973 max_occurrence___2__0__0__2(G, C, D, H)
13974 ; max_occurrence___2__0__0__2(G, C, D, H)
13975 ).
13976max_occurrence___2__0(A, B, C) :-
13977 max_occurrence___2__1(A, B, C).
13978max_occurrence___2__1(B, D, C) :-
13979 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
13980 A),
13981 lookup_ht(A, k(B, 0), F), !,
13982 C=suspension(E, not_stored_yet, t, B, D),
13983 'chr gen_id'(E),
13984 max_occurrence___2__1__0__5(F, B, D, C).
13985max_occurrence___2__1__0__5([], A, B, C) :-
13986 max_occurrence___2__2(A, B, C).
13987max_occurrence___2__1__0__5([A|H], C, I, J) :-
13988 ( ( A=suspension(_, active, _, B, G, D),
13989 B==C,
13990 D=0
13991 ),
13992 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
13993 E),
13994 lookup_ht(E, C, F)
13995 -> max_occurrence___2__1__1__5(F,
13996 G,
13997 A,
13998 H,
13999 C,
14000 I,
14001 J)
14002 ; max_occurrence___2__1__0__5(H, C, I, J)
14003 ).
14004max_occurrence___2__1__1__5([], _, _, A, B, C, D) :-
14005 max_occurrence___2__1__0__5(A, B, C, D).
14006max_occurrence___2__1__1__5([A|G], H, I, J, C, K, L) :-
14007 ( ( A=suspension(_, active, _, _, B, _, E, _, _),
14008 B==C
14009 ),
14010 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
14011 D),
14012 lookup_ht(D, E, F)
14013 -> max_occurrence___2__1__2__5(F,
14014 E,
14015 A,
14016 G,
14017 H,
14018 I,
14019 J,
14020 C,
14021 K,
14022 L)
14023 ; max_occurrence___2__1__1__5(G,
14024 H,
14025 I,
14026 J,
14027 C,
14028 K,
14029 L)
14030 ).
14031max_occurrence___2__1__2__5([], _, _, A, B, C, D, E, F, G) :-
14032 max_occurrence___2__1__1__5(A,
14033 B,
14034 C,
14035 D,
14036 E,
14037 F,
14038 G).
14039max_occurrence___2__1__2__5([A|N], D, B, O, H, E, P, L, I, F) :-
14040 ( A=suspension(_, active, _, _, _, _, C, M, _),
14041 A\==B,
14042 C==D,
14043 ( G=t(250, A, B, E, F),
14044 '$novel_production'(A, G),
14045 '$novel_production'(B, G),
14046 '$novel_production'(E, G),
14047 '$novel_production'(F, G)
14048 ),
14049 H=<I
14050 -> '$extend_history'(F, G),
14051 ( arg(2, F, J),
14052 setarg(2, F, active),
14053 ( J==not_stored_yet
14054 -> nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
14055 K),
14056 insert_ht(K, L, F)
14057 ; true
14058 )
14059 ),
14060 passive(D, M),
14061 ( F=suspension(_, active, _, _, _)
14062 -> setarg(2, F, inactive),
14063 max_occurrence___2__1__2__5(N,
14064 D,
14065 B,
14066 O,
14067 H,
14068 E,
14069 P,
14070 L,
14071 I,
14072 F)
14073 ; true
14074 )
14075 ; max_occurrence___2__1__2__5(N,
14076 D,
14077 B,
14078 O,
14079 H,
14080 E,
14081 P,
14082 L,
14083 I,
14084 F)
14085 ).
14086max_occurrence___2__1(B, C, A) :-
14087 A=suspension(D, not_stored_yet, t, B, C),
14088 'chr gen_id'(D),
14089 max_occurrence___2__2(B, C, A).
14090max_occurrence___2__2(D, _, A) :-
14091 arg(2, A, B),
14092 setarg(2, A, active),
14093 ( B==not_stored_yet
14094 -> nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
14095 C),
14096 insert_ht(C, D, A)
14097 ; true
14098 ).
14099get_max_occurrence(B, E) :-
14100 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
14101 A),
14102 lookup_ht(A, B, C),
14103 member(D, C),
14104 D=suspension(_, active, _, _, F), !,
14105 E=F.
14106get_max_occurrence(A, _) :-
14107 chr_error(internal,
14108 'get_max_occurrence: missing max occurrence for ~w\n',
14109 [A]).
14110allocation_occurrence(A, B) :-
14111 allocation_occurrence___2__0(A, B, _).
14112allocation_occurrence___2__0(B, 0, A) :- !,
14113 A=suspension(C, active, t, B, 0),
14114 'chr gen_id'(C),
14115 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14116 D),
14117 insert_ht(D, B, A),
14118 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
14119 E),
14120 insert_ht(E, k(B, 0), A),
14121 stored_in_guard_before_next_kept_occurrence(B, 0),
14122 ( A=suspension(_, active, _, _, _)
14123 -> setarg(2, A, inactive),
14124 allocation_occurrence___2__1(B, 0, A)
14125 ; true
14126 ).
14127allocation_occurrence___2__0(B, C, A) :-
14128 A=suspension(D, not_stored_yet, t, B, C),
14129 'chr gen_id'(D),
14130 allocation_occurrence___2__1(B, C, A).
14131allocation_occurrence___2__1(B, C, E) :-
14132 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
14133 A),
14134 lookup_ht(A, k(B, C), D), !,
14135 allocation_occurrence___2__1__0__2(D, B, C, E).
14136allocation_occurrence___2__1__0__2([], A, B, C) :-
14137 allocation_occurrence___2__2(A, B, C).
14138allocation_occurrence___2__1__0__2([A|K], C, E, L) :-
14139 ( ( A=suspension(_, active, _, _, B, D, G, I, J),
14140 B==C,
14141 D==E
14142 ),
14143 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14144 F),
14145 lookup_ht(F, G, H)
14146 -> allocation_occurrence___2__1__1__2(H,
14147 G,
14148 I,
14149 J,
14150 A,
14151 K,
14152 C,
14153 E,
14154 L)
14155 ; allocation_occurrence___2__1__0__2(K,
14156 C,
14157 E,
14158 L)
14159 ).
14160allocation_occurrence___2__1__1__2([], _, _, _, _, A, B, C, D) :-
14161 allocation_occurrence___2__1__0__2(A, B, C, D).
14162allocation_occurrence___2__1__1__2([A|O], C, L, M, D, P, I, K, E) :-
14163 ( A=suspension(_, active, _, _, B, N),
14164 B==C,
14165 F=t(60, A, D, E),
14166 '$novel_production'(A, F),
14167 '$novel_production'(D, F),
14168 '$novel_production'(E, F)
14169 -> '$extend_history'(E, F),
14170 ( arg(2, E, G),
14171 setarg(2, E, active),
14172 ( G==not_stored_yet
14173 -> ( nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14174 H),
14175 insert_ht(H, I, E)
14176 ),
14177 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
14178 J),
14179 insert_ht(J, k(I, K), E)
14180 ; true
14181 )
14182 ),
14183 ( \+ is_passive(C, L),
14184 M==propagation,
14185 ( stored_in_guard_before_next_kept_occurrence(I,
14186 K)
14187 -> true
14188 ; N=pragma(rule([_|_], _, _, _), _, _, _, _)
14189 -> is_observed(I, K)
14190 ; is_least_occurrence(C)
14191 -> is_observed(I, K)
14192 ; true
14193 )
14194 ),
14195 ( E=suspension(_, active, _, _, _)
14196 -> setarg(2, E, inactive),
14197 allocation_occurrence___2__1__1__2(O,
14198 C,
14199 L,
14200 M,
14201 D,
14202 P,
14203 I,
14204 K,
14205 E)
14206 ; true
14207 )
14208 ; allocation_occurrence___2__1__1__2(O,
14209 C,
14210 L,
14211 M,
14212 D,
14213 P,
14214 I,
14215 K,
14216 E)
14217 ).
14218allocation_occurrence___2__1(A, B, C) :-
14219 allocation_occurrence___2__2(A, B, C).
14220allocation_occurrence___2__2(B, D, E) :-
14221 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
14222 A),
14223 lookup_ht(A, B, C), !,
14224 allocation_occurrence___2__2__0__3(C, B, D, E).
14225allocation_occurrence___2__2__0__3([], A, B, C) :-
14226 allocation_occurrence___2__3(A, B, C).
14227allocation_occurrence___2__2__0__3([A|I], C, J, K) :-
14228 ( ( A=suspension(_, active, _, _, B, G, E, H, _),
14229 B==C
14230 ),
14231 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
14232 D),
14233 lookup_ht(D, E, F)
14234 -> allocation_occurrence___2__2__1__3(F,
14235 G,
14236 E,
14237 H,
14238 A,
14239 I,
14240 C,
14241 J,
14242 K)
14243 ; allocation_occurrence___2__2__0__3(I,
14244 C,
14245 J,
14246 K)
14247 ).
14248allocation_occurrence___2__2__1__3([], _, _, _, _, A, B, C, D) :-
14249 allocation_occurrence___2__2__0__3(A, B, C, D).
14250allocation_occurrence___2__2__1__3([A|T], H, C, F, U, V, L, G, P) :-
14251 ( ( A=suspension(_, active, B, D),
14252 B==C,
14253 D=[E|N],
14254 E==F
14255 ),
14256 G>=H,
14257 ( ( ground(C),
14258 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14259 I),
14260 lookup_ht(I, C, J)
14261 ),
14262 member(K, J),
14263 K=suspension(_, active, _, _, _, _)
14264 ),
14265 \+ may_trigger(L)
14266 -> ( setarg(2, A, removed),
14267 ( nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
14268 M),
14269 delete_ht(M, k(C, [F|N]), A)
14270 ),
14271 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
14272 O),
14273 delete_ht(O, C, A)
14274 ),
14275 ( arg(2, P, Q),
14276 setarg(2, P, active),
14277 ( Q==not_stored_yet
14278 -> ( nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14279 R),
14280 insert_ht(R, L, P)
14281 ),
14282 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
14283 S),
14284 insert_ht(S, k(L, G), P)
14285 ; true
14286 )
14287 ),
14288 least_occurrence(C, N),
14289 ( P=suspension(_, active, _, _, _)
14290 -> setarg(2, P, inactive),
14291 allocation_occurrence___2__2__1__3(T,
14292 H,
14293 C,
14294 F,
14295 U,
14296 V,
14297 L,
14298 G,
14299 P)
14300 ; true
14301 )
14302 ; allocation_occurrence___2__2__1__3(T,
14303 H,
14304 C,
14305 F,
14306 U,
14307 V,
14308 L,
14309 G,
14310 P)
14311 ).
14312allocation_occurrence___2__2(A, B, C) :-
14313 allocation_occurrence___2__3(A, B, C).
14314allocation_occurrence___2__3(B, D, E) :-
14315 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
14316 A),
14317 lookup_ht(A, B, C), !,
14318 allocation_occurrence___2__3__0__5(C, B, D, E).
14319allocation_occurrence___2__3__0__5([], A, B, C) :-
14320 allocation_occurrence___2__4(A, B, C).
14321allocation_occurrence___2__3__0__5([A|R], C, H, L) :-
14322 ( ( A=suspension(_, active, B, D, P, Q),
14323 B==C
14324 ),
14325 D>1,
14326 ( ( ( ground(C),
14327 ground(D)
14328 ),
14329 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
14330 E),
14331 lookup_ht(E, k(C, D), F)
14332 ),
14333 member(G, F),
14334 G=suspension(_, active, _, _, _, I, _, _, _)
14335 ),
14336 H>I
14337 -> ( setarg(2, A, removed),
14338 ( nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
14339 J),
14340 delete_ht(J, C, A)
14341 ),
14342 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',
14343 K),
14344 delete_ht(K, k(C, D), A)
14345 ),
14346 ( arg(2, L, M),
14347 setarg(2, L, active),
14348 ( M==not_stored_yet
14349 -> ( nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14350 N),
14351 insert_ht(N, C, L)
14352 ),
14353 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
14354 O),
14355 insert_ht(O, k(C, H), L)
14356 ; true
14357 )
14358 ),
14359 functional_dependency(C, 1, P, Q),
14360 ( L=suspension(_, active, _, _, _)
14361 -> setarg(2, L, inactive),
14362 allocation_occurrence___2__3__0__5(R,
14363 C,
14364 H,
14365 L)
14366 ; true
14367 )
14368 ; allocation_occurrence___2__3__0__5(R,
14369 C,
14370 H,
14371 L)
14372 ).
14373allocation_occurrence___2__3(A, B, C) :-
14374 allocation_occurrence___2__4(A, B, C).
14375allocation_occurrence___2__4(D, F, A) :-
14376 arg(2, A, B),
14377 setarg(2, A, active),
14378 ( B==not_stored_yet
14379 -> ( nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14380 C),
14381 insert_ht(C, D, A)
14382 ),
14383 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
14384 E),
14385 insert_ht(E, k(D, F), A)
14386 ; true
14387 ).
14388get_allocation_occurrence(B, E) :-
14389 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14390 A),
14391 lookup_ht(A, B, C),
14392 member(D, C),
14393 D=suspension(_, active, _, _, F), !,
14394 E=F.
14395get_allocation_occurrence(_, A) :-
14396 chr_pp_flag(late_allocation, off),
14397 A=0.
14398rule(A, B) :-
14399 rule___2__0(A, B, _).
14400rule___2__0(B, D, C) :-
14401 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
14402 A),
14403 lookup_ht(A, B, F), !,
14404 C=suspension(E, not_stored_yet, t, _, B, D),
14405 'chr gen_id'(E),
14406 rule___2__0__0__1(F, B, D, C).
14407rule___2__0__0__1([], A, B, C) :-
14408 rule___2__1(A, B, C).
14409rule___2__0__0__1([A|J], C, K, L) :-
14410 ( ( A=suspension(_, active, _, _, E, F, B, H, I),
14411 B==C
14412 ),
14413 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-12',
14414 D),
14415 lookup_ht(D, k(E, F), G)
14416 -> rule___2__0__1__1(G,
14417 E,
14418 F,
14419 H,
14420 I,
14421 A,
14422 J,
14423 C,
14424 K,
14425 L)
14426 ; rule___2__0__0__1(J, C, K, L)
14427 ).
14428rule___2__0__1__1([], _, _, _, _, _, A, B, C, D) :-
14429 rule___2__0__0__1(A, B, C, D).
14430rule___2__0__1__1([A|R], C, E, O, P, G, S, N, Q, F) :-
14431 ( A=suspension(_, active, _, B, D),
14432 ( B==C,
14433 D==E
14434 ),
14435 H=t(60, F, G, A),
14436 '$novel_production'(F, H),
14437 '$novel_production'(G, H),
14438 '$novel_production'(A, H)
14439 -> '$extend_history'(F, H),
14440 ( arg(2, F, I),
14441 setarg(2, F, active),
14442 ( I==not_stored_yet
14443 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14444 J),
14445 K=[F|J],
14446 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14447 K),
14448 ( J=[L|_]
14449 -> setarg(4, L, K)
14450 ; true
14451 )
14452 ),
14453 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14454 M),
14455 insert_ht(M, N, F)
14456 ; true
14457 )
14458 ),
14459 ( \+ is_passive(N, O),
14460 P==propagation,
14461 ( stored_in_guard_before_next_kept_occurrence(C, E)
14462 -> true
14463 ; Q=pragma(rule([_|_], _, _, _), _, _, _, _)
14464 -> is_observed(C, E)
14465 ; is_least_occurrence(N)
14466 -> is_observed(C, E)
14467 ; true
14468 )
14469 ),
14470 ( F=suspension(_, active, _, _, _, _)
14471 -> setarg(2, F, inactive),
14472 rule___2__0__1__1(R,
14473 C,
14474 E,
14475 O,
14476 P,
14477 G,
14478 S,
14479 N,
14480 Q,
14481 F)
14482 ; true
14483 )
14484 ; rule___2__0__1__1(R,
14485 C,
14486 E,
14487 O,
14488 P,
14489 G,
14490 S,
14491 N,
14492 Q,
14493 F)
14494 ).
14495rule___2__0(B, C, A) :-
14496 A=suspension(D, not_stored_yet, t, _, B, C),
14497 'chr gen_id'(D),
14498 rule___2__1(B, C, A).
14499rule___2__1(B, D, E) :-
14500 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
14501 A),
14502 lookup_ht(A, B, C), !,
14503 rule___2__1__0__2(C, B, D, E).
14504rule___2__1__0__2([], A, B, C) :-
14505 rule___2__2(A, B, C).
14506rule___2__1__0__2([A|X], C, Y, R) :-
14507 ( ( A=suspension(_, active, B, D),
14508 B==C,
14509 D=[E|P]
14510 ),
14511 ( ( ( ground(C),
14512 ground(E)
14513 ),
14514 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
14515 F),
14516 lookup_ht(F, k(C, E), G)
14517 ),
14518 member(H, G),
14519 H=suspension(_, active, _, _, J, N, _, _, _)
14520 ),
14521 ( ( nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
14522 I),
14523 lookup_ht(I, J, K)
14524 ),
14525 member(L, K),
14526 L=suspension(_, active, _, _, M)
14527 ),
14528 M>=N,
14529 \+ may_trigger(J)
14530 -> ( setarg(2, A, removed),
14531 ( nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
14532 O),
14533 delete_ht(O, k(C, [E|P]), A)
14534 ),
14535 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
14536 Q),
14537 delete_ht(Q, C, A)
14538 ),
14539 ( arg(2, R, S),
14540 setarg(2, R, active),
14541 ( S==not_stored_yet
14542 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14543 T),
14544 U=[R|T],
14545 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14546 U),
14547 ( T=[V|_]
14548 -> setarg(4, V, U)
14549 ; true
14550 )
14551 ),
14552 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14553 W),
14554 insert_ht(W, C, R)
14555 ; true
14556 )
14557 ),
14558 least_occurrence(C, P),
14559 ( R=suspension(_, active, _, _, _, _)
14560 -> setarg(2, R, inactive),
14561 rule___2__1__0__2(X, C, Y, R)
14562 ; true
14563 )
14564 ; rule___2__1__0__2(X, C, Y, R)
14565 ).
14566rule___2__1(A, B, C) :-
14567 rule___2__2(A, B, C).
14568rule___2__2(B, D, E) :-
14569 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
14570 A),
14571 lookup_ht(A, B, C), !,
14572 rule___2__2__0__3(C, B, D, E).
14573rule___2__2__0__3([], A, B, C) :-
14574 rule___2__3(A, B, C).
14575rule___2__2__0__3([A|R], C, S, L) :-
14576 ( ( A=suspension(_, active, B, D),
14577 B==C,
14578 D=[E|J]
14579 ),
14580 ( ( ground(C),
14581 ground(E)
14582 ),
14583 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
14584 F),
14585 lookup_ht(F, k(C, E), G)
14586 ),
14587 member(H, G),
14588 H=suspension(_, active, _, _, _)
14589 -> ( setarg(2, A, removed),
14590 ( nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
14591 I),
14592 delete_ht(I, k(C, [E|J]), A)
14593 ),
14594 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
14595 K),
14596 delete_ht(K, C, A)
14597 ),
14598 ( arg(2, L, M),
14599 setarg(2, L, active),
14600 ( M==not_stored_yet
14601 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14602 N),
14603 O=[L|N],
14604 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14605 O),
14606 ( N=[P|_]
14607 -> setarg(4, P, O)
14608 ; true
14609 )
14610 ),
14611 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14612 Q),
14613 insert_ht(Q, C, L)
14614 ; true
14615 )
14616 ),
14617 least_occurrence(C, J),
14618 ( L=suspension(_, active, _, _, _, _)
14619 -> setarg(2, L, inactive),
14620 rule___2__2__0__3(R, C, S, L)
14621 ; true
14622 )
14623 ; rule___2__2__0__3(R, C, S, L)
14624 ).
14625rule___2__2(A, B, C) :-
14626 rule___2__3(A, B, C).
14627rule___2__3(H, A, B) :-
14628 A=pragma(rule([], _, _, _), ids([], I), _, _, _), !,
14629 arg(2, B, C),
14630 setarg(2, B, active),
14631 ( C==not_stored_yet
14632 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14633 D),
14634 E=[B|D],
14635 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14636 E),
14637 ( D=[F|_]
14638 -> setarg(4, F, E)
14639 ; true
14640 )
14641 ),
14642 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14643 G),
14644 insert_ht(G, H, B)
14645 ; true
14646 ),
14647 least_occurrence(H, I),
14648 ( B=suspension(_, active, _, _, _, _)
14649 -> setarg(2, B, inactive),
14650 rule___2__4(H, A, B)
14651 ; true
14652 ).
14653rule___2__3(A, B, C) :-
14654 rule___2__4(A, B, C).
14655rule___2__4(B, E, S) :-
14656 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
14657 A),
14658 lookup_ht(A, B, C),
14659 member(D, C),
14660 D=suspension(_, active, _, _, _, F1, F, H, G, _),
14661 E=pragma(rule(Z, A1, F, L), C1, D1, E1, B),
14662 F\==true,
14663 append(G, H, I),
14664 ( conj2list(F, J),
14665 append(I, J, K),
14666 guard_entailment:entails_guard(K, fail)
14667 -> M=fail
14668 ; simplify_guard(F, L, I, M, B1)
14669 ),
14670 F\==M, !,
14671 setarg(2, D, removed),
14672 arg(4, D, N),
14673 ( var(N)
14674 -> nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
14675 O),
14676 O=[_|P],
14677 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
14678 P),
14679 ( P=[Q|_]
14680 -> setarg(4, Q, _)
14681 ; true
14682 )
14683 ; N=[_, _|P],
14684 setarg(2, N, P),
14685 ( P=[Q|_]
14686 -> setarg(4, Q, N)
14687 ; true
14688 )
14689 ),
14690 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
14691 R),
14692 delete_ht(R, B, D),
14693 ( var(S)
14694 -> true
14695 ; arg(2, S, T),
14696 setarg(2, S, removed),
14697 ( T==not_stored_yet
14698 -> true
14699 ; ( arg(4, S, U),
14700 ( var(U)
14701 -> nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14702 V),
14703 V=[_|W],
14704 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14705 W),
14706 ( W=[X|_]
14707 -> setarg(4, X, _)
14708 ; true
14709 )
14710 ; U=[_, _|W],
14711 setarg(2, U, W),
14712 ( W=[X|_]
14713 -> setarg(4, X, U)
14714 ; true
14715 )
14716 )
14717 ),
14718 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14719 Y),
14720 delete_ht(Y, B, S)
14721 )
14722 ),
14723 rule(B,
14724 pragma(rule(Z, A1, M, B1),
14725 C1,
14726 D1,
14727 E1,
14728 B)),
14729 prev_guard_list(B, F1, M, H, G, []).
14730rule___2__4(B, C, D) :-
14731 nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
14732 A), !,
14733 rule___2__4__0__10(A, B, C, D).
14734rule___2__4__0__10([], A, B, C) :-
14735 rule___2__5(A, B, C).
14736rule___2__4__0__10([A|R], I, J, B) :-
14737 ( A=suspension(_, active, _, _),
14738 C=t(174, B, A),
14739 '$novel_production'(B, C),
14740 '$novel_production'(A, C)
14741 -> '$extend_history'(B, C),
14742 ( arg(2, B, D),
14743 setarg(2, B, active),
14744 ( D==not_stored_yet
14745 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14746 E),
14747 F=[B|E],
14748 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14749 F),
14750 ( E=[G|_]
14751 -> setarg(4, G, F)
14752 ; true
14753 )
14754 ),
14755 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14756 H),
14757 insert_ht(H, I, B)
14758 ; true
14759 )
14760 ),
14761 ( J=pragma(rule(K, L, _, _), _, _, _, _),
14762 append(K, L, M),
14763 make_head_matchings_explicit_(M, N, O),
14764 copy_term_nat(N-O, P-Q),
14765 make_head_matchings_explicit_memo_table(I,
14766 P,
14767 Q)
14768 ),
14769 ( B=suspension(_, active, _, _, _, _)
14770 -> setarg(2, B, inactive),
14771 rule___2__4__0__10(R, I, J, B)
14772 ; true
14773 )
14774 ; rule___2__4__0__10(R, I, J, B)
14775 ).
14776rule___2__4(A, B, C) :-
14777 rule___2__5(A, B, C).
14778rule___2__5(B, D, E) :-
14779 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
14780 A),
14781 lookup_ht(A, B, C), !,
14782 rule___2__5__0__11(C, B, D, E).
14783rule___2__5__0__11([], A, B, C) :-
14784 rule___2__6(A, B, C).
14785rule___2__5__0__11([A|R], C, F, D) :-
14786 ( A=suspension(_, active, _, _, B, _, G, I, H, _),
14787 B==C,
14788 ( E=t(178, A, D),
14789 '$novel_production'(A, E),
14790 '$novel_production'(D, E)
14791 ),
14792 chr_pp_flag(check_impossible_rules, on),
14793 F=pragma(rule(_, _, G, _), _, _, _, C),
14794 conj2list(G, K),
14795 append(H, I, J),
14796 append(J, K, L),
14797 guard_entailment:entails_guard(L, fail)
14798 -> '$extend_history'(D, E),
14799 ( arg(2, D, M),
14800 setarg(2, D, active),
14801 ( M==not_stored_yet
14802 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14803 N),
14804 O=[D|N],
14805 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14806 O),
14807 ( N=[P|_]
14808 -> setarg(4, P, O)
14809 ; true
14810 )
14811 ),
14812 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14813 Q),
14814 insert_ht(Q, C, D)
14815 ; true
14816 )
14817 ),
14818 ( chr_warning(weird_program,
14819 'Heads will never match or guard will always fail in ~@.\n\tThis rule will never fire!\n',
14820 [format_rule(F)]),
14821 set_all_passive(C)
14822 ),
14823 ( D=suspension(_, active, _, _, _, _)
14824 -> setarg(2, D, inactive),
14825 rule___2__5__0__11(R, C, F, D)
14826 ; true
14827 )
14828 ; rule___2__5__0__11(R, C, F, D)
14829 ).
14830rule___2__5(A, B, C) :-
14831 rule___2__6(A, B, C).
14832rule___2__6(B, E, B1) :-
14833 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
14834 A),
14835 lookup_ht(A, B, C),
14836 member(D, C),
14837 D=suspension(_, active, _, _, _, M, F, H, G, _),
14838 E=pragma(rule(K, L, F, I), Y, Z, A1, B),
14839 simplify_heads(G, H, F, I, J, S),
14840 J\==[],
14841 extract_arguments(K, N),
14842 extract_arguments(L, O),
14843 extract_arguments(M, P),
14844 replace_some_heads(N,
14845 O,
14846 P,
14847 J,
14848 Q,
14849 R,
14850 F,
14851 I,
14852 T),
14853 substitute_arguments(K, Q, V),
14854 substitute_arguments(L, R, W),
14855 append(S, T, U),
14856 list2conj(U, X),
14857 I1=pragma(rule(V, W, F, (X, I)), Y, Z, A1, B),
14858 ( K\==V
14859 ; L\==W
14860 ), !,
14861 ( var(B1)
14862 -> true
14863 ; arg(2, B1, C1),
14864 setarg(2, B1, removed),
14865 ( C1==not_stored_yet
14866 -> true
14867 ; ( arg(4, B1, D1),
14868 ( var(D1)
14869 -> nb_getval('$chr_store_global_ground_chr_translate____rule___2',
14870 E1),
14871 E1=[_|F1],
14872 b_setval('$chr_store_global_ground_chr_translate____rule___2',
14873 F1),
14874 ( F1=[G1|_]
14875 -> setarg(4, G1, _)
14876 ; true
14877 )
14878 ; D1=[_, _|F1],
14879 setarg(2, D1, F1),
14880 ( F1=[G1|_]
14881 -> setarg(4, G1, D1)
14882 ; true
14883 )
14884 )
14885 ),
14886 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
14887 H1),
14888 delete_ht(H1, B, B1)
14889 )
14890 ),
14891 rule(B, I1).
14892rule___2__6(B, D, E) :-
14893 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
14894 A),
14895 lookup_ht(A, B, C), !,
14896 rule___2__6__0__13(C, B, D, E).
14897rule___2__6__0__13([], A, B, C) :-
14898 rule___2__7(A, B, C).
14899rule___2__6__0__13([A|H], C, I, J) :-
14900 ( ( A=suspension(_, active, _, _, E, G, B, _, _),
14901 B==C
14902 ),
14903 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
14904 D),
14905 lookup_ht(D, k(E, C), F)
14906 -> rule___2__6__1__13(F,
14907 E,
14908 G,
14909 A,
14910 H,
14911 C,
14912 I,
14913 J)
14914 ; rule___2__6__0__13(H, C, I, J)
14915 ).
14916rule___2__6__1__13([], _, _, _, A, B, C, D) :-
14917 rule___2__6__0__13(A, B, C, D).
14918rule___2__6__1__13([A|K], D, L, B, M, F, N, O) :-
14919 ( ( A=suspension(_, active, _, _, C, I, E, J, _),
14920 A\==B,
14921 C==D,
14922 E==F
14923 ),
14924 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
14925 G),
14926 lookup_ht(G, F, H)
14927 -> rule___2__6__2__13(H,
14928 I,
14929 J,
14930 A,
14931 K,
14932 D,
14933 L,
14934 B,
14935 M,
14936 F,
14937 N,
14938 O)
14939 ; rule___2__6__1__13(K,
14940 D,
14941 L,
14942 B,
14943 M,
14944 F,
14945 N,
14946 O)
14947 ).
14948rule___2__6__2__13([], _, _, _, A, B, C, D, E, F, G, H) :-
14949 rule___2__6__1__13(A,
14950 B,
14951 C,
14952 D,
14953 E,
14954 F,
14955 G,
14956 H).
14957rule___2__6__2__13([A|E], F, G, H, I, J, K, L, M, C, N, O) :-
14958 ( ( A=suspension(_, active, _, _, B, _, _, _, _, _),
14959 B==C
14960 ),
14961 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
14962 D)
14963 -> rule___2__6__3__13(D,
14964 A,
14965 E,
14966 F,
14967 G,
14968 H,
14969 I,
14970 J,
14971 K,
14972 L,
14973 M,
14974 C,
14975 N,
14976 O)
14977 ; rule___2__6__2__13(E,
14978 F,
14979 G,
14980 H,
14981 I,
14982 J,
14983 K,
14984 L,
14985 M,
14986 C,
14987 N,
14988 O)
14989 ).
14990rule___2__6__3__13([], _, A, B, C, D, E, F, G, H, I, J, K, L) :-
14991 rule___2__6__2__13(A,
14992 B,
14993 C,
14994 D,
14995 E,
14996 F,
14997 G,
14998 H,
14999 I,
15000 J,
15001 K,
15002 L).
15003rule___2__6__3__13([A|U], V, W, B, S, X, Y, F, C, Z, A1, R, D, L) :-
15004 ( A=suspension(_, active, _, G),
15005 B<C,
15006 chr_pp_flag(occurrence_subsumption, on),
15007 D=pragma(rule(E, _, _, _), _, _, _, _),
15008 E\==[],
15009 \+ tree_set_memberchk(F, G)
15010 -> ( setarg(2, A, removed),
15011 arg(3, A, H),
15012 ( var(H)
15013 -> nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
15014 I),
15015 I=[_|J],
15016 b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
15017 J),
15018 ( J=[K|_]
15019 -> setarg(3, K, _)
15020 ; true
15021 )
15022 ; H=[_, _|J],
15023 setarg(2, H, J),
15024 ( J=[K|_]
15025 -> setarg(3, K, H)
15026 ; true
15027 )
15028 )
15029 ),
15030 ( arg(2, L, M),
15031 setarg(2, L, active),
15032 ( M==not_stored_yet
15033 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
15034 N),
15035 O=[L|N],
15036 b_setval('$chr_store_global_ground_chr_translate____rule___2',
15037 O),
15038 ( N=[P|_]
15039 -> setarg(4, P, O)
15040 ; true
15041 )
15042 ),
15043 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
15044 Q),
15045 insert_ht(Q, R, L)
15046 ; true
15047 )
15048 ),
15049 ( first_occ_in_rule(R, F, B, S),
15050 tree_set_add(G, F, T),
15051 multiple_occ_constraints_checked(T)
15052 ),
15053 ( L=suspension(_, active, _, _, _, _)
15054 -> setarg(2, L, inactive),
15055 rule___2__6__3__13(U,
15056 V,
15057 W,
15058 B,
15059 S,
15060 X,
15061 Y,
15062 F,
15063 C,
15064 Z,
15065 A1,
15066 R,
15067 D,
15068 L)
15069 ; true
15070 )
15071 ; rule___2__6__3__13(U,
15072 V,
15073 W,
15074 B,
15075 S,
15076 X,
15077 Y,
15078 F,
15079 C,
15080 Z,
15081 A1,
15082 R,
15083 D,
15084 L)
15085 ).
15086rule___2__6(A, B, C) :-
15087 rule___2__7(A, B, C).
15088rule___2__7(B, D, E) :-
15089 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
15090 A),
15091 lookup_ht(A, B, C), !,
15092 rule___2__7__0__15(C, B, D, E).
15093rule___2__7__0__15([], A, B, C) :-
15094 rule___2__8(A, B, C).
15095rule___2__7__0__15([A|P], C, F, D) :-
15096 ( A=suspension(_, active, _, B, G),
15097 B==C,
15098 ( E=t(251, D, A),
15099 '$novel_production'(D, E),
15100 '$novel_production'(A, E)
15101 ),
15102 F=pragma(rule(_, _, _, _), ids([G|M], N), _, _, C)
15103 -> '$extend_history'(D, E),
15104 ( arg(2, D, H),
15105 setarg(2, D, active),
15106 ( H==not_stored_yet
15107 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
15108 I),
15109 J=[D|I],
15110 b_setval('$chr_store_global_ground_chr_translate____rule___2',
15111 J),
15112 ( I=[K|_]
15113 -> setarg(4, K, J)
15114 ; true
15115 )
15116 ),
15117 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
15118 L),
15119 insert_ht(L, C, D)
15120 ; true
15121 )
15122 ),
15123 ( append(M, N, O),
15124 check_all_passive(C, O)
15125 ),
15126 ( D=suspension(_, active, _, _, _, _)
15127 -> setarg(2, D, inactive),
15128 rule___2__7__0__15(P, C, F, D)
15129 ; true
15130 )
15131 ; rule___2__7__0__15(P, C, F, D)
15132 ).
15133rule___2__7(A, B, C) :-
15134 rule___2__8(A, B, C).
15135rule___2__8(B, D, E) :-
15136 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
15137 A),
15138 lookup_ht(A, B, C), !,
15139 rule___2__8__0__16(C, B, D, E).
15140rule___2__8__0__16([], A, B, C) :-
15141 rule___2__9(A, B, C).
15142rule___2__8__0__16([A|N], C, F, D) :-
15143 ( A=suspension(_, active, _, B, G),
15144 B==C,
15145 ( E=t(252, D, A),
15146 '$novel_production'(D, E),
15147 '$novel_production'(A, E)
15148 ),
15149 F=pragma(rule(_, _, _, _), ids([], [G|M]), _, _, C)
15150 -> '$extend_history'(D, E),
15151 ( arg(2, D, H),
15152 setarg(2, D, active),
15153 ( H==not_stored_yet
15154 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
15155 I),
15156 J=[D|I],
15157 b_setval('$chr_store_global_ground_chr_translate____rule___2',
15158 J),
15159 ( I=[K|_]
15160 -> setarg(4, K, J)
15161 ; true
15162 )
15163 ),
15164 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
15165 L),
15166 insert_ht(L, C, D)
15167 ; true
15168 )
15169 ),
15170 check_all_passive(C, M),
15171 ( D=suspension(_, active, _, _, _, _)
15172 -> setarg(2, D, inactive),
15173 rule___2__8__0__16(N, C, F, D)
15174 ; true
15175 )
15176 ; rule___2__8__0__16(N, C, F, D)
15177 ).
15178rule___2__8(A, B, C) :-
15179 rule___2__9(A, B, C).
15180rule___2__9(B, D, E) :-
15181 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
15182 A),
15183 lookup_ht(A, k(B, []), C), !,
15184 rule___2__9__0__17(C, B, D, E).
15185rule___2__9__0__17([], A, B, C) :-
15186 rule___2__10(A, B, C).
15187rule___2__9__0__17([A|N], C, M, G) :-
15188 ( A=suspension(_, active, B, D),
15189 B==C,
15190 D=[]
15191 -> ( setarg(2, A, removed),
15192 ( nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
15193 E),
15194 delete_ht(E, k(C, []), A)
15195 ),
15196 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',
15197 F),
15198 delete_ht(F, C, A)
15199 ),
15200 ( arg(2, G, H),
15201 setarg(2, G, active),
15202 ( H==not_stored_yet
15203 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
15204 I),
15205 J=[G|I],
15206 b_setval('$chr_store_global_ground_chr_translate____rule___2',
15207 J),
15208 ( I=[K|_]
15209 -> setarg(4, K, J)
15210 ; true
15211 )
15212 ),
15213 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
15214 L),
15215 insert_ht(L, C, G)
15216 ; true
15217 )
15218 ),
15219 chr_warning(weird_program,
15220 'All heads passive in ~@.\n\tThis rule never fires. Please check your program.\n',
15221 [format_rule(M)]),
15222 ( G=suspension(_, active, _, _, _, _)
15223 -> setarg(2, G, inactive),
15224 rule___2__9__0__17(N, C, M, G)
15225 ; true
15226 )
15227 ; rule___2__9__0__17(N, C, M, G)
15228 ).
15229rule___2__9(A, B, C) :-
15230 rule___2__10(A, B, C).
15231rule___2__10(B, D, E) :-
15232 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
15233 A),
15234 lookup_ht(A, B, C), !,
15235 rule___2__10__0__22(C, B, D, E).
15236rule___2__10__0__22([], A, B, C) :-
15237 rule___2__11(A, B, C).
15238rule___2__10__0__22([A|H], C, I, J) :-
15239 ( ( A=suspension(_, active, _, _, E, _, B, F, G),
15240 B==C
15241 ),
15242 nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
15243 D)
15244 -> rule___2__10__1__22(D,
15245 E,
15246 F,
15247 G,
15248 A,
15249 H,
15250 C,
15251 I,
15252 J)
15253 ; rule___2__10__0__22(H, C, I, J)
15254 ).
15255rule___2__10__1__22([], _, _, _, _, A, B, C, D) :-
15256 rule___2__10__0__22(A, B, C, D).
15257rule___2__10__1__22([A|E], C, F, G, H, I, J, K, L) :-
15258 ( A=suspension(_, active, _, _),
15259 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
15260 B),
15261 lookup_ht(B, C, D)
15262 -> rule___2__10__2__22(D,
15263 A,
15264 E,
15265 C,
15266 F,
15267 G,
15268 H,
15269 I,
15270 J,
15271 K,
15272 L)
15273 ; rule___2__10__1__22(E,
15274 C,
15275 F,
15276 G,
15277 H,
15278 I,
15279 J,
15280 K,
15281 L)
15282 ).
15283rule___2__10__2__22([], _, A, B, C, D, E, F, G, H, I) :-
15284 rule___2__10__1__22(A,
15285 B,
15286 C,
15287 D,
15288 E,
15289 F,
15290 G,
15291 H,
15292 I).
15293rule___2__10__2__22([A|X], D, Y, C, O, P, E, Z, M, N, F) :-
15294 ( A=suspension(_, active, _, _, B, U),
15295 B==C,
15296 G=t(330, D, E, F, A),
15297 '$novel_production'(D, G),
15298 '$novel_production'(E, G),
15299 '$novel_production'(F, G),
15300 '$novel_production'(A, G)
15301 -> '$extend_history'(F, G),
15302 ( arg(2, F, H),
15303 setarg(2, F, active),
15304 ( H==not_stored_yet
15305 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
15306 I),
15307 J=[F|I],
15308 b_setval('$chr_store_global_ground_chr_translate____rule___2',
15309 J),
15310 ( I=[K|_]
15311 -> setarg(4, K, J)
15312 ; true
15313 )
15314 ),
15315 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
15316 L),
15317 insert_ht(L, M, F)
15318 ; true
15319 )
15320 ),
15321 ( N=pragma(rule(Q, W, S, _), _, _, _, _),
15322 ( is_passive(M, O)
15323 -> true
15324 ; P==simplification
15325 -> select(R, Q, _),
15326 R=..[_|T],
15327 term_variables(S, V),
15328 partial_wake_args(T, U, V, C)
15329 ; select(R, W, _),
15330 R=..[_|T],
15331 term_variables(S, V),
15332 partial_wake_args(T, U, V, C)
15333 )
15334 ),
15335 ( F=suspension(_, active, _, _, _, _)
15336 -> setarg(2, F, inactive),
15337 rule___2__10__2__22(X,
15338 D,
15339 Y,
15340 C,
15341 O,
15342 P,
15343 E,
15344 Z,
15345 M,
15346 N,
15347 F)
15348 ; true
15349 )
15350 ; rule___2__10__2__22(X,
15351 D,
15352 Y,
15353 C,
15354 O,
15355 P,
15356 E,
15357 Z,
15358 M,
15359 N,
15360 F)
15361 ).
15362rule___2__10(A, B, C) :-
15363 rule___2__11(A, B, C).
15364rule___2__11(G, _, A) :-
15365 arg(2, A, B),
15366 setarg(2, A, active),
15367 ( B==not_stored_yet
15368 -> ( nb_getval('$chr_store_global_ground_chr_translate____rule___2',
15369 C),
15370 D=[A|C],
15371 b_setval('$chr_store_global_ground_chr_translate____rule___2',
15372 D),
15373 ( C=[E|_]
15374 -> setarg(4, E, D)
15375 ; true
15376 )
15377 ),
15378 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
15379 F),
15380 insert_ht(F, G, A)
15381 ; true
15382 ).
15383get_rule(B, E) :-
15384 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
15385 lookup_ht(A, B, C),
15386 member(D, C),
15387 D=suspension(_, active, _, _, _, F), !,
15388 E=F.
15389get_rule(_, _) :-
15390 fail.
15391least_occurrence(B, [F|O]) :-
15392 ( nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
15393 lookup_ht(A, B, C),
15394 member(D, C),
15395 D=suspension(_, active, _, _, _, _)
15396 ),
15397 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
15398 E),
15399 lookup_ht(E, k(B, F), G),
15400 member(H, G),
15401 H=suspension(_, active, _, _, J, N, _, _, _),
15402 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
15403 I),
15404 lookup_ht(I, J, K),
15405 member(L, K),
15406 L=suspension(_, active, _, _, M),
15407 M>=N,
15408 \+ may_trigger(J), !,
15409 least_occurrence(B, O)
15410 ; nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
15411 P),
15412 lookup_ht(P, k(B, F), Q),
15413 member(R, Q),
15414 R=suspension(_, active, _, _, _), !,
15415 least_occurrence(B, O)
15416 ).
15417least_occurrence(A, B) :-
15418 E=suspension(C, active, A, B),
15419 'chr gen_id'(C),
15420 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
15421 D),
15422 insert_ht(D, k(A, B), E),
15423 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-1',
15424 F),
15425 insert_ht(F, A, E).
15426is_least_occurrence(B) :-
15427 nb_getval('$chr_store_multi_hash_chr_translate____least_occurrence___2-12',
15428 A),
15429 lookup_ht(A, k(B, []), C),
15430 member(D, C),
15431 D=suspension(_, active, _, _), !.
15432is_least_occurrence(_) :-
15433 fail.
15434stored_in_guard_lookahead(B, C) :-
15435 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
15436 A),
15437 lookup_ht(A, k(B, C), D),
15438 member(E, D),
15439 E=suspension(_, active, _, _, _, _, G, H, L)
15440 ),
15441 ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
15442 F),
15443 lookup_ht(F, k(G, H), I),
15444 member(J, I),
15445 J=suspension(_, active, _, _, _), !,
15446 K is C+1,
15447 stored_in_guard_lookahead(B, K)
15448 ; !,
15449 L==simplification,
15450 ( is_stored_in_guard(B, G)
15451 -> true
15452 ; M is C+1,
15453 stored_in_guard_lookahead(B, M)
15454 )
15455 ).
15456stored_in_guard_lookahead(_, _) :-
15457 fail.
15458constraint_index(A, B) :-
15459 E=suspension(C, active, A, B),
15460 'chr gen_id'(C),
15461 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',
15462 D),
15463 insert_ht(D, B, E),
15464 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',
15465 F),
15466 insert_ht(F, A, E).
15467get_constraint_index(B, E) :-
15468 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-1',
15469 A),
15470 lookup_ht(A, B, C),
15471 member(D, C),
15472 D=suspension(_, active, _, F), !,
15473 E=F.
15474get_constraint_index(_, _) :-
15475 fail.
15476get_indexed_constraint(B, E) :-
15477 nb_getval('$chr_store_multi_hash_chr_translate____constraint_index___2-2',
15478 A),
15479 lookup_ht(A, B, C),
15480 member(D, C),
15481 D=suspension(_, active, F, _), !,
15482 E=F.
15483get_indexed_constraint(_, _) :-
15484 fail.
15485max_constraint_index(A) :-
15486 C=suspension(B, active, _, A),
15487 'chr gen_id'(B),
15488 nb_getval('$chr_store_global_ground_chr_translate____max_constraint_index___1',
15489 D),
15490 E=[C|D],
15491 b_setval('$chr_store_global_ground_chr_translate____max_constraint_index___1',
15492 E),
15493 ( D=[F|_]
15494 -> setarg(3, F, E)
15495 ; true
15496 ).
15497get_max_constraint_index(C) :-
15498 nb_getval('$chr_store_global_ground_chr_translate____max_constraint_index___1',
15499 A),
15500 member(B, A),
15501 B=suspension(_, active, _, D), !,
15502 C=D.
15503get_max_constraint_index(0).
15504identifier_size(C) :-
15505 nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
15506 A),
15507 ( member(B, A),
15508 B=suspension(_, active, _, _), !
15509 ; !,
15510 identifier_size___1__0__0__2(A, C)
15511 ).
15512identifier_size___1__0__0__2([], A) :-
15513 identifier_size___1__1(A).
15514identifier_size___1__0__0__2([A|F], G) :-
15515 ( A=suspension(_, active, _, _)
15516 -> ( setarg(2, A, removed),
15517 arg(3, A, B),
15518 ( var(B)
15519 -> nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
15520 C),
15521 C=[_|D],
15522 b_setval('$chr_store_global_ground_chr_translate____identifier_size___1',
15523 D),
15524 ( D=[E|_]
15525 -> setarg(3, E, _)
15526 ; true
15527 )
15528 ; B=[_, _|D],
15529 setarg(2, B, D),
15530 ( D=[E|_]
15531 -> setarg(3, E, B)
15532 ; true
15533 )
15534 )
15535 ),
15536 identifier_size___1__0__0__2(F, G)
15537 ; identifier_size___1__0__0__2(F, G)
15538 ).
15539identifier_size(A) :-
15540 identifier_size___1__1(A).
15541identifier_size___1__1(A) :-
15542 C=suspension(B, active, _, A),
15543 'chr gen_id'(B),
15544 nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
15545 D),
15546 E=[C|D],
15547 b_setval('$chr_store_global_ground_chr_translate____identifier_size___1',
15548 E),
15549 ( D=[F|_]
15550 -> setarg(3, F, E)
15551 ; true
15552 ).
15553get_identifier_size(C) :-
15554 nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
15555 A),
15556 member(B, A),
15557 B=suspension(_, active, _, D), !,
15558 C=D.
15559get_identifier_size(1).
15560identifier_index(B, C, F) :-
15561 ( nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
15562 A),
15563 lookup_ht(A, k(B, C), D)
15564 ),
15565 ( member(E, D),
15566 E=suspension(_, active, _, _, _), !
15567 ; !,
15568 identifier_index___3__0__0__2(D, B, C, F)
15569 ).
15570identifier_index___3__0__0__2([], A, B, C) :-
15571 identifier_index___3__1(A, B, C).
15572identifier_index___3__0__0__2([A|G], C, E, H) :-
15573 ( A=suspension(_, active, B, D, _),
15574 B==C,
15575 D==E
15576 -> ( setarg(2, A, removed),
15577 nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
15578 F),
15579 delete_ht(F, k(C, E), A)
15580 ),
15581 identifier_index___3__0__0__2(G, C, E, H)
15582 ; identifier_index___3__0__0__2(G, C, E, H)
15583 ).
15584identifier_index(A, B, C) :-
15585 identifier_index___3__1(A, B, C).
15586identifier_index___3__1(A, B, C) :-
15587 F=suspension(D, active, A, B, C),
15588 'chr gen_id'(D),
15589 nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
15590 E),
15591 insert_ht(E, k(A, B), F).
15592get_identifier_index(B, C, F) :-
15593 nb_getval('$chr_store_multi_hash_chr_translate____identifier_index___3-12',
15594 A),
15595 lookup_ht(A, k(B, C), D),
15596 member(E, D),
15597 E=suspension(_, active, _, _, G), !,
15598 F=G.
15599get_identifier_index(H, I, K) :-
15600 nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
15601 A),
15602 member(B, A),
15603 B=suspension(_, active, _, G), !,
15604 setarg(2, B, removed),
15605 arg(3, B, C),
15606 ( var(C)
15607 -> nb_getval('$chr_store_global_ground_chr_translate____identifier_size___1',
15608 D),
15609 D=[_|E],
15610 b_setval('$chr_store_global_ground_chr_translate____identifier_size___1',
15611 E),
15612 ( E=[F|_]
15613 -> setarg(3, F, _)
15614 ; true
15615 )
15616 ; C=[_, _|E],
15617 setarg(2, C, E),
15618 ( E=[F|_]
15619 -> setarg(3, F, C)
15620 ; true
15621 )
15622 ),
15623 J is G+1,
15624 identifier_index(H, I, J),
15625 identifier_size(J),
15626 K=J.
15627get_identifier_index(A, B, C) :-
15628 identifier_index(A, B, 2),
15629 identifier_size(2),
15630 C=2.
15631type_indexed_identifier_size(B, E) :-
15632 ( nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
15633 A),
15634 lookup_ht(A, B, C)
15635 ),
15636 ( member(D, C),
15637 D=suspension(_, active, _, _), !
15638 ; !,
15639 type_indexed_identifier_size___2__0__0__2(C, B, E)
15640 ).
15641type_indexed_identifier_size___2__0__0__2([], A, B) :-
15642 type_indexed_identifier_size___2__1(A, B).
15643type_indexed_identifier_size___2__0__0__2([A|E], C, F) :-
15644 ( A=suspension(_, active, B, _),
15645 B==C
15646 -> ( setarg(2, A, removed),
15647 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
15648 D),
15649 delete_ht(D, C, A)
15650 ),
15651 type_indexed_identifier_size___2__0__0__2(E, C, F)
15652 ; type_indexed_identifier_size___2__0__0__2(E, C, F)
15653 ).
15654type_indexed_identifier_size(A, B) :-
15655 type_indexed_identifier_size___2__1(A, B).
15656type_indexed_identifier_size___2__1(A, B) :-
15657 E=suspension(C, active, A, B),
15658 'chr gen_id'(C),
15659 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
15660 D),
15661 insert_ht(D, A, E).
15662get_type_indexed_identifier_size(B, E) :-
15663 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
15664 A),
15665 lookup_ht(A, B, C),
15666 member(D, C),
15667 D=suspension(_, active, _, F), !,
15668 E=F.
15669get_type_indexed_identifier_size(_, 1).
15670type_indexed_identifier_index(F, B, C, G) :-
15671 ( nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',
15672 A),
15673 lookup_ht(A, k(B, C), D)
15674 ),
15675 ( member(E, D),
15676 E=suspension(_, active, _, _, _, _), !
15677 ; !,
15678 type_indexed_identifier_index___4__0__0__2(D,
15679 F,
15680 B,
15681 C,
15682 G)
15683 ).
15684type_indexed_identifier_index___4__0__0__2([], A, B, C, D) :-
15685 type_indexed_identifier_index___4__1(A, B, C, D).
15686type_indexed_identifier_index___4__0__0__2([A|I], J, C, E, K) :-
15687 ( A=suspension(_, active, G, B, D, _),
15688 B==C,
15689 D==E
15690 -> ( setarg(2, A, removed),
15691 ( nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',
15692 F),
15693 delete_ht(F, k(G, C, E), A)
15694 ),
15695 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',
15696 H),
15697 delete_ht(H, k(C, E), A)
15698 ),
15699 type_indexed_identifier_index___4__0__0__2(I,
15700 J,
15701 C,
15702 E,
15703 K)
15704 ; type_indexed_identifier_index___4__0__0__2(I,
15705 J,
15706 C,
15707 E,
15708 K)
15709 ).
15710type_indexed_identifier_index(A, B, C, D) :-
15711 type_indexed_identifier_index___4__1(A, B, C, D).
15712type_indexed_identifier_index___4__1(A, B, C, D) :-
15713 G=suspension(E, active, A, B, C, D),
15714 'chr gen_id'(E),
15715 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',
15716 F),
15717 insert_ht(F, k(A, B, C), G),
15718 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-23',
15719 H),
15720 insert_ht(H, k(B, C), G).
15721get_type_indexed_identifier_index(B, C, D, G) :-
15722 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_index___4-123',
15723 A),
15724 lookup_ht(A, k(B, C, D), E),
15725 member(F, E),
15726 F=suspension(_, active, _, _, _, H), !,
15727 G=H.
15728get_type_indexed_identifier_index(B, G, H, J) :-
15729 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
15730 A),
15731 lookup_ht(A, B, C),
15732 member(D, C),
15733 D=suspension(_, active, _, F), !,
15734 setarg(2, D, removed),
15735 nb_getval('$chr_store_multi_hash_chr_translate____type_indexed_identifier_size___2-1',
15736 E),
15737 delete_ht(E, B, D),
15738 I is F+1,
15739 type_indexed_identifier_index(B, G, H, I),
15740 type_indexed_identifier_size(B, I),
15741 J=I.
15742get_type_indexed_identifier_index(A, B, C, D) :-
15743 type_indexed_identifier_index(A, B, C, 2),
15744 type_indexed_identifier_size(A, 2),
15745 D=2.
15746no_history(A) :-
15747 D=suspension(B, active, A),
15748 'chr gen_id'(B),
15749 nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',
15750 C),
15751 insert_ht(C, A, D).
15752has_no_history(B) :-
15753 nb_getval('$chr_store_multi_hash_chr_translate____no_history___1-1',
15754 A),
15755 lookup_ht(A, B, C),
15756 member(D, C),
15757 D=suspension(_, active, _), !.
15758has_no_history(_) :-
15759 fail.
15760history(A, B, C) :-
15761 history___3__0(A, B, C, _).
15762history___3__0(B, D, E, C) :-
15763 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
15764 A),
15765 lookup_ht(A, B, G), !,
15766 C=suspension(F, not_stored_yet, t, B, D, E),
15767 'chr gen_id'(F),
15768 history___3__0__0__1(G, B, D, E, C).
15769history___3__0__0__1([], A, B, C, D) :-
15770 history___3__1(A, B, C, D).
15771history___3__0__0__1([A|M], C, K, G, D) :-
15772 ( A=suspension(_, active, _, B, _, _),
15773 B==C,
15774 E=t(95, D, A),
15775 '$novel_production'(D, E),
15776 '$novel_production'(A, E)
15777 -> '$extend_history'(D, E),
15778 ( arg(2, D, F),
15779 setarg(2, D, active),
15780 ( F==not_stored_yet
15781 -> ( '$chr_store_constants_chr_translate____history___3___[3]'(G,
15782 H)
15783 -> nb_getval(H, I),
15784 b_setval(H, [D|I])
15785 ; true
15786 ),
15787 ( nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
15788 J),
15789 insert_ht(J, K, D)
15790 ),
15791 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
15792 L),
15793 insert_ht(L, C, D)
15794 ; true
15795 )
15796 ),
15797 chr_error(syntax,
15798 'Only one pragma history allowed per rule (rule number ~w)\n',
15799 [C]),
15800 ( D=suspension(_, active, _, _, _, _)
15801 -> setarg(2, D, inactive),
15802 history___3__0__0__1(M,
15803 C,
15804 K,
15805 G,
15806 D)
15807 ; true
15808 )
15809 ; history___3__0__0__1(M, C, K, G, D)
15810 ).
15811history___3__0(B, C, D, A) :-
15812 A=suspension(E, not_stored_yet, t, B, C, D),
15813 'chr gen_id'(E),
15814 history___3__1(B, C, D, A).
15815history___3__1(B, D, E, F) :-
15816 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
15817 A),
15818 lookup_ht(A, B, C), !,
15819 history___3__1__0__2(C, B, D, E, F).
15820history___3__1__0__2([], A, B, C, D) :-
15821 history___3__2(A, B, C, D).
15822history___3__1__0__2([A|M], C, K, G, D) :-
15823 ( A=suspension(_, active, _, B, _, _),
15824 B==C,
15825 E=t(95, A, D),
15826 '$novel_production'(A, E),
15827 '$novel_production'(D, E)
15828 -> '$extend_history'(D, E),
15829 ( arg(2, D, F),
15830 setarg(2, D, active),
15831 ( F==not_stored_yet
15832 -> ( '$chr_store_constants_chr_translate____history___3___[3]'(G,
15833 H)
15834 -> nb_getval(H, I),
15835 b_setval(H, [D|I])
15836 ; true
15837 ),
15838 ( nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
15839 J),
15840 insert_ht(J, K, D)
15841 ),
15842 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
15843 L),
15844 insert_ht(L, C, D)
15845 ; true
15846 )
15847 ),
15848 chr_error(syntax,
15849 'Only one pragma history allowed per rule (rule number ~w)\n',
15850 [C]),
15851 ( D=suspension(_, active, _, _, _, _)
15852 -> setarg(2, D, inactive),
15853 history___3__1__0__2(M,
15854 C,
15855 K,
15856 G,
15857 D)
15858 ; true
15859 )
15860 ; history___3__1__0__2(M, C, K, G, D)
15861 ).
15862history___3__1(A, B, C, D) :-
15863 history___3__2(A, B, C, D).
15864history___3__2(D, B, E, F) :-
15865 nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
15866 A),
15867 lookup_ht(A, B, C), !,
15868 history___3__2__0__3(C, D, B, E, F).
15869history___3__2__0__3([], A, B, C, D) :-
15870 history___3__3(A, B, C, D).
15871history___3__2__0__3([A|Q], L, C, G, D) :-
15872 ( A=suspension(_, active, _, P, B, M),
15873 B==C,
15874 E=t(96, D, A),
15875 '$novel_production'(D, E),
15876 '$novel_production'(A, E)
15877 -> '$extend_history'(D, E),
15878 ( arg(2, D, F),
15879 setarg(2, D, active),
15880 ( F==not_stored_yet
15881 -> ( '$chr_store_constants_chr_translate____history___3___[3]'(G,
15882 H)
15883 -> nb_getval(H, I),
15884 b_setval(H, [D|I])
15885 ; true
15886 ),
15887 ( nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
15888 J),
15889 insert_ht(J, C, D)
15890 ),
15891 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
15892 K),
15893 insert_ht(K, L, D)
15894 ; true
15895 )
15896 ),
15897 ( length(G, N),
15898 length(M, O),
15899 ( N\==O
15900 -> chr_error(syntax,
15901 'The history named ~w does not always range over an equal amount of occurrences.\n',
15902 [C])
15903 ; test_named_history_id_pairs(L,
15904 G,
15905 P,
15906 M)
15907 )
15908 ),
15909 ( D=suspension(_, active, _, _, _, _)
15910 -> setarg(2, D, inactive),
15911 history___3__2__0__3(Q,
15912 L,
15913 C,
15914 G,
15915 D)
15916 ; true
15917 )
15918 ; history___3__2__0__3(Q, L, C, G, D)
15919 ).
15920history___3__2(A, B, C, D) :-
15921 history___3__3(A, B, C, D).
15922history___3__3(D, B, E, F) :-
15923 nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
15924 A),
15925 lookup_ht(A, B, C), !,
15926 history___3__3__0__4(C, D, B, E, F).
15927history___3__3__0__4([], A, B, C, D) :-
15928 history___3__4(A, B, C, D).
15929history___3__3__0__4([A|Q], L, C, G, D) :-
15930 ( A=suspension(_, active, _, P, B, M),
15931 B==C,
15932 E=t(96, A, D),
15933 '$novel_production'(A, E),
15934 '$novel_production'(D, E)
15935 -> '$extend_history'(D, E),
15936 ( arg(2, D, F),
15937 setarg(2, D, active),
15938 ( F==not_stored_yet
15939 -> ( '$chr_store_constants_chr_translate____history___3___[3]'(G,
15940 H)
15941 -> nb_getval(H, I),
15942 b_setval(H, [D|I])
15943 ; true
15944 ),
15945 ( nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
15946 J),
15947 insert_ht(J, C, D)
15948 ),
15949 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
15950 K),
15951 insert_ht(K, L, D)
15952 ; true
15953 )
15954 ),
15955 ( length(M, N),
15956 length(G, O),
15957 ( N\==O
15958 -> chr_error(syntax,
15959 'The history named ~w does not always range over an equal amount of occurrences.\n',
15960 [C])
15961 ; test_named_history_id_pairs(P,
15962 M,
15963 L,
15964 G)
15965 )
15966 ),
15967 ( D=suspension(_, active, _, _, _, _)
15968 -> setarg(2, D, inactive),
15969 history___3__3__0__4(Q,
15970 L,
15971 C,
15972 G,
15973 D)
15974 ; true
15975 )
15976 ; history___3__3__0__4(Q, L, C, G, D)
15977 ).
15978history___3__3(A, B, C, D) :-
15979 history___3__4(A, B, C, D).
15980history___3__4(B, C, [], D) :-
15981 nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
15982 A), !,
15983 history___3__4__0__6(A, B, C, [], D).
15984history___3__4__0__6([], A, B, C, D) :-
15985 history___3__5(A, B, C, D).
15986history___3__4__0__6([A|L], K, I, E, B) :-
15987 ( A=suspension(_, active, _, _),
15988 C=t(142, A, B),
15989 '$novel_production'(A, C),
15990 '$novel_production'(B, C)
15991 -> '$extend_history'(B, C),
15992 ( arg(2, B, D),
15993 setarg(2, B, active),
15994 ( D==not_stored_yet
15995 -> ( '$chr_store_constants_chr_translate____history___3___[3]'(E,
15996 F)
15997 -> nb_getval(F, G),
15998 b_setval(F, [B|G])
15999 ; true
16000 ),
16001 ( nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
16002 H),
16003 insert_ht(H, I, B)
16004 ),
16005 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
16006 J),
16007 insert_ht(J, K, B)
16008 ; true
16009 )
16010 ),
16011 generate_empty_named_history_initialisation(I),
16012 ( B=suspension(_, active, _, _, _, _)
16013 -> setarg(2, B, inactive),
16014 history___3__4__0__6(L,
16015 K,
16016 I,
16017 E,
16018 B)
16019 ; true
16020 )
16021 ; history___3__4__0__6(L, K, I, E, B)
16022 ).
16023history___3__4(A, B, C, D) :-
16024 history___3__5(A, B, C, D).
16025history___3__5(I, G, C, A) :-
16026 arg(2, A, B),
16027 setarg(2, A, active),
16028 ( B==not_stored_yet
16029 -> ( '$chr_store_constants_chr_translate____history___3___[3]'(C,
16030 D)
16031 -> nb_getval(D, E),
16032 b_setval(D, [A|E])
16033 ; true
16034 ),
16035 ( nb_getval('$chr_store_multi_hash_chr_translate____history___3-2',
16036 F),
16037 insert_ht(F, G, A)
16038 ),
16039 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
16040 H),
16041 insert_ht(H, I, A)
16042 ; true
16043 ).
16044named_history(A, E, G) :-
16045 ground(A),
16046 nb_getval('$chr_store_multi_hash_chr_translate____history___3-1',
16047 B),
16048 lookup_ht(B, A, C),
16049 member(D, C),
16050 D=suspension(_, active, _, _, F, H), !,
16051 E=F,
16052 G=H.
16053named_history(_, _, _) :-
16054 fail.
16055test_named_history_id_pair(B, C, H, I) :-
16056 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-34',
16057 A),
16058 lookup_ht(A, k(B, C), D),
16059 member(E, D),
16060 E=suspension(_, active, _, _, G, _, _, _, _),
16061 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
16062 F),
16063 lookup_ht(F, k(G, H, I), J),
16064 member(K, J),
16065 K=suspension(_, active, _, _, _, _, _, _, _),
16066 K\==E, !.
16067test_named_history_id_pair(B, _, A, _) :-
16068 chr_error(syntax,
16069 'Occurrences of shared history in rules number ~w and ~w do not correspond\n',
16070 [A, B]).
16071indexing_spec(B, F) :-
16072 nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
16073 A),
16074 lookup_ht(A, B, C),
16075 member(D, C),
16076 D=suspension(_, active, _, G), !,
16077 setarg(2, D, removed),
16078 nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
16079 E),
16080 delete_ht(E, B, D),
16081 append(F, G, H),
16082 indexing_spec(B, H).
16083indexing_spec(A, B) :-
16084 E=suspension(C, active, A, B),
16085 'chr gen_id'(C),
16086 nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
16087 D),
16088 insert_ht(D, A, E).
16089get_indexing_spec(B, E) :-
16090 nb_getval('$chr_store_multi_hash_chr_translate____indexing_spec___2-1',
16091 A),
16092 lookup_ht(A, B, C),
16093 member(D, C),
16094 D=suspension(_, active, _, F), !,
16095 E=F.
16096get_indexing_spec(_, []).
16097observation_analysis(A) :-
16098 observation_analysis___1__0(A, _).
16099observation_analysis___1__0(B, A) :-
16100 nb_getval('$chr_store_global_ground_chr_translate____rule___2', D), !,
16101 A=suspension(C, not_stored_yet, _, B),
16102 'chr gen_id'(C),
16103 observation_analysis___1__0__0__1(D, B, A).
16104observation_analysis___1__0__0__1([], A, B) :-
16105 observation_analysis___1__1(A, B).
16106observation_analysis___1__0__0__1([A|G], E, H) :-
16107 ( A=suspension(_, active, _, _, C, B)
16108 -> ( B=pragma(rule(_, _, D, F), _, _, _, _),
16109 ( chr_pp_flag(store_in_guards, on)
16110 -> observation_analysis(C, D, guard, E)
16111 ; true
16112 ),
16113 observation_analysis(C, F, body, E)
16114 ),
16115 observation_analysis___1__0__0__1(G, E, H)
16116 ; observation_analysis___1__0__0__1(G, E, H)
16117 ).
16118observation_analysis___1__0(B, A) :-
16119 A=suspension(C, not_stored_yet, _, B),
16120 'chr gen_id'(C),
16121 observation_analysis___1__1(B, A).
16122observation_analysis___1__1(_, A) :-
16123 ( var(A)
16124 -> true
16125 ; arg(2, A, B),
16126 setarg(2, A, removed),
16127 ( B==not_stored_yet
16128 -> true
16129 ; arg(3, A, C),
16130 ( var(C)
16131 -> nb_getval('$chr_store_global_ground_chr_translate____observation_analysis___1',
16132 D),
16133 D=[_|E],
16134 b_setval('$chr_store_global_ground_chr_translate____observation_analysis___1',
16135 E),
16136 ( E=[F|_]
16137 -> setarg(3, F, _)
16138 ; true
16139 )
16140 ; C=[_, _|E],
16141 setarg(2, C, E),
16142 ( E=[F|_]
16143 -> setarg(3, F, C)
16144 ; true
16145 )
16146 )
16147 )
16148 ).
16149spawns(A, B, C) :-
16150 spawns___3__0(A, B, C, _).
16151spawns___3__0(B, C, D, _) :-
16152 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16153 A),
16154 lookup_ht(A, k(B, C, D), E),
16155 member(F, E),
16156 F=suspension(_, active, _, _, _, _, _), !.
16157spawns___3__0(B, body, C, _) :-
16158 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16159 A),
16160 lookup_ht(A, k(B, guard, C), D),
16161 member(E, D),
16162 E=suspension(_, active, _, _, _, _, _), !.
16163spawns___3__0(B, guard, C, E) :-
16164 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16165 A),
16166 lookup_ht(A, k(B, body, C), D), !,
16167 spawns___3__0__0__4(D, B, guard, C, E).
16168spawns___3__0__0__4([], A, B, C, D) :-
16169 spawns___3__1(A, B, C, D).
16170spawns___3__0__0__4([A|P], C, Q, F, R) :-
16171 ( A=suspension(_, active, _, _, B, D, E),
16172 B==C,
16173 D=body,
16174 E==F
16175 -> ( setarg(2, A, removed),
16176 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16177 G),
16178 delete_ht(G, k(C, F), A)
16179 ),
16180 ( arg(4, A, H),
16181 ( var(H)
16182 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16183 I),
16184 I=[_|J],
16185 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16186 J),
16187 ( J=[K|_]
16188 -> setarg(4, K, _)
16189 ; true
16190 )
16191 ; H=[_, _|J],
16192 setarg(2, H, J),
16193 ( J=[K|_]
16194 -> setarg(4, K, H)
16195 ; true
16196 )
16197 )
16198 ),
16199 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16200 L),
16201 delete_ht(L, k(C, body), A)
16202 ),
16203 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16204 M),
16205 delete_ht(M, C, A)
16206 ),
16207 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16208 N),
16209 delete_ht(N, F, A)
16210 ),
16211 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16212 O),
16213 delete_ht(O, k(C, body, F), A)
16214 ),
16215 spawns___3__0__0__4(P, C, Q, F, R)
16216 ; spawns___3__0__0__4(P, C, Q, F, R)
16217 ).
16218spawns___3__0(A, B, C, D) :-
16219 spawns___3__1(A, B, C, D).
16220spawns___3__1(B, C, I, F) :-
16221 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
16222 A),
16223 lookup_ht(A, k(B, C), D),
16224 member(E, D),
16225 E=suspension(_, active, _, _), !,
16226 ( var(F)
16227 -> true
16228 ; arg(2, F, G),
16229 setarg(2, F, removed),
16230 ( G==not_stored_yet
16231 -> true
16232 ; ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16233 H),
16234 delete_ht(H, k(B, I), F)
16235 ),
16236 ( arg(4, F, J),
16237 ( var(J)
16238 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16239 K),
16240 K=[_|L],
16241 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16242 L),
16243 ( L=[M|_]
16244 -> setarg(4, M, _)
16245 ; true
16246 )
16247 ; J=[_, _|L],
16248 setarg(2, J, L),
16249 ( L=[M|_]
16250 -> setarg(4, M, J)
16251 ; true
16252 )
16253 )
16254 ),
16255 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16256 N),
16257 delete_ht(N, k(B, C), F)
16258 ),
16259 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16260 O),
16261 delete_ht(O, B, F)
16262 ),
16263 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16264 P),
16265 delete_ht(P, I, F)
16266 ),
16267 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16268 Q),
16269 delete_ht(Q, k(B, C, I), F)
16270 )
16271 ).
16272spawns___3__1(B, body, H, E) :-
16273 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
16274 A),
16275 lookup_ht(A, k(B, guard), C),
16276 member(D, C),
16277 D=suspension(_, active, _, _), !,
16278 ( var(E)
16279 -> true
16280 ; arg(2, E, F),
16281 setarg(2, E, removed),
16282 ( F==not_stored_yet
16283 -> true
16284 ; ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16285 G),
16286 delete_ht(G, k(B, H), E)
16287 ),
16288 ( arg(4, E, I),
16289 ( var(I)
16290 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16291 J),
16292 J=[_|K],
16293 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16294 K),
16295 ( K=[L|_]
16296 -> setarg(4, L, _)
16297 ; true
16298 )
16299 ; I=[_, _|K],
16300 setarg(2, I, K),
16301 ( K=[L|_]
16302 -> setarg(4, L, I)
16303 ; true
16304 )
16305 )
16306 ),
16307 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16308 M),
16309 delete_ht(M, k(B, body), E)
16310 ),
16311 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16312 N),
16313 delete_ht(N, B, E)
16314 ),
16315 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16316 O),
16317 delete_ht(O, H, E)
16318 ),
16319 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16320 P),
16321 delete_ht(P, k(B, body, H), E)
16322 )
16323 ).
16324spawns___3__1(B, C, F, G) :-
16325 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
16326 A),
16327 lookup_ht(A, k(B, C), D),
16328 member(E, D),
16329 E=suspension(_, active, _, _, _, _),
16330 may_trigger(F), !,
16331 ( var(G)
16332 -> true
16333 ; arg(2, G, H),
16334 setarg(2, G, removed),
16335 ( H==not_stored_yet
16336 -> true
16337 ; ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16338 I),
16339 delete_ht(I, k(B, F), G)
16340 ),
16341 ( arg(4, G, J),
16342 ( var(J)
16343 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16344 K),
16345 K=[_|L],
16346 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16347 L),
16348 ( L=[M|_]
16349 -> setarg(4, M, _)
16350 ; true
16351 )
16352 ; J=[_, _|L],
16353 setarg(2, J, L),
16354 ( L=[M|_]
16355 -> setarg(4, M, J)
16356 ; true
16357 )
16358 )
16359 ),
16360 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16361 N),
16362 delete_ht(N, k(B, C), G)
16363 ),
16364 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16365 O),
16366 delete_ht(O, B, G)
16367 ),
16368 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16369 P),
16370 delete_ht(P, F, G)
16371 ),
16372 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16373 Q),
16374 delete_ht(Q, k(B, C, F), G)
16375 )
16376 ).
16377spawns___3__1(B, body, E, F) :-
16378 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
16379 A),
16380 lookup_ht(A, k(B, guard), C),
16381 member(D, C),
16382 D=suspension(_, active, _, _, _, _),
16383 may_trigger(E), !,
16384 ( var(F)
16385 -> true
16386 ; arg(2, F, G),
16387 setarg(2, F, removed),
16388 ( G==not_stored_yet
16389 -> true
16390 ; ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16391 H),
16392 delete_ht(H, k(B, E), F)
16393 ),
16394 ( arg(4, F, I),
16395 ( var(I)
16396 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16397 J),
16398 J=[_|K],
16399 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16400 K),
16401 ( K=[L|_]
16402 -> setarg(4, L, _)
16403 ; true
16404 )
16405 ; I=[_, _|K],
16406 setarg(2, I, K),
16407 ( K=[L|_]
16408 -> setarg(4, L, I)
16409 ; true
16410 )
16411 )
16412 ),
16413 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16414 M),
16415 delete_ht(M, k(B, body), F)
16416 ),
16417 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16418 N),
16419 delete_ht(N, B, F)
16420 ),
16421 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16422 O),
16423 delete_ht(O, E, F)
16424 ),
16425 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16426 P),
16427 delete_ht(P, k(B, body, E), F)
16428 )
16429 ).
16430spawns___3__1(M, S, B, J) :-
16431 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
16432 A),
16433 lookup_ht(A, B, C)
16434 ),
16435 ( member(D, C),
16436 D=suspension(_, active, _, _, _, _, F, I, _),
16437 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
16438 E),
16439 lookup_ht(E, F, G),
16440 member(H, G),
16441 H=suspension(_, active, _, _),
16442 \+ is_passive(F, I), !,
16443 ( var(J)
16444 -> true
16445 ; arg(2, J, K),
16446 setarg(2, J, removed),
16447 ( K==not_stored_yet
16448 -> true
16449 ; ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16450 L),
16451 delete_ht(L, k(M, B), J)
16452 ),
16453 ( arg(4, J, N),
16454 ( var(N)
16455 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16456 O),
16457 O=[_|P],
16458 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16459 P),
16460 ( P=[Q|_]
16461 -> setarg(4, Q, _)
16462 ; true
16463 )
16464 ; N=[_, _|P],
16465 setarg(2, N, P),
16466 ( P=[Q|_]
16467 -> setarg(4, Q, N)
16468 ; true
16469 )
16470 )
16471 ),
16472 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16473 R),
16474 delete_ht(R, k(M, S), J)
16475 ),
16476 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16477 T),
16478 delete_ht(T, M, J)
16479 ),
16480 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16481 U),
16482 delete_ht(U, B, J)
16483 ),
16484 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16485 V),
16486 delete_ht(V,
16487 k(M, S, B),
16488 J)
16489 )
16490 ),
16491 spawns_all(M, S)
16492 ; nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
16493 W),
16494 lookup_ht(W, F, X),
16495 member(Y, X),
16496 Y=suspension(_, active, _, _, _, _),
16497 may_trigger(B),
16498 \+ is_passive(F, I), !,
16499 ( var(J)
16500 -> true
16501 ; arg(2, J, Z),
16502 setarg(2, J, removed),
16503 ( Z==not_stored_yet
16504 -> true
16505 ; ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16506 A1),
16507 delete_ht(A1, k(M, B), J)
16508 ),
16509 ( arg(4, J, B1),
16510 ( var(B1)
16511 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16512 C1),
16513 C1=[_|D1],
16514 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16515 D1),
16516 ( D1=[E1|_]
16517 -> setarg(4, E1, _)
16518 ; true
16519 )
16520 ; B1=[_, _|D1],
16521 setarg(2, B1, D1),
16522 ( D1=[E1|_]
16523 -> setarg(4, E1, B1)
16524 ; true
16525 )
16526 )
16527 ),
16528 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16529 F1),
16530 delete_ht(F1, k(M, S), J)
16531 ),
16532 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16533 G1),
16534 delete_ht(G1, M, J)
16535 ),
16536 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16537 H1),
16538 delete_ht(H1, B, J)
16539 ),
16540 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16541 I1),
16542 delete_ht(I1,
16543 k(M, S, B),
16544 J)
16545 )
16546 ),
16547 spawns_all_triggers(M, S)
16548 )
16549 ; !,
16550 J=suspension(J1, not_stored_yet, t, _, M, S, B),
16551 'chr gen_id'(J1),
16552 spawns___3__1__0__11(C, M, S, B, J)
16553 ).
16554spawns___3__1__0__11([], A, B, C, D) :-
16555 spawns___3__2(A, B, C, D).
16556spawns___3__1__0__11([A|H], I, J, C, K) :-
16557 ( ( A=suspension(_, active, _, _, B, _, E, G, _),
16558 B==C
16559 ),
16560 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
16561 D),
16562 lookup_ht(D, E, F)
16563 -> spawns___3__1__1__11(F,
16564 E,
16565 G,
16566 A,
16567 H,
16568 I,
16569 J,
16570 C,
16571 K)
16572 ; spawns___3__1__0__11(H, I, J, C, K)
16573 ).
16574spawns___3__1__1__11([], _, _, _, A, B, C, D, E) :-
16575 spawns___3__1__0__11(A, B, C, D, E).
16576spawns___3__1__1__11([A|T], C, H, D, U, K, P, G, E) :-
16577 ( A=suspension(_, active, _, _, B, _),
16578 B==C,
16579 ( F=t(123, A, D, E),
16580 '$novel_production'(A, F),
16581 '$novel_production'(E, F)
16582 ),
16583 \+ may_trigger(G),
16584 \+ is_passive(C, H)
16585 -> '$extend_history'(E, F),
16586 ( arg(2, E, I),
16587 setarg(2, E, active),
16588 ( I==not_stored_yet
16589 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16590 J),
16591 insert_ht(J, k(K, G), E)
16592 ),
16593 ( nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16594 L),
16595 M=[E|L],
16596 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16597 M),
16598 ( L=[N|_]
16599 -> setarg(4, N, M)
16600 ; true
16601 )
16602 ),
16603 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16604 O),
16605 insert_ht(O, k(K, P), E)
16606 ),
16607 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16608 Q),
16609 insert_ht(Q, K, E)
16610 ),
16611 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16612 R),
16613 insert_ht(R, G, E)
16614 ),
16615 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16616 S),
16617 insert_ht(S, k(K, P, G), E)
16618 ; true
16619 )
16620 ),
16621 spawns_all_triggers(K, P),
16622 ( E=suspension(_, active, _, _, _, _, _)
16623 -> setarg(2, E, inactive),
16624 spawns___3__1__1__11(T,
16625 C,
16626 H,
16627 D,
16628 U,
16629 K,
16630 P,
16631 G,
16632 E)
16633 ; true
16634 )
16635 ; spawns___3__1__1__11(T,
16636 C,
16637 H,
16638 D,
16639 U,
16640 K,
16641 P,
16642 G,
16643 E)
16644 ).
16645spawns___3__1(B, C, D, A) :-
16646 A=suspension(E, not_stored_yet, t, _, B, C, D),
16647 'chr gen_id'(E),
16648 spawns___3__2(B, C, D, A).
16649spawns___3__2(B, D, E, F) :-
16650 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
16651 A),
16652 lookup_ht(A, B, C), !,
16653 spawns___3__2__0__12(C, B, D, E, F).
16654spawns___3__2__0__12([], A, B, C, D) :-
16655 spawns___3__3(A, B, C, D).
16656spawns___3__2__0__12([A|H], C, I, J, K) :-
16657 ( ( A=suspension(_, active, _, _, E, _, B, G, _),
16658 B==C
16659 ),
16660 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16661 D),
16662 lookup_ht(D, E, F)
16663 -> spawns___3__2__1__12(F,
16664 E,
16665 G,
16666 A,
16667 H,
16668 C,
16669 I,
16670 J,
16671 K)
16672 ; spawns___3__2__0__12(H, C, I, J, K)
16673 ).
16674spawns___3__2__1__12([], _, _, _, A, B, C, D, E) :-
16675 spawns___3__2__0__12(A, B, C, D, E).
16676spawns___3__2__1__12([A|V], C, J, E, W, H, Q, I, D) :-
16677 ( A=suspension(_, active, _, _, G, U, B),
16678 B==C,
16679 ( F=t(124, D, E, A),
16680 '$novel_production'(D, F),
16681 '$novel_production'(A, F)
16682 ),
16683 G\==H,
16684 C\==I,
16685 \+ is_passive(H, J)
16686 -> '$extend_history'(D, F),
16687 ( arg(2, D, K),
16688 setarg(2, D, active),
16689 ( K==not_stored_yet
16690 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16691 L),
16692 insert_ht(L, k(H, I), D)
16693 ),
16694 ( nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16695 M),
16696 N=[D|M],
16697 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16698 N),
16699 ( M=[O|_]
16700 -> setarg(4, O, N)
16701 ; true
16702 )
16703 ),
16704 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16705 P),
16706 insert_ht(P, k(H, Q), D)
16707 ),
16708 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16709 R),
16710 insert_ht(R, H, D)
16711 ),
16712 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16713 S),
16714 insert_ht(S, I, D)
16715 ),
16716 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16717 T),
16718 insert_ht(T, k(H, Q, I), D)
16719 ; true
16720 )
16721 ),
16722 spawns(G, U, I),
16723 ( D=suspension(_, active, _, _, _, _, _)
16724 -> setarg(2, D, inactive),
16725 spawns___3__2__1__12(V,
16726 C,
16727 J,
16728 E,
16729 W,
16730 H,
16731 Q,
16732 I,
16733 D)
16734 ; true
16735 )
16736 ; spawns___3__2__1__12(V,
16737 C,
16738 J,
16739 E,
16740 W,
16741 H,
16742 Q,
16743 I,
16744 D)
16745 ).
16746spawns___3__2(A, B, C, D) :-
16747 spawns___3__3(A, B, C, D).
16748spawns___3__3(D, E, B, F) :-
16749 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
16750 A),
16751 lookup_ht(A, B, C), !,
16752 spawns___3__3__0__13(C, D, E, B, F).
16753spawns___3__3__0__13([], A, B, C, D) :-
16754 spawns___3__4(A, B, C, D).
16755spawns___3__3__0__13([A|H], I, J, C, K) :-
16756 ( ( A=suspension(_, active, _, _, B, _, E, G, _),
16757 B==C
16758 ),
16759 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16760 D),
16761 lookup_ht(D, E, F)
16762 -> spawns___3__3__1__13(F,
16763 E,
16764 G,
16765 A,
16766 H,
16767 I,
16768 J,
16769 C,
16770 K)
16771 ; spawns___3__3__0__13(H, I, J, C, K)
16772 ).
16773spawns___3__3__1__13([], _, _, _, A, B, C, D, E) :-
16774 spawns___3__3__0__13(A, B, C, D, E).
16775spawns___3__3__1__13([A|U], C, J, D, V, G, Q, H, E) :-
16776 ( A=suspension(_, active, _, _, B, _, I),
16777 B==C,
16778 ( F=t(124, A, D, E),
16779 '$novel_production'(A, F),
16780 '$novel_production'(E, F)
16781 ),
16782 G\==C,
16783 H\==I,
16784 \+ is_passive(C, J)
16785 -> '$extend_history'(E, F),
16786 ( arg(2, E, K),
16787 setarg(2, E, active),
16788 ( K==not_stored_yet
16789 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16790 L),
16791 insert_ht(L, k(G, H), E)
16792 ),
16793 ( nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16794 M),
16795 N=[E|M],
16796 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16797 N),
16798 ( M=[O|_]
16799 -> setarg(4, O, N)
16800 ; true
16801 )
16802 ),
16803 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16804 P),
16805 insert_ht(P, k(G, Q), E)
16806 ),
16807 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16808 R),
16809 insert_ht(R, G, E)
16810 ),
16811 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16812 S),
16813 insert_ht(S, H, E)
16814 ),
16815 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16816 T),
16817 insert_ht(T, k(G, Q, H), E)
16818 ; true
16819 )
16820 ),
16821 spawns(G, Q, I),
16822 ( E=suspension(_, active, _, _, _, _, _)
16823 -> setarg(2, E, inactive),
16824 spawns___3__3__1__13(U,
16825 C,
16826 J,
16827 D,
16828 V,
16829 G,
16830 Q,
16831 H,
16832 E)
16833 ; true
16834 )
16835 ; spawns___3__3__1__13(U,
16836 C,
16837 J,
16838 D,
16839 V,
16840 G,
16841 Q,
16842 H,
16843 E)
16844 ).
16845spawns___3__3(A, B, C, D) :-
16846 spawns___3__4(A, B, C, D).
16847spawns___3__4(B, D, E, F) :-
16848 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
16849 A),
16850 lookup_ht(A, B, C), !,
16851 spawns___3__4__0__14(C, B, D, E, F).
16852spawns___3__4__0__14([], A, B, C, D) :-
16853 spawns___3__5(A, B, C, D).
16854spawns___3__4__0__14([A|G], C, H, I, J) :-
16855 ( ( A=suspension(_, active, _, _, E, _, B, F, _),
16856 B==C
16857 ),
16858 nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
16859 D)
16860 -> spawns___3__4__1__14(D,
16861 E,
16862 F,
16863 A,
16864 G,
16865 C,
16866 H,
16867 I,
16868 J)
16869 ; spawns___3__4__0__14(G, C, H, I, J)
16870 ).
16871spawns___3__4__1__14([], _, _, _, A, B, C, D, E) :-
16872 spawns___3__4__0__14(A, B, C, D, E).
16873spawns___3__4__1__14([A|U], G, F, C, V, E, O, H, B) :-
16874 ( A=suspension(_, active, _, _, S, T),
16875 ( D=t(125, B, C, A),
16876 '$novel_production'(B, D),
16877 '$novel_production'(A, D)
16878 ),
16879 \+ is_passive(E, F),
16880 may_trigger(G),
16881 \+ may_trigger(H)
16882 -> '$extend_history'(B, D),
16883 ( arg(2, B, I),
16884 setarg(2, B, active),
16885 ( I==not_stored_yet
16886 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16887 J),
16888 insert_ht(J, k(E, H), B)
16889 ),
16890 ( nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16891 K),
16892 L=[B|K],
16893 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16894 L),
16895 ( K=[M|_]
16896 -> setarg(4, M, L)
16897 ; true
16898 )
16899 ),
16900 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16901 N),
16902 insert_ht(N, k(E, O), B)
16903 ),
16904 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16905 P),
16906 insert_ht(P, E, B)
16907 ),
16908 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16909 Q),
16910 insert_ht(Q, H, B)
16911 ),
16912 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16913 R),
16914 insert_ht(R, k(E, O, H), B)
16915 ; true
16916 )
16917 ),
16918 spawns(S, T, H),
16919 ( B=suspension(_, active, _, _, _, _, _)
16920 -> setarg(2, B, inactive),
16921 spawns___3__4__1__14(U,
16922 G,
16923 F,
16924 C,
16925 V,
16926 E,
16927 O,
16928 H,
16929 B)
16930 ; true
16931 )
16932 ; spawns___3__4__1__14(U,
16933 G,
16934 F,
16935 C,
16936 V,
16937 E,
16938 O,
16939 H,
16940 B)
16941 ).
16942spawns___3__4(A, B, C, D) :-
16943 spawns___3__5(A, B, C, D).
16944spawns___3__5(D, J, E, A) :-
16945 arg(2, A, B),
16946 setarg(2, A, active),
16947 ( B==not_stored_yet
16948 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
16949 C),
16950 insert_ht(C, k(D, E), A)
16951 ),
16952 ( nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
16953 F),
16954 G=[A|F],
16955 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
16956 G),
16957 ( F=[H|_]
16958 -> setarg(4, H, G)
16959 ; true
16960 )
16961 ),
16962 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
16963 I),
16964 insert_ht(I, k(D, J), A)
16965 ),
16966 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
16967 K),
16968 insert_ht(K, D, A)
16969 ),
16970 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
16971 L),
16972 insert_ht(L, E, A)
16973 ),
16974 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
16975 M),
16976 insert_ht(M, k(D, J, E), A)
16977 ; true
16978 ).
16979spawns_all(A, B) :-
16980 spawns_all___2__0(A, B, _).
16981spawns_all___2__0(B, C, _) :-
16982 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
16983 A),
16984 lookup_ht(A, k(B, C), D),
16985 member(E, D),
16986 E=suspension(_, active, _, _), !.
16987spawns_all___2__0(B, body, _) :-
16988 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
16989 A),
16990 lookup_ht(A, k(B, guard), C),
16991 member(D, C),
16992 D=suspension(_, active, _, _), !.
16993spawns_all___2__0(B, guard, D) :-
16994 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
16995 A),
16996 lookup_ht(A, k(B, body), C), !,
16997 spawns_all___2__0__0__4(C, B, guard, D).
16998spawns_all___2__0__0__4([], A, B, C) :-
16999 spawns_all___2__1(A, B, C).
17000spawns_all___2__0__0__4([A|G], C, H, I) :-
17001 ( A=suspension(_, active, B, D),
17002 B==C,
17003 D=body
17004 -> ( setarg(2, A, removed),
17005 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
17006 E),
17007 delete_ht(E, C, A)
17008 ),
17009 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
17010 F),
17011 delete_ht(F, k(C, body), A)
17012 ),
17013 spawns_all___2__0__0__4(G, C, H, I)
17014 ; spawns_all___2__0__0__4(G, C, H, I)
17015 ).
17016spawns_all___2__0(A, B, C) :-
17017 spawns_all___2__1(A, B, C).
17018spawns_all___2__1(B, C, E) :-
17019 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17020 A),
17021 lookup_ht(A, k(B, C), D), !,
17022 spawns_all___2__1__0__5(D, B, C, E).
17023spawns_all___2__1__0__5([], A, B, C) :-
17024 spawns_all___2__2(A, B, C).
17025spawns_all___2__1__0__5([A|P], C, E, Q) :-
17026 ( A=suspension(_, active, _, _, B, D, G),
17027 B==C,
17028 D==E
17029 -> ( setarg(2, A, removed),
17030 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
17031 F),
17032 delete_ht(F, k(C, G), A)
17033 ),
17034 ( arg(4, A, H),
17035 ( var(H)
17036 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17037 I),
17038 I=[_|J],
17039 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
17040 J),
17041 ( J=[K|_]
17042 -> setarg(4, K, _)
17043 ; true
17044 )
17045 ; H=[_, _|J],
17046 setarg(2, H, J),
17047 ( J=[K|_]
17048 -> setarg(4, K, H)
17049 ; true
17050 )
17051 )
17052 ),
17053 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17054 L),
17055 delete_ht(L, k(C, E), A)
17056 ),
17057 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
17058 M),
17059 delete_ht(M, C, A)
17060 ),
17061 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17062 N),
17063 delete_ht(N, G, A)
17064 ),
17065 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
17066 O),
17067 delete_ht(O, k(C, E, G), A)
17068 ),
17069 spawns_all___2__1__0__5(P, C, E, Q)
17070 ; spawns_all___2__1__0__5(P, C, E, Q)
17071 ).
17072spawns_all___2__1(A, B, C) :-
17073 spawns_all___2__2(A, B, C).
17074spawns_all___2__2(B, guard, D) :-
17075 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17076 A),
17077 lookup_ht(A, k(B, body), C), !,
17078 spawns_all___2__2__0__6(C, B, guard, D).
17079spawns_all___2__2__0__6([], A, B, C) :-
17080 spawns_all___2__3(A, B, C).
17081spawns_all___2__2__0__6([A|O], C, P, Q) :-
17082 ( A=suspension(_, active, _, _, B, D, F),
17083 B==C,
17084 D=body
17085 -> ( setarg(2, A, removed),
17086 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
17087 E),
17088 delete_ht(E, k(C, F), A)
17089 ),
17090 ( arg(4, A, G),
17091 ( var(G)
17092 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17093 H),
17094 H=[_|I],
17095 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
17096 I),
17097 ( I=[J|_]
17098 -> setarg(4, J, _)
17099 ; true
17100 )
17101 ; G=[_, _|I],
17102 setarg(2, G, I),
17103 ( I=[J|_]
17104 -> setarg(4, J, G)
17105 ; true
17106 )
17107 )
17108 ),
17109 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17110 K),
17111 delete_ht(K, k(C, body), A)
17112 ),
17113 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
17114 L),
17115 delete_ht(L, C, A)
17116 ),
17117 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17118 M),
17119 delete_ht(M, F, A)
17120 ),
17121 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
17122 N),
17123 delete_ht(N, k(C, body, F), A)
17124 ),
17125 spawns_all___2__2__0__6(O, C, P, Q)
17126 ; spawns_all___2__2__0__6(O, C, P, Q)
17127 ).
17128spawns_all___2__2(A, B, C) :-
17129 spawns_all___2__3(A, B, C).
17130spawns_all___2__3(B, C, E) :-
17131 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17132 A),
17133 lookup_ht(A, k(B, C), D), !,
17134 spawns_all___2__3__0__7(D, B, C, E).
17135spawns_all___2__3__0__7([], A, B, C) :-
17136 spawns_all___2__4(A, B, C).
17137spawns_all___2__3__0__7([A|L], C, E, M) :-
17138 ( A=suspension(_, active, _, _, B, D),
17139 B==C,
17140 D==E
17141 -> ( setarg(2, A, removed),
17142 ( arg(4, A, F),
17143 ( var(F)
17144 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17145 G),
17146 G=[_|H],
17147 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17148 H),
17149 ( H=[I|_]
17150 -> setarg(4, I, _)
17151 ; true
17152 )
17153 ; F=[_, _|H],
17154 setarg(2, F, H),
17155 ( H=[I|_]
17156 -> setarg(4, I, F)
17157 ; true
17158 )
17159 )
17160 ),
17161 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17162 J),
17163 delete_ht(J, C, A)
17164 ),
17165 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17166 K),
17167 delete_ht(K, k(C, E), A)
17168 ),
17169 spawns_all___2__3__0__7(L, C, E, M)
17170 ; spawns_all___2__3__0__7(L, C, E, M)
17171 ).
17172spawns_all___2__3(A, B, C) :-
17173 spawns_all___2__4(A, B, C).
17174spawns_all___2__4(B, guard, D) :-
17175 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17176 A),
17177 lookup_ht(A, k(B, body), C), !,
17178 spawns_all___2__4__0__8(C, B, guard, D).
17179spawns_all___2__4__0__8([], A, B, C) :-
17180 spawns_all___2__5(A, B, C).
17181spawns_all___2__4__0__8([A|K], C, L, M) :-
17182 ( A=suspension(_, active, _, _, B, D),
17183 B==C,
17184 D=body
17185 -> ( setarg(2, A, removed),
17186 ( arg(4, A, E),
17187 ( var(E)
17188 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17189 F),
17190 F=[_|G],
17191 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17192 G),
17193 ( G=[H|_]
17194 -> setarg(4, H, _)
17195 ; true
17196 )
17197 ; E=[_, _|G],
17198 setarg(2, E, G),
17199 ( G=[H|_]
17200 -> setarg(4, H, E)
17201 ; true
17202 )
17203 )
17204 ),
17205 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17206 I),
17207 delete_ht(I, C, A)
17208 ),
17209 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17210 J),
17211 delete_ht(J, k(C, body), A)
17212 ),
17213 spawns_all___2__4__0__8(K, C, L, M)
17214 ; spawns_all___2__4__0__8(K, C, L, M)
17215 ).
17216spawns_all___2__4(A, B, C) :-
17217 spawns_all___2__5(A, B, C).
17218spawns_all___2__5(B, D, C) :-
17219 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
17220 A),
17221 lookup_ht(A, B, F), !,
17222 C=suspension(E, not_stored_yet, B, D),
17223 'chr gen_id'(E),
17224 spawns_all___2__5__0__9(F, B, D, C).
17225spawns_all___2__5__0__9([], A, B, C) :-
17226 spawns_all___2__6(A, B, C).
17227spawns_all___2__5__0__9([A|H], C, I, J) :-
17228 ( ( A=suspension(_, active, _, _, E, _, B, G, _),
17229 B==C
17230 ),
17231 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17232 D),
17233 lookup_ht(D, E, F)
17234 -> spawns_all___2__5__1__9(F,
17235 E,
17236 G,
17237 A,
17238 H,
17239 C,
17240 I,
17241 J)
17242 ; spawns_all___2__5__0__9(H, C, I, J)
17243 ).
17244spawns_all___2__5__1__9([], _, _, _, A, B, C, D) :-
17245 spawns_all___2__5__0__9(A, B, C, D).
17246spawns_all___2__5__1__9([A|V], C, E, W, X, D, U, Q) :-
17247 ( ( A=suspension(_, active, _, _, G, M, B),
17248 B==C
17249 ),
17250 \+ is_passive(D, E)
17251 -> ( setarg(2, A, removed),
17252 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
17253 F),
17254 delete_ht(F, k(G, C), A)
17255 ),
17256 ( arg(4, A, H),
17257 ( var(H)
17258 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17259 I),
17260 I=[_|J],
17261 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
17262 J),
17263 ( J=[K|_]
17264 -> setarg(4, K, _)
17265 ; true
17266 )
17267 ; H=[_, _|J],
17268 setarg(2, H, J),
17269 ( J=[K|_]
17270 -> setarg(4, K, H)
17271 ; true
17272 )
17273 )
17274 ),
17275 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17276 L),
17277 delete_ht(L, k(G, M), A)
17278 ),
17279 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
17280 N),
17281 delete_ht(N, G, A)
17282 ),
17283 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17284 O),
17285 delete_ht(O, C, A)
17286 ),
17287 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
17288 P),
17289 delete_ht(P, k(G, M, C), A)
17290 ),
17291 ( arg(2, Q, R),
17292 setarg(2, Q, active),
17293 ( R==not_stored_yet
17294 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
17295 S),
17296 insert_ht(S, D, Q)
17297 ),
17298 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
17299 T),
17300 insert_ht(T, k(D, U), Q)
17301 ; true
17302 )
17303 ),
17304 spawns_all(G, M),
17305 ( Q=suspension(_, active, _, _)
17306 -> setarg(2, Q, inactive),
17307 spawns_all___2__5__1__9(V,
17308 C,
17309 E,
17310 W,
17311 X,
17312 D,
17313 U,
17314 Q)
17315 ; true
17316 )
17317 ; spawns_all___2__5__1__9(V,
17318 C,
17319 E,
17320 W,
17321 X,
17322 D,
17323 U,
17324 Q)
17325 ).
17326spawns_all___2__5(B, C, A) :-
17327 A=suspension(D, not_stored_yet, B, C),
17328 'chr gen_id'(D),
17329 spawns_all___2__6(B, C, A).
17330spawns_all___2__6(B, D, E) :-
17331 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
17332 A),
17333 lookup_ht(A, B, C), !,
17334 spawns_all___2__6__0__10(C, B, D, E).
17335spawns_all___2__6__0__10([], A, B, C) :-
17336 spawns_all___2__7(A, B, C).
17337spawns_all___2__6__0__10([A|K], C, J, F) :-
17338 ( A=suspension(_, active, _, _, E, _, B, D, _),
17339 B==C,
17340 \+ \+ spawns_all_triggers_implies_spawns_all,
17341 \+ is_passive(C, D),
17342 may_trigger(E)
17343 -> ( arg(2, F, G),
17344 setarg(2, F, active),
17345 ( G==not_stored_yet
17346 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
17347 H),
17348 insert_ht(H, C, F)
17349 ),
17350 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
17351 I),
17352 insert_ht(I, k(C, J), F)
17353 ; true
17354 )
17355 ),
17356 spawns_all_triggers_implies_spawns_all,
17357 ( F=suspension(_, active, _, _)
17358 -> setarg(2, F, inactive),
17359 spawns_all___2__6__0__10(K, C, J, F)
17360 ; true
17361 )
17362 ; spawns_all___2__6__0__10(K, C, J, F)
17363 ).
17364spawns_all___2__6(A, B, C) :-
17365 spawns_all___2__7(A, B, C).
17366spawns_all___2__7(D, F, A) :-
17367 arg(2, A, B),
17368 setarg(2, A, active),
17369 ( B==not_stored_yet
17370 -> ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
17371 C),
17372 insert_ht(C, D, A)
17373 ),
17374 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
17375 E),
17376 insert_ht(E, k(D, F), A)
17377 ; true
17378 ).
17379spawns_all_triggers(A, B) :-
17380 spawns_all_triggers___2__0(A, B, _).
17381spawns_all_triggers___2__0(B, C, _) :-
17382 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17383 A),
17384 lookup_ht(A, k(B, C), D),
17385 member(E, D),
17386 E=suspension(_, active, _, _, _, _), !.
17387spawns_all_triggers___2__0(B, body, _) :-
17388 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17389 A),
17390 lookup_ht(A, k(B, guard), C),
17391 member(D, C),
17392 D=suspension(_, active, _, _, _, _), !.
17393spawns_all_triggers___2__0(B, guard, D) :-
17394 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17395 A),
17396 lookup_ht(A, k(B, body), C), !,
17397 spawns_all_triggers___2__0__0__4(C, B, guard, D).
17398spawns_all_triggers___2__0__0__4([], A, B, C) :-
17399 spawns_all_triggers___2__1(A, B, C).
17400spawns_all_triggers___2__0__0__4([A|K], C, L, M) :-
17401 ( A=suspension(_, active, _, _, B, D),
17402 B==C,
17403 D=body
17404 -> ( setarg(2, A, removed),
17405 ( arg(4, A, E),
17406 ( var(E)
17407 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17408 F),
17409 F=[_|G],
17410 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17411 G),
17412 ( G=[H|_]
17413 -> setarg(4, H, _)
17414 ; true
17415 )
17416 ; E=[_, _|G],
17417 setarg(2, E, G),
17418 ( G=[H|_]
17419 -> setarg(4, H, E)
17420 ; true
17421 )
17422 )
17423 ),
17424 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17425 I),
17426 delete_ht(I, C, A)
17427 ),
17428 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17429 J),
17430 delete_ht(J, k(C, body), A)
17431 ),
17432 spawns_all_triggers___2__0__0__4(K,
17433 C,
17434 L,
17435 M)
17436 ; spawns_all_triggers___2__0__0__4(K,
17437 C,
17438 L,
17439 M)
17440 ).
17441spawns_all_triggers___2__0(A, B, C) :-
17442 spawns_all_triggers___2__1(A, B, C).
17443spawns_all_triggers___2__1(B, C, F) :-
17444 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
17445 A),
17446 lookup_ht(A, k(B, C), D),
17447 member(E, D),
17448 E=suspension(_, active, _, _), !,
17449 ( var(F)
17450 -> true
17451 ; arg(2, F, G),
17452 setarg(2, F, removed),
17453 ( G==not_stored_yet
17454 -> true
17455 ; ( arg(4, F, H),
17456 ( var(H)
17457 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17458 I),
17459 I=[_|J],
17460 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17461 J),
17462 ( J=[K|_]
17463 -> setarg(4, K, _)
17464 ; true
17465 )
17466 ; H=[_, _|J],
17467 setarg(2, H, J),
17468 ( J=[K|_]
17469 -> setarg(4, K, H)
17470 ; true
17471 )
17472 )
17473 ),
17474 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17475 L),
17476 delete_ht(L, B, F)
17477 ),
17478 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17479 M),
17480 delete_ht(M, k(B, C), F)
17481 )
17482 ).
17483spawns_all_triggers___2__1(B, body, E) :-
17484 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
17485 A),
17486 lookup_ht(A, k(B, guard), C),
17487 member(D, C),
17488 D=suspension(_, active, _, _), !,
17489 ( var(E)
17490 -> true
17491 ; arg(2, E, F),
17492 setarg(2, E, removed),
17493 ( F==not_stored_yet
17494 -> true
17495 ; ( arg(4, E, G),
17496 ( var(G)
17497 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17498 H),
17499 H=[_|I],
17500 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17501 I),
17502 ( I=[J|_]
17503 -> setarg(4, J, _)
17504 ; true
17505 )
17506 ; G=[_, _|I],
17507 setarg(2, G, I),
17508 ( I=[J|_]
17509 -> setarg(4, J, G)
17510 ; true
17511 )
17512 )
17513 ),
17514 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17515 K),
17516 delete_ht(K, B, E)
17517 ),
17518 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17519 L),
17520 delete_ht(L, k(B, body), E)
17521 )
17522 ).
17523spawns_all_triggers___2__1(B, C, E) :-
17524 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17525 A),
17526 lookup_ht(A, k(B, C), D), !,
17527 spawns_all_triggers___2__1__0__7(D, B, C, E).
17528spawns_all_triggers___2__1__0__7([], A, B, C) :-
17529 spawns_all_triggers___2__2(A, B, C).
17530spawns_all_triggers___2__1__0__7([A|P], C, E, Q) :-
17531 ( ( A=suspension(_, active, _, _, B, D, F),
17532 B==C,
17533 D==E
17534 ),
17535 may_trigger(F)
17536 -> ( setarg(2, A, removed),
17537 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
17538 G),
17539 delete_ht(G, k(C, F), A)
17540 ),
17541 ( arg(4, A, H),
17542 ( var(H)
17543 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17544 I),
17545 I=[_|J],
17546 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
17547 J),
17548 ( J=[K|_]
17549 -> setarg(4, K, _)
17550 ; true
17551 )
17552 ; H=[_, _|J],
17553 setarg(2, H, J),
17554 ( J=[K|_]
17555 -> setarg(4, K, H)
17556 ; true
17557 )
17558 )
17559 ),
17560 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17561 L),
17562 delete_ht(L, k(C, E), A)
17563 ),
17564 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
17565 M),
17566 delete_ht(M, C, A)
17567 ),
17568 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17569 N),
17570 delete_ht(N, F, A)
17571 ),
17572 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
17573 O),
17574 delete_ht(O, k(C, E, F), A)
17575 ),
17576 spawns_all_triggers___2__1__0__7(P,
17577 C,
17578 E,
17579 Q)
17580 ; spawns_all_triggers___2__1__0__7(P,
17581 C,
17582 E,
17583 Q)
17584 ).
17585spawns_all_triggers___2__1(A, B, C) :-
17586 spawns_all_triggers___2__2(A, B, C).
17587spawns_all_triggers___2__2(B, guard, D) :-
17588 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17589 A),
17590 lookup_ht(A, k(B, body), C), !,
17591 spawns_all_triggers___2__2__0__8(C, B, guard, D).
17592spawns_all_triggers___2__2__0__8([], A, B, C) :-
17593 spawns_all_triggers___2__3(A, B, C).
17594spawns_all_triggers___2__2__0__8([A|O], C, P, Q) :-
17595 ( ( A=suspension(_, active, _, _, B, D, E),
17596 B==C,
17597 D=body
17598 ),
17599 may_trigger(E)
17600 -> ( setarg(2, A, removed),
17601 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
17602 F),
17603 delete_ht(F, k(C, E), A)
17604 ),
17605 ( arg(4, A, G),
17606 ( var(G)
17607 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17608 H),
17609 H=[_|I],
17610 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
17611 I),
17612 ( I=[J|_]
17613 -> setarg(4, J, _)
17614 ; true
17615 )
17616 ; G=[_, _|I],
17617 setarg(2, G, I),
17618 ( I=[J|_]
17619 -> setarg(4, J, G)
17620 ; true
17621 )
17622 )
17623 ),
17624 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17625 K),
17626 delete_ht(K, k(C, body), A)
17627 ),
17628 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
17629 L),
17630 delete_ht(L, C, A)
17631 ),
17632 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17633 M),
17634 delete_ht(M, E, A)
17635 ),
17636 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
17637 N),
17638 delete_ht(N, k(C, body, E), A)
17639 ),
17640 spawns_all_triggers___2__2__0__8(O,
17641 C,
17642 P,
17643 Q)
17644 ; spawns_all_triggers___2__2__0__8(O,
17645 C,
17646 P,
17647 Q)
17648 ).
17649spawns_all_triggers___2__2(A, B, C) :-
17650 spawns_all_triggers___2__3(A, B, C).
17651spawns_all_triggers___2__3(J, L, C) :-
17652 nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
17653 A),
17654 member(B, A),
17655 B=suspension(_, active, _), !,
17656 ( var(C)
17657 -> true
17658 ; arg(2, C, D),
17659 setarg(2, C, removed),
17660 ( D==not_stored_yet
17661 -> true
17662 ; ( arg(4, C, E),
17663 ( var(E)
17664 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17665 F),
17666 F=[_|G],
17667 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17668 G),
17669 ( G=[H|_]
17670 -> setarg(4, H, _)
17671 ; true
17672 )
17673 ; E=[_, _|G],
17674 setarg(2, E, G),
17675 ( G=[H|_]
17676 -> setarg(4, H, E)
17677 ; true
17678 )
17679 )
17680 ),
17681 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17682 I),
17683 delete_ht(I, J, C)
17684 ),
17685 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17686 K),
17687 delete_ht(K, k(J, L), C)
17688 )
17689 ),
17690 spawns_all(J, L).
17691spawns_all_triggers___2__3(B, D, C) :-
17692 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
17693 A),
17694 lookup_ht(A, B, F), !,
17695 C=suspension(E, not_stored_yet, t, _, B, D),
17696 'chr gen_id'(E),
17697 spawns_all_triggers___2__3__0__10(F, B, D, C).
17698spawns_all_triggers___2__3__0__10([], A, B, C) :-
17699 spawns_all_triggers___2__4(A, B, C).
17700spawns_all_triggers___2__3__0__10([A|H], C, I, J) :-
17701 ( ( A=suspension(_, active, _, _, E, _, B, G, _),
17702 B==C
17703 ),
17704 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17705 D),
17706 lookup_ht(D, E, F)
17707 -> spawns_all_triggers___2__3__1__10(F,
17708 E,
17709 G,
17710 A,
17711 H,
17712 C,
17713 I,
17714 J)
17715 ; spawns_all_triggers___2__3__0__10(H, C, I, J)
17716 ).
17717spawns_all_triggers___2__3__1__10([], _, _, _, A, B, C, D) :-
17718 spawns_all_triggers___2__3__0__10(A, B, C, D).
17719spawns_all_triggers___2__3__1__10([A|Y], C, E, Z, A1, D, X, Q) :-
17720 ( ( A=suspension(_, active, _, _, G, M, B),
17721 B==C
17722 ),
17723 may_trigger(C),
17724 \+ is_passive(D, E)
17725 -> ( setarg(2, A, removed),
17726 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
17727 F),
17728 delete_ht(F, k(G, C), A)
17729 ),
17730 ( arg(4, A, H),
17731 ( var(H)
17732 -> nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17733 I),
17734 I=[_|J],
17735 b_setval('$chr_store_global_ground_chr_translate____spawns___3',
17736 J),
17737 ( J=[K|_]
17738 -> setarg(4, K, _)
17739 ; true
17740 )
17741 ; H=[_, _|J],
17742 setarg(2, H, J),
17743 ( J=[K|_]
17744 -> setarg(4, K, H)
17745 ; true
17746 )
17747 )
17748 ),
17749 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-12',
17750 L),
17751 delete_ht(L, k(G, M), A)
17752 ),
17753 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-1',
17754 N),
17755 delete_ht(N, G, A)
17756 ),
17757 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17758 O),
17759 delete_ht(O, C, A)
17760 ),
17761 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
17762 P),
17763 delete_ht(P, k(G, M, C), A)
17764 ),
17765 ( arg(2, Q, R),
17766 setarg(2, Q, active),
17767 ( R==not_stored_yet
17768 -> ( nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17769 S),
17770 T=[Q|S],
17771 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17772 T),
17773 ( S=[U|_]
17774 -> setarg(4, U, T)
17775 ; true
17776 )
17777 ),
17778 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17779 V),
17780 insert_ht(V, D, Q)
17781 ),
17782 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17783 W),
17784 insert_ht(W, k(D, X), Q)
17785 ; true
17786 )
17787 ),
17788 spawns_all_triggers(G, M),
17789 ( Q=suspension(_, active, _, _, _, _)
17790 -> setarg(2, Q, inactive),
17791 spawns_all_triggers___2__3__1__10(Y,
17792 C,
17793 E,
17794 Z,
17795 A1,
17796 D,
17797 X,
17798 Q)
17799 ; true
17800 )
17801 ; spawns_all_triggers___2__3__1__10(Y,
17802 C,
17803 E,
17804 Z,
17805 A1,
17806 D,
17807 X,
17808 Q)
17809 ).
17810spawns_all_triggers___2__3(B, C, A) :-
17811 A=suspension(D, not_stored_yet, t, _, B, C),
17812 'chr gen_id'(D),
17813 spawns_all_triggers___2__4(B, C, A).
17814spawns_all_triggers___2__4(B, D, E) :-
17815 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
17816 A),
17817 lookup_ht(A, B, C), !,
17818 spawns_all_triggers___2__4__0__11(C, B, D, E).
17819spawns_all_triggers___2__4__0__11([], A, B, C) :-
17820 spawns_all_triggers___2__5(A, B, C).
17821spawns_all_triggers___2__4__0__11([A|H], C, I, J) :-
17822 ( ( A=suspension(_, active, _, _, E, _, B, G, _),
17823 B==C
17824 ),
17825 nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-3',
17826 D),
17827 lookup_ht(D, E, F)
17828 -> spawns_all_triggers___2__4__1__11(F,
17829 E,
17830 G,
17831 A,
17832 H,
17833 C,
17834 I,
17835 J)
17836 ; spawns_all_triggers___2__4__0__11(H, C, I, J)
17837 ).
17838spawns_all_triggers___2__4__1__11([], _, _, _, A, B, C, D) :-
17839 spawns_all_triggers___2__4__0__11(A, B, C, D).
17840spawns_all_triggers___2__4__1__11([A|R], C, H, E, S, G, O, D) :-
17841 ( A=suspension(_, active, _, _, P, Q, B),
17842 B==C,
17843 ( F=t(123, D, E, A),
17844 '$novel_production'(D, F),
17845 '$novel_production'(A, F)
17846 ),
17847 \+ may_trigger(C),
17848 \+ is_passive(G, H)
17849 -> '$extend_history'(D, F),
17850 ( arg(2, D, I),
17851 setarg(2, D, active),
17852 ( I==not_stored_yet
17853 -> ( nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17854 J),
17855 K=[D|J],
17856 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17857 K),
17858 ( J=[L|_]
17859 -> setarg(4, L, K)
17860 ; true
17861 )
17862 ),
17863 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17864 M),
17865 insert_ht(M, G, D)
17866 ),
17867 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17868 N),
17869 insert_ht(N, k(G, O), D)
17870 ; true
17871 )
17872 ),
17873 spawns_all_triggers(P, Q),
17874 ( D=suspension(_, active, _, _, _, _)
17875 -> setarg(2, D, inactive),
17876 spawns_all_triggers___2__4__1__11(R,
17877 C,
17878 H,
17879 E,
17880 S,
17881 G,
17882 O,
17883 D)
17884 ; true
17885 )
17886 ; spawns_all_triggers___2__4__1__11(R,
17887 C,
17888 H,
17889 E,
17890 S,
17891 G,
17892 O,
17893 D)
17894 ).
17895spawns_all_triggers___2__4(A, B, C) :-
17896 spawns_all_triggers___2__5(A, B, C).
17897spawns_all_triggers___2__5(B, C, D) :-
17898 nb_getval('$chr_store_global_ground_chr_translate____spawns___3',
17899 A), !,
17900 spawns_all_triggers___2__5__0__12(A, B, C, D).
17901spawns_all_triggers___2__5__0__12([], A, B, C) :-
17902 spawns_all_triggers___2__6(A, B, C).
17903spawns_all_triggers___2__5__0__12([A|F], G, H, I) :-
17904 ( A=suspension(_, active, _, _, C, _, E),
17905 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
17906 B),
17907 lookup_ht(B, C, D)
17908 -> spawns_all_triggers___2__5__1__12(D,
17909 C,
17910 E,
17911 A,
17912 F,
17913 G,
17914 H,
17915 I)
17916 ; spawns_all_triggers___2__5__0__12(F, G, H, I)
17917 ).
17918spawns_all_triggers___2__5__1__12([], _, _, _, A, B, C, D) :-
17919 spawns_all_triggers___2__5__0__12(A, B, C, D).
17920spawns_all_triggers___2__5__1__12([A|R], C, I, D, S, O, Q, E) :-
17921 ( A=suspension(_, active, _, _, H, _, B, G, _),
17922 B==C,
17923 ( F=t(125, D, A, E),
17924 '$novel_production'(D, F),
17925 '$novel_production'(E, F)
17926 ),
17927 \+ is_passive(C, G),
17928 may_trigger(H),
17929 \+ may_trigger(I)
17930 -> '$extend_history'(E, F),
17931 ( arg(2, E, J),
17932 setarg(2, E, active),
17933 ( J==not_stored_yet
17934 -> ( nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17935 K),
17936 L=[E|K],
17937 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17938 L),
17939 ( K=[M|_]
17940 -> setarg(4, M, L)
17941 ; true
17942 )
17943 ),
17944 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17945 N),
17946 insert_ht(N, O, E)
17947 ),
17948 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17949 P),
17950 insert_ht(P, k(O, Q), E)
17951 ; true
17952 )
17953 ),
17954 spawns(O, Q, I),
17955 ( E=suspension(_, active, _, _, _, _)
17956 -> setarg(2, E, inactive),
17957 spawns_all_triggers___2__5__1__12(R,
17958 C,
17959 I,
17960 D,
17961 S,
17962 O,
17963 Q,
17964 E)
17965 ; true
17966 )
17967 ; spawns_all_triggers___2__5__1__12(R,
17968 C,
17969 I,
17970 D,
17971 S,
17972 O,
17973 Q,
17974 E)
17975 ).
17976spawns_all_triggers___2__5(A, B, C) :-
17977 spawns_all_triggers___2__6(A, B, C).
17978spawns_all_triggers___2__6(G, I, A) :-
17979 arg(2, A, B),
17980 setarg(2, A, active),
17981 ( B==not_stored_yet
17982 -> ( nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17983 C),
17984 D=[A|C],
17985 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
17986 D),
17987 ( C=[E|_]
17988 -> setarg(4, E, D)
17989 ; true
17990 )
17991 ),
17992 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
17993 F),
17994 insert_ht(F, G, A)
17995 ),
17996 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
17997 H),
17998 insert_ht(H, k(G, I), A)
17999 ; true
18000 ).
18001spawns_all_triggers_implies_spawns_all :-
18002 spawns_all_triggers_implies_spawns_all___0__0(_).
18003spawns_all_triggers_implies_spawns_all___0__0(_) :-
18004 nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18005 A),
18006 member(B, A),
18007 B=suspension(_, active, _), !,
18008 setarg(2, B, removed),
18009 arg(3, B, C),
18010 ( var(C)
18011 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18012 D),
18013 D=[_|E],
18014 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18015 E),
18016 ( E=[F|_]
18017 -> setarg(3, F, _)
18018 ; true
18019 )
18020 ; C=[_, _|E],
18021 setarg(2, C, E),
18022 ( E=[F|_]
18023 -> setarg(3, F, C)
18024 ; true
18025 )
18026 ),
18027 fail.
18028spawns_all_triggers_implies_spawns_all___0__0(A) :-
18029 nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
18030 C), !,
18031 A=suspension(B, not_stored_yet, _),
18032 'chr gen_id'(B),
18033 spawns_all_triggers_implies_spawns_all___0__0__0__3(C, A).
18034spawns_all_triggers_implies_spawns_all___0__0__0__3([], A) :-
18035 spawns_all_triggers_implies_spawns_all___0__1(A).
18036spawns_all_triggers_implies_spawns_all___0__0__0__3([A|O], J) :-
18037 ( A=suspension(_, active, _, _, G, I)
18038 -> ( setarg(2, A, removed),
18039 ( arg(4, A, B),
18040 ( var(B)
18041 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
18042 C),
18043 C=[_|D],
18044 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers___2',
18045 D),
18046 ( D=[E|_]
18047 -> setarg(4, E, _)
18048 ; true
18049 )
18050 ; B=[_, _|D],
18051 setarg(2, B, D),
18052 ( D=[E|_]
18053 -> setarg(4, E, B)
18054 ; true
18055 )
18056 )
18057 ),
18058 ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
18059 F),
18060 delete_ht(F, G, A)
18061 ),
18062 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
18063 H),
18064 delete_ht(H, k(G, I), A)
18065 ),
18066 ( arg(2, J, K),
18067 setarg(2, J, active),
18068 ( K==not_stored_yet
18069 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18070 L),
18071 M=[J|L],
18072 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18073 M),
18074 ( L=[N|_]
18075 -> setarg(3, N, M)
18076 ; true
18077 )
18078 ; true
18079 )
18080 ),
18081 spawns_all(G, I),
18082 ( J=suspension(_, active, _)
18083 -> setarg(2, J, inactive),
18084 spawns_all_triggers_implies_spawns_all___0__0__0__3(O,
18085 J)
18086 ; true
18087 )
18088 ; spawns_all_triggers_implies_spawns_all___0__0__0__3(O,
18089 J)
18090 ).
18091spawns_all_triggers_implies_spawns_all___0__0(A) :-
18092 A=suspension(B, not_stored_yet, _),
18093 'chr gen_id'(B),
18094 spawns_all_triggers_implies_spawns_all___0__1(A).
18095spawns_all_triggers_implies_spawns_all___0__1(A) :-
18096 arg(2, A, B),
18097 setarg(2, A, active),
18098 ( B==not_stored_yet
18099 -> nb_getval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18100 C),
18101 D=[A|C],
18102 b_setval('$chr_store_global_ground_chr_translate____spawns_all_triggers_implies_spawns_all___0',
18103 D),
18104 ( C=[E|_]
18105 -> setarg(3, E, D)
18106 ; true
18107 )
18108 ; true
18109 ).
18110all_spawned(B, E) :-
18111 nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
18112 A),
18113 ( lookup_ht(A, k(B, guard), C),
18114 member(D, C),
18115 D=suspension(_, active, _, _), !
18116 ; lookup_ht(A, k(B, E), F),
18117 member(G, F),
18118 G=suspension(_, active, _, _), !
18119 ).
18120all_spawned(_, _) :-
18121 fail.
18122is_observed(B, C, G) :-
18123 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
18124 A),
18125 lookup_ht(A, k(B, C), D),
18126 member(E, D),
18127 E=suspension(_, active, _, _, _, _, F, _, _), !,
18128 do_is_observed(B, F, G).
18129is_observed(_, _, _) :-
18130 fail.
18131do_is_observed(B, C, A) :-
18132 var(A), !,
18133 do_is_observed(B, C).
18134do_is_observed(B, K, I) :-
18135 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
18136 A),
18137 lookup_ht(A, B, C),
18138 member(D, C),
18139 D=suspension(_, active, _, _, _, _, F, _, _),
18140 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
18141 E),
18142 lookup_ht(E, F, G),
18143 member(H, G),
18144 H=suspension(_, active, _, _, P, _, _, N, _),
18145 H\==D,
18146 ground(I)
18147 ),
18148 ( ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-12',
18149 J),
18150 lookup_ht(J, k(K, I), L),
18151 member(M, L),
18152 M=suspension(_, active, _, _),
18153 \+ is_passive(F, N), !
18154 ; nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-123',
18155 O),
18156 lookup_ht(O, k(K, I, P), Q),
18157 member(R, Q),
18158 R=suspension(_, active, _, _, _, _, _),
18159 \+ is_passive(F, N), !
18160 )
18161 ; nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-12',
18162 S),
18163 lookup_ht(S, k(K, I), T),
18164 member(U, T),
18165 U=suspension(_, active, _, _, _, _),
18166 \+ is_passive(F, N),
18167 may_trigger(P), !
18168 ).
18169do_is_observed(_, _, _) :-
18170 chr_pp_flag(observation_analysis, off).
18171do_is_observed(B, J) :-
18172 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
18173 A),
18174 lookup_ht(A, B, C),
18175 member(D, C),
18176 D=suspension(_, active, _, _, _, _, F, _, _),
18177 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
18178 E),
18179 lookup_ht(E, F, G),
18180 member(H, G),
18181 H=suspension(_, active, _, _, O, _, _, M, _),
18182 H\==D
18183 ),
18184 ( ( nb_getval('$chr_store_multi_hash_chr_translate____spawns_all___2-1',
18185 I),
18186 lookup_ht(I, J, K),
18187 member(L, K),
18188 L=suspension(_, active, _, _),
18189 \+ is_passive(F, M), !
18190 ; nb_getval('$chr_store_multi_hash_chr_translate____spawns___3-13',
18191 N),
18192 lookup_ht(N, k(J, O), P),
18193 member(Q, P),
18194 Q=suspension(_, active, _, _, _, _, _),
18195 \+ is_passive(F, M), !
18196 )
18197 ; nb_getval('$chr_store_multi_hash_chr_translate____spawns_all_triggers___2-1',
18198 R),
18199 lookup_ht(R, J, S),
18200 member(T, S),
18201 T=suspension(_, active, _, _, _, _),
18202 \+ is_passive(F, M),
18203 may_trigger(O), !
18204 ).
18205do_is_observed(_, _) :-
18206 chr_pp_flag(observation_analysis, off).
18207generate_indexed_variables_body(B/C, G, H, I) :-
18208 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
18209 A),
18210 lookup_ht(A, B/C, D),
18211 member(E, D),
18212 E=suspension(_, active, _, _, _, J), !,
18213 get_indexing_spec(B/C, F),
18214 ( chr_pp_flag(term_indexing, on)
18215 -> spectermvars(F, G, B, C, H, I)
18216 ; get_constraint_type_det(B/C, K),
18217 create_indexed_variables_body(G,
18218 J,
18219 K,
18220 I,
18221 1,
18222 B/C,
18223 L,
18224 M),
18225 ( L==empty
18226 -> H=true,
18227 I=[]
18228 ; M==0
18229 -> ( G=[N]
18230 -> true
18231 ; N=..[term|G]
18232 ),
18233 H=term_variables(N, I)
18234 ; L=H
18235 )
18236 ).
18237generate_indexed_variables_body(A, _, _, _) :-
18238 chr_error(internal,
18239 'generate_indexed_variables_body: missing mode info for ~w.\n',
18240 [A]).
18241empty_named_history_initialisations(A, B) :-
18242 D=suspension(C, active, _, A, B),
18243 'chr gen_id'(C),
18244 nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18245 E),
18246 F=[D|E],
18247 b_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18248 F),
18249 ( E=[G|_]
18250 -> setarg(3, G, F)
18251 ; true
18252 ).
18253generate_empty_named_history_initialisation(A) :-
18254 generate_empty_named_history_initialisation___1__0(A, _).
18255generate_empty_named_history_initialisation___1__0(A, G) :-
18256 ( 'chr newvia_1'(A, B)
18257 -> get_attr(B, chr_translate, C),
18258 C=v(_, D, _, _, _, _, _, _, _, _, _)
18259 ; nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18260 D)
18261 ),
18262 member(E, D),
18263 E=suspension(_, active, _, _, F),
18264 F==A, !,
18265 ( var(G)
18266 -> true
18267 ; G=suspension(_, H, _, _, I),
18268 setarg(2, G, removed),
18269 ( H==not_stored_yet
18270 -> J=[]
18271 ; term_variables(I, J),
18272 ( arg(4, G, K),
18273 ( var(K)
18274 -> nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18275 L),
18276 L=[_|M],
18277 b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18278 M),
18279 ( M=[N|_]
18280 -> setarg(4, N, _)
18281 ; true
18282 )
18283 ; K=[_, _|M],
18284 setarg(2, K, M),
18285 ( M=[N|_]
18286 -> setarg(4, N, K)
18287 ; true
18288 )
18289 )
18290 ),
18291 detach_generate_empty_named_history_initialisation___1(J,
18292 G)
18293 )
18294 ).
18295generate_empty_named_history_initialisation___1__0(B, A) :-
18296 nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18297 D), !,
18298 ( var(A)
18299 -> A=suspension(C, not_stored_yet, 0, _, B),
18300 'chr gen_id'(C)
18301 ; true
18302 ),
18303 generate_empty_named_history_initialisation___1__0__0__3(D,
18304 B,
18305 A).
18306generate_empty_named_history_initialisation___1__0__0__3([], A, B) :-
18307 generate_empty_named_history_initialisation___1__1(A, B).
18308generate_empty_named_history_initialisation___1__0__0__3([A|T], O, F) :-
18309 ( A=suspension(_, active, _, P, S)
18310 -> ( setarg(2, A, removed),
18311 arg(3, A, B),
18312 ( var(B)
18313 -> nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18314 C),
18315 C=[_|D],
18316 b_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18317 D),
18318 ( D=[E|_]
18319 -> setarg(3, E, _)
18320 ; true
18321 )
18322 ; B=[_, _|D],
18323 setarg(2, B, D),
18324 ( D=[E|_]
18325 -> setarg(3, E, B)
18326 ; true
18327 )
18328 )
18329 ),
18330 ( arg(2, F, I),
18331 setarg(2, F, active),
18332 ( arg(3, F, G),
18333 H is G+1,
18334 setarg(3, F, H)
18335 ),
18336 ( I==not_stored_yet
18337 -> F=suspension(_, _, _, _, J),
18338 term_variables(J, N),
18339 ( nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18340 K),
18341 L=[F|K],
18342 b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18343 L),
18344 ( K=[M|_]
18345 -> setarg(4, M, L)
18346 ; true
18347 )
18348 ),
18349 attach_generate_empty_named_history_initialisation___1(N,
18350 F)
18351 ; true
18352 )
18353 ),
18354 ( empty_named_history_global_variable(O, Q),
18355 P=[(:-nb_setval(Q, 0))|R],
18356 empty_named_history_initialisations(R, S)
18357 ),
18358 ( F=suspension(_, active, H, _, _)
18359 -> setarg(2, F, inactive),
18360 generate_empty_named_history_initialisation___1__0__0__3(T,
18361 O,
18362 F)
18363 ; true
18364 )
18365 ; generate_empty_named_history_initialisation___1__0__0__3(T,
18366 O,
18367 F)
18368 ).
18369generate_empty_named_history_initialisation___1__0(B, A) :-
18370 ( var(A)
18371 -> A=suspension(C, not_stored_yet, 0, _, B),
18372 'chr gen_id'(C)
18373 ; true
18374 ),
18375 generate_empty_named_history_initialisation___1__1(B, A).
18376generate_empty_named_history_initialisation___1__1(_, A) :-
18377 arg(2, A, D),
18378 setarg(2, A, active),
18379 arg(3, A, B),
18380 C is B+1,
18381 setarg(3, A, C),
18382 ( D==not_stored_yet
18383 -> A=suspension(_, _, _, _, E),
18384 term_variables(E, I),
18385 ( nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18386 F),
18387 G=[A|F],
18388 b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18389 G),
18390 ( F=[H|_]
18391 -> setarg(4, H, G)
18392 ; true
18393 )
18394 ),
18395 attach_generate_empty_named_history_initialisation___1(I,
18396 A)
18397 ; true
18398 ).
18399find_empty_named_histories :-
18400 find_empty_named_histories___0__0(_).
18401find_empty_named_histories___0__0(A) :-
18402 nb_getval('$chr_store_constants_chr_translate____history___3___[3]___[]',
18403 C), !,
18404 A=suspension(B, not_stored_yet, t, _),
18405 'chr gen_id'(B),
18406 find_empty_named_histories___0__0__0__1(C, A).
18407find_empty_named_histories___0__0__0__1([], A) :-
18408 find_empty_named_histories___0__1(A).
18409find_empty_named_histories___0__0__0__1([A|J], C) :-
18410 ( A=suspension(_, active, _, _, I, B),
18411 B=[],
18412 D=t(142, C, A),
18413 '$novel_production'(C, D),
18414 '$novel_production'(A, D)
18415 -> '$extend_history'(C, D),
18416 ( arg(2, C, E),
18417 setarg(2, C, active),
18418 ( E==not_stored_yet
18419 -> nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
18420 F),
18421 G=[C|F],
18422 b_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
18423 G),
18424 ( F=[H|_]
18425 -> setarg(4, H, G)
18426 ; true
18427 )
18428 ; true
18429 )
18430 ),
18431 generate_empty_named_history_initialisation(I),
18432 ( C=suspension(_, active, _, _)
18433 -> setarg(2, C, inactive),
18434 find_empty_named_histories___0__0__0__1(J, C)
18435 ; true
18436 )
18437 ; find_empty_named_histories___0__0__0__1(J, C)
18438 ).
18439find_empty_named_histories___0__0(A) :-
18440 A=suspension(B, not_stored_yet, t, _),
18441 'chr gen_id'(B),
18442 find_empty_named_histories___0__1(A).
18443find_empty_named_histories___0__1(B) :-
18444 nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18445 A), !,
18446 find_empty_named_histories___0__1__0__2(A, B).
18447find_empty_named_histories___0__1__0__2([], A) :-
18448 find_empty_named_histories___0__2(A).
18449find_empty_named_histories___0__1__0__2([A|H], I) :-
18450 ( A=suspension(_, active, _, _, _)
18451 -> ( A=suspension(_, _, _, _, B),
18452 setarg(2, A, removed),
18453 term_variables(B, G),
18454 ( arg(4, A, C),
18455 ( var(C)
18456 -> nb_getval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18457 D),
18458 D=[_|E],
18459 b_setval('$chr_store_global_list_chr_translate____generate_empty_named_history_initialisation___1',
18460 E),
18461 ( E=[F|_]
18462 -> setarg(4, F, _)
18463 ; true
18464 )
18465 ; C=[_, _|E],
18466 setarg(2, C, E),
18467 ( E=[F|_]
18468 -> setarg(4, F, C)
18469 ; true
18470 )
18471 )
18472 ),
18473 detach_generate_empty_named_history_initialisation___1(G,
18474 A)
18475 ),
18476 find_empty_named_histories___0__1__0__2(H, I)
18477 ; find_empty_named_histories___0__1__0__2(H, I)
18478 ).
18479find_empty_named_histories___0__1(A) :-
18480 find_empty_named_histories___0__2(A).
18481find_empty_named_histories___0__2(G) :-
18482 nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18483 A),
18484 member(B, A),
18485 B=suspension(_, active, _, M, N), !,
18486 setarg(2, B, removed),
18487 arg(3, B, C),
18488 ( var(C)
18489 -> nb_getval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18490 D),
18491 D=[_|E],
18492 b_setval('$chr_store_global_ground_chr_translate____empty_named_history_initialisations___2',
18493 E),
18494 ( E=[F|_]
18495 -> setarg(3, F, _)
18496 ; true
18497 )
18498 ; C=[_, _|E],
18499 setarg(2, C, E),
18500 ( E=[F|_]
18501 -> setarg(3, F, C)
18502 ; true
18503 )
18504 ),
18505 ( var(G)
18506 -> true
18507 ; arg(2, G, H),
18508 setarg(2, G, removed),
18509 ( H==not_stored_yet
18510 -> true
18511 ; arg(4, G, I),
18512 ( var(I)
18513 -> nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
18514 J),
18515 J=[_|K],
18516 b_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
18517 K),
18518 ( K=[L|_]
18519 -> setarg(4, L, _)
18520 ; true
18521 )
18522 ; I=[_, _|K],
18523 setarg(2, I, K),
18524 ( K=[L|_]
18525 -> setarg(4, L, I)
18526 ; true
18527 )
18528 )
18529 )
18530 ),
18531 M=N.
18532find_empty_named_histories___0__2(A) :-
18533 ( var(A)
18534 -> true
18535 ; arg(2, A, B),
18536 setarg(2, A, removed),
18537 ( B==not_stored_yet
18538 -> true
18539 ; arg(4, A, C),
18540 ( var(C)
18541 -> nb_getval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
18542 D),
18543 D=[_|E],
18544 b_setval('$chr_store_global_ground_chr_translate____find_empty_named_histories___0',
18545 E),
18546 ( E=[F|_]
18547 -> setarg(4, F, _)
18548 ; true
18549 )
18550 ; C=[_, _|E],
18551 setarg(2, C, E),
18552 ( E=[F|_]
18553 -> setarg(4, F, C)
18554 ; true
18555 )
18556 )
18557 )
18558 ),
18559 chr_error(internal, 'find_empty_named_histories was not removed', []).
18560module_initializer(A) :-
18561 C=suspension(B, active, _, A),
18562 'chr gen_id'(B),
18563 nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',
18564 D),
18565 E=[C|D],
18566 b_setval('$chr_store_global_ground_chr_translate____module_initializer___1',
18567 E),
18568 ( D=[F|_]
18569 -> setarg(3, F, E)
18570 ; true
18571 ).
18572module_initializers(G) :-
18573 nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',
18574 A),
18575 member(B, A),
18576 B=suspension(_, active, _, H), !,
18577 setarg(2, B, removed),
18578 arg(3, B, C),
18579 ( var(C)
18580 -> nb_getval('$chr_store_global_ground_chr_translate____module_initializer___1',
18581 D),
18582 D=[_|E],
18583 b_setval('$chr_store_global_ground_chr_translate____module_initializer___1',
18584 E),
18585 ( E=[F|_]
18586 -> setarg(3, F, _)
18587 ; true
18588 )
18589 ; C=[_, _|E],
18590 setarg(2, C, E),
18591 ( E=[F|_]
18592 -> setarg(3, F, C)
18593 ; true
18594 )
18595 ),
18596 G=(H, I),
18597 module_initializers(I).
18598module_initializers(true).
18599actual_atomic_multi_hash_keys(B, I, O) :-
18600 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
18601 A),
18602 lookup_ht(A, B, C),
18603 member(D, C),
18604 D=suspension(_, active, _, J),
18605 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
18606 E),
18607 lookup_ht(E, B, F),
18608 member(G, F),
18609 G=suspension(_, active, _), !,
18610 setarg(2, D, removed),
18611 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
18612 H),
18613 delete_ht(H, B, D),
18614 selectchk(multi_hash([I]), J, Q),
18615 I=[K],
18616 ( get_constraint_arg_type(B, K, L),
18617 enumerated_atomic_type(L, M)
18618 -> N=M,
18619 P=complete
18620 ; N=O,
18621 P=incomplete
18622 ),
18623 actual_store_types(B,
18624
18625 [ atomic_constants(I, N, P)
18626 | Q
18627 ]).
18628actual_atomic_multi_hash_keys(B, C, H) :-
18629 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18630 A),
18631 lookup_ht(A, k(B, C), D),
18632 member(E, D),
18633 E=suspension(_, active, _, _, I), !,
18634 setarg(2, E, removed),
18635 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18636 F),
18637 delete_ht(F, k(B, C), E),
18638 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
18639 G),
18640 delete_ht(G, B, E),
18641 append(H, I, J),
18642 sort(J, K),
18643 actual_atomic_multi_hash_keys(B, C, K).
18644actual_atomic_multi_hash_keys(B, C, I) :-
18645 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18646 A),
18647 lookup_ht(A, k(B, C), D),
18648 member(E, D),
18649 E=suspension(_, active, _, _, H), !,
18650 setarg(2, E, removed),
18651 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18652 F),
18653 delete_ht(F, k(B, C), E),
18654 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
18655 G),
18656 delete_ht(G, B, E),
18657 append(H, I, J),
18658 sort(J, K),
18659 actual_ground_multi_hash_keys(B, C, K).
18660actual_atomic_multi_hash_keys(B, C, _) :-
18661 nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
18662 A),
18663 lookup_ht(A, k(B, C), D),
18664 member(E, D),
18665 E=suspension(_, active, _, _), !.
18666actual_atomic_multi_hash_keys(A, B, C) :-
18667 F=suspension(D, active, A, B, C),
18668 'chr gen_id'(D),
18669 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18670 E),
18671 insert_ht(E, k(A, B), F),
18672 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
18673 G),
18674 insert_ht(G, A, F).
18675actual_ground_multi_hash_keys(B, I, M) :-
18676 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
18677 A),
18678 lookup_ht(A, B, C),
18679 member(D, C),
18680 D=suspension(_, active, _, O),
18681 nb_getval('$chr_store_multi_hash_chr_translate____validate_store_type_assumption___1-1',
18682 E),
18683 lookup_ht(E, B, F),
18684 member(G, F),
18685 G=suspension(_, active, _), !,
18686 setarg(2, D, removed),
18687 nb_getval('$chr_store_multi_hash_chr_translate____actual_store_types___2-1',
18688 H),
18689 delete_ht(H, B, D),
18690 ( I=[J],
18691 get_constraint_arg_type(B, J, K),
18692 K=chr_enum(L)
18693 -> N=complete
18694 ; L=M,
18695 N=incomplete
18696 ),
18697 selectchk(multi_hash([I]), O, P),
18698 actual_store_types(B,
18699
18700 [ ground_constants(I, L, N)
18701 | P
18702 ]).
18703actual_ground_multi_hash_keys(B, C, H) :-
18704 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18705 A),
18706 lookup_ht(A, k(B, C), D),
18707 member(E, D),
18708 E=suspension(_, active, _, _, I), !,
18709 setarg(2, E, removed),
18710 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18711 F),
18712 delete_ht(F, k(B, C), E),
18713 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
18714 G),
18715 delete_ht(G, B, E),
18716 append(H, I, J),
18717 sort(J, K),
18718 actual_ground_multi_hash_keys(B, C, K).
18719actual_ground_multi_hash_keys(B, C, H) :-
18720 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18721 A),
18722 lookup_ht(A, k(B, C), D),
18723 member(E, D),
18724 E=suspension(_, active, _, _, I), !,
18725 setarg(2, E, removed),
18726 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18727 F),
18728 delete_ht(F, k(B, C), E),
18729 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
18730 G),
18731 delete_ht(G, B, E),
18732 append(H, I, J),
18733 sort(J, K),
18734 actual_ground_multi_hash_keys(B, C, K).
18735actual_ground_multi_hash_keys(B, C, _) :-
18736 nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
18737 A),
18738 lookup_ht(A, k(B, C), D),
18739 member(E, D),
18740 E=suspension(_, active, _, _), !.
18741actual_ground_multi_hash_keys(A, B, C) :-
18742 F=suspension(D, active, A, B, C),
18743 'chr gen_id'(D),
18744 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18745 E),
18746 insert_ht(E, k(A, B), F),
18747 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
18748 G),
18749 insert_ht(G, A, F).
18750actual_non_ground_multi_hash_key(B, C) :-
18751 nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
18752 A),
18753 lookup_ht(A, k(B, C), D),
18754 member(E, D),
18755 E=suspension(_, active, _, _), !.
18756actual_non_ground_multi_hash_key(B, C) :-
18757 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18758 A),
18759 lookup_ht(A, k(B, C), D), !,
18760 actual_non_ground_multi_hash_key___2__0__0__3(D, B, C).
18761actual_non_ground_multi_hash_key___2__0__0__3([], A, B) :-
18762 actual_non_ground_multi_hash_key___2__1(A, B).
18763actual_non_ground_multi_hash_key___2__0__0__3([A|H], C, E) :-
18764 ( A=suspension(_, active, B, D, _),
18765 B==C,
18766 D==E
18767 -> ( setarg(2, A, removed),
18768 ( nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-12',
18769 F),
18770 delete_ht(F, k(C, E), A)
18771 ),
18772 nb_getval('$chr_store_multi_hash_chr_translate____actual_atomic_multi_hash_keys___3-1',
18773 G),
18774 delete_ht(G, C, A)
18775 ),
18776 actual_non_ground_multi_hash_key___2__0__0__3(H,
18777 C,
18778 E)
18779 ; actual_non_ground_multi_hash_key___2__0__0__3(H,
18780 C,
18781 E)
18782 ).
18783actual_non_ground_multi_hash_key(A, B) :-
18784 actual_non_ground_multi_hash_key___2__1(A, B).
18785actual_non_ground_multi_hash_key___2__1(B, C) :-
18786 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18787 A),
18788 lookup_ht(A, k(B, C), D), !,
18789 actual_non_ground_multi_hash_key___2__1__0__4(D, B, C).
18790actual_non_ground_multi_hash_key___2__1__0__4([], A, B) :-
18791 actual_non_ground_multi_hash_key___2__2(A, B).
18792actual_non_ground_multi_hash_key___2__1__0__4([A|H], C, E) :-
18793 ( A=suspension(_, active, B, D, _),
18794 B==C,
18795 D==E
18796 -> ( setarg(2, A, removed),
18797 ( nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-12',
18798 F),
18799 delete_ht(F, k(C, E), A)
18800 ),
18801 nb_getval('$chr_store_multi_hash_chr_translate____actual_ground_multi_hash_keys___3-1',
18802 G),
18803 delete_ht(G, C, A)
18804 ),
18805 actual_non_ground_multi_hash_key___2__1__0__4(H,
18806 C,
18807 E)
18808 ; actual_non_ground_multi_hash_key___2__1__0__4(H,
18809 C,
18810 E)
18811 ).
18812actual_non_ground_multi_hash_key___2__1(A, B) :-
18813 actual_non_ground_multi_hash_key___2__2(A, B).
18814actual_non_ground_multi_hash_key___2__2(A, B) :-
18815 E=suspension(C, active, A, B),
18816 'chr gen_id'(C),
18817 nb_getval('$chr_store_multi_hash_chr_translate____actual_non_ground_multi_hash_key___2-12',
18818 D),
18819 insert_ht(D, k(A, B), E).
18820symbol_count(A, B) :-
18821 symbol_count___2__0(A, B, _).
18822symbol_count___2__0(A, T, M) :-
18823 ( 'chr newvia_1'(A, B)
18824 -> get_attr(B, chr_translate, C),
18825 C=v(_, _, _, D, _, _, _, _, _, _, _)
18826 ; nb_getval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18827 D)
18828 ),
18829 member(E, D),
18830 E=suspension(_, active, _, _, _, F, U),
18831 F==A, !,
18832 E=suspension(_, _, _, _, _, G, _),
18833 setarg(2, E, removed),
18834 term_variables(G, L),
18835 arg(5, E, H),
18836 ( var(H)
18837 -> nb_getval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18838 I),
18839 I=[_|J],
18840 b_setval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18841 J),
18842 ( J=[K|_]
18843 -> setarg(5, K, _)
18844 ; true
18845 )
18846 ; H=[_, _|J],
18847 setarg(2, H, J),
18848 ( J=[K|_]
18849 -> setarg(5, K, H)
18850 ; true
18851 )
18852 ),
18853 detach_fresh_symbol___2(L, E),
18854 ( var(M)
18855 -> true
18856 ; M=suspension(_, _, _, N, _),
18857 setarg(2, M, removed),
18858 term_variables(N, S),
18859 ( arg(3, M, O),
18860 ( var(O)
18861 -> nb_getval('$chr_store_global_list_chr_translate____symbol_count___2',
18862 P),
18863 P=[_|Q],
18864 b_setval('$chr_store_global_list_chr_translate____symbol_count___2',
18865 Q),
18866 ( Q=[R|_]
18867 -> setarg(3, R, _)
18868 ; true
18869 )
18870 ; O=[_, _|Q],
18871 setarg(2, O, Q),
18872 ( Q=[R|_]
18873 -> setarg(3, R, O)
18874 ; true
18875 )
18876 )
18877 ),
18878 detach_symbol_count___2(S, M)
18879 ),
18880 atom_concat(A, T, U),
18881 V is T+1,
18882 symbol_count(A, V).
18883symbol_count___2__0(B, C, A) :-
18884 ( var(A)
18885 -> ( A=suspension(D, active, _, B, C),
18886 term_variables(B, H),
18887 'chr gen_id'(D)
18888 ),
18889 ( nb_getval('$chr_store_global_list_chr_translate____symbol_count___2',
18890 E),
18891 F=[A|E],
18892 b_setval('$chr_store_global_list_chr_translate____symbol_count___2',
18893 F),
18894 ( E=[G|_]
18895 -> setarg(3, G, F)
18896 ; true
18897 )
18898 ),
18899 attach_symbol_count___2(H, A)
18900 ; setarg(2, A, active)
18901 ).
18902fresh_symbol(A, B) :-
18903 fresh_symbol___2__0(A, B, _).
18904fresh_symbol___2__0(A, V, M) :-
18905 ( 'chr newvia_1'(A, B)
18906 -> get_attr(B, chr_translate, C),
18907 C=v(_, _, D, _, _, _, _, _, _, _, _)
18908 ; nb_getval('$chr_store_global_list_chr_translate____symbol_count___2',
18909 D)
18910 ),
18911 member(E, D),
18912 E=suspension(_, active, _, F, U),
18913 F==A, !,
18914 E=suspension(_, _, _, G, _),
18915 setarg(2, E, removed),
18916 term_variables(G, L),
18917 arg(3, E, H),
18918 ( var(H)
18919 -> nb_getval('$chr_store_global_list_chr_translate____symbol_count___2',
18920 I),
18921 I=[_|J],
18922 b_setval('$chr_store_global_list_chr_translate____symbol_count___2',
18923 J),
18924 ( J=[K|_]
18925 -> setarg(3, K, _)
18926 ; true
18927 )
18928 ; H=[_, _|J],
18929 setarg(2, H, J),
18930 ( J=[K|_]
18931 -> setarg(3, K, H)
18932 ; true
18933 )
18934 ),
18935 detach_symbol_count___2(L, E),
18936 ( var(M)
18937 -> true
18938 ; M=suspension(_, N, _, _, _, O, _),
18939 setarg(2, M, removed),
18940 ( N==not_stored_yet
18941 -> P=[]
18942 ; term_variables(O, P),
18943 ( arg(5, M, Q),
18944 ( var(Q)
18945 -> nb_getval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18946 R),
18947 R=[_|S],
18948 b_setval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18949 S),
18950 ( S=[T|_]
18951 -> setarg(5, T, _)
18952 ; true
18953 )
18954 ; Q=[_, _|S],
18955 setarg(2, Q, S),
18956 ( S=[T|_]
18957 -> setarg(5, T, Q)
18958 ; true
18959 )
18960 )
18961 ),
18962 detach_fresh_symbol___2(P, M)
18963 )
18964 ),
18965 atom_concat(A, U, V),
18966 W is U+1,
18967 symbol_count(A, W).
18968fresh_symbol___2__0(B, C, A) :-
18969 ( var(A)
18970 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
18971 'chr gen_id'(D)
18972 ; true
18973 ),
18974 ( '$novel_production'(A, 157), !,
18975 '$extend_history'(A, 157),
18976 arg(2, A, G),
18977 setarg(2, A, active),
18978 arg(4, A, E),
18979 F is E+1,
18980 setarg(4, A, F),
18981 ( G==not_stored_yet
18982 -> A=suspension(_, _, _, _, _, H, _),
18983 term_variables(H, L),
18984 ( nb_getval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18985 I),
18986 J=[A|I],
18987 b_setval('$chr_store_global_list_chr_translate____fresh_symbol___2',
18988 J),
18989 ( I=[K|_]
18990 -> setarg(5, K, J)
18991 ; true
18992 )
18993 ),
18994 attach_fresh_symbol___2(L, A)
18995 ; true
18996 ),
18997 symbol_count(B, 0),
18998 ( A=suspension(_, active, _, F, _, _, _)
18999 -> setarg(2, A, inactive),
19000 fresh_symbol___2__1(B, C, A)
19001 ; true
19002 )
19003 ; fresh_symbol___2__1(B, C, A)
19004 ).
19005fresh_symbol___2__1(_, _, A) :-
19006 arg(2, A, D),
19007 setarg(2, A, active),
19008 arg(4, A, B),
19009 C is B+1,
19010 setarg(4, A, C),
19011 ( D==not_stored_yet
19012 -> A=suspension(_, _, _, _, _, E, _),
19013 term_variables(E, I),
19014 ( nb_getval('$chr_store_global_list_chr_translate____fresh_symbol___2',
19015 F),
19016 G=[A|F],
19017 b_setval('$chr_store_global_list_chr_translate____fresh_symbol___2',
19018 G),
19019 ( F=[H|_]
19020 -> setarg(5, H, G)
19021 ; true
19022 )
19023 ),
19024 attach_fresh_symbol___2(I, A)
19025 ; true
19026 ).
19027prolog_global_variable(B) :-
19028 nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',
19029 A),
19030 lookup_ht(A, B, C),
19031 member(D, C),
19032 D=suspension(_, active, _, _), !.
19033prolog_global_variable(A) :-
19034 C=suspension(B, active, _, A),
19035 'chr gen_id'(B),
19036 nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
19037 D),
19038 E=[C|D],
19039 b_setval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
19040 E),
19041 ( D=[F|_]
19042 -> setarg(3, F, E)
19043 ; true
19044 ),
19045 nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',
19046 G),
19047 insert_ht(G, A, C).
19048prolog_global_variables(I) :-
19049 nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
19050 A),
19051 member(B, A),
19052 B=suspension(_, active, _, H), !,
19053 setarg(2, B, removed),
19054 arg(3, B, C),
19055 ( var(C)
19056 -> nb_getval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
19057 D),
19058 D=[_|E],
19059 b_setval('$chr_store_global_ground_chr_translate____prolog_global_variable___1',
19060 E),
19061 ( E=[F|_]
19062 -> setarg(3, F, _)
19063 ; true
19064 )
19065 ; C=[_, _|E],
19066 setarg(2, C, E),
19067 ( E=[F|_]
19068 -> setarg(3, F, C)
19069 ; true
19070 )
19071 ),
19072 nb_getval('$chr_store_multi_hash_chr_translate____prolog_global_variable___1-1',
19073 G),
19074 delete_ht(G, H, B),
19075 I=[H|J],
19076 prolog_global_variables(J).
19077prolog_global_variables([]).
19078background_info(G) :-
19079 nb_getval('$chr_store_global_ground_chr_translate____background_info___1',
19080 A),
19081 member(B, A),
19082 B=suspension(_, active, _, H), !,
19083 setarg(2, B, removed),
19084 arg(3, B, C),
19085 ( var(C)
19086 -> nb_getval('$chr_store_global_ground_chr_translate____background_info___1',
19087 D),
19088 D=[_|E],
19089 b_setval('$chr_store_global_ground_chr_translate____background_info___1',
19090 E),
19091 ( E=[F|_]
19092 -> setarg(3, F, _)
19093 ; true
19094 )
19095 ; C=[_, _|E],
19096 setarg(2, C, E),
19097 ( E=[F|_]
19098 -> setarg(3, F, C)
19099 ; true
19100 )
19101 ),
19102 append(G, H, I),
19103 background_info(I).
19104background_info(A) :-
19105 C=suspension(B, active, _, A),
19106 'chr gen_id'(B),
19107 nb_getval('$chr_store_global_ground_chr_translate____background_info___1',
19108 D),
19109 E=[C|D],
19110 b_setval('$chr_store_global_ground_chr_translate____background_info___1',
19111 E),
19112 ( D=[F|_]
19113 -> setarg(3, F, E)
19114 ; true
19115 ).
19116background_info(A, B) :-
19117 background_info___2__0(A, B, _).
19118background_info___2__0(B, C, A) :-
19119 nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',
19120 E), !,
19121 ( var(A)
19122 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
19123 'chr gen_id'(D)
19124 ; true
19125 ),
19126 background_info___2__0__0__1(E, B, C, A).
19127background_info___2__0__0__1([], A, B, C) :-
19128 background_info___2__1(A, B, C).
19129background_info___2__0__0__1([A|Q], D, O, B) :-
19130 ( A=suspension(_, active, _, _, _, F, _),
19131 ( C=t(164, B, A),
19132 '$novel_production'(B, C),
19133 '$novel_production'(A, C)
19134 ),
19135 copy_term_nat(D, E),
19136 subsumes_term(E, F)
19137 -> '$extend_history'(B, C),
19138 ( arg(2, B, I),
19139 setarg(2, B, active),
19140 ( arg(4, B, G),
19141 H is G+1,
19142 setarg(4, B, H)
19143 ),
19144 ( I==not_stored_yet
19145 -> B=suspension(_, _, _, _, _, J, _),
19146 term_variables(J, N),
19147 ( nb_getval('$chr_store_global_list_chr_translate____background_info___2',
19148 K),
19149 L=[B|K],
19150 b_setval('$chr_store_global_list_chr_translate____background_info___2',
19151 L),
19152 ( K=[M|_]
19153 -> setarg(5, M, L)
19154 ; true
19155 )
19156 ),
19157 attach_background_info___2(N, B)
19158 ; true
19159 )
19160 ),
19161 ( copy_term_nat(D-O, F-P),
19162 get_bg_info_answer([P])
19163 ),
19164 ( B=suspension(_, active, _, H, _, _, _)
19165 -> setarg(2, B, inactive),
19166 background_info___2__0__0__1(Q,
19167 D,
19168 O,
19169 B)
19170 ; true
19171 )
19172 ; background_info___2__0__0__1(Q, D, O, B)
19173 ).
19174background_info___2__0(B, C, A) :-
19175 ( var(A)
19176 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
19177 'chr gen_id'(D)
19178 ; true
19179 ),
19180 background_info___2__1(B, C, A).
19181background_info___2__1(_, _, A) :-
19182 arg(2, A, D),
19183 setarg(2, A, active),
19184 arg(4, A, B),
19185 C is B+1,
19186 setarg(4, A, C),
19187 ( D==not_stored_yet
19188 -> A=suspension(_, _, _, _, _, E, _),
19189 term_variables(E, I),
19190 ( nb_getval('$chr_store_global_list_chr_translate____background_info___2',
19191 F),
19192 G=[A|F],
19193 b_setval('$chr_store_global_list_chr_translate____background_info___2',
19194 G),
19195 ( F=[H|_]
19196 -> setarg(5, H, G)
19197 ; true
19198 )
19199 ),
19200 attach_background_info___2(I, A)
19201 ; true
19202 ).
19203get_bg_info(C) :-
19204 nb_getval('$chr_store_global_ground_chr_translate____background_info___1',
19205 A),
19206 member(B, A),
19207 B=suspension(_, active, _, D), !,
19208 C=D.
19209get_bg_info([]).
19210get_bg_info(A, B) :-
19211 get_bg_info___2__0(A, B, _).
19212get_bg_info___2__0(B, C, A) :-
19213 nb_getval('$chr_store_global_list_chr_translate____background_info___2',
19214 E), !,
19215 ( var(A)
19216 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
19217 'chr gen_id'(D)
19218 ; true
19219 ),
19220 get_bg_info___2__0__0__1(E, B, C, A).
19221get_bg_info___2__0__0__1([], A, B, C) :-
19222 get_bg_info___2__1(A, B, C).
19223get_bg_info___2__0__0__1([A|Q], F, R, B) :-
19224 ( A=suspension(_, active, _, _, _, D, O),
19225 ( C=t(164, A, B),
19226 '$novel_production'(A, C),
19227 '$novel_production'(B, C)
19228 ),
19229 copy_term_nat(D, E),
19230 subsumes_term(E, F)
19231 -> '$extend_history'(B, C),
19232 ( arg(2, B, I),
19233 setarg(2, B, active),
19234 ( arg(4, B, G),
19235 H is G+1,
19236 setarg(4, B, H)
19237 ),
19238 ( I==not_stored_yet
19239 -> B=suspension(_, _, _, _, _, J, _),
19240 term_variables(J, N),
19241 ( nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',
19242 K),
19243 L=[B|K],
19244 b_setval('$chr_store_global_list_chr_translate____get_bg_info___2',
19245 L),
19246 ( K=[M|_]
19247 -> setarg(5, M, L)
19248 ; true
19249 )
19250 ),
19251 attach_get_bg_info___2(N, B)
19252 ; true
19253 )
19254 ),
19255 ( copy_term_nat(D-O, F-P),
19256 get_bg_info_answer([P])
19257 ),
19258 ( B=suspension(_, active, _, H, _, _, _)
19259 -> setarg(2, B, inactive),
19260 get_bg_info___2__0__0__1(Q, F, R, B)
19261 ; true
19262 )
19263 ; get_bg_info___2__0__0__1(Q, F, R, B)
19264 ).
19265get_bg_info___2__0(B, C, A) :-
19266 ( var(A)
19267 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
19268 'chr gen_id'(D)
19269 ; true
19270 ),
19271 get_bg_info___2__1(B, C, A).
19272get_bg_info___2__1(_, O, G) :-
19273 nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19274 A),
19275 member(B, A),
19276 B=suspension(_, active, _, P), !,
19277 setarg(2, B, removed),
19278 arg(3, B, C),
19279 ( var(C)
19280 -> nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19281 D),
19282 D=[_|E],
19283 b_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19284 E),
19285 ( E=[F|_]
19286 -> setarg(3, F, _)
19287 ; true
19288 )
19289 ; C=[_, _|E],
19290 setarg(2, C, E),
19291 ( E=[F|_]
19292 -> setarg(3, F, C)
19293 ; true
19294 )
19295 ),
19296 ( var(G)
19297 -> true
19298 ; G=suspension(_, H, _, _, _, I, _),
19299 setarg(2, G, removed),
19300 ( H==not_stored_yet
19301 -> J=[]
19302 ; term_variables(I, J),
19303 ( arg(5, G, K),
19304 ( var(K)
19305 -> nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',
19306 L),
19307 L=[_|M],
19308 b_setval('$chr_store_global_list_chr_translate____get_bg_info___2',
19309 M),
19310 ( M=[N|_]
19311 -> setarg(5, N, _)
19312 ; true
19313 )
19314 ; K=[_, _|M],
19315 setarg(2, K, M),
19316 ( M=[N|_]
19317 -> setarg(5, N, K)
19318 ; true
19319 )
19320 )
19321 ),
19322 detach_get_bg_info___2(J, G)
19323 )
19324 ),
19325 O=P.
19326get_bg_info___2__1(_, I, A) :-
19327 ( var(A)
19328 -> true
19329 ; A=suspension(_, B, _, _, _, C, _),
19330 setarg(2, A, removed),
19331 ( B==not_stored_yet
19332 -> D=[]
19333 ; term_variables(C, D),
19334 ( arg(5, A, E),
19335 ( var(E)
19336 -> nb_getval('$chr_store_global_list_chr_translate____get_bg_info___2',
19337 F),
19338 F=[_|G],
19339 b_setval('$chr_store_global_list_chr_translate____get_bg_info___2',
19340 G),
19341 ( G=[H|_]
19342 -> setarg(5, H, _)
19343 ; true
19344 )
19345 ; E=[_, _|G],
19346 setarg(2, E, G),
19347 ( G=[H|_]
19348 -> setarg(5, H, E)
19349 ; true
19350 )
19351 )
19352 ),
19353 detach_get_bg_info___2(D, A)
19354 )
19355 ),
19356 I=[].
19357get_bg_info_answer(G) :-
19358 nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19359 A),
19360 member(B, A),
19361 B=suspension(_, active, _, H), !,
19362 setarg(2, B, removed),
19363 arg(3, B, C),
19364 ( var(C)
19365 -> nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19366 D),
19367 D=[_|E],
19368 b_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19369 E),
19370 ( E=[F|_]
19371 -> setarg(3, F, _)
19372 ; true
19373 )
19374 ; C=[_, _|E],
19375 setarg(2, C, E),
19376 ( E=[F|_]
19377 -> setarg(3, F, C)
19378 ; true
19379 )
19380 ),
19381 append(G, H, I),
19382 get_bg_info_answer(I).
19383get_bg_info_answer(A) :-
19384 C=suspension(B, active, _, A),
19385 'chr gen_id'(B),
19386 nb_getval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19387 D),
19388 E=[C|D],
19389 b_setval('$chr_store_global_ground_chr_translate____get_bg_info_answer___1',
19390 E),
19391 ( D=[F|_]
19392 -> setarg(3, F, E)
19393 ; true
19394 ).
19395prev_guard_list(W, B, V, H, Z, Q, O, P) :-
19396 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
19397 lookup_ht(A, B, C),
19398 member(D, C),
19399 D=suspension(_, active, _, _, _, E),
19400 E=pragma(rule(F, J, N, _), _, _, _, _),
19401 F\==[],
19402 make_head_matchings_explicit(B, G, L),
19403 setof(I,
19404 chr_translate:head_subset(G, H, I),
19405 K), !,
19406 append(F, J, M),
19407 compute_derived_info(K,
19408 L,
19409 G,
19410 M,
19411 N,
19412 O,
19413 H,
19414 P,
19415 R,
19416 T),
19417 append(Q, R, S),
19418 normalize_conj_list(S, A1),
19419 append(T, P, U),
19420 normalize_conj_list(U, B1),
19421 next_prev_rule(V, X, Y),
19422 prev_guard_list(W,
19423 X,
19424 Y,
19425 H,
19426 Z,
19427 A1,
19428 O,
19429 B1).
19430prev_guard_list(C, A, B, F, G, H, I, J) :-
19431 ( A>0
19432 -> next_prev_rule(B, D, E),
19433 prev_guard_list(C,
19434 D,
19435 E,
19436 F,
19437 G,
19438 H,
19439 I,
19440 J)
19441 ; prev_guard_list(C, F, G, H, I, J)
19442 ).
19443prev_guard_list(A, B, C, D, E, F) :-
19444 prev_guard_list___6__0(A,
19445 B,
19446 C,
19447 D,
19448 E,
19449 F,
19450 _).
19451prev_guard_list___6__0(M, B, I, F, O, A, _) :-
19452 A\==[], !,
19453 head_types_modes_condition(A, B, C),
19454 conj2list(C, E),
19455 term_variables(B, D),
19456 append([chr_pp_headvariables(D)|E], F, G),
19457 normalize_conj_list(G, H),
19458 append(B, H, J),
19459 add_background_info([I|J], K),
19460 append(H, K, L),
19461 normalize_conj_list(L, N),
19462 prev_guard_list(M, B, I, N, O, []).
19463prev_guard_list___6__0(B, Y, F, H, G, A1, Z) :-
19464 ( nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
19465 lookup_ht(A, B, C)
19466 ),
19467 ( member(D, C),
19468 D=suspension(_, active, _, _, _, E),
19469 E=pragma(rule(S, T, F, L), V, W, X, B),
19470 F\==true,
19471 append(G, H, I),
19472 ( conj2list(F, J),
19473 append(I, J, K),
19474 guard_entailment:entails_guard(K, fail)
19475 -> M=fail
19476 ; simplify_guard(F, L, I, M, U)
19477 ),
19478 F\==M, !,
19479 setarg(2, D, removed),
19480 arg(4, D, N),
19481 ( var(N)
19482 -> nb_getval('$chr_store_global_ground_chr_translate____rule___2',
19483 O),
19484 O=[_|P],
19485 b_setval('$chr_store_global_ground_chr_translate____rule___2',
19486 P),
19487 ( P=[Q|_]
19488 -> setarg(4, Q, _)
19489 ; true
19490 )
19491 ; N=[_, _|P],
19492 setarg(2, N, P),
19493 ( P=[Q|_]
19494 -> setarg(4, Q, N)
19495 ; true
19496 )
19497 ),
19498 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
19499 R),
19500 delete_ht(R, B, D),
19501 rule(B,
19502 pragma(rule(S, T, M, U),
19503 V,
19504 W,
19505 X,
19506 B)),
19507 prev_guard_list(B, Y, M, H, G, [])
19508 ; !,
19509 Z=suspension(B1, not_stored_yet, t, _, B, Y, F, H, G, A1),
19510 'chr gen_id'(B1),
19511 prev_guard_list___6__0__0__3(C,
19512 B,
19513 Y,
19514 F,
19515 H,
19516 G,
19517 A1,
19518 Z)
19519 ).
19520prev_guard_list___6__0__0__3([], A, B, C, D, E, F, G) :-
19521 prev_guard_list___6__1(A,
19522 B,
19523 C,
19524 D,
19525 E,
19526 F,
19527 G).
19528prev_guard_list___6__0__0__3([A|R], C, S, G, I, H, T, D) :-
19529 ( A=suspension(_, active, _, _, B, F),
19530 B==C,
19531 ( E=t(178, D, A),
19532 '$novel_production'(D, E),
19533 '$novel_production'(A, E)
19534 ),
19535 chr_pp_flag(check_impossible_rules, on),
19536 F=pragma(rule(_, _, G, _), _, _, _, C),
19537 conj2list(G, K),
19538 append(H, I, J),
19539 append(J, K, L),
19540 guard_entailment:entails_guard(L, fail)
19541 -> '$extend_history'(D, E),
19542 ( arg(2, D, M),
19543 setarg(2, D, active),
19544 ( M==not_stored_yet
19545 -> ( nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
19546 N),
19547 O=[D|N],
19548 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
19549 O),
19550 ( N=[P|_]
19551 -> setarg(4, P, O)
19552 ; true
19553 )
19554 ),
19555 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
19556 Q),
19557 insert_ht(Q, C, D)
19558 ; true
19559 )
19560 ),
19561 ( chr_warning(weird_program,
19562 'Heads will never match or guard will always fail in ~@.\n\tThis rule will never fire!\n',
19563 [format_rule(F)]),
19564 set_all_passive(C)
19565 ),
19566 ( D=suspension(_, active, _, _, _, _, _, _, _, _)
19567 -> setarg(2, D, inactive),
19568 prev_guard_list___6__0__0__3(R,
19569 C,
19570 S,
19571 G,
19572 I,
19573 H,
19574 T,
19575 D)
19576 ; true
19577 )
19578 ; prev_guard_list___6__0__0__3(R,
19579 C,
19580 S,
19581 G,
19582 I,
19583 H,
19584 T,
19585 D)
19586 ).
19587prev_guard_list___6__0(B, C, D, E, F, G, A) :-
19588 A=suspension(H, not_stored_yet, t, _, B, C, D, E, F, G),
19589 'chr gen_id'(H),
19590 prev_guard_list___6__1(B,
19591 C,
19592 D,
19593 E,
19594 F,
19595 G,
19596 A).
19597prev_guard_list___6__1(B, D, E, F, G, H, I) :-
19598 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
19599 lookup_ht(A, B, C), !,
19600 prev_guard_list___6__1__0__4(C,
19601 B,
19602 D,
19603 E,
19604 F,
19605 G,
19606 H,
19607 I).
19608prev_guard_list___6__1__0__4([], A, B, C, D, E, F, G) :-
19609 prev_guard_list___6__2(A,
19610 B,
19611 C,
19612 D,
19613 E,
19614 F,
19615 G).
19616prev_guard_list___6__1__0__4([A|M1], C, L, E, G, F, N1, F1) :-
19617 ( ( A=suspension(_, active, _, _, B, D),
19618 B==C
19619 ),
19620 D=pragma(rule(J, K, E, H), X, Y, Z, C),
19621 simplify_heads(F, G, E, H, I, R),
19622 I\==[],
19623 extract_arguments(J, M),
19624 extract_arguments(K, N),
19625 extract_arguments(L, O),
19626 replace_some_heads(M,
19627 N,
19628 O,
19629 I,
19630 P,
19631 Q,
19632 E,
19633 H,
19634 S),
19635 substitute_arguments(J, P, U),
19636 substitute_arguments(K, Q, V),
19637 append(R, S, T),
19638 list2conj(T, W),
19639 L1=pragma(rule(U, V, E, (W, H)), X, Y, Z, C),
19640 ( J\==U
19641 ; K\==V
19642 )
19643 -> ( setarg(2, A, removed),
19644 ( arg(4, A, A1),
19645 ( var(A1)
19646 -> nb_getval('$chr_store_global_ground_chr_translate____rule___2',
19647 B1),
19648 B1=[_|C1],
19649 b_setval('$chr_store_global_ground_chr_translate____rule___2',
19650 C1),
19651 ( C1=[D1|_]
19652 -> setarg(4, D1, _)
19653 ; true
19654 )
19655 ; A1=[_, _|C1],
19656 setarg(2, A1, C1),
19657 ( C1=[D1|_]
19658 -> setarg(4, D1, A1)
19659 ; true
19660 )
19661 )
19662 ),
19663 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
19664 E1),
19665 delete_ht(E1, C, A)
19666 ),
19667 ( arg(2, F1, G1),
19668 setarg(2, F1, active),
19669 ( G1==not_stored_yet
19670 -> ( nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
19671 H1),
19672 I1=[F1|H1],
19673 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
19674 I1),
19675 ( H1=[J1|_]
19676 -> setarg(4, J1, I1)
19677 ; true
19678 )
19679 ),
19680 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
19681 K1),
19682 insert_ht(K1, C, F1)
19683 ; true
19684 )
19685 ),
19686 rule(C, L1),
19687 ( F1=suspension(_, active, _, _, _, _, _, _, _, _)
19688 -> setarg(2, F1, inactive),
19689 prev_guard_list___6__1__0__4(M1,
19690 C,
19691 L,
19692 E,
19693 G,
19694 F,
19695 N1,
19696 F1)
19697 ; true
19698 )
19699 ; prev_guard_list___6__1__0__4(M1,
19700 C,
19701 L,
19702 E,
19703 G,
19704 F,
19705 N1,
19706 F1)
19707 ).
19708prev_guard_list___6__1(A, B, C, D, E, F, G) :-
19709 prev_guard_list___6__2(A,
19710 B,
19711 C,
19712 D,
19713 E,
19714 F,
19715 G).
19716prev_guard_list___6__2(B, D, E, F, G, H, I) :-
19717 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
19718 lookup_ht(A, B, C), !,
19719 prev_guard_list___6__2__0__5(C,
19720 B,
19721 D,
19722 E,
19723 F,
19724 G,
19725 H,
19726 I).
19727prev_guard_list___6__2__0__5([], A, B, C, D, E, F, G) :-
19728 prev_guard_list___6__3(A,
19729 B,
19730 C,
19731 D,
19732 E,
19733 F,
19734 G).
19735prev_guard_list___6__2__0__5([A|G], C, H, I, J, K, L, M) :-
19736 ( ( A=suspension(_, active, _, _, B, F),
19737 B==C
19738 ),
19739 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
19740 D),
19741 lookup_ht(D, C, E)
19742 -> prev_guard_list___6__2__1__5(E,
19743 F,
19744 A,
19745 G,
19746 C,
19747 H,
19748 I,
19749 J,
19750 K,
19751 L,
19752 M)
19753 ; prev_guard_list___6__2__0__5(G,
19754 C,
19755 H,
19756 I,
19757 J,
19758 K,
19759 L,
19760 M)
19761 ).
19762prev_guard_list___6__2__1__5([], _, _, A, B, C, D, E, F, G, H) :-
19763 prev_guard_list___6__2__0__5(A,
19764 B,
19765 C,
19766 D,
19767 E,
19768 F,
19769 G,
19770 H).
19771prev_guard_list___6__2__1__5([A|H], I, J, K, C, L, M, N, O, P, Q) :-
19772 ( ( A=suspension(_, active, _, _, E, G, B, _, _),
19773 B==C
19774 ),
19775 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
19776 D),
19777 lookup_ht(D, k(E, C), F)
19778 -> prev_guard_list___6__2__2__5(F,
19779 E,
19780 G,
19781 A,
19782 H,
19783 I,
19784 J,
19785 K,
19786 C,
19787 L,
19788 M,
19789 N,
19790 O,
19791 P,
19792 Q)
19793 ; prev_guard_list___6__2__1__5(H,
19794 I,
19795 J,
19796 K,
19797 C,
19798 L,
19799 M,
19800 N,
19801 O,
19802 P,
19803 Q)
19804 ).
19805prev_guard_list___6__2__2__5([], _, _, _, A, B, C, D, E, F, G, H, I, J, K) :-
19806 prev_guard_list___6__2__1__5(A,
19807 B,
19808 C,
19809 D,
19810 E,
19811 F,
19812 G,
19813 H,
19814 I,
19815 J,
19816 K).
19817prev_guard_list___6__2__2__5([A|J], D, K, B, L, M, N, O, F, P, Q, R, S, T, U) :-
19818 ( ( A=suspension(_, active, _, _, C, H, E, I, _),
19819 A\==B,
19820 C==D,
19821 E==F
19822 ),
19823 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
19824 G)
19825 -> prev_guard_list___6__2__3__5(G,
19826 H,
19827 I,
19828 A,
19829 J,
19830 D,
19831 K,
19832 B,
19833 L,
19834 M,
19835 N,
19836 O,
19837 F,
19838 P,
19839 Q,
19840 R,
19841 S,
19842 T,
19843 U)
19844 ; prev_guard_list___6__2__2__5(J,
19845 D,
19846 K,
19847 B,
19848 L,
19849 M,
19850 N,
19851 O,
19852 F,
19853 P,
19854 Q,
19855 R,
19856 S,
19857 T,
19858 U)
19859 ).
19860prev_guard_list___6__2__3__5([], _, _, _, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) :-
19861 prev_guard_list___6__2__2__5(A,
19862 B,
19863 C,
19864 D,
19865 E,
19866 F,
19867 G,
19868 H,
19869 I,
19870 J,
19871 K,
19872 L,
19873 M,
19874 N,
19875 O).
19876prev_guard_list___6__2__3__5([A|U], B, S, V, W, F, C, X, Y, D, Z, A1, R, B1, C1, D1, E1, F1, L) :-
19877 ( A=suspension(_, active, _, G),
19878 B<C,
19879 chr_pp_flag(occurrence_subsumption, on),
19880 D=pragma(rule(E, _, _, _), _, _, _, _),
19881 E\==[],
19882 \+ tree_set_memberchk(F, G)
19883 -> ( setarg(2, A, removed),
19884 arg(3, A, H),
19885 ( var(H)
19886 -> nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
19887 I),
19888 I=[_|J],
19889 b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
19890 J),
19891 ( J=[K|_]
19892 -> setarg(3, K, _)
19893 ; true
19894 )
19895 ; H=[_, _|J],
19896 setarg(2, H, J),
19897 ( J=[K|_]
19898 -> setarg(3, K, H)
19899 ; true
19900 )
19901 )
19902 ),
19903 ( arg(2, L, M),
19904 setarg(2, L, active),
19905 ( M==not_stored_yet
19906 -> ( nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
19907 N),
19908 O=[L|N],
19909 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
19910 O),
19911 ( N=[P|_]
19912 -> setarg(4, P, O)
19913 ; true
19914 )
19915 ),
19916 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
19917 Q),
19918 insert_ht(Q, R, L)
19919 ; true
19920 )
19921 ),
19922 ( first_occ_in_rule(R, F, B, S),
19923 tree_set_add(G, F, T),
19924 multiple_occ_constraints_checked(T)
19925 ),
19926 ( L=suspension(_, active, _, _, _, _, _, _, _, _)
19927 -> setarg(2, L, inactive),
19928 prev_guard_list___6__2__3__5(U,
19929 B,
19930 S,
19931 V,
19932 W,
19933 F,
19934 C,
19935 X,
19936 Y,
19937 D,
19938 Z,
19939 A1,
19940 R,
19941 B1,
19942 C1,
19943 D1,
19944 E1,
19945 F1,
19946 L)
19947 ; true
19948 )
19949 ; prev_guard_list___6__2__3__5(U,
19950 B,
19951 S,
19952 V,
19953 W,
19954 F,
19955 C,
19956 X,
19957 Y,
19958 D,
19959 Z,
19960 A1,
19961 R,
19962 B1,
19963 C1,
19964 D1,
19965 E1,
19966 F1,
19967 L)
19968 ).
19969prev_guard_list___6__2(A, B, C, D, E, F, G) :-
19970 prev_guard_list___6__3(A,
19971 B,
19972 C,
19973 D,
19974 E,
19975 F,
19976 G).
19977prev_guard_list___6__3(N, _, _, _, _, _, G) :-
19978 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
19979 A),
19980 member(B, A),
19981 B=suspension(_, active, _, _), !,
19982 setarg(2, B, removed),
19983 arg(3, B, C),
19984 ( var(C)
19985 -> nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
19986 D),
19987 D=[_|E],
19988 b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
19989 E),
19990 ( E=[F|_]
19991 -> setarg(3, F, _)
19992 ; true
19993 )
19994 ; C=[_, _|E],
19995 setarg(2, C, E),
19996 ( E=[F|_]
19997 -> setarg(3, F, C)
19998 ; true
19999 )
20000 ),
20001 ( var(G)
20002 -> true
20003 ; arg(2, G, H),
20004 setarg(2, G, removed),
20005 ( H==not_stored_yet
20006 -> true
20007 ; ( arg(4, G, I),
20008 ( var(I)
20009 -> nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20010 J),
20011 J=[_|K],
20012 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20013 K),
20014 ( K=[L|_]
20015 -> setarg(4, L, _)
20016 ; true
20017 )
20018 ; I=[_, _|K],
20019 setarg(2, I, K),
20020 ( K=[L|_]
20021 -> setarg(4, L, I)
20022 ; true
20023 )
20024 )
20025 ),
20026 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
20027 M),
20028 delete_ht(M, N, G)
20029 )
20030 ).
20031prev_guard_list___6__3(G, _, _, _, _, _, A) :-
20032 arg(2, A, B),
20033 setarg(2, A, active),
20034 ( B==not_stored_yet
20035 -> ( nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20036 C),
20037 D=[A|C],
20038 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20039 D),
20040 ( C=[E|_]
20041 -> setarg(4, E, D)
20042 ; true
20043 )
20044 ),
20045 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
20046 F),
20047 insert_ht(F, G, A)
20048 ; true
20049 ).
20050simplify_guards(B) :-
20051 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
20052 lookup_ht(A, B, C),
20053 member(D, C),
20054 D=suspension(_, active, _, _, _, E), !,
20055 E=pragma(rule(F, G, J, _), ids(K, L), _, _, B),
20056 append(F, G, H),
20057 make_head_matchings_explicit_not_negated(H, W, X),
20058 tree_set_empty(I),
20059 multiple_occ_constraints_checked(I),
20060 apply_guard_wrt_term(H, J, Y),
20061 append(K, L, M),
20062 findall(tuple(N, O, B)-(-B),
20063 ( member(P, M),
20064 get_occurrence_from_id(N, O, B, P)
20065 ),
20066 Q),
20067 empty_q(R),
20068 insert_list_q(Q, R, S),
20069 next_prev_rule(S, _, T),
20070 next_prev_rule(T, U, V),
20071 prev_guard_list(B,
20072 U,
20073 V,
20074 W,
20075 J,
20076 [],
20077 X,
20078 [Y]),
20079 Z is B+1,
20080 simplify_guards(Z).
20081simplify_guards(_).
20082set_all_passive(A) :-
20083 set_all_passive___1__0(A, _).
20084set_all_passive___1__0(B, C) :-
20085 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
20086 A),
20087 lookup_ht(A, B, E), !,
20088 C=suspension(D, not_stored_yet, t, B),
20089 'chr gen_id'(D),
20090 set_all_passive___1__0__0__1(E, B, C).
20091set_all_passive___1__0__0__1([], A, B) :-
20092 set_all_passive___1__1(A, B).
20093set_all_passive___1__0__0__1([A|I], C, D) :-
20094 ( A=suspension(_, active, _, _, _, _, B, H, _),
20095 B==C,
20096 E=t(180, D, A),
20097 '$novel_production'(D, E),
20098 '$novel_production'(A, E)
20099 -> '$extend_history'(D, E),
20100 ( arg(2, D, F),
20101 setarg(2, D, active),
20102 ( F==not_stored_yet
20103 -> nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',
20104 G),
20105 insert_ht(G, C, D)
20106 ; true
20107 )
20108 ),
20109 passive(C, H),
20110 ( D=suspension(_, active, _, _)
20111 -> setarg(2, D, inactive),
20112 set_all_passive___1__0__0__1(I, C, D)
20113 ; true
20114 )
20115 ; set_all_passive___1__0__0__1(I, C, D)
20116 ).
20117set_all_passive___1__0(B, A) :-
20118 A=suspension(C, not_stored_yet, t, B),
20119 'chr gen_id'(C),
20120 set_all_passive___1__1(B, A).
20121set_all_passive___1__1(D, A) :-
20122 ( var(A)
20123 -> true
20124 ; arg(2, A, B),
20125 setarg(2, A, removed),
20126 ( B==not_stored_yet
20127 -> true
20128 ; nb_getval('$chr_store_multi_hash_chr_translate____set_all_passive___1-1',
20129 C),
20130 delete_ht(C, D, A)
20131 )
20132 ).
20133precompute_head_matchings :-
20134 precompute_head_matchings___0__0(_).
20135precompute_head_matchings___0__0(A) :-
20136 nb_getval('$chr_store_global_ground_chr_translate____rule___2', C), !,
20137 A=suspension(B, not_stored_yet, t, _),
20138 'chr gen_id'(B),
20139 precompute_head_matchings___0__0__0__1(C, A).
20140precompute_head_matchings___0__0__0__1([], A) :-
20141 precompute_head_matchings___0__1(A).
20142precompute_head_matchings___0__0__0__1([A|Q], B) :-
20143 ( A=suspension(_, active, _, _, N, H),
20144 C=t(174, A, B),
20145 '$novel_production'(A, C),
20146 '$novel_production'(B, C)
20147 -> '$extend_history'(B, C),
20148 ( arg(2, B, D),
20149 setarg(2, B, active),
20150 ( D==not_stored_yet
20151 -> nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
20152 E),
20153 F=[B|E],
20154 b_setval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
20155 F),
20156 ( E=[G|_]
20157 -> setarg(4, G, F)
20158 ; true
20159 )
20160 ; true
20161 )
20162 ),
20163 ( H=pragma(rule(I, J, _, _), _, _, _, _),
20164 append(I, J, K),
20165 make_head_matchings_explicit_(K, L, M),
20166 copy_term_nat(L-M, O-P),
20167 make_head_matchings_explicit_memo_table(N,
20168 O,
20169 P)
20170 ),
20171 ( B=suspension(_, active, _, _)
20172 -> setarg(2, B, inactive),
20173 precompute_head_matchings___0__0__0__1(Q, B)
20174 ; true
20175 )
20176 ; precompute_head_matchings___0__0__0__1(Q, B)
20177 ).
20178precompute_head_matchings___0__0(A) :-
20179 A=suspension(B, not_stored_yet, t, _),
20180 'chr gen_id'(B),
20181 precompute_head_matchings___0__1(A).
20182precompute_head_matchings___0__1(A) :-
20183 ( var(A)
20184 -> true
20185 ; arg(2, A, B),
20186 setarg(2, A, removed),
20187 ( B==not_stored_yet
20188 -> true
20189 ; arg(4, A, C),
20190 ( var(C)
20191 -> nb_getval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
20192 D),
20193 D=[_|E],
20194 b_setval('$chr_store_global_ground_chr_translate____precompute_head_matchings___0',
20195 E),
20196 ( E=[F|_]
20197 -> setarg(4, F, _)
20198 ; true
20199 )
20200 ; C=[_, _|E],
20201 setarg(2, C, E),
20202 ( E=[F|_]
20203 -> setarg(4, F, C)
20204 ; true
20205 )
20206 )
20207 )
20208 ).
20209make_head_matchings_explicit_memo_table(A, B, C) :-
20210 F=suspension(D, active, A, B, C),
20211 'chr gen_id'(D),
20212 nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',
20213 E),
20214 insert_ht(E, A, F).
20215make_head_matchings_explicit_memo_lookup(B, E, G) :-
20216 nb_getval('$chr_store_multi_hash_chr_translate____make_head_matchings_explicit_memo_table___3-1',
20217 A),
20218 lookup_ht(A, B, C),
20219 member(D, C),
20220 D=suspension(_, active, _, F, H), !,
20221 E=F,
20222 G=H.
20223make_head_matchings_explicit_memo_lookup(_, _, _) :-
20224 fail.
20225first_occ_in_rule(C, B, G, _) :-
20226 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
20227 A),
20228 lookup_ht(A, k(B, C), D),
20229 member(E, D),
20230 E=suspension(_, active, _, _, _, F, _, H, _),
20231 F<G, !,
20232 first_occ_in_rule(C, B, F, H).
20233first_occ_in_rule(D, A, E, F) :-
20234 A=B/C,
20235 functor(G, B, C),
20236 next_occ_in_rule(D, A, E, F, [], G).
20237next_occ_in_rule(B, F, K, L, _, M) :-
20238 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-1',
20239 A),
20240 lookup_ht(A, B, C),
20241 member(D, C),
20242 D=suspension(_, active, _, _, G),
20243 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-134',
20244 E),
20245 lookup_ht(E, k(F, B, G), H),
20246 member(I, H),
20247 I=suspension(_, active, _, _, _, J, _, _, _),
20248 J is K+1, !,
20249 next_occ_in_rule(B, F, J, L, _, M).
20250next_occ_in_rule(B, I, M, T, Y, U) :-
20251 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
20252 A),
20253 lookup_ht(A, B, C),
20254 member(D, C),
20255 D=suspension(_, active, _, _, _, S, O, Z, V, _),
20256 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', E),
20257 lookup_ht(E, B, F),
20258 member(G, F),
20259 G=suspension(_, active, _, _, _, N),
20260 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
20261 H),
20262 lookup_ht(H, k(I, B), J),
20263 member(K, J),
20264 K=suspension(_, active, _, _, _, L, _, X, _),
20265 L is M+1,
20266 N=pragma(rule(P, Q, O, _), ids(_, _), _, _, B), !,
20267 append(P, Q, R),
20268 add_failing_occ(N,
20269 R,
20270 S,
20271 T,
20272 W,
20273 U,
20274 V,
20275 I,
20276 B1),
20277 ( W==[chr_pp_void_info]
20278 -> next_occ_in_rule(B,
20279 I,
20280 L,
20281 X,
20282 Y,
20283 U)
20284 ; append(W, Y, F1),
20285 add_failing_occ(N,
20286 R,
20287 S,
20288 X,
20289 N1,
20290 U,
20291 V,
20292 I,
20293 C1),
20294 copy_term(Z, A1),
20295 variable_replacement(Z, A1, E1),
20296 copy_with_variable_replacement(Z, G1, B1),
20297 copy_with_variable_replacement(Z, D1, C1),
20298 copy_with_variable_replacement(D1, I1, E1),
20299 append(F1, G1, H1),
20300 append(H1, I1, K1),
20301 copy_with_variable_replacement(V, L1, B1),
20302 copy_with_variable_replacement(V, J1, C1),
20303 append(J1, K1, M1),
20304 append([chr_pp_active_constraint(U)|L1],
20305 M1,
20306 O1),
20307 list2conj(N1, P1),
20308 copy_term((F1, K1, O1, P1, U),
20309 (_, _, Q1, R1, _)),
20310 ( P1\=chr_pp_void_info
20311 -> ( guard_entailment:entails_guard(Q1, R1)
20312 -> passive(B, X)
20313 ; true
20314 )
20315 ; true
20316 ), !,
20317 next_occ_in_rule(B,
20318 I,
20319 L,
20320 X,
20321 F1,
20322 U)
20323 ).
20324next_occ_in_rule(_, _, _, _, _, _).
20325multiple_occ_constraints_checked(R) :-
20326 ( nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20327 A),
20328 member(B, A),
20329 B=suspension(_, active, _, _, D, _, _, _, _, _)
20330 ),
20331 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
20332 C),
20333 lookup_ht(C, D, E),
20334 member(F, E),
20335 F=suspension(_, active, _, _, K, O, _, _, _),
20336 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
20337 G),
20338 lookup_ht(G, D, H),
20339 member(I, H),
20340 I=suspension(_, active, _, _, _, P),
20341 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
20342 J),
20343 lookup_ht(J, k(K, D), L),
20344 member(M, L),
20345 M=suspension(_, active, _, _, _, N, _, S, _),
20346 M\==F,
20347 N<O,
20348 chr_pp_flag(occurrence_subsumption, on),
20349 P=pragma(rule(Q, _, _, _), _, _, _, _),
20350 Q\==[],
20351 \+ tree_set_memberchk(K, R), !,
20352 first_occ_in_rule(D, K, N, S),
20353 tree_set_add(R, K, T),
20354 multiple_occ_constraints_checked(T)
20355 ; !,
20356 setarg(2, B, removed),
20357 arg(4, B, U),
20358 ( var(U)
20359 -> nb_getval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20360 V),
20361 V=[_|W],
20362 b_setval('$chr_store_global_ground_chr_translate____prev_guard_list___6',
20363 W),
20364 ( W=[X|_]
20365 -> setarg(4, X, _)
20366 ; true
20367 )
20368 ; U=[_, _|W],
20369 setarg(2, U, W),
20370 ( W=[X|_]
20371 -> setarg(4, X, U)
20372 ; true
20373 )
20374 ),
20375 nb_getval('$chr_store_multi_hash_chr_translate____prev_guard_list___6-1',
20376 Y),
20377 delete_ht(Y, D, B)
20378 ).
20379multiple_occ_constraints_checked(A) :-
20380 C=suspension(B, active, _, A),
20381 'chr gen_id'(B),
20382 nb_getval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
20383 D),
20384 E=[C|D],
20385 b_setval('$chr_store_global_ground_chr_translate____multiple_occ_constraints_checked___1',
20386 E),
20387 ( D=[F|_]
20388 -> setarg(3, F, E)
20389 ; true
20390 ).
20391type_definition(A, B) :-
20392 type_definition___2__0(A, B, _).
20393type_definition___2__0(C, _, N) :-
20394 ( nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20395 A),
20396 member(B, A),
20397 B=suspension(_, active, _, _, _, D, _)
20398 ),
20399 ( functor(C, E, F),
20400 functor(D, E, F), !,
20401 B=suspension(_, _, _, _, _, G, H),
20402 setarg(2, B, removed),
20403 term_variables(term(G, H), M),
20404 arg(5, B, I),
20405 ( var(I)
20406 -> nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20407 J),
20408 J=[_|K],
20409 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20410 K),
20411 ( K=[L|_]
20412 -> setarg(5, L, _)
20413 ; true
20414 )
20415 ; I=[_, _|K],
20416 setarg(2, I, K),
20417 ( K=[L|_]
20418 -> setarg(5, L, I)
20419 ; true
20420 )
20421 ),
20422 detach_type_definition___2(M, B),
20423 ( var(N)
20424 -> true
20425 ; N=suspension(_, O, _, _, _, P, Q),
20426 setarg(2, N, removed),
20427 ( O==not_stored_yet
20428 -> R=[]
20429 ; term_variables(term(P, Q), R),
20430 ( arg(5, N, S),
20431 ( var(S)
20432 -> nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20433 T),
20434 T=[_|U],
20435 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20436 U),
20437 ( U=[V|_]
20438 -> setarg(5, V, _)
20439 ; true
20440 )
20441 ; S=[_, _|U],
20442 setarg(2, S, U),
20443 ( U=[V|_]
20444 -> setarg(5, V, S)
20445 ; true
20446 )
20447 )
20448 ),
20449 detach_type_definition___2(R, N)
20450 )
20451 ),
20452 chr_error(type_error,
20453 'Multiple definitions for type: ~w/~w.\n',
20454 [E, F])
20455 ; functor(D, W, X),
20456 functor(C, W, X), !,
20457 B=suspension(_, _, _, _, _, Y, Z),
20458 setarg(2, B, removed),
20459 term_variables(term(Y, Z), E1),
20460 arg(5, B, A1),
20461 ( var(A1)
20462 -> nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20463 B1),
20464 B1=[_|C1],
20465 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20466 C1),
20467 ( C1=[D1|_]
20468 -> setarg(5, D1, _)
20469 ; true
20470 )
20471 ; A1=[_, _|C1],
20472 setarg(2, A1, C1),
20473 ( C1=[D1|_]
20474 -> setarg(5, D1, A1)
20475 ; true
20476 )
20477 ),
20478 detach_type_definition___2(E1, B),
20479 ( var(N)
20480 -> true
20481 ; N=suspension(_, F1, _, _, _, G1, H1),
20482 setarg(2, N, removed),
20483 ( F1==not_stored_yet
20484 -> I1=[]
20485 ; term_variables(term(G1, H1), I1),
20486 ( arg(5, N, J1),
20487 ( var(J1)
20488 -> nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20489 K1),
20490 K1=[_|L1],
20491 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20492 L1),
20493 ( L1=[M1|_]
20494 -> setarg(5, M1, _)
20495 ; true
20496 )
20497 ; J1=[_, _|L1],
20498 setarg(2, J1, L1),
20499 ( L1=[M1|_]
20500 -> setarg(5, M1, J1)
20501 ; true
20502 )
20503 )
20504 ),
20505 detach_type_definition___2(I1, N)
20506 )
20507 ),
20508 chr_error(type_error,
20509 'Multiple definitions for type: ~w/~w.\n',
20510 [W, X])
20511 ).
20512type_definition___2__0(C, _, N) :-
20513 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20514 A),
20515 member(B, A),
20516 B=suspension(_, active, _, _, _, D, _),
20517 functor(C, E, F),
20518 functor(D, E, F), !,
20519 B=suspension(_, _, _, _, _, G, H),
20520 setarg(2, B, removed),
20521 term_variables(term(G, H), M),
20522 arg(5, B, I),
20523 ( var(I)
20524 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20525 J),
20526 J=[_|K],
20527 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20528 K),
20529 ( K=[L|_]
20530 -> setarg(5, L, _)
20531 ; true
20532 )
20533 ; I=[_, _|K],
20534 setarg(2, I, K),
20535 ( K=[L|_]
20536 -> setarg(5, L, I)
20537 ; true
20538 )
20539 ),
20540 detach_type_alias___2(M, B),
20541 ( var(N)
20542 -> true
20543 ; N=suspension(_, O, _, _, _, P, Q),
20544 setarg(2, N, removed),
20545 ( O==not_stored_yet
20546 -> R=[]
20547 ; term_variables(term(P, Q), R),
20548 ( arg(5, N, S),
20549 ( var(S)
20550 -> nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20551 T),
20552 T=[_|U],
20553 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20554 U),
20555 ( U=[V|_]
20556 -> setarg(5, V, _)
20557 ; true
20558 )
20559 ; S=[_, _|U],
20560 setarg(2, S, U),
20561 ( U=[V|_]
20562 -> setarg(5, V, S)
20563 ; true
20564 )
20565 )
20566 ),
20567 detach_type_definition___2(R, N)
20568 )
20569 ),
20570 chr_error(type_error,
20571 'Multiple definitions for type, once in a type definition and once as a type alias: ~w/~w.\n',
20572 [E, F]).
20573type_definition___2__0(B, C, A) :-
20574 nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
20575 E), !,
20576 ( var(A)
20577 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
20578 'chr gen_id'(D)
20579 ; true
20580 ),
20581 type_definition___2__0__0__5(E, B, C, A).
20582type_definition___2__0__0__5([], A, B, C) :-
20583 type_definition___2__1(A, B, C).
20584type_definition___2__0__0__5([A|W], B, X, L) :-
20585 ( A=suspension(_, active, _, C, V),
20586 nonvar(B),
20587 functor(B, D, E),
20588 functor(C, D, E)
20589 -> ( A=suspension(_, _, _, F, _),
20590 setarg(2, A, removed),
20591 term_variables(F, K),
20592 ( arg(3, A, G),
20593 ( var(G)
20594 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
20595 H),
20596 H=[_|I],
20597 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
20598 I),
20599 ( I=[J|_]
20600 -> setarg(3, J, _)
20601 ; true
20602 )
20603 ; G=[_, _|I],
20604 setarg(2, G, I),
20605 ( I=[J|_]
20606 -> setarg(3, J, G)
20607 ; true
20608 )
20609 )
20610 ),
20611 detach_unalias_type___2(K, A)
20612 ),
20613 ( arg(2, L, O),
20614 setarg(2, L, active),
20615 ( arg(4, L, M),
20616 N is M+1,
20617 setarg(4, L, N)
20618 ),
20619 ( O==not_stored_yet
20620 -> L=suspension(_, _, _, _, _, P, Q),
20621 term_variables(term(P, Q), U),
20622 ( nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20623 R),
20624 S=[L|R],
20625 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20626 S),
20627 ( R=[T|_]
20628 -> setarg(5, T, S)
20629 ; true
20630 )
20631 ),
20632 attach_type_definition___2(U, L)
20633 ; true
20634 )
20635 ),
20636 V=C,
20637 ( L=suspension(_, active, _, N, _, _, _)
20638 -> setarg(2, L, inactive),
20639 type_definition___2__0__0__5(W,
20640 B,
20641 X,
20642 L)
20643 ; true
20644 )
20645 ; type_definition___2__0__0__5(W, B, X, L)
20646 ).
20647type_definition___2__0(B, C, A) :-
20648 ( var(A)
20649 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
20650 'chr gen_id'(D)
20651 ; true
20652 ),
20653 type_definition___2__1(B, C, A).
20654type_definition___2__1(B, C, D) :-
20655 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
20656 A), !,
20657 type_definition___2__1__0__7(A, B, C, D).
20658type_definition___2__1__0__7([], A, B, C) :-
20659 type_definition___2__2(A, B, C).
20660type_definition___2__1__0__7([A|R], M, N, B) :-
20661 ( A=suspension(_, active, _, _),
20662 C=t(235, B, A),
20663 '$novel_production'(B, C),
20664 '$novel_production'(A, C)
20665 -> '$extend_history'(B, C),
20666 ( arg(2, B, F),
20667 setarg(2, B, active),
20668 ( arg(4, B, D),
20669 E is D+1,
20670 setarg(4, B, E)
20671 ),
20672 ( F==not_stored_yet
20673 -> B=suspension(_, _, _, _, _, G, H),
20674 term_variables(term(G, H), L),
20675 ( nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20676 I),
20677 J=[B|I],
20678 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20679 J),
20680 ( I=[K|_]
20681 -> setarg(5, K, J)
20682 ; true
20683 )
20684 ),
20685 attach_type_definition___2(L, B)
20686 ; true
20687 )
20688 ),
20689 ( copy_term_nat(M-N, O-P),
20690 maplist(dynamic_type_check_clause(O), P, Q),
20691 dynamic_type_check_clauses(Q)
20692 ),
20693 ( B=suspension(_, active, _, E, _, _, _)
20694 -> setarg(2, B, inactive),
20695 type_definition___2__1__0__7(R,
20696 M,
20697 N,
20698 B)
20699 ; true
20700 )
20701 ; type_definition___2__1__0__7(R, M, N, B)
20702 ).
20703type_definition___2__1(A, B, C) :-
20704 type_definition___2__2(A, B, C).
20705type_definition___2__2(B, C, D) :-
20706 nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
20707 A), !,
20708 type_definition___2__2__0__8(A, B, C, D).
20709type_definition___2__2__0__8([], A, B, C) :-
20710 type_definition___2__3(A, B, C).
20711type_definition___2__2__0__8([A|W], C, V, L) :-
20712 ( A=suspension(_, active, _, B),
20713 functor(B, D, E),
20714 functor(C, D, E)
20715 -> ( A=suspension(_, _, _, F),
20716 setarg(2, A, removed),
20717 term_variables(F, K),
20718 ( arg(3, A, G),
20719 ( var(G)
20720 -> nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
20721 H),
20722 H=[_|I],
20723 b_setval('$chr_store_global_list_chr_translate____atomic_type___1',
20724 I),
20725 ( I=[J|_]
20726 -> setarg(3, J, _)
20727 ; true
20728 )
20729 ; G=[_, _|I],
20730 setarg(2, G, I),
20731 ( I=[J|_]
20732 -> setarg(3, J, G)
20733 ; true
20734 )
20735 )
20736 ),
20737 detach_atomic_type___1(K, A)
20738 ),
20739 ( arg(2, L, O),
20740 setarg(2, L, active),
20741 ( arg(4, L, M),
20742 N is M+1,
20743 setarg(4, L, N)
20744 ),
20745 ( O==not_stored_yet
20746 -> L=suspension(_, _, _, _, _, P, Q),
20747 term_variables(term(P, Q), U),
20748 ( nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20749 R),
20750 S=[L|R],
20751 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20752 S),
20753 ( R=[T|_]
20754 -> setarg(5, T, S)
20755 ; true
20756 )
20757 ),
20758 attach_type_definition___2(U, L)
20759 ; true
20760 )
20761 ),
20762 maplist(atomic, V),
20763 ( L=suspension(_, active, _, N, _, _, _)
20764 -> setarg(2, L, inactive),
20765 type_definition___2__2__0__8(W,
20766 C,
20767 V,
20768 L)
20769 ; true
20770 )
20771 ; type_definition___2__2__0__8(W, C, V, L)
20772 ).
20773type_definition___2__2(A, B, C) :-
20774 type_definition___2__3(A, B, C).
20775type_definition___2__3(_, _, A) :-
20776 arg(2, A, D),
20777 setarg(2, A, active),
20778 arg(4, A, B),
20779 C is B+1,
20780 setarg(4, A, C),
20781 ( D==not_stored_yet
20782 -> A=suspension(_, _, _, _, _, E, F),
20783 term_variables(term(E, F), J),
20784 ( nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
20785 G),
20786 H=[A|G],
20787 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
20788 H),
20789 ( G=[I|_]
20790 -> setarg(5, I, H)
20791 ; true
20792 )
20793 ),
20794 attach_type_definition___2(J, A)
20795 ; true
20796 ).
20797type_alias(A, B) :-
20798 type_alias___2__0(A, B, _).
20799type_alias___2__0(A, K, B) :-
20800 var(A), !,
20801 ( var(B)
20802 -> true
20803 ; B=suspension(_, C, _, _, _, D, E),
20804 setarg(2, B, removed),
20805 ( C==not_stored_yet
20806 -> F=[]
20807 ; term_variables(term(D, E), F),
20808 ( arg(5, B, G),
20809 ( var(G)
20810 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20811 H),
20812 H=[_|I],
20813 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20814 I),
20815 ( I=[J|_]
20816 -> setarg(5, J, _)
20817 ; true
20818 )
20819 ; G=[_, _|I],
20820 setarg(2, G, I),
20821 ( I=[J|_]
20822 -> setarg(5, J, G)
20823 ; true
20824 )
20825 )
20826 ),
20827 detach_type_alias___2(F, B)
20828 )
20829 ),
20830 chr_error(type_error,
20831 'Variable alias definition: "~w".\n',
20832 [(:-chr_type A==K)]).
20833type_alias___2__0(K, A, B) :-
20834 var(A), !,
20835 ( var(B)
20836 -> true
20837 ; B=suspension(_, C, _, _, _, D, E),
20838 setarg(2, B, removed),
20839 ( C==not_stored_yet
20840 -> F=[]
20841 ; term_variables(term(D, E), F),
20842 ( arg(5, B, G),
20843 ( var(G)
20844 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20845 H),
20846 H=[_|I],
20847 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20848 I),
20849 ( I=[J|_]
20850 -> setarg(5, J, _)
20851 ; true
20852 )
20853 ; G=[_, _|I],
20854 setarg(2, G, I),
20855 ( I=[J|_]
20856 -> setarg(5, J, G)
20857 ; true
20858 )
20859 )
20860 ),
20861 detach_type_alias___2(F, B)
20862 )
20863 ),
20864 chr_error(type_error,
20865 'Variable alias definition: "~w".\n',
20866 [(:-chr_type K==A)]).
20867type_alias___2__0(A, B, C) :-
20868 subsumes_term(A, B), !,
20869 ( var(C)
20870 -> true
20871 ; C=suspension(_, D, _, _, _, E, F),
20872 setarg(2, C, removed),
20873 ( D==not_stored_yet
20874 -> G=[]
20875 ; term_variables(term(E, F), G),
20876 ( arg(5, C, H),
20877 ( var(H)
20878 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20879 I),
20880 I=[_|J],
20881 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20882 J),
20883 ( J=[K|_]
20884 -> setarg(5, K, _)
20885 ; true
20886 )
20887 ; H=[_, _|J],
20888 setarg(2, H, J),
20889 ( J=[K|_]
20890 -> setarg(5, K, H)
20891 ; true
20892 )
20893 )
20894 ),
20895 detach_type_alias___2(G, C)
20896 )
20897 ),
20898 chr_error(type_error,
20899 'Cyclic alias definition: "~w".\n',
20900 [A==B]).
20901type_alias___2__0(C, Y, N) :-
20902 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20903 A),
20904 ( member(B, A),
20905 B=suspension(_, active, _, _, _, D, Z),
20906 ( ( functor(C, E, F),
20907 functor(D, E, F),
20908 \+ C\=D, !,
20909 B=suspension(_, _, _, _, _, G, H),
20910 setarg(2, B, removed),
20911 term_variables(term(G, H), M),
20912 arg(5, B, I),
20913 ( var(I)
20914 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20915 J),
20916 J=[_|K],
20917 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20918 K),
20919 ( K=[L|_]
20920 -> setarg(5, L, _)
20921 ; true
20922 )
20923 ; I=[_, _|K],
20924 setarg(2, I, K),
20925 ( K=[L|_]
20926 -> setarg(5, L, I)
20927 ; true
20928 )
20929 ),
20930 detach_type_alias___2(M, B),
20931 ( var(N)
20932 -> true
20933 ; N=suspension(_, O, _, _, _, P, Q),
20934 setarg(2, N, removed),
20935 ( O==not_stored_yet
20936 -> R=[]
20937 ; term_variables(term(P, Q), R),
20938 ( arg(5, N, S),
20939 ( var(S)
20940 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20941 T),
20942 T=[_|U],
20943 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20944 U),
20945 ( U=[V|_]
20946 -> setarg(5, V, _)
20947 ; true
20948 )
20949 ; S=[_, _|U],
20950 setarg(2, S, U),
20951 ( U=[V|_]
20952 -> setarg(5, V, S)
20953 ; true
20954 )
20955 )
20956 ),
20957 detach_type_alias___2(R, N)
20958 )
20959 ),
20960 copy_term_nat(C, W),
20961 copy_term_nat(D, X),
20962 W=X,
20963 chr_error(type_error,
20964 'Ambiguous type aliases: you have defined \n\t`~w\'\n\t`~w\'\n\tresulting in two definitions for "~w".\n',
20965 [C==Y, D==Z, W])
20966 ; functor(D, A1, B1),
20967 functor(C, A1, B1),
20968 \+ D\=C, !,
20969 B=suspension(_, _, _, _, _, C1, D1),
20970 setarg(2, B, removed),
20971 term_variables(term(C1, D1), I1),
20972 arg(5, B, E1),
20973 ( var(E1)
20974 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
20975 F1),
20976 F1=[_|G1],
20977 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
20978 G1),
20979 ( G1=[H1|_]
20980 -> setarg(5, H1, _)
20981 ; true
20982 )
20983 ; E1=[_, _|G1],
20984 setarg(2, E1, G1),
20985 ( G1=[H1|_]
20986 -> setarg(5, H1, E1)
20987 ; true
20988 )
20989 ),
20990 detach_type_alias___2(I1, B),
20991 ( var(N)
20992 -> true
20993 ; N=suspension(_, J1, _, _, _, K1, L1),
20994 setarg(2, N, removed),
20995 ( J1==not_stored_yet
20996 -> M1=[]
20997 ; term_variables(term(K1, L1), M1),
20998 ( arg(5, N, N1),
20999 ( var(N1)
21000 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21001 O1),
21002 O1=[_|P1],
21003 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21004 P1),
21005 ( P1=[Q1|_]
21006 -> setarg(5, Q1, _)
21007 ; true
21008 )
21009 ; N1=[_, _|P1],
21010 setarg(2, N1, P1),
21011 ( P1=[Q1|_]
21012 -> setarg(5, Q1, N1)
21013 ; true
21014 )
21015 )
21016 ),
21017 detach_type_alias___2(M1, N)
21018 )
21019 ),
21020 copy_term_nat(D, R1),
21021 copy_term_nat(C, S1),
21022 R1=S1,
21023 chr_error(type_error,
21024 'Ambiguous type aliases: you have defined \n\t`~w\'\n\t`~w\'\n\tresulting in two definitions for "~w".\n',
21025 [D==Z, C==Y, R1])
21026 )
21027 ; functor(D, T1, U1),
21028 functor(Y, T1, U1),
21029 copy_term_nat((C, Y, D, Z),
21030 (F2, W1, V1, G2)),
21031 subsumes_term(V1, W1), !,
21032 ( var(N)
21033 -> true
21034 ; N=suspension(_, X1, _, _, _, Y1, Z1),
21035 setarg(2, N, removed),
21036 ( X1==not_stored_yet
21037 -> A2=[]
21038 ; term_variables(term(Y1, Z1), A2),
21039 ( arg(5, N, B2),
21040 ( var(B2)
21041 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21042 C2),
21043 C2=[_|D2],
21044 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21045 D2),
21046 ( D2=[E2|_]
21047 -> setarg(5, E2, _)
21048 ; true
21049 )
21050 ; B2=[_, _|D2],
21051 setarg(2, B2, D2),
21052 ( D2=[E2|_]
21053 -> setarg(5, E2, B2)
21054 ; true
21055 )
21056 )
21057 ),
21058 detach_type_alias___2(A2, N)
21059 )
21060 ),
21061 type_alias(F2, G2)
21062 )
21063 ; !,
21064 ( var(N)
21065 -> N=suspension(H2, not_stored_yet, t, 0, _, C, Y),
21066 'chr gen_id'(H2)
21067 ; true
21068 ),
21069 type_alias___2__0__0__7(A, C, Y, N)
21070 ).
21071type_alias___2__0__0__7([], A, B, C) :-
21072 type_alias___2__1(A, B, C).
21073type_alias___2__0__0__7([A|C1], B, G, Q) :-
21074 ( A=suspension(_, active, _, _, _, F, C),
21075 functor(B, D, E),
21076 functor(C, D, E),
21077 copy_term_nat((F, C, B, G),
21078 (A1, I, H, B1)),
21079 subsumes_term(H, I)
21080 -> ( A=suspension(_, _, _, _, _, J, K),
21081 setarg(2, A, removed),
21082 term_variables(term(J, K), P),
21083 ( arg(5, A, L),
21084 ( var(L)
21085 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21086 M),
21087 M=[_|N],
21088 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21089 N),
21090 ( N=[O|_]
21091 -> setarg(5, O, _)
21092 ; true
21093 )
21094 ; L=[_, _|N],
21095 setarg(2, L, N),
21096 ( N=[O|_]
21097 -> setarg(5, O, L)
21098 ; true
21099 )
21100 )
21101 ),
21102 detach_type_alias___2(P, A)
21103 ),
21104 ( arg(2, Q, T),
21105 setarg(2, Q, active),
21106 ( arg(4, Q, R),
21107 S is R+1,
21108 setarg(4, Q, S)
21109 ),
21110 ( T==not_stored_yet
21111 -> Q=suspension(_, _, _, _, _, U, V),
21112 term_variables(term(U, V), Z),
21113 ( nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21114 W),
21115 X=[Q|W],
21116 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21117 X),
21118 ( W=[Y|_]
21119 -> setarg(5, Y, X)
21120 ; true
21121 )
21122 ),
21123 attach_type_alias___2(Z, Q)
21124 ; true
21125 )
21126 ),
21127 type_alias(A1, B1),
21128 ( Q=suspension(_, active, _, S, _, _, _)
21129 -> setarg(2, Q, inactive),
21130 type_alias___2__0__0__7(C1, B, G, Q)
21131 ; true
21132 )
21133 ; type_alias___2__0__0__7(C1, B, G, Q)
21134 ).
21135type_alias___2__0(B, C, A) :-
21136 ( var(A)
21137 -> A=suspension(D, not_stored_yet, t, 0, _, B, C),
21138 'chr gen_id'(D)
21139 ; true
21140 ),
21141 type_alias___2__1(B, C, A).
21142type_alias___2__1(D, _, N) :-
21143 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
21144 A),
21145 member(B, A),
21146 B=suspension(_, active, _, _, _, C, _),
21147 functor(C, E, F),
21148 functor(D, E, F), !,
21149 B=suspension(_, _, _, _, _, G, H),
21150 setarg(2, B, removed),
21151 term_variables(term(G, H), M),
21152 arg(5, B, I),
21153 ( var(I)
21154 -> nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
21155 J),
21156 J=[_|K],
21157 b_setval('$chr_store_global_list_chr_translate____type_definition___2',
21158 K),
21159 ( K=[L|_]
21160 -> setarg(5, L, _)
21161 ; true
21162 )
21163 ; I=[_, _|K],
21164 setarg(2, I, K),
21165 ( K=[L|_]
21166 -> setarg(5, L, I)
21167 ; true
21168 )
21169 ),
21170 detach_type_definition___2(M, B),
21171 ( var(N)
21172 -> true
21173 ; N=suspension(_, O, _, _, _, P, Q),
21174 setarg(2, N, removed),
21175 ( O==not_stored_yet
21176 -> R=[]
21177 ; term_variables(term(P, Q), R),
21178 ( arg(5, N, S),
21179 ( var(S)
21180 -> nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21181 T),
21182 T=[_|U],
21183 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21184 U),
21185 ( U=[V|_]
21186 -> setarg(5, V, _)
21187 ; true
21188 )
21189 ; S=[_, _|U],
21190 setarg(2, S, U),
21191 ( U=[V|_]
21192 -> setarg(5, V, S)
21193 ; true
21194 )
21195 )
21196 ),
21197 detach_type_alias___2(R, N)
21198 )
21199 ),
21200 chr_error(type_error,
21201 'Multiple definitions for type, once in a type definition and once as a type alias: ~w/~w.\n',
21202 [E, F]).
21203type_alias___2__1(B, C, D) :-
21204 nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21205 A), !,
21206 type_alias___2__1__0__10(A, B, C, D).
21207type_alias___2__1__0__10([], A, B, C) :-
21208 type_alias___2__2(A, B, C).
21209type_alias___2__1__0__10([A|Z], B, F, N) :-
21210 ( A=suspension(_, active, _, C, Y),
21211 functor(B, D, E),
21212 functor(C, D, E),
21213 copy_term_nat((B, F), (G, X)),
21214 C=G
21215 -> ( A=suspension(_, _, _, H, _),
21216 setarg(2, A, removed),
21217 term_variables(H, M),
21218 ( arg(3, A, I),
21219 ( var(I)
21220 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21221 J),
21222 J=[_|K],
21223 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21224 K),
21225 ( K=[L|_]
21226 -> setarg(3, L, _)
21227 ; true
21228 )
21229 ; I=[_, _|K],
21230 setarg(2, I, K),
21231 ( K=[L|_]
21232 -> setarg(3, L, I)
21233 ; true
21234 )
21235 )
21236 ),
21237 detach_unalias_type___2(M, A)
21238 ),
21239 ( arg(2, N, Q),
21240 setarg(2, N, active),
21241 ( arg(4, N, O),
21242 P is O+1,
21243 setarg(4, N, P)
21244 ),
21245 ( Q==not_stored_yet
21246 -> N=suspension(_, _, _, _, _, R, S),
21247 term_variables(term(R, S), W),
21248 ( nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21249 T),
21250 U=[N|T],
21251 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21252 U),
21253 ( T=[V|_]
21254 -> setarg(5, V, U)
21255 ; true
21256 )
21257 ),
21258 attach_type_alias___2(W, N)
21259 ; true
21260 )
21261 ),
21262 unalias_type(X, Y),
21263 ( N=suspension(_, active, _, P, _, _, _)
21264 -> setarg(2, N, inactive),
21265 type_alias___2__1__0__10(Z, B, F, N)
21266 ; true
21267 )
21268 ; type_alias___2__1__0__10(Z, B, F, N)
21269 ).
21270type_alias___2__1(A, B, C) :-
21271 type_alias___2__2(A, B, C).
21272type_alias___2__2(B, C, D) :-
21273 nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21274 A), !,
21275 type_alias___2__2__0__12(A, B, C, D).
21276type_alias___2__2__0__12([], A, B, C) :-
21277 type_alias___2__3(A, B, C).
21278type_alias___2__2__0__12([A|A1], B, V, L) :-
21279 ( A=suspension(_, active, _, W, X, C, Z),
21280 functor(B, D, E),
21281 functor(C, D, E)
21282 -> ( A=suspension(_, _, _, _, _, F, _),
21283 setarg(2, A, removed),
21284 term_variables(F, K),
21285 ( arg(3, A, G),
21286 ( var(G)
21287 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21288 H),
21289 H=[_|I],
21290 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21291 I),
21292 ( I=[J|_]
21293 -> setarg(3, J, _)
21294 ; true
21295 )
21296 ; G=[_, _|I],
21297 setarg(2, G, I),
21298 ( I=[J|_]
21299 -> setarg(3, J, G)
21300 ; true
21301 )
21302 )
21303 ),
21304 detach_ast_static_type_check_var___4(K, A)
21305 ),
21306 ( arg(2, L, O),
21307 setarg(2, L, active),
21308 ( arg(4, L, M),
21309 N is M+1,
21310 setarg(4, L, N)
21311 ),
21312 ( O==not_stored_yet
21313 -> L=suspension(_, _, _, _, _, P, Q),
21314 term_variables(term(P, Q), U),
21315 ( nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21316 R),
21317 S=[L|R],
21318 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21319 S),
21320 ( R=[T|_]
21321 -> setarg(5, T, S)
21322 ; true
21323 )
21324 ),
21325 attach_type_alias___2(U, L)
21326 ; true
21327 )
21328 ),
21329 ( copy_term_nat(B-V, C-Y),
21330 ast_static_type_check_var(W, X, Y, Z)
21331 ),
21332 ( L=suspension(_, active, _, N, _, _, _)
21333 -> setarg(2, L, inactive),
21334 type_alias___2__2__0__12(A1, B, V, L)
21335 ; true
21336 )
21337 ; type_alias___2__2__0__12(A1, B, V, L)
21338 ).
21339type_alias___2__2(A, B, C) :-
21340 type_alias___2__3(A, B, C).
21341type_alias___2__3(B, C, D) :-
21342 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
21343 A), !,
21344 type_alias___2__3__0__13(A, B, C, D).
21345type_alias___2__3__0__13([], A, B, C) :-
21346 type_alias___2__4(A, B, C).
21347type_alias___2__3__0__13([A|R], M, N, B) :-
21348 ( A=suspension(_, active, _, _),
21349 C=t(236, B, A),
21350 '$novel_production'(B, C),
21351 '$novel_production'(A, C)
21352 -> '$extend_history'(B, C),
21353 ( arg(2, B, F),
21354 setarg(2, B, active),
21355 ( arg(4, B, D),
21356 E is D+1,
21357 setarg(4, B, E)
21358 ),
21359 ( F==not_stored_yet
21360 -> B=suspension(_, _, _, _, _, G, H),
21361 term_variables(term(G, H), L),
21362 ( nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21363 I),
21364 J=[B|I],
21365 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21366 J),
21367 ( I=[K|_]
21368 -> setarg(5, K, J)
21369 ; true
21370 )
21371 ),
21372 attach_type_alias___2(L, B)
21373 ; true
21374 )
21375 ),
21376 ( copy_term_nat(M-N, O-P),
21377 dynamic_type_check_alias_clause(O, P, Q),
21378 dynamic_type_check_clauses([Q])
21379 ),
21380 ( B=suspension(_, active, _, E, _, _, _)
21381 -> setarg(2, B, inactive),
21382 type_alias___2__3__0__13(R, M, N, B)
21383 ; true
21384 )
21385 ; type_alias___2__3__0__13(R, M, N, B)
21386 ).
21387type_alias___2__3(A, B, C) :-
21388 type_alias___2__4(A, B, C).
21389type_alias___2__4(B, C, D) :-
21390 nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
21391 A), !,
21392 type_alias___2__4__0__14(A, B, C, D).
21393type_alias___2__4__0__14([], A, B, C) :-
21394 type_alias___2__5(A, B, C).
21395type_alias___2__4__0__14([A|X], C, V, L) :-
21396 ( A=suspension(_, active, _, B),
21397 functor(B, D, E),
21398 functor(C, D, E)
21399 -> ( A=suspension(_, _, _, F),
21400 setarg(2, A, removed),
21401 term_variables(F, K),
21402 ( arg(3, A, G),
21403 ( var(G)
21404 -> nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
21405 H),
21406 H=[_|I],
21407 b_setval('$chr_store_global_list_chr_translate____atomic_type___1',
21408 I),
21409 ( I=[J|_]
21410 -> setarg(3, J, _)
21411 ; true
21412 )
21413 ; G=[_, _|I],
21414 setarg(2, G, I),
21415 ( I=[J|_]
21416 -> setarg(3, J, G)
21417 ; true
21418 )
21419 )
21420 ),
21421 detach_atomic_type___1(K, A)
21422 ),
21423 ( arg(2, L, O),
21424 setarg(2, L, active),
21425 ( arg(4, L, M),
21426 N is M+1,
21427 setarg(4, L, N)
21428 ),
21429 ( O==not_stored_yet
21430 -> L=suspension(_, _, _, _, _, P, Q),
21431 term_variables(term(P, Q), U),
21432 ( nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21433 R),
21434 S=[L|R],
21435 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21436 S),
21437 ( R=[T|_]
21438 -> setarg(5, T, S)
21439 ; true
21440 )
21441 ),
21442 attach_type_alias___2(U, L)
21443 ; true
21444 )
21445 ),
21446 ( atomic(V),
21447 copy_term_nat(C-V, B-W),
21448 atomic_type(W)
21449 ),
21450 ( L=suspension(_, active, _, N, _, _, _)
21451 -> setarg(2, L, inactive),
21452 type_alias___2__4__0__14(X, C, V, L)
21453 ; true
21454 )
21455 ; type_alias___2__4__0__14(X, C, V, L)
21456 ).
21457type_alias___2__4(A, B, C) :-
21458 type_alias___2__5(A, B, C).
21459type_alias___2__5(_, _, A) :-
21460 arg(2, A, D),
21461 setarg(2, A, active),
21462 arg(4, A, B),
21463 C is B+1,
21464 setarg(4, A, C),
21465 ( D==not_stored_yet
21466 -> A=suspension(_, _, _, _, _, E, F),
21467 term_variables(term(E, F), J),
21468 ( nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21469 G),
21470 H=[A|G],
21471 b_setval('$chr_store_global_list_chr_translate____type_alias___2',
21472 H),
21473 ( G=[I|_]
21474 -> setarg(5, I, H)
21475 ; true
21476 )
21477 ),
21478 attach_type_alias___2(J, A)
21479 ; true
21480 ).
21481constraint_type(A, B) :-
21482 constraint_type___2__0(A, B, _).
21483constraint_type___2__0(B, C, A) :-
21484 nb_getval('$chr_store_global_ground_chr_translate____static_type_check___2',
21485 E), !,
21486 A=suspension(D, not_stored_yet, _, B, C),
21487 'chr gen_id'(D),
21488 constraint_type___2__0__0__2(E, B, C, A).
21489constraint_type___2__0__0__2([], A, B, C) :-
21490 constraint_type___2__1(A, B, C).
21491constraint_type___2__0__0__2([A|L], H, I, B) :-
21492 ( A=suspension(_, active, _, _, _)
21493 -> ( arg(2, B, C),
21494 setarg(2, B, active),
21495 ( C==not_stored_yet
21496 -> ( nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',
21497 D),
21498 E=[B|D],
21499 b_setval('$chr_store_global_ground_chr_translate____constraint_type___2',
21500 E),
21501 ( D=[F|_]
21502 -> setarg(3, F, E)
21503 ; true
21504 )
21505 ),
21506 nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',
21507 G),
21508 insert_ht(G, H, B)
21509 ; true
21510 )
21511 ),
21512 forall(( member(J, I),
21513 sub_term(J, K)
21514 ),
21515 ( get_type_definition(K, _)
21516 -> true
21517 ; chr_error(type_error,
21518 'Undefined type "~w" used in type declaration of "~w".\n',
21519 [K, H])
21520 )),
21521 ( B=suspension(_, active, _, _, _)
21522 -> setarg(2, B, inactive),
21523 constraint_type___2__0__0__2(L, H, I, B)
21524 ; true
21525 )
21526 ; constraint_type___2__0__0__2(L, H, I, B)
21527 ).
21528constraint_type___2__0(B, C, A) :-
21529 A=suspension(D, not_stored_yet, _, B, C),
21530 'chr gen_id'(D),
21531 constraint_type___2__1(B, C, A).
21532constraint_type___2__1(G, _, A) :-
21533 arg(2, A, B),
21534 setarg(2, A, active),
21535 ( B==not_stored_yet
21536 -> ( nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',
21537 C),
21538 D=[A|C],
21539 b_setval('$chr_store_global_ground_chr_translate____constraint_type___2',
21540 D),
21541 ( C=[E|_]
21542 -> setarg(3, E, D)
21543 ; true
21544 )
21545 ),
21546 nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',
21547 F),
21548 insert_ht(F, G, A)
21549 ; true
21550 ).
21551get_type_definition(A, _) :-
21552 \+ ground(A), !,
21553 chr_error(type_error,
21554 'Non-ground type in constraint definition: "~w".\n',
21555 [A]).
21556get_type_definition(D, J) :-
21557 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21558 A),
21559 member(B, A),
21560 B=suspension(_, active, _, _, _, C, G),
21561 functor(C, E, F),
21562 functor(D, E, F),
21563 copy_term_nat((C, G), (H, I)),
21564 H=D, !,
21565 ( get_type_definition(I, J)
21566 -> true
21567 ; chr_error(type_error,
21568 'Could not find type definition for "~w" (accessed via alias "~w").\n',
21569 [I, H]),
21570 fail
21571 ).
21572get_type_definition(D, I) :-
21573 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
21574 A),
21575 member(B, A),
21576 B=suspension(_, active, _, _, _, C, G),
21577 nonvar(C),
21578 functor(C, E, F),
21579 functor(D, E, F),
21580 copy_term_nat((C, G), (H, J)),
21581 H=D, !,
21582 I=J.
21583get_type_definition(A, B) :-
21584 atomic_builtin_type(A, _, _), !,
21585 B=[A].
21586get_type_definition(A, B) :-
21587 compound_builtin_type(A, _, _, _), !,
21588 B=[A].
21589get_type_definition(_, _) :-
21590 fail.
21591get_constraint_type(B, E) :-
21592 nb_getval('$chr_store_multi_hash_chr_translate____constraint_type___2-1',
21593 A),
21594 lookup_ht(A, B, C),
21595 member(D, C),
21596 D=suspension(_, active, _, _, F), !,
21597 E=F.
21598get_constraint_type(_, _) :-
21599 fail.
21600unalias_type(A, B) :-
21601 unalias_type___2__0(A, B, _).
21602unalias_type___2__0(A, I, B) :-
21603 var(A), !,
21604 ( var(B)
21605 -> true
21606 ; B=suspension(_, _, _, C, _),
21607 setarg(2, B, removed),
21608 term_variables(C, H),
21609 ( arg(3, B, D),
21610 ( var(D)
21611 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21612 E),
21613 E=[_|F],
21614 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21615 F),
21616 ( F=[G|_]
21617 -> setarg(3, G, _)
21618 ; true
21619 )
21620 ; D=[_, _|F],
21621 setarg(2, D, F),
21622 ( F=[G|_]
21623 -> setarg(3, G, D)
21624 ; true
21625 )
21626 )
21627 ),
21628 detach_unalias_type___2(H, B)
21629 ),
21630 I=A.
21631unalias_type___2__0(D, Q, I) :-
21632 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21633 A),
21634 member(B, A),
21635 B=suspension(_, active, _, _, _, C, G),
21636 functor(C, E, F),
21637 functor(D, E, F),
21638 copy_term_nat((C, G), (H, P)),
21639 D=H, !,
21640 ( var(I)
21641 -> true
21642 ; I=suspension(_, _, _, J, _),
21643 setarg(2, I, removed),
21644 term_variables(J, O),
21645 ( arg(3, I, K),
21646 ( var(K)
21647 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21648 L),
21649 L=[_|M],
21650 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21651 M),
21652 ( M=[N|_]
21653 -> setarg(3, N, _)
21654 ; true
21655 )
21656 ; K=[_, _|M],
21657 setarg(2, K, M),
21658 ( M=[N|_]
21659 -> setarg(3, N, K)
21660 ; true
21661 )
21662 )
21663 ),
21664 detach_unalias_type___2(O, I)
21665 ),
21666 unalias_type(P, Q).
21667unalias_type___2__0(D, N, G) :-
21668 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
21669 A),
21670 member(B, A),
21671 B=suspension(_, active, _, _, _, C, _),
21672 nonvar(C),
21673 functor(C, E, F),
21674 functor(D, E, F), !,
21675 ( var(G)
21676 -> true
21677 ; G=suspension(_, _, _, H, _),
21678 setarg(2, G, removed),
21679 term_variables(H, M),
21680 ( arg(3, G, I),
21681 ( var(I)
21682 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21683 J),
21684 J=[_|K],
21685 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21686 K),
21687 ( K=[L|_]
21688 -> setarg(3, L, _)
21689 ; true
21690 )
21691 ; I=[_, _|K],
21692 setarg(2, I, K),
21693 ( K=[L|_]
21694 -> setarg(3, L, I)
21695 ; true
21696 )
21697 )
21698 ),
21699 detach_unalias_type___2(M, G)
21700 ),
21701 N=D.
21702unalias_type___2__0(A, I, B) :-
21703 atomic_builtin_type(A, _, _), !,
21704 ( var(B)
21705 -> true
21706 ; B=suspension(_, _, _, C, _),
21707 setarg(2, B, removed),
21708 term_variables(C, H),
21709 ( arg(3, B, D),
21710 ( var(D)
21711 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21712 E),
21713 E=[_|F],
21714 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21715 F),
21716 ( F=[G|_]
21717 -> setarg(3, G, _)
21718 ; true
21719 )
21720 ; D=[_, _|F],
21721 setarg(2, D, F),
21722 ( F=[G|_]
21723 -> setarg(3, G, D)
21724 ; true
21725 )
21726 )
21727 ),
21728 detach_unalias_type___2(H, B)
21729 ),
21730 I=A.
21731unalias_type___2__0(A, I, B) :-
21732 compound_builtin_type(A, _, _, _), !,
21733 ( var(B)
21734 -> true
21735 ; B=suspension(_, _, _, C, _),
21736 setarg(2, B, removed),
21737 term_variables(C, H),
21738 ( arg(3, B, D),
21739 ( var(D)
21740 -> nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21741 E),
21742 E=[_|F],
21743 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21744 F),
21745 ( F=[G|_]
21746 -> setarg(3, G, _)
21747 ; true
21748 )
21749 ; D=[_, _|F],
21750 setarg(2, D, F),
21751 ( F=[G|_]
21752 -> setarg(3, G, D)
21753 ; true
21754 )
21755 )
21756 ),
21757 detach_unalias_type___2(H, B)
21758 ),
21759 I=A.
21760unalias_type___2__0(B, C, A) :-
21761 ( var(A)
21762 -> ( A=suspension(D, active, _, B, C),
21763 term_variables(B, H),
21764 'chr gen_id'(D)
21765 ),
21766 ( nb_getval('$chr_store_global_list_chr_translate____unalias_type___2',
21767 E),
21768 F=[A|E],
21769 b_setval('$chr_store_global_list_chr_translate____unalias_type___2',
21770 F),
21771 ( E=[G|_]
21772 -> setarg(3, G, F)
21773 ; true
21774 )
21775 ),
21776 attach_unalias_type___2(H, A)
21777 ; setarg(2, A, active)
21778 ).
21779types_modes_condition([], [], A) :- !,
21780 A=true.
21781types_modes_condition([D|O], [K|P], G) :-
21782 nb_getval('$chr_store_global_ground_chr_translate____constraint_mode___2',
21783 A),
21784 member(B, A),
21785 B=suspension(_, active, _, _, C, H),
21786 C=E/F,
21787 functor(D, E, F), !,
21788 D=..[_|I],
21789 G=(J, N, Q),
21790 modes_condition(H, I, J),
21791 get_constraint_type_det(E/F, L),
21792 K=..[_|M],
21793 types_condition(L, I, M, H, N),
21794 types_modes_condition(O, P, Q).
21795types_modes_condition([A|_], _, _) :- !,
21796 functor(A, B, C),
21797 chr_error(internal,
21798 'Mode information missing for ~w.\n',
21799 [B/C]).
21800types_modes_condition(A, B, C) :-
21801 E=suspension(D, active, _, A, B, C),
21802 'chr gen_id'(D),
21803 nb_getval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
21804 F),
21805 G=[E|F],
21806 b_setval('$chr_store_global_ground_chr_translate____types_modes_condition___3',
21807 G),
21808 ( F=[H|_]
21809 -> setarg(3, H, G)
21810 ; true
21811 ).
21812static_type_check(A, B) :-
21813 static_type_check___2__0(A, B, _).
21814static_type_check___2__0(B, C, A) :-
21815 nb_getval('$chr_store_global_ground_chr_translate____constraint_type___2',
21816 E), !,
21817 A=suspension(D, not_stored_yet, _, B, C),
21818 'chr gen_id'(D),
21819 static_type_check___2__0__0__1(E, B, C, A).
21820static_type_check___2__0__0__1([], A, B, C) :-
21821 static_type_check___2__1(A, B, C).
21822static_type_check___2__0__0__1([A|K], L, M, B) :-
21823 ( A=suspension(_, active, _, J, G)
21824 -> ( arg(2, B, C),
21825 setarg(2, B, active),
21826 ( C==not_stored_yet
21827 -> nb_getval('$chr_store_global_ground_chr_translate____static_type_check___2',
21828 D),
21829 E=[B|D],
21830 b_setval('$chr_store_global_ground_chr_translate____static_type_check___2',
21831 E),
21832 ( D=[F|_]
21833 -> setarg(3, F, E)
21834 ; true
21835 )
21836 ; true
21837 )
21838 ),
21839 forall(( member(H, G),
21840 sub_term(H, I)
21841 ),
21842 ( get_type_definition(I, _)
21843 -> true
21844 ; chr_error(type_error,
21845 'Undefined type "~w" used in type declaration of "~w".\n',
21846 [I, J])
21847 )),
21848 ( B=suspension(_, active, _, _, _)
21849 -> setarg(2, B, inactive),
21850 static_type_check___2__0__0__1(K,
21851 L,
21852 M,
21853 B)
21854 ; true
21855 )
21856 ; static_type_check___2__0__0__1(K, L, M, B)
21857 ).
21858static_type_check___2__0(B, C, A) :-
21859 A=suspension(D, not_stored_yet, _, B, C),
21860 'chr gen_id'(D),
21861 static_type_check___2__1(B, C, A).
21862static_type_check___2__1(G, H, A) :-
21863 ( var(A)
21864 -> true
21865 ; arg(2, A, B),
21866 setarg(2, A, removed),
21867 ( B==not_stored_yet
21868 -> true
21869 ; arg(3, A, C),
21870 ( var(C)
21871 -> nb_getval('$chr_store_global_ground_chr_translate____static_type_check___2',
21872 D),
21873 D=[_|E],
21874 b_setval('$chr_store_global_ground_chr_translate____static_type_check___2',
21875 E),
21876 ( E=[F|_]
21877 -> setarg(3, F, _)
21878 ; true
21879 )
21880 ; C=[_, _|E],
21881 setarg(2, C, E),
21882 ( E=[F|_]
21883 -> setarg(3, F, C)
21884 ; true
21885 )
21886 )
21887 )
21888 ),
21889 maplist(static_type_check_rule, G, H).
21890ast_static_type_check_term(_, _, A) :-
21891 A==any, !.
21892ast_static_type_check_term(E, A, D) :-
21893 nonvar(A),
21894 A=var(B, C), !,
21895 ast_static_type_check_var(B,
21896 var(B, C),
21897 D,
21898 E).
21899ast_static_type_check_term(D, B, A) :-
21900 ast_atomic_builtin_type(A, B, C), !,
21901 ( call(C)
21902 -> true
21903 ; throw(type_error(invalid_functor(D, B, A)))
21904 ).
21905ast_static_type_check_term(D, B, A) :-
21906 ast_compound_builtin_type(A, B, C), !,
21907 ( call(C)
21908 -> true
21909 ; throw(type_error(invalid_functor(D, B, A)))
21910 ).
21911ast_static_type_check_term(H, I, C) :-
21912 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21913 A),
21914 member(B, A),
21915 B=suspension(_, active, _, _, _, D, G),
21916 functor(C, E, F),
21917 functor(D, E, F), !,
21918 copy_term_nat(D-G, C-J),
21919 ast_static_type_check_term(H, I, J).
21920ast_static_type_check_term(M, H, C) :-
21921 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
21922 A),
21923 member(B, A),
21924 B=suspension(_, active, _, _, _, D, G),
21925 functor(C, E, F),
21926 functor(D, E, F), !,
21927 copy_term_nat(D-G, C-I),
21928 ast_functor(H, K, L),
21929 ( member(J, I),
21930 functor(J, K, L)
21931 -> ast_args(H, N),
21932 J=..[_|O],
21933 maplist(ast_static_type_check_term(M), N, O)
21934 ; throw(type_error(invalid_functor(M, H, C)))
21935 ).
21936ast_static_type_check_term(C, B, A) :-
21937 chr_error(internal,
21938 'Undefined type ~w while type checking term ~w in ~@.\n',
21939 [A, B, chr_translate:format_src(C)]).
21940ast_static_type_check_var(A, B, C, D) :-
21941 ast_static_type_check_var___4__0(A,
21942 B,
21943 C,
21944 D,
21945 _).
21946ast_static_type_check_var___4__0(O, P, D, R, G) :-
21947 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
21948 A),
21949 member(B, A),
21950 B=suspension(_, active, _, _, _, C, N),
21951 functor(C, E, F),
21952 functor(D, E, F), !,
21953 ( var(G)
21954 -> true
21955 ; G=suspension(_, _, _, _, _, H, _),
21956 setarg(2, G, removed),
21957 term_variables(H, M),
21958 ( arg(3, G, I),
21959 ( var(I)
21960 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21961 J),
21962 J=[_|K],
21963 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21964 K),
21965 ( K=[L|_]
21966 -> setarg(3, L, _)
21967 ; true
21968 )
21969 ; I=[_, _|K],
21970 setarg(2, I, K),
21971 ( K=[L|_]
21972 -> setarg(3, L, I)
21973 ; true
21974 )
21975 )
21976 ),
21977 detach_ast_static_type_check_var___4(M, G)
21978 ),
21979 copy_term_nat(C-N, D-Q),
21980 ast_static_type_check_var(O, P, Q, R).
21981ast_static_type_check_var___4__0(I, J, A, K, B) :-
21982 atomic_builtin_type(A, _, _), !,
21983 ( var(B)
21984 -> true
21985 ; B=suspension(_, _, _, _, _, C, _),
21986 setarg(2, B, removed),
21987 term_variables(C, H),
21988 ( arg(3, B, D),
21989 ( var(D)
21990 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21991 E),
21992 E=[_|F],
21993 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
21994 F),
21995 ( F=[G|_]
21996 -> setarg(3, G, _)
21997 ; true
21998 )
21999 ; D=[_, _|F],
22000 setarg(2, D, F),
22001 ( F=[G|_]
22002 -> setarg(3, G, D)
22003 ; true
22004 )
22005 )
22006 ),
22007 detach_ast_static_type_check_var___4(H, B)
22008 ),
22009 ast_static_atomic_builtin_type_check_var(I,
22010 J,
22011 A,
22012 K).
22013ast_static_type_check_var___4__0(_, _, A, _, B) :-
22014 compound_builtin_type(A, _, _, _), !,
22015 ( var(B)
22016 -> true
22017 ; B=suspension(_, _, _, _, _, C, _),
22018 setarg(2, B, removed),
22019 term_variables(C, H),
22020 ( arg(3, B, D),
22021 ( var(D)
22022 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22023 E),
22024 E=[_|F],
22025 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22026 F),
22027 ( F=[G|_]
22028 -> setarg(3, G, _)
22029 ; true
22030 )
22031 ; D=[_, _|F],
22032 setarg(2, D, F),
22033 ( F=[G|_]
22034 -> setarg(3, G, D)
22035 ; true
22036 )
22037 )
22038 ),
22039 detach_ast_static_type_check_var___4(H, B)
22040 ).
22041ast_static_type_check_var___4__0(D, T, E, U, M) :-
22042 ( nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22043 A),
22044 member(B, A),
22045 B=suspension(_, active, _, C, I1, F, V),
22046 C=D
22047 ),
22048 ( E\==F, !,
22049 B=suspension(_, _, _, _, _, G, _),
22050 setarg(2, B, removed),
22051 term_variables(G, L),
22052 arg(3, B, H),
22053 ( var(H)
22054 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22055 I),
22056 I=[_|J],
22057 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22058 J),
22059 ( J=[K|_]
22060 -> setarg(3, K, _)
22061 ; true
22062 )
22063 ; H=[_, _|J],
22064 setarg(2, H, J),
22065 ( J=[K|_]
22066 -> setarg(3, K, H)
22067 ; true
22068 )
22069 ),
22070 detach_ast_static_type_check_var___4(L, B),
22071 ( var(M)
22072 -> true
22073 ; M=suspension(_, _, _, _, _, N, _),
22074 setarg(2, M, removed),
22075 term_variables(N, S),
22076 ( arg(3, M, O),
22077 ( var(O)
22078 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22079 P),
22080 P=[_|Q],
22081 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22082 Q),
22083 ( Q=[R|_]
22084 -> setarg(3, R, _)
22085 ; true
22086 )
22087 ; O=[_, _|Q],
22088 setarg(2, O, Q),
22089 ( Q=[R|_]
22090 -> setarg(3, R, O)
22091 ; true
22092 )
22093 )
22094 ),
22095 detach_ast_static_type_check_var___4(S, M)
22096 ),
22097 throw(type_error(type_clash(T,
22098 U,
22099 V,
22100 E,
22101 F)))
22102 ; F\==E, !,
22103 B=suspension(_, _, _, _, _, W, _),
22104 setarg(2, B, removed),
22105 term_variables(W, B1),
22106 arg(3, B, X),
22107 ( var(X)
22108 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22109 Y),
22110 Y=[_|Z],
22111 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22112 Z),
22113 ( Z=[A1|_]
22114 -> setarg(3, A1, _)
22115 ; true
22116 )
22117 ; X=[_, _|Z],
22118 setarg(2, X, Z),
22119 ( Z=[A1|_]
22120 -> setarg(3, A1, X)
22121 ; true
22122 )
22123 ),
22124 detach_ast_static_type_check_var___4(B1, B),
22125 ( var(M)
22126 -> true
22127 ; M=suspension(_, _, _, _, _, C1, _),
22128 setarg(2, M, removed),
22129 term_variables(C1, H1),
22130 ( arg(3, M, D1),
22131 ( var(D1)
22132 -> nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22133 E1),
22134 E1=[_|F1],
22135 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22136 F1),
22137 ( F1=[G1|_]
22138 -> setarg(3, G1, _)
22139 ; true
22140 )
22141 ; D1=[_, _|F1],
22142 setarg(2, D1, F1),
22143 ( F1=[G1|_]
22144 -> setarg(3, G1, D1)
22145 ; true
22146 )
22147 )
22148 ),
22149 detach_ast_static_type_check_var___4(H1, M)
22150 ),
22151 throw(type_error(type_clash(I1,
22152 V,
22153 U,
22154 F,
22155 E)))
22156 ).
22157ast_static_type_check_var___4__0(B, C, D, E, A) :-
22158 ( var(A)
22159 -> ( A=suspension(F, active, _, B, C, D, E),
22160 term_variables(D, J),
22161 'chr gen_id'(F)
22162 ),
22163 ( nb_getval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22164 G),
22165 H=[A|G],
22166 b_setval('$chr_store_global_list_chr_translate____ast_static_type_check_var___4',
22167 H),
22168 ( G=[I|_]
22169 -> setarg(3, I, H)
22170 ; true
22171 )
22172 ),
22173 attach_ast_static_type_check_var___4(J, A)
22174 ; setarg(2, A, active)
22175 ).
22176ast_static_atomic_builtin_type_check_var(_, _, any, _) :- !.
22177ast_static_atomic_builtin_type_check_var(B, F, C, G) :-
22178 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22179 A),
22180 lookup_ht(A, k(B, C), D)
22181 ),
22182 ( member(E, D),
22183 E=suspension(_, active, _, _, _, _), !
22184 ; !,
22185 ast_static_atomic_builtin_type_check_var___4__0__0__3(D,
22186 B,
22187 F,
22188 C,
22189 G)
22190 ).
22191ast_static_atomic_builtin_type_check_var___4__0__0__3([], A, B, C, D) :-
22192 ast_static_atomic_builtin_type_check_var___4__1(A,
22193 B,
22194 C,
22195 D).
22196ast_static_atomic_builtin_type_check_var___4__0__0__3([A|H], C, I, E, J) :-
22197 ( A=suspension(_, active, B, _, D, _),
22198 B==C,
22199 D==E
22200 -> ( setarg(2, A, removed),
22201 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22202 F),
22203 delete_ht(F, C, A)
22204 ),
22205 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22206 G),
22207 delete_ht(G, k(C, E), A)
22208 ),
22209 ast_static_atomic_builtin_type_check_var___4__0__0__3(H,
22210 C,
22211 I,
22212 E,
22213 J)
22214 ; ast_static_atomic_builtin_type_check_var___4__0__0__3(H,
22215 C,
22216 I,
22217 E,
22218 J)
22219 ).
22220ast_static_atomic_builtin_type_check_var(A, B, C, D) :-
22221 ast_static_atomic_builtin_type_check_var___4__1(A,
22222 B,
22223 C,
22224 D).
22225ast_static_atomic_builtin_type_check_var___4__1(B, _, number, _) :-
22226 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22227 A),
22228 lookup_ht(A, k(B, float), C),
22229 member(D, C),
22230 D=suspension(_, active, _, _, _, _), !.
22231ast_static_atomic_builtin_type_check_var___4__1(B, D, float, E) :-
22232 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22233 A),
22234 lookup_ht(A, k(B, number), C), !,
22235 ast_static_atomic_builtin_type_check_var___4__1__0__5(C,
22236 B,
22237 D,
22238 float,
22239 E).
22240ast_static_atomic_builtin_type_check_var___4__1__0__5([], A, B, C, D) :-
22241 ast_static_atomic_builtin_type_check_var___4__8(A,
22242 B,
22243 C,
22244 D).
22245ast_static_atomic_builtin_type_check_var___4__1__0__5([A|G], C, H, I, J) :-
22246 ( A=suspension(_, active, B, _, D, _),
22247 B==C,
22248 D=number
22249 -> ( setarg(2, A, removed),
22250 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22251 E),
22252 delete_ht(E, C, A)
22253 ),
22254 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22255 F),
22256 delete_ht(F, k(C, number), A)
22257 ),
22258 ast_static_atomic_builtin_type_check_var___4__1__0__5(G,
22259 C,
22260 H,
22261 I,
22262 J)
22263 ; ast_static_atomic_builtin_type_check_var___4__1__0__5(G,
22264 C,
22265 H,
22266 I,
22267 J)
22268 ).
22269ast_static_atomic_builtin_type_check_var___4__1(A, B, C, D) :-
22270 ast_static_atomic_builtin_type_check_var___4__2(A,
22271 B,
22272 C,
22273 D).
22274ast_static_atomic_builtin_type_check_var___4__2(B, _, number, _) :-
22275 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22276 A),
22277 lookup_ht(A, k(B, int), C),
22278 member(D, C),
22279 D=suspension(_, active, _, _, _, _), !.
22280ast_static_atomic_builtin_type_check_var___4__2(B, D, int, E) :-
22281 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22282 A),
22283 lookup_ht(A, k(B, number), C), !,
22284 ast_static_atomic_builtin_type_check_var___4__2__0__7(C,
22285 B,
22286 D,
22287 int,
22288 E).
22289ast_static_atomic_builtin_type_check_var___4__2__0__7([], A, B, C, D) :-
22290 ast_static_atomic_builtin_type_check_var___4__5(A,
22291 B,
22292 C,
22293 D).
22294ast_static_atomic_builtin_type_check_var___4__2__0__7([A|G], C, H, I, J) :-
22295 ( A=suspension(_, active, B, _, D, _),
22296 B==C,
22297 D=number
22298 -> ( setarg(2, A, removed),
22299 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22300 E),
22301 delete_ht(E, C, A)
22302 ),
22303 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22304 F),
22305 delete_ht(F, k(C, number), A)
22306 ),
22307 ast_static_atomic_builtin_type_check_var___4__2__0__7(G,
22308 C,
22309 H,
22310 I,
22311 J)
22312 ; ast_static_atomic_builtin_type_check_var___4__2__0__7(G,
22313 C,
22314 H,
22315 I,
22316 J)
22317 ).
22318ast_static_atomic_builtin_type_check_var___4__2(A, B, C, D) :-
22319 ast_static_atomic_builtin_type_check_var___4__3(A,
22320 B,
22321 C,
22322 D).
22323ast_static_atomic_builtin_type_check_var___4__3(B, _, number, _) :-
22324 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22325 A),
22326 lookup_ht(A, k(B, natural), C),
22327 member(D, C),
22328 D=suspension(_, active, _, _, _, _), !.
22329ast_static_atomic_builtin_type_check_var___4__3(B, D, natural, E) :-
22330 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22331 A),
22332 lookup_ht(A, k(B, number), C), !,
22333 ast_static_atomic_builtin_type_check_var___4__3__0__9(C,
22334 B,
22335 D,
22336 natural,
22337 E).
22338ast_static_atomic_builtin_type_check_var___4__3__0__9([], A, B, C, D) :-
22339 ast_static_atomic_builtin_type_check_var___4__5(A,
22340 B,
22341 C,
22342 D).
22343ast_static_atomic_builtin_type_check_var___4__3__0__9([A|G], C, H, I, J) :-
22344 ( A=suspension(_, active, B, _, D, _),
22345 B==C,
22346 D=number
22347 -> ( setarg(2, A, removed),
22348 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22349 E),
22350 delete_ht(E, C, A)
22351 ),
22352 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22353 F),
22354 delete_ht(F, k(C, number), A)
22355 ),
22356 ast_static_atomic_builtin_type_check_var___4__3__0__9(G,
22357 C,
22358 H,
22359 I,
22360 J)
22361 ; ast_static_atomic_builtin_type_check_var___4__3__0__9(G,
22362 C,
22363 H,
22364 I,
22365 J)
22366 ).
22367ast_static_atomic_builtin_type_check_var___4__3(A, B, C, D) :-
22368 ast_static_atomic_builtin_type_check_var___4__4(A,
22369 B,
22370 C,
22371 D).
22372ast_static_atomic_builtin_type_check_var___4__4(B, _, number, _) :-
22373 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22374 A),
22375 lookup_ht(A, k(B, dense_int), C),
22376 member(D, C),
22377 D=suspension(_, active, _, _, _, _), !.
22378ast_static_atomic_builtin_type_check_var___4__4(B, D, dense_int, E) :-
22379 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22380 A),
22381 lookup_ht(A, k(B, number), C), !,
22382 ast_static_atomic_builtin_type_check_var___4__4__0__11(C,
22383 B,
22384 D,
22385 dense_int,
22386 E).
22387ast_static_atomic_builtin_type_check_var___4__4__0__11([], A, B, C, D) :-
22388 ast_static_atomic_builtin_type_check_var___4__6(A,
22389 B,
22390 C,
22391 D).
22392ast_static_atomic_builtin_type_check_var___4__4__0__11([A|G], C, H, I, J) :-
22393 ( A=suspension(_, active, B, _, D, _),
22394 B==C,
22395 D=number
22396 -> ( setarg(2, A, removed),
22397 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22398 E),
22399 delete_ht(E, C, A)
22400 ),
22401 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22402 F),
22403 delete_ht(F, k(C, number), A)
22404 ),
22405 ast_static_atomic_builtin_type_check_var___4__4__0__11(G,
22406 C,
22407 H,
22408 I,
22409 J)
22410 ; ast_static_atomic_builtin_type_check_var___4__4__0__11(G,
22411 C,
22412 H,
22413 I,
22414 J)
22415 ).
22416ast_static_atomic_builtin_type_check_var___4__4(A, B, C, D) :-
22417 ast_static_atomic_builtin_type_check_var___4__5(A,
22418 B,
22419 C,
22420 D).
22421ast_static_atomic_builtin_type_check_var___4__5(B, _, int, _) :-
22422 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22423 A),
22424 lookup_ht(A, k(B, natural), C),
22425 member(D, C),
22426 D=suspension(_, active, _, _, _, _), !.
22427ast_static_atomic_builtin_type_check_var___4__5(B, D, natural, E) :-
22428 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22429 A),
22430 lookup_ht(A, k(B, int), C), !,
22431 ast_static_atomic_builtin_type_check_var___4__5__0__13(C,
22432 B,
22433 D,
22434 natural,
22435 E).
22436ast_static_atomic_builtin_type_check_var___4__5__0__13([], A, B, C, D) :-
22437 ast_static_atomic_builtin_type_check_var___4__7(A,
22438 B,
22439 C,
22440 D).
22441ast_static_atomic_builtin_type_check_var___4__5__0__13([A|G], C, H, I, J) :-
22442 ( A=suspension(_, active, B, _, D, _),
22443 B==C,
22444 D=int
22445 -> ( setarg(2, A, removed),
22446 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22447 E),
22448 delete_ht(E, C, A)
22449 ),
22450 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22451 F),
22452 delete_ht(F, k(C, int), A)
22453 ),
22454 ast_static_atomic_builtin_type_check_var___4__5__0__13(G,
22455 C,
22456 H,
22457 I,
22458 J)
22459 ; ast_static_atomic_builtin_type_check_var___4__5__0__13(G,
22460 C,
22461 H,
22462 I,
22463 J)
22464 ).
22465ast_static_atomic_builtin_type_check_var___4__5(A, B, C, D) :-
22466 ast_static_atomic_builtin_type_check_var___4__6(A,
22467 B,
22468 C,
22469 D).
22470ast_static_atomic_builtin_type_check_var___4__6(B, _, int, _) :-
22471 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22472 A),
22473 lookup_ht(A, k(B, dense_int), C),
22474 member(D, C),
22475 D=suspension(_, active, _, _, _, _), !.
22476ast_static_atomic_builtin_type_check_var___4__6(B, D, dense_int, E) :-
22477 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22478 A),
22479 lookup_ht(A, k(B, int), C), !,
22480 ast_static_atomic_builtin_type_check_var___4__6__0__15(C,
22481 B,
22482 D,
22483 dense_int,
22484 E).
22485ast_static_atomic_builtin_type_check_var___4__6__0__15([], A, B, C, D) :-
22486 ast_static_atomic_builtin_type_check_var___4__7(A,
22487 B,
22488 C,
22489 D).
22490ast_static_atomic_builtin_type_check_var___4__6__0__15([A|G], C, H, I, J) :-
22491 ( A=suspension(_, active, B, _, D, _),
22492 B==C,
22493 D=int
22494 -> ( setarg(2, A, removed),
22495 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22496 E),
22497 delete_ht(E, C, A)
22498 ),
22499 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22500 F),
22501 delete_ht(F, k(C, int), A)
22502 ),
22503 ast_static_atomic_builtin_type_check_var___4__6__0__15(G,
22504 C,
22505 H,
22506 I,
22507 J)
22508 ; ast_static_atomic_builtin_type_check_var___4__6__0__15(G,
22509 C,
22510 H,
22511 I,
22512 J)
22513 ).
22514ast_static_atomic_builtin_type_check_var___4__6(A, B, C, D) :-
22515 ast_static_atomic_builtin_type_check_var___4__7(A,
22516 B,
22517 C,
22518 D).
22519ast_static_atomic_builtin_type_check_var___4__7(B, _, natural, _) :-
22520 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22521 A),
22522 lookup_ht(A, k(B, dense_int), C),
22523 member(D, C),
22524 D=suspension(_, active, _, _, _, _), !.
22525ast_static_atomic_builtin_type_check_var___4__7(B, D, dense_int, E) :-
22526 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22527 A),
22528 lookup_ht(A, k(B, natural), C), !,
22529 ast_static_atomic_builtin_type_check_var___4__7__0__17(C,
22530 B,
22531 D,
22532 dense_int,
22533 E).
22534ast_static_atomic_builtin_type_check_var___4__7__0__17([], A, B, C, D) :-
22535 ast_static_atomic_builtin_type_check_var___4__8(A,
22536 B,
22537 C,
22538 D).
22539ast_static_atomic_builtin_type_check_var___4__7__0__17([A|G], C, H, I, J) :-
22540 ( A=suspension(_, active, B, _, D, _),
22541 B==C,
22542 D=natural
22543 -> ( setarg(2, A, removed),
22544 ( nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22545 E),
22546 delete_ht(E, C, A)
22547 ),
22548 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22549 F),
22550 delete_ht(F, k(C, natural), A)
22551 ),
22552 ast_static_atomic_builtin_type_check_var___4__7__0__17(G,
22553 C,
22554 H,
22555 I,
22556 J)
22557 ; ast_static_atomic_builtin_type_check_var___4__7__0__17(G,
22558 C,
22559 H,
22560 I,
22561 J)
22562 ).
22563ast_static_atomic_builtin_type_check_var___4__7(A, B, C, D) :-
22564 ast_static_atomic_builtin_type_check_var___4__8(A,
22565 B,
22566 C,
22567 D).
22568ast_static_atomic_builtin_type_check_var___4__8(B, H, K, I) :-
22569 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22570 A),
22571 lookup_ht(A, B, C),
22572 member(D, C),
22573 D=suspension(_, active, _, _, G, J), !,
22574 setarg(2, D, removed),
22575 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22576 E),
22577 delete_ht(E, B, D),
22578 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22579 F),
22580 delete_ht(F, k(B, G), D),
22581 throw(type_error(type_clash(H, I, J, K, G))).
22582ast_static_atomic_builtin_type_check_var___4__8(A, B, C, D) :-
22583 G=suspension(E, active, A, B, C, D),
22584 'chr gen_id'(E),
22585 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-1',
22586 F),
22587 insert_ht(F, A, G),
22588 nb_getval('$chr_store_multi_hash_chr_translate____ast_static_atomic_builtin_type_check_var___4-13',
22589 H),
22590 insert_ht(H, k(A, C), G).
22591dynamic_type_check :-
22592 dynamic_type_check___0__0(_).
22593dynamic_type_check___0__0(A) :-
22594 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
22595 C), !,
22596 A=suspension(B, not_stored_yet, t, _),
22597 'chr gen_id'(B),
22598 dynamic_type_check___0__0__0__1(C, A).
22599dynamic_type_check___0__0__0__1([], A) :-
22600 dynamic_type_check___0__1(A).
22601dynamic_type_check___0__0__0__1([A|M], B) :-
22602 ( A=suspension(_, active, _, _, _, H, I),
22603 C=t(235, A, B),
22604 '$novel_production'(A, C),
22605 '$novel_production'(B, C)
22606 -> '$extend_history'(B, C),
22607 ( arg(2, B, D),
22608 setarg(2, B, active),
22609 ( D==not_stored_yet
22610 -> nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
22611 E),
22612 F=[B|E],
22613 b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
22614 F),
22615 ( E=[G|_]
22616 -> setarg(4, G, F)
22617 ; true
22618 )
22619 ; true
22620 )
22621 ),
22622 ( copy_term_nat(H-I, J-K),
22623 maplist(dynamic_type_check_clause(J), K, L),
22624 dynamic_type_check_clauses(L)
22625 ),
22626 ( B=suspension(_, active, _, _)
22627 -> setarg(2, B, inactive),
22628 dynamic_type_check___0__0__0__1(M, B)
22629 ; true
22630 )
22631 ; dynamic_type_check___0__0__0__1(M, B)
22632 ).
22633dynamic_type_check___0__0(A) :-
22634 A=suspension(B, not_stored_yet, t, _),
22635 'chr gen_id'(B),
22636 dynamic_type_check___0__1(A).
22637dynamic_type_check___0__1(B) :-
22638 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
22639 A), !,
22640 dynamic_type_check___0__1__0__2(A, B).
22641dynamic_type_check___0__1__0__2([], A) :-
22642 dynamic_type_check___0__2(A).
22643dynamic_type_check___0__1__0__2([A|M], B) :-
22644 ( A=suspension(_, active, _, _, _, H, I),
22645 C=t(236, A, B),
22646 '$novel_production'(A, C),
22647 '$novel_production'(B, C)
22648 -> '$extend_history'(B, C),
22649 ( arg(2, B, D),
22650 setarg(2, B, active),
22651 ( D==not_stored_yet
22652 -> nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
22653 E),
22654 F=[B|E],
22655 b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
22656 F),
22657 ( E=[G|_]
22658 -> setarg(4, G, F)
22659 ; true
22660 )
22661 ; true
22662 )
22663 ),
22664 ( copy_term_nat(H-I, J-K),
22665 dynamic_type_check_alias_clause(J, K, L),
22666 dynamic_type_check_clauses([L])
22667 ),
22668 ( B=suspension(_, active, _, _)
22669 -> setarg(2, B, inactive),
22670 dynamic_type_check___0__1__0__2(M, B)
22671 ; true
22672 )
22673 ; dynamic_type_check___0__1__0__2(M, B)
22674 ).
22675dynamic_type_check___0__1(A) :-
22676 dynamic_type_check___0__2(A).
22677dynamic_type_check___0__2(A) :-
22678 ( var(A)
22679 -> true
22680 ; arg(2, A, B),
22681 setarg(2, A, removed),
22682 ( B==not_stored_yet
22683 -> true
22684 ; arg(4, A, C),
22685 ( var(C)
22686 -> nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
22687 D),
22688 D=[_|E],
22689 b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check___0',
22690 E),
22691 ( E=[F|_]
22692 -> setarg(4, F, _)
22693 ; true
22694 )
22695 ; C=[_, _|E],
22696 setarg(2, C, E),
22697 ( E=[F|_]
22698 -> setarg(4, F, C)
22699 ; true
22700 )
22701 )
22702 )
22703 ),
22704 findall(('$dynamic_type_check'(G, H):-I),
22705 ( atomic_builtin_type(G, H, I)
22706 ; compound_builtin_type(G, H, I, _)
22707 ),
22708 J),
22709 dynamic_type_check_clauses(J).
22710dynamic_type_check_clauses(G) :-
22711 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22712 A),
22713 member(B, A),
22714 B=suspension(_, active, _, H), !,
22715 setarg(2, B, removed),
22716 arg(3, B, C),
22717 ( var(C)
22718 -> nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22719 D),
22720 D=[_|E],
22721 b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22722 E),
22723 ( E=[F|_]
22724 -> setarg(3, F, _)
22725 ; true
22726 )
22727 ; C=[_, _|E],
22728 setarg(2, C, E),
22729 ( E=[F|_]
22730 -> setarg(3, F, C)
22731 ; true
22732 )
22733 ),
22734 append(G, H, I),
22735 dynamic_type_check_clauses(I).
22736dynamic_type_check_clauses(A) :-
22737 C=suspension(B, active, _, A),
22738 'chr gen_id'(B),
22739 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22740 D),
22741 E=[C|D],
22742 b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22743 E),
22744 ( D=[F|_]
22745 -> setarg(3, F, E)
22746 ; true
22747 ).
22748get_dynamic_type_check_clauses(G) :-
22749 nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22750 A),
22751 member(B, A),
22752 B=suspension(_, active, _, H), !,
22753 setarg(2, B, removed),
22754 arg(3, B, C),
22755 ( var(C)
22756 -> nb_getval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22757 D),
22758 D=[_|E],
22759 b_setval('$chr_store_global_ground_chr_translate____dynamic_type_check_clauses___1',
22760 E),
22761 ( E=[F|_]
22762 -> setarg(3, F, _)
22763 ; true
22764 )
22765 ; C=[_, _|E],
22766 setarg(2, C, E),
22767 ( E=[F|_]
22768 -> setarg(3, F, C)
22769 ; true
22770 )
22771 ),
22772 G=H.
22773get_dynamic_type_check_clauses([]).
22774atomic_type(A) :-
22775 atomic_type___1__0(A, _).
22776atomic_type___1__0(A, B) :-
22777 atomic_builtin_type(A, _, _), !,
22778 ( var(B)
22779 -> true
22780 ; B=suspension(_, _, _, C),
22781 setarg(2, B, removed),
22782 term_variables(C, H),
22783 ( arg(3, B, D),
22784 ( var(D)
22785 -> nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
22786 E),
22787 E=[_|F],
22788 b_setval('$chr_store_global_list_chr_translate____atomic_type___1',
22789 F),
22790 ( F=[G|_]
22791 -> setarg(3, G, _)
22792 ; true
22793 )
22794 ; D=[_, _|F],
22795 setarg(2, D, F),
22796 ( F=[G|_]
22797 -> setarg(3, G, D)
22798 ; true
22799 )
22800 )
22801 ),
22802 detach_atomic_type___1(H, B)
22803 ),
22804 A\==any.
22805atomic_type___1__0(C, G) :-
22806 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
22807 A),
22808 member(B, A),
22809 B=suspension(_, active, _, _, _, D, N),
22810 functor(C, E, F),
22811 functor(D, E, F), !,
22812 ( var(G)
22813 -> true
22814 ; G=suspension(_, _, _, H),
22815 setarg(2, G, removed),
22816 term_variables(H, M),
22817 ( arg(3, G, I),
22818 ( var(I)
22819 -> nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
22820 J),
22821 J=[_|K],
22822 b_setval('$chr_store_global_list_chr_translate____atomic_type___1',
22823 K),
22824 ( K=[L|_]
22825 -> setarg(3, L, _)
22826 ; true
22827 )
22828 ; I=[_, _|K],
22829 setarg(2, I, K),
22830 ( K=[L|_]
22831 -> setarg(3, L, I)
22832 ; true
22833 )
22834 )
22835 ),
22836 detach_atomic_type___1(M, G)
22837 ),
22838 maplist(atomic, N).
22839atomic_type___1__0(C, G) :-
22840 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
22841 A),
22842 member(B, A),
22843 B=suspension(_, active, _, _, _, D, N),
22844 functor(C, E, F),
22845 functor(D, E, F), !,
22846 ( var(G)
22847 -> true
22848 ; G=suspension(_, _, _, H),
22849 setarg(2, G, removed),
22850 term_variables(H, M),
22851 ( arg(3, G, I),
22852 ( var(I)
22853 -> nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
22854 J),
22855 J=[_|K],
22856 b_setval('$chr_store_global_list_chr_translate____atomic_type___1',
22857 K),
22858 ( K=[L|_]
22859 -> setarg(3, L, _)
22860 ; true
22861 )
22862 ; I=[_, _|K],
22863 setarg(2, I, K),
22864 ( K=[L|_]
22865 -> setarg(3, L, I)
22866 ; true
22867 )
22868 )
22869 ),
22870 detach_atomic_type___1(M, G)
22871 ),
22872 atomic(N),
22873 copy_term_nat(D-N, C-O),
22874 atomic_type(O).
22875atomic_type___1__0(B, A) :-
22876 ( var(A)
22877 -> ( A=suspension(C, active, _, B),
22878 term_variables(B, G),
22879 'chr gen_id'(C)
22880 ),
22881 ( nb_getval('$chr_store_global_list_chr_translate____atomic_type___1',
22882 D),
22883 E=[A|D],
22884 b_setval('$chr_store_global_list_chr_translate____atomic_type___1',
22885 E),
22886 ( D=[F|_]
22887 -> setarg(3, F, E)
22888 ; true
22889 )
22890 ),
22891 attach_atomic_type___1(G, A)
22892 ; setarg(2, A, active)
22893 ).
22894enumerated_atomic_type(A, _) :-
22895 atomic_builtin_type(A, _, _), !,
22896 fail.
22897enumerated_atomic_type(C, H) :-
22898 nb_getval('$chr_store_global_list_chr_translate____type_definition___2',
22899 A),
22900 member(B, A),
22901 B=suspension(_, active, _, _, _, D, G),
22902 functor(C, E, F),
22903 functor(D, E, F), !,
22904 maplist(atomic, G),
22905 H=G.
22906enumerated_atomic_type(C, I) :-
22907 nb_getval('$chr_store_global_list_chr_translate____type_alias___2',
22908 A),
22909 member(B, A),
22910 B=suspension(_, active, _, _, _, D, G),
22911 functor(C, E, F),
22912 functor(D, E, F), !,
22913 atomic(G),
22914 copy_term_nat(D-G, C-H),
22915 enumerated_atomic_type(H, I).
22916enumerated_atomic_type(_, _) :-
22917 fail.
22918stored(B, C, yes) :-
22919 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
22920 A),
22921 lookup_ht(A, k(B, C), D),
22922 member(E, D),
22923 E=suspension(_, active, _, _, _, _, G, H, _),
22924 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
22925 F),
22926 lookup_ht(F, k(G, H), I),
22927 member(J, I),
22928 J=suspension(_, active, _, _, _),
22929 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
22930 K),
22931 lookup_ht(K, B, L),
22932 member(M, L),
22933 M=suspension(_, active, _, _, N, P),
22934 C<N, !,
22935 setarg(2, M, removed),
22936 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
22937 O),
22938 delete_ht(O, k(B, P), M),
22939 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
22940 Q),
22941 delete_ht(Q, B, M),
22942 R is P-1,
22943 stored(B, C, maybe),
22944 stored_complete(B, N, R).
22945stored(B, E, yes) :-
22946 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
22947 A),
22948 lookup_ht(A, B, C),
22949 member(D, C),
22950 D=suspension(_, active, _, _, F, K),
22951 E<F,
22952 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
22953 G),
22954 lookup_ht(G, k(B, E), H),
22955 member(I, H),
22956 I=suspension(_, active, _, _), !,
22957 setarg(2, D, removed),
22958 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
22959 J),
22960 delete_ht(J, k(B, K), D),
22961 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
22962 L),
22963 delete_ht(L, B, D),
22964 M is K-1,
22965 stored(B, E, maybe),
22966 stored_complete(B, F, M).
22967stored(A, B, C) :-
22968 F=suspension(D, active, A, B, C),
22969 'chr gen_id'(D),
22970 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
22971 E),
22972 insert_ht(E, k(A, C), F),
22973 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
22974 G),
22975 insert_ht(G, k(A, B, C), F).
22976stored_completing(A, B, F) :-
22977 ( ground(A),
22978 ground(B),
22979 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
22980 C)
22981 ),
22982 ( ( lookup_ht(C, k(A, B, yes), D),
22983 member(E, D),
22984 E=suspension(_, active, _, _, _), !,
22985 G is B+1,
22986 H is F+1,
22987 stored_completing(A, G, H)
22988 ; lookup_ht(C, k(A, B, maybe), I),
22989 member(J, I),
22990 J=suspension(_, active, _, _, _), !,
22991 K is B+1,
22992 stored_completing(A, K, F)
22993 )
22994 ; lookup_ht(C, k(A, B, no), L),
22995 member(M, L),
22996 M=suspension(_, active, _, _, _), !,
22997 stored_complete(A, B, F)
22998 ).
22999stored_completing(A, B, C) :-
23000 stored_complete(A, B, C).
23001stored_complete(A, B, C) :-
23002 stored_complete___3__0(A, B, C, _).
23003stored_complete___3__0(B, F, Q, _) :-
23004 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
23005 A),
23006 lookup_ht(A, B, C),
23007 member(D, C),
23008 D=suspension(_, active, _, _, _, E, H, I, _),
23009 E<F,
23010 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
23011 G),
23012 lookup_ht(G, k(H, I), J),
23013 member(K, J),
23014 K=suspension(_, active, _, _, _),
23015 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
23016 L),
23017 lookup_ht(L, k(B, E, yes), M),
23018 member(N, M),
23019 N=suspension(_, active, _, _, _), !,
23020 setarg(2, N, removed),
23021 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
23022 O),
23023 delete_ht(O, k(B, yes), N),
23024 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
23025 P),
23026 delete_ht(P, k(B, E, yes), N),
23027 R is Q-1,
23028 stored(B, E, maybe),
23029 stored_complete(B, F, R).
23030stored_complete___3__0(B, F, L, _) :-
23031 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
23032 A),
23033 lookup_ht(A, k(B, yes), C),
23034 member(D, C),
23035 D=suspension(_, active, _, E, _),
23036 E<F,
23037 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
23038 G),
23039 lookup_ht(G, k(B, E), H),
23040 member(I, H),
23041 I=suspension(_, active, _, _), !,
23042 setarg(2, D, removed),
23043 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
23044 J),
23045 delete_ht(J, k(B, yes), D),
23046 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
23047 K),
23048 delete_ht(K, k(B, E, yes), D),
23049 M is L-1,
23050 stored(B, E, maybe),
23051 stored_complete(B, F, M).
23052stored_complete___3__0(B, D, 0, C) :-
23053 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
23054 A),
23055 lookup_ht(A, B, F), !,
23056 C=suspension(E, not_stored_yet, t, B, D, 0),
23057 'chr gen_id'(E),
23058 stored_complete___3__0__0__3(F, B, D, 0, C).
23059stored_complete___3__0__0__3([], A, B, C, D) :-
23060 stored_complete___3__1(A, B, C, D).
23061stored_complete___3__0__0__3([A|G], C, H, I, J) :-
23062 ( ( A=suspension(_, active, _, B, F),
23063 B==C
23064 ),
23065 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
23066 D),
23067 lookup_ht(D, C, E)
23068 -> stored_complete___3__0__1__3(E,
23069 F,
23070 A,
23071 G,
23072 C,
23073 H,
23074 I,
23075 J)
23076 ; stored_complete___3__0__0__3(G,
23077 C,
23078 H,
23079 I,
23080 J)
23081 ).
23082stored_complete___3__0__1__3([], _, _, A, B, C, D, E) :-
23083 stored_complete___3__0__0__3(A, B, C, D, E).
23084stored_complete___3__0__1__3([A|G], H, I, J, C, K, L, M) :-
23085 ( ( A=suspension(_, active, _, _, B, _, E, _, _),
23086 B==C
23087 ),
23088 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-3',
23089 D),
23090 lookup_ht(D, E, F)
23091 -> stored_complete___3__0__2__3(F,
23092 E,
23093 A,
23094 G,
23095 H,
23096 I,
23097 J,
23098 C,
23099 K,
23100 L,
23101 M)
23102 ; stored_complete___3__0__1__3(G,
23103 H,
23104 I,
23105 J,
23106 C,
23107 K,
23108 L,
23109 M)
23110 ).
23111stored_complete___3__0__2__3([], _, _, A, B, C, D, E, F, G, H) :-
23112 stored_complete___3__0__1__3(A,
23113 B,
23114 C,
23115 D,
23116 E,
23117 F,
23118 G,
23119 H).
23120stored_complete___3__0__2__3([A|P], D, B, Q, I, F, R, L, H, M, E) :-
23121 ( A=suspension(_, active, _, _, _, _, C, O, _),
23122 A\==B,
23123 C==D,
23124 ( G=t(250, A, B, E, F),
23125 '$novel_production'(A, G),
23126 '$novel_production'(B, G),
23127 '$novel_production'(E, G),
23128 '$novel_production'(F, G)
23129 ),
23130 H=<I
23131 -> '$extend_history'(E, G),
23132 ( arg(2, E, J),
23133 setarg(2, E, active),
23134 ( J==not_stored_yet
23135 -> ( nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
23136 K),
23137 insert_ht(K, k(L, M), E)
23138 ),
23139 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
23140 N),
23141 insert_ht(N, L, E)
23142 ; true
23143 )
23144 ),
23145 passive(D, O),
23146 ( E=suspension(_, active, _, _, _, _)
23147 -> setarg(2, E, inactive),
23148 stored_complete___3__0__2__3(P,
23149 D,
23150 B,
23151 Q,
23152 I,
23153 F,
23154 R,
23155 L,
23156 H,
23157 M,
23158 E)
23159 ; true
23160 )
23161 ; stored_complete___3__0__2__3(P,
23162 D,
23163 B,
23164 Q,
23165 I,
23166 F,
23167 R,
23168 L,
23169 H,
23170 M,
23171 E)
23172 ).
23173stored_complete___3__0(B, C, D, A) :-
23174 A=suspension(E, not_stored_yet, t, B, C, D),
23175 'chr gen_id'(E),
23176 stored_complete___3__1(B, C, D, A).
23177stored_complete___3__1(B, D, E, F) :-
23178 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-1',
23179 A),
23180 lookup_ht(A, B, C), !,
23181 stored_complete___3__1__0__4(C, B, D, E, F).
23182stored_complete___3__1__0__4([], A, B, C, D) :-
23183 stored_complete___3__2(A, B, C, D).
23184stored_complete___3__1__0__4([A|N], C, G, J, D) :-
23185 ( A=suspension(_, active, _, _, B, F, L, M, _),
23186 B==C,
23187 ( E=t(259, D, A),
23188 '$novel_production'(D, E),
23189 '$novel_production'(A, E)
23190 ),
23191 F>G
23192 -> '$extend_history'(D, E),
23193 ( arg(2, D, H),
23194 setarg(2, D, active),
23195 ( H==not_stored_yet
23196 -> ( nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
23197 I),
23198 insert_ht(I, k(C, J), D)
23199 ),
23200 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
23201 K),
23202 insert_ht(K, C, D)
23203 ; true
23204 )
23205 ),
23206 passive(L, M),
23207 ( D=suspension(_, active, _, _, _, _)
23208 -> setarg(2, D, inactive),
23209 stored_complete___3__1__0__4(N,
23210 C,
23211 G,
23212 J,
23213 D)
23214 ; true
23215 )
23216 ; stored_complete___3__1__0__4(N,
23217 C,
23218 G,
23219 J,
23220 D)
23221 ).
23222stored_complete___3__1(A, B, C, D) :-
23223 stored_complete___3__2(A, B, C, D).
23224stored_complete___3__2(D, _, E, A) :-
23225 arg(2, A, B),
23226 setarg(2, A, active),
23227 ( B==not_stored_yet
23228 -> ( nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
23229 C),
23230 insert_ht(C, k(D, E), A)
23231 ),
23232 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
23233 F),
23234 insert_ht(F, D, A)
23235 ; true
23236 ).
23237is_stored(A) :-
23238 ground(A),
23239 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
23240 B),
23241 lookup_ht(B, A, C),
23242 member(D, C),
23243 D=suspension(_, active, _, _, I),
23244 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
23245 E),
23246 lookup_ht(E, k(A, 0), F),
23247 member(G, F),
23248 G=suspension(_, active, _, _, H, _),
23249 H=<I, !,
23250 fail.
23251is_stored(_).
23252is_finally_stored(A) :-
23253 ground(A),
23254 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
23255 B),
23256 lookup_ht(B, A, C),
23257 member(D, C),
23258 D=suspension(_, active, _, _, I),
23259 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
23260 E),
23261 lookup_ht(E, A, F),
23262 member(G, F),
23263 G=suspension(_, active, _, _, H, _),
23264 H=<I, !,
23265 fail.
23266is_finally_stored(_).
23267check_all_passive(B, [C|F]) :-
23268 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
23269 A),
23270 lookup_ht(A, k(B, C), D),
23271 member(E, D),
23272 E=suspension(_, active, _, _, _), !,
23273 check_all_passive(B, F).
23274check_all_passive(B, []) :-
23275 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
23276 lookup_ht(A, B, C),
23277 member(D, C),
23278 D=suspension(_, active, _, _, _, E), !,
23279 chr_warning(weird_program,
23280 'All heads passive in ~@.\n\tThis rule never fires. Please check your program.\n',
23281 [format_rule(E)]).
23282check_all_passive(A, B) :-
23283 E=suspension(C, active, A, B),
23284 'chr gen_id'(C),
23285 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-12',
23286 D),
23287 insert_ht(D, k(A, B), E),
23288 nb_getval('$chr_store_multi_hash_chr_translate____check_all_passive___2-1',
23289 F),
23290 insert_ht(F, A, E).
23291constraints_code1([], A, B) :- !,
23292 A=B.
23293constraints_code1([A|C], B, E) :- !,
23294 constraint_code(A, B, D),
23295 constraints_code1(C, D, E).
23296constraints_code1(A, B, C) :-
23297 E=suspension(D, active, _, A, B, C),
23298 'chr gen_id'(D),
23299 nb_getval('$chr_store_global_ground_chr_translate____constraints_code1___3',
23300 F),
23301 G=[E|F],
23302 b_setval('$chr_store_global_ground_chr_translate____constraints_code1___3',
23303 G),
23304 ( F=[H|_]
23305 -> setarg(3, H, G)
23306 ; true
23307 ).
23308constraint_code(A, E, K) :-
23309 ( ( chr_pp_flag(debugable, on)
23310 ; is_stored(A),
23311 ( has_active_occurrence(A)
23312 ; chr_pp_flag(late_allocation, off)
23313 ),
23314 ( may_trigger(A)
23315 ; get_allocation_occurrence(A, C),
23316 get_max_occurrence(A, B),
23317 B>=C
23318 )
23319 )
23320 -> constraint_prelude(A, D),
23321 add_dummy_location(D, F),
23322 E=[F|G]
23323 ; E=G
23324 ),
23325 H=[0],
23326 occurrences_code(A, 1, H, I, G, J),
23327 gen_cond_attach_clause(A, I, J, K).
23328has_active_occurrence(B) :-
23329 nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',
23330 A),
23331 lookup_ht(A, B, C),
23332 member(D, C),
23333 D=suspension(_, active, _), !.
23334has_active_occurrence(A) :-
23335 has_active_occurrence(A, 1),
23336 memo_has_active_occurrence(A).
23337has_active_occurrence(B, E) :-
23338 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
23339 A),
23340 lookup_ht(A, B, C),
23341 member(D, C),
23342 D=suspension(_, active, _, _, F),
23343 E>F, !,
23344 fail.
23345has_active_occurrence(B, C) :-
23346 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
23347 A),
23348 lookup_ht(A, k(B, C), D),
23349 member(E, D),
23350 E=suspension(_, active, _, _, _, _, G, H, _),
23351 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
23352 F),
23353 lookup_ht(F, k(G, H), I),
23354 member(J, I),
23355 J=suspension(_, active, _, _, _), !,
23356 K is C+1,
23357 has_active_occurrence(B, K).
23358has_active_occurrence(_, _).
23359memo_has_active_occurrence(A) :-
23360 D=suspension(B, active, A),
23361 'chr gen_id'(B),
23362 nb_getval('$chr_store_multi_hash_chr_translate____memo_has_active_occurrence___1-1',
23363 C),
23364 insert_ht(C, A, D).
23365use_auxiliary_predicate(B) :-
23366 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
23367 A),
23368 lookup_ht(A, B, C),
23369 member(D, C),
23370 D=suspension(_, active, _), !.
23371use_auxiliary_predicate(A) :-
23372 D=suspension(B, active, A),
23373 'chr gen_id'(B),
23374 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
23375 C),
23376 insert_ht(C, A, D).
23377use_auxiliary_predicate(B, C) :-
23378 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',
23379 A),
23380 lookup_ht(A, k(B, C), D),
23381 member(E, D),
23382 E=suspension(_, active, _, _), !.
23383use_auxiliary_predicate(A, B) :-
23384 E=suspension(C, active, A, B),
23385 'chr gen_id'(C),
23386 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',
23387 D),
23388 insert_ht(D, A, E),
23389 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',
23390 F),
23391 insert_ht(F, k(A, B), E).
23392is_used_auxiliary_predicate(B) :-
23393 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
23394 A),
23395 lookup_ht(A, B, C),
23396 member(D, C),
23397 D=suspension(_, active, _), !.
23398is_used_auxiliary_predicate(B) :-
23399 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-1',
23400 A),
23401 lookup_ht(A, B, C),
23402 member(D, C),
23403 D=suspension(_, active, _, _), !.
23404is_used_auxiliary_predicate(_) :-
23405 fail.
23406is_used_auxiliary_predicate(B, _) :-
23407 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___1-1',
23408 A),
23409 lookup_ht(A, B, C),
23410 member(D, C),
23411 D=suspension(_, active, _), !.
23412is_used_auxiliary_predicate(B, C) :-
23413 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_predicate___2-12',
23414 A),
23415 lookup_ht(A, k(B, C), D),
23416 member(E, D),
23417 E=suspension(_, active, _, _), !.
23418is_used_auxiliary_predicate(_, _) :-
23419 fail.
23420use_auxiliary_module(B) :-
23421 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',
23422 A),
23423 lookup_ht(A, B, C),
23424 member(D, C),
23425 D=suspension(_, active, _), !.
23426use_auxiliary_module(A) :-
23427 D=suspension(B, active, A),
23428 'chr gen_id'(B),
23429 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',
23430 C),
23431 insert_ht(C, A, D).
23432is_used_auxiliary_module(B) :-
23433 nb_getval('$chr_store_multi_hash_chr_translate____use_auxiliary_module___1-1',
23434 A),
23435 lookup_ht(A, B, C),
23436 member(D, C),
23437 D=suspension(_, active, _), !.
23438is_used_auxiliary_module(_) :-
23439 fail.
23440occurrences_code(B, E, H, G, I, J) :-
23441 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
23442 A),
23443 lookup_ht(A, B, C),
23444 member(D, C),
23445 D=suspension(_, active, _, _, F),
23446 E>F, !,
23447 G=H,
23448 I=J.
23449occurrences_code(A, B, C, G, D, I) :-
23450 occurrence_code(A, B, C, F, D, H),
23451 E is B+1,
23452 occurrences_code(A, E, F, G, H, I).
23453occurrence_code(B, C, L, K, M, N) :-
23454 ( nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
23455 A),
23456 lookup_ht(A, k(B, C), D),
23457 member(E, D),
23458 E=suspension(_, active, _, _, _, _, G, H, _)
23459 ),
23460 ( nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
23461 F),
23462 lookup_ht(F, k(G, H), I),
23463 member(J, I),
23464 J=suspension(_, active, _, _, _), !,
23465 ( named_history(G, _, _)
23466 -> does_use_history(B, C)
23467 ; true
23468 ),
23469 K=L,
23470 M=N
23471 ; nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
23472 O),
23473 lookup_ht(O, G, P),
23474 member(Q, P),
23475 Q=suspension(_, active, _, _, _, R), !,
23476 R=pragma(rule(T, Y, _, _), ids(S, X), _, _, _),
23477 ( select2(H, U, S, T, W, V)
23478 -> K=L,
23479 head1_code(U,
23480 H,
23481 V,
23482 W,
23483 R,
23484 B,
23485 C,
23486 L,
23487 M,
23488 N)
23489 ; select2(H, Z, X, Y, B1, A1)
23490 -> head2_code(Z,
23491 H,
23492 A1,
23493 B1,
23494 R,
23495 B,
23496 C,
23497 L,
23498 M,
23499 C1),
23500 ( should_skip_to_next_id(B, C)
23501 -> inc_id(L, K),
23502 ( unconditional_occurrence(B, C)
23503 -> C1=N
23504 ; gen_alloc_inc_clause(B,
23505 C,
23506 L,
23507 C1,
23508 N)
23509 )
23510 ; K=L,
23511 C1=N
23512 )
23513 )
23514 ).
23515occurrence_code(A, B, _, _, _, _) :-
23516 chr_error(internal,
23517 'occurrence_code/6: missing information to compile ~w:~w\n',
23518 [A, B]).
23519functional_dependency(C, A, K, L) :-
23520 A>1,
23521 nb_getval('$chr_store_multi_hash_chr_translate____allocation_occurrence___2-1',
23522 B),
23523 lookup_ht(B, C, D),
23524 member(E, D),
23525 E=suspension(_, active, _, _, I),
23526 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-13',
23527 F),
23528 lookup_ht(F, k(C, A), G),
23529 member(H, G),
23530 H=suspension(_, active, _, _, _, J, _, _, _),
23531 I>J, !,
23532 functional_dependency(C, 1, K, L).
23533functional_dependency(A, B, C, D) :-
23534 G=suspension(E, active, A, B, C, D),
23535 'chr gen_id'(E),
23536 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
23537 F),
23538 insert_ht(F, A, G),
23539 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-12',
23540 H),
23541 insert_ht(H, k(A, B), G).
23542get_functional_dependency(B, E, G, I) :-
23543 nb_getval('$chr_store_multi_hash_chr_translate____functional_dependency___4-1',
23544 A),
23545 lookup_ht(A, B, C),
23546 member(D, C),
23547 D=suspension(_, active, _, F, H, J),
23548 E>=F, !,
23549 G=H,
23550 I=J.
23551get_functional_dependency(_, _, _, _) :-
23552 fail.
23553initial_call_pattern(A) :-
23554 initial_call_pattern___1__0(A, _).
23555initial_call_pattern___1__0(B, _) :-
23556 nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',
23557 A),
23558 lookup_ht(A, B, C),
23559 member(D, C),
23560 D=suspension(_, active, _, _), !.
23561initial_call_pattern___1__0(B, A) :-
23562 A=suspension(C, active, t, B),
23563 'chr gen_id'(C),
23564 nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',
23565 D),
23566 insert_ht(D, B, A),
23567 call_pattern(B),
23568 ( A=suspension(_, active, _, _)
23569 -> setarg(2, A, inactive),
23570 initial_call_pattern___1__1(B, A)
23571 ; true
23572 ).
23573initial_call_pattern___1__1(B, D) :-
23574 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23575 A),
23576 lookup_ht(A, B, C), !,
23577 initial_call_pattern___1__1__0__4(C, B, D).
23578initial_call_pattern___1__1__0__4([], A, B) :-
23579 initial_call_pattern___1__2(A, B).
23580initial_call_pattern___1__1__0__4([A|F], C, G) :-
23581 ( ( A=suspension(_, active, _, B, E),
23582 B==C
23583 ),
23584 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
23585 D)
23586 -> initial_call_pattern___1__1__1__4(D,
23587 E,
23588 A,
23589 F,
23590 C,
23591 G)
23592 ; initial_call_pattern___1__1__0__4(F, C, G)
23593 ).
23594initial_call_pattern___1__1__1__4([], _, _, A, B, C) :-
23595 initial_call_pattern___1__1__0__4(A, B, C).
23596initial_call_pattern___1__1__1__4([A|G], F, C, H, I, B) :-
23597 ( A=suspension(_, active, _, E),
23598 D=t(303, B, C, A),
23599 '$novel_production'(B, D),
23600 '$novel_production'(C, D)
23601 -> '$extend_history'(B, D),
23602 setarg(2, B, active),
23603 ai_observation_schedule_new_calls(E, F),
23604 ( B=suspension(_, active, _, _)
23605 -> setarg(2, B, inactive),
23606 initial_call_pattern___1__1__1__4(G,
23607 F,
23608 C,
23609 H,
23610 I,
23611 B)
23612 ; true
23613 )
23614 ; initial_call_pattern___1__1__1__4(G,
23615 F,
23616 C,
23617 H,
23618 I,
23619 B)
23620 ).
23621initial_call_pattern___1__1(A, B) :-
23622 initial_call_pattern___1__2(A, B).
23623initial_call_pattern___1__2(_, A) :-
23624 setarg(2, A, active).
23625call_pattern(A) :-
23626 call_pattern___1__0(A, _).
23627call_pattern___1__0(B, _) :-
23628 nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',
23629 A),
23630 lookup_ht(A, B, C),
23631 member(D, C),
23632 D=suspension(_, active, _), !.
23633call_pattern___1__0(B, A) :-
23634 A=suspension(C, active, B),
23635 'chr gen_id'(C),
23636 nb_getval('$chr_store_multi_hash_chr_translate____call_pattern___1-1',
23637 D),
23638 insert_ht(D, B, A),
23639 call_pattern_worker(B),
23640 ( A=suspension(_, active, _)
23641 -> setarg(2, A, inactive),
23642 call_pattern___1__1(B, A)
23643 ; true
23644 ).
23645call_pattern___1__1(_, A) :-
23646 setarg(2, A, active).
23647call_pattern_worker(odom([], A)) :- !,
23648 final_answer_pattern(odom([], A), odom([], A)).
23649call_pattern_worker(odom([A|C], B)) :- !,
23650 D=odom(A, B),
23651 depends_on_goal(odom([A|C], B), D),
23652 call_pattern(D).
23653call_pattern_worker(odom((A;B), C)) :- !,
23654 D=odom((A;B), C),
23655 E=odom([], C),
23656 final_answer_pattern(D, E),
23657 F=odom(A, C),
23658 G=odom(B, C),
23659 call_pattern(F),
23660 call_pattern(G),
23661 depends_on_as(D, F, G).
23662call_pattern_worker(odom(builtin, A)) :- !,
23663 ord_empty(B),
23664 final_answer_pattern(odom(builtin, A), odom([], B)).
23665call_pattern_worker(odom(occ(B, E), G)) :-
23666 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
23667 A),
23668 lookup_ht(A, B, C),
23669 member(D, C),
23670 D=suspension(_, active, _, _, F),
23671 E>F, !,
23672 final_answer_pattern(odom(occ(B, E), G),
23673 odom([], G)).
23674call_pattern_worker(odom(A, B)) :-
23675 A=_/_, !,
23676 C=odom(occ(A, 1), B),
23677 call_pattern(C),
23678 depends_on(odom(A, B), C).
23679call_pattern_worker(odom(occ(B, C), I)) :-
23680 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
23681 A),
23682 lookup_ht(A, k(B, C), D),
23683 member(E, D),
23684 E=suspension(_, active, _, _, _, _, F, G, _),
23685 is_passive(F, G), !,
23686 H is C+1,
23687 J=odom(occ(B, H), I),
23688 call_pattern(J),
23689 final_answer_pattern(odom(occ(B, C), I),
23690 odom([], I)),
23691 depends_on(odom(occ(B, C), I), J).
23692call_pattern_worker(odom(occ(B, C), H)) :-
23693 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
23694 A),
23695 ( lookup_ht(A, k(B, C, simplification), D),
23696 member(E, D),
23697 E=suspension(_, active, _, _, _, _, F, G, _),
23698 \+ is_passive(F, G), !,
23699 ai_observation_memo_simplification_rest_heads(B,
23700 C,
23701 I),
23702 ai_observation_observe_set(H, I, K),
23703 ai_observation_memo_abstract_goal(F, J),
23704 call_pattern(odom(J, K)),
23705 L is C+1,
23706 M=odom(occ(B, L), H),
23707 call_pattern(M),
23708 depends_on_as(odom(occ(B, C), H),
23709 odom(J, K),
23710 M),
23711 final_answer_pattern(odom(occ(B, C), H),
23712 odom([], H))
23713 ; lookup_ht(A, k(B, C, propagation), N),
23714 member(O, N),
23715 O=suspension(_, active, _, _, _, _, P, Q, _),
23716 \+ is_passive(P, Q), !,
23717 ai_observation_memo_propagation_rest_heads(B,
23718 C,
23719 R),
23720 ai_observation_observe_set(H, R, S),
23721 ord_add_element(S, B, U),
23722 ai_observation_memo_abstract_goal(P, T),
23723 call_pattern(odom(T, U)),
23724 ( ord_memberchk(B, S)
23725 -> V=no
23726 ; V=yes
23727 ),
23728 W is C+1,
23729 X=odom(occ(B, W), H),
23730 call_pattern(X),
23731 depends_on_ap(odom(occ(B, C), H),
23732 odom(T, U),
23733 X,
23734 V)
23735 ).
23736call_pattern_worker(A) :-
23737 chr_error(internal,
23738 'AI observation analysis: unexpected abstract state ~w\n',
23739 [A]).
23740final_answer_pattern(A, B) :-
23741 final_answer_pattern___2__0(A, B, _).
23742final_answer_pattern___2__0(B, E, G) :-
23743 ( nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23744 A),
23745 lookup_ht(A, B, C)
23746 ),
23747 ( member(D, C),
23748 D=suspension(_, active, _, _, F),
23749 ai_observation_leq(E, F), !
23750 ; !,
23751 final_answer_pattern___2__0__0__2(C, B, E, G)
23752 ).
23753final_answer_pattern___2__0__0__2([], A, B, C) :-
23754 final_answer_pattern___2__1(A, B, C).
23755final_answer_pattern___2__0__0__2([A|G], C, E, H) :-
23756 ( ( A=suspension(_, active, _, B, D),
23757 B==C
23758 ),
23759 ai_observation_leq(D, E)
23760 -> ( setarg(2, A, removed),
23761 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23762 F),
23763 delete_ht(F, C, A)
23764 ),
23765 final_answer_pattern___2__0__0__2(G, C, E, H)
23766 ; final_answer_pattern___2__0__0__2(G, C, E, H)
23767 ).
23768final_answer_pattern___2__0(A, B, C) :-
23769 final_answer_pattern___2__1(A, B, C).
23770final_answer_pattern___2__1(B, D, C) :-
23771 nb_getval('$chr_store_multi_hash_chr_translate____initial_call_pattern___1-1',
23772 A),
23773 lookup_ht(A, B, F), !,
23774 C=suspension(E, not_stored_yet, t, B, D),
23775 'chr gen_id'(E),
23776 final_answer_pattern___2__1__0__3(F, B, D, C).
23777final_answer_pattern___2__1__0__3([], A, B, C) :-
23778 final_answer_pattern___2__2(A, B, C).
23779final_answer_pattern___2__1__0__3([A|E], C, F, G) :-
23780 ( ( A=suspension(_, active, _, B),
23781 B==C
23782 ),
23783 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
23784 D)
23785 -> final_answer_pattern___2__1__1__3(D,
23786 A,
23787 E,
23788 C,
23789 F,
23790 G)
23791 ; final_answer_pattern___2__1__0__3(E, C, F, G)
23792 ).
23793final_answer_pattern___2__1__1__3([], _, A, B, C, D) :-
23794 final_answer_pattern___2__1__0__3(A, B, C, D).
23795final_answer_pattern___2__1__1__3([A|J], B, K, G, I, C) :-
23796 ( A=suspension(_, active, _, H),
23797 D=t(303, B, C, A),
23798 '$novel_production'(B, D),
23799 '$novel_production'(C, D)
23800 -> '$extend_history'(C, D),
23801 ( arg(2, C, E),
23802 setarg(2, C, active),
23803 ( E==not_stored_yet
23804 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23805 F),
23806 insert_ht(F, G, C)
23807 ; true
23808 )
23809 ),
23810 ai_observation_schedule_new_calls(H, I),
23811 ( C=suspension(_, active, _, _, _)
23812 -> setarg(2, C, inactive),
23813 final_answer_pattern___2__1__1__3(J,
23814 B,
23815 K,
23816 G,
23817 I,
23818 C)
23819 ; true
23820 )
23821 ; final_answer_pattern___2__1__1__3(J,
23822 B,
23823 K,
23824 G,
23825 I,
23826 C)
23827 ).
23828final_answer_pattern___2__1(B, C, A) :-
23829 A=suspension(D, not_stored_yet, t, B, C),
23830 'chr gen_id'(D),
23831 final_answer_pattern___2__2(B, C, A).
23832final_answer_pattern___2__2(B, D, E) :-
23833 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
23834 A),
23835 lookup_ht(A, B, C), !,
23836 final_answer_pattern___2__2__0__4(C, B, D, E).
23837final_answer_pattern___2__2__0__4([], A, B, C) :-
23838 final_answer_pattern___2__3(A, B, C).
23839final_answer_pattern___2__2__0__4([A|J], C, I, D) :-
23840 ( A=suspension(_, active, _, H, B),
23841 B==C,
23842 E=t(305, A, D),
23843 '$novel_production'(A, E),
23844 '$novel_production'(D, E)
23845 -> '$extend_history'(D, E),
23846 ( arg(2, D, F),
23847 setarg(2, D, active),
23848 ( F==not_stored_yet
23849 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23850 G),
23851 insert_ht(G, C, D)
23852 ; true
23853 )
23854 ),
23855 final_answer_pattern(H, I),
23856 ( D=suspension(_, active, _, _, _)
23857 -> setarg(2, D, inactive),
23858 final_answer_pattern___2__2__0__4(J,
23859 C,
23860 I,
23861 D)
23862 ; true
23863 )
23864 ; final_answer_pattern___2__2__0__4(J, C, I, D)
23865 ).
23866final_answer_pattern___2__2(A, B, C) :-
23867 final_answer_pattern___2__3(A, B, C).
23868final_answer_pattern___2__3(B, D, E) :-
23869 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
23870 A),
23871 lookup_ht(A, B, C), !,
23872 final_answer_pattern___2__3__0__5(C, B, D, E).
23873final_answer_pattern___2__3__0__5([], A, B, C) :-
23874 final_answer_pattern___2__4(A, B, C).
23875final_answer_pattern___2__3__0__5([A|G], C, H, I) :-
23876 ( ( A=suspension(_, active, _, E, B),
23877 B==C
23878 ),
23879 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
23880 D),
23881 lookup_ht(D, E, F)
23882 -> final_answer_pattern___2__3__1__5(F,
23883 E,
23884 A,
23885 G,
23886 C,
23887 H,
23888 I)
23889 ; final_answer_pattern___2__3__0__5(G, C, H, I)
23890 ).
23891final_answer_pattern___2__3__1__5([], _, _, A, B, C, D) :-
23892 final_answer_pattern___2__3__0__5(A, B, C, D).
23893final_answer_pattern___2__3__1__5([A|G], C, H, I, J, K, L) :-
23894 ( A=suspension(_, active, _, B, F),
23895 B==C
23896 -> ( setarg(2, A, removed),
23897 ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
23898 D),
23899 delete_ht(D, C, A)
23900 ),
23901 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
23902 E),
23903 delete_ht(E, F, A)
23904 ),
23905 final_answer_pattern___2__3__1__5(G,
23906 C,
23907 H,
23908 I,
23909 J,
23910 K,
23911 L)
23912 ; final_answer_pattern___2__3__1__5(G,
23913 C,
23914 H,
23915 I,
23916 J,
23917 K,
23918 L)
23919 ).
23920final_answer_pattern___2__3(A, B, C) :-
23921 final_answer_pattern___2__4(A, B, C).
23922final_answer_pattern___2__4(B, D, E) :-
23923 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
23924 A),
23925 lookup_ht(A, B, C), !,
23926 final_answer_pattern___2__4__0__6(C, B, D, E).
23927final_answer_pattern___2__4__0__6([], A, B, C) :-
23928 final_answer_pattern___2__5(A, B, C).
23929final_answer_pattern___2__4__0__6([A|M], C, I, D) :-
23930 ( A=suspension(_, active, _, H, B),
23931 B==C,
23932 E=t(310, A, D),
23933 '$novel_production'(A, E),
23934 '$novel_production'(D, E)
23935 -> '$extend_history'(D, E),
23936 ( arg(2, D, F),
23937 setarg(2, D, active),
23938 ( F==not_stored_yet
23939 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23940 G),
23941 insert_ht(G, C, D)
23942 ; true
23943 )
23944 ),
23945 ( H=odom([_|J], _),
23946 I=odom([], K),
23947 L=odom(J, K),
23948 call_pattern(L),
23949 depends_on(H, L)
23950 ),
23951 ( D=suspension(_, active, _, _, _)
23952 -> setarg(2, D, inactive),
23953 final_answer_pattern___2__4__0__6(M,
23954 C,
23955 I,
23956 D)
23957 ; true
23958 )
23959 ; final_answer_pattern___2__4__0__6(M,
23960 C,
23961 I,
23962 D)
23963 ).
23964final_answer_pattern___2__4(A, B, C) :-
23965 final_answer_pattern___2__5(A, B, C).
23966final_answer_pattern___2__5(B, D, E) :-
23967 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',
23968 A),
23969 lookup_ht(A, B, C), !,
23970 final_answer_pattern___2__5__0__7(C, B, D, E).
23971final_answer_pattern___2__5__0__7([], A, B, C) :-
23972 final_answer_pattern___2__6(A, B, C).
23973final_answer_pattern___2__5__0__7([A|H], C, I, J) :-
23974 ( ( A=suspension(_, active, _, G, B, E),
23975 B==C
23976 ),
23977 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
23978 D),
23979 lookup_ht(D, E, F)
23980 -> final_answer_pattern___2__5__1__7(F,
23981 G,
23982 E,
23983 A,
23984 H,
23985 C,
23986 I,
23987 J)
23988 ; final_answer_pattern___2__5__0__7(H, C, I, J)
23989 ).
23990final_answer_pattern___2__5__1__7([], _, _, _, A, B, C, D) :-
23991 final_answer_pattern___2__5__0__7(A, B, C, D).
23992final_answer_pattern___2__5__1__7([A|N], L, C, D, O, I, J, E) :-
23993 ( A=suspension(_, active, _, B, K),
23994 B==C,
23995 F=t(317, D, E, A),
23996 '$novel_production'(D, F),
23997 '$novel_production'(E, F),
23998 '$novel_production'(A, F)
23999 -> '$extend_history'(E, F),
24000 ( arg(2, E, G),
24001 setarg(2, E, active),
24002 ( G==not_stored_yet
24003 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24004 H),
24005 insert_ht(H, I, E)
24006 ; true
24007 )
24008 ),
24009 ( ai_observation_lub(J, K, M),
24010 final_answer_pattern(L, M)
24011 ),
24012 ( E=suspension(_, active, _, _, _)
24013 -> setarg(2, E, inactive),
24014 final_answer_pattern___2__5__1__7(N,
24015 L,
24016 C,
24017 D,
24018 O,
24019 I,
24020 J,
24021 E)
24022 ; true
24023 )
24024 ; final_answer_pattern___2__5__1__7(N,
24025 L,
24026 C,
24027 D,
24028 O,
24029 I,
24030 J,
24031 E)
24032 ).
24033final_answer_pattern___2__5(A, B, C) :-
24034 final_answer_pattern___2__6(A, B, C).
24035final_answer_pattern___2__6(B, D, E) :-
24036 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',
24037 A),
24038 lookup_ht(A, B, C), !,
24039 final_answer_pattern___2__6__0__8(C, B, D, E).
24040final_answer_pattern___2__6__0__8([], A, B, C) :-
24041 final_answer_pattern___2__7(A, B, C).
24042final_answer_pattern___2__6__0__8([A|H], C, I, J) :-
24043 ( ( A=suspension(_, active, _, G, E, B),
24044 B==C
24045 ),
24046 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24047 D),
24048 lookup_ht(D, E, F)
24049 -> final_answer_pattern___2__6__1__8(F,
24050 G,
24051 E,
24052 A,
24053 H,
24054 C,
24055 I,
24056 J)
24057 ; final_answer_pattern___2__6__0__8(H, C, I, J)
24058 ).
24059final_answer_pattern___2__6__1__8([], _, _, _, A, B, C, D) :-
24060 final_answer_pattern___2__6__0__8(A, B, C, D).
24061final_answer_pattern___2__6__1__8([A|N], L, C, D, O, I, K, E) :-
24062 ( A=suspension(_, active, _, B, J),
24063 B==C,
24064 F=t(317, D, A, E),
24065 '$novel_production'(D, F),
24066 '$novel_production'(A, F),
24067 '$novel_production'(E, F)
24068 -> '$extend_history'(E, F),
24069 ( arg(2, E, G),
24070 setarg(2, E, active),
24071 ( G==not_stored_yet
24072 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24073 H),
24074 insert_ht(H, I, E)
24075 ; true
24076 )
24077 ),
24078 ( ai_observation_lub(J, K, M),
24079 final_answer_pattern(L, M)
24080 ),
24081 ( E=suspension(_, active, _, _, _)
24082 -> setarg(2, E, inactive),
24083 final_answer_pattern___2__6__1__8(N,
24084 L,
24085 C,
24086 D,
24087 O,
24088 I,
24089 K,
24090 E)
24091 ; true
24092 )
24093 ; final_answer_pattern___2__6__1__8(N,
24094 L,
24095 C,
24096 D,
24097 O,
24098 I,
24099 K,
24100 E)
24101 ).
24102final_answer_pattern___2__6(A, B, C) :-
24103 final_answer_pattern___2__7(A, B, C).
24104final_answer_pattern___2__7(B, D, E) :-
24105 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
24106 A),
24107 lookup_ht(A, B, C), !,
24108 final_answer_pattern___2__7__0__9(C, B, D, E).
24109final_answer_pattern___2__7__0__9([], A, B, C) :-
24110 final_answer_pattern___2__8(A, B, C).
24111final_answer_pattern___2__7__0__9([A|J], C, I, D) :-
24112 ( A=suspension(_, active, _, H, _, B, _),
24113 B==C,
24114 E=t(325, A, D),
24115 '$novel_production'(A, E),
24116 '$novel_production'(D, E)
24117 -> '$extend_history'(D, E),
24118 ( arg(2, D, F),
24119 setarg(2, D, active),
24120 ( F==not_stored_yet
24121 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24122 G),
24123 insert_ht(G, C, D)
24124 ; true
24125 )
24126 ),
24127 final_answer_pattern(H, I),
24128 ( D=suspension(_, active, _, _, _)
24129 -> setarg(2, D, inactive),
24130 final_answer_pattern___2__7__0__9(J,
24131 C,
24132 I,
24133 D)
24134 ; true
24135 )
24136 ; final_answer_pattern___2__7__0__9(J, C, I, D)
24137 ).
24138final_answer_pattern___2__7(A, B, C) :-
24139 final_answer_pattern___2__8(A, B, C).
24140final_answer_pattern___2__8(B, D, E) :-
24141 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
24142 A),
24143 lookup_ht(A, B, C), !,
24144 final_answer_pattern___2__8__0__10(C, B, D, E).
24145final_answer_pattern___2__8__0__10([], A, B, C) :-
24146 final_answer_pattern___2__9(A, B, C).
24147final_answer_pattern___2__8__0__10([A|I], C, J, K) :-
24148 ( ( A=suspension(_, active, _, G, B, E, H),
24149 B==C
24150 ),
24151 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24152 D),
24153 lookup_ht(D, E, F)
24154 -> final_answer_pattern___2__8__1__10(F,
24155 G,
24156 E,
24157 H,
24158 A,
24159 I,
24160 C,
24161 J,
24162 K)
24163 ; final_answer_pattern___2__8__0__10(I,
24164 C,
24165 J,
24166 K)
24167 ).
24168final_answer_pattern___2__8__1__10([], _, _, _, _, A, B, C, D) :-
24169 final_answer_pattern___2__8__0__10(A, B, C, D).
24170final_answer_pattern___2__8__1__10([A|T], J, C, N, D, U, I, K, E) :-
24171 ( A=suspension(_, active, _, B, R),
24172 B==C,
24173 F=t(326, D, E, A),
24174 '$novel_production'(D, F),
24175 '$novel_production'(E, F),
24176 '$novel_production'(A, F)
24177 -> '$extend_history'(E, F),
24178 ( arg(2, E, G),
24179 setarg(2, E, active),
24180 ( G==not_stored_yet
24181 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24182 H),
24183 insert_ht(H, I, E)
24184 ; true
24185 )
24186 ),
24187 ( J=odom(occ(L, M), _),
24188 ( ai_observation_is_observed(K, L)
24189 -> ai_observed_internal(L, M)
24190 ; ai_not_observed_internal(L, M)
24191 ),
24192 ( N==yes
24193 -> K=odom([], O),
24194 ord_del_element(O, L, P),
24195 Q=odom([], P)
24196 ; Q=K
24197 ),
24198 ai_observation_lub(Q, R, S),
24199 final_answer_pattern(J, S)
24200 ),
24201 ( E=suspension(_, active, _, _, _)
24202 -> setarg(2, E, inactive),
24203 final_answer_pattern___2__8__1__10(T,
24204 J,
24205 C,
24206 N,
24207 D,
24208 U,
24209 I,
24210 K,
24211 E)
24212 ; true
24213 )
24214 ; final_answer_pattern___2__8__1__10(T,
24215 J,
24216 C,
24217 N,
24218 D,
24219 U,
24220 I,
24221 K,
24222 E)
24223 ).
24224final_answer_pattern___2__8(A, B, C) :-
24225 final_answer_pattern___2__9(A, B, C).
24226final_answer_pattern___2__9(B, D, E) :-
24227 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
24228 A),
24229 lookup_ht(A, B, C), !,
24230 final_answer_pattern___2__9__0__11(C, B, D, E).
24231final_answer_pattern___2__9__0__11([], A, B, C) :-
24232 final_answer_pattern___2__10(A, B, C).
24233final_answer_pattern___2__9__0__11([A|I], C, J, K) :-
24234 ( ( A=suspension(_, active, _, G, E, B, H),
24235 B==C
24236 ),
24237 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24238 D),
24239 lookup_ht(D, E, F)
24240 -> final_answer_pattern___2__9__1__11(F,
24241 G,
24242 E,
24243 H,
24244 A,
24245 I,
24246 C,
24247 J,
24248 K)
24249 ; final_answer_pattern___2__9__0__11(I,
24250 C,
24251 J,
24252 K)
24253 ).
24254final_answer_pattern___2__9__1__11([], _, _, _, _, A, B, C, D) :-
24255 final_answer_pattern___2__9__0__11(A, B, C, D).
24256final_answer_pattern___2__9__1__11([A|T], J, C, N, D, U, I, R, E) :-
24257 ( A=suspension(_, active, _, B, K),
24258 B==C,
24259 F=t(326, D, A, E),
24260 '$novel_production'(D, F),
24261 '$novel_production'(A, F),
24262 '$novel_production'(E, F)
24263 -> '$extend_history'(E, F),
24264 ( arg(2, E, G),
24265 setarg(2, E, active),
24266 ( G==not_stored_yet
24267 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24268 H),
24269 insert_ht(H, I, E)
24270 ; true
24271 )
24272 ),
24273 ( J=odom(occ(L, M), _),
24274 ( ai_observation_is_observed(K, L)
24275 -> ai_observed_internal(L, M)
24276 ; ai_not_observed_internal(L, M)
24277 ),
24278 ( N==yes
24279 -> K=odom([], O),
24280 ord_del_element(O, L, P),
24281 Q=odom([], P)
24282 ; Q=K
24283 ),
24284 ai_observation_lub(Q, R, S),
24285 final_answer_pattern(J, S)
24286 ),
24287 ( E=suspension(_, active, _, _, _)
24288 -> setarg(2, E, inactive),
24289 final_answer_pattern___2__9__1__11(T,
24290 J,
24291 C,
24292 N,
24293 D,
24294 U,
24295 I,
24296 R,
24297 E)
24298 ; true
24299 )
24300 ; final_answer_pattern___2__9__1__11(T,
24301 J,
24302 C,
24303 N,
24304 D,
24305 U,
24306 I,
24307 R,
24308 E)
24309 ).
24310final_answer_pattern___2__9(A, B, C) :-
24311 final_answer_pattern___2__10(A, B, C).
24312final_answer_pattern___2__10(D, _, A) :-
24313 arg(2, A, B),
24314 setarg(2, A, active),
24315 ( B==not_stored_yet
24316 -> nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24317 C),
24318 insert_ht(C, D, A)
24319 ; true
24320 ).
24321abstract_constraints(C) :-
24322 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
24323 A),
24324 ( member(B, A),
24325 B=suspension(_, active, _, _), !
24326 ; !,
24327 abstract_constraints___1__0__0__2(A, C)
24328 ).
24329abstract_constraints___1__0__0__2([], A) :-
24330 abstract_constraints___1__1(A).
24331abstract_constraints___1__0__0__2([A|F], G) :-
24332 ( A=suspension(_, active, _, _)
24333 -> ( setarg(2, A, removed),
24334 arg(3, A, B),
24335 ( var(B)
24336 -> nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
24337 C),
24338 C=[_|D],
24339 b_setval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
24340 D),
24341 ( D=[E|_]
24342 -> setarg(3, E, _)
24343 ; true
24344 )
24345 ; B=[_, _|D],
24346 setarg(2, B, D),
24347 ( D=[E|_]
24348 -> setarg(3, E, B)
24349 ; true
24350 )
24351 )
24352 ),
24353 abstract_constraints___1__0__0__2(F, G)
24354 ; abstract_constraints___1__0__0__2(F, G)
24355 ).
24356abstract_constraints(A) :-
24357 abstract_constraints___1__1(A).
24358abstract_constraints___1__1(A) :-
24359 C=suspension(B, active, _, A),
24360 'chr gen_id'(B),
24361 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
24362 D),
24363 E=[C|D],
24364 b_setval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
24365 E),
24366 ( D=[F|_]
24367 -> setarg(3, F, E)
24368 ; true
24369 ).
24370depends_on(A, B) :-
24371 depends_on___2__0(A, B, _).
24372depends_on___2__0(D, B, C) :-
24373 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24374 A),
24375 lookup_ht(A, B, F), !,
24376 C=suspension(E, not_stored_yet, t, D, B),
24377 'chr gen_id'(E),
24378 depends_on___2__0__0__1(F, D, B, C).
24379depends_on___2__0__0__1([], A, B, C) :-
24380 depends_on___2__1(A, B, C).
24381depends_on___2__0__0__1([A|K], H, C, D) :-
24382 ( A=suspension(_, active, _, B, J),
24383 B==C,
24384 E=t(305, D, A),
24385 '$novel_production'(D, E),
24386 '$novel_production'(A, E)
24387 -> '$extend_history'(D, E),
24388 ( arg(2, D, F),
24389 setarg(2, D, active),
24390 ( F==not_stored_yet
24391 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
24392 G),
24393 insert_ht(G, H, D)
24394 ),
24395 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
24396 I),
24397 insert_ht(I, C, D)
24398 ; true
24399 )
24400 ),
24401 final_answer_pattern(H, J),
24402 ( D=suspension(_, active, _, _, _)
24403 -> setarg(2, D, inactive),
24404 depends_on___2__0__0__1(K, H, C, D)
24405 ; true
24406 )
24407 ; depends_on___2__0__0__1(K, H, C, D)
24408 ).
24409depends_on___2__0(B, C, A) :-
24410 A=suspension(D, not_stored_yet, t, B, C),
24411 'chr gen_id'(D),
24412 depends_on___2__1(B, C, A).
24413depends_on___2__1(D, F, A) :-
24414 arg(2, A, B),
24415 setarg(2, A, active),
24416 ( B==not_stored_yet
24417 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
24418 C),
24419 insert_ht(C, D, A)
24420 ),
24421 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
24422 E),
24423 insert_ht(E, F, A)
24424 ; true
24425 ).
24426depends_on_ap(A, B, C, D) :-
24427 depends_on_ap___4__0(A, B, C, D, _).
24428depends_on_ap___4__0(D, E, B, F, C) :-
24429 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24430 A),
24431 lookup_ht(A, B, H), !,
24432 C=suspension(G, not_stored_yet, t, D, E, B, F),
24433 'chr gen_id'(G),
24434 depends_on_ap___4__0__0__1(H,
24435 D,
24436 E,
24437 B,
24438 F,
24439 C).
24440depends_on_ap___4__0__0__1([], A, B, C, D, E) :-
24441 depends_on_ap___4__1(A, B, C, D, E).
24442depends_on_ap___4__0__0__1([A|L], J, H, C, M, D) :-
24443 ( A=suspension(_, active, _, B, K),
24444 B==C,
24445 E=t(325, D, A),
24446 '$novel_production'(D, E),
24447 '$novel_production'(A, E)
24448 -> '$extend_history'(D, E),
24449 ( arg(2, D, F),
24450 setarg(2, D, active),
24451 ( F==not_stored_yet
24452 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
24453 G),
24454 insert_ht(G, H, D)
24455 ),
24456 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
24457 I),
24458 insert_ht(I, C, D)
24459 ; true
24460 )
24461 ),
24462 final_answer_pattern(J, K),
24463 ( D=suspension(_, active, _, _, _, _, _)
24464 -> setarg(2, D, inactive),
24465 depends_on_ap___4__0__0__1(L,
24466 J,
24467 H,
24468 C,
24469 M,
24470 D)
24471 ; true
24472 )
24473 ; depends_on_ap___4__0__0__1(L,
24474 J,
24475 H,
24476 C,
24477 M,
24478 D)
24479 ).
24480depends_on_ap___4__0(B, C, D, E, A) :-
24481 A=suspension(F, not_stored_yet, t, B, C, D, E),
24482 'chr gen_id'(F),
24483 depends_on_ap___4__1(B, C, D, E, A).
24484depends_on_ap___4__1(D, B, E, F, G) :-
24485 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24486 A),
24487 lookup_ht(A, B, C), !,
24488 depends_on_ap___4__1__0__2(C,
24489 D,
24490 B,
24491 E,
24492 F,
24493 G).
24494depends_on_ap___4__1__0__2([], A, B, C, D, E) :-
24495 depends_on_ap___4__2(A, B, C, D, E).
24496depends_on_ap___4__1__0__2([A|H], I, C, E, J, K) :-
24497 ( ( A=suspension(_, active, _, B, G),
24498 B==C
24499 ),
24500 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24501 D),
24502 lookup_ht(D, E, F)
24503 -> depends_on_ap___4__1__1__2(F,
24504 G,
24505 A,
24506 H,
24507 I,
24508 C,
24509 E,
24510 J,
24511 K)
24512 ; depends_on_ap___4__1__0__2(H,
24513 I,
24514 C,
24515 E,
24516 J,
24517 K)
24518 ).
24519depends_on_ap___4__1__1__2([], _, _, A, B, C, D, E, F) :-
24520 depends_on_ap___4__1__0__2(A,
24521 B,
24522 C,
24523 D,
24524 E,
24525 F).
24526depends_on_ap___4__1__1__2([A|U], L, B, V, K, I, D, O, E) :-
24527 ( A=suspension(_, active, _, C, S),
24528 A\==B,
24529 C==D,
24530 F=t(326, E, B, A),
24531 '$novel_production'(E, F),
24532 '$novel_production'(B, F),
24533 '$novel_production'(A, F)
24534 -> '$extend_history'(E, F),
24535 ( arg(2, E, G),
24536 setarg(2, E, active),
24537 ( G==not_stored_yet
24538 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
24539 H),
24540 insert_ht(H, I, E)
24541 ),
24542 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
24543 J),
24544 insert_ht(J, D, E)
24545 ; true
24546 )
24547 ),
24548 ( K=odom(occ(M, N), _),
24549 ( ai_observation_is_observed(L, M)
24550 -> ai_observed_internal(M, N)
24551 ; ai_not_observed_internal(M, N)
24552 ),
24553 ( O==yes
24554 -> L=odom([], P),
24555 ord_del_element(P, M, Q),
24556 R=odom([], Q)
24557 ; R=L
24558 ),
24559 ai_observation_lub(R, S, T),
24560 final_answer_pattern(K, T)
24561 ),
24562 ( E=suspension(_, active, _, _, _, _, _)
24563 -> setarg(2, E, inactive),
24564 depends_on_ap___4__1__1__2(U,
24565 L,
24566 B,
24567 V,
24568 K,
24569 I,
24570 D,
24571 O,
24572 E)
24573 ; true
24574 )
24575 ; depends_on_ap___4__1__1__2(U,
24576 L,
24577 B,
24578 V,
24579 K,
24580 I,
24581 D,
24582 O,
24583 E)
24584 ).
24585depends_on_ap___4__1(A, B, C, D, E) :-
24586 depends_on_ap___4__2(A, B, C, D, E).
24587depends_on_ap___4__2(_, D, F, _, A) :-
24588 arg(2, A, B),
24589 setarg(2, A, active),
24590 ( B==not_stored_yet
24591 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-2',
24592 C),
24593 insert_ht(C, D, A)
24594 ),
24595 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_ap___4-3',
24596 E),
24597 insert_ht(E, F, A)
24598 ; true
24599 ).
24600depends_on_goal(A, B) :-
24601 depends_on_goal___2__0(A, B, _).
24602depends_on_goal___2__0(B, D, E) :-
24603 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
24604 A),
24605 lookup_ht(A, B, C), !,
24606 depends_on_goal___2__0__0__1(C, B, D, E).
24607depends_on_goal___2__0__0__1([], A, B, C) :-
24608 depends_on_goal___2__1(A, B, C).
24609depends_on_goal___2__0__0__1([A|K], C, D, L) :-
24610 ( ( A=suspension(_, active, _, B, J),
24611 B==C
24612 ),
24613 ( ground(D),
24614 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24615 E),
24616 lookup_ht(E, D, F)
24617 ),
24618 member(G, F),
24619 G=suspension(_, active, _, _, _)
24620 -> ( setarg(2, A, removed),
24621 ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-1',
24622 H),
24623 delete_ht(H, C, A)
24624 ),
24625 nb_getval('$chr_store_multi_hash_chr_translate____depends_on___2-2',
24626 I),
24627 delete_ht(I, J, A)
24628 ),
24629 depends_on_goal___2__0__0__1(K, C, D, L)
24630 ; depends_on_goal___2__0__0__1(K, C, D, L)
24631 ).
24632depends_on_goal___2__0(A, B, C) :-
24633 depends_on_goal___2__1(A, B, C).
24634depends_on_goal___2__1(D, B, C) :-
24635 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24636 A),
24637 lookup_ht(A, B, F), !,
24638 C=suspension(E, not_stored_yet, t, D, B),
24639 'chr gen_id'(E),
24640 depends_on_goal___2__1__0__2(F, D, B, C).
24641depends_on_goal___2__1__0__2([], A, B, C) :-
24642 depends_on_goal___2__2(A, B, C).
24643depends_on_goal___2__1__0__2([A|M], H, C, D) :-
24644 ( A=suspension(_, active, _, B, I),
24645 B==C,
24646 E=t(310, D, A),
24647 '$novel_production'(D, E),
24648 '$novel_production'(A, E)
24649 -> '$extend_history'(D, E),
24650 ( arg(2, D, F),
24651 setarg(2, D, active),
24652 ( F==not_stored_yet
24653 -> nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
24654 G),
24655 insert_ht(G, C, D)
24656 ; true
24657 )
24658 ),
24659 ( H=odom([_|J], _),
24660 I=odom([], K),
24661 L=odom(J, K),
24662 call_pattern(L),
24663 depends_on(H, L)
24664 ),
24665 ( D=suspension(_, active, _, _, _)
24666 -> setarg(2, D, inactive),
24667 depends_on_goal___2__1__0__2(M, H, C, D)
24668 ; true
24669 )
24670 ; depends_on_goal___2__1__0__2(M, H, C, D)
24671 ).
24672depends_on_goal___2__1(B, C, A) :-
24673 A=suspension(D, not_stored_yet, t, B, C),
24674 'chr gen_id'(D),
24675 depends_on_goal___2__2(B, C, A).
24676depends_on_goal___2__2(_, D, A) :-
24677 arg(2, A, B),
24678 setarg(2, A, active),
24679 ( B==not_stored_yet
24680 -> nb_getval('$chr_store_multi_hash_chr_translate____depends_on_goal___2-2',
24681 C),
24682 insert_ht(C, D, A)
24683 ; true
24684 ).
24685ai_observed_internal(B, C) :-
24686 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
24687 A),
24688 lookup_ht(A, k(B, C), D), !,
24689 ai_observed_internal___2__0__0__1(D, B, C).
24690ai_observed_internal___2__0__0__1([], A, B) :-
24691 ai_observed_internal___2__1(A, B).
24692ai_observed_internal___2__0__0__1([A|K], C, E) :-
24693 ( A=suspension(_, active, _, B, D),
24694 B==C,
24695 D==E
24696 -> ( setarg(2, A, removed),
24697 ( arg(3, A, F),
24698 ( var(F)
24699 -> nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
24700 G),
24701 G=[_|H],
24702 b_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
24703 H),
24704 ( H=[I|_]
24705 -> setarg(3, I, _)
24706 ; true
24707 )
24708 ; F=[_, _|H],
24709 setarg(2, F, H),
24710 ( H=[I|_]
24711 -> setarg(3, I, F)
24712 ; true
24713 )
24714 )
24715 ),
24716 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
24717 J),
24718 delete_ht(J, k(C, E), A)
24719 ),
24720 ai_observed_internal___2__0__0__1(K, C, E)
24721 ; ai_observed_internal___2__0__0__1(K, C, E)
24722 ).
24723ai_observed_internal(A, B) :-
24724 ai_observed_internal___2__1(A, B).
24725ai_observed_internal___2__1(B, C) :-
24726 nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',
24727 A),
24728 lookup_ht(A, k(B, C), D),
24729 member(E, D),
24730 E=suspension(_, active, _, _, _), !.
24731ai_observed_internal___2__1(_, _) :-
24732 nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
24733 A),
24734 member(B, A),
24735 B=suspension(_, active, _), !.
24736ai_observed_internal___2__1(A, B) :-
24737 D=suspension(C, active, _, A, B),
24738 'chr gen_id'(C),
24739 nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
24740 E),
24741 F=[D|E],
24742 b_setval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
24743 F),
24744 ( E=[G|_]
24745 -> setarg(3, G, F)
24746 ; true
24747 ),
24748 nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',
24749 H),
24750 insert_ht(H, k(A, B), D).
24751ai_not_observed_internal(B, C) :-
24752 nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',
24753 A),
24754 lookup_ht(A, k(B, C), D),
24755 member(E, D),
24756 E=suspension(_, active, _, _, _), !.
24757ai_not_observed_internal(B, C) :-
24758 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
24759 A),
24760 lookup_ht(A, k(B, C), D),
24761 member(E, D),
24762 E=suspension(_, active, _, _, _), !.
24763ai_not_observed_internal(C, D) :-
24764 nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
24765 A),
24766 member(B, A),
24767 B=suspension(_, active, _), !,
24768 ai_not_observed(C, D).
24769ai_not_observed_internal(A, B) :-
24770 D=suspension(C, active, _, A, B),
24771 'chr gen_id'(C),
24772 nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
24773 E),
24774 F=[D|E],
24775 b_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
24776 F),
24777 ( E=[G|_]
24778 -> setarg(3, G, F)
24779 ; true
24780 ),
24781 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
24782 H),
24783 insert_ht(H, k(A, B), D).
24784ai_not_observed(A, B) :-
24785 ai_not_observed___2__0(A, B, _).
24786ai_not_observed___2__0(B, C, D) :-
24787 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
24788 A),
24789 lookup_ht(A, k(B, C, yes), F), !,
24790 D=suspension(E, not_stored_yet, B, C),
24791 'chr gen_id'(E),
24792 ai_not_observed___2__0__0__1(F, B, C, D).
24793ai_not_observed___2__0__0__1([], A, B, C) :-
24794 ai_not_observed___2__1(A, B, C).
24795ai_not_observed___2__0__0__1([A|T], C, E, P) :-
24796 ( ( A=suspension(_, active, B, D, F),
24797 B==C,
24798 D==E,
24799 F=yes
24800 ),
24801 ( ( ground(C),
24802 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
24803 G),
24804 lookup_ht(G, C, H)
24805 ),
24806 member(I, H),
24807 I=suspension(_, active, _, _, J, N)
24808 ),
24809 E<J
24810 -> ( ( setarg(2, A, removed),
24811 ( nb_getval('$chr_store_multi_hash_chr_translate____stored___3-13',
24812 K),
24813 delete_ht(K, k(C, yes), A)
24814 ),
24815 nb_getval('$chr_store_multi_hash_chr_translate____stored___3-123',
24816 L),
24817 delete_ht(L, k(C, E, yes), A)
24818 ),
24819 setarg(2, I, removed),
24820 ( nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-13',
24821 M),
24822 delete_ht(M, k(C, N), I)
24823 ),
24824 nb_getval('$chr_store_multi_hash_chr_translate____stored_complete___3-1',
24825 O),
24826 delete_ht(O, C, I)
24827 ),
24828 ( arg(2, P, Q),
24829 setarg(2, P, active),
24830 ( Q==not_stored_yet
24831 -> nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
24832 R),
24833 insert_ht(R, k(C, E), P)
24834 ; true
24835 )
24836 ),
24837 ( S is N-1,
24838 stored(C, E, maybe),
24839 stored_complete(C, J, S)
24840 ),
24841 ( P=suspension(_, active, _, _)
24842 -> setarg(2, P, inactive),
24843 ai_not_observed___2__0__0__1(T,
24844 C,
24845 E,
24846 P)
24847 ; true
24848 )
24849 ; ai_not_observed___2__0__0__1(T, C, E, P)
24850 ).
24851ai_not_observed___2__0(B, C, A) :-
24852 A=suspension(D, not_stored_yet, B, C),
24853 'chr gen_id'(D),
24854 ai_not_observed___2__1(B, C, A).
24855ai_not_observed___2__1(D, E, A) :-
24856 arg(2, A, B),
24857 setarg(2, A, active),
24858 ( B==not_stored_yet
24859 -> nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
24860 C),
24861 insert_ht(C, k(D, E), A)
24862 ; true
24863 ).
24864ai_is_observed(B, C) :-
24865 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed___2-12',
24866 A),
24867 lookup_ht(A, k(B, C), D),
24868 member(E, D),
24869 E=suspension(_, active, _, _), !,
24870 fail.
24871ai_is_observed(_, _).
24872depends_on_as(A, B, C) :-
24873 depends_on_as___3__0(A, B, C, _).
24874depends_on_as___3__0(D, B, E, C) :-
24875 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24876 A),
24877 lookup_ht(A, B, G), !,
24878 C=suspension(F, not_stored_yet, t, D, B, E),
24879 'chr gen_id'(F),
24880 depends_on_as___3__0__0__1(G, D, B, E, C).
24881depends_on_as___3__0__0__1([], A, B, C, D) :-
24882 depends_on_as___3__1(A, B, C, D).
24883depends_on_as___3__0__0__1([A|H], I, C, E, J) :-
24884 ( ( A=suspension(_, active, _, B, G),
24885 B==C
24886 ),
24887 nb_getval('$chr_store_multi_hash_chr_translate____final_answer_pattern___2-1',
24888 D),
24889 lookup_ht(D, E, F)
24890 -> depends_on_as___3__0__1__1(F,
24891 G,
24892 A,
24893 H,
24894 I,
24895 C,
24896 E,
24897 J)
24898 ; depends_on_as___3__0__0__1(H,
24899 I,
24900 C,
24901 E,
24902 J)
24903 ).
24904depends_on_as___3__0__1__1([], _, _, A, B, C, D, E) :-
24905 depends_on_as___3__0__0__1(A, B, C, D, E).
24906depends_on_as___3__0__1__1([A|O], K, B, P, M, J, D, E) :-
24907 ( A=suspension(_, active, _, C, L),
24908 A\==B,
24909 C==D,
24910 F=t(317, E, B, A),
24911 '$novel_production'(E, F),
24912 '$novel_production'(B, F),
24913 '$novel_production'(A, F)
24914 -> '$extend_history'(E, F),
24915 ( arg(2, E, G),
24916 setarg(2, E, active),
24917 ( G==not_stored_yet
24918 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',
24919 H),
24920 insert_ht(H, D, E)
24921 ),
24922 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',
24923 I),
24924 insert_ht(I, J, E)
24925 ; true
24926 )
24927 ),
24928 ( ai_observation_lub(K, L, N),
24929 final_answer_pattern(M, N)
24930 ),
24931 ( E=suspension(_, active, _, _, _, _)
24932 -> setarg(2, E, inactive),
24933 depends_on_as___3__0__1__1(O,
24934 K,
24935 B,
24936 P,
24937 M,
24938 J,
24939 D,
24940 E)
24941 ; true
24942 )
24943 ; depends_on_as___3__0__1__1(O,
24944 K,
24945 B,
24946 P,
24947 M,
24948 J,
24949 D,
24950 E)
24951 ).
24952depends_on_as___3__0(B, C, D, A) :-
24953 A=suspension(E, not_stored_yet, t, B, C, D),
24954 'chr gen_id'(E),
24955 depends_on_as___3__1(B, C, D, A).
24956depends_on_as___3__1(_, F, D, A) :-
24957 arg(2, A, B),
24958 setarg(2, A, active),
24959 ( B==not_stored_yet
24960 -> ( nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-3',
24961 C),
24962 insert_ht(C, D, A)
24963 ),
24964 nb_getval('$chr_store_multi_hash_chr_translate____depends_on_as___3-2',
24965 E),
24966 insert_ht(E, F, A)
24967 ; true
24968 ).
24969ai_observation_gather_results :-
24970 ai_observation_gather_results___0__0(_).
24971ai_observation_gather_results___0__0(B) :-
24972 nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
24973 A), !,
24974 ai_observation_gather_results___0__0__0__1(A, B).
24975ai_observation_gather_results___0__0__0__1([], A) :-
24976 ai_observation_gather_results___0__1(A).
24977ai_observation_gather_results___0__0__0__1([A|I], J) :-
24978 ( A=suspension(_, active, _, G, H)
24979 -> ( setarg(2, A, removed),
24980 ( arg(3, A, B),
24981 ( var(B)
24982 -> nb_getval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
24983 C),
24984 C=[_|D],
24985 b_setval('$chr_store_global_ground_chr_translate____ai_observed_internal___2',
24986 D),
24987 ( D=[E|_]
24988 -> setarg(3, E, _)
24989 ; true
24990 )
24991 ; B=[_, _|D],
24992 setarg(2, B, D),
24993 ( D=[E|_]
24994 -> setarg(3, E, B)
24995 ; true
24996 )
24997 )
24998 ),
24999 nb_getval('$chr_store_multi_hash_chr_translate____ai_observed_internal___2-12',
25000 F),
25001 delete_ht(F, k(G, H), A)
25002 ),
25003 ai_observation_gather_results___0__0__0__1(I, J)
25004 ; ai_observation_gather_results___0__0__0__1(I, J)
25005 ).
25006ai_observation_gather_results___0__0(A) :-
25007 ai_observation_gather_results___0__1(A).
25008ai_observation_gather_results___0__1(A) :-
25009 nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
25010 C), !,
25011 A=suspension(B, not_stored_yet, _),
25012 'chr gen_id'(B),
25013 ai_observation_gather_results___0__1__0__2(C, A).
25014ai_observation_gather_results___0__1__0__2([], A) :-
25015 ai_observation_gather_results___0__2(A).
25016ai_observation_gather_results___0__1__0__2([A|N], I) :-
25017 ( A=suspension(_, active, _, G, H)
25018 -> ( setarg(2, A, removed),
25019 ( arg(3, A, B),
25020 ( var(B)
25021 -> nb_getval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
25022 C),
25023 C=[_|D],
25024 b_setval('$chr_store_global_ground_chr_translate____ai_not_observed_internal___2',
25025 D),
25026 ( D=[E|_]
25027 -> setarg(3, E, _)
25028 ; true
25029 )
25030 ; B=[_, _|D],
25031 setarg(2, B, D),
25032 ( D=[E|_]
25033 -> setarg(3, E, B)
25034 ; true
25035 )
25036 )
25037 ),
25038 nb_getval('$chr_store_multi_hash_chr_translate____ai_not_observed_internal___2-12',
25039 F),
25040 delete_ht(F, k(G, H), A)
25041 ),
25042 ( arg(2, I, J),
25043 setarg(2, I, active),
25044 ( J==not_stored_yet
25045 -> nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
25046 K),
25047 L=[I|K],
25048 b_setval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
25049 L),
25050 ( K=[M|_]
25051 -> setarg(3, M, L)
25052 ; true
25053 )
25054 ; true
25055 )
25056 ),
25057 ai_not_observed(G, H),
25058 ( I=suspension(_, active, _)
25059 -> setarg(2, I, inactive),
25060 ai_observation_gather_results___0__1__0__2(N, I)
25061 ; true
25062 )
25063 ; ai_observation_gather_results___0__1__0__2(N, I)
25064 ).
25065ai_observation_gather_results___0__1(A) :-
25066 A=suspension(B, not_stored_yet, _),
25067 'chr gen_id'(B),
25068 ai_observation_gather_results___0__2(A).
25069ai_observation_gather_results___0__2(A) :-
25070 ( var(A)
25071 -> true
25072 ; arg(2, A, B),
25073 setarg(2, A, removed),
25074 ( B==not_stored_yet
25075 -> true
25076 ; arg(3, A, C),
25077 ( var(C)
25078 -> nb_getval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
25079 D),
25080 D=[_|E],
25081 b_setval('$chr_store_global_ground_chr_translate____ai_observation_gather_results___0',
25082 E),
25083 ( E=[F|_]
25084 -> setarg(3, F, _)
25085 ; true
25086 )
25087 ; C=[_, _|E],
25088 setarg(2, C, E),
25089 ( E=[F|_]
25090 -> setarg(3, F, C)
25091 ; true
25092 )
25093 )
25094 )
25095 ).
25096ai_observation_memo_simplification_rest_heads(B, C, F) :-
25097 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',
25098 A),
25099 lookup_ht(A, k(B, C), D),
25100 member(E, D),
25101 E=suspension(_, active, _, _, G), !,
25102 F=G.
25103ai_observation_memo_simplification_rest_heads(B, C, V) :-
25104 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
25105 A),
25106 lookup_ht(A, k(B, C), D),
25107 member(E, D),
25108 E=suspension(_, active, _, _, _, _, G, M, _),
25109 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', F),
25110 lookup_ht(F, G, H),
25111 member(I, H),
25112 I=suspension(_, active, _, _, _, L),
25113 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
25114 J),
25115 member(K, J),
25116 K=suspension(_, active, _, Q), !,
25117 L=pragma(rule(O, R, _, _), ids(N, _), _, _, _),
25118 once(select2(M, _, N, O, _, P)),
25119 ai_observation_abstract_constraints(P, Q, S),
25120 ai_observation_abstract_constraints(R, Q, T),
25121 append(S, T, U),
25122 sort(U, V),
25123 ai_observation_memoed_simplification_rest_heads(B,
25124 C,
25125 V).
25126ai_observation_memo_simplification_rest_heads(_, _, _) :-
25127 fail.
25128ai_observation_memoed_simplification_rest_heads(A, B, C) :-
25129 F=suspension(D, active, A, B, C),
25130 'chr gen_id'(D),
25131 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_simplification_rest_heads___3-12',
25132 E),
25133 insert_ht(E, k(A, B), F).
25134ai_observation_memo_propagation_rest_heads(B, C, F) :-
25135 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',
25136 A),
25137 lookup_ht(A, k(B, C), D),
25138 member(E, D),
25139 E=suspension(_, active, _, _, G), !,
25140 F=G.
25141ai_observation_memo_propagation_rest_heads(B, C, V) :-
25142 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
25143 A),
25144 lookup_ht(A, k(B, C), D),
25145 member(E, D),
25146 E=suspension(_, active, _, _, _, _, G, M, _),
25147 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', F),
25148 lookup_ht(F, G, H),
25149 member(I, H),
25150 I=suspension(_, active, _, _, _, L),
25151 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
25152 J),
25153 member(K, J),
25154 K=suspension(_, active, _, Q), !,
25155 L=pragma(rule(R, O, _, _), ids(_, N), _, _, _),
25156 once(select2(M, _, N, O, _, P)),
25157 ai_observation_abstract_constraints(P, Q, S),
25158 ai_observation_abstract_constraints(R, Q, T),
25159 append(S, T, U),
25160 sort(U, V),
25161 ai_observation_memoed_propagation_rest_heads(B, C, V).
25162ai_observation_memo_propagation_rest_heads(_, _, _) :-
25163 fail.
25164ai_observation_memoed_propagation_rest_heads(A, B, C) :-
25165 F=suspension(D, active, A, B, C),
25166 'chr gen_id'(D),
25167 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_propagation_rest_heads___3-12',
25168 E),
25169 insert_ht(E, k(A, B), F).
25170ai_observation_memoed_abstract_goal(A, B) :-
25171 E=suspension(C, active, A, B),
25172 'chr gen_id'(C),
25173 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',
25174 D),
25175 insert_ht(D, A, E).
25176ai_observation_memo_abstract_goal(B, E) :-
25177 nb_getval('$chr_store_multi_hash_chr_translate____ai_observation_memoed_abstract_goal___2-1',
25178 A),
25179 lookup_ht(A, B, C),
25180 member(D, C),
25181 D=suspension(_, active, _, F), !,
25182 E=F.
25183ai_observation_memo_abstract_goal(B, M) :-
25184 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1', A),
25185 lookup_ht(A, B, C),
25186 member(D, C),
25187 D=suspension(_, active, _, _, _, G),
25188 nb_getval('$chr_store_global_ground_chr_translate____abstract_constraints___1',
25189 E),
25190 member(F, E),
25191 F=suspension(_, active, _, L), !,
25192 G=pragma(rule(H, I, J, K), _, _, _, _),
25193 ai_observation_abstract_goal_(H,
25194 I,
25195 J,
25196 K,
25197 L,
25198 N),
25199 M=N,
25200 ai_observation_memoed_abstract_goal(B, N).
25201ai_observation_memo_abstract_goal(A, B) :-
25202 D=suspension(C, active, _, A, B),
25203 'chr gen_id'(C),
25204 nb_getval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',
25205 E),
25206 F=[D|E],
25207 b_setval('$chr_store_global_ground_chr_translate____ai_observation_memo_abstract_goal___2',
25208 F),
25209 ( E=[G|_]
25210 -> setarg(3, G, F)
25211 ; true
25212 ).
25213partial_wake_analysis :-
25214 partial_wake_analysis___0__0(_).
25215partial_wake_analysis___0__0(A) :-
25216 nb_getval('$chr_store_global_ground_chr_translate____occurrence___5',
25217 C), !,
25218 A=suspension(B, not_stored_yet, t, _),
25219 'chr gen_id'(B),
25220 partial_wake_analysis___0__0__0__1(C, A).
25221partial_wake_analysis___0__0__0__1([], A) :-
25222 partial_wake_analysis___0__1(A).
25223partial_wake_analysis___0__0__0__1([A|H], I) :-
25224 ( A=suspension(_, active, _, _, C, _, E, F, G),
25225 nb_getval('$chr_store_multi_hash_chr_translate____constraint_mode___2-1',
25226 B),
25227 lookup_ht(B, C, D)
25228 -> partial_wake_analysis___0__0__1__1(D,
25229 C,
25230 E,
25231 F,
25232 G,
25233 A,
25234 H,
25235 I)
25236 ; partial_wake_analysis___0__0__0__1(H, I)
25237 ).
25238partial_wake_analysis___0__0__1__1([], _, _, _, _, _, A, B) :-
25239 partial_wake_analysis___0__0__0__1(A, B).
25240partial_wake_analysis___0__0__1__1([A|H], C, E, I, J, K, L, M) :-
25241 ( ( A=suspension(_, active, _, _, B, G),
25242 B==C
25243 ),
25244 nb_getval('$chr_store_multi_hash_chr_translate____rule___2-1',
25245 D),
25246 lookup_ht(D, E, F)
25247 -> partial_wake_analysis___0__0__2__1(F,
25248 G,
25249 A,
25250 H,
25251 C,
25252 E,
25253 I,
25254 J,
25255 K,
25256 L,
25257 M)
25258 ; partial_wake_analysis___0__0__1__1(H,
25259 C,
25260 E,
25261 I,
25262 J,
25263 K,
25264 L,
25265 M)
25266 ).
25267partial_wake_analysis___0__0__2__1([], _, _, A, B, C, D, E, F, G, H) :-
25268 partial_wake_analysis___0__0__1__1(A,
25269 B,
25270 C,
25271 D,
25272 E,
25273 F,
25274 G,
25275 H).
25276partial_wake_analysis___0__0__2__1([A|W], S, F, X, U, C, M, N, E, Y, D) :-
25277 ( A=suspension(_, active, _, _, B, L),
25278 B==C,
25279 G=t(330, D, E, A, F),
25280 '$novel_production'(D, G),
25281 '$novel_production'(E, G),
25282 '$novel_production'(A, G),
25283 '$novel_production'(F, G)
25284 -> '$extend_history'(D, G),
25285 ( arg(2, D, H),
25286 setarg(2, D, active),
25287 ( H==not_stored_yet
25288 -> nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
25289 I),
25290 J=[D|I],
25291 b_setval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
25292 J),
25293 ( I=[K|_]
25294 -> setarg(4, K, J)
25295 ; true
25296 )
25297 ; true
25298 )
25299 ),
25300 ( L=pragma(rule(O, V, Q, _), _, _, _, _),
25301 ( is_passive(C, M)
25302 -> true
25303 ; N==simplification
25304 -> select(P, O, _),
25305 P=..[_|R],
25306 term_variables(Q, T),
25307 partial_wake_args(R, S, T, U)
25308 ; select(P, V, _),
25309 P=..[_|R],
25310 term_variables(Q, T),
25311 partial_wake_args(R, S, T, U)
25312 )
25313 ),
25314 ( D=suspension(_, active, _, _)
25315 -> setarg(2, D, inactive),
25316 partial_wake_analysis___0__0__2__1(W,
25317 S,
25318 F,
25319 X,
25320 U,
25321 C,
25322 M,
25323 N,
25324 E,
25325 Y,
25326 D)
25327 ; true
25328 )
25329 ; partial_wake_analysis___0__0__2__1(W,
25330 S,
25331 F,
25332 X,
25333 U,
25334 C,
25335 M,
25336 N,
25337 E,
25338 Y,
25339 D)
25340 ).
25341partial_wake_analysis___0__0(A) :-
25342 A=suspension(B, not_stored_yet, t, _),
25343 'chr gen_id'(B),
25344 partial_wake_analysis___0__1(A).
25345partial_wake_analysis___0__1(A) :-
25346 arg(2, A, B),
25347 setarg(2, A, active),
25348 ( B==not_stored_yet
25349 -> nb_getval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
25350 C),
25351 D=[A|C],
25352 b_setval('$chr_store_global_ground_chr_translate____partial_wake_analysis___0',
25353 D),
25354 ( C=[E|_]
25355 -> setarg(4, E, D)
25356 ; true
25357 )
25358 ; true
25359 ).
25360no_partial_wake(B) :-
25361 nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',
25362 A),
25363 lookup_ht(A, B, C),
25364 member(D, C),
25365 D=suspension(_, active, _), !.
25366no_partial_wake(A) :-
25367 D=suspension(B, active, A),
25368 'chr gen_id'(B),
25369 nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',
25370 C),
25371 insert_ht(C, A, D).
25372wakes_partially(B) :-
25373 nb_getval('$chr_store_multi_hash_chr_translate____no_partial_wake___1-1',
25374 A),
25375 lookup_ht(A, B, C),
25376 member(D, C),
25377 D=suspension(_, active, _), !,
25378 fail.
25379wakes_partially(_).
25380phase_end(A) :-
25381 phase_end___1__0(A, _).
25382phase_end___1__0(B, C) :-
25383 nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',
25384 A),
25385 lookup_ht(A, B, E), !,
25386 C=suspension(D, not_stored_yet, B),
25387 'chr gen_id'(D),
25388 phase_end___1__0__0__1(E, B, C).
25389phase_end___1__0__0__1([], A, B) :-
25390 phase_end___1__1(A, B).
25391phase_end___1__0__0__1([A|I], C, E) :-
25392 ( A=suspension(_, active, B, H),
25393 B==C
25394 -> ( setarg(2, A, removed),
25395 nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',
25396 D),
25397 delete_ht(D, C, A)
25398 ),
25399 ( arg(2, E, F),
25400 setarg(2, E, active),
25401 ( F==not_stored_yet
25402 -> nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',
25403 G),
25404 insert_ht(G, C, E)
25405 ; true
25406 )
25407 ),
25408 call(H),
25409 ( E=suspension(_, active, _)
25410 -> setarg(2, E, inactive),
25411 phase_end___1__0__0__1(I, C, E)
25412 ; true
25413 )
25414 ; phase_end___1__0__0__1(I, C, E)
25415 ).
25416phase_end___1__0(B, A) :-
25417 A=suspension(C, not_stored_yet, B),
25418 'chr gen_id'(C),
25419 phase_end___1__1(B, A).
25420phase_end___1__1(D, A) :-
25421 arg(2, A, B),
25422 setarg(2, A, active),
25423 ( B==not_stored_yet
25424 -> nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',
25425 C),
25426 insert_ht(C, D, A)
25427 ; true
25428 ).
25429delay_phase_end(B, E) :-
25430 nb_getval('$chr_store_multi_hash_chr_translate____phase_end___1-1',
25431 A),
25432 lookup_ht(A, B, C),
25433 member(D, C),
25434 D=suspension(_, active, _), !,
25435 call(E).
25436delay_phase_end(A, B) :-
25437 E=suspension(C, active, A, B),
25438 'chr gen_id'(C),
25439 nb_getval('$chr_store_multi_hash_chr_translate____delay_phase_end___2-1',
25440 D),
25441 insert_ht(D, A, E).
25442does_use_history(B, C) :-
25443 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',
25444 A),
25445 lookup_ht(A, k(B, C), D),
25446 member(E, D),
25447 E=suspension(_, active, _, _), !.
25448does_use_history(A, B) :-
25449 E=suspension(C, active, A, B),
25450 'chr gen_id'(C),
25451 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',
25452 D),
25453 insert_ht(D, A, E),
25454 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',
25455 F),
25456 insert_ht(F, k(A, B), E).
25457uses_history(B) :-
25458 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-1',
25459 A),
25460 lookup_ht(A, B, C),
25461 member(D, C),
25462 D=suspension(_, active, _, _), !.
25463uses_history(_) :-
25464 fail.
25465novel_production_call(B, C, G, F) :-
25466 nb_getval('$chr_store_multi_hash_chr_translate____does_use_history___2-12',
25467 A),
25468 lookup_ht(A, k(B, C), D),
25469 member(E, D),
25470 E=suspension(_, active, _, _), !,
25471 F=G.
25472novel_production_call(_, _, _, true).
25473does_use_field(B, C) :-
25474 nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',
25475 A),
25476 lookup_ht(A, k(B, C), D),
25477 member(E, D),
25478 E=suspension(_, active, _, _), !.
25479does_use_field(A, B) :-
25480 E=suspension(C, active, A, B),
25481 'chr gen_id'(C),
25482 nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',
25483 D),
25484 insert_ht(D, k(A, B), E).
25485uses_field(B, C) :-
25486 nb_getval('$chr_store_multi_hash_chr_translate____does_use_field___2-12',
25487 A),
25488 lookup_ht(A, k(B, C), D),
25489 member(E, D),
25490 E=suspension(_, active, _, _), !.
25491uses_field(_, _) :-
25492 fail.
25493uses_state(A, B) :-
25494 uses_state___2__0(A, B, _).
25495uses_state___2__0(B, C, _) :-
25496 nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
25497 A),
25498 lookup_ht(A, k(B, C), D),
25499 member(E, D),
25500 E=suspension(_, active, _, _), !.
25501uses_state___2__0(B, C, A) :-
25502 nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',
25503 E), !,
25504 A=suspension(D, not_stored_yet, B, C),
25505 'chr gen_id'(D),
25506 uses_state___2__0__0__3(E, B, C, A).
25507uses_state___2__0__0__3([], A, B, C) :-
25508 uses_state___2__1(A, B, C).
25509uses_state___2__0__0__3([A|F], C, D, G) :-
25510 ( A=suspension(_, active, _),
25511 nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
25512 B),
25513 lookup_ht(B, k(C, D), E)
25514 -> uses_state___2__0__1__3(E,
25515 A,
25516 F,
25517 C,
25518 D,
25519 G)
25520 ; uses_state___2__0__0__3(F, C, D, G)
25521 ).
25522uses_state___2__0__1__3([], _, A, B, C, D) :-
25523 uses_state___2__0__0__3(A, B, C, D).
25524uses_state___2__0__1__3([A|P], Q, R, C, E, K) :-
25525 ( A=suspension(_, active, _, B, D, O, _, N),
25526 B==C,
25527 D==E
25528 -> ( setarg(2, A, removed),
25529 ( arg(3, A, F),
25530 ( var(F)
25531 -> nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
25532 G),
25533 G=[_|H],
25534 b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',
25535 H),
25536 ( H=[I|_]
25537 -> setarg(3, I, _)
25538 ; true
25539 )
25540 ; F=[_, _|H],
25541 setarg(2, F, H),
25542 ( H=[I|_]
25543 -> setarg(3, I, F)
25544 ; true
25545 )
25546 )
25547 ),
25548 nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
25549 J),
25550 delete_ht(J, k(C, E), A)
25551 ),
25552 ( arg(2, K, L),
25553 setarg(2, K, active),
25554 ( L==not_stored_yet
25555 -> nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
25556 M),
25557 insert_ht(M, k(C, E), K)
25558 ; true
25559 )
25560 ),
25561 N=O,
25562 ( K=suspension(_, active, _, _)
25563 -> setarg(2, K, inactive),
25564 uses_state___2__0__1__3(P,
25565 Q,
25566 R,
25567 C,
25568 E,
25569 K)
25570 ; true
25571 )
25572 ; uses_state___2__0__1__3(P,
25573 Q,
25574 R,
25575 C,
25576 E,
25577 K)
25578 ).
25579uses_state___2__0(B, C, A) :-
25580 A=suspension(D, not_stored_yet, B, C),
25581 'chr gen_id'(D),
25582 uses_state___2__1(B, C, A).
25583uses_state___2__1(D, E, A) :-
25584 arg(2, A, B),
25585 setarg(2, A, active),
25586 ( B==not_stored_yet
25587 -> nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
25588 C),
25589 insert_ht(C, k(D, E), A)
25590 ; true
25591 ).
25592if_used_state(D, E, I, J, H) :-
25593 ( nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',
25594 A),
25595 member(B, A),
25596 B=suspension(_, active, _)
25597 ),
25598 ( nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
25599 C),
25600 lookup_ht(C, k(D, E), F),
25601 member(G, F),
25602 G=suspension(_, active, _, _), !,
25603 H=I
25604 ; !,
25605 H=J
25606 ).
25607if_used_state(A, B, C, D, E) :-
25608 G=suspension(F, active, _, A, B, C, D, E),
25609 'chr gen_id'(F),
25610 nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
25611 H),
25612 I=[G|H],
25613 b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',
25614 I),
25615 ( H=[J|_]
25616 -> setarg(3, J, I)
25617 ; true
25618 ),
25619 nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
25620 K),
25621 insert_ht(K, k(A, B), G).
25622used_states_known :-
25623 used_states_known___0__0(_).
25624used_states_known___0__0(A) :-
25625 nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
25626 C), !,
25627 A=suspension(B, not_stored_yet, _),
25628 'chr gen_id'(B),
25629 used_states_known___0__0__0__1(C, A).
25630used_states_known___0__0__0__1([], A) :-
25631 used_states_known___0__1(A).
25632used_states_known___0__0__0__1([A|S], L) :-
25633 ( A=suspension(_, active, _, B, C, R, _, Q),
25634 ( ( ground(B),
25635 ground(C)
25636 ),
25637 nb_getval('$chr_store_multi_hash_chr_translate____uses_state___2-12',
25638 D),
25639 lookup_ht(D, k(B, C), E)
25640 ),
25641 member(F, E),
25642 F=suspension(_, active, _, _)
25643 -> ( setarg(2, A, removed),
25644 ( arg(3, A, G),
25645 ( var(G)
25646 -> nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
25647 H),
25648 H=[_|I],
25649 b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',
25650 I),
25651 ( I=[J|_]
25652 -> setarg(3, J, _)
25653 ; true
25654 )
25655 ; G=[_, _|I],
25656 setarg(2, G, I),
25657 ( I=[J|_]
25658 -> setarg(3, J, G)
25659 ; true
25660 )
25661 )
25662 ),
25663 nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
25664 K),
25665 delete_ht(K, k(B, C), A)
25666 ),
25667 ( arg(2, L, M),
25668 setarg(2, L, active),
25669 ( M==not_stored_yet
25670 -> nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',
25671 N),
25672 O=[L|N],
25673 b_setval('$chr_store_global_ground_chr_translate____used_states_known___0',
25674 O),
25675 ( N=[P|_]
25676 -> setarg(3, P, O)
25677 ; true
25678 )
25679 ; true
25680 )
25681 ),
25682 Q=R,
25683 ( L=suspension(_, active, _)
25684 -> setarg(2, L, inactive),
25685 used_states_known___0__0__0__1(S, L)
25686 ; true
25687 )
25688 ; used_states_known___0__0__0__1(S, L)
25689 ).
25690used_states_known___0__0(A) :-
25691 A=suspension(B, not_stored_yet, _),
25692 'chr gen_id'(B),
25693 used_states_known___0__1(A).
25694used_states_known___0__1(B) :-
25695 nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
25696 A), !,
25697 used_states_known___0__1__0__2(A, B).
25698used_states_known___0__1__0__2([], A) :-
25699 used_states_known___0__2(A).
25700used_states_known___0__1__0__2([A|P], I) :-
25701 ( A=suspension(_, active, _, G, H, _, O, N)
25702 -> ( setarg(2, A, removed),
25703 ( arg(3, A, B),
25704 ( var(B)
25705 -> nb_getval('$chr_store_global_ground_chr_translate____if_used_state___5',
25706 C),
25707 C=[_|D],
25708 b_setval('$chr_store_global_ground_chr_translate____if_used_state___5',
25709 D),
25710 ( D=[E|_]
25711 -> setarg(3, E, _)
25712 ; true
25713 )
25714 ; B=[_, _|D],
25715 setarg(2, B, D),
25716 ( D=[E|_]
25717 -> setarg(3, E, B)
25718 ; true
25719 )
25720 )
25721 ),
25722 nb_getval('$chr_store_multi_hash_chr_translate____if_used_state___5-12',
25723 F),
25724 delete_ht(F, k(G, H), A)
25725 ),
25726 ( arg(2, I, J),
25727 setarg(2, I, active),
25728 ( J==not_stored_yet
25729 -> nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',
25730 K),
25731 L=[I|K],
25732 b_setval('$chr_store_global_ground_chr_translate____used_states_known___0',
25733 L),
25734 ( K=[M|_]
25735 -> setarg(3, M, L)
25736 ; true
25737 )
25738 ; true
25739 )
25740 ),
25741 N=O,
25742 ( I=suspension(_, active, _)
25743 -> setarg(2, I, inactive),
25744 used_states_known___0__1__0__2(P, I)
25745 ; true
25746 )
25747 ; used_states_known___0__1__0__2(P, I)
25748 ).
25749used_states_known___0__1(A) :-
25750 used_states_known___0__2(A).
25751used_states_known___0__2(A) :-
25752 arg(2, A, B),
25753 setarg(2, A, active),
25754 ( B==not_stored_yet
25755 -> nb_getval('$chr_store_global_ground_chr_translate____used_states_known___0',
25756 C),
25757 D=[A|C],
25758 b_setval('$chr_store_global_ground_chr_translate____used_states_known___0',
25759 D),
25760 ( C=[E|_]
25761 -> setarg(3, E, D)
25762 ; true
25763 )
25764 ; true
25765 ).
25766stored_assertion(A) :-
25767 D=suspension(B, active, A),
25768 'chr gen_id'(B),
25769 nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',
25770 C),
25771 insert_ht(C, A, D).
25772never_stored_default(A, B) :-
25773 never_stored_default___2__0(A, B, _).
25774never_stored_default___2__0(B, C, A) :-
25775 nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
25776 E), !,
25777 A=suspension(D, not_stored_yet, B, C),
25778 'chr gen_id'(D),
25779 never_stored_default___2__0__0__1(E, B, C, A).
25780never_stored_default___2__0__0__1([], A, B, C) :-
25781 never_stored_default___2__1(A, B, C).
25782never_stored_default___2__0__0__1([A|U], D, O, I) :-
25783 ( A=suspension(_, active, _, B, Q),
25784 B=[C|S],
25785 C==D
25786 -> ( setarg(2, A, removed),
25787 arg(3, A, E),
25788 ( var(E)
25789 -> nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
25790 F),
25791 F=[_|G],
25792 b_setval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
25793 G),
25794 ( G=[H|_]
25795 -> setarg(3, H, _)
25796 ; true
25797 )
25798 ; E=[_, _|G],
25799 setarg(2, E, G),
25800 ( G=[H|_]
25801 -> setarg(3, H, E)
25802 ; true
25803 )
25804 )
25805 ),
25806 ( arg(2, I, J),
25807 setarg(2, I, active),
25808 ( J==not_stored_yet
25809 -> nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
25810 K),
25811 insert_ht(K, D, I)
25812 ; true
25813 )
25814 ),
25815 ( D=L/M,
25816 functor(N, L, M),
25817 inc_rule_count(P),
25818 R=pragma(rule([N], [], true, O), ids([0], []), [], no, P),
25819 Q=[R|T],
25820 never_stored_rules(S, T)
25821 ),
25822 ( I=suspension(_, active, _, _)
25823 -> setarg(2, I, inactive),
25824 never_stored_default___2__0__0__1(U,
25825 D,
25826 O,
25827 I)
25828 ; true
25829 )
25830 ; never_stored_default___2__0__0__1(U,
25831 D,
25832 O,
25833 I)
25834 ).
25835never_stored_default___2__0(B, C, A) :-
25836 A=suspension(D, not_stored_yet, B, C),
25837 'chr gen_id'(D),
25838 never_stored_default___2__1(B, C, A).
25839never_stored_default___2__1(D, _, A) :-
25840 arg(2, A, B),
25841 setarg(2, A, active),
25842 ( B==not_stored_yet
25843 -> nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
25844 C),
25845 insert_ht(C, D, A)
25846 ; true
25847 ).
25848never_stored_rules([], A) :- !,
25849 A=[].
25850never_stored_rules([B|L], J) :-
25851 nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
25852 A),
25853 lookup_ht(A, B, C),
25854 member(D, C),
25855 D=suspension(_, active, _, H), !,
25856 B=E/F,
25857 functor(G, E, F),
25858 inc_rule_count(I),
25859 K=pragma(rule([G], [], true, H), ids([0], []), [], no, I),
25860 J=[K|M],
25861 never_stored_rules(L, M).
25862never_stored_rules([_|A], B) :- !,
25863 never_stored_rules(A, B).
25864never_stored_rules(A, B) :-
25865 D=suspension(C, active, _, A, B),
25866 'chr gen_id'(C),
25867 nb_getval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
25868 E),
25869 F=[D|E],
25870 b_setval('$chr_store_global_ground_chr_translate____never_stored_rules___2',
25871 F),
25872 ( E=[G|_]
25873 -> setarg(3, G, F)
25874 ; true
25875 ).
25876check_storedness_assertion(B) :-
25877 nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',
25878 A),
25879 lookup_ht(A, B, C),
25880 member(D, C),
25881 D=suspension(_, active, _), !,
25882 setarg(2, D, removed),
25883 nb_getval('$chr_store_multi_hash_chr_translate____stored_assertion___1-1',
25884 E),
25885 delete_ht(E, B, D),
25886 ( is_stored(B)
25887 -> true
25888 ; chr_warning(assertion_failed,
25889 'Constraint ~w is not stored. However, it was asserted to be stored.\n',
25890 [B])
25891 ).
25892check_storedness_assertion(B) :-
25893 nb_getval('$chr_store_multi_hash_chr_translate____never_stored_default___2-1',
25894 A),
25895 lookup_ht(A, B, C),
25896 member(D, C),
25897 D=suspension(_, active, _, _), !,
25898 ( is_finally_stored(B)
25899 -> chr_warning(assertion_failed,
25900 'Constraint ~w is stored. However, it was asserted not to be stored.\n',
25901 [B])
25902 ; is_stored(B)
25903 -> chr_warning(assertion_failed,
25904 'Constraint ~w is temporarily stored. However, it was asserted not to be stored.\n',
25905 [B])
25906 ; true
25907 ).
25908check_storedness_assertion(A) :-
25909 ( is_finally_stored(A)
25910 -> chr_warning(assertion_failed,
25911 'Constraint ~w is stored. However, it was asserted not to be stored.\n',
25912 [A])
25913 ; is_stored(A)
25914 -> chr_warning(assertion_failed,
25915 'Constraint ~w is temporarily stored. However, it was asserted not to be stored.\n',
25916 [A])
25917 ; true
25918 ).
25919continuation_occurrence(A, B, C) :-
25920 F=suspension(D, active, A, B, C),
25921 'chr gen_id'(D),
25922 nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',
25923 E),
25924 insert_ht(E, k(A, B), F).
25925get_success_continuation_occurrence(B, C, F) :-
25926 nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',
25927 A),
25928 lookup_ht(A, k(B, C), D),
25929 member(E, D),
25930 E=suspension(_, active, _, _, G), !,
25931 F=G.
25932get_success_continuation_occurrence(A, B, _) :-
25933 chr_error(internal,
25934 'Success continuation not found for ~w.\n',
25935 [A:B]).
25936skip_to_next_id(A, B) :-
25937 skip_to_next_id___2__0(A, B, _).
25938skip_to_next_id___2__0(B, C, _) :-
25939 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
25940 A),
25941 lookup_ht(A, k(B, C), D),
25942 member(E, D),
25943 E=suspension(_, active, _, _, _), !.
25944skip_to_next_id___2__0(B, C, D) :-
25945 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
25946 A),
25947 lookup_ht(A, k(B, C), F), !,
25948 D=suspension(E, not_stored_yet, t, B, C),
25949 'chr gen_id'(E),
25950 skip_to_next_id___2__0__0__4(F, B, C, D).
25951skip_to_next_id___2__0__0__4([], A, B, C) :-
25952 skip_to_next_id___2__1(A, B, C).
25953skip_to_next_id___2__0__0__4([A|J], C, E, K) :-
25954 ( ( A=suspension(_, active, _, _, B, D, G, H, _),
25955 B==C,
25956 D==E
25957 ),
25958 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
25959 F),
25960 lookup_ht(F, k(G, H), I)
25961 -> skip_to_next_id___2__0__1__4(I,
25962 G,
25963 H,
25964 A,
25965 J,
25966 C,
25967 E,
25968 K)
25969 ; skip_to_next_id___2__0__0__4(J, C, E, K)
25970 ).
25971skip_to_next_id___2__0__1__4([], _, _, _, A, B, C, D) :-
25972 skip_to_next_id___2__0__0__4(A, B, C, D).
25973skip_to_next_id___2__0__1__4([A|N], C, E, F, O, L, I, G) :-
25974 ( A=suspension(_, active, _, B, D),
25975 ( B==C,
25976 D==E
25977 ),
25978 ( H=t(362, F, A, G),
25979 '$novel_production'(F, H),
25980 '$novel_production'(A, H),
25981 '$novel_production'(G, H)
25982 ),
25983 I>1
25984 -> '$extend_history'(G, H),
25985 ( arg(2, G, J),
25986 setarg(2, G, active),
25987 ( J==not_stored_yet
25988 -> nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
25989 K),
25990 insert_ht(K, k(L, I), G)
25991 ; true
25992 )
25993 ),
25994 ( M is I-1,
25995 skip_to_next_id(L, M)
25996 ),
25997 ( G=suspension(_, active, _, _, _)
25998 -> setarg(2, G, inactive),
25999 skip_to_next_id___2__0__1__4(N,
26000 C,
26001 E,
26002 F,
26003 O,
26004 L,
26005 I,
26006 G)
26007 ; true
26008 )
26009 ; skip_to_next_id___2__0__1__4(N,
26010 C,
26011 E,
26012 F,
26013 O,
26014 L,
26015 I,
26016 G)
26017 ).
26018skip_to_next_id___2__0(B, C, A) :-
26019 A=suspension(D, not_stored_yet, t, B, C),
26020 'chr gen_id'(D),
26021 skip_to_next_id___2__1(B, C, A).
26022skip_to_next_id___2__1(B, C, E) :-
26023 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
26024 A),
26025 lookup_ht(A, k(B, C), D), !,
26026 skip_to_next_id___2__1__0__5(D, B, C, E).
26027skip_to_next_id___2__1__0__5([], A, B, C) :-
26028 skip_to_next_id___2__2(A, B, C).
26029skip_to_next_id___2__1__0__5([A|P], C, E, J) :-
26030 ( ( A=suspension(_, active, B, D, M),
26031 B==C,
26032 D==E
26033 ),
26034 ( ( ground(C),
26035 ground(E)
26036 ),
26037 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
26038 F),
26039 lookup_ht(F, k(C, E, propagation), G)
26040 ),
26041 member(H, G),
26042 H=suspension(_, active, _, _, _, _, _, _, _)
26043 -> ( setarg(2, A, removed),
26044 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
26045 I),
26046 delete_ht(I, k(C, E), A)
26047 ),
26048 ( arg(2, J, K),
26049 setarg(2, J, active),
26050 ( K==not_stored_yet
26051 -> nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
26052 L),
26053 insert_ht(L, k(C, E), J)
26054 ; true
26055 )
26056 ),
26057 ( occurrence_code_id(C, E, M),
26058 N is E+1,
26059 O is M+1,
26060 set_occurrence_code_id(C, N, O)
26061 ),
26062 ( J=suspension(_, active, _, _, _)
26063 -> setarg(2, J, inactive),
26064 skip_to_next_id___2__1__0__5(P, C, E, J)
26065 ; true
26066 )
26067 ; skip_to_next_id___2__1__0__5(P, C, E, J)
26068 ).
26069skip_to_next_id___2__1(A, B, C) :-
26070 skip_to_next_id___2__2(A, B, C).
26071skip_to_next_id___2__2(D, E, A) :-
26072 arg(2, A, B),
26073 setarg(2, A, active),
26074 ( B==not_stored_yet
26075 -> nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
26076 C),
26077 insert_ht(C, k(D, E), A)
26078 ; true
26079 ).
26080should_skip_to_next_id(B, C) :-
26081 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
26082 A),
26083 lookup_ht(A, k(B, C), D),
26084 member(E, D),
26085 E=suspension(_, active, _, _, _), !.
26086should_skip_to_next_id(_, _) :-
26087 fail.
26088bulk_propagation(B, E, _) :-
26089 nb_getval('$chr_store_multi_hash_chr_translate____max_occurrence___2-1',
26090 A),
26091 lookup_ht(A, B, C),
26092 member(D, C),
26093 D=suspension(_, active, _, _, F),
26094 E>=F, !,
26095 skip_to_next_id(B, E).
26096bulk_propagation(C, B, A) :-
26097 A=:=B+1, !,
26098 skip_to_next_id(C, B),
26099 get_max_occurrence(C, D),
26100 E is D+1,
26101 bulk_propagation(C, A, E).
26102bulk_propagation(B, F, _) :-
26103 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-15',
26104 A),
26105 lookup_ht(A, k(B, simplification), C),
26106 member(D, C),
26107 D=suspension(_, active, _, _, _, E, _, _, _),
26108 E=:=F+1, !,
26109 skip_to_next_id(B, F),
26110 get_max_occurrence(B, G),
26111 H is G+1,
26112 bulk_propagation(B, E, H).
26113bulk_propagation(B, C, G) :-
26114 nb_getval('$chr_store_multi_hash_chr_translate____continuation_occurrence___3-12',
26115 A),
26116 lookup_ht(A, k(B, C), D),
26117 member(E, D),
26118 E=suspension(_, active, _, _, F),
26119 F>C+1, !,
26120 I is min(G, F),
26121 H is C+1,
26122 bulk_propagation(B, H, I).
26123bulk_propagation(A, B, _) :-
26124 skip_to_next_id(A, B),
26125 get_max_occurrence(A, C),
26126 E is C+1,
26127 D is B+1,
26128 bulk_propagation(A, D, E).
26129set_occurrence_code_id(A, B, D) :-
26130 get_max_occurrence(A, C),
26131 B>C, !,
26132 occurrence_code_id(A, B, D).
26133set_occurrence_code_id(B, C, K) :-
26134 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-12',
26135 A),
26136 lookup_ht(A, k(B, C), D),
26137 member(E, D),
26138 E=suspension(_, active, _, _, _, _, G, H, _),
26139 nb_getval('$chr_store_multi_hash_chr_translate____passive___2-12',
26140 F),
26141 lookup_ht(F, k(G, H), I),
26142 member(J, I),
26143 J=suspension(_, active, _, _, _), !,
26144 occurrence_code_id(B, C, K),
26145 L is C+1,
26146 set_occurrence_code_id(B, L, K).
26147set_occurrence_code_id(B, C, F) :-
26148 nb_getval('$chr_store_multi_hash_chr_translate____occurrence___5-125',
26149 A),
26150 ( ( lookup_ht(A, k(B, C, simplification), D),
26151 member(E, D),
26152 E=suspension(_, active, _, _, _, _, _, _, _), !,
26153 occurrence_code_id(B, C, F),
26154 G is C+1,
26155 set_occurrence_code_id(B, G, F)
26156 ; lookup_ht(A, k(B, C, propagation), H),
26157 member(I, H),
26158 I=suspension(_, active, _, _, _, _, _, _, _),
26159 nb_getval('$chr_store_multi_hash_chr_translate____skip_to_next_id___2-12',
26160 J),
26161 lookup_ht(J, k(B, C), K),
26162 member(L, K),
26163 L=suspension(_, active, _, _, _), !,
26164 occurrence_code_id(B, C, F),
26165 M is C+1,
26166 N is F+1,
26167 set_occurrence_code_id(B, M, N)
26168 )
26169 ; lookup_ht(A, k(B, C, propagation), O),
26170 member(P, O),
26171 P=suspension(_, active, _, _, _, _, _, _, _), !,
26172 occurrence_code_id(B, C, F),
26173 Q is C+1,
26174 set_occurrence_code_id(B, Q, F)
26175 ).
26176set_occurrence_code_id(A, B, C) :-
26177 F=suspension(D, active, A, B, C),
26178 'chr gen_id'(D),
26179 nb_getval('$chr_store_multi_hash_chr_translate____set_occurrence_code_id___3-12',
26180 E),
26181 insert_ht(E, k(A, B), F).
26182occurrence_code_id(A, B, C) :-
26183 F=suspension(D, active, A, B, C),
26184 'chr gen_id'(D),
26185 nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',
26186 E),
26187 insert_ht(E, k(A, B), F).
26188get_occurrence_code_id(B, C, F) :-
26189 nb_getval('$chr_store_multi_hash_chr_translate____occurrence_code_id___3-12',
26190 A),
26191 lookup_ht(A, k(B, C), D),
26192 member(E, D),
26193 E=suspension(_, active, _, _, G), !,
26194 F=G.
26195get_occurrence_code_id(B, A, _) :-
26196 ( A==0
26197 -> true
26198 ; format('no occurrence code for ~w!\n', [B:A])
26199 ).
26200chr_constants(A) :-
26201 C=suspension(B, active, _, A),
26202 'chr gen_id'(B),
26203 nb_getval('$chr_store_global_ground_chr_translate____chr_constants___1',
26204 D),
26205 E=[C|D],
26206 b_setval('$chr_store_global_ground_chr_translate____chr_constants___1',
26207 E),
26208 ( D=[F|_]
26209 -> setarg(3, F, E)
26210 ; true
26211 ).
26212get_chr_constants(C) :-
26213 nb_getval('$chr_store_global_ground_chr_translate____chr_constants___1',
26214 A),
26215 member(B, A),
26216 B=suspension(_, active, _, D), !,
26217 C=D.
26218get_chr_constants(A) :-
26219 chr_warning(internal, 'No constants found for key ~w.\n', [_]),
26220 A=[].
26221add_chr_constants_(G) :-
26222 nb_getval('$chr_store_global_ground_chr_translate____chr_constants___1',
26223 A),
26224 member(B, A),
26225 B=suspension(_, active, _, H), !,
26226 setarg(2, B, removed),
26227 arg(3, B, C),
26228 ( var(C)
26229 -> nb_getval('$chr_store_global_ground_chr_translate____chr_constants___1',
26230 D),
26231 D=[_|E],
26232 b_setval('$chr_store_global_ground_chr_translate____chr_constants___1',
26233 E),
26234 ( E=[F|_]
26235 -> setarg(3, F, _)
26236 ; true
26237 )
26238 ; C=[_, _|E],
26239 setarg(2, C, E),
26240 ( E=[F|_]
26241 -> setarg(3, F, C)
26242 ; true
26243 )
26244 ),
26245 sort([G|H], I),
26246 chr_constants(I).
26247add_chr_constants_(A) :-
26248 chr_constants([A]).
26249print_chr_constants :-
26250 print_chr_constants___0__0(_).
26251print_chr_constants___0__0(A) :-
26252 nb_getval('$chr_store_global_ground_chr_translate____chr_constants___1',
26253 C), !,
26254 A=suspension(B, not_stored_yet, _),
26255 'chr gen_id'(B),
26256 print_chr_constants___0__0__0__1(C, A).
26257print_chr_constants___0__0__0__1([], A) :-
26258 print_chr_constants___0__1(A).
26259print_chr_constants___0__0__0__1([A|C], D) :-
26260 ( A=suspension(_, active, _, B)
26261 -> format('\t* chr_constants : ~w.\n', [B]),
26262 print_chr_constants___0__0__0__1(C, D)
26263 ; print_chr_constants___0__0__0__1(C, D)
26264 ).
26265print_chr_constants___0__0(A) :-
26266 A=suspension(B, not_stored_yet, _),
26267 'chr gen_id'(B),
26268 print_chr_constants___0__1(A).
26269print_chr_constants___0__1(A) :-
26270 ( var(A)
26271 -> true
26272 ; arg(2, A, B),
26273 setarg(2, A, removed),
26274 ( B==not_stored_yet
26275 -> true
26276 ; arg(3, A, C),
26277 ( var(C)
26278 -> nb_getval('$chr_store_global_ground_chr_translate____print_chr_constants___0',
26279 D),
26280 D=[_|E],
26281 b_setval('$chr_store_global_ground_chr_translate____print_chr_constants___0',
26282 E),
26283 ( E=[F|_]
26284 -> setarg(3, F, _)
26285 ; true
26286 )
26287 ; C=[_, _|E],
26288 setarg(2, C, E),
26289 ( E=[F|_]
26290 -> setarg(3, F, C)
26291 ; true
26292 )
26293 )
26294 )
26295 )