| OCR Text |
Show 12 One of the primary attractions of using logic as a progra.mmJng language is that logic programs consist simply of a set of statements, which contain no sense of how to solve a problem. The program is purely declarative, rather than proceduraL Procedural programs consist of a sequence of instructions which describe how a problem is to be solved. While declarative programming is very attractive because of the natural way problems can be described, today's machines cannot efficiently execute them directly. To be able to execute a logic program, a mapping between its declarative semantics and some procedural form of the program is required. This mapping is provided by a procedural interpretation of the program. The procedural interpretation of a logic program treats each relation as a procedure, and treats each term in the body of a clause as a procedure call. To prove a goal term, a procedure is called which represents the set of clauses which have the same functor name and arity as the goal term. The procedure attempts to unify the arguments of the goal term with the arguments in the heads of the clauses comprising the relation. If unification succeeds with a clause head, the body of the clause is treated as a procedure body. Each of the terms in the body is the analog of a procedure invocation in a conventional language, and the procedure for each body term is called successively until each has retumed successfully, and which point the original procedure call also retums successfully to the top goal level. The nested procedure calls "bottom out" when the body term is unified with a unit clause. If any unification fails, the procedure tries another clause in the same relation. If no clause succeeds, the entire procedure fails. 2.1.4 Search Trees and Backtracking One common and effective way to visualize a logic program is to create a search tree for the program. The graphical depiction of a search tree which most closely models the actual operation of a logic program is the so-called Ferguson diagram. A Ferguson diagram contains two kinds of symbols, connected into a tree. A dark box represents a goal for which unification may be attempted with one or more clause heads. The successful unification of a goal with a clause head is |