Inference counter would benefit from fine-tuning
For example, with:
count(Goal, Count) :-
'$inference_count'(C0),
Goal,
'$inference_count'(C),
Count is C - C0.
We get:
?- count(true, C). C = 1. ?- count((true,true),C). C = 3. ?- count((true,true,true), C). C = 4.
So, adding the same conjunct sometimes increments the count by 1, and sometimes by 2. Maybe there is a way to tune this.
Similarly, we get:
?- count((true;true), C). C = 2 ; C = 264.
Why so high?
Further, we have:
?- count((false;true), C). C = 2.
So, false or (;)/2 has influence on the the counter.
Yet, we also get:
?- count((false;false;false;true), C). C = 2.
So, further false and (;)/2 apparently have no influence.
The global inference count includes the intermediary calls in the toplevel when backtracking. That's the reason for the gap 2 - 264.
Oh interesting. That means that disjuctions in general will have inflated inference counts because they invoke the top level.
To fix this I guess you'd have to call count/2 for each disjuction and handle backtracking internally or something.
call_with_inference_limit/3 avoids it by bracketing a local inference count around its goal. time/1 could do something similar but it's tricky.. you don't want to time the inferences made in the count setup, for one.