implement goal-driven reduction in anlib