Hello,

Is there an efficient way to know how many facts in total were asserted into the Prolog fact store. For example – suppose I am asserting a number of fact types:

fact_type_1(a).

fact_type_2(a,b).

And then know how many fact_type_1/1 and fact_type_2/2, there are.

I am interested in all facts not the result of a goal / query with constraints.

Can this be done without actually retrieving each one of them and counting them?

Or, do i need to actually keep track of their count, e.g.

add_fact_type_1 :-

fact_type_1_count(N),

retractall(fact_type_1_count(N)),

N1 is N + 1,

assert(fact_type_1_count(N1)).

thank you,

Dan