A query is a means of extracting information from a logic program and consists of attempting to prove that the query is a logical consequence of the program. We will say more about how Prolog does this in section 1.4. When we pose a query to Prolog, we are setting up a goal for Prolog to try to satisfy. If Prolog is able to find facts and rules that allow it to conclude that the goal is true, we say that the goal is ‘satisfied’, or ‘succeeds’; if a goal cannot be satisfied, we say it ‘fails’.
There is a major difference between the interpretations assigned to variables in facts and queries. In facts, variables are taken as being universally quantified; in queries, they are treated as being existentially quantified.
As a fact in file, human(X) is equivalent to x.human(x) - ‘everything is human’.
As a query,
corresponds to evaluating x.human(x) - ‘is there at least one thing that is human?’.