Phases of Query Processing

Query processing is done in several phases, described below. We will illustrate what is done in each phase through a simple example: the question put to the user when the solution to the toplevel query `X is 1+1' is displayed, requesting a decision whether to find alternative answers or not:

     | ?- X is 1+1.
     X = 2 ? no
     Please enter ";" for more choices; otherwise, <return>
      ? ;

We focus on the query `X = 2 ? ' in the above script.

The example query belongs to the class next_solution, its text is described by the message term solutions([binding("X",2)]), and its help text by the message term bindings_help. Accordingly, such a query is executed by calling:

     ask_query(next_solution,               /* QueryClass */
               solutions([binding("X",2)]), /* Query */
               bindings_help,               /* Help */

In general, execution of ask_query(+QueryClass, +Query, +Help, -Answer) consists of the following phases: