Page 206 - DCAP506_ARTIFICIAL_INTELLIGENCE
P. 206

Artificial Intelligence




                    Notes          The incorporated predicate true will always do well (without any further side-effects), while fail
                                   will at all times fail. At times there is more than one method of satisfying the existing goal.
                                   Prolog selects the first option (as determined by the order of clauses in a program), but the fact
                                   that there are choices is recorded. If at some point Prolog fails to confirm a certain subgoal, the
                                   system can go back and attempt a substitute way of executing the earlier goal. This process is
                                   called backtracking. We shall demonstrate the process of goal execution by using the following
                                   well-known argument:
                                   All men are mortal.
                                   Socrates is a man.
                                   Hence, Socrates is mortal.

                                   In Prolog terms, the first statement shows a rule: X is mortal, if X is a man (for all X). The second
                                   one comprises a fact: Socrates is a man. This can be executed in Prolog as below:
                                   mortal(X) :- man(X).

                                   man(socrates).
                                   Note that X is a variable, while socrates is an atom. The conclusion of the argument, “Socrates is
                                   mortal”, can be displayed via the predicate mortal(socrates). After having conferred with the
                                   above program we can propose this predicate to Prolog as a query, which will cause the following
                                   reaction:

                                   ?- mortal(socrates).
                                   Yes
                                   Prolog consents with our own rational reasoning, which  is nice. But how did it reach to its
                                   conclusion? Let’s follow the goal execution step by step.
                                   1.  The query mortal(socrates) is made the initial goal.
                                   2.  Scanning via the clauses of our program, Prolog attempts to match mortal(socrates) with
                                       the first probable fact or head of rule. It finds mortal(X), the head of the first (and only)
                                       rule. When matching the two terms the instantiation X = socrates requires to be made.
                                   3.  The variable instantiation is extended to the body of the rule, i.e. man(X) turns out to be
                                       man(socrates).
                                   4.  The newly instantiated body turns out to be our new goal: man(socrates).
                                   5.  Prolog implements the new goal by again attempting to match it with a rule-head or a
                                       fact. Clearly, the goal man(socrates) matches the fact man(socrates), since they are identical.
                                       This means the current goal succeeds.

                                   6.  This, again, means that also the initial goal succeeds.
                                   Self Assessment


                                   Fill in the blank:
                                   5.  Proposing  a .........................  means demanding  Prolog  to  attempt to  prove  that  the
                                       statement(s)  implied  by  the  query  can  be  prepared  true  given  the  right  variable
                                       instantiations are prepared.









          200                               LOVELY PROFESSIONAL UNIVERSITY
   201   202   203   204   205   206   207   208   209   210   211