Anda di halaman 1dari 75

Artificial Intelligence

By
Shailendra S. Aote

2/3/2016

Course Outcome
On successful completion of the course, students will be able to:
Understand challenges involved in designing intelligent systems by exploring
human intelligence nature and its role in problem solving.
Represent given problem using state space representation and apply informed
and uninformed search techniques on it .

Understand knowledge representation methods using logic programming,


frames, Scripts Semantic net etc.
Understand uncertainty theory based on techniques like probability theory
and fuzzy logic.
Design Knowledge Based Systems using production rules.
2/3/2016

Intelligence
The ability to acquire & apply knowledge to solve a problem.

What is AI
AI is the study of how to make computers to do things which at the
moment , people do better. (Rich & Knight)
Is a branch of computer Science that is concerned with the automation
of intelligent behavior in simple terms.
AI is a way of making a computer thinks intelligently (Mathews)
2/3/2016

Block Architecture of AI System


Collection of facts and rules.
Place where the domain specific knowledge is stored
Consist of body of facts axioms, rules and concepts about different entities.

Knowledg
e Base

Inference
Engine

User
Interface

Means of utilizing
facts and rules.
Carries out the
search through the
Knowledge base
To
prove
the
hypothesis & to arrive
at a conclusion

Provides the needed facilities for the user to


communicate with the system.
2/3/2016

Task Domains of AI
Mundane Tasks
Perception
Vision
Speech
Natural language
Understanding
Generation
Translation
Commonsense Reasoning
Robot Control

2/3/2016

Formal Tasks
Games
Chess
Checkers
Mathematics
Geometry
Logic
Proving Properties of Programs
Expert Tasks
Engineering
Design
Manufacturing and Planning
Scientific Analysis
Medical Analysis
Financial Analysis
5

Turing Test
To detect whether the m/c has become intelligent as
human or not.

Room-1

2/3/2016

interrogator

Room-2

AI Techniques
Intelligence requires Knowledge. : It is a method which should be
applied to solve the AI problems by exploiting knowledge.
Search:
It provides a way of solving problems for which no more direct approach
is available.
Use of Knowledge:
It provides a way of solving complex problems
Abstraction:
It provides a way of separating important features from unimportant

2/3/2016

Knowledge should be represented in such a


way that
Knowledge captures generalization (DATA)

It can be understood by the people who must provide it.


It can easily be modified to correct errors
It can be used in many situations.

Even It is not totally accurate or complete.

2/3/2016

What are the things required to built a system to


solve an AI problem?
1.

Define the problem precisely

2.

Analyze the problem.

3.

Isolate and represent the task knowledge that is necessary to solve


the problem.

4.

Choose the best problem solving technique and apply them to the
particular problem.

2/3/2016

Problem Space/ State Space /Space of the


problem state
The set of all possible configuration is the
space of the problem states.
Problem Space The environment where the
search is performed.
State Space-set of all states reachable from the
initial state.
2/3/2016

10

Water Jug Problem


You are given two jugs, a 4-gallon one and 3-gallon one.
Neither has any measuring marks on it. There is a pump that
can be used to fill the jugs with water. How can you get
exactly 2 gallons of water into the 4-gallon jug?

2/3/2016

4G

3G

11

State Space Search: Water Jug


Problem
State: (x, y)
x = 0, 1, 2, 3, or 4
y = 0, 1, 2, 3
x No. of gallons of water in 4 gallon jug
Y No. of gallons of water in 3 gallon jug

Start state: (0, 0).

Goal state: (2, n) for any n.


Attempting to end up in a goal state.
2/3/2016

12

Water jug rules


1 (x,y)
if x < 4
2 (x,y)
if y < 3
3 (x,y)
if x > 0
4 (x,y)
if y > 0
5 (x,y)
if x > 0
6 (x,y)
if y > 0
2/3/2016

(4,y)

Fill the 4-gallon jug

(x,3)

Fill the 3-gallon jug

(x d,y) Pour some water out of


the 4-gallon jug
(x,y d) Pour some water out of
the 3-gallon jug
(0,y)
Empty the 4-gallon jug
on the ground
(x,0)
Empty the 3-gallon jug
on the ground
13

Water jug rules


7 (x,y)
if x+y >= 4 and y > 0
8 (x,y)
if x+y >= 3 and y > 0
9 (x,y)
if x+y <= 4 and y > 0
10 (x,y)

11 (0,2)

12 (2,y)

2/3/2016

(4,y (4 - x))

Pour water from the


3-gallon jug into the 4-gallon jug
until the 4-gallon jug is full
(x (3 - y),3)
Pour water from the
4-gallon jug into the 3-gallon jug
until the 3-gallon jug is full
(x+y,0)
Pour all water from the
from the 3-gallon jug
into the 4-gallon jug
(0,x + y )
Pour all water from the
if x + y <= 3 and X > 0 from the 4-gallon jug
into the 3-gallon jug
(2,0)
Pour the 2 gallons from the 3gallon jug into the 4-gallon jug
(0,y)
Empty the 2 gallons in
the 4-gallon jug on the ground

14

A Water Jug solution


4-Gallon Jug
0
0
3
3
4
0
2

3-Gallon Jug
0
3
0
3
2
2
0

Rule Applied
2
9
2
7
5 or 12
9 or 11

Solution : path / plan


2/3/2016

15

Solution-2
(0, 0)
(4, 0)
(1, 3)
(1, 0)
(0, 1)
(4, 1)
(2, 3)

2/3/2016

Rules Applied--??

16

Another way to show the solution ?

2/3/2016

17

Production Systems
o A production system consists of a collection of productions
(rules), a working memory of facts (database) and an
algorithm for producing new facts from old.
o A rule becomes eligible to "fire" when its conditions match
some set of elements currently in working memory. A
control strategy determines which of several eligible rules
fires next.

2/3/2016

18

Production Systems
To solve a problem using a production system, we must
specify the
Global Database
Rules
Control Strategy

Transforming
a problem statement into these three
components of a production system is called the
representation problem in AI

2/3/2016

19

Control Strategies
It specifies in which order the rules to be fired.
The first requirement of a good CS is that it causes motion.
Every time the rules cant be started from first
rule. (Water Jug problem)

The Second requirement of a good control strategy is that it be


systematic.
Construct the tree with the initial state as its root.

2/3/2016

20

Continue this process until some


rule produces a goal state.
2/3/2016

21

Search Techniques
Uninformed Search/Blind Search

They have no additional information about states

Is to generate the successors and distinguish the goal state from non
goal state.

Informed Search/Heuristic Search


Strategies that know whether one non goal state is more promising

than another are called informed search


2/3/2016

22

Measuring Problem solving Performance


Criteria's
Completeness

Is the algorithm guaranteed to find a solution when there is one?


Optimality
Will the strategy find the optimal solution?

Time Complexity
How long does it take to find a solution?
Space Complexity

How much memory is needed to perform the search?

2/3/2016

23

Heuristic Search Methods


BFS

DFS
Generate And Test
Hill Climbing
Best First
Problem Reduction
Constraint Satisfaction
2/3/2016

24

Search Strategies: Blind Search


Breadth-first search
Expand all the nodes of
one level first.

Depth-first search
Expand one of the nodes at
the deepest level.
2/3/2016

25

Generate And Test


1. Generate A possible Solution
For some problems, this means generating a particular point in the problem
space i.e Generating a path from a start state.
2. Test to see if this Actually a Solution by compairing the chosen point or the
endpoint of the chosen path to the set of acceptable goal states.

3. If a solution has been found QUIT


Otherwise return to step-1
Exa. Throwing a die to get particular score(6)
1

6
2/3/2016

26

Generate And Test


1. It is Depth first Search procedure since complete solution must be generated
before they can be generated
2. Exhaustive Search
3. It is also known as British Museum algorithm
(Finding an object in the museum randomly.)
4. ==DFS with Backtracking.

2/3/2016

27

Hill Climbing

Similar to generate-and-test
Test function + heuristic function
Tell how close to the goal state
EX : In unfamiliar city without a map...
downtown = tall building...
heuristic function = distance between
downtown and tall building

Stop

2/3/2016

Goal state meet


No alternative state to move
28

Simple Hill Climbing


1.

Evaluate the initial state. If it is a goal state ,return & Quit


else continue

2.

with initial state as the current state.

Loop until a solution is found or until there are no


operators left to be applied in the current state.
a) Select an operator that has not yet been applied to the

current state and apply it to produce a new state


b) Evaluate a New State
i) If it is a goal state then return it & quit
ii) If it is not a goal state, but it is better than the
current state then make it the current state.
iii) If it is not better than the current state,then
2/3/2016

continue in the loop.

29

Steepest-Ascent Hill Climbing


1.Evaluate the initial state.If it is also a goal state, then return it & quit.
Otherwise continue with the initial state as the current state.
2. Loop until a solution is found or until a complete iteration produce no
change to the current state.
a) Let SUCC be a state such that any possible successor of the
current state will be better than succ.
b) For each operator that applies to the current state do:
i)Apply the operator & Generate new state.
ii)Evaluate new state..If it is a goal state then return &
quit. If not ,compare it to SUCC. If it is better, then set

SUCC to this state. If not Then leave SUCC alone.


iii)If SUCC is better than current state,then set current
state to SUCC.
2/3/2016

30

Best First Search


It combines the advantages of DFS & BFS

DFS:-It allows solution to be found w/o all competing branches being


expanded.
BFS:-It does not get trapped on dead end paths.
Follow a single path at a time, but switch paths whenever some
competing paths looks more promising than the current one.
We have to apply appropriate Heuristic Function.
The old branch is not forgotten.

2/3/2016

31

Best First Search


At each step of the BFS process

1)Select the most promising of the nodes we have generated so far.


2)Then expand the chosen node by using the rules to generate its
successors.
3) If one of them is a solution then quit.
4)If not all those new nodes are added to the set of nodes generated so far.
5)Again the most promising node is selected and the process continues.

2/3/2016

32

OR Graph
If each of the branches represent an alternative problem solving path it
is called as OR Graph.

In place of using search tree, it uses the search graph called as OR


graph.
Each node of the graph contains a description of the problem state.
Heuristic function is an estimate of
the cost of getting to a solution
from a given node

Step-2
A

Step-1
A

B
(3)

2/3/2016

(5)

(1)
33

Step-3

Step-4

B
(3)

(5)

(5)
E
(4)

2/3/2016

(6)

(6)

(5)

E
(4)

F
(6)

34

Step-5
A

(5)
G

(6)

(5)

E
(4)

I
(2)
2/3/2016

F
(6)

J
(1)
35

Lists Required?
OPEN:-Nodes that have been generated and have had the heuristic

function applied to them but which have not been examined.


(Visited, but not expanded)
CLOSED:-nodes that have already been examined. (Visited, expanded)

2/3/2016

36

Algorithm :-Best First Search


1.Start with OPEN containing just the initial state.
2.Until a goal is found or there are no nodes left on OPEN do:
a)

Pick the best node on OPEN

b)

Generate its successor.

For each successor do:


(i) If it has not been generated before. evaluate it. add it to OPEN, and record its
parent.
(ii) If it has been generated before, change the parent if this new path is better than
the previous one.
In that case update the cost of getting to this node and to any successors that
this node may already have.
Ex. Travelling Salesman Problem.
2/3/2016

37

Notations.
F-Heuristic function to be used
g-measure of the cost of getting from the initial state
to the current node.
h Estimate of the additional cost of getting from the
current node to the goal state.
F(x)=g(x)+h(x)
2/3/2016

38

A* Algorithm
1.Place the starting node S on open.
2.If open is empty, Stop & return failure.
3.Remove from open the node n that has the smallest value of f*(n).
If the node is a goal node, return success & Stop. Otherwise.
4. Expand n, generating all of its successor n and place n on closed.
For every successor n, if n is not already on open or closed attach a
back-pointer to n, Compute f*(n) and place it on open.
5.Each n that is already on open or closed should be attached to backpointers which reflect the lowest g*(n) path. If n was on closed and its

pointer was changed, remove it and place it on open.


6.Return to step 2
2/3/2016

39

Romania with step costs in km

2/3/2016

40

Open List:

A* search example

Arad

We start with our initial state Arad. We make a node and add
it to the open list. Since its the only thing on the open list,
we expand the node.
Think of the open list as a priority queue (or heap) that sorts
the nodes inside of it according to their g()+h() score.

2/3/2016

41

Open List:
Sibiu
Timisoara

A* search example

Zerind

We add the three nodes we found to the open list.


We sort them according to the
2/3/2016

g()+h()

calculation.
42

Open List:
Rimricu Vicea
Fagaras

A* search example

Weve been

Timisoara to Arad
Zerind
Arad
Oradea

before.
Dont list it
again on the
open list.

When we expand Sibiu, we run into Arad again. But weve


already expanded this node once; so, we dont add it to the
open list again.
2/3/2016

43

Open List:
Rimricu Vicea
Fagaras

A* search example

Timisoara
Zerind
Oradea

We see that Rimricu Vicea is at the top of the open list; so, its
the next node we will expand.

2/3/2016

44

Open List:

A* search example

Fagaras
Pitesti
Timisoara
Zerind
Craiova
Sibiu
Oradea

When we expand Rimricu Vicea, we run into Sibiu again.


But weve already expanded this node once; so, we dont add
it to the open list again.
2/3/2016

45

Open List:

A* search example

Fagaras
Pitesti
Timisoara
Zerind
Craiova
Oradea

Fagaras will be the next node we should expand its at the


top of the sorted open list.

2/3/2016

46

Open List:
Pitesti
Timisoara

A* search example

Zerind
Bucharest
Craiova
Sibiu
Oradea

When we expand Fagaras, we find Sibiu again. We dont add


it to the open list.
We also find Bucharest, but were not done. The algorithm
doesnt end until we expand the goal node it has to be at
the top of the open list.
2/3/2016

47

Open List:
Pitesti
Timisoara

A* search example

Zerind
Bucharest
Craiova
Oradea

It looks like Pitesti is the next node we should expand.

2/3/2016

48

Open List:
Bucharest
Timisoara

A* search example

Zerind
Craiova
Rimricu Vicea
Oradea

We just found a better value for Bucharest; so, it got moved


higher in the list. We also found a worse value for Craiova
we just ignore this.
And of course, we ran into Rimricu Vicea again. Since its
already been expanded once, we dont re-add it to the Open
List.
2/3/2016

49

Open List:
Bucharest
Timisoara

A* search example

Zerind
Craiova
Oradea

Now it looks like Bucharest is at the top of the open list

2/3/2016

50

Open List:
Bucharest
Timisoara

A* search example

Zerind
Craiova
Oradea

Now we expand the node for Bucharest.


Were done!
optimal.)
2/3/2016

(And we know the path that weve found is


51

Problem Characteristics
To choose an appropriate method for a
particular problem:
1) Is the problem decomposable?
2) Can solution steps be ignored or undone?
3) Is the universe predictable?
4) Is a good solution absolute or relative?
5) Is the solution a state or a path?
6) What is the role of knowledge?
7) Does the task require human-interaction?

2/3/2016

52

1) Is the problem decomposable?


Can the problem be broken down to smaller
problems to be solved independently?
Decomposable problem can be solved easily.

2/3/2016

53

Symbolic Integration

(1+cos2X)dx
2/3/2016

54

Is the problem decomposable?


Start

Goal

C
A

ON(B,C)

ON(A,B)

Blocks World
CLEAR(x)

ON(x, Table)

CLEAR(x) and CLEAR(y)


2/3/2016

ON(x, y)
55

Is the problem decomposable?


ON(B, C) and ON(A, B)

ON(B, C)

ON(A, B)

CLEAR(A)

ON(A, B)

C
A
2/3/2016

B
B

C
56

2)Can solution steps be ignored or


undone?
Theorem Proving
A lemma that has been proved can be ignored
for next steps.

Ignorable!

2/3/2016

57

Can solution steps be ignored or


undone?
The 8-Puzzle

2 8 3

1 2 3

1 6 4

7 6 5

Moves can be undone and backtracked.


Recoverable!

2/3/2016

58

Can solution steps be ignored or


undone?
Ignorable problems can be solved using a
simple control structure that never backtracks.
Recoverable problems can be solved using
backtracking.
Irrecoverable problems can be solved by
recoverable style methods via planning.

2/3/2016

59

3) Is the universe predictable?


The 8-Puzzle
Every time we make a move, we
know exactly what will happen.
Certain outcome!

2/3/2016

60

Is the universe predictable?


Playing Bridge
We cannot know exactly where all the cards are
or what
the other players will do on their turns.
Uncertain outcome!

2/3/2016

61

Is the universe predictable?


For certain-outcome problems, planning can used to generate a
sequence of operators that is guaranteed to lead to a solution.
For uncertain-outcome problems, a sequence of generated
operators can only have a good probability of leading to a
solution.
Plan revision is made as the plan is carried out and the
necessary feedback is provided.

2/3/2016

62

4)Is a good solution absolute or


relative?
1. Marcus was a man.
2.

Marcus was a Pompeian.

3.

Marcus was born in 40 A.D.

4. All men are mortal.


5.

All Pompeians died when the volcano


erupted in 79 A.D.

6.

No mortal lives longer than 150 years.

7.

It is now 2004 A.D.

2/3/2016

63

Is a good solution absolute or


relative?
1.
2.
3.
4.
5.

Marcus was a man.


Marcus was a Pompeian.
Marcus was born in 40 A.D.
All men are mortal.
All Pompeians died when the volcano
erupted in 79 A.D.
6. No mortal lives longer than 150 years.
7. It is now 2004 A.D.

Is Marcus alive?
2/3/2016

64

Is a good solution absolute or


relative?
1.
2.
3.
4.
5.

Marcus was a man.


Marcus was a Pompeian.
Marcus was born in 40 A.D.
All men are mortal.
All Pompeians died when the volcano
erupted in 79 A.D.
6. No mortal lives longer than 150 years.
7. It is now 2009 A.D.
Is Marcus alive?
Different reasoning paths lead to the answer. It does not
matter which path we follow.

2/3/2016

65

Solution 1
1. Marcus was man.
4. All men are mortal.
8. Marcus is mortal.
3. Marcus was born in 40 A.D.
7. It is now 2009 A.D.
9. Marcus age is 1961 years.
6. No mortal lives longer than 150 years
10. Marcus is dead.

2/3/2016

axiom 1
axiom 4
1,4
axiom 3
axiom 7
3,7
axiom 6
8,6,9

66

Solution 2

7. It is now 2009 A.D.


5. All Pompeians died in 79 A.D.
11. All Pompeians are dead now.
2. Marcus was a Pompeian.
12. Marcus is dead.

2/3/2016

axiom 7
axiom 5
7,5
axiom 2
11,2

67

Is a good solution absolute


or relative?
The Travelling Salesman Problem
We have to try all paths to find the shortest one.

2/3/2016

Boston

New York

Miami

Dallas

Sanfransi
sco

Boston

250

1450

1700

1300

New York

250

1200

1500

2900

Miami

1450

1200

1600

3300

Dallas

1700

1500

1600

1700

Sanfransisco

3000

2900

3300

1700

68

Is a good solution absolute or


relative?
Any-path problems can be solved using
heuristics that suggest good paths to explore.
For best-path problems, much more exhaustive
search will be performed.

2/3/2016

69

5)Is the solution a state or a path?


Finding a consistent interpretation
The bank president ate a dish of pasta salad with
the fork.
bank refers to a financial situation or to a side of a river?
dish or pasta salad was eaten?
Does pasta salad contain pasta, as dog food does not contain
dog?
Which part of the sentence does with the fork modify?
What if with vegetables is there?
No record of the processing is necessary.

2/3/2016

70

Is the solution a state or a path?


The Water Jug Problem
The path that leads to the goal must be reported.

2/3/2016

71

Is the solution a state or a path?


A path-solution problem can be reformulated
as a state-solution problem by describing a
state as a partial path to a solution.

The question is whether that is natural or not.

2/3/2016

72

6) What is the role of knowledge


Playing Chess
Knowledge is important only to
constrain the search for a solution.

Reading Newspaper
Knowledge is required even to be able
to recognize a solution.
Exa-Cricket news(players)
2/3/2016

73

7) Does the task require human-interaction?


Solitary problem, in which there is no
intermediate communication and no demand
for an explanation of the reasoning process.

Conversational problem, in which intermediate


communication is to provide either additional
assistance to the computer or additional
information to the user.
2/3/2016

74

Summary
Sr.
No.

Problem Char

Chess

WaterJug

8 Puzzle

Travelling
Salesman

Tower of
Hanoi

Bridge

Decomposable

No

No

No

No

No

No

Ignored
/Undone

No

Yes

Yes

Yes

Yes

No

Universe
predictable

Yes

Yes

Yes

Yes

Yes

No

Absolute/Rela
tive

Any
Path

Any
Path

Any
Path

Best

Any

Any

State/ Path

State

Path

Path

Path

Path

Path

Knowledge
Required

Yes

Yes

Yes

Yes

Yes

Yes

User
Interaction

Yes

No

No

No

No

Yes

2/3/2016

75

Anda mungkin juga menyukai