0% found this document useful (0 votes)
23 views86 pages

18CS71 - Module 1

The document discusses artificial intelligence, including definitions of AI, its goals and advantages. It also covers topics like what comprises AI, problems in AI, hypotheses in AI and examples of physical symbol systems.

Uploaded by

fahadaslam12315
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views86 pages

18CS71 - Module 1

The document discusses artificial intelligence, including definitions of AI, its goals and advantages. It also covers topics like what comprises AI, problems in AI, hypotheses in AI and examples of physical symbol systems.

Uploaded by

fahadaslam12315
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 86

18CS71-Introduction to

Artificial Intelligence
What is Artificial Intelligence?

• In today's world, technology is growing very fast, and we are getting in


touch with different new technologies day by day.
• Here, one of the booming technologies of computer science is Artificial
Intelligence which is ready to create a new revolution in the world by
making intelligent machines.
• The Artificial Intelligence is now all around us. It is currently working with
a variety of subfields, ranging from general to specific, such as self-driving
cars, playing chess, proving theorems, playing music, Painting, etc.
• AI is one of the fascinating and universal fields of Computer science which
has a great scope in future. AI holds a tendency to cause a machine to work
as a human.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 2
• Artificial Intelligence is composed of two
words Artificial and Intelligence, where Artificial
defines "man-made," and intelligence defines "thinking power",
hence AI means "a man-made thinking power.“
• "It is a branch of computer science by which we can create
intelligent machines which can behave like a human, think like
humans, and able to make decisions."
• Artificial Intelligence exists when a machine can have human
based skills such as learning, reasoning, and solving problems
• With Artificial Intelligence you do not need to preprogram a
machine to do some work, despite that you can create a
machine with programmed algorithms which can work with
own intelligence, and that is the awesomeness of AI.
• It is believed that AI is not a new technology, and some people
says that as per Greek myth, there were Mechanical men in
early days which can work and behave like humans.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 3


Why Artificial Intelligence?

• Before Learning about Artificial Intelligence, we should know that what is the
importance of AI and why should we learn it. Following are some main reasons
to learn about AI:
• With the help of AI, you can create such software or devices which can solve
real-world problems very easily and with accuracy such as health issues,
marketing, traffic issues, etc.
• With the help of AI, you can create your personal virtual Assistant, such as
Cortana, Google Assistant, Siri, etc.
• With the help of AI, you can build such Robots which can work in an
environment where survival of humans can be at risk.
• AI opens a path for other new technologies, new devices, and new Opportunities.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 4


Goals of Artificial Intelligence

• Following are the main goals of Artificial Intelligence:


1.Replicate human intelligence
2.Solve Knowledge-intensive tasks
3.An intelligent connection of perception and action
4.Building a machine which can perform tasks that requires human intelligence such
as:
1. Proving a theorem
2. Playing chess
3. Plan some surgical operation
4. Driving a car in traffic
5.Creating some system which can exhibit intelligent behavior, learn new things by
itself, demonstrate, explain, and can advise to its user.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 5
What Comprises to Artificial Intelligence?

• Artificial Intelligence is not just a part of computer science even it's so


vast and requires lots of other factors which can contribute to it.
• To create the AI first we should know that how intelligence is
composed, so the Intelligence is an intangible part of our brain which
is a combination of Reasoning, learning, problem-solving
perception, language understanding, etc.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 6


• To achieve the above factors for a machine or software Artificial
Intelligence requires the following discipline:

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 7


Advantages of Artificial Intelligence

• Following are some main advantages of Artificial Intelligence:


• High Accuracy with less errors: AI machines or systems are prone to less errors and high accuracy
as it takes decisions as per pre-experience or information.
• High-Speed: AI systems can be of very high-speed and fast-decision making, because of that AI
systems can beat a chess champion in the Chess game.
• High reliability: AI machines are highly reliable and can perform the same action multiple times
with high accuracy.
• Useful for risky areas: AI machines can be helpful in situations such as defusing a bomb, exploring
the ocean floor, where to employ a human can be risky.
• Digital Assistant: AI can be very useful to provide digital assistant to the users such as AI technology
is currently used by various E-commerce websites to show the products as per customer requirement.
• Useful as a public utility: AI can be very useful for public utilities such as a self-driving car which
can make our journey safer and hassle-free, facial recognition for security purpose, Natural language
processing to communicate with the human in human-language, etc.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 8


Disadvantages of Artificial Intelligence

• Every technology has some disadvantages, and the same goes for Artificial intelligence. Being so
advantageous technology still, it has some disadvantages which we need to keep in our mind while
creating an AI system. Following are the disadvantages of AI:
• High Cost: The hardware and software requirement of AI is very costly as it requires lots of
maintenance to meet current world requirements.
• Can't think out of the box: Even we are making smarter machines with AI, but still they cannot
work out of the box, as the robot will only do that work for which they are trained, or programmed.
• No feelings and emotions: AI machines can be an outstanding performer, but still it does not have
the feeling so it cannot make any kind of emotional attachment with human, and may sometime be
harmful for users if the proper care is not taken.
• Increase dependency on machines: With the increment of technology, people are getting more
dependent on devices and hence they are losing their mental capabilities.
• No Original Creativity: As humans are so creative and can imagine some new ideas but still AI
machines cannot beat this power of human intelligence and cannot be creative and imaginative.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 9


What is Artificial Intelligence?
• Artificial Intelligence: Artificial intelligence is the study of how make computers to do things
which people do better at the moment. It refers to the intelligence controlled by a computer
machine.
• One View of AI is
• About designing systems that are as intelligent as humans
• Computers can be acquired with abilities nearly equal to human intelligence
• How system arrives at a conclusion or reasoning behind selection of actions
• How system acts and performs not so much on reasoning process.
Why Artificial Intelligence?
• Making mistakes on real-time can be costly and dangerous.
• Time-constraints may limit the extent of learning in real world.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 10


The AI Problem
• The AI Problem
There are some of the problems contained within AI.
1. Game Playing and theorem proving share the property that people who do them well are
considered to be displaying intelligence.
2. Another important foray into AI is focused on Commonsense Reasoning. It includes
reasoning about physical objects and their relationships to each other, as well as
reasoning about actions and other consequences.
3. To investigate this sort of reasoning Nowell Shaw and Simon built the General Problem
Solver (GPS) which they applied to several common sense tasks as well as the problem
of performing symbolic manipulations of logical expressions. But no attempt was made to
create a program with a large amount of knowledge about a particular problem domain.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 11


16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 12
• It is important to discuss the following four questions:
1.What are our underlying assumptions about intelligence?
2.What kind of techniques will be useful for solving AI Problems?
3.At what level of detail,if at all,we are trying model human
intelligence?
4.How will we know when we have succeeded in building an intelligent
program?

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 13


What is Hypothesis?
• https://www.youtube.com/watch?v=bp2fbzWZDmA

• A hypothesis is an assumption, an idea that is proposed for


the sake of argument so that it can be tested to see if it
might be true.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 14


• Examples of physical symbol systems include:
• Formal logic: the symbols are words like "and", "or", "not", "for all x" and so on. The expressions are
statements in formal logic which can be true or false. The processes are the rules of logical deduction.
• Algebra: the symbols are "+", "×", "x", "y", "1", "2", "3", etc. The expressions are equations. The
processes are the rules of algebra, that allow one to manipulate a mathematical expression and retain
its truth.
• A digital computer: the symbols are zeros and ones of computer memory, the processes are the
operations of the CPU that change memory.
• Chess: the symbols are the pieces, the processes are the legal chess moves, the expressions are the
positions of all the pieces on the board.
• The physical symbol system hypothesis claims that both of these are also examples of physical
symbol systems:
• Intelligent human thought: the symbols are encoded in our brains. The expressions are thoughts. The
processes are the mental operations of thinking.
• A running artificial intelligence program: the symbols are data. The expressions are more data. The
processes are programs that manipulate the data.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 15
The Underlying Assumption
• Physical Symbol System Hypothesis
At the heart of research in artificial intelligence, the underlying assumptions about intelligence lie in what Newell and
Simon (1976) call the physical symbol system hypothesis. They define a physical symbol system as follows:
1. Symbols
2. Expressions
3. Symbol Structure
4. System
• A physical symbol system consists of a set of entities called symbols, which are physically patters that can occur as
components of another type of entity called an expression (or symbol structure).
• A symbol structure is composed of a number of instances (or tokens) of symbols related in some physical way. At any
instance of the time the system will contain a collection of these symbol structures.
• The system also contains a collection of processes that operate on expressions to produce other expressions: processes
of creation, modification, reproduction and destruction.
They state hypothesis as:
“A physical symbol system has the necessary and sufficient means for general ‘intelligent actions’.”
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 16
• This hypothesis is only a hypothesis there appears to be no way to prove or disprove it on logical ground so,
it must be subjected to empirical validation we find that it is false. We may find the bulk of the evidence says
that it is true but only way to determine its truth is by experimentation”

Computers provide the perfect medium for this experimentation since they can be programmed
to simulate physical symbol system we like. The importance of the physical symbol system
hypothesis is twofold. It is a significant theory of the nature of human intelligence and so is of
great interest to psychologists.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 17


What is an AI Technique?
• Artificial Intelligence problems span a very broad spectrum. They appear
to have very little in common except that they are hard. There are
techniques that are appropriate for the solution of a variety of these
problems. The results of AI research tells that
• Intelligence requires Knowledge. Knowledge possesses some less
desirable properties including:
 It is voluminous
 It is hard to characterize accurately
 It is constantly changing
 It differs from data by being organized in a way that corresponds to the
ways it will solve AI problems without using AI techniques .

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 18


What is an AI Technique?
AI technique is a method that exploits knowledge that should be represented in such a way that:
The knowledge captures generalizations. In other words, it is not necessary to
represent each individual situation. Instead situations that share important
properties are grouped together.
• It can be understood by people who must provide it. Most of the knowledge a
program has must ultimately be provided by people in terms they understand.
• It can be easily be modified to correct errors and to reflect changes in the world
and in our world view.
• It can be used in a great many situations even if it is not totally accurate or
complete.
• It can be used to help overcome its own sheer bulk by helping to narrow the
range of possibilities that must usually be considered.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 19


Tic Tac Toe
• How to play Tic Tac Toe
• https://www.youtube.com/watch?v=5SdW0_wTX5c
• Always win tic tac toe
• https://www.youtube.com/watch?v=OmC07DvEayY

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 20


• Tic-Tac-Toe Game Playing:
• Tic-Tac-Toe is a simple and yet an interesting board game. Researchers have used various approaches to
study the Tic-Tac-Toe game. For example, Fok and Ong and Grim et al. have used artificial neural network
based strategies to play it. Citrenbaum and Yakowitz discuss games like Go-Moku, Hex and Bridg-It which
share some similarities with Tic-Tac-Toe.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 21


Tic Tac Toe
• A Formal Definition of the Game:
• The board used to play the Tic-Tac-Toe game consists of 9 cells laid out in the form of a 3x3 matrix (Fig. 1). The game
is played by 2 players and either of them can start. Each of the two players is assigned a unique symbol (generally 0
and X). Each player alternately gets a turn to make a move. Making a move is compulsory and cannot be deferred. In
each move a player places the symbol assigned to him/her in a hitherto blank cell.
• Let a track be defined as any row, column or diagonal on the board. Since the board is a square matrix with 9 cells, all
rows, columns and diagonals have exactly 3 cells. It can be easily observed that there are 3 rows, 3 columns and 2
diagonals, and hence a total of 8 tracks on the board (Fig. 1). The goal of the game is to fill all the three cells of any
track on the board with the symbol assigned to one before the opponent does the same with the symbol assigned to
him/her. At any point of the game, if there exists a track whose all three cells have been marked by the same symbol,
then the player to whom that symbol have been assigned wins and the game terminates. If there exist no track whose
cells have been marked by the same symbol when there is no more blank cell on the board then the game is drawn.
• Let the priority of a cell be defined as the number of tracks passing through it. The priorities of the nine cells on the
board according to this definition are tabulated in Table 1. Alternatively, let the priority of a track be defined as the
sum of the priorities of its three cells. The priorities of the eight tracks on the board according to this definition are
tabulated in Table 2. The prioritization of the cells and the tracks lays the foundation of the heuristics to be used in
this study. These heuristics are somewhat similar to those proposed by Rich and Knight.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 22


Tic Tac Toe

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 23


Tic Tac Toe
Strategy 1:
Algorithm:
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.
Procedure: Comments:
1) Elements of vector:
1. A lot of space to store the Move-Table.
2. A lot of work to specify all the entries in the
0: Empty
Move-Table.
1: X 3. Difficult to extend
2: O
→ the vector is a ternary number
2) Store inside the program a move-table (lookuptable):
a) Elements in the table: 19683 (39)
b) Element = A vector which describes the most suitable move from the data structure

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 24


Explanation of Strategy 2 of solving Tic-tac-toe problem
Strategy 2:

Function Library:
Data Structure:
1) Use vector, called board, as Solution 1 1.Make2:
2) However, elements of the vector: a) Return a location on a game-board.
2: Empty /blank IF (board[5] = 2)
3: X RETURN 5; //the center cell.
5: O
ELSE
3) Turn of move: indexed by integer RETURN any cell that is not at the board’s corner;
1,2,3, etc ,9 is the last // (cell: 2,4,6,8)
b) Let P represent for X or O
c) can_win(P) :
P has filled already at least two cells on a straight
line (horizontal, vertical, or diagonal)
d) cannot_win(P) = NOT(can_win(P))
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 25
2. Posswin(P):

Returns 0 if player p cannot win on his next move:otherwise,it returns the number of the square that constitutes a winning
move.This function will enable the program that constitutes a winning move.
This function will enable the program both to win and to block the opponents win.Posswin operates by Checking ,one at
a time ,each of the rows,colums and diagonals.Because of the way values are numbered,it can test an entire row(column
or diagonal) to see if it is a possible win by multiplying the values of its squares together.
If the product is 18(3 .3.2),then X can win. If the product is 50(5 .5.2),then O can win.
If we find a winning row,we determine which element is blank,and return the number of that square.

IF (cannot_win(P))
RETURN 0;
ELSE
RETURN index to the empty cell on the line of
can_win(P)
Let odd numbers are turns of X
Let even numbers are turns of O
3. Go(n): make a move in square n.This Procedure sets Board[n] to 3 if Turn is odd,or 5 if Turn is even.It also
increments Turn by one.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 26


2.Posswin(P):
Returns 0 if player p cannot win on his next move:otherwise,it returns the number of the square that
constitutes a winning move.This function will enable the program that constitutes a winning move.
This function will enable the program both to win and to block the opponents win.Posswin operates
by Checking ,one at a time ,each of the rows,colums and diagonals.Because of the way values are
numbered,it can test an entire row(column or diagonal) to see if it is a possible win by multiplying
the values of its squares together.
If the product is 18(3 .3.2),then X can win. If the product is 50(3 .3.2),then O can win.
If we find a winning row,we determine which element is blank,and return the number of that square.

IF (cannot_win(P))
RETURN 0;
ELSE
RETURN index to the empty cell on the line of
can_win(P)
Let odd numbers are turns of X
Let even numbers are turns of O
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 27
3. Go(n): make a move in square n.This Procedure sets Board[n] to 3 if Turn is odd,or 5 if Turn is even.It also
increments Turn by one.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 28


1. Turn = 1: (X moves) 4. Turn = 4: (O moves)
IF Posswin (X) is not 0 THEN
Go(1) //make a move at the left-top cell
Go (Posswin (X))
2. Turn = 2: (O moves) //Prevent the opponent to win
IF board[5] is empty THEN ELSE Go (Make2)
Go(5) 5. Turn = 5: (X moves)
ELSE IF Posswin(X) is not 0 THEN
Go(1) Go(Posswin(X))
//Win for X.
3. Turn = 3: (X moves) ELSE IF Posswin(O) is not 0 THEN
IF board[9] is empty THEN Go(Posswin(O))
Go(9) //Prevent the opponent to win
ELSE ELSE IF board[7] is empty THEN
Go(7)
Go(3).
ELSE Go(3).
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 29
Turn = 6:
Turn = 8:
IF Posswin(O) is not 0 THEN
Go(Posswin(O)) IF Posswin(O) is not 0 THEN
Go(Posswin(O))
ELSE IF Posswin(X) is not 0 THEN
Go(Posswin(X))
ELSE IF Posswin(X) is not 0 THEN
ELSE Go(Make 2).
Go(Posswin(X))
Turn = 7:
IF Posswin(X) is not 0 THEN
Go(Posswin(X)) ELSE Go anywhere that is blank.
ELSE IF Posswin(O) is not 0 THEN
Go(Posswin(O)) Turn = 9:
ELSE Go anywhere that is blank. Same as Turn=7
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 30
Comments:
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.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 31


Example-2: Question Answering
Let us consider Question Answering systems that accept input in English and provide
answers also in English. This problem is harder than the previous one as it is more
difficult to specify the problem properly.
Another area of difficulty concerns deciding whether the answer obtained is correct, or
not, and further what is meant by ‘correct’. For example, consider the following situation:
Text
Rani went shopping for a new Coat. She found a red one she really liked.
When she got home, she found that it went perfectly with her favourite dress.
Question
1. What did Rani go shopping for?
2. What did Rani find that she liked?
3. Did Rani buy anything?

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 32


Example-2:
Method 1
Question Answering
Data Structures
QuestionPattens:A set of templates that match common questions and produce patterns used to match against
inputs.
Templates and patterns are used so that a template that matches a given question is associated with the
corresponding pattern to find the answer in the input text.
For example, the template who did x y generates x y z if a match occurs and z is the answer to the question.
The given text and the question are both stored as strings.
Algorithm
Answering a question requires the following four steps to be followed:
 Compare the template against the questions and store all successful matches to produce a set of text patterns.
 Pass each of these text patterns through a substitution process that generates alternative forms of verbs so that
for example ,”go” in a question might match “went” in the text. This step generates a new ,an expanded set of
text patterns.
· Apply each of these patterns to the text; collect all the answers
· Reply with the set of answers just collected.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 33
Example-2: Question Answering
Example
In question 1 we use the template WHAT DID X Y which generates Rani go shopping for z and after substitution we get
Rani goes shopping for z and Rani went shopping for z giving z [equivalence] a new coat
In question 2 we need a very large number of templates and also a scheme to allow the insertion of ‘find’ between it and
the modifying phrase‘that she liked’;
the insertion of ‘really’ in the text; and the substitution of ‘she’ for ‘Rani’ this question is not answerable.If all of these
variations are accounted for and the questions can be answered then the response is ‘a red one’.
Question 3 cannot be answered.
Comments
This is a very primitive approach basically not matching the criteria we set for
intelligence and worse than that, used in the game.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 34


Method 2
This program first converts the input text into a structured internal form that attempts to capture the
meaning of the sentences.It also converts questions into that form.It finds answers by matching structured
forms against each other.

Data Structures
A structure called English consists of a dictionary, grammar and some semantics about the vocabulary we are likely
to come across.
This data structure provides the knowledge to convert English text into a storable internal form and also to convert
the response back into English. The structured representation of the text is a processed form and defines the context
of the input text by making explicit all references such as pronouns.
There are three types of such knowledge representation systems: production rules of the form ‘if x then y’, slot and
filler systems and statements in mathematical logic. The system used here will be the slot and filler
system.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 35


Take, for example sentence:
‘She found a red one she really liked’.
Event2 Event2
instance: finding instance: liking
tense: past tense: past
agent: Rani modifier: much
object: Thing1 object: Thing1
Thing1
instance: coat
colour: red
The question is stored in two forms: as input and in the above form

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 36


Algorithm
 Convert the question to a structured form using English know how, then use a marker to indicate the substring
(like ‘who’ or ‘what’) of the structure, that should be returned as an answer. If a slot and filler system is used a
special marker can be placed in more than one slot.
 The answer appears by matching this structured form against the structured text.
 The structured form is matched against the text and the requested segments of the question are returned.
Examples
Both questions 1 and 2 generate answers via a new coat and a red coat respectively.
Question 3 cannot be answered, because there is no direct response.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 37


Comments
This approach is more meaningful than the previous one and so is more effective. The extra power given must
be paid for by additional search time in the knowledge bases. A warning must be given here: that is – to
generate unambiguous English knowledge base is a complex task and must be left until later in the course.
The problems of handling pronouns are difficult.
For example:
Rani walked up to the salesperson: she asked where the toy department was.
Rani walked up to the salesperson: she asked her if she needed any help.
Whereas in the original text the linkage of ‘she’ to ‘Rani’ is easy, linkage of ‘she’ in each of the
above sentences to Rani and to the salesperson requires additional knowledge about the context
via the people in a shop.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 38


Method 3
This program converts the input text into a structured form that contains the meanings of the sentences in the
text,and then it combines that form with other structured forms that describe prior knowledge about the objects
and situations involved in the text.It answers questions using this augumented knowledge structure.
Data Structures
World model contains knowledge about objects, actions and situations that are described in the input text.
This structure is used to create integrated text from input text.
The diagram shows how the system’s knowledge of shopping might be represented and stored. This information is known
as a script and in this case is a shopping script.
Algorithm
Convert the question to a structured form using both the knowledge contained in Method 2 and the World model,
generating even more possible structures, since even more knowledge is being used. Sometimes filters are introduced to
prune the possible answers.
To answer a question, the scheme followed is: Convert the question to a structured form as before but use the world
model to resolve any ambiguities that may occur. The structured form is matched against the text and the requested
segments of the question are returned.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 39


Example
Both questions 1 and 2 generate answers, as in the previous program. Question 3 can now be answered. The
shopping script is instantiated and from the last sentence the path through step 14 is the one used to form the
representation. ‘M’ is bound to the red coat-got home. ‘Rani buys a red coat’ comes from step 10 and the
integrated text generates that she bought a red coat.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 40


Comments
This program is more powerful than both the previous programs because it has more knowledge. Thus, like the last
game program it is exploiting AI techniques.
However, we are not yet in a position to handle any English question. The major omission is that of a general
reasoning mechanism known as inference to be used when the required answer is not explicitly given in the input
text.
But this approach can handle, with some modifications, questions of the following form with the answer—Saturday
morning Rani went shopping. Her brother tried to call her but she did not answer.
Question: Why couldn’t Rani’s brother reach her?

Answer: Because she was not in.


This answer is derived because we have supplied an additional fact that a person cannot be in two places at once.
This patch is not sufficiently general so as to work in all cases and does not provide the type of solution we are really
looking for.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 41
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 42
LEVEL OF THE AI MODEL
LEVEL OF THE AI MODEL
‘What is our goal in trying to produce programs that do the intelligent things that people do?’
Are we trying to produce programs that do the tasks the same way that people do?
OR
Are we trying to produce programs that simply do the tasks the easiest way that is
possible?
Programs in the first class attempt to solve problems that a computer can easily solve and do not usually use AI
techniques.
AI techniques usually include a search, as no direct method is available, the use of knowledge about the objects
involved in the problem area and abstraction on which allows an element of pruning to occur, and to enable a
solution to be found in real time; otherwise, the data could explode in size. Examples of these trivial problems in
the first class, which are now of interest only to psychologists are EPAM (Elementary Perceiver and Memorizer)
which memorized garbage syllables.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 43


The second class of problems attempts to solve problems that are non-trivial for a computer and
use AI techniques. We wish to model human performance on these:
1. To test psychological theories of human performance. Ex. PARRY [Colby, 1975] – a program to simulate the
conversational behavior of a paranoid person.
2. To enable computers to understand human reasoning – for example, programs that answer questions based
upon newspaper articles indicating human behavior.
3. To enable people to understand computer reasoning. Some people are reluctant to accept computer results
unless they understand the mechanisms involved in arriving at the results.
4. To exploit the knowledge gained by people who are best at gathering information. This persuaded the earlier
workers to simulate human behavior in the SB part of AISB simulated behavior. Examples of this type of
approach led to GPS (General Problem Solver).

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 44


Important AI Techniques
Search: Provides a way of solving problems for which no more direct approach is
available as well as a framework into which any direct techniques that are
available can be embedded.
Use of Knowledge: Provides a way of solving complex problems by exploiting the
structures of the objects that are involved.
Abstraction: Provides a way of separating important features and variations from
the many unimportant ones that would otherwise overwhelm any process.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 45


Criteria for Success(Turing Test)
In 1950, Alan Turing proposed the method for determining whether a machine can think. His
method has since become known as the “Turing Test”. To conduct this test, we need two people
and the machine to be evaluated. Turing Test
provides a definition of intelligence in a machine
and compares the intelligent behavior of human
being with that of a computer.
One person A plays the role of the interrogator, who
is in a separate room from the computer and the
other person. The interrogator can ask set of
questions to both the computer Z and person X by
typing questions and receiving typed responses. The interrogator knows them only as Z and X
and aims to determine who the person is and who the machine is.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 46
The goal of machine is to fool the interrogator into believing that it is the person. If the machine
succeeds we conclude that the machine can think. The machine is allowed to do whatever it can
do to fool the interrogator.
For example, if asked the question “How much is 12,324 times 73,981?” The machine
could wait several minutes and then respond with wrong answer.
The interrogator receives two sets of responses, but does not know which set comes from
human and which from computer. After careful examination of responses, if interrogator cannot
definitely tell which set has come from the computer and which from human, then the computer
has passed the Turing Test. The more serious issue is the amount of knowledge that a machine
would need to pass the Turing test.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 47


Chapter 2
• Problems, Problem Spaces and Search

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 48


Introduction to Problem Solving, General problem solving

Problem solving is a process of generating solutions from observed data.


−a problem is characterized by a set of goals,
−a set of objects, and
−a set of operations.
These could be ill-defined and may evolve during problem solving.
Searching Solutions:
To build a system to solve a 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 techniques and apply it to the particular problem.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 49


Defining the problem as State Space Search:

Defining the problem as State Space Search:


The state space representation forms the basis of most of the AI methods.
Formulate a problem as a state space search by showing the legal problem states, the legal operators, and the
initial and goal states.
A state is defined by the specification of the values of all attributes of interest in the world
An operator changes one state into the other; it has a precondition which is the value of certain attributes prior
to the application of the operator, and a set of effects, which are the attributes altered by the operator
The initial state is where you start
The goal state is the partial description of the solution

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 50


• Formal Description of the problem:
1. Define a state space that contains all the possible configurations of the relevant objects.
2. Specify one or more states within that space that describe possible situations from which the problem
solving process may start ( initial state)
3. Specify one or more states that would be acceptable as solutions to the problem. ( goal states)

4.Specify a set of rules that describe the actions (operations) available

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 51


• Example:8-queens problem

1. Initial State: Any arrangement of 0 to 8 queens on board.


2. Operators: add a queen to any square.
3. Goal Test: 8 queens on board, none attacked.
4. Path cost: not applicable or Zero (because only the final state counts, search cost might be of interest)

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 52


Example: Water Jug Problem
Consider the following problem:
A Water Jug Problem: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which has unlimited
water which you can use to fill the jug, and the ground on which water may be poured. Neither jug has any
measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug?
State Representation and Initial State :
We will represent a state of the problem as a tuple (x, y) where x represents the amount of water in the 4-
gallon jug and y represents the amount of water in the 3-gallon jug. Note 0 ≤x≤ 4, and 0 ≤y ≤3. Our initial state:
(0, 0)

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 53


16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 54
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 55
Production Systems
The entire procedure for getting a solution for AI problem can be viewed as “Production System”. It provides
the desired goal. It is a basic building block which describes the AI problem and also describes the method of
searching the goal. Its main components are:
 A Set of Rules, each consisting of a left side (a pattern) that determines the applicability of the rule and right
side that describes the operation to be performed if the rule is applied.
 Knowledge Base – It contains whatever information is appropriate for a particular task. Some parts of the
database may be permanent, while the parts of it may pertain only to the solution of the current problem.
 Control Strategy – It specifies the order in which the rules will be compared to the database and the way of
resolving the conflicts that arise when several rules match at one.
o The first requirement of a goal control strategy is that it is cause motion; a control strategy that does not
cause motion will never lead to a solution.
o The second requirement of a good control strategy is that it should be systematic.
 A rule applier: Production rule is like below if(condition) then consequence or action

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 56


Control Strategy
The question arises
"How to decide which rule to apply next during the process of searching for a solution to a problem?"
Requirements of a good search strategy:
1. It causes motion. It must reduce the difference between current state and goal state.
Otherwise, it will never lead to a solution.
2. It is systematic. Otherwise, it may use more steps than necessary.
3. It is efficient. Find a good, but not necessarily the best, answer.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 57


Breadth First Search

To solve the water jug problem systemically construct a tree with limited states as its root.
Generate all the offspring and their successors from the root according to the rules until some
rule produces a goal state. This process is called Breadth-First Search.
Algorithm:
1) Create a variable called NODE_LIST and set it to the initial state.
2) Until a goal state is found or NODE_LIST is empty do:
a. Remove the first element from NODE_LIST and call it E. If NODE_LIST was empty quit.
b. For each way that each rule can match the state described in E do:
i. Apply the rule to generate a new state
ii. If the new state is goal state, quit and return this state
iii. Otherwise add the new state to the end of NODE_LIST

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 58


Algorithm: Breadth-First Search

Rules 3,4,11 and 12 have


been ignored in
constructing the search
trees

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 59


Depth First Search
There is another way of dealing the Water Jug Problem. One should construct a single branched tree utility yields
a solution or until a decision terminate when the path is reaching a dead end to the previous state.
If the branch is larger than the pre-specified unit then backtracking occurs to the previous state so as to create
another path.
This is called Chronological Backtracking because the order in which steps are undone depends only on the
temporal sequence in which the steps were originally made.
This procedure is called Depth-First Search.
Algorithm:
1) If the initial state is the goal state, quit return success.
2) Otherwise, do the following until success or failure is signaled
a. Generate a successor E of the initial state, if there are no more successors,
signal failure
b. Call Depth-First Search with E as the initial state
c. If success is returned, signal success. Otherwise continue in this loop.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 60


16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 61
Travelling Salesman Problem

The Problem is the salesman has a list of cities, each of which he must visit exactly once. There
are direct roads between each pair of cities on the list. Find the route the salesman should
follow for the shortest possible round trip that both states and finishes at any one of the cities.
Solution:
State Space: The state space for this problem represents states in which the cities traversed by
salesman and state described as salesman starting at any city in the given list of cities. A set of
rules is applied such that the salesman will not traverse a city traversed once. These rules are
resulted to be states with the salesman will complex the round trip and return to his starting
position.
Initial State
 Salesman starting at any arbitrary city in the given list of cities
Goal State
 Visiting all cities once and only and reaching his starting state
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 62
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 63
Suppose we find a path it may not be a solution to the problem. We also try all other paths. The
shortest path (best path) is called as a solution to the problem. These types of problems are
known as “Best path” problems. But path problems are computationally harder than any path
problems.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 64


Heuristic Search
• Heuristic Search
– It is a "rule of thumb" used to help guide search
– It is a technique that improves the efficiency of search process, possibly by sacrificing claims of completeness.
– It is involving or serving as an aid to learning, discovery, or problem-solving by experimental and especially trial-and-error methods.

• Heuristic Function:
– It is a function applied to a state in a search space to indicate a likelihood of success if that state is selected
– It is a function that maps from problem state descriptions to measures of desirability usually represented by numbers – Heuristic
function is problem specific.

•The purpose of heuristic function is to guide the search process in the most profitable direction by suggesting which path to follow first when
more than one is available (best promising way).

•We can find the TSM problem in less exponential items. On the average Heuristic improve the quality of the paths that are explored.
Following procedure is to solve TRS problem
– Select a Arbitrary City as a starting city
– To select the next city, look at all cities not yet visited, and select one closest to the current city
– Repeat steps until all cities have been visited

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 65


Some Sample Hecuristics Function

Chess The Material advantage of our side over the opponent

Traveling Salesman The sum of the distances so far

Tic-Tac-Toe 1 for each row in which we could win and in which we already
have one piece plus 2 for each such row in which we have two
pieces.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 66


Problem Characteristics

In order to choose the most appropriate method (or a combination of methods) for a particular
problem, it is necessary to analyze the problem along several key dimensions:
• Is the problem decomposable?
• Can solution steps be ignored or undone?
• Is the universe predictable?
• Is a good solution absolute or relative?
• Is the solution a state or a path?
• What is the role of knowledge?
• Does the task require human-interaction?

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 67


1.Is the problem decomposable?
Is the problem decomposable?
Decomposable problem can be solved easily. Suppose we want to solve the problem of
computing the expression.

We can solve this problem by breaking it down into these smaller problems, each of which we
can then solve by using a small collection of specific rules the following figure shows problem
tree that as it can be exploited by a simple recursive integration program that works as follows.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 68


At each step it checks to see whether the problem it is working on is
immediately solvable.
If so, then the answer is returned directly.
If the problem is not easily solvable, the integrator checks to see
whether it can decompose the problem into smaller problems.
It can create those problems and calls itself recursively on using this
technique of problem decomposition we can often solve
very large problem easily.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 69


2. Can solution steps be ignored or undone?
•Suppose we are trying to prove a mathematical theorem. We proceed by first proving a lemma that we think
will be useful. A lemma that has been proved can be ignored for next steps as eventually we realize the
lemma is no help at all.

• Now consider the 8-puzzle game. A sample game using the 8-puzzle is shown below:
•In attempting to solve the 8 puzzle, we might make a stupid move for example; we slide the tile 5 into an
empty space. We actually want to slide the tile 6 into empty space but we can back track and undo the first
move, sliding tile 5 back to where it was then we can know tile 6 so mistake and still recovered from but not
quit as easy as in the theorem moving problem. An additional step must be performed to undo each
incorrect step.

•Now consider the problem of playing chess. Suppose a chess playing problem makes a stupid move and
realize a couple of moves later. But here solutions steps cannot be undone.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 70


2.Can solution steps be ignored or undone?

• The above three problems illustrate difference between three important classes of problems:
1) Ignorable: in which solution steps can be ignored. Example: Theorem Proving
2) Recoverable: in which solution steps can be undone. Example: 8-Puzzle
3) Irrecoverable: in which solution steps cannot be undone. Example:
Chess

• The recoverability of a problem plays an important role in determining the complexity of the control
structure necessary for problem solution.

• Ignorable problems can be solved using a simple control structure that never backtracks. Recoverable
problems can be solved by slightly complicated control strategy that does sometimes make mistakes using
backtracking. Irrecoverable problems can be solved by recoverable style methods via planning that expands a
great deal of effort making each decision since the decision is final.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 71


3.Is the universe predictable?
• There are certain outcomes every time we make a move we will know what exactly happen. This means it is possible to
plan entire sequence of moves and be confident that we know what the resulting state will be. Example is 8-Puzzle.
• In the uncertain problems, this planning process may not be possible. We can do fairly well since we have available
accurate estimates of a probabilities of each of the possible outcomes.
• A few examples of such problems are
• Example:

 Bridge Game – Playing Bridge. We cannot know exactly where all the cards are or what the other players will do on their
turns.
 Controlling a robot arm: The outcome is uncertain for a variety of reasons. Someone might move something into the path
of the arm. The gears of the arm might stick.
 Helping a lawyer decide how to defend his client against a murder charge. Here we probably cannot even list all the
possible outcomes, which leads outcome to be uncertain.

 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.
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 72
4.Is a Good Solution Absolute or Relative?

•Consider the problem of answering questions based on a database of simple facts, such as the
following:
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 Pompeian’s died when the volcano erupted in 79 A.D.
6) No mortal lives longer than 150 years. 7) It is now 1991 A.D.
•Suppose we ask a question “Is Marcus alive?” By representing each of these facts in a formal
language such as predicate logic, and then using formal inference methods we can fairly easily
derive an answer to the question.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 73


•Since we are interested in the answer to the
question, it does not matter which path we
follow. If we do follow one path successfully to
the answer, there is no reason to go back and see
if some other path might also lead to a solution.
These types of problems are called as “Any path
Problems”.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 74


Travelling Salesman Problem

The Problem is the salesman has a list of cities, each of which he must visit exactly once. There
are direct roads between each pair of cities on the list. Find the route the salesman should
follow for the shortest possible round trip that both states and finishes at any one of the cities.
Solution:
State Space: The state space for this problem represents states in which the cities traversed by
salesman and state described as salesman starting at any city in the given list of cities. A set of
rules is applied such that the salesman will not traverse a city traversed once. These rules are
resulted to be states with the salesman will complex the round trip and return to his starting
position.
Initial State
 Salesman starting at any arbitrary city in the given list of cities
Goal State
 Visiting all cities once and only and reaching his starting state
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 75
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 76
Suppose we find a path it may not be a solution to the problem. We also try all other paths. The
shortest path (best path) is called as a solution to the problem. These types of problems are
known as “Best path” problems. But path problems are computationally harder than any path
problems.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 77


5.Is the Solution a State or a Path?
• Consider the problem of finding a consistent interpretation for the sentence
• The bank president ate a dish of pasta salad with the fork
•There are several components of this sentence, each of which may have more than one
interpretation. Some of the sources of ambiguity in this sentence are the following:
 The word “Bank” may refer either to a financed institution or to a side of river. But only one
of these may have a President.
 The word “dish” is the object of the word “eat”. It is possible that a dish was eaten.
 But it is more likely that the pasta salad in the dish was eaten.
•Because of the interaction among the interpretations of the constituents of the sentence some search
may be required to find a complete interpreter for the sentence. But to solve the problem of finding
the interpretation we need to produce only the interpretation itself. No record of the processing by
which the interpretation was found is necessary. But with the “water-jug” problem it is not sufficient
to report the final state we have to show the “path” also.

•So the solution of natural language understanding problem is a state of the world. And the solution
of “Water jug” problem is a path to a state.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 78


6.What is the role of knowledge?

• What is the role of knowledge?


•Consider the problem of playing chess. The knowledge required for this problem is the rules for
determining legal move and some simple control mechanism that implements an appropriate search
procedure.
•Now consider the problem of scanning daily newspapers to decide which are supporting ‘n’
party and which are supporting ‘y’ party. For this problems are required lot of knowledge.

•The above two problems illustrate the difference between the problems for which a lot of
knowledge is important only to constrain the search for a solution and those for which a lot of
knowledge is required even to be able to recognize a solution.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 79


7.Does a task require interaction with the person?

• Does a task require interaction with the person?


•Suppose that we are trying to prove some new very difficult theorem. We might demand a prove
that follows traditional patterns so that mathematician each read the prove and check to make sure it
is correct. Alternatively, finding a proof of the theorem might be sufficiently difficult that the
program does not know where to start. At the moment people are still better at doing the highest
level strategies required for a proof. So that the computer might like to be able to ask for advice.
• For Example:
• 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.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 80


8.Problem Classification

• Problem Classification
•When actual problems are examined from the point of view all of these questions it becomes
apparent that there are several broad classes into which the problem fall.
•The classes can be each associated with a generic control strategy that is approached for solving the
problem.
•There is a variety of problem-solving methods, but there is no one single way of solving all
problems.
•Not all new problems should be considered as totally new. Solutions of similar problems can be
exploited.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 81


Classification of Production System

Based on the direction they can be:


1.Forward Production System
 Moving from Initial State to Goal
State
 When there are number of goal states and only one initial state,
it is advantage to use forward production system.
2.Backward Production System
 Moving from Goal State to Initial State
 If there is only one goal state and many initial states, it is
advantage to use backward production system.

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 82


Production System Characteristics

•Production system is a good way to describe the operations that can be performed in a search for solution
of the problem.
• Two questions we might reasonably ask at this point are:
 Can production systems, like problems, be described by a set of characteristics that shed some light on how they can easily
be implemented?
 If so, what relationships are there between problem types and the types of production systems best suited to solving the
problems?

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 83


The four categories of Production Systems

Monotonic Non-monotonic

Partially commutative Theorem proving Robot Navigation

Not Partially commutative Chemical Bridge


Synthesis

16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 84


16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 85
16/04/2024 A.Rosline Mary,Assistant Professor,Dept of CSE 86

You might also like