Перейдите на более высокий уровень и используйте переходное замыкание 1 в качестве основного идиома!
% <i>your</i> binary predicate arc/2 gets used here
% |
% v
?- <a href="https://stackoverflow.com/q/30328433/4609915">path</a>(arc, Path, From, To).
From = To , Path = [To]
; From = a, To = b, Path = [a,b]
; From = a, To = c, Path = [a,b,c]
; From = a, To = d, Path = [a,b,c,d]
; From = a, To = e, Path = [a,b,c,d,e]
; From = a, To = f, Path = [a,b,c,d,e,f]
; From = b, To = c, Path = [b,c]
; From = b, To = d, Path = [b,c,d]
; From = b, To = e, Path = [b,c,d,e]
; From = b, To = f, Path = [b,c,d,e,f]
; From = c, To = d, Path = [c,d]
; From = c, To = b, Path = [c,d,b]
; From = c, To = e, Path = [c,d,e]
; From = c, To = f, Path = [c,d,e,f]
; From = d, To = b, Path = [d,b]
; From = d, To = c, Path = [d,b,c]
; From = d, To = e, Path = [d,e]
; From = d, To = f, Path = [d,e,f]
; From = e, To = f, Path = [e,f]
; false.
Сноска 1: В соответствии с универсальным мета-предикатом path/4
.