10. Lisp Language
○ LISP: LISt Processing language
○ • An AI language developed in 1958 (J. McCarthy at MIT)
○ • Special focus on symbolic processing and symbol
○ manipulation
○ – Linked list structures
○ – Also programs, functions are represented as lists
○ • At one point special LISP computers with basic LISP
○ functions implemented directly on hardware were
○ available (Symbolics Inc., 80s)
○ LISP today:
○ • Many AI programs now are written in C,C++, Java
○ – List manipulation libraries are available 10
11. So john McCarthy wanted to
build a programing language
think like human being using
logic like when human think
11
13. Back in 1956
○ So up until this point all programing languages was
assembly.
○ And even also Lisp is assembly based language.
○ But it’s the first lisp programing language.
○ McCarthy saw that by listing he can represent knowledge
for human being .
13
14. What is the
Computer science
field about ?
○ Computer Science is about studying
of how computer thinks.
14
15. 15
• performs calculations
○ a billion calculations per second! two operations in same time light
travels 1 foot.
○ If u think that computer make something different ? I want to note you
that your brain do the same every single situation
○ Example when you cross a street your brain do the calculation after
taking the decision of crossing the street or not .
WHAT DOES A
COMPUTER DO?
16. What Does
Computer Do ?
• Remembers results
○ 100s of gigabytes of storage!
○ typical machine could hold 1.5M books of
standard size
16
17. Two kinds of
programs
1. Regular program: take input and function to produce
output.
UBER Mobile app which developed by regular
programing by specific functions to calculate
distance and another features.
2. AI program: take input (and in some cases output too) to
produce the generating function
Google Self Driven car which depend on learning from
previous examples.
17
18. What they mean by
Computer
18
Computers can be
PC or Laptop
Mobile or Tablet
Microcontroller (microcomputer)
o Is a single-chip embedded controller includes at
minimum microprocessor, program memory, data
memory and an input-output (I/O) device.
o we can see it In the most Electronic devices such
as the Refrigerator, the traffic lights the Air
Conditions and in modern cars.
19. Overview of Artificial
Intelligence
○ Artificial intelligence (AI)
○ Computers with the ability to mimic or duplicate the functions
of the human brain
○ Artificial intelligence systems
○ The people, procedures, hardware, software, data, and
knowledge needed to develop computer systems and
machines that demonstrate the characteristics of intelligence
19
20. Major Branches of AI
○ Perceptive system
○ A system that approximates the way a human sees, hears, and feels objects
○ Vision system
○ Capture, store, and manipulate visual images and pictures
○ Robotics
○ Mechanical and computer devices that perform tedious tasks with high
precision
○ Expert system
○ Stores knowledge and makes inferences
○ Learning system
○ Computer changes how it functions or reacts to situations based on feedback
○ Natural language processing
○ Computers understand and react to statements and commands made in a
“natural” language, such as English
○ Neural network
○ Computer system that can act like or simulate the functioning of the human
brain
20
22. What is an expert system?
“An expert system is a computer system that
emulates, or acts in all respects, with the decision-
making capabilities of a human expert.”
Professor Edward Feigenbaum
Stanford University
22
25. Lisp Language
○ LISP: LISt Processing language
○ • An AI language developed in 1958 (J. McCarthy at MIT)
○ • Special focus on symbolic processing and symbol
○ manipulation
○ – Linked list structures
○ – Also programs, functions are represented as lists
○ • At one point special LISP computers with basic LISP
○ functions implemented directly on hardware were
○ available (Symbolics Inc., 80s)
○ LISP today:
○ • Many AI programs now are written in C,C++, Java
○ – List manipulation libraries are available 25
26. So john McCarthy wanted to
build a programing language
think like human being using
logic like when human think
26
28. Back in 1956
○ So up until this point all programing languages was
assembly.
○ And even also Lisp is assembly based language.
○ But it’s the first lisp programing language.
○ McCarthy saw that by listing he can represent knowledge
for human being .
28
29. Lisp setup
○ Visit : https://sourceforge.net/projects/clisp/
○ After installing it you can write CLISP in the cmd and it
will open a clisp terminal .
29
30. LISP Competitors
○ Prolog, Python
○ but LISP keeps its dominance among
high level (AI) programming languages
30
31. Run lisp
○ You can run lisp in the lisp in the shell or write the code in the
external file .lisp and load it.
31
32. Syntax:
○ Prefix notation
– Operator first, arguments follow
– E.g.
> (+ 3 2) ;;adds 3 and 2
5
– E.g.
>4/2
2
32
33. LISP :data types
○ Symbols
– a
– john
– 34
○ Lists
– ( )
– (a)
– (a john 34)
– (lambda (arg) (* arg arg))
33
34. ○ For each symbol lisp attempts to find its value >
○ (setq a 10) ;; sets a value of symbol a to 10
○ 10
○ > a ;; returns the value of a
○ 10
○ Special symbols:
○ > t ;; true T
○ > nil ;; nil stands for false or NIL
○ > ( ) ;; an empty list NIL
34
35. Lists represent function calls as
well as basic data structures
○ > (factorial 3)
○ 6
○ > (+ 2 4)
○ 6
○ > (setq a ‘(john peter 34)) ;; quote means: do not eval the argument
(john peter 34)
○ > (setq a ‘((john 1) (peter 2)))
○ ((john 1) (peter 2))
35
36. LISP tutorial: function
definition
○ Definition of a function (defun )
○ (defun <f-name> <parameter-list> <body>)
○ >(defun square (x) (* x x))
○ SQUARE
○ >(square 2)
○ 4
○ >(square (square 2))
○ 16
36
37. LISP tutorial: function
definition
○ Definition of a function
○ (defun <f-name> <parameter-list> <body>)
○ (defun ) can be a sequence of function calls, the
function returns the value of the last call in the
sequence
○ > (defun foo (a)
○ (setq b (+ a 1))
○ (setq c (+ a 2)) c)
○ FOO
○ > (foo 2)
○ 4
37
38. LISP tutorial: conditionals
○ if statement:
○ if statement: (if<test><then><else> )
○ > (defun abs (a)
○ (if (> a 0) a (- a)))
○ ABS
○ > (abs 2)
○ 2
○ > (abs -3)
○ 3
38
39. LISP tutorial: conditionals
○ Cond statement: sequentially tests conditions, the call associated
with the first true condition is executed
○ > (defun abs (a)
○ (cond ((> a 0) a)
○ (t (- a))))
○ ABS
○ > (abs 2) 2
○ > (abs -3) 3
39
40. LISP tutorial: iterations Iterations: dotimes
○ > (dotimes (i 4) (print i)) ;; starts from 0 and continues till limit 4
○ 0
○ 1
○ 2
○ 3
○ 4
○ NIL ;; returns NIL
40