I dunno, I only figured out just now that SWI-Prolog must also do auto load during predicate property. I assumed that it does not, but the relevant information for function expansion seems to be available:
?- predicate_property(aggregate_all(_,_,_), X).
X = (meta_predicate aggregate_all(?, 0, -)) ;
The information seems to be available without use_module(library(aggregate)). So I don’t know whats going wrong, and why the use_module(library(aggregate)) is need in abaljeu example.
I did another test. Instead of use_module(library(aggregate)), just using aggregate_all/3, also triggers correct function expansion:
?- aggregate_all(sum(X), between(1,10,X), Y).
Y = 55.
test2(Player, Count1) :-
aggregate_all(count, (member(G, Player.games), ground(G.opponent)), Count1).
test2(A, E) :-
( ( '.'(A, games, B), member(C, B)),
'.'(C, opponent, D), ground(D)),