next up previous
Next: Forcing Backtracking Up: No Title Previous: The ladder rule

Rules of Execution of Prolog programs

  1. Put all goals in the query into a list of goals to be satisfied
  2. When all goals are satisfied, execution stops
  3. Take first goal (left most), and search program in a top-down manner until a clause whose head matches the goal is satisfied
  4. If such a clause exists :
    Make a variant of the clause
    Match the head of the variant with the goal
    Put Goals from the body of the variant at the beginning of the list of goals to be satisfied - go to 3
  5. If such a clause does not exist :
    Uninstantiate all the variables that were instantiated in the last matching
    Return to the last successfully matched goal (climbing up the ladder)
    Search for another clause whose head matches the goal and go to 4

If the no previously matched goals criteria in (4) above can be satisfied, then the goals in question cannot be satisfied, and execution stops



Omer F Rana
Thu Feb 13 19:58:14 GMT 1997