Page 213 - DCAP506_ARTIFICIAL_INTELLIGENCE
P. 213

Unit 14: Prolog




          ?- X is 2 + 2, 3 >= X.                                                                Notes
          no


          ?- 3+4 > 3*2.

          yes


          They can be used in rules also.


                 Example: Here are two example predicates. One transforms centigrade temperatures to
          Fahrenheit, the other verifies if a temperature is below freezing.



          c_to_f(C,F) :-
            F is C * 9 / 5 + 32.



          freezing(F) :-
            F =< 32.


          Here are some examples of their use.

          ?- c_to_f(100,X).
          X = 212
          yes



          ?- freezing(15).
          yes


          ?- freezing(45).
          no

          Self Assessment

          Fill in the blank:
          10.  Prolog must be able to manage arithmetic in order to be a ...................... general purpose
               programming language.

          14.7 Matching

          Two terms are defined to match if they are either indistinguishable or if they  can be made
          indistinguishable by variable  instantiation. Instantiating a variable means allocating it a xed
          value. Two free variables also match, since they could be instantiated with the similar ground
          term.



                                           LOVELY PROFESSIONAL UNIVERSITY                                   207
   208   209   210   211   212   213   214   215   216   217   218