With the behaviour of the list pattern-matching variables explained, we shall summarize how the answer procedure works. In brief, the procedure takes as input a tourist's enquiry, processes the question by searching its database, and produces and answer as output. In the course of this operation, the procedure links up no less than six different lists or list-patterns. These are
We can thus divide the working of the procedure into five steps, as follows:
answer([what is the closest underground station to the science museum])=>
[what == underground station to ??x]
The double-equals matches the words `is the closest' and this information is discarded. The pattern-variable ??x matches the words `the national gallery', so the variable x is set to the list [the science museum].
[^
x underground ?y]
The search pattern can be partially filled out, using the value assigned to x:
[[the science museum] underground ?y]
A matching database entry is found, using present. In this case the database entry is
[[the science museum] underground [south kensington]]
This results in the variable y being given the value [south kensington].
[the nearest underground station to^^
x is^^
y]
Since both x and y how have lists as their value, the items in these lists (without the outer brackets) are inserted into the slots in the answer pattern.
** [the nearest underground station to the science museum is south kensington]