Availability:built-in
expand_goal(+Goal1,
-Goal2)If goal_expansion/2 wraps a goal as in the example below the system still reaches fixed-point as it prevents re-expanding the expanded term while recursing. It does re-enable expansion on the arguments of the expanded goal as illustrated in t2/1 in the example.57After discussion with Peter Ludemann and Paulo Moura on the forum.
:- meta_predicate run(0).
may_not_fail(test(_)).
may_not_fail(run(_)).
goal_expansion(G, (G *-> true ; error(goal_failed(G),_))) :-
may_not_fail(G).
t1(X) :- test(X).
t2(X) :- run(run(X)).
Is expanded into
t1(X) :-
( test(X)
*-> true
; error(goal_failed(test(X)), _)
).
t2(X) :-
( run((run(X)*->true;error(goal_failed(run(X)), _)))
*-> true
; error(goal_failed(run(run(X))), _)
).