Page 87 - DCAP310_INTRODUCTION_TO_ARTIFICIAL_INTELLIGENCE_AND_EXPERT_SYSTEMS
P. 87

Unit 5: Artificial Intelligence Programming Language




          allows no side effects and includes no imperative features of any kind, basically because it has  Notes
          no variables and no assignment statements. Furthermore, it uses a lazy evaluation technique, in
          which no sub expression is evaluated until its value is known to be required. Lists are a commonly
          used data structure in Haskell.


                 Example: [1,2,3] is the list of three integers 1,2, and 3. The list [1,2,3] in Haskell is actually
          shorthand for the list 1:(2:(3:[])), where [] is the empty list and: is the infix operator that adds its
          first argument to the front of its second argument (a list). As an example of a user-defined
          function that operates on lists, consider the problem of counting the number of elements in a list
          by defining the function length:
          length:: [a] -> Integer
          length [ ] = 0

          length (x:xs) = 1 + length xs; which can be read as “The length of the empty list is 0, and the length
          of a list whose first element is x and remainder is xs is 1 plus the length of xs”. In Haskell,
          function invocation is guided by pattern matching. For example, the left-hand sides of the
          equations contain patterns such as [] and x:xs. In a function application, these patterns are matched
          against actual parameters ([]) only matches the empty list, and x:xs will successfully match any
          list with at least one element, binding x to the first element and xs to the rest of the list). If the
          match succeeds, the right hand side is evaluated and returned as the result of the application. If
          it fails, the next equation is tried, and if all equations fail, an error results.

               !

             Caution Use Prolog after creating Algorithm.



              Task  Use Prolog for any general programs.


          Self Assessment

          State whether the following statements are true or false:

          16.  In the 1970s an alternative paradigm for symbolic computation and AI programming
               arose from the success in the area of automatic theorem proving.
          17.  A query is used to activate Prolog’s proof procedure.

          18.  Prolog was not the first logic programming languages.

          5.7 Summary

               Programming languages in artificial intelligence (AI) are the major tool for exploring and
               building computer programs that can be used to simulate intelligent processes such as
               learning, reasoning and understanding symbolic information in context.
               The AI programming benefits considerably if the programming language frees the AI
               programmer from the constraints of too many technical constructions.
               The input-output functions print, prinl, princ, read, terpri, and format were defined and
               example programs presented.






                                           LOVELY PROFESSIONAL UNIVERSITY                                   81
   82   83   84   85   86   87   88   89   90   91   92