When answering a query and searching for a goal, Prolog looks for a match where the predicates and their arguments are the same as in the query. This match can be from the database, or any intermediate places along the search path. Put another way, attempts are made to find a clause in the database from which the goal follows. If there is a successful match, Prolog will respond with yes. Alternatively if terms are not identical, variables may be instantiated. An integer or atom will match only itself. A more complicated structure will match another structure with the same relation and arity, provided that all corresponding arguments match.
Unable to display preview. Download preview PDF.