print_memo_table :-
stored_memo_expansion(Hash,LookupTerm,PackedValue),
(hash_count(Hash,Count) -> print(Count), print(' : ') ; true),
(hash_time(Hash,Time) -> print(Time),print(' --> ') ; true),
print_memo_entry(LookupTerm),
nl, print(' : '),translate:print_bvalue(PackedValue),nl,fail.
print_memo_table :-
registered_value(MemoID,Name,FunValue),
format('MemoID ~w stored FUNCTION ~w ',[MemoID,Name]),
nl, print(' : '),translate:print_bvalue(FunValue),nl,fail.
print_memo_table :-
stored_memo_result(_Hash,MemoID,LookupTerm,PackedValue),
format('MemoID ~w result for argument ',[MemoID]),
print_memo_entry(LookupTerm),
nl, print(' : '),translate:print_bvalue(PackedValue),nl,fail.
print_memo_table :-
stored_memo_result(Hash,MemoID1,T1,_),
stored_memo_result(Hash,MemoID2,T2,_),
dif((MemoID1,T1),(MemoID2,T2)),
format('Hash COLLISION ~w, ~w:~w vs ~w:~w~n',[Hash,MemoID1,T1,MemoID2,T2]),
fail.
print_memo_table :- get_counter(memoization_hash_counter,Hash),
get_counter(memoization_reuse_counter,RHit),
format('Hashes computed: ~w, expansions reused: ~w~n',[Hash,RHit]),
get_counter(memoization_function_counter,F),
get_counter(memoization_function_reuse_counter,FR),
format('Memoization functions registered: ~w, results reused: ~w~n',[F,FR]).