Download as pdf or txt
Download as pdf or txt
You are on page 1of 64

Chapter 01

An Introduction to
Artificial Intelligence
Instructor
LE Thanh Sach, Ph.D.
Instructor’s Information

LE Thanh Sach, Ph.D.


Office:
Department of Computer Science,
Faculty of Computer Science and Engineering,
HoChiMinh City University of Technology.
Office Address:
268 LyThuongKiet Str., Dist. 10, HoChiMinh City,
Vietnam.
E-mail: LTSACH@cse.hcmut.edu.vn
E-home: http://cse.hcmut.edu.vn/~ltsach/
Tel: (+84) 83-864-7256 (Ext: 5839)
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 2
Outline

vWhat is AI?
vThe foundations of AI
vA brief history of AI
vThe state of the art
vIntroductory problems
vTools and Programming Languages for AI
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 3
What is AI?

vIntelligence:
@“ability to learn, understand and think”
(Oxford dictionary)

vArtificial Intelligence:
@“attempts to understand intelligent entities”
@“strives to build intelligent entities”
(Stuart Russel & Peter Norvig [1])

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 4


What is AI?

vSchools of Thought:

Thinking humanly Thinking rationally

Acting humanly Acting rationally

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 5


Acting Humanly: The Turing Test

vAlan Turing (1912-1954)


v“Computing Machinery and Intelligence” (1950)

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 6


Acting Humanly: The Turing Test

vCan machines think?" à "Can machines behave


intelligently?"
vOperational test for intelligent behavior: the
Imitation Game

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 7


Acting Humanly: The Turing Test

v Human capabilities
v (1) Can express activities: walk, run, dance, …
v Robotics
v (2) Can see and understand
v Computer vision
v (3) Can listen/speak
v Speak recognition and synthesis
v (4) Can use language
vNatural language processing
v (5) Can perform reasoning
vknowledge representation and reasoning
v (6) Can learn
v Machine learning
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 8
Acting Humanly: The Turing Test

vPredicted that by 2000, a machine might have a


30% chance of fooling a lay person for 5 minutes.

vAnticipated all major arguments against AI in


following 50 years.

vSuggested major components of AI: knowledge,


reasoning, language, understanding, learning.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 9


Thinking Humanly: Cognitive Modelling

v Not content to have a program correctly solving a problem.


More concerned with comparing its reasoning steps
to traces of human solving the same problem.

v Requires testable theories of the workings of the


human mind: cognitive science.
@How does a human think?

v Typical research:
@General Problem Solver (GPS), Newell & Simon

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 10


Thinking Rationally: Laws of Thought

v Aristotle was one of the first to attempt to codify “right


thinking”, i.e., irrefutable reasoning processes.
@Aristotle: ~ 430BC
@Syllogism:
ü Major premise: All men are mortal.
ü Minor premise: Socrates is a man.
ü Conclusion: Socrates is mortal.

v Formal logic provides a precise notation and rules for


representing and reasoning with all kinds of things in the
world.
@Example:
ü Major premise: Men(X) Þ Mortal(X)
ü Minor premise: Men(Socrates)
ü Conclusion: Mortal(Socrates)
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 11
Thinking Rationally: Laws of Thought

vObstacles:
@Informal knowledge representation.
@Computational complexity and resources.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 12


Acting Rationally

vActing so as to achieve one’s goals, given one’s


beliefs.

vDoes not necessarily involve thinking.


vAdvantages:
- More general than the “laws of thought” approach.
- More amenable to scientific development than
human-based approaches.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 13


The Foundations of AI

vPhilosophy (423 BC - present):


- Logic, methods of reasoning.
- Mind as a physical system.
- Foundations of learning, language, and rationality.

vMathematics (c.800 - present):


- Formal representation and proof.
- Algorithms, computation, decidability, tractability.
- Probability.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 14


The Foundations of AI

vPsychology (1879 - present):


- Adaptation.
- Phenomena of perception and motor control.
- Experimental techniques.

vLinguistics (1957 - present):


- Knowledge representation.
- Grammar.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 15


A Brief History of AI

v The gestation of AI (1943 - 1956):


- 1943: McCulloch & Pitts: Boolean circuit model of brain.
- 1950: Turing’s “Computing Machinery and Intelligence”.
- 1956: McCarthy’s name “Artificial Intelligence” adopted.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 16


A Brief History of AI

v Early enthusiasm, great expectations (1952 - 1969):


- Early successful AI programs: Samuel’s checkers,
Newell & Simon’s Logic Theorist, Gelernter’s Geometry
Theorem Prover.
- Robinson’s complete algorithm for logical reasoning.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 17


A Brief History of AI

vA dose of reality (1966 - 1974):


- AI discovered computational complexity.
- Neural network research almost disappeared
after Minsky & Papert’s book in 1969.

vKnowledge-based systems (1969 - 1979):


- 1969: DENDRAL by Buchanan et al..
- 1976: MYCIN by Shortliffle.
- 1979: PROSPECTOR by Duda et al..

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 18


A Brief History of AI

v AI becomes an industry (1980 - 1988):


- Expert systems industry booms.
- 1981: Japan’s 10-year Fifth Generation project.

v The return of NNs and novel AI (1986 - present):


- Mid 80’s: Back-propagation learning algorithm reinvented.
- Expert systems industry busts.
- 1988: Resurgence of probability.
- 1988: Novel AI (ALife, GAs, Soft Computing, …).
- 1995: Agents everywhere.
- 2003: Human-level AI back on the agenda.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 19


A Brief History of AI

v The return of NNs and novel AI (2006 - present):


- Deep learning is developed quickly, has many applications in
processing speech, text, and video.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 20


The State of the Art

v Computer beats human in a chess game.


v Computer-human conversation using speech recognition.
v Computer program can chat with human
v Expert system controls a spacecraft.
v Robot can walk on stairs and hold a cup of water.
v Language translation for webpages.
v Home appliances use fuzzy logic.
v ......
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 21
Some recent applications need AI

vGames: many
vChatbox: e.g., Siri (demo)
vLanguage translation: e.g., Google Translate
vText to speech: e.g. VOA, eNews Reader, many
v Object recognition for Images and Videos

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 22


Introductory Problem: Tic-Tac-Toe

X X
o

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 23


Tic-Tac-Toe: Solution 1

vData Structure:

1 2 3
4 5 6
7 8 9 1 2 3 4 5 6 7 8 9
2-D game-board 1-D Vector

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 24


Tic-Tac-Toe: Solution 1

@Elements of vector:
ü 0 : Empty
ü1 : X
ü2 : O
ÞThe vector is a ternary number

@Store inside the program a move-table (lookup-


table):
ü #Elements in the table: 19683 (=39)

ü Element = A vector which describes the most suitable


move from the current game-board
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 25
Tic-Tac-Toe: Solution 1

vData Structure:

000 000 000 000 000 000 000 010 000

X
000 000 001

. With this game-board . We can move

. .
. .

222 222 222

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 26


Tic-Tac-Toe: Solution 1

vAlgorithm:
1.View the vector as a ternary number. Convert it to
a decimal number.

2.Use the computed number as an index into


Move-Table and access the vector stored there.

3.Set the new board to that vector.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 27


Tic-Tac-Toe: Solution 1

vComments:

1. A lot of space to store the Move-Table.

2. A lot of work to specify all the entries in the


Move-Table.

3. Difficult to extend.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 28


Tic-Tac-Toe: Solution 2

vData Structure:
@Use vector, called board, as Solution 1
@However, elements of the vector:
ü2 : Empty
ü3 :X
ü5 :O

@Turn of move: indexed by integer


ü 1,2,3, etc.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 29


Tic-Tac-Toe: Solution 2

vFunction Library:
1 2 3
1. Make2:
@Return a location on a game-board. 4 5 6
7 8 9
IF (board[5] = 2)
RETURN 5; //the center cell.
ELSE
RETURN any cell that is not at the board’s corner;
// (cell: 2,4,6,8)

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 30


Tic-Tac-Toe: Solution 2

vFunction Library:
@Let P represent for X or O

@can_win(P) :
ü P has filled already at least two cells on a straight line
(horizontal, vertical, or diagonal)

@cannot_win(P) = NOT(can_win(P))

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 31


Tic-Tac-Toe: Solution 2

vFunction Library:
2. Posswin(P):

IF (cannot_win(P))
RETURN 0;
ELSE
RETURN index to the empty cell on the line of
can_win(P)

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 32


Tic-Tac-Toe: Solution 2

v Function Library:
@ Let odd numbers are turns of X
@ Let even numbers are turns of O

3. Go(n): make a move.

IF odd(turn) THEN // for X


Board[n] = 3
ELSE // for O
Board[n] = 5
turn = turn + 1

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 33


Tic-Tac-Toe: Solution 2

v Algorithm:
1. Turn = 1: (X moves)
Go(1) //make a move at the left-top cell

2. Turn = 2: (O moves)
IF board[5] is empty THEN
Go(5)
ELSE
Go(1)

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 34


Tic-Tac-Toe: Solution 2

v Algorithm:
3. Turn = 3: (X moves)
IF board[9] is empty THEN
Go(9)
ELSE
Go(3).
4. Turn = 4: (O moves)
IF Posswin(X) <> 0 THEN
Go(Posswin(X))
//Prevent the opponent to win
ELSE Go(Make2)
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 35
Tic-Tac-Toe: Solution 2

v Algorithm:
5. Turn = 5: (X moves)
IF Posswin(X) <> 0 THEN
Go(Posswin(X))
//Win for X.
ELSE IF Posswin(O) <> THEN
Go(Posswin(O))
//Prevent the opponent to win
ELSE IF board[7] is empty THEN
Go(7)
ELSE Go(3).
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 36
Tic-Tac-Toe: Solution 2

vComments:

1. Not efficient in time, as it has to check several


conditions before making each move.

2. Easier to understand the program’s strategy.

3. Hard to generalize.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 37


Tic-Tac-Toe: Solution 2

8 3 4
1 5 9
6 7 2
15 - (8 + 5)
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 38
Tic-Tac-Toe: Solution 2

v Comments:
1. Checking for a possible win is quicker.

2. Human finds the row-scan approach easier, while


computer finds the number-counting approach
more efficient.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 39


Tic-Tac-Toe: Solution 3

v Data structure:
1. Game-board: Use vector as described for the
above program
2. List:
ü Contains possible game-boards generated from
the current game-board

ü Each the game-board is augmented a score


indicating the possibility of victory of the current
turn
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 40
Tic-Tac-Toe: Solution 3

v Algorithm:
1. If it is a win, give it the highest rating.

2. Otherwise, consider all the moves the opponent could


make next. Assume the opponent will make the move that
is worst for us. Assign the rating of that move to the
current node.

3. The best node is then the one with the highest rating.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 41


Tic-Tac-Toe: Solution 3

Current game-board
vAlgorithm:

All possible moves for us

All possible moves


for the opponent

Please see more detail in Chapter: Game Theory

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 42


Tic-Tac-Toe: Solution 3

v Comments:
1. Require much more time to consider all possible
moves.

2. Could be extended to handle more complicated


games.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 43


Introductory Problem: Question Answering

“Mary went shopping for a new coat. She found a red


one she really liked. When she got it home, she
discovered that it went perfectly with her favourite
dress”.

Q1: What did Mary go shopping for?

Q2: What did Mary find that she liked?

Q3: Did Mary buy anything?

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 44


Question Answering: Solution 1

v Data structure:
@ Question Patterns:
ü Set of predefined TEMPLATEs.
Given TEMLATEs, generate PATTERNs to match with
input text. For example,

TEMPLATE: “Who did X Y”


PATTERN: “X Y Z”
ANSWER: Z

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 45


Question Answering: Solution 1

v Algorithm:
1. MATCH(TEMPLATE, QUESTION) è PATTERNs.

2. Extend the generated set of PATTERNs by adding


patterns that change the verb in the original pattern. For
example, from “go”, we can add patterns for “went”,
“goes”, etc.

3. MATCH(PATTERNs, TEXT) è ANSWER.


4. Return Answers.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 46


Question Answering: Solution 1

v Algorithm:
Example:
ü TEMPATE: “What did X Y”
ü QUESTION: “What did Mary go shopping for”
è PATTERN:
Mary go shopping for Z
è PATTERN+:

Mary go shopping for Z ;


Mary goes shopping for Z;
Mary went shopping for Z
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 47
Question Answering: Solution 1

v Q1: What did Mary go shopping for?


(Original text: Mary went shopping for a new coat)
v PATTERN:
Mary go shopping for Z ;
Mary goes shopping for Z;
Mary went shopping for Z
v INPUT TEXT:
Mary went shopping for a new coat

v ANSWER:
Z = a new coat.
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 48
Question Answering: Solution 1

v Q2: What did Mary find that she liked?


(Original text: She found a red one she really liked)

@ Need further processing:


ü Inserting new word, like “really”.
ü Relating noun to pronoun, i.e., Mary à She.

@ Answers:
“a red one”
“a red coat”

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 49


Question Answering: Solution 1

v Q3: Did Mary buy anything?


(Original text: When she got it home, she
discovered that it went perfectly with her favourite
dress)

@ Cannot answer, because there is no word “buy”


in the input text.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 50


Question Answering: Solution 1

v Comments:

@ Heavily depend on syntax analysis (using


template, patterns).

@ Difficult to realize in the real world.

@ Similar to a well-known program called ELIZA.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 51


Question Answering: Solution 2

vData structure:
@Should have an efficient representation for input
text, input questions.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 52


Question Answering: Solution 2
Event2: THING1: Event2:
Instance: Finding Instance: Coat Instance: Liking
Tense: Past Color: Red Tense: Past
Agent: Mary Agent: Mary
Object: THING1 Object: THING1

Concepts in the current problem:


Mary.
Coat.
Liking.
Finding.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 53


Question Answering: Solution 2

v Algorithm:
1. Convert the input text to the internal representation,
referred to as structured text.

2. Convert the input question to the internal representation,


referred to as structured question. Focus on the parts
which will be returned from the questions. For example,
@ With representation as Slot-Filler: focus on the fields that
will be returned
@ With logic representation: focus on the value of some
variable.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 54


Question Answering: Solution 2

v Algorithm:
3. MATCH(structured text, structured question).

4. Return the parts which marked as results for the


questions.

@ For example: with the three questions above.


Q1: “a new coat”
Q2: “a red coat”
Q3: Cannot answer.
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 55
Question Answering: Solution 2

v Comments:

@ More efficient than Solution 1.

@ Using semantic and knowledge inside.

@ Time-consuming when doing “match”

@ Knowledge representation, in general, is a


difficult problem.
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 56
Question Answering: Solution 3

v Data structure:
@ World Model:
ü An internal representation for the world.
ü Including: objects, actions, situation, see the following
chart.
@ IntegratedText:
ü An internal representation of the input text that has the
relation to the world model.

@ Other knowledge: like Solution 2.


Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 57
1. C enters L

2. C begins looking around

Example: about a shopping


tour. 3. C looks for a specific M 4. C looks for any interesting M

5. C asks S for help


v Roles:
@ C = customer. 6.
@ S = salesperson.
7. C finds M 8. C fail to finds M
@ M: merchandise
@ D: dollars 9. C leaves L 10. C buys M 11. C leaves L 12. Goto step 2.
@ L = a store
13. C leaves L

14. C takes M

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 58


“Mary went shopping for a new coat. She found a red
one she really liked. When she got it home, she
discovered that it went perfectly with her favourite
dress”.

Q1: What did Mary go shopping for?

Q2: What did Mary find that she liked?

Q3: Did Mary buy anything?

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 59


Question Answering: Solution 3

v Algorithm:
1. Convert the input text to an internal
representation.

2. Convert the input question to an internal


representation.

3. MATCH( result of Step 1, result of Step 2).

4. Return answer.
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 60
Question Answering: Solution 3

v Algorithm:

@ Example: With the three questions above


Q1: like Solution 2
Q2: like Solution 2
Q3: Can answer:
ü Run script from 1 to 14.
ü Assign: C= Mary, M = a red coat.
ü Step 10: “Mary buys a red coat”
ü Hence, Answer is “She bought a red coat”

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 61


Question Answering: Solution 3

v Comments

@ Outperform the two previous solutions.

@ Need additional reasoning to answer more


complex questions.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 62


Tools and Programming Languages for AI

v Programming Languages:
@ Prolog
@ Java
@ C++
v Tools:
@ For building expert systems or rule-based
systems:
ü CLIPS: C Language Integrated Production System
ü JESS: Java Expert System Shell
@ For processing semantics:
ü RDF, RDFS, OIL
Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 63
Homework

1. Read “Computing Machinery and Intelligence”


(1950).

2. Read documents related to


• Expert System.
• Knowledge Representation and languages.

Artificial Intelligence: An Introduction to Artificial Intelligence Slide: 64

You might also like