I’ve solved day 11, part 2 (advent of code 2025), with subsumptive tabling, but cannot find the right syntax/semantic to use the table sum specification.
That is this works
:- table count_paths(+,+,+,-).
count_paths(T,T,_,1).
count_paths(S,T,U,N) :-
memberchk(S-Cs,U),
aggregate_all(sum(V), (
member(C,Cs),
count_paths(C,T,U,V)
),N).
while this one doesn’t:
:- table count_paths(+,+,+,sum).
count_paths(T,T,_,1).
count_paths(S,T,U,N) :-
memberchk(S-Cs,U),
maplist(count_path(T,U),Cs,Ns),
sumlist(Ns,N).
count_path(T,U,C,N) :-
count_paths(C,T,U,N).
How to take advantage of :- table count_paths(+,+,+,sum). ?