1 /* Generated by CHR bootstrap compiler
2 From
: chr_translate_bootstrap2
.chr
3 Date
: Wed Jan
19 10:16:37 2005
5 DO NOT EDIT
. EDIT THE CHR FILE INSTEAD
8 :-module
(chr_translate
, [chr_translate
/2]).
9 :-use_module
(chr_runtime
).
10 :-style_check
(-singleton
).
11 :-style_check
(- (discontiguous
)).
12 :-use_module
(chr_runtime
).
13 :-use_module
(chr_hashtable_store
).
14 :-style_check
(-singleton
).
15 :-style_check
(- (discontiguous
)).
16 :-use_module
(library
(lists
)).
17 :-use_module
(hprolog
).
18 :-use_module
(library
(assoc
)).
19 :-use_module
(pairlist
).
20 :-use_module
(library
(ordsets
)).
22 :-use_module
(clean_code
).
23 :-use_module
(builtins
).
26 chr_translate
(A
, B
) :-
28 partition_clauses
(A
, C
, D
, E
),
30 -> insert_declarations
(E
, B
)
35 unique_analyse_optimise
(D
, F
),
37 assume_constraint_stores
(C
),
38 set_constraint_indices
(C
, 1),
39 constraints_code
(C
, F
, G
),
40 validate_store_type_assumptions
(C
),
41 store_management_preds
(C
, H
),
42 insert_declarations
(E
, I
),
43 chr_module_declaration
(J
),
44 append_lists
([I
, H
, G
, J
], B
)
46 store_management_preds
(A
, B
) :-
47 generate_attach_detach_a_constraint_all
(A
, C
),
48 generate_indexed_variables_clauses
(A
, D
),
49 generate_attach_increment
(E
),
50 generate_attr_unify_hook
(F
),
51 generate_extra_clauses
(A
, G
),
52 generate_insert_delete_constraints
(A
, H
),
53 generate_store_code
(A
, I
),
54 append_lists
([C
, D
, E
, F
, G
, H
, I
], B
).
55 insert_declarations
(A
, B
) :-
56 ( A
=[ (:-module
(C
, D
))|E
]
57 -> B
=[ (:-module
(C
, D
)), (:-use_module
(chr_runtime
)), (:-use_module
(chr_hashtable_store
)), (:-style_check
(-singleton
)), (:-style_check
(- (discontiguous
)))|E
]
58 ; B
=[ (:-use_module
(chr_runtime
)), (:-use_module
(chr_hashtable_store
)), (:-style_check
(-singleton
)), (:-style_check
(- (discontiguous
)))|A
]
60 chr_module_declaration
(A
) :-
63 -> A
=[ (:-multifile
chr:'$chr_module'/1), chr:'$chr_module'(B
)]
66 partition_clauses
([], [], [], []).
67 partition_clauses
([A
|B
], C
, D
, E
) :-
72 ; is_declaration
(A
, J
)
76 ; is_module_declaration
(A
, K
)
82 -> format
('CHR compiler WARNING: ~w.\n', [A
]),
83 format
(' `--> SICStus compatibility: ignoring handler/1 declaration.\n', []),
88 -> format
('CHR compiler WARNING: ~w.\n', [A
]),
89 format
(' `--> SICStus compatibility: ignoring rules/1 declaration.\n', []),
94 -> handle_option
(N
, O
),
102 partition_clauses
(B
, G
, H
, I
).
103 is_declaration
(A
, B
) :-
108 C
=..[constraints
, D
],
120 C
=pragma
(F
, G
, H
, B
, I
).
124 C
=pragma
(D
, E
, [], B
, F
).
131 -> B
=rule
([], H
, I
, J
)
132 ; B
=rule
([], H
, true
, E
)
145 get_ids
(L
, N
, O
, 0, P
),
146 get_ids
(M
, Q
, R
, P
, S
),
155 get_ids
(A
, B
, C
, 0, D
).
156 get_ids
([], [], [], A
, A
).
157 get_ids
([A
|B
], [C
|D
], [E
|F
], C
, G
) :-
163 get_ids
(B
, D
, F
, H
, G
).
164 is_module_declaration
((:-module
(A
)), A
).
165 is_module_declaration
((:-module
(A
, B
)), A
).
168 A
=pragma
(C
, D
, E
, F
, G
),
172 check_rules
([A
|B
], C
) :-
176 check_rule_indexing
(A
),
177 A
=pragma
(C
, D
, E
, F
, G
),
180 check_head_constraints
(L
, B
, A
),
182 check_head_constraints
([], A
, B
).
183 check_head_constraints
([A
|B
], C
, D
) :-
186 -> check_head_constraints
(B
, C
, D
)
187 ; format
('CHR compiler ERROR: Undeclared constraint ~w in head of ~@.\n', [E
/F
, format_rule
(D
)]),
188 format
(' `--> Constraint should be one of ~w.\n', [C
]),
191 check_pragmas
([], A
).
192 check_pragmas
([A
|B
], C
) :-
195 check_pragma
(A
, B
) :-
197 format
('CHR compiler ERROR: invalid pragma ~w in ~@.\n', [A
, format_rule
(B
)]),
198 format
(' `--> Pragma should not be a variable!\n', []),
200 check_pragma
(passive
(A
), B
) :- !,
201 B
=pragma
(C
, ids
(D
, E
), F
, G
, H
),
206 ; format
('CHR compiler ERROR: invalid identifier ~w in pragma passive in ~@.\n', [A
, format_rule
(B
)]),
210 check_pragma
(A
, B
) :-
212 B
=pragma
(E
, F
, G
, H
, I
),
213 pragma_unique
(I
, C
, D
),
214 format
('CHR compiler WARNING: undocument pragma ~w in ~@.\n', [A
, format_rule
(B
)]),
215 format
(' `--> Only use this pragma if you know what you are doing.\n', []).
216 check_pragma
(A
, B
) :-
217 A
=already_in_heads
, !,
218 format
('CHR compiler WARNING: currently unsupported pragma ~w in ~@.\n', [A
, format_rule
(B
)]),
219 format
(' `--> Pragma is ignored. Termination and correctness may be affected \n', []).
220 check_pragma
(A
, B
) :-
221 A
=already_in_head
(C
), !,
222 format
('CHR compiler WARNING: currently unsupported pragma ~w in ~@.\n', [A
, format_rule
(B
)]),
223 format
(' `--> Pragma is ignored. Termination and correctness may be affected \n', []).
224 check_pragma
(A
, B
) :-
225 format
('CHR compiler ERROR: invalid pragma ~w in ~@.\n', [A
, format_rule
(B
)]),
226 format
(' `--> Pragma should be one of passive/1!\n', []),
229 A
=pragma
(B
, C
, D
, E
, F
),
233 ; write('rule number '),
236 check_rule_indexing
(A
) :-
237 A
=pragma
(B
, C
, D
, E
, F
),
239 term_variables
(G
-H
, K
),
240 remove_anti_monotonic_guards
(I
, K
, L
),
241 check_indexing
(G
, L
-H
),
242 check_indexing
(H
, L
-G
).
243 remove_anti_monotonic_guards
(A
, B
, C
) :-
245 remove_anti_monotonic_guard_list
(D
, B
, E
),
247 remove_anti_monotonic_guard_list
([], A
, []).
248 remove_anti_monotonic_guard_list
([A
|B
], C
, D
) :-
254 remove_anti_monotonic_guard_list
(B
, C
, F
).
255 check_indexing
([], A
).
256 check_indexing
([A
|B
], C
) :-
259 term_variables
(B
-C
, H
),
260 check_indexing
(G
, 1, D
/E
, H
),
261 check_indexing
(B
, [A
|C
]).
262 check_indexing
([], A
, B
, C
).
263 check_indexing
([A
|B
], C
, D
, E
) :-
264 ( is_indexed_argument
(D
, C
)
267 -> indexed_argument
(D
, C
)
268 ; term_variables
(B
, F
),
271 -> indexed_argument
(D
, C
)
276 term_variables
(A
, I
),
278 check_indexing
(B
, H
, D
, J
).
280 add_occurrences
([A
|B
]) :-
281 A
=pragma
(rule
(C
, D
, E
, F
), ids
(G
, H
), I
, J
, K
),
282 add_occurrences
(C
, G
, K
),
283 add_occurrences
(D
, H
, K
),
285 add_occurrences
([], [], A
).
286 add_occurrences
([A
|B
], [C
|D
], E
) :-
289 get_max_occurrence
(H
, I
),
291 occurrence
(H
, J
, E
, C
),
292 add_occurrences
(B
, D
, E
).
294 late_allocation
([A
|B
]) :-
295 allocation_occurrence
(A
, 1),
297 handle_option
(A
, B
) :-
299 format
('CHR compiler ERROR: ~w.\n', [option
(A
, B
)]),
300 format
(' `--> First argument should be an atom, not a variable.\n', []),
302 handle_option
(A
, B
) :-
304 format
('CHR compiler ERROR: ~w.\n', [option
(A
, B
)]),
305 format
(' `--> Second argument should be a nonvariable.\n', []),
307 handle_option
(A
, B
) :-
308 option_definition
(A
, B
, C
), !,
310 handle_option
(A
, B
) :-
311 \
+option_definition
(A
, C
, D
), !,
312 format
('CHR compiler WARNING: ~w.\n', [option
(A
, B
)]),
313 format
(' `--> Invalid option name \n', []).
314 handle_option
(A
, B
) :-
315 findall
(C
, option_definition
(A
, C
, D
), E
),
316 format
('CHR compiler ERROR: ~w.\n', [option
(A
, B
)]),
317 format
(' `--> Invalid value ~w: should be one of ~w.\n', [B
, E
]),
319 option_definition
(optimize
, experimental
, A
) :-
320 A
=[unique_analyse_optimise
-on
, check_unnecessary_active
-full
, reorder_heads
-on
, set_semantics_rule
-on
, check_attachments
-on
, guard_via_reschedule
-on
].
321 option_definition
(optimize
, full
, A
) :-
322 A
=[unique_analyse_optimise
-on
, check_unnecessary_active
-full
, reorder_heads
-on
, set_semantics_rule
-on
, check_attachments
-on
, guard_via_reschedule
-on
].
323 option_definition
(optimize
, sicstus
, A
) :-
324 A
=[unique_analyse_optimise
-off
, check_unnecessary_active
-simplification
, reorder_heads
-off
, set_semantics_rule
-off
, check_attachments
-off
, guard_via_reschedule
-off
].
325 option_definition
(optimize
, off
, A
) :-
326 A
=[unique_analyse_optimise
-off
, check_unnecessary_active
-off
, reorder_heads
-off
, set_semantics_rule
-off
, check_attachments
-off
, guard_via_reschedule
-off
].
327 option_definition
(check_guard_bindings
, on
, A
) :-
329 option_definition
(check_guard_bindings
, off
, A
) :-
331 option_definition
(reduced_indexing
, on
, A
) :-
332 A
=[reduced_indexing
-on
].
333 option_definition
(reduced_indexing
, off
, A
) :-
334 A
=[reduced_indexing
-off
].
335 option_definition
(mode
, A
, []) :-
339 constraint_mode
(B
/C
, E
)
342 option_definition
(store
, A
-B
, []) :-
344 option_definition
(debug
, on
, A
) :-
346 option_definition
(debug
, off
, A
) :-
349 chr_pp_flag_definition
(A
, [B
|C
]),
350 set_chr_pp_flag
(A
, B
),
353 set_chr_pp_flags
([]).
354 set_chr_pp_flags
([A
-B
|C
]) :-
355 set_chr_pp_flag
(A
, B
),
357 set_chr_pp_flag
(A
, B
) :-
358 atom_concat
('$chr_pp_', A
, C
),
360 chr_pp_flag_definition
(unique_analyse_optimise
, [on
, off
]).
361 chr_pp_flag_definition
(check_unnecessary_active
, [full
, simplification
, off
]).
362 chr_pp_flag_definition
(reorder_heads
, [on
, off
]).
363 chr_pp_flag_definition
(set_semantics_rule
, [on
, off
]).
364 chr_pp_flag_definition
(guard_via_reschedule
, [on
, off
]).
365 chr_pp_flag_definition
(guard_locks
, [on
, off
]).
366 chr_pp_flag_definition
(check_attachments
, [on
, off
]).
367 chr_pp_flag_definition
(debugable
, [off
, on
]).
368 chr_pp_flag_definition
(reduced_indexing
, [on
, off
]).
370 atom_concat
('$chr_pp_', A
, C
),
373 -> chr_pp_flag_definition
(A
, [B
|E
])
376 generate_attach_detach_a_constraint_all
([], []).
377 generate_attach_detach_a_constraint_all
([A
|B
], C
) :-
379 -> generate_attach_a_constraint
(A
, D
),
380 generate_detach_a_constraint
(A
, E
)
384 generate_attach_detach_a_constraint_all
(B
, F
),
385 append_lists
([D
, E
, F
], C
).
386 generate_attach_a_constraint
(A
, [B
, C
]) :-
387 generate_attach_a_constraint_empty_list
(A
, B
),
388 get_max_constraint_index
(D
),
390 -> generate_attach_a_constraint_1_1
(A
, C
)
391 ; generate_attach_a_constraint_t_p
(A
, C
)
393 generate_attach_a_constraint_skeleton
(A
, B
, C
, D
) :-
394 make_name
(attach_
, A
, E
),
397 generate_attach_a_constraint_empty_list
(A
, B
) :-
398 generate_attach_a_constraint_skeleton
(A
, [[], C
], true
, B
).
399 generate_attach_a_constraint_1_1
(A
, B
) :-
401 generate_attach_a_constraint_skeleton
(A
, C
, G
, B
),
402 generate_attach_body_1
(A
, D
, F
, H
),
403 make_name
(attach_
, A
, I
),
406 generate_attach_body_1
(A
, B
, C
, D
) :-
407 get_target_module
(E
),
408 D
= (get_attr
(B
, E
, F
)->G=[C
|F
], put_attr
(B
, E
, G
);put_attr
(B
, E
, [C
])).
409 generate_attach_a_constraint_t_p
(A
, B
) :-
411 generate_attach_a_constraint_skeleton
(A
, C
, G
, B
),
412 make_name
(attach_
, A
, H
),
414 generate_attach_body_n
(A
, D
, F
, J
),
416 generate_attach_body_n
(A
/B
, C
, D
, E
) :-
417 get_constraint_index
(A
/B
, F
),
419 get_max_constraint_index
(H
),
420 make_attr
(H
, I
, J
, K
),
422 substitute
(L
, J
, [D
|L
], M
),
423 make_attr
(H
, I
, M
, N
),
424 substitute
(L
, J
, [D
], O
),
425 make_attr
(H
, P
, O
, Q
),
430 make_attr
(H
, G
, R
, T
),
431 get_target_module
(U
),
432 E
= (get_attr
(C
, U
, V
)->V=K
, (I
/\G=:=G->put_attr(C, U, N);P is I\/G
, put_attr
(C
, U
, Q
));put_attr
(C
, U
, T
)).
433 generate_detach_a_constraint
(A
, [B
, C
]) :-
434 generate_detach_a_constraint_empty_list
(A
, B
),
435 get_max_constraint_index
(D
),
437 -> generate_detach_a_constraint_1_1
(A
, C
)
438 ; generate_detach_a_constraint_t_p
(A
, C
)
440 generate_detach_a_constraint_empty_list
(A
, B
) :-
441 make_name
(detach_
, A
, C
),
445 generate_detach_a_constraint_1_1
(A
, B
) :-
446 make_name
(detach_
, A
, C
),
450 generate_detach_body_1
(A
, E
, G
, J
),
453 generate_detach_body_1
(A
, B
, C
, D
) :-
454 get_target_module
(E
),
455 D
= (get_attr
(B
, E
, F
)->'chr sbag_del_element'(F
, C
, G
), (G
==[]->del_attr(B
, E
);put_attr
(B
, E
, G
));true
).
456 generate_detach_a_constraint_t_p
(A
, B
) :-
457 make_name
(detach_
, A
, C
),
461 generate_detach_body_n
(A
, E
, G
, J
),
464 generate_detach_body_n
(A
/B
, C
, D
, E
) :-
465 get_constraint_index
(A
/B
, F
),
468 get_max_constraint_index
(I
),
469 make_attr
(I
, J
, K
, L
),
471 substitute
(M
, K
, [], N
),
472 make_attr
(I
, O
, N
, P
),
473 substitute
(M
, K
, Q
, R
),
474 make_attr
(I
, J
, R
, S
),
475 get_target_module
(T
),
476 E
= (get_attr
(C
, T
, U
)->U=L
, (J
/\G=:=G->'chr sbag_del_element'(M, D, Q), (Q==[]->O is J/\H
, (O
==0->del_attr(C
, T
);put_attr
(C
, T
, P
));put_attr
(C
, T
, S
));true
);true
).
477 generate_indexed_variables_clauses
(A
, B
) :-
478 ( forsome
(C
, A
, chr_translate
:may_trigger
(C
))
479 -> generate_indexed_variables_clauses_
(A
, B
)
482 generate_indexed_variables_clauses_
([], []).
483 generate_indexed_variables_clauses_
([A
|B
], C
) :-
485 ; chr_pp_flag
(debugable
, on
)
488 generate_indexed_variables_clause
(A
, D
)
491 generate_indexed_variables_clauses_
(B
, E
).
492 generate_indexed_variables_clause
(A
/B
, C
) :-
494 get_constraint_mode
(A
/B
, E
),
496 create_indexed_variables_body
(G
, E
, H
, 1, A
/B
, I
, J
),
500 -> K
=term_variables
(L
, H
)
503 C
= ('$indexed_variables'(L
, H
):-L
=D
, K
).
504 create_indexed_variables_body
([], [], A
, B
, C
, empty
, 0).
505 create_indexed_variables_body
([A
|B
], [C
|D
], E
, F
, G
, H
, I
) :-
507 create_indexed_variables_body
(B
, D
, K
, J
, G
, L
, M
),
509 is_indexed_argument
(G
, F
)
511 -> H
=term_variables
(A
, E
)
512 ; H
= (term_variables
(A
, E
, K
), L
)
519 generate_extra_clauses
(A
, [B
, C
, D
, E
, F
]) :-
520 ( chr_pp_flag
(reduced_indexing
, on
)
521 -> global_indexed_variables_clause
(A
, E
)
522 ; E
= (chr_indexed_variables
(G
, H
):-'chr chr_indexed_variables'(G
, H
))
524 generate_remove_clause
(B
),
525 generate_activate_clause
(C
),
526 generate_allocate_clause
(D
),
527 generate_insert_constraint_internal
(F
).
528 generate_remove_clause
(A
) :-
529 A
= (remove_constraint_internal
(B
, C
, D
):-arg
(2, B
, E
), E
=mutable
(F
), 'chr update_mutable'(removed
, E
), (compound
(F
)->C=[], D
=no;F
==removed
->C=[], D
=no;D
=yes
, chr_indexed_variables
(B
, C
))).
530 generate_activate_clause
(A
) :-
531 A
= (activate_constraint
(B
, C
, D
, E
):-arg
(2, D
, F
), F
=mutable
(G
), 'chr update_mutable'(active
, F
), (nonvar
(E
)->true;arg
(4, D
, H
), H
=mutable
(I
), E is I
+1, 'chr update_mutable'(E
, H
)), (compound
(G
)->term_variables(G
, C
), 'chr none_locked'(C
), B
=yes
;G
==removed
->chr_indexed_variables(D
, C
), B
=yes
;C
=[], B
=no)).
532 generate_allocate_clause
(A
) :-
533 A
= (allocate_constraint
(B
, C
, D
, E
):-C
=..[suspension
, F
, G
, B
, H
, I
, D
|E
], H
=mutable
(0), 'chr empty_history'(J
), I
=mutable
(J
), chr_indexed_variables
(C
, K
), G
=mutable
(passive
(K
)), 'chr gen_id'(F
)).
534 generate_insert_constraint_internal
(A
) :-
535 A
= (insert_constraint_internal
(yes
, B
, C
, D
, E
, F
):-C
=..[suspension
, G
, H
, D
, I
, J
, E
|F
], chr_indexed_variables
(C
, B
), 'chr none_locked'(B
), H
=mutable
(active
), I
=mutable
(0), J
=mutable
(K
), 'chr empty_history'(K
), 'chr gen_id'(G
)).
536 global_indexed_variables_clause
(A
, B
) :-
537 ( forsome
(C
, A
, chr_translate
:may_trigger
(C
))
538 -> D
= (E
=..[F
, G
, H
, I
, J
, K
, L
|M
], '$indexed_variables'(L
, N
))
542 B
= (chr_indexed_variables
(E
, N
):-D
).
543 generate_attach_increment
(A
) :-
544 get_max_constraint_index
(B
),
547 generate_attach_increment_empty
(C
),
549 -> generate_attach_increment_one
(D
)
550 ; generate_attach_increment_many
(B
, D
)
554 generate_attach_increment_empty
((attach_increment
([], A
):-true
)).
555 generate_attach_increment_one
(A
) :-
556 B
=attach_increment
([C
|D
], E
),
557 get_target_module
(F
),
558 G
= ('chr not_locked'(C
), (get_attr
(C
, F
, H
)->sort(H
, I
), merge
(E
, I
, J
), put_attr
(C
, F
, J
);put_attr
(C
, F
, E
)), attach_increment
(D
, E
)),
560 generate_attach_increment_many
(A
, B
) :-
561 make_attr
(A
, C
, D
, E
),
562 make_attr
(A
, F
, G
, H
),
563 I
=attach_increment
([J
|K
], E
),
564 bagof
(L
, M
^N
^O
^P
^ (member2
(D
, G
, M
-N
), L
= (sort(N
, O
), 'chr merge_attributes'(M
, O
, P
))), Q
),
566 bagof
(S
, T
^U
^V
^member
((T
, 'chr merge_attributes'(U
, V
, S
)), Q
), W
),
567 make_attr
(A
, X
, W
, Y
),
568 get_target_module
(Z
),
569 A1
= ('chr not_locked'(J
), (get_attr
(J
, Z
, B1
)->B1=H
, R
, X is C\
/F
, put_attr
(J
, Z
, Y
);put_attr
(J
, Z
, E
)), attach_increment
(K
, E
)),
571 generate_attr_unify_hook
([A
]) :-
572 get_max_constraint_index
(B
),
574 -> get_target_module
(C
),
575 A
= (attr_unify_hook
(D
, E
):-write('ERROR: Unexpected triggering of attr_unify_hook/2 in module '), writeln
(C
))
577 -> generate_attr_unify_hook_one
(A
)
578 ; generate_attr_unify_hook_many
(B
, A
)
580 generate_attr_unify_hook_one
(A
) :-
581 B
=attr_unify_hook
(C
, D
),
582 get_target_module
(E
),
583 make_run_suspensions
(F
, G
),
584 make_run_suspensions
(C
, H
),
585 I
= (sort(C
, J
), (var
(D
)-> (get_attr
(D
, E
, K
)->true;K
=[]), sort(K
, L
), 'chr merge_attributes'(J
, L
, F
), put_attr
(D
, E
, F
), G
; (compound
(D
)->term_variables(D
, M
), attach_increment
(M
, J
);true
), H
)),
587 generate_attr_unify_hook_many
(A
, B
) :-
588 make_attr
(A
, C
, D
, E
),
589 make_attr
(A
, F
, G
, H
),
590 bagof
(I
, J
^K
^ (member
(J
, D
), I
=sort(J
, K
)), L
),
592 bagof
(K
, J
^member
(sort(J
, K
), L
), N
),
593 bagof
(O
, P
^Q
^R
^S
^ (member2
(N
, G
, P
-Q
), O
= (sort(Q
, R
), 'chr merge_attributes'(P
, R
, S
))), T
),
594 bagof
(S
, P
^R
^U
^member
((U
, 'chr merge_attributes'(P
, R
, S
)), T
), V
),
596 make_attr
(A
, X
, V
, Y
),
597 make_attr
(A
, C
, N
, Z
),
598 A1
=attr_unify_hook
(E
, B1
),
599 get_target_module
(C1
),
600 make_run_suspensions_loop
(V
, D1
),
601 make_run_suspensions_loop
(N
, E1
),
602 F1
= (M
, (var
(B1
)-> (get_attr
(B1
, C1
, G1
)->G1=H
, W
, X is C\
/F
, put_attr
(B1
, C1
, Y
), D1
;put_attr
(B1
, C1
, Z
), E1
); (compound
(B1
)->term_variables(B1
, H1
), attach_increment
(H1
, Z
);true
), E1
)),
604 make_run_suspensions
(A
, B
) :-
605 ( chr_pp_flag
(debugable
, on
)
606 -> B
='chr run_suspensions_d'(A
)
607 ; B
='chr run_suspensions'(A
)
609 make_run_suspensions_loop
(A
, B
) :-
610 ( chr_pp_flag
(debugable
, on
)
611 -> B
='chr run_suspensions_loop_d'(A
)
612 ; B
='chr run_suspensions_loop'(A
)
614 generate_insert_delete_constraints
([], []).
615 generate_insert_delete_constraints
([A
|B
], C
) :-
618 generate_insert_delete_constraint
(A
, D
, E
)
621 generate_insert_delete_constraints
(B
, F
).
622 generate_insert_delete_constraint
(A
, B
, C
) :-
623 get_store_type
(A
, D
),
624 generate_insert_constraint
(D
, A
, B
),
625 generate_delete_constraint
(D
, A
, C
).
626 generate_insert_constraint
(A
, B
, C
) :-
627 make_name
('$insert_in_store_', B
, D
),
629 generate_insert_constraint_body
(A
, B
, F
, G
),
631 generate_insert_constraint_body
(default, A
, B
, C
) :-
632 get_target_module
(D
),
633 get_max_constraint_index
(E
),
635 -> generate_attach_body_1
(A
, F
, B
, G
)
636 ; generate_attach_body_n
(A
, F
, B
, G
)
638 C
= ('chr global_term_ref_1'(F
), G
).
639 generate_insert_constraint_body
(multi_hash
(A
), B
, C
, D
) :-
640 generate_multi_hash_insert_constraint_bodies
(A
, B
, C
, D
).
641 generate_insert_constraint_body
(global_ground
, A
, B
, C
) :-
642 global_ground_store_name
(A
, D
),
643 C
= (nb_getval
(D
, E
), b_setval
(D
, [B
|E
])).
644 generate_insert_constraint_body
(multi_store
(A
), B
, C
, D
) :-
645 find_with_var_identity
(E
, [C
], (member
(F
, A
), chr_translate
:generate_insert_constraint_body
(F
, B
, C
, E
)), G
),
647 generate_multi_hash_insert_constraint_bodies
([], A
, B
, true
).
648 generate_multi_hash_insert_constraint_bodies
([A
|B
], C
, D
, (E
, F
)) :-
649 multi_hash_store_name
(C
, A
, G
),
650 multi_hash_key
(C
, A
, D
, H
, I
),
651 E
= (H
, nb_getval
(G
, J
), insert_ht
(J
, I
, D
)),
652 generate_multi_hash_insert_constraint_bodies
(B
, C
, D
, F
).
653 generate_delete_constraint
(A
, B
, C
) :-
654 make_name
('$delete_from_store_', B
, D
),
656 generate_delete_constraint_body
(A
, B
, F
, G
),
658 generate_delete_constraint_body
(default, A
, B
, C
) :-
659 get_target_module
(D
),
660 get_max_constraint_index
(E
),
662 -> generate_detach_body_1
(A
, F
, B
, G
),
663 C
= ('chr global_term_ref_1'(F
), G
)
664 ; generate_detach_body_n
(A
, F
, B
, G
),
665 C
= ('chr global_term_ref_1'(F
), G
)
667 generate_delete_constraint_body
(multi_hash
(A
), B
, C
, D
) :-
668 generate_multi_hash_delete_constraint_bodies
(A
, B
, C
, D
).
669 generate_delete_constraint_body
(global_ground
, A
, B
, C
) :-
670 global_ground_store_name
(A
, D
),
671 C
= (nb_getval
(D
, E
), 'chr sbag_del_element'(E
, B
, F
), b_setval
(D
, F
)).
672 generate_delete_constraint_body
(multi_store
(A
), B
, C
, D
) :-
673 find_with_var_identity
(E
, [C
], (member
(F
, A
), chr_translate
:generate_delete_constraint_body
(F
, B
, C
, E
)), G
),
675 generate_multi_hash_delete_constraint_bodies
([], A
, B
, true
).
676 generate_multi_hash_delete_constraint_bodies
([A
|B
], C
, D
, (E
, F
)) :-
677 multi_hash_store_name
(C
, A
, G
),
678 multi_hash_key
(C
, A
, D
, H
, I
),
679 E
= (H
, nb_getval
(G
, J
), delete_ht
(J
, I
, D
)),
680 generate_multi_hash_delete_constraint_bodies
(B
, C
, D
, F
).
681 generate_delete_constraint_call
(A
, B
, C
) :-
682 make_name
('$delete_from_store_', A
, D
),
684 generate_insert_constraint_call
(A
, B
, C
) :-
685 make_name
('$insert_in_store_', A
, D
),
687 generate_store_code
(A
, [B
|C
]) :-
688 enumerate_stores_code
(A
, B
),
689 generate_store_code
(A
, C
, []).
690 generate_store_code
([], A
, A
).
691 generate_store_code
([A
|B
], C
, D
) :-
692 get_store_type
(A
, E
),
693 generate_store_code
(E
, A
, C
, F
),
694 generate_store_code
(B
, F
, D
).
695 generate_store_code
(default, A
, B
, B
).
696 generate_store_code
(multi_hash
(A
), B
, C
, D
) :-
697 multi_hash_store_initialisations
(A
, B
, C
, E
),
698 multi_hash_via_lookups
(A
, B
, E
, D
).
699 generate_store_code
(global_ground
, A
, B
, C
) :-
700 global_ground_store_initialisation
(A
, B
, C
).
701 generate_store_code
(multi_store
(A
), B
, C
, D
) :-
702 multi_store_generate_store_code
(A
, B
, C
, D
).
703 multi_store_generate_store_code
([], A
, B
, B
).
704 multi_store_generate_store_code
([A
|B
], C
, D
, E
) :-
705 generate_store_code
(A
, C
, D
, F
),
706 multi_store_generate_store_code
(B
, C
, F
, E
).
707 multi_hash_store_initialisations
([], A
, B
, B
).
708 multi_hash_store_initialisations
([A
|B
], C
, D
, E
) :-
709 multi_hash_store_name
(C
, A
, F
),
710 D
=[ (:-new_ht
(G
), nb_setval
(F
, G
))|H
],
711 multi_hash_store_initialisations
(B
, C
, H
, E
).
712 global_ground_store_initialisation
(A
, B
, C
) :-
713 global_ground_store_name
(A
, D
),
714 B
=[ (:-nb_setval
(D
, []))|C
].
715 multi_hash_via_lookups
([], A
, B
, B
).
716 multi_hash_via_lookups
([A
|B
], C
, D
, E
) :-
717 multi_hash_via_lookup_name
(C
, A
, F
),
719 multi_hash_store_name
(C
, A
, J
),
720 K
= (nb_getval
(J
, L
), lookup_ht
(L
, H
, I
)),
722 multi_hash_via_lookups
(B
, C
, M
, E
).
723 multi_hash_via_lookup_name
(A
/B
, C
, D
) :-
727 -> atom_concat_list
(C
, E
)
729 atom_concat_list
(['$via1_multi_hash_', A
, /, B
, -, E
], D
).
730 multi_hash_store_name
(A
/B
, C
, D
) :-
731 get_target_module
(E
),
735 -> atom_concat_list
(C
, F
)
737 atom_concat_list
(['$chr_store_multi_hash_', E
, :, A
, /, B
, -, F
], D
).
738 multi_hash_key
(A
/B
, C
, D
, E
, F
) :-
747 find_with_var_identity
(arg
(J
, D
, K
)-K
, [D
], (member
(G
, I
), J is G
+6), L
),
752 multi_hash_key_args
(A
, B
, C
) :-
758 term_variables
(B
, F
),
759 find_with_var_identity
(D
, F
, (member
(G
, E
), arg
(G
, B
, D
)), C
)
761 global_ground_store_name
(A
/B
, C
) :-
762 get_target_module
(D
),
763 atom_concat_list
(['$chr_store_global_ground_', D
, :, A
, /, B
], C
).
764 enumerate_stores_code
(A
, B
) :-
765 C
='$enumerate_suspensions'(D
),
766 enumerate_store_bodies
(A
, D
, E
),
769 enumerate_store_bodies
([], A
, []).
770 enumerate_store_bodies
([A
|B
], C
, D
) :-
772 -> get_store_type
(A
, E
),
773 enumerate_store_body
(E
, A
, C
, F
),
777 enumerate_store_bodies
(B
, C
, G
).
778 enumerate_store_body
(default, A
, B
, C
) :-
779 get_constraint_index
(A
, D
),
780 get_target_module
(E
),
781 get_max_constraint_index
(F
),
782 G
= ('chr global_term_ref_1'(H
), get_attr
(H
, E
, I
)),
785 K
= (arg
(J
, I
, L
), 'chr sbag_member'(B
, L
))
786 ; K
='chr sbag_member'(B
, I
)
789 enumerate_store_body
(multi_hash
([A
|B
]), C
, D
, E
) :-
790 multi_hash_enumerate_store_body
(A
, C
, D
, E
).
791 enumerate_store_body
(global_ground
, A
, B
, C
) :-
792 global_ground_store_name
(A
, D
),
793 C
= (nb_getval
(D
, E
), 'chr sbag_member'(B
, E
)).
794 enumerate_store_body
(multi_store
(A
), B
, C
, D
) :-
797 enumerate_store_body
(E
, B
, C
, D
)
799 multi_hash_enumerate_store_body
(A
, B
, C
, D
) :-
800 multi_hash_store_name
(B
, A
, E
),
801 D
= (nb_getval
(E
, F
), value_ht
(F
, C
)).
802 check_attachments
(A
) :-
803 ( chr_pp_flag
(check_attachments
, on
)
804 -> check_constraint_attachments
(A
)
807 check_constraint_attachments
([]).
808 check_constraint_attachments
([A
|B
]) :-
809 check_constraint_attachment
(A
),
810 check_constraint_attachments
(B
).
811 check_constraint_attachment
(A
) :-
812 get_max_occurrence
(A
, B
),
813 check_occurrences_attachment
(A
, 1, B
).
814 check_occurrences_attachment
(A
, B
, C
) :-
817 ; check_occurrence_attachment
(A
, B
),
819 check_occurrences_attachment
(A
, D
, C
)
821 check_occurrence_attachment
(A
, B
) :-
822 get_occurrence
(A
, B
, C
, D
),
824 E
=pragma
(rule
(F
, G
, H
, I
), ids
(J
, K
), L
, M
, N
),
825 ( select2
(D
, O
, J
, F
, P
, Q
)
826 -> check_attachment_head1
(O
, D
, C
, F
, G
, H
)
827 ; select2
(D
, R
, K
, G
, S
, T
)
828 -> check_attachment_head2
(R
, D
, C
, F
, I
)
830 check_attachment_head1
(A
, B
, C
, D
, E
, F
) :-
839 ; attached
(G
/H
, maybe
)
842 no_matching
([A
|B
], C
) :-
844 \
+memberchk_eq
(A
, C
),
845 no_matching
(B
, [A
|C
]).
846 check_attachment_head2
(A
, B
, C
, D
, E
) :-
849 -> attached
(F
/G
, maybe
)
852 -> attached
(F
/G
, maybe
)
856 all_attached
([A
|B
]) :-
860 set_constraint_indices
([], A
) :-
862 max_constraint_index
(B
).
863 set_constraint_indices
([A
|B
], C
) :-
866 get_store_type
(A
, default)
868 -> constraint_index
(A
, C
),
870 set_constraint_indices
(B
, D
)
871 ; set_constraint_indices
(B
, C
)
873 constraints_code
(A
, B
, C
) :-
874 post_constraints
(A
, 1),
875 constraints_code1
(1, B
, D
, []),
877 post_constraints
([], A
) :-
880 post_constraints
([A
/B
|C
], D
) :-
883 post_constraints
(C
, E
).
884 constraints_code1
(A
, B
, C
, D
) :-
885 get_constraint_count
(E
),
888 ; constraint_code
(A
, B
, C
, F
),
890 constraints_code1
(G
, B
, F
, D
)
892 constraint_code
(A
, B
, C
, D
) :-
893 get_constraint
(E
, A
),
894 constraint_prelude
(E
, F
),
897 rules_code
(B
, A
, H
, I
, G
, J
),
898 gen_cond_attach_clause
(E
, I
, J
, D
).
899 constraint_prelude
(A
/B
, C
) :-
900 vars_susp
(B
, D
, E
, F
),
902 build_head
(A
, B
, [0], F
, H
),
903 get_target_module
(I
),
905 ( chr_pp_flag
(debugable
, on
)
906 -> C
= (G
:-allocate_constraint
(I
:H
, E
, J
, D
), ('chr debug_event'(call
(E
)), H
;'chr debug_event'(fail
(E
)), !, fail
), ('chr debug_event'(exit(E
));'chr debug_event'(redo(E
)), fail
))
909 gen_cond_attach_clause
(A
/B
, C
, D
, E
) :-
912 -> ( may_trigger
(A
/B
)
913 -> gen_cond_attach_goal
(A
/B
, F
, G
, H
, I
)
914 ; gen_insert_constraint_internal_goal
(A
/B
, F
, G
, H
, I
)
916 ; vars_susp
(B
, H
, I
, G
),
917 gen_uncond_attach_goal
(A
/B
, I
, F
, J
)
919 ( chr_pp_flag
(debugable
, on
)
921 L
='chr debug_event'(insert
(#(K, I)))
924 build_head
(A
, B
, C
, G
, M
),
929 gen_cond_attach_goal
(A
/B
, C
, D
, E
, F
) :-
930 vars_susp
(B
, E
, F
, D
),
931 build_head
(A
, B
, [0], D
, G
),
933 -> make_name
(attach_
, A
/B
, H
),
937 get_target_module
(K
),
939 generate_insert_constraint_call
(A
/B
, F
, M
),
940 C
= ((var
(F
)->insert_constraint_internal(N
, J
, F
, K
:G
, L
, E
);activate_constraint
(N
, J
, F
, O
)), (N
==yes
->M, I
;true
)).
941 gen_insert_constraint_internal_goal
(A
/B
, C
, D
, E
, F
) :-
942 vars_susp
(B
, E
, F
, D
),
943 build_head
(A
, B
, [0], D
, G
),
945 -> make_name
(attach_
, A
/B
, H
),
949 get_target_module
(K
),
951 generate_insert_constraint_call
(A
/B
, F
, M
),
952 C
= (insert_constraint_internal
(N
, J
, F
, K
:G
, L
, E
), M
, I
).
953 gen_uncond_attach_goal
(A
, B
, C
, D
) :-
955 -> make_name
(attach_
, A
, E
),
959 generate_insert_constraint_call
(A
, B
, H
),
960 C
= (activate_constraint
(I
, G
, B
, D
), (I
==yes
->H, F
;true
)).
961 occurrences_code
(A
, B
, C
, D
, E
, F
, G
) :-
965 ; occurrence_code
(A
, C
, D
, H
, F
, I
),
967 occurrences_code
(J
, B
, C
, H
, E
, I
, G
)
969 occurrences_code
(A
, B
, C
, D
, E
, F
) :-
970 get_occurrence
(B
, A
, G
, H
),
975 I
=pragma
(rule
(J
, K
, L
, M
), ids
(N
, O
), P
, Q
, R
),
976 ( select2
(N
, J
, H
, S
, T
, U
)
978 head1_code
(S
, U
, T
, I
, B
, C
, E
, F
)
979 ; select2
(O
, K
, H
, V
, W
, X
)
981 head2_code
(V
, X
, W
, I
, Y
, B
, C
, E
, Z
),
983 gen_alloc_inc_clause
(B
, C
, Z
, F
)
986 rules_code
([], A
, B
, B
, C
, C
).
987 rules_code
([A
|B
], C
, D
, E
, F
, G
) :-
988 rule_code
(A
, C
, D
, H
, F
, I
),
989 rules_code
(B
, C
, H
, E
, I
, G
).
990 rule_code
(A
, B
, C
, D
, E
, F
) :-
991 A
=pragma
(G
, H
, I
, J
, K
),
994 heads1_code
(N
, [], L
, [], A
, B
, C
, E
, R
),
995 heads2_code
(O
, [], M
, [], A
, B
, C
, D
, R
, F
).
996 heads1_code
([], A
, B
, C
, D
, E
, F
, G
, G
).
997 heads1_code
([A
|B
], C
, [D
|E
], F
, G
, H
, I
, J
, K
) :-
998 G
=pragma
(L
, M
, N
, O
, P
),
999 get_constraint
(Q
/R
, H
),
1002 \
+check_unnecessary_active
(A
, C
, L
),
1009 head1_code
(A
, W
, X
, G
, Q
/R
, H
, I
, J
, Y
)
1012 heads1_code
(B
, [A
|C
], E
, [D
|F
], G
, H
, I
, Y
, K
).
1013 head1_code
(A
, B
, C
, D
, E
, F
, G
, H
, I
) :-
1014 D
=pragma
(J
, K
, L
, M
, N
),
1017 -> reorder_heads
(N
, A
, B
, C
, S
, T
),
1018 simplification_code
(A
, S
, T
, D
, E
, G
, H
, I
)
1019 ; simpagation_head1_code
(A
, B
, C
, D
, E
, G
, H
, I
)
1021 heads2_code
([], A
, B
, C
, D
, E
, F
, F
, G
, G
).
1022 heads2_code
([A
|B
], C
, [D
|E
], F
, G
, H
, I
, J
, K
, L
) :-
1023 G
=pragma
(M
, N
, O
, P
, Q
),
1024 get_constraint
(R
/S
, H
),
1027 \
+check_unnecessary_active
(A
, C
, M
),
1028 \
+set_semantics_rule
(G
),
1036 head2_code
(A
, X
, Y
, G
, Z
, R
/S
, I
, K
, A1
),
1038 gen_alloc_inc_clause
(R
/S
, I
, A1
, C1
)
1042 heads2_code
(B
, [A
|C
], E
, [D
|F
], G
, H
, B1
, J
, C1
, L
).
1043 head2_code
(A
, B
, C
, D
, E
, F
, G
, H
, I
) :-
1044 D
=pragma
(J
, K
, L
, M
, N
),
1047 -> reorder_heads
(N
, A
, B
, C
, S
, T
),
1048 propagation_code
(A
, S
, J
, N
, E
, F
, G
, H
, I
)
1049 ; simpagation_head2_code
(A
, B
, C
, D
, F
, G
, H
, I
)
1051 gen_alloc_inc_clause
(A
/B
, C
, D
, E
) :-
1052 vars_susp
(B
, F
, G
, H
),
1053 build_head
(A
, B
, C
, H
, I
),
1055 build_head
(A
, B
, J
, H
, K
),
1056 gen_allocation
(C
, F
, G
, A
/B
, H
, L
),
1059 gen_cond_allocation
(A
, B
, C
, D
, E
) :-
1060 gen_allocation
(A
, B
, C
, D
, F
),
1061 E
= (var
(B
)->F;true
).
1062 gen_allocation
(A
, B
, C
/D
, E
, F
) :-
1063 build_head
(C
, D
, [0], E
, G
),
1064 get_target_module
(H
),
1066 F
=allocate_constraint
(H
:G
, B
, I
, A
).
1067 gen_allocation
(A
, B
, C
, D
, E
, F
) :-
1071 -> gen_cond_allocation
(B
, C
, D
, E
, F
)
1072 ; gen_allocation
(B
, C
, D
, E
, F
)
1078 guard_via_reschedule
(A
, B
, C
, D
) :-
1079 ( chr_pp_flag
(guard_via_reschedule
, on
)
1080 -> guard_via_reschedule_main
(A
, B
, C
, D
)
1084 guard_via_reschedule_main
(A
, B
, C
, D
) :-
1085 initialize_unit_dictionary
(C
, E
),
1086 build_units
(A
, B
, E
, F
),
1087 dependency_reorder
(F
, G
),
1089 units2goal
([], true
).
1090 units2goal
([unit
(A
, B
, C
, D
)|E
], (B
, F
)) :-
1092 dependency_reorder
(A
, B
) :-
1093 dependency_reorder
(A
, [], B
).
1094 dependency_reorder
([], A
, B
) :-
1096 dependency_reorder
([A
|B
], C
, D
) :-
1100 ; dependency_insert
(C
, A
, H
, I
)
1102 dependency_reorder
(B
, I
, D
).
1103 dependency_insert
([], A
, B
, [A
]).
1104 dependency_insert
([A
|B
], C
, D
, E
) :-
1109 dependency_insert
(B
, C
, D
, J
)
1111 build_units
(A
, B
, C
, D
) :-
1112 build_retrieval_units
(A
, 1, E
, C
, F
, D
, G
),
1113 build_guard_units
(B
, E
, F
, G
).
1114 build_retrieval_units
([], A
, A
, B
, B
, C
, C
).
1115 build_retrieval_units
([A
|B
], C
, D
, E
, F
, G
, H
) :-
1116 term_variables
(A
, I
),
1117 update_unit_dictionary
(I
, C
, E
, J
, [], K
),
1118 G
=[unit
(C
, A
, movable
, K
)|L
],
1120 build_retrieval_units2
(B
, M
, D
, J
, F
, L
, H
).
1121 build_retrieval_units2
([], A
, A
, B
, B
, C
, C
).
1122 build_retrieval_units2
([A
|B
], C
, D
, E
, F
, G
, H
) :-
1123 term_variables
(A
, I
),
1124 update_unit_dictionary
(I
, C
, E
, J
, [], K
),
1125 G
=[unit
(C
, A
, fixed
, K
)|L
],
1127 build_retrieval_units
(B
, M
, D
, J
, F
, L
, H
).
1128 initialize_unit_dictionary
(A
, B
) :-
1129 term_variables
(A
, C
),
1130 pair_all_with
(C
, 0, B
).
1131 update_unit_dictionary
([], A
, B
, B
, C
, C
).
1132 update_unit_dictionary
([A
|B
], C
, D
, E
, F
, G
) :-
1133 ( lookup_eq
(D
, A
, H
)
1144 update_unit_dictionary
(B
, C
, J
, E
, I
, G
).
1145 build_guard_units
(A
, B
, C
, D
) :-
1147 -> D
=[unit
(B
, E
, fixed
, [])]
1149 -> term_variables
(E
, G
),
1150 update_unit_dictionary2
(G
, B
, C
, H
, [], I
),
1151 D
=[unit
(B
, E
, movable
, I
)|J
],
1153 build_guard_units
(F
, K
, H
, J
)
1155 update_unit_dictionary2
([], A
, B
, B
, C
, C
).
1156 update_unit_dictionary2
([A
|B
], C
, D
, E
, F
, G
) :-
1157 ( lookup_eq
(D
, A
, H
)
1168 update_unit_dictionary2
(B
, C
, J
, E
, I
, G
).
1169 unique_analyse_optimise
(A
, B
) :-
1170 ( chr_pp_flag
(unique_analyse_optimise
, on
)
1171 -> unique_analyse_optimise_main
(A
, 1, [], B
)
1174 unique_analyse_optimise_main
([], A
, B
, []).
1175 unique_analyse_optimise_main
([A
|B
], C
, D
, [E
|F
]) :-
1176 ( discover_unique_pattern
(A
, C
, G
)
1180 A
=pragma
(I
, J
, K
, L
, M
),
1183 apply_unique_patterns_to_constraints
(N
, R
, H
, T
),
1184 apply_unique_patterns_to_constraints
(O
, S
, H
, U
),
1185 globalize_unique_pragmas
(T
, M
),
1186 globalize_unique_pragmas
(U
, M
),
1187 append_lists
([T
, U
, K
], V
),
1188 E
=pragma
(I
, J
, V
, L
, M
),
1190 unique_analyse_optimise_main
(B
, W
, H
, F
).
1191 globalize_unique_pragmas
([], A
).
1192 globalize_unique_pragmas
([unique
(A
, B
)|C
], D
) :-
1193 pragma_unique
(D
, A
, B
),
1194 globalize_unique_pragmas
(C
, D
).
1195 apply_unique_patterns_to_constraints
([], A
, B
, []).
1196 apply_unique_patterns_to_constraints
([A
|B
], [C
|D
], E
, F
) :-
1198 apply_unique_pattern
(A
, C
, G
, H
)
1202 apply_unique_patterns_to_constraints
(B
, D
, E
, I
).
1203 apply_unique_pattern
(A
, B
, C
, D
) :-
1206 ( setof
(H
, I
^J
^K
^ (member
(I
, F
), lookup_eq
(G
, I
, J
), term_variables
(J
, K
), member
(H
, K
)), L
)
1211 subsumes
(A
, B
, C
) :-
1213 subsumes_aux
(A
, B
, D
, E
),
1214 assoc_to_list
(E
, F
),
1215 build_unifier
(F
, C
).
1216 subsumes_aux
(A
, B
, C
, D
) :-
1221 subsumes_aux
(F
, A
, B
, C
, D
)
1229 put_assoc
(A
, C
, B
, D
)
1231 subsumes_aux
(0, A
, B
, C
, C
) :- !.
1232 subsumes_aux
(A
, B
, C
, D
, E
) :-
1235 subsumes_aux
(F
, G
, D
, H
),
1237 subsumes_aux
(I
, B
, C
, H
, E
).
1238 build_unifier
([], []).
1239 build_unifier
([A
-B
|C
], [B
-A
|D
]) :-
1240 build_unifier
(C
, D
).
1241 discover_unique_pattern
(A
, B
, C
) :-
1242 A
=pragma
(D
, E
, F
, G
, B
),
1251 check_unique_constraints
(L
, M
, J
, B
, N
),
1252 term_variables
(L
, O
),
1253 select_pragma_unique_variables
(N
, O
, P
),
1256 ( prolog_flag
(verbose
, R
),
1258 -> format
('Found unique pattern ~w in rule ~d~@\n', [C
, B
, (G
=yes
(S
)->write([58, 32]), write(S
);true
)])
1261 select_pragma_unique_variables
([], A
, []).
1262 select_pragma_unique_variables
([A
-B
|C
], D
, E
) :-
1266 ( \
+memberchk_eq
(A
, D
)
1267 ; \
+memberchk_eq
(B
, D
)
1272 select_pragma_unique_variables
(C
, D
, F
).
1273 check_unique_constraints
(A
, B
, C
, D
, E
) :-
1274 \
+any_passive_head
(D
),
1275 variable_replacement
(A
-B
, B
-A
, E
),
1276 copy_with_variable_replacement
(C
, F
, E
),
1278 once
(entails_b
(G
, F
)).
1279 check_unnecessary_active
(A
, B
, C
) :-
1280 ( chr_pp_flag
(check_unnecessary_active
, full
)
1281 -> check_unnecessary_active_main
(A
, B
, C
)
1282 ; chr_pp_flag
(check_unnecessary_active
, simplification
),
1284 -> check_unnecessary_active_main
(A
, B
, C
)
1287 check_unnecessary_active_main
(A
, B
, C
) :-
1289 variable_replacement
(D
, A
, E
),
1290 copy_with_variable_replacement
(C
, F
, E
),
1291 identical_rules
(C
, F
), !.
1292 set_semantics_rule
(A
) :-
1293 ( chr_pp_flag
(set_semantics_rule
, on
)
1294 -> set_semantics_rule_main
(A
)
1297 set_semantics_rule_main
(A
) :-
1298 A
=pragma
(B
, C
, D
, E
, F
),
1299 B
=rule
([G
], [H
], true
, I
),
1301 once
(member
(unique
(J
, L
), D
)),
1302 once
(member
(unique
(K
, M
), D
)),
1305 identical_rules
(rule
(A
, B
, C
, D
), rule
(E
, F
, G
, H
)) :-
1307 identical_bodies
(D
, H
),
1312 identical_bodies
(A
, B
) :-
1322 copy_with_variable_replacement
(A
, B
, C
) :-
1324 -> ( lookup_eq
(C
, A
, B
)
1332 copy_with_variable_replacement_l
(G
, I
, C
)
1334 copy_with_variable_replacement_l
([], [], A
).
1335 copy_with_variable_replacement_l
([A
|B
], [C
|D
], E
) :-
1336 copy_with_variable_replacement
(A
, C
, E
),
1337 copy_with_variable_replacement_l
(B
, D
, E
).
1338 variable_replacement
(A
, B
, C
) :-
1339 variable_replacement
(A
, B
, [], C
).
1340 variable_replacement
(A
, B
, C
, D
) :-
1343 ( lookup_eq
(C
, A
, E
)
1351 variable_replacement_l
(G
, H
, C
, D
)
1353 variable_replacement_l
([], [], A
, A
).
1354 variable_replacement_l
([A
|B
], [C
|D
], E
, F
) :-
1355 variable_replacement
(A
, C
, E
, G
),
1356 variable_replacement_l
(B
, D
, G
, F
).
1357 simplification_code
(A
, B
, C
, D
, E
/F
, G
, H
, I
) :-
1358 D
=pragma
(J
, K
, L
, M
, N
),
1359 head_info
(A
, F
, O
, P
, Q
, R
),
1360 build_head
(E
, F
, G
, Q
, S
),
1361 head_arg_matches
(R
, [], T
, U
),
1366 ; rest_heads_retrieval_and_matching
(B
, C
, L
, A
, X
, V
, U
, W
)
1368 guard_body_copies2
(J
, W
, Y
, Z
),
1369 guard_via_reschedule
(X
, Y
, S
-T
, A1
),
1370 gen_uncond_susps_detachments
(V
, B
, B1
),
1371 gen_cond_susp_detachment
(G
, P
, E
/F
, C1
),
1372 ( chr_pp_flag
(debugable
, on
)
1373 -> J
=rule
(D1
, E1
, F1
, G1
),
1374 my_term_copy
(F1
-G1
, W
, H1
, I1
-J1
),
1375 K1
='chr debug_event'(try
([P
|L1
], [], I1
, J1
)),
1376 M1
='chr debug_event'(apply
([P
|L1
], [], I1
, J1
))
1380 N1
= (S
:-T
, A1
, K1
, !, M1
, B1
, C1
, Z
),
1382 head_arg_matches
(A
, B
, C
, D
) :-
1383 head_arg_matches_
(A
, B
, E
, D
),
1385 head_arg_matches_
([], A
, [], A
).
1386 head_arg_matches_
([A
-B
|C
], D
, E
, F
) :-
1388 -> ( lookup_eq
(D
, A
, G
)
1403 E
=[nonvar
(B
), B
=O
|H
],
1408 head_arg_matches_
(J
, I
, H
, F
).
1409 rest_heads_retrieval_and_matching
(A
, B
, C
, D
, E
, F
, G
, H
) :-
1410 rest_heads_retrieval_and_matching
(A
, B
, C
, D
, E
, F
, G
, H
, [], [], []).
1411 rest_heads_retrieval_and_matching
(A
, B
, C
, D
, E
, F
, G
, H
, I
, J
, K
) :-
1413 -> rest_heads_retrieval_and_matching_n
(A
, B
, C
, I
, J
, D
, E
, F
, G
, H
, K
)
1418 rest_heads_retrieval_and_matching_n
([], A
, B
, C
, D
, E
, [], [], F
, F
, G
) :-
1419 instantiate_pattern_goals
(G
).
1420 rest_heads_retrieval_and_matching_n
([A
|B
], [C
|D
], E
, F
, G
, H
, [I
, J
|K
], [L
|M
], N
, O
, P
) :-
1422 get_store_type
(Q
/R
, S
),
1424 -> passive_head_via
(A
, [H
|F
], P
, N
, I
, T
, U
),
1425 get_max_constraint_index
(V
),
1428 ; get_constraint_index
(Q
/R
, X
),
1429 make_attr
(V
, Y
, Z
, T
),
1432 ; lookup_passive_head
(S
, A
, [H
|F
], N
, I
, W
),
1435 head_info
(A
, R
, A1
, B1
, C1
, D1
),
1436 head_arg_matches
(D1
, N
, E1
, F1
),
1437 G1
=..[suspension
, H1
, I1
, J1
, K1
, L1
, M1
|A1
],
1438 different_from_other_susps
(A
, L
, F
, G
, N1
),
1439 create_get_mutable
(active
, I1
, O1
),
1440 P1
= ('chr sbag_member'(L
, W
), L
=G1
, O1
, N1
, E1
),
1441 ( member
(unique
(C
, Q1
), E
),
1442 check_unique_keys
(Q1
, N
)
1446 rest_heads_retrieval_and_matching_n
(B
, D
, E
, [A
|F
], [L
|G
], H
, K
, M
, F1
, O
, U
).
1447 instantiate_pattern_goals
([]).
1448 instantiate_pattern_goals
([A
-attr
(B
, C
, D
)|E
]) :-
1449 get_max_constraint_index
(F
),
1452 ; make_attr
(F
, G
, H
, B
),
1456 instantiate_pattern_goals
(E
).
1457 check_unique_keys
([], A
).
1458 check_unique_keys
([A
|B
], C
) :-
1460 check_unique_keys
(B
, C
).
1461 different_from_other_susps
(A
, B
, C
, D
, E
) :-
1462 ( bagof
(F
, G
^ (nth
(G
, C
, H
), \
+A\
=H
, nth
(G
, D
, I
), F
= (B\
==I
)), J
)
1466 passive_head_via
(A
, B
, C
, D
, E
, F
, G
) :-
1468 get_constraint_index
(H
/I
, J
),
1469 common_variables
(A
, B
, K
),
1472 ( permutation
(L
, N
),
1473 lookup_eq
(C
, N
, attr
(F
, O
, P
))
1478 gen_get_mod_constraints
(L
, Q
, F
),
1479 G
=[L
-attr
(F
, [M
|S
], R
)|C
]
1481 common_variables
(A
, B
, C
) :-
1482 term_variables
(A
, D
),
1483 term_variables
(B
, E
),
1484 intersect_eq
(D
, E
, C
).
1485 gen_get_mod_constraints
(A
, B
, C
) :-
1486 get_target_module
(D
),
1488 -> B
= ('chr global_term_ref_1'(E
), get_attr
(E
, D
, F
), F
=C
)
1490 -> H
='chr via_1'(G
, I
)
1492 -> H
='chr via_2'(G
, J
, I
)
1495 B
= (H
, get_attr
(I
, D
, F
), F
=C
)
1497 guard_body_copies
(A
, B
, C
, D
) :-
1498 guard_body_copies2
(A
, B
, E
, D
),
1500 guard_body_copies2
(A
, B
, C
, D
) :-
1503 split_off_simple_guard
(I
, B
, J
, K
),
1504 my_term_copy
(J
-K
, B
, L
, M
-N
),
1506 term_variables
(K
, P
),
1507 term_variables
(N
, Q
),
1508 ( chr_pp_flag
(guard_locks
, on
),
1509 bagof
('chr lock'(R
)-'chr unlock'(R
), S
^ (member
(S
, P
), lookup_eq
(B
, S
, R
), memberchk_eq
(R
, Q
)), T
)
1510 -> once
(pairup
(U
, V
, T
))
1518 my_term_copy
(H
, L
, D
).
1519 split_off_simple_guard
([], A
, [], []).
1520 split_off_simple_guard
([A
|B
], C
, D
, E
) :-
1521 ( simple_guard
(A
, C
)
1523 split_off_simple_guard
(B
, C
, F
, E
)
1527 simple_guard
(A
, B
) :-
1533 my_term_copy
(A
, B
, C
) :-
1534 my_term_copy
(A
, B
, D
, C
).
1535 my_term_copy
(A
, B
, C
, D
) :-
1537 -> ( lookup_eq
(B
, A
, D
)
1545 my_term_copy_list
(H
, B
, C
, J
)
1547 my_term_copy_list
([], A
, A
, []).
1548 my_term_copy_list
([A
|B
], C
, D
, [E
|F
]) :-
1549 my_term_copy
(A
, C
, G
, E
),
1550 my_term_copy_list
(B
, G
, D
, F
).
1551 gen_cond_susp_detachment
(A
, B
, C
, D
) :-
1556 ; gen_uncond_susp_detachment
(B
, C
, E
),
1561 gen_uncond_susp_detachment
(A
, B
, C
) :-
1564 -> make_name
(detach_
, B
, D
),
1568 ( chr_pp_flag
(debugable
, on
)
1569 -> G
='chr debug_event'(remove
(A
))
1572 generate_delete_constraint_call
(B
, A
, H
),
1573 C
= (G
, remove_constraint_internal
(A
, F
, I
), (I
==yes
->H, E
;true
))
1576 gen_uncond_susps_detachments
([], [], true
).
1577 gen_uncond_susps_detachments
([A
|B
], [C
|D
], (E
, F
)) :-
1579 gen_uncond_susp_detachment
(A
, G
/H
, E
),
1580 gen_uncond_susps_detachments
(B
, D
, F
).
1581 simpagation_head1_code
(A
, B
, C
, D
, E
/F
, G
, H
, I
) :-
1582 D
=pragma
(J
, ids
(K
, L
), M
, N
, O
),
1584 head_info
(A
, F
, T
, U
, V
, W
),
1585 head_arg_matches
(W
, [], X
, Y
),
1586 build_head
(E
, F
, G
, V
, Z
),
1589 reorder_heads
(O
, A
, A1
, B1
, C1
, D1
),
1590 rest_heads_retrieval_and_matching
(C1
, D1
, M
, A
, E1
, F1
, Y
, G1
),
1591 split_by_ids
(D1
, F1
, C
, H1
, I1
),
1592 guard_body_copies2
(J
, G1
, J1
, K1
),
1593 guard_via_reschedule
(E1
, J1
, Z
-X
, L1
),
1594 gen_uncond_susps_detachments
(H1
, B
, M1
),
1595 gen_cond_susp_detachment
(G
, U
, E
/F
, N1
),
1596 ( chr_pp_flag
(debugable
, on
)
1597 -> my_term_copy
(R
-S
, G1
, O1
, P1
-Q1
),
1598 R1
='chr debug_event'(try
([U
|H1
], I1
, P1
, Q1
)),
1599 S1
='chr debug_event'(apply
([U
|H1
], I1
, P1
, Q1
))
1603 T1
= (Z
:-X
, L1
, R1
, !, S1
, M1
, N1
, K1
),
1605 split_by_ids
([], [], A
, [], []).
1606 split_by_ids
([A
|B
], [C
|D
], E
, F
, G
) :-
1607 ( memberchk_eq
(A
, E
)
1613 split_by_ids
(B
, D
, E
, H
, I
).
1614 simpagation_head2_code
(A
, B
, C
, D
, E
, F
, G
, H
) :-
1615 D
=pragma
(I
, ids
(J
, K
), L
, M
, N
),
1617 reorder_heads
(N
, A
, O
, J
, [S
|T
], [U
|V
]),
1618 simpagation_head2_prelude
(A
, S
, [B
, O
, Q
, R
], E
, F
, G
, W
),
1620 simpagation_head2_worker
(A
, S
, U
, T
, V
, B
, C
, D
, E
, X
, W
, H
).
1621 simpagation_head2_prelude
(A
, B
, C
, D
/E
, F
, G
, H
) :-
1622 head_info
(A
, E
, I
, J
, K
, L
),
1623 build_head
(D
, E
, F
, K
, M
),
1624 head_arg_matches
(L
, [], N
, O
),
1625 lookup_passive_head
(B
, [A
], O
, P
, Q
),
1626 gen_allocation
(F
, I
, J
, D
/E
, K
, R
),
1628 extra_active_delegate_variables
(A
, C
, O
, T
),
1629 append
([Q
|K
], T
, U
),
1630 build_head
(D
, E
, S
, U
, V
),
1631 W
= (M
:-N
, P
, !, R
, V
),
1633 extra_active_delegate_variables
(A
, B
, C
, D
) :-
1635 delegate_variables
(A
, B
, C
, F
, D
).
1636 passive_delegate_variables
(A
, B
, C
, D
, E
) :-
1637 term_variables
(B
, F
),
1638 delegate_variables
(A
, C
, D
, F
, E
).
1639 delegate_variables
(A
, B
, C
, D
, E
) :-
1640 term_variables
(A
, F
),
1641 term_variables
(B
, G
),
1642 intersect_eq
(F
, G
, H
),
1643 list_difference_eq
(H
, D
, I
),
1645 simpagation_head2_worker
(A
, B
, C
, D
, E
, F
, G
, H
, I
, J
, K
, L
) :-
1646 H
=pragma
(M
, N
, O
, P
, Q
),
1648 simpagation_head2_worker_end
(A
, [B
, D
, F
, T
, U
], I
, J
, K
, V
),
1649 simpagation_head2_worker_body
(A
, B
, C
, D
, E
, F
, G
, H
, I
, J
, V
, L
).
1650 simpagation_head2_worker_body
(A
, B
, C
, D
, E
, F
, G
, H
, I
/J
, K
, L
, M
) :-
1653 head_info
(A
, J
, P
, Q
, R
, S
),
1654 head_arg_matches
(S
, [], T
, U
),
1655 H
=pragma
(V
, W
, X
, Y
, Z
),
1656 V
=rule
(A1
, B1
, C1
, D1
),
1657 extra_active_delegate_variables
(A
, [B
, D
, F
, C1
, D1
], U
, E1
),
1658 append
([[N
|O
]|R
], E1
, F1
),
1659 build_head
(I
, J
, K
, F1
, G1
),
1661 head_info
(B
, I1
, J1
, K1
, L1
, M1
),
1662 head_arg_matches
(M1
, U
, N1
, O1
),
1663 P1
=..[suspension
, Q1
, R1
, S1
, T1
, U1
, V1
|J1
],
1664 create_get_mutable
(active
, R1
, W1
),
1669 -> append
(D
, F
, Y1
),
1671 reorder_heads
(Z
, B
-A
, Y1
, Z1
, A2
, B2
),
1672 rest_heads_retrieval_and_matching
(A2
, B2
, X
, [B
, A
], C2
, D2
, O1
, E2
, [B
], [N
], []),
1673 split_by_ids
(B2
, D2
, E
, F2
, G2
)
1679 gen_uncond_susps_detachments
([N
|F2
], [B
|D
], H2
),
1680 append
([O
|R
], E1
, I2
),
1681 build_head
(I
, J
, K
, I2
, J2
),
1682 append
([[]|R
], E1
, K2
),
1683 build_head
(I
, J
, K
, K2
, L2
),
1684 guard_body_copies2
(V
, E2
, M2
, N2
),
1685 guard_via_reschedule
(C2
, M2
, v
(G1
, X1
, N1
), O2
),
1687 -> gen_uncond_attach_goal
(I
/J
, Q
, P2
, Q2
),
1688 gen_state_cond_call
(Q
, J
, J2
, Q2
, R2
),
1689 gen_state_cond_call
(Q
, J
, L2
, Q2
, S2
)
1694 ( chr_pp_flag
(debugable
, on
)
1695 -> my_term_copy
(C1
-D1
, E2
, T2
, U2
-V2
),
1696 W2
='chr debug_event'(try
([N
|F2
], [Q
|G2
], U2
, V2
)),
1697 X2
='chr debug_event'(apply
([N
|F2
], [Q
|G2
], U2
, V2
))
1701 ( member
(unique
(C
, Y2
), X
),
1702 check_unique_keys
(Y2
, U
)
1703 -> Z2
= (G1
:-X1
, N1
-> (O2
, W2
->X2, H2
, P2
, N2
, S2
;L2
);J2
)
1704 ; Z2
= (G1
:-X1
, N1
, O2
, W2
->X2, H2
, P2
, N2
, R2
;J2
)
1707 gen_state_cond_call
(A
, B
, C
, D
, E
) :-
1709 G
=..[suspension
, H
, I
, J
, K
, L
, M
|F
],
1710 create_get_mutable
(active
, I
, N
),
1711 create_get_mutable
(D
, K
, O
),
1712 E
= (A
=G
, N
, O
->'chr update_mutable'(inactive
, I
), C
;true
).
1713 simpagation_head2_worker_end
(A
, B
, C
/D
, E
, F
, G
) :-
1714 head_info
(A
, D
, H
, I
, J
, K
),
1715 head_arg_matches
(K
, [], L
, M
),
1716 extra_active_delegate_variables
(A
, B
, M
, N
),
1717 append
([[]|J
], N
, O
),
1718 build_head
(C
, D
, E
, O
, P
),
1720 build_head
(C
, D
, Q
, J
, R
),
1723 propagation_code
(A
, B
, C
, D
, E
, F
, G
, H
, I
) :-
1725 -> propagation_single_headed
(A
, C
, D
, F
, G
, H
, I
)
1726 ; propagation_multi_headed
(A
, B
, C
, D
, E
, F
, G
, H
, I
)
1728 propagation_single_headed
(A
, B
, C
, D
/E
, F
, G
, H
) :-
1729 head_info
(A
, E
, I
, J
, K
, L
),
1730 build_head
(D
, E
, F
, K
, M
),
1732 build_head
(D
, E
, N
, K
, O
),
1734 head_arg_matches
(L
, [], Q
, R
),
1735 guard_body_copies
(B
, R
, S
, T
),
1736 gen_allocation
(F
, I
, J
, D
/E
, K
, U
),
1737 gen_uncond_attach_goal
(D
/E
, J
, V
, W
),
1738 gen_state_cond_call
(J
, E
, P
, W
, X
),
1739 ( chr_pp_flag
(debugable
, on
)
1740 -> B
=rule
(Y
, Z
, A1
, B1
),
1741 my_term_copy
(A1
-B1
, R
, C1
, D1
-E1
),
1742 F1
='chr debug_event'(try
([], [J
], D1
, E1
)),
1743 G1
='chr debug_event'(apply
([], [J
], D1
, E1
))
1747 H1
= (M
:-Q
, U
, 'chr novel_production'(J
, C
), S
, F1
, !, G1
, 'chr extend_history'(J
, C
), V
, T
, X
),
1749 propagation_multi_headed
(A
, B
, C
, D
, E
, F
, G
, H
, I
) :-
1751 propagation_prelude
(A
, B
, C
, F
, G
, H
, L
),
1753 propagation_nested_code
(K
, [J
, A
], C
, D
, E
, F
, M
, L
, I
).
1754 propagation_prelude
(A
, [B
|C
], D
, E
/F
, G
, H
, I
) :-
1755 head_info
(A
, F
, J
, K
, L
, M
),
1756 build_head
(E
, F
, G
, L
, N
),
1757 head_arg_matches
(M
, [], O
, P
),
1759 extra_active_delegate_variables
(A
, [B
, C
, S
, T
], P
, U
),
1760 lookup_passive_head
(B
, [A
], P
, V
, W
),
1761 gen_allocation
(G
, J
, K
, E
/F
, L
, X
),
1763 append
([W
|L
], U
, Z
),
1764 build_head
(E
, F
, Y
, Z
, A1
),
1766 C1
= (N
:-O
, V
, !, X
, B1
),
1768 propagation_nested_code
([], [A
|B
], C
, D
, E
, F
, G
, H
, I
) :-
1769 propagation_end
([A
|B
], [], C
, F
, G
, H
, J
),
1770 propagation_body
(A
, B
, C
, D
, E
, F
, G
, J
, I
).
1771 propagation_nested_code
([A
|B
], C
, D
, E
, F
, G
, H
, I
, J
) :-
1772 propagation_end
(C
, [A
|B
], D
, G
, H
, I
, K
),
1773 propagation_accumulator
([A
|B
], C
, D
, G
, H
, K
, L
),
1775 propagation_nested_code
(B
, [A
|C
], D
, E
, F
, G
, M
, L
, J
).
1776 propagation_body
(A
, B
, C
, D
, E
, F
/G
, H
, I
, J
) :-
1778 get_prop_inner_loop_vars
(B
, [A
, M
, N
], O
, P
, Q
, R
),
1783 X
=..[suspension
, Y
, Z
, A1
, B1
, C1
, D1
|W
],
1784 create_get_mutable
(active
, Z
, E1
),
1787 build_head
(F
, G
, H
, G1
, H1
),
1789 build_head
(F
, G
, H
, I1
, J1
),
1793 head_arg_matches
(N1
, P
, O1
, P1
),
1794 different_from_other_susps
(A
, S
, B
, R
, Q1
),
1795 guard_body_copies
(C
, P1
, R1
, S1
),
1796 gen_uncond_attach_goal
(F
/G
, Q
, T1
, U1
),
1797 gen_state_cond_call
(Q
, G
, K1
, U1
, V1
),
1798 history_susps
(E
, [S
|R
], Q
, [], W1
),
1799 bagof
('chr novel_production'(X1
, Y1
), (member
(X1
, W1
), Y1
=Z1
), A2
),
1802 ( chr_pp_flag
(debugable
, on
)
1803 -> C
=rule
(D2
, E2
, M
, N
),
1804 my_term_copy
(M
-N
, P1
, F2
, G2
-H2
),
1805 I2
='chr debug_event'(try
([], [Q
, S
|R
], G2
, H2
)),
1806 J2
='chr debug_event'(apply
([], [Q
, S
|R
], G2
, H2
))
1810 K2
= (H1
:-F1
, Q1
, O1
, Z1
=C2
, B2
, R1
, I2
->J2, 'chr extend_history'(Q
, Z1
), T1
, S1
, V1
;K1
),
1812 history_susps
(A
, B
, C
, D
, E
) :-
1818 history_susps
(I
, H
, C
, [G
|D
], E
)
1820 get_prop_inner_loop_vars
([A
], B
, C
, D
, E
, []) :- !,
1822 head_info
(A
, G
, H
, E
, I
, J
),
1823 head_arg_matches
(J
, [], K
, D
),
1824 extra_active_delegate_variables
(A
, B
, D
, L
),
1826 get_prop_inner_loop_vars
([A
|B
], C
, D
, E
, F
, [G
|H
]) :-
1827 get_prop_inner_loop_vars
(B
, [A
|C
], I
, J
, F
, H
),
1830 head_info
(A
, L
, N
, G
, O
, P
),
1831 head_arg_matches
(P
, J
, Q
, E
),
1832 passive_delegate_variables
(A
, B
, C
, E
, R
),
1833 append
(R
, [G
, M
|I
], D
).
1834 propagation_end
([A
|B
], C
, D
, E
/F
, G
, H
, I
) :-
1836 gen_var_susp_list_for
(B
, [A
, C
, L
, M
], N
, O
, P
, Q
),
1838 build_head
(E
, F
, G
, R
, S
),
1845 build_head
(E
, F
, U
, V
, W
),
1849 gen_var_susp_list_for
([A
], B
, C
, D
, E
, F
) :- !,
1851 head_info
(A
, H
, I
, F
, E
, J
),
1852 head_arg_matches
(J
, [], K
, C
),
1853 extra_active_delegate_variables
(A
, B
, C
, L
),
1855 gen_var_susp_list_for
([A
|B
], C
, D
, E
, F
, G
) :-
1856 gen_var_susp_list_for
(B
, [A
|C
], H
, F
, I
, J
),
1859 head_info
(A
, L
, M
, N
, O
, P
),
1860 head_arg_matches
(P
, H
, Q
, D
),
1861 passive_delegate_variables
(A
, B
, C
, D
, R
),
1862 append
(R
, [N
, G
|F
], E
).
1863 propagation_accumulator
([A
|B
], [C
|D
], E
, F
/G
, H
, I
, J
) :-
1865 pre_vars_and_susps
(D
, [C
, A
, B
, M
, N
], O
, P
, Q
),
1869 head_info
(C
, T
, U
, V
, W
, X
),
1870 head_arg_matches
(X
, P
, Y
, Z
),
1871 A1
=..[suspension
, B1
, C1
, D1
, E1
, F1
, G1
|U
],
1872 different_from_other_susps
(C
, V
, D
, Q
, H1
),
1873 create_get_mutable
(active
, C1
, I1
),
1874 J1
= (V
=A1
, I1
, H1
, Y
),
1875 lookup_passive_head
(A
, [C
|D
], Z
, K1
, L1
),
1878 build_head
(F
, G
, H
, N1
, O1
),
1879 passive_delegate_variables
(C
, D
, [A
, B
, M
, N
], Z
, P1
),
1880 append
([L1
|P1
], [V
, R
|O
], Q1
),
1881 build_head
(F
, G
, M1
, Q1
, R1
),
1883 build_head
(F
, G
, H
, S1
, T1
),
1884 U1
= (O1
:-J1
, K1
->R1;T1
),
1886 pre_vars_and_susps
([A
], B
, C
, D
, []) :- !,
1888 head_info
(A
, F
, G
, H
, I
, J
),
1889 head_arg_matches
(J
, [], K
, D
),
1890 extra_active_delegate_variables
(A
, B
, D
, L
),
1892 pre_vars_and_susps
([A
|B
], C
, D
, E
, [F
|G
]) :-
1893 pre_vars_and_susps
(B
, [A
|C
], H
, I
, G
),
1896 head_info
(A
, K
, M
, F
, N
, O
),
1897 head_arg_matches
(O
, I
, P
, E
),
1898 passive_delegate_variables
(A
, B
, C
, E
, Q
),
1899 append
(Q
, [F
, L
|H
], D
).
1900 reorder_heads
(A
, B
, C
, D
, E
, F
) :-
1901 ( chr_pp_flag
(reorder_heads
, on
)
1902 -> reorder_heads_main
(A
, B
, C
, D
, E
, F
)
1906 reorder_heads_main
(A
, B
, C
, D
, E
, F
) :-
1907 term_variables
(B
, G
),
1908 H
=entry
([], [], G
, C
, D
, A
),
1909 a_star
(H
, I
^ (chr_translate
:final_data
(I
)), J
^K
^L
^ (chr_translate
:expand_data
(J
, K
, L
)), M
),
1910 M
=entry
(N
, O
, P
, Q
, R
, S
),
1914 A
=entry
(B
, C
, D
, E
, [], F
).
1915 expand_data
(A
, B
, C
) :-
1916 A
=entry
(D
, E
, F
, G
, H
, I
),
1917 term_variables
(A
, J
),
1918 B
=entry
([K
|D
], [L
|E
], M
, N
, O
, I
),
1919 select2
(K
, L
, G
, H
, N
, O
),
1920 order_score
(K
, L
, F
, N
, I
, C
),
1921 term_variables
([K
|F
], M
).
1922 order_score
(A
, B
, C
, D
, E
, F
) :-
1924 get_store_type
(G
/H
, I
),
1925 order_score
(I
, A
, B
, C
, D
, E
, F
).
1926 order_score
(default, A
, B
, C
, D
, E
, F
) :-
1927 term_variables
(A
, G
),
1928 term_variables
(D
, H
),
1929 order_score_vars
(G
, C
, D
, 0, F
).
1930 order_score
(multi_hash
(A
), B
, C
, D
, E
, F
, G
) :-
1931 order_score_indexes
(A
, B
, D
, 0, G
).
1932 order_score
(global_ground
, A
, B
, C
, D
, E
, F
) :-
1934 ( get_pragma_unique
(E
, B
, I
),
1942 order_score
(multi_store
(A
), B
, C
, D
, E
, F
, G
) :-
1943 find_with_var_identity
(H
, t
(B
, D
, E
), (member
(I
, A
), chr_translate
:order_score
(I
, B
, C
, D
, E
, F
, H
)), J
),
1945 order_score_indexes
([], A
, B
, C
, C
) :-
1947 order_score_indexes
([A
|B
], C
, D
, E
, F
) :-
1948 multi_hash_key_args
(A
, C
, G
),
1949 ( forall
(H
, G
, hprolog
:memberchk_eq
(H
, D
))
1953 order_score_indexes
(B
, C
, D
, I
, F
).
1954 order_score_vars
([], A
, B
, C
, D
) :-
1959 order_score_vars
([A
|B
], C
, D
, E
, F
) :-
1960 ( memberchk_eq
(A
, C
)
1962 ; memberchk_eq
(A
, D
)
1966 order_score_vars
(B
, C
, D
, G
, F
).
1967 create_get_mutable
(A
, B
, C
) :-
1972 head_info
(A
, B
, C
, D
, E
, F
) :-
1973 vars_susp
(B
, C
, D
, E
),
1976 inc_id
([A
|B
], [C
|B
]) :-
1978 dec_id
([A
|B
], [C
|B
]) :-
1980 extend_id
(A
, [0|A
]).
1981 next_id
([A
, B
|C
], [D
|C
]) :-
1983 build_head
(A
, B
, C
, D
, E
) :-
1984 buildName
(A
, B
, C
, F
),
1986 buildName
(A
, B
, C
, D
) :-
1987 atom_concat
(A
, /, E
),
1988 atom_concat
(E
, B
, F
),
1989 buildName_
(C
, F
, D
).
1990 buildName_
([], A
, A
).
1991 buildName_
([A
|B
], C
, D
) :-
1992 buildName_
(B
, C
, E
),
1993 atom_concat
(E
, '__', F
),
1994 atom_concat
(F
, A
, D
).
1995 vars_susp
(A
, B
, C
, D
) :-
1998 make_attr
(A
, B
, C
, D
) :-
2004 and_pattern(A, B) :-
2009 conj2list(A, B, []).
2010 conj2list(A, B, C) :-
2014 conj2list
(A
, [A
|B
], B
).
2015 list2conj
([], true
).
2016 list2conj
([A
], B
) :- !,
2018 list2conj
([A
|B
], C
) :-
2024 list2disj
([], fail
).
2025 list2disj
([A
], B
) :- !,
2027 list2disj
([A
|B
], C
) :-
2033 atom_concat_list
([A
], A
) :- !.
2034 atom_concat_list
([A
|B
], C
) :-
2035 atom_concat_list
(B
, D
),
2036 atom_concat
(A
, D
, C
).
2037 make_name
(A
, B
/C
, D
) :-
2038 atom_concat_list
([A
, B
, /, C
], D
).
2040 set_elems
([A
|B
], A
) :-
2042 member2
([A
|B
], [C
|D
], A
-C
).
2043 member2
([A
|B
], [C
|D
], E
) :-
2045 select2
(A
, B
, [A
|C
], [B
|D
], C
, D
).
2046 select2
(A
, B
, [C
|D
], [E
|F
], [C
|G
], [E
|H
]) :-
2047 select2
(A
, B
, D
, F
, G
, H
).
2048 pair_all_with
([], A
, []).
2049 pair_all_with
([A
|B
], C
, [A
-C
|D
]) :-
2050 pair_all_with
(B
, C
, D
).
2051 lookup_passive_head
(A
, B
, C
, D
, E
) :-
2053 get_store_type
(F
/G
, H
),
2054 lookup_passive_head
(H
, A
, B
, C
, D
, E
).
2055 lookup_passive_head
(default, A
, B
, C
, D
, E
) :-
2056 passive_head_via
(A
, B
, [], C
, D
, F
, G
),
2057 instantiate_pattern_goals
(G
),
2058 get_max_constraint_index
(H
),
2062 get_constraint_index
(I
/J
, K
),
2063 make_attr
(H
, L
, M
, F
),
2066 lookup_passive_head
(multi_hash
(A
), B
, C
, D
, E
, F
) :-
2069 multi_hash_key_args
(G
, B
, H
),
2077 multi_hash_via_lookup_name
(K
/L
, G
, M
),
2079 update_store_type
(K
/L
, multi_hash
([G
])).
2080 lookup_passive_head
(global_ground
, A
, B
, C
, D
, E
) :-
2082 global_ground_store_name
(F
/G
, H
),
2084 update_store_type
(F
/G
, global_ground
).
2085 lookup_passive_head
(multi_store
(A
), B
, C
, D
, E
, F
) :-
2088 lookup_passive_head
(G
, B
, C
, D
, E
, F
)
2090 assume_constraint_stores
([]).
2091 assume_constraint_stores
([A
|B
]) :-
2094 get_store_type
(A
, default)
2095 -> get_indexed_arguments
(A
, C
),
2096 findall
(D
, (sublist
(D
, C
), D\
==[]), E
),
2097 assumed_store_type
(A
, multi_store
([multi_hash
(E
), global_ground
]))
2100 assume_constraint_stores
(B
).
2101 get_indexed_arguments
(A
, B
) :-
2103 get_indexed_arguments
(1, D
, A
, B
).
2104 get_indexed_arguments
(A
, B
, C
, D
) :-
2107 ; ( is_indexed_argument
(C
, A
)
2112 get_indexed_arguments
(F
, B
, C
, E
)
2114 validate_store_type_assumptions
([]).
2115 validate_store_type_assumptions
([A
|B
]) :-
2116 validate_store_type_assumption
(A
),
2117 validate_store_type_assumptions
(B
).
2118 attr_unify_hook
(A
, B
) :-
2119 write('ERROR: Unexpected triggering of attr_unify_hook/2 in module '),
2120 writeln
(chr_translate
).
2121 remove_constraint_internal
(A
, B
, C
) :-
2124 'chr update_mutable'(removed
, D
),
2132 chr_indexed_variables
(A
, B
)
2134 activate_constraint
(A
, B
, C
, D
) :-
2137 'chr update_mutable'(active
, E
),
2143 'chr update_mutable'(D
, G
)
2146 -> term_variables
(F
, B
),
2147 'chr none_locked'(B
),
2150 -> chr_indexed_variables
(C
, B
),
2155 allocate_constraint
(A
, B
, C
, D
) :-
2156 B
=..[suspension
, E
, F
, A
, G
, H
, C
|D
],
2158 'chr empty_history'(I
),
2160 chr_indexed_variables
(B
, J
),
2161 F
=mutable
(passive
(J
)),
2163 chr_indexed_variables
(A
, []).
2164 insert_constraint_internal
(yes
, A
, B
, C
, D
, E
) :-
2165 B
=..[suspension
, F
, G
, C
, H
, I
, D
|E
],
2166 chr_indexed_variables
(B
, A
),
2167 'chr none_locked'(A
),
2171 'chr empty_history'(J
),
2173 '$insert_in_store_constraint/2'(A
) :-
2175 nb_getval
('$chr_store_multi_hash_chr_translate:constraint/2-2', C
),
2178 '$delete_from_store_constraint/2'(A
) :-
2180 nb_getval
('$chr_store_multi_hash_chr_translate:constraint/2-2', C
),
2183 '$insert_in_store_constraint_count/1'(A
) :-
2184 nb_getval
('$chr_store_global_ground_chr_translate:constraint_count/1', B
),
2185 b_setval
('$chr_store_global_ground_chr_translate:constraint_count/1', [A
|B
]).
2186 '$delete_from_store_constraint_count/1'(A
) :-
2187 nb_getval
('$chr_store_global_ground_chr_translate:constraint_count/1', B
),
2188 'chr sbag_del_element'(B
, A
, C
),
2189 b_setval
('$chr_store_global_ground_chr_translate:constraint_count/1', C
).
2190 '$insert_in_store_constraint_index/2'(A
) :-
2192 nb_getval
('$chr_store_multi_hash_chr_translate:constraint_index/2-1', C
),
2195 '$delete_from_store_constraint_index/2'(A
) :-
2197 nb_getval
('$chr_store_multi_hash_chr_translate:constraint_index/2-1', C
),
2200 '$insert_in_store_max_constraint_index/1'(A
) :-
2201 nb_getval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', B
),
2202 b_setval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', [A
|B
]).
2203 '$delete_from_store_max_constraint_index/1'(A
) :-
2204 nb_getval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', B
),
2205 'chr sbag_del_element'(B
, A
, C
),
2206 b_setval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', C
).
2207 '$insert_in_store_target_module/1'(A
) :-
2208 nb_getval
('$chr_store_global_ground_chr_translate:target_module/1', B
),
2209 b_setval
('$chr_store_global_ground_chr_translate:target_module/1', [A
|B
]).
2210 '$delete_from_store_target_module/1'(A
) :-
2211 nb_getval
('$chr_store_global_ground_chr_translate:target_module/1', B
),
2212 'chr sbag_del_element'(B
, A
, C
),
2213 b_setval
('$chr_store_global_ground_chr_translate:target_module/1', C
).
2214 '$insert_in_store_attached/2'(A
) :-
2216 nb_getval
('$chr_store_multi_hash_chr_translate:attached/2-1', C
),
2219 '$delete_from_store_attached/2'(A
) :-
2221 nb_getval
('$chr_store_multi_hash_chr_translate:attached/2-1', C
),
2224 '$insert_in_store_indexed_argument/2'(A
) :-
2227 nb_getval
('$chr_store_multi_hash_chr_translate:indexed_argument/2-12', D
),
2228 insert_ht
(D
, k
(B
, C
), A
),
2230 '$delete_from_store_indexed_argument/2'(A
) :-
2233 nb_getval
('$chr_store_multi_hash_chr_translate:indexed_argument/2-12', D
),
2234 delete_ht
(D
, k
(B
, C
), A
),
2236 '$insert_in_store_constraint_mode/2'(A
) :-
2238 nb_getval
('$chr_store_multi_hash_chr_translate:constraint_mode/2-1', C
),
2241 '$delete_from_store_constraint_mode/2'(A
) :-
2243 nb_getval
('$chr_store_multi_hash_chr_translate:constraint_mode/2-1', C
),
2246 '$insert_in_store_store_type/2'(A
) :-
2248 nb_getval
('$chr_store_multi_hash_chr_translate:store_type/2-1', C
),
2251 '$delete_from_store_store_type/2'(A
) :-
2253 nb_getval
('$chr_store_multi_hash_chr_translate:store_type/2-1', C
),
2256 '$insert_in_store_actual_store_types/2'(A
) :-
2258 nb_getval
('$chr_store_multi_hash_chr_translate:actual_store_types/2-1', C
),
2261 '$delete_from_store_actual_store_types/2'(A
) :-
2263 nb_getval
('$chr_store_multi_hash_chr_translate:actual_store_types/2-1', C
),
2266 '$insert_in_store_assumed_store_type/2'(A
) :-
2268 nb_getval
('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1', C
),
2271 '$delete_from_store_assumed_store_type/2'(A
) :-
2273 nb_getval
('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1', C
),
2276 '$insert_in_store_rule_count/1'(A
) :-
2277 nb_getval
('$chr_store_global_ground_chr_translate:rule_count/1', B
),
2278 b_setval
('$chr_store_global_ground_chr_translate:rule_count/1', [A
|B
]).
2279 '$delete_from_store_rule_count/1'(A
) :-
2280 nb_getval
('$chr_store_global_ground_chr_translate:rule_count/1', B
),
2281 'chr sbag_del_element'(B
, A
, C
),
2282 b_setval
('$chr_store_global_ground_chr_translate:rule_count/1', C
).
2283 '$insert_in_store_passive/2'(A
) :-
2285 nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-1', C
),
2290 nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-12', F
),
2291 insert_ht
(F
, k
(D
, E
), A
),
2293 '$delete_from_store_passive/2'(A
) :-
2295 nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-1', C
),
2300 nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-12', F
),
2301 delete_ht
(F
, k
(D
, E
), A
),
2303 '$insert_in_store_pragma_unique/3'(A
) :-
2306 nb_getval
('$chr_store_multi_hash_chr_translate:pragma_unique/3-12', D
),
2307 insert_ht
(D
, k
(B
, C
), A
),
2309 '$delete_from_store_pragma_unique/3'(A
) :-
2312 nb_getval
('$chr_store_multi_hash_chr_translate:pragma_unique/3-12', D
),
2313 delete_ht
(D
, k
(B
, C
), A
),
2315 '$insert_in_store_occurrence/4'(A
) :-
2317 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-3', C
),
2321 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-2', E
),
2328 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-1234', J
),
2329 insert_ht
(J
, k
(F
, G
, H
, I
), A
),
2331 '$delete_from_store_occurrence/4'(A
) :-
2333 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-3', C
),
2337 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-2', E
),
2344 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-1234', J
),
2345 delete_ht
(J
, k
(F
, G
, H
, I
), A
),
2347 '$insert_in_store_max_occurrence/2'(A
) :-
2349 nb_getval
('$chr_store_multi_hash_chr_translate:max_occurrence/2-1', C
),
2352 '$delete_from_store_max_occurrence/2'(A
) :-
2354 nb_getval
('$chr_store_multi_hash_chr_translate:max_occurrence/2-1', C
),
2357 '$insert_in_store_allocation_occurrence/2'(A
) :-
2359 nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1', C
),
2364 nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-12', F
),
2365 insert_ht
(F
, k
(D
, E
), A
),
2367 nb_getval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', G
),
2368 b_setval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', [A
|G
]).
2369 '$delete_from_store_allocation_occurrence/2'(A
) :-
2371 nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1', C
),
2376 nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-12', F
),
2377 delete_ht
(F
, k
(D
, E
), A
),
2379 nb_getval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', G
),
2380 'chr sbag_del_element'(G
, A
, H
),
2381 b_setval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', H
).
2382 '$insert_in_store_rule/2'(A
) :-
2384 nb_getval
('$chr_store_multi_hash_chr_translate:rule/2-1', C
),
2387 '$delete_from_store_rule/2'(A
) :-
2389 nb_getval
('$chr_store_multi_hash_chr_translate:rule/2-1', C
),
2392 '$enumerate_suspensions'(A
) :-
2393 ( nb_getval
('$chr_store_multi_hash_chr_translate:constraint/2-2', B
),
2395 ; nb_getval
('$chr_store_global_ground_chr_translate:constraint_count/1', C
),
2396 'chr sbag_member'(A
, C
)
2397 ; nb_getval
('$chr_store_multi_hash_chr_translate:constraint_index/2-1', D
),
2399 ; nb_getval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', E
),
2400 'chr sbag_member'(A
, E
)
2401 ; nb_getval
('$chr_store_global_ground_chr_translate:target_module/1', F
),
2402 'chr sbag_member'(A
, F
)
2403 ; nb_getval
('$chr_store_multi_hash_chr_translate:attached/2-1', G
),
2405 ; nb_getval
('$chr_store_multi_hash_chr_translate:indexed_argument/2-12', H
),
2407 ; nb_getval
('$chr_store_multi_hash_chr_translate:constraint_mode/2-1', I
),
2409 ; nb_getval
('$chr_store_multi_hash_chr_translate:store_type/2-1', J
),
2411 ; nb_getval
('$chr_store_multi_hash_chr_translate:actual_store_types/2-1', K
),
2413 ; nb_getval
('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1', L
),
2415 ; nb_getval
('$chr_store_global_ground_chr_translate:rule_count/1', M
),
2416 'chr sbag_member'(A
, M
)
2417 ; nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-1', N
),
2419 ; nb_getval
('$chr_store_multi_hash_chr_translate:pragma_unique/3-12', O
),
2421 ; nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-3', P
),
2423 ; nb_getval
('$chr_store_multi_hash_chr_translate:max_occurrence/2-1', Q
),
2425 ; nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1', R
),
2427 ; nb_getval
('$chr_store_multi_hash_chr_translate:rule/2-1', S
),
2430 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:constraint/2-2', A
).
2431 '$via1_multi_hash_constraint/2-2'(A
, B
) :-
2432 nb_getval
('$chr_store_multi_hash_chr_translate:constraint/2-2', C
),
2434 :-nb_setval
('$chr_store_global_ground_chr_translate:constraint_count/1', []).
2435 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:constraint_index/2-1', A
).
2436 '$via1_multi_hash_constraint_index/2-1'(A
, B
) :-
2437 nb_getval
('$chr_store_multi_hash_chr_translate:constraint_index/2-1', C
),
2439 :-nb_setval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', []).
2440 :-nb_setval
('$chr_store_global_ground_chr_translate:target_module/1', []).
2441 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:attached/2-1', A
).
2442 '$via1_multi_hash_attached/2-1'(A
, B
) :-
2443 nb_getval
('$chr_store_multi_hash_chr_translate:attached/2-1', C
),
2445 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:indexed_argument/2-12', A
).
2446 '$via1_multi_hash_indexed_argument/2-12'(A
, B
) :-
2447 nb_getval
('$chr_store_multi_hash_chr_translate:indexed_argument/2-12', C
),
2449 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:constraint_mode/2-1', A
).
2450 '$via1_multi_hash_constraint_mode/2-1'(A
, B
) :-
2451 nb_getval
('$chr_store_multi_hash_chr_translate:constraint_mode/2-1', C
),
2453 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:store_type/2-1', A
).
2454 '$via1_multi_hash_store_type/2-1'(A
, B
) :-
2455 nb_getval
('$chr_store_multi_hash_chr_translate:store_type/2-1', C
),
2457 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:actual_store_types/2-1', A
).
2458 '$via1_multi_hash_actual_store_types/2-1'(A
, B
) :-
2459 nb_getval
('$chr_store_multi_hash_chr_translate:actual_store_types/2-1', C
),
2461 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1', A
).
2462 '$via1_multi_hash_assumed_store_type/2-1'(A
, B
) :-
2463 nb_getval
('$chr_store_multi_hash_chr_translate:assumed_store_type/2-1', C
),
2465 :-nb_setval
('$chr_store_global_ground_chr_translate:rule_count/1', []).
2466 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:passive/2-1', A
).
2467 '$via1_multi_hash_passive/2-1'(A
, B
) :-
2468 nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-1', C
),
2470 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:passive/2-12', A
).
2471 '$via1_multi_hash_passive/2-12'(A
, B
) :-
2472 nb_getval
('$chr_store_multi_hash_chr_translate:passive/2-12', C
),
2474 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:pragma_unique/3-12', A
).
2475 '$via1_multi_hash_pragma_unique/3-12'(A
, B
) :-
2476 nb_getval
('$chr_store_multi_hash_chr_translate:pragma_unique/3-12', C
),
2478 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:occurrence/4-3', A
).
2479 '$via1_multi_hash_occurrence/4-3'(A
, B
) :-
2480 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-3', C
),
2482 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:occurrence/4-2', A
).
2483 '$via1_multi_hash_occurrence/4-2'(A
, B
) :-
2484 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-2', C
),
2486 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:occurrence/4-1234', A
).
2487 '$via1_multi_hash_occurrence/4-1234'(A
, B
) :-
2488 nb_getval
('$chr_store_multi_hash_chr_translate:occurrence/4-1234', C
),
2490 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:max_occurrence/2-1', A
).
2491 '$via1_multi_hash_max_occurrence/2-1'(A
, B
) :-
2492 nb_getval
('$chr_store_multi_hash_chr_translate:max_occurrence/2-1', C
),
2494 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1', A
).
2495 '$via1_multi_hash_allocation_occurrence/2-1'(A
, B
) :-
2496 nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-1', C
),
2498 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-12', A
).
2499 '$via1_multi_hash_allocation_occurrence/2-12'(A
, B
) :-
2500 nb_getval
('$chr_store_multi_hash_chr_translate:allocation_occurrence/2-12', C
),
2502 :-nb_setval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', []).
2503 :-new_ht
(A
), nb_setval
('$chr_store_multi_hash_chr_translate:rule/2-1', A
).
2504 '$via1_multi_hash_rule/2-1'(A
, B
) :-
2505 nb_getval
('$chr_store_multi_hash_chr_translate:rule/2-1', C
),
2508 'constraint/2__0'(A
, B
, C
).
2509 'constraint/2__0'(A
, B
, C
) :-
2510 insert_constraint_internal
(D
, E
, C
, chr_translate
:'constraint/2__0'(A
, B
, C
), constraint
(A
, B
), [A
, B
]),
2511 '$insert_in_store_constraint/2'(C
).
2512 get_constraint
(A
, B
) :-
2513 'get_constraint/2__0'(A
, B
, C
).
2514 'get_constraint/2__0'(A
, B
, C
) :-
2515 '$via1_multi_hash_constraint/2-2'(B
, D
),
2516 'chr sbag_member'(E
, D
),
2517 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2521 'get_constraint/2__0'(A
, B
, C
) :- !,
2523 constraint_count
(A
) :-
2524 'constraint_count/1__0'(A
, B
).
2525 'constraint_count/1__0'(A
, B
) :-
2526 insert_constraint_internal
(C
, D
, B
, chr_translate
:'constraint_count/1__0'(A
, B
), constraint_count
(A
), [A
]),
2527 '$insert_in_store_constraint_count/1'(B
).
2528 get_constraint_count
(A
) :-
2529 'get_constraint_count/1__0'(A
, B
).
2530 'get_constraint_count/1__0'(A
, B
) :-
2531 nb_getval
('$chr_store_global_ground_chr_translate:constraint_count/1', C
),
2532 'chr sbag_member'(D
, C
),
2533 D
=suspension
(E
, F
, G
, H
, I
, J
, K
),
2534 F
=mutable
(active
), !,
2536 'get_constraint_count/1__0'(A
, B
) :- !,
2538 constraint_index
(A
, B
) :-
2539 'constraint_index/2__0'(A
, B
, C
).
2540 'constraint_index/2__0'(A
, B
, C
) :-
2541 insert_constraint_internal
(D
, E
, C
, chr_translate
:'constraint_index/2__0'(A
, B
, C
), constraint_index
(A
, B
), [A
, B
]),
2542 '$insert_in_store_constraint_index/2'(C
).
2543 get_constraint_index
(A
, B
) :-
2544 'get_constraint_index/2__0'(A
, B
, C
).
2545 'get_constraint_index/2__0'(A
, B
, C
) :-
2546 '$via1_multi_hash_constraint_index/2-1'(A
, D
),
2547 'chr sbag_member'(E
, D
),
2548 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2552 'get_constraint_index/2__0'(A
, B
, C
) :- !,
2554 max_constraint_index
(A
) :-
2555 'max_constraint_index/1__0'(A
, B
).
2556 'max_constraint_index/1__0'(A
, B
) :-
2557 insert_constraint_internal
(C
, D
, B
, chr_translate
:'max_constraint_index/1__0'(A
, B
), max_constraint_index
(A
), [A
]),
2558 '$insert_in_store_max_constraint_index/1'(B
).
2559 get_max_constraint_index
(A
) :-
2560 'get_max_constraint_index/1__0'(A
, B
).
2561 'get_max_constraint_index/1__0'(A
, B
) :-
2562 nb_getval
('$chr_store_global_ground_chr_translate:max_constraint_index/1', C
),
2563 'chr sbag_member'(D
, C
),
2564 D
=suspension
(E
, F
, G
, H
, I
, J
, K
),
2565 F
=mutable
(active
), !,
2567 'get_max_constraint_index/1__0'(A
, B
) :- !,
2570 'target_module/1__0'(A
, B
).
2571 'target_module/1__0'(A
, B
) :-
2572 insert_constraint_internal
(C
, D
, B
, chr_translate
:'target_module/1__0'(A
, B
), target_module
(A
), [A
]),
2573 '$insert_in_store_target_module/1'(B
).
2574 get_target_module
(A
) :-
2575 'get_target_module/1__0'(A
, B
).
2576 'get_target_module/1__0'(A
, B
) :-
2577 nb_getval
('$chr_store_global_ground_chr_translate:target_module/1', C
),
2578 'chr sbag_member'(D
, C
),
2579 D
=suspension
(E
, F
, G
, H
, I
, J
, K
),
2580 F
=mutable
(active
), !,
2582 'get_target_module/1__0'(A
, B
) :- !,
2585 'attached/2__0'(A
, B
, C
).
2586 'attached/2__0'(A
, B
, C
) :-
2587 '$via1_multi_hash_attached/2-1'(A
, D
),
2588 'chr sbag_member'(E
, D
),
2589 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2593 'attached/2__0'(A
, B
, C
) :-
2595 '$via1_multi_hash_attached/2-1'(A
, D
), !,
2596 allocate_constraint
(chr_translate
:'attached/2__0'(A
, B
, C
), C
, attached
(A
, B
), [A
, B
]),
2597 'attached/2__0__0'(D
, A
, B
, C
).
2598 'attached/2__0__0'([], A
, B
, C
) :-
2599 'attached/2__1'(A
, B
, C
).
2600 'attached/2__0__0'([A
|B
], C
, D
, E
) :-
2601 ( A
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2604 -> remove_constraint_internal
(A
, N
, O
),
2606 -> '$delete_from_store_attached/2'(A
)
2609 'attached/2__0__0'(B
, C
, D
, E
)
2610 ; 'attached/2__0__0'(B
, C
, D
, E
)
2612 'attached/2__0'(A
, B
, C
) :-
2613 allocate_constraint
(chr_translate
:'attached/2__0'(A
, B
, C
), C
, attached
(A
, B
), [A
, B
]),
2614 'attached/2__1'(A
, B
, C
).
2615 'attached/2__1'(A
, B
, C
) :-
2616 '$via1_multi_hash_attached/2-1'(A
, D
),
2617 'chr sbag_member'(E
, D
),
2618 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2624 ; remove_constraint_internal
(C
, N
, O
),
2626 -> '$delete_from_store_attached/2'(C
)
2630 'attached/2__1'(A
, B
, C
) :-
2632 '$via1_multi_hash_attached/2-1'(A
, D
), !,
2633 'attached/2__1__0'(D
, A
, B
, C
).
2634 'attached/2__1__0'([], A
, B
, C
) :-
2635 'attached/2__2'(A
, B
, C
).
2636 'attached/2__1__0'([A
|B
], C
, D
, E
) :-
2637 ( A
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2640 -> remove_constraint_internal
(A
, N
, O
),
2642 -> '$delete_from_store_attached/2'(A
)
2645 'attached/2__1__0'(B
, C
, D
, E
)
2646 ; 'attached/2__1__0'(B
, C
, D
, E
)
2648 'attached/2__1'(A
, B
, C
) :-
2649 'attached/2__2'(A
, B
, C
).
2650 'attached/2__2'(A
, B
, C
) :-
2652 '$via1_multi_hash_attached/2-1'(A
, D
),
2653 ( 'chr sbag_member'(E
, D
),
2654 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2662 ; remove_constraint_internal
(C
, N
, O
),
2664 -> '$delete_from_store_attached/2'(C
)
2668 'attached/2__2'(A
, B
, C
) :-
2669 activate_constraint
(D
, E
, C
, F
),
2671 -> '$insert_in_store_attached/2'(C
)
2675 'is_attached/1__0'(A
, B
).
2676 'is_attached/1__0'(A
, B
) :-
2677 '$via1_multi_hash_attached/2-1'(A
, C
),
2678 'chr sbag_member'(D
, C
),
2679 D
=suspension
(E
, F
, G
, H
, I
, J
, K
, L
),
2683 'is_attached/1__0'(A
, B
) :- !.
2684 indexed_argument
(A
, B
) :-
2685 'indexed_argument/2__0'(A
, B
, C
).
2686 'indexed_argument/2__0'(A
, B
, C
) :-
2687 '$via1_multi_hash_indexed_argument/2-12'(k
(A
, B
), D
),
2688 ( 'chr sbag_member'(E
, D
),
2689 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2695 'indexed_argument/2__0'(A
, B
, C
) :-
2696 insert_constraint_internal
(D
, E
, C
, chr_translate
:'indexed_argument/2__0'(A
, B
, C
), indexed_argument
(A
, B
), [A
, B
]),
2697 '$insert_in_store_indexed_argument/2'(C
).
2698 is_indexed_argument
(A
, B
) :-
2699 'is_indexed_argument/2__0'(A
, B
, C
).
2700 'is_indexed_argument/2__0'(A
, B
, C
) :-
2701 '$via1_multi_hash_indexed_argument/2-12'(k
(A
, B
), D
),
2702 ( 'chr sbag_member'(E
, D
),
2703 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2709 'is_indexed_argument/2__0'(A
, B
, C
) :- !,
2711 constraint_mode
(A
, B
) :-
2712 'constraint_mode/2__0'(A
, B
, C
).
2713 'constraint_mode/2__0'(A
, B
, C
) :-
2714 insert_constraint_internal
(D
, E
, C
, chr_translate
:'constraint_mode/2__0'(A
, B
, C
), constraint_mode
(A
, B
), [A
, B
]),
2715 '$insert_in_store_constraint_mode/2'(C
).
2716 get_constraint_mode
(A
, B
) :-
2717 'get_constraint_mode/2__0'(A
, B
, C
).
2718 'get_constraint_mode/2__0'(A
, B
, C
) :-
2719 '$via1_multi_hash_constraint_mode/2-1'(A
, D
),
2720 'chr sbag_member'(E
, D
),
2721 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2725 'get_constraint_mode/2__0'(A
, B
, C
) :- !,
2730 'may_trigger/1__0'(A
, B
).
2731 'may_trigger/1__0'(A
, B
) :- !,
2733 get_constraint_mode
(A
, C
),
2734 has_nonground_indexed_argument
(A
, 1, C
).
2735 has_nonground_indexed_argument
(A
, B
, C
) :-
2736 'has_nonground_indexed_argument/3__0'(A
, B
, C
, D
).
2737 'has_nonground_indexed_argument/3__0'(A
, B
, C
, D
) :-
2740 ( is_indexed_argument
(A
, B
),
2744 has_nonground_indexed_argument
(A
, G
, F
)
2746 'has_nonground_indexed_argument/3__0'(A
, B
, C
, D
) :- !,
2749 'store_type/2__0'(A
, B
, C
).
2750 'store_type/2__0'(A
, B
, C
) :-
2753 store_type
(A
, multi_hash
([D
])).
2754 'store_type/2__0'(A
, B
, C
) :-
2755 insert_constraint_internal
(D
, E
, C
, chr_translate
:'store_type/2__0'(A
, B
, C
), store_type
(A
, B
), [A
, B
]),
2756 '$insert_in_store_store_type/2'(C
).
2757 get_store_type
(A
, B
) :-
2758 'get_store_type/2__0'(A
, B
, C
).
2759 'get_store_type/2__0'(A
, B
, C
) :-
2760 '$via1_multi_hash_store_type/2-1'(A
, D
),
2761 'chr sbag_member'(E
, D
),
2762 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2766 'get_store_type/2__0'(A
, B
, C
) :-
2767 '$via1_multi_hash_assumed_store_type/2-1'(A
, D
),
2768 'chr sbag_member'(E
, D
),
2769 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2773 'get_store_type/2__0'(A
, B
, C
) :- !,
2775 update_store_type
(A
, B
) :-
2776 'update_store_type/2__0'(A
, B
, C
).
2777 'update_store_type/2__0'(A
, B
, C
) :-
2778 '$via1_multi_hash_actual_store_types/2-1'(A
, D
),
2779 'chr sbag_member'(E
, D
),
2780 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2786 'update_store_type/2__0'(A
, B
, C
) :-
2787 '$via1_multi_hash_actual_store_types/2-1'(A
, D
),
2788 'chr sbag_member'(E
, D
),
2789 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2792 remove_constraint_internal
(E
, N
, O
),
2794 -> '$delete_from_store_actual_store_types/2'(E
)
2797 actual_store_types
(A
, [B
|M
]).
2798 'update_store_type/2__0'(A
, B
, C
) :- !,
2799 actual_store_types
(A
, [B
]).
2800 actual_store_types
(A
, B
) :-
2801 'actual_store_types/2__0'(A
, B
, C
).
2802 'actual_store_types/2__0'(A
, B
, C
) :-
2803 insert_constraint_internal
(D
, E
, C
, chr_translate
:'actual_store_types/2__0'(A
, B
, C
), actual_store_types
(A
, B
), [A
, B
]),
2804 '$insert_in_store_actual_store_types/2'(C
).
2805 assumed_store_type
(A
, B
) :-
2806 'assumed_store_type/2__0'(A
, B
, C
).
2807 'assumed_store_type/2__0'(A
, B
, C
) :-
2808 insert_constraint_internal
(D
, E
, C
, chr_translate
:'assumed_store_type/2__0'(A
, B
, C
), assumed_store_type
(A
, B
), [A
, B
]),
2809 '$insert_in_store_assumed_store_type/2'(C
).
2810 validate_store_type_assumption
(A
) :-
2811 'validate_store_type_assumption/1__0'(A
, B
).
2812 'validate_store_type_assumption/1__0'(A
, B
) :-
2813 '$via1_multi_hash_assumed_store_type/2-1'(A
, C
),
2814 '$via1_multi_hash_actual_store_types/2-1'(A
, D
),
2815 'chr sbag_member'(E
, D
),
2816 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2819 'chr sbag_member'(N
, C
),
2820 N
=suspension
(O
, P
, Q
, R
, S
, T
, U
, V
),
2823 remove_constraint_internal
(E
, W
, X
),
2825 -> '$delete_from_store_actual_store_types/2'(E
)
2828 remove_constraint_internal
(N
, Y
, Z
),
2830 -> '$delete_from_store_assumed_store_type/2'(N
)
2833 store_type
(A
, multi_store
(M
)).
2834 'validate_store_type_assumption/1__0'(A
, B
) :-
2835 '$via1_multi_hash_store_type/2-1'(A
, C
),
2836 '$via1_multi_hash_actual_store_types/2-1'(A
, D
),
2837 'chr sbag_member'(E
, D
),
2838 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2841 'chr sbag_member'(N
, C
),
2842 N
=suspension
(O
, P
, Q
, R
, S
, T
, U
, V
),
2845 remove_constraint_internal
(E
, W
, X
),
2847 -> '$delete_from_store_actual_store_types/2'(E
)
2850 remove_constraint_internal
(N
, Y
, Z
),
2852 -> '$delete_from_store_store_type/2'(N
)
2855 store_type
(A
, multi_store
(M
)).
2856 'validate_store_type_assumption/1__0'(A
, B
) :- !.
2858 'rule_count/1__0'(A
, B
).
2859 'rule_count/1__0'(A
, B
) :-
2860 insert_constraint_internal
(C
, D
, B
, chr_translate
:'rule_count/1__0'(A
, B
), rule_count
(A
), [A
]),
2861 '$insert_in_store_rule_count/1'(B
).
2862 inc_rule_count
(A
) :-
2863 'inc_rule_count/1__0'(A
, B
).
2864 'inc_rule_count/1__0'(A
, B
) :-
2865 nb_getval
('$chr_store_global_ground_chr_translate:rule_count/1', C
),
2866 'chr sbag_member'(D
, C
),
2867 D
=suspension
(E
, F
, G
, H
, I
, J
, K
),
2868 F
=mutable
(active
), !,
2869 remove_constraint_internal
(D
, L
, M
),
2871 -> '$delete_from_store_rule_count/1'(D
)
2876 'inc_rule_count/1__0'(A
, B
) :- !,
2879 get_rule_count
(A
) :-
2880 'get_rule_count/1__0'(A
, B
).
2881 'get_rule_count/1__0'(A
, B
) :-
2882 nb_getval
('$chr_store_global_ground_chr_translate:rule_count/1', C
),
2883 'chr sbag_member'(D
, C
),
2884 D
=suspension
(E
, F
, G
, H
, I
, J
, K
),
2885 F
=mutable
(active
), !,
2887 'get_rule_count/1__0'(A
, B
) :- !,
2890 'passive/2__0'(A
, B
, C
).
2891 'passive/2__0'(A
, B
, C
) :-
2892 nb_getval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', D
), !,
2893 allocate_constraint
(chr_translate
:'passive/2__0'(A
, B
, C
), C
, passive
(A
, B
), [A
, B
]),
2894 'passive/2__0__0'(D
, A
, B
, C
).
2895 'passive/2__0__0'([], A
, B
, C
) :-
2896 'passive/2__1'(A
, B
, C
).
2897 'passive/2__0__0'([A
|B
], C
, D
, E
) :-
2898 ( A
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2900 '$via1_multi_hash_occurrence/4-1234'(k
(L
, M
, C
, D
), N
),
2901 'chr sbag_member'(O
, N
),
2902 O
=suspension
(P
, Q
, R
, S
, T
, U
, V
, W
, X
, Y
),
2908 -> remove_constraint_internal
(A
, Z
, A1
),
2910 -> '$delete_from_store_allocation_occurrence/2'(A
)
2913 activate_constraint
(B1
, C1
, E
, D1
),
2915 -> '$insert_in_store_passive/2'(E
)
2919 allocation_occurrence
(L
, E1
),
2920 ( E
=suspension
(F1
, G1
, H1
, I1
, J1
, K1
, L1
, M1
),
2923 -> 'chr update_mutable'(inactive
, G1
),
2924 'passive/2__0__0'(B
, C
, D
, E
)
2927 ; 'passive/2__0__0'(B
, C
, D
, E
)
2929 'passive/2__0'(A
, B
, C
) :-
2930 allocate_constraint
(chr_translate
:'passive/2__0'(A
, B
, C
), C
, passive
(A
, B
), [A
, B
]),
2931 'passive/2__1'(A
, B
, C
).
2932 'passive/2__1'(A
, B
, C
) :-
2933 activate_constraint
(D
, E
, C
, F
),
2935 -> '$insert_in_store_passive/2'(C
)
2939 'is_passive/2__0'(A
, B
, C
).
2940 'is_passive/2__0'(A
, B
, C
) :-
2941 '$via1_multi_hash_passive/2-12'(k
(A
, B
), D
),
2942 'chr sbag_member'(E
, D
),
2943 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
2947 'is_passive/2__0'(A
, B
, C
) :- !,
2949 any_passive_head
(A
) :-
2950 'any_passive_head/1__0'(A
, B
).
2951 'any_passive_head/1__0'(A
, B
) :-
2952 '$via1_multi_hash_passive/2-1'(A
, C
),
2953 'chr sbag_member'(D
, C
),
2954 D
=suspension
(E
, F
, G
, H
, I
, J
, K
, L
),
2957 'any_passive_head/1__0'(A
, B
) :- !,
2959 pragma_unique
(A
, B
, C
) :-
2960 'pragma_unique/3__0'(A
, B
, C
, D
).
2961 'pragma_unique/3__0'(A
, B
, C
, D
) :-
2962 insert_constraint_internal
(E
, F
, D
, chr_translate
:'pragma_unique/3__0'(A
, B
, C
, D
), pragma_unique
(A
, B
, C
), [A
, B
, C
]),
2963 '$insert_in_store_pragma_unique/3'(D
).
2964 get_pragma_unique
(A
, B
, C
) :-
2965 'get_pragma_unique/3__0'(A
, B
, C
, D
).
2966 'get_pragma_unique/3__0'(A
, B
, C
, D
) :-
2967 '$via1_multi_hash_pragma_unique/3-12'(k
(A
, B
), E
),
2968 'chr sbag_member'(F
, E
),
2969 F
=suspension
(G
, H
, I
, J
, K
, L
, M
, N
, O
),
2974 'get_pragma_unique/3__0'(A
, B
, C
, D
) :- !.
2975 occurrence
(A
, B
, C
, D
) :-
2976 'occurrence/4__0'(A
, B
, C
, D
, E
).
2977 'occurrence/4__0'(A
, B
, C
, D
, E
) :-
2978 allocate_constraint
(chr_translate
:'occurrence/4__0'(A
, B
, C
, D
, E
), E
, occurrence
(A
, B
, C
, D
), [A
, B
, C
, D
]),
2979 'chr novel_production'(E
, 46), !,
2980 'chr extend_history'(E
, 46),
2981 activate_constraint
(F
, G
, E
, H
),
2983 -> '$insert_in_store_occurrence/4'(E
)
2986 max_occurrence
(A
, B
),
2987 ( E
=suspension
(I
, J
, K
, L
, M
, N
, O
, P
, Q
, R
),
2990 -> 'chr update_mutable'(inactive
, J
),
2991 'occurrence/4__1'(A
, B
, C
, D
, E
)
2994 'occurrence/4__0'(A
, B
, C
, D
, E
) :-
2995 allocate_constraint
(chr_translate
:'occurrence/4__0'(A
, B
, C
, D
, E
), E
, occurrence
(A
, B
, C
, D
), [A
, B
, C
, D
]),
2996 'occurrence/4__1'(A
, B
, C
, D
, E
).
2997 'occurrence/4__1'(A
, B
, C
, D
, E
) :-
2998 '$via1_multi_hash_allocation_occurrence/2-12'(k
(A
, B
), F
), !,
2999 'occurrence/4__1__0'(F
, A
, B
, C
, D
, E
).
3000 'occurrence/4__1__0'([], A
, B
, C
, D
, E
) :-
3001 'occurrence/4__2'(A
, B
, C
, D
, E
).
3002 'occurrence/4__1__0'([A
|B
], C
, D
, E
, F
, G
) :-
3003 ( A
=suspension
(H
, I
, J
, K
, L
, M
, N
, O
),
3007 '$via1_multi_hash_rule/2-1'(E
, P
),
3008 'chr sbag_member'(Q
, P
),
3009 Q
=suspension
(R
, S
, T
, U
, V
, W
, X
, Y
),
3013 Y
=pragma
(Z
, ids
(A1
, B1
), C1
, D1
, E1
),
3016 -> remove_constraint_internal
(A
, G1
, H1
),
3018 -> '$delete_from_store_allocation_occurrence/2'(A
)
3021 activate_constraint
(I1
, J1
, G
, K1
),
3023 -> '$insert_in_store_occurrence/4'(G
)
3027 allocation_occurrence
(C
, L1
),
3028 ( G
=suspension
(M1
, N1
, O1
, P1
, Q1
, R1
, S1
, T1
, U1
, V1
),
3031 -> 'chr update_mutable'(inactive
, N1
),
3032 'occurrence/4__1__0'(B
, C
, D
, E
, F
, G
)
3035 ; 'occurrence/4__1__0'(B
, C
, D
, E
, F
, G
)
3037 'occurrence/4__1'(A
, B
, C
, D
, E
) :-
3038 'occurrence/4__2'(A
, B
, C
, D
, E
).
3039 'occurrence/4__2'(A
, B
, C
, D
, E
) :-
3040 '$via1_multi_hash_allocation_occurrence/2-12'(k
(A
, B
), F
), !,
3041 'occurrence/4__2__0'(F
, A
, B
, C
, D
, E
).
3042 'occurrence/4__2__0'([], A
, B
, C
, D
, E
) :-
3043 'occurrence/4__3'(A
, B
, C
, D
, E
).
3044 'occurrence/4__2__0'([A
|B
], C
, D
, E
, F
, G
) :-
3045 ( A
=suspension
(H
, I
, J
, K
, L
, M
, N
, O
),
3049 '$via1_multi_hash_rule/2-1'(E
, P
),
3050 'chr sbag_member'(Q
, P
),
3051 Q
=suspension
(R
, S
, T
, U
, V
, W
, X
, Y
),
3055 Y
=pragma
(rule
(Z
, A1
, B1
, true
), C1
, D1
, E1
, F1
),
3057 -> remove_constraint_internal
(A
, G1
, H1
),
3059 -> '$delete_from_store_allocation_occurrence/2'(A
)
3062 activate_constraint
(I1
, J1
, G
, K1
),
3064 -> '$insert_in_store_occurrence/4'(G
)
3068 allocation_occurrence
(C
, L1
),
3069 ( G
=suspension
(M1
, N1
, O1
, P1
, Q1
, R1
, S1
, T1
, U1
, V1
),
3072 -> 'chr update_mutable'(inactive
, N1
),
3073 'occurrence/4__2__0'(B
, C
, D
, E
, F
, G
)
3076 ; 'occurrence/4__2__0'(B
, C
, D
, E
, F
, G
)
3078 'occurrence/4__2'(A
, B
, C
, D
, E
) :-
3079 'occurrence/4__3'(A
, B
, C
, D
, E
).
3080 'occurrence/4__3'(A
, B
, C
, D
, E
) :-
3081 '$via1_multi_hash_allocation_occurrence/2-12'(k
(A
, B
), F
), !,
3082 'occurrence/4__3__0'(F
, A
, B
, C
, D
, E
).
3083 'occurrence/4__3__0'([], A
, B
, C
, D
, E
) :-
3084 'occurrence/4__4'(A
, B
, C
, D
, E
).
3085 'occurrence/4__3__0'([A
|B
], C
, D
, E
, F
, G
) :-
3086 ( A
=suspension
(H
, I
, J
, K
, L
, M
, N
, O
),
3090 '$via1_multi_hash_passive/2-12'(k
(E
, F
), P
),
3091 'chr sbag_member'(Q
, P
),
3092 Q
=suspension
(R
, S
, T
, U
, V
, W
, X
, Y
),
3096 -> remove_constraint_internal
(A
, Z
, A1
),
3098 -> '$delete_from_store_allocation_occurrence/2'(A
)
3101 activate_constraint
(B1
, C1
, G
, D1
),
3103 -> '$insert_in_store_occurrence/4'(G
)
3107 allocation_occurrence
(C
, E1
),
3108 ( G
=suspension
(F1
, G1
, H1
, I1
, J1
, K1
, L1
, M1
, N1
, O1
),
3111 -> 'chr update_mutable'(inactive
, G1
),
3112 'occurrence/4__3__0'(B
, C
, D
, E
, F
, G
)
3115 ; 'occurrence/4__3__0'(B
, C
, D
, E
, F
, G
)
3117 'occurrence/4__3'(A
, B
, C
, D
, E
) :-
3118 'occurrence/4__4'(A
, B
, C
, D
, E
).
3119 'occurrence/4__4'(A
, B
, C
, D
, E
) :-
3120 activate_constraint
(F
, G
, E
, H
),
3122 -> '$insert_in_store_occurrence/4'(E
)
3125 get_occurrence
(A
, B
, C
, D
) :-
3126 'get_occurrence/4__0'(A
, B
, C
, D
, E
).
3127 'get_occurrence/4__0'(A
, B
, C
, D
, E
) :-
3128 '$via1_multi_hash_occurrence/4-2'(B
, F
),
3129 'chr sbag_member'(G
, F
),
3130 G
=suspension
(H
, I
, J
, K
, L
, M
, N
, O
, P
, Q
),
3136 'get_occurrence/4__0'(A
, B
, C
, D
, E
) :- !,
3138 max_occurrence
(A
, B
) :-
3139 'max_occurrence/2__0'(A
, B
, C
).
3140 'max_occurrence/2__0'(A
, B
, C
) :-
3141 '$via1_multi_hash_max_occurrence/2-1'(A
, D
),
3142 ( 'chr sbag_member'(E
, D
),
3143 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3149 'max_occurrence/2__0'(A
, B
, C
) :-
3150 '$via1_multi_hash_max_occurrence/2-1'(A
, D
), !,
3151 allocate_constraint
(chr_translate
:'max_occurrence/2__0'(A
, B
, C
), C
, max_occurrence
(A
, B
), [A
, B
]),
3152 'max_occurrence/2__0__0'(D
, A
, B
, C
).
3153 'max_occurrence/2__0__0'([], A
, B
, C
) :-
3154 'max_occurrence/2__1'(A
, B
, C
).
3155 'max_occurrence/2__0__0'([A
|B
], C
, D
, E
) :-
3156 ( A
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3160 -> remove_constraint_internal
(A
, N
, O
),
3162 -> '$delete_from_store_max_occurrence/2'(A
)
3165 'max_occurrence/2__0__0'([], C
, D
, E
)
3166 ; 'max_occurrence/2__0__0'([], C
, D
, E
)
3168 ; 'max_occurrence/2__0__0'(B
, C
, D
, E
)
3170 'max_occurrence/2__0'(A
, B
, C
) :-
3171 allocate_constraint
(chr_translate
:'max_occurrence/2__0'(A
, B
, C
), C
, max_occurrence
(A
, B
), [A
, B
]),
3172 'max_occurrence/2__1'(A
, B
, C
).
3173 'max_occurrence/2__1'(A
, B
, C
) :-
3174 activate_constraint
(D
, E
, C
, F
),
3176 -> '$insert_in_store_max_occurrence/2'(C
)
3179 get_max_occurrence
(A
, B
) :-
3180 'get_max_occurrence/2__0'(A
, B
, C
).
3181 'get_max_occurrence/2__0'(A
, B
, C
) :-
3182 '$via1_multi_hash_max_occurrence/2-1'(A
, D
),
3183 ( 'chr sbag_member'(E
, D
),
3184 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3190 'get_max_occurrence/2__0'(A
, B
, C
) :- !,
3192 allocation_occurrence
(A
, B
) :-
3193 'allocation_occurrence/2__0'(A
, B
, C
).
3194 'allocation_occurrence/2__0'(A
, B
, C
) :-
3195 '$via1_multi_hash_occurrence/4-2'(B
, D
),
3196 'chr sbag_member'(E
, D
),
3197 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
, N
, O
),
3201 '$via1_multi_hash_rule/2-1'(N
, P
),
3202 'chr sbag_member'(Q
, P
),
3203 Q
=suspension
(R
, S
, T
, U
, V
, W
, X
, Y
),
3207 Y
=pragma
(Z
, ids
(A1
, B1
), C1
, D1
, E1
),
3211 allocation_occurrence
(A
, G1
).
3212 'allocation_occurrence/2__0'(A
, B
, C
) :-
3213 '$via1_multi_hash_occurrence/4-2'(B
, D
),
3214 'chr sbag_member'(E
, D
),
3215 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
, N
, O
),
3219 '$via1_multi_hash_rule/2-1'(N
, P
),
3220 'chr sbag_member'(Q
, P
),
3221 Q
=suspension
(R
, S
, T
, U
, V
, W
, X
, Y
),
3225 Y
=pragma
(rule
(Z
, A1
, B1
, true
), C1
, D1
, E1
, F1
),
3228 allocation_occurrence
(A
, G1
).
3229 'allocation_occurrence/2__0'(A
, B
, C
) :-
3230 '$via1_multi_hash_occurrence/4-2'(B
, D
),
3231 'chr sbag_member'(E
, D
),
3232 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
, N
, O
),
3236 '$via1_multi_hash_passive/2-12'(k
(N
, O
), P
),
3237 'chr sbag_member'(Q
, P
),
3238 Q
=suspension
(R
, S
, T
, U
, V
, W
, X
, Y
),
3243 allocation_occurrence
(A
, Z
).
3244 'allocation_occurrence/2__0'(A
, B
, C
) :-
3245 insert_constraint_internal
(D
, E
, C
, chr_translate
:'allocation_occurrence/2__0'(A
, B
, C
), allocation_occurrence
(A
, B
), [A
, B
]),
3246 '$insert_in_store_allocation_occurrence/2'(C
).
3247 get_allocation_occurrence
(A
, B
) :-
3248 'get_allocation_occurrence/2__0'(A
, B
, C
).
3249 'get_allocation_occurrence/2__0'(A
, B
, C
) :-
3250 '$via1_multi_hash_allocation_occurrence/2-1'(A
, D
),
3251 'chr sbag_member'(E
, D
),
3252 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3256 'get_allocation_occurrence/2__0'(A
, B
, C
) :- !,
3259 'rule/2__0'(A
, B
, C
).
3260 'rule/2__0'(A
, B
, C
) :-
3261 nb_getval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', D
), !,
3262 allocate_constraint
(chr_translate
:'rule/2__0'(A
, B
, C
), C
, rule
(A
, B
), [A
, B
]),
3263 'rule/2__0__0'(D
, A
, B
, C
).
3264 'rule/2__0__0'([], A
, B
, C
) :-
3265 'rule/2__1'(A
, B
, C
).
3266 'rule/2__0__0'([A
|B
], C
, D
, E
) :-
3267 ( A
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3269 '$via1_multi_hash_occurrence/4-3'(C
, N
),
3270 'chr sbag_member'(O
, N
),
3271 O
=suspension
(P
, Q
, R
, S
, T
, U
, V
, W
, X
, Y
),
3277 D
=pragma
(Z
, ids
(A1
, B1
), C1
, D1
, E1
),
3280 -> remove_constraint_internal
(A
, G1
, H1
),
3282 -> '$delete_from_store_allocation_occurrence/2'(A
)
3285 activate_constraint
(I1
, J1
, E
, K1
),
3287 -> '$insert_in_store_rule/2'(E
)
3291 allocation_occurrence
(L
, L1
),
3292 ( E
=suspension
(M1
, N1
, O1
, P1
, Q1
, R1
, S1
, T1
),
3295 -> 'chr update_mutable'(inactive
, N1
),
3296 'rule/2__0__0'(B
, C
, D
, E
)
3299 ; 'rule/2__0__0'(B
, C
, D
, E
)
3301 'rule/2__0'(A
, B
, C
) :-
3302 allocate_constraint
(chr_translate
:'rule/2__0'(A
, B
, C
), C
, rule
(A
, B
), [A
, B
]),
3303 'rule/2__1'(A
, B
, C
).
3304 'rule/2__1'(A
, B
, C
) :-
3305 nb_getval
('$chr_store_global_ground_chr_translate:allocation_occurrence/2', D
), !,
3306 'rule/2__1__0'(D
, A
, B
, C
).
3307 'rule/2__1__0'([], A
, B
, C
) :-
3308 'rule/2__2'(A
, B
, C
).
3309 'rule/2__1__0'([A
|B
], C
, D
, E
) :-
3310 ( A
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3312 '$via1_multi_hash_occurrence/4-3'(C
, N
),
3313 'chr sbag_member'(O
, N
),
3314 O
=suspension
(P
, Q
, R
, S
, T
, U
, V
, W
, X
, Y
),
3320 D
=pragma
(rule
(Z
, A1
, B1
, true
), C1
, D1
, E1
, F1
),
3322 -> remove_constraint_internal
(A
, G1
, H1
),
3324 -> '$delete_from_store_allocation_occurrence/2'(A
)
3327 activate_constraint
(I1
, J1
, E
, K1
),
3329 -> '$insert_in_store_rule/2'(E
)
3333 allocation_occurrence
(L
, L1
),
3334 ( E
=suspension
(M1
, N1
, O1
, P1
, Q1
, R1
, S1
, T1
),
3337 -> 'chr update_mutable'(inactive
, N1
),
3338 'rule/2__1__0'(B
, C
, D
, E
)
3341 ; 'rule/2__1__0'(B
, C
, D
, E
)
3343 'rule/2__1'(A
, B
, C
) :-
3344 'rule/2__2'(A
, B
, C
).
3345 'rule/2__2'(A
, B
, C
) :-
3346 activate_constraint
(D
, E
, C
, F
),
3348 -> '$insert_in_store_rule/2'(C
)
3352 'get_rule/2__0'(A
, B
, C
).
3353 'get_rule/2__0'(A
, B
, C
) :-
3354 '$via1_multi_hash_rule/2-1'(A
, D
),
3355 'chr sbag_member'(E
, D
),
3356 E
=suspension
(F
, G
, H
, I
, J
, K
, L
, M
),
3360 'get_rule/2__0'(A
, B
, C
) :- !,