use expand_goal directly for existential-qualified goals in all-solutions predicates (#1246)

This commit is contained in:
Mark Thom
2022-01-26 17:34:36 -07:00
parent a562793fce
commit 142ddcd57a

View File

@@ -698,15 +698,15 @@ rightmost_power(Term, FinalTerm, Xs) :-
findall_with_existential(Template, Goal, PairedSolutions, Witnesses0, Witnesses) :- findall_with_existential(Template, Goal, PairedSolutions, Witnesses0, Witnesses) :-
( nonvar(Goal), ( nonvar(Goal),
( Goal = _ ^ _ loader:strip_module(Goal, M, Goal1),
; Goal = _ : (_ ^ _) ( Goal1 = _ ^ _ ) ->
) -> rightmost_power(Goal1, Goal2, ExistentialVars0),
rightmost_power(Goal, Goal1, ExistentialVars0),
term_variables(ExistentialVars0, ExistentialVars), term_variables(ExistentialVars0, ExistentialVars),
sort(Witnesses0, Witnesses1), sort(Witnesses0, Witnesses1),
sort(ExistentialVars, ExistentialVars1), sort(ExistentialVars, ExistentialVars1),
set_difference(Witnesses1, ExistentialVars1, Witnesses), set_difference(Witnesses1, ExistentialVars1, Witnesses),
findall(Witnesses-Template, Goal1, PairedSolutions) expand_goal(M:Goal2, M, Goal3),
findall(Witnesses-Template, Goal3, PairedSolutions)
; Witnesses = Witnesses0, ; Witnesses = Witnesses0,
findall(Witnesses-Template, Goal, PairedSolutions) findall(Witnesses-Template, Goal, PairedSolutions)
). ).