# Relation between the number of goals remaining and using the wrong operator in a General Problem Solver

In Peter Norvig's Paradigms of Artificial Intelligence Programming, chapter 4, which is about the all-famous General Problem Solver (GPS). In this chapter, the author asks a question (4.4), which is as follows:

The Not Looking after You don't Leap Problem

Write a program that keeps track of the remaining goals so that it doesn't get stuck considering only one possible operation when others will eventually lead to the goal.

HINT: have achieve take an extra argument indicating the goals that remain to be achieved after the current goal is achieved. achieve should succeed only if it can achieve the current goal and also achieve-all the remaining goals."

Here's the description of these functions

1. achieve: We input a goal, the list of operators, and the current state, in the achieve function, which checks if the goal is in the state already, if not, then checks if the goal is recursive, if not, then finds all the appropriate operators and then applies them, until the goal os achieved. Or achieve returns a nil.

2. achieve-all: This has a list of goals as an input, which it tries to achieve using the achieve function. Moreover, it makes sure that all the goals are in the final state. Otherwise, it returns a nil.

The problem that I face is to find a relation between "getting stucked" over an operator and maintaining the number of goals remaining. Moreover, the version of achieve in the GPS program checks for all the operators that can achieve the goal, and then apply only the one that does the work.

Let's forget this for a while, and consider the hint. It says that we should have an extra argument maintaining the goals that are remaining. But how will it help a goal, which is stuck because of applying the wrong operator?

There seems to be no relation between them. I know I'm missing something here, but I can't find that.