Artificial Intelligence: Instructor
Artificial Intelligence: Instructor
Instructor
QUIZ
Q1: What is relationship between Natural intelligence and AI
Q2: AI Objective
Q3: Write Name of Different Type of Agent Program
2
Assignment Q 5
A: Explain Steps in Problem Solving B: What is State Transition Diagrams (STD's)
LISP
Lisp was invented by John McCarthy in 1958 while he was at the Massachusetts Institute of Technology (MIT). McCarthy published its design in a paper in Communications of the ACM in 1960, entitled "Recursive Functions of Symbolic Expressions and Their Computation by Machine,
It was at the 1958 Research Project on Artificial Intelligence that John McCarthy first developed the basics behind Lisp. His motivation was to develop a list processing language for Artificial Intelligence. By 1965 the primary dialect of Lisp was created (version 1.5). By 1970 specialpurpose computers known as Lisp Machines, were designed to run Lisp programs. 1980 was the year that object-oriented concepts were integrated into the language. By 1986, the X3J13 group formed to produce a draft for ANSI Common Lisp standard. Finally in 1992, X3J13 group published the American National Standard for Common Lisp.
4
LISP keeps its dominance among high level (AI) programming languages Common Lisp Interpreter and compiler object oriented programming
6
Advantages of LISP
Recursion: A program can call itself a sub routine Garbage Collector: Data storage is automatically recycled Uniform Representation: Program and data look the same Program can execution other program Interaction: User can combine program writing, compilation,testing,debugging,running in a single interacting session
Application of LISP
Artificial Intelligence Symbolical Algebraic Manipulation Natural Language Understanding Machine Translation Expert System Diagnosis System Automatic Programming (Robotics) Perception(Vision, Speech Understanding)
LISP Syntax
Syntax: Prefix notation Operator first, arguments follow E.g. (+ 3 2) adds 3 and 2 A lot of parentheses These define lists and also programs Examples: (a b c d) is a list of 4 elements (atoms) a,b,c,d (defun factorial (num) (cond ((<= num 0) 1) (t (* (factorial (- num 1)) num)) ))
9
Lists: (a), (+ 6 7), (a (e f g) h), (), nil Evaluating a list always invokes a function. (function-name arg1 argn) (+ 6 7) => 13 (foo 17 18 19) => Error (function not defined) (+ my-age 4) => 28
Lists are chains of pairs Can make other trees, etc as well
11
LISP Expressions
(+ (* ((/ Numeric Functions x1 x2 ... xn) x1 x2 ... xn) x y) x y) Meaning The sum of x1, x2, ..., xn The product of x1, x2, ..., xn Subtract y from x Divide x by y The remainder of dividing x by y The absolute value of x The maximum of x1, x2, ..., xn The minimum of x1, x2, ..., xn
12
function definition
Definition of a function (defun <name> <documentation-string> (<arguments>) <body>) (defun square computes square (x) (* x x))
Relational Operators
Relational Operators Meaning (= x y) x is equal to y (/= x y) x is not equal to y (< x y) x is less than y (> x y) x is greater than y (<= x y) x is no greater than y (>= x y) x is no less than y
14
Logical Operators Logical Operators Meaning (or x1 x2 ... Logical or xn) (and x1 x2 ... Logical and xn) (not x) Logical negation
15
Many ways to define iterations Commands: loop dolist dotimes do, do*
Iterations: loop
> (setq a 4) 4 > (loop (setq a (+ a 1)) (when (> a 7) (return a))) ;; return exists the loop 8 > (loop (setq a (- a 1)) (when (< a 3) (return))) NIL
16
Iterations: dolist > (dolist (x '(1 2 3 4)) (print x)) 1 2 3 4 NIL ;; NIL is returned by dolist
Iterations: dotimes > (dotimes (i 4) (print i)) ;; starts from 0 and continues till limit 4 0 1 2 3 4 NIL ;; returns NIL
17
Basic Functions
CAR returns the head of a list CDR returns the tail of a list CONS inserts a new head into a list EQ compares two atoms for equality ATOM tests if its argument is an atom
18
(NULL S) tests if S is the empty list (LISTP S) tests if S is a list LIST makes a list of its (evaluated) arguments
(LIST 'A '(B C) 'D) returns (A (B C) D) (LIST (CDR '(A B)) 'C) returns ((B) C) (APPEND '(A B) '((X) Y) ) returns (A B (X) Y)
19
CAR
The CAR of a list is the first thing in the list CAR is only defined for nonempty lists
Then (CAR L) is
A (X Y) () undefined
20
If L is
(A B C) ( (X Y) Z) (()()) ()
CDR examples
If L is (A B C) ( (X Y) Z) (X) (()()) ()
First Program
(defun hello () (write-string "Hello, World!"))
21