AI Unit 1
AI Unit 1
Course Delivery
By
Dr.M.Shobha Rani
UNIT -1
PROBLEMS & SEARCH
COURSE CONTENT
1. What is AI
2. AI Problems
3. AI Techniques
4. Space and Problem Search techniques
5. Defining the problem as a state space search
6. Production systems
7. Problem characteristics
8. Production system characteristics
9. Issues in the design of search programs
10. Heuristic search techniques
11. generate-and-test
12. Hill climbing, BFS, DFS
13. Problem reduction; Constraint satisfaction
1. WHAT IS AI?
Definition:
Symbol Structure
• A symbol structure is composed of a number of
instances (or tokens) or symbols related in some
physical way.
PHYSICAL SYMBOL SYSTEM HYPOTHESIS
• Tic-Tac Toe
• Question Answering Systems
TIC-TAC TOE
1. A nine element vector representing the board
2. Paper pencil playing game of 2 players Marking X &
O. Mark in 3X3 grid
BOARD STATES
The tic-Tac-Toe game can be solved in three ways. The
programs or solutions in the Series increase in,
• Their complexity
• Use of generalization
• Clarity of their knowledge
• Extensibility of their approach
PROGRAM 1
DATA STRUCTURES
1. Board: A nine-element vector representing the board, where the elements of
the vector correspond to the board positions as follows:
Element contains the value
0 – if the corresponding square is blank
1 – if filled with an ‘X’
2 – if filled with an ‘O’
2. Movetable: A large vector of 19,683 elements (3^9 = 19683) each element of
which is a nine-element vector.
ALGORITHM 1
To make a move do the following
1. View the vector board as a ternary (base three)
number. Convert it to a decimal number.
2. Use the number computed in Step 1 as an index into
Movetable and access the vector stored there.
3. The vector selected in step 2 represents the way the
board will look after the move that should be made.
So set board equal to that vector.
ADVANTAGES & DISADVANTAGES OF
ALGORITHM 1
Advantages
1. Program is efficient in terms of time.
Disadvantages
1. It takes a lot of space to store the table that specifies the
correct move to make from each board position.
2. Someone will have to do a lot work specifying all the
entries in the table.
3. It is very unlikely that all the required movetable entries
can be determined and entered without any errors.
4. If we extend the game to three dimensions, we would
have to store 3^27 board positions overwhelming the
computer memories
PROGRAM 2
Data Structures
1. Board: A nine element vector representing the
board
2 – if the corresponding square is blank
3 – if filled with an ‘X’
5 – if filled with an ‘O’
2. Turn: An integer indicating which move of the
game is about to be played, 1 indicating the first
move, 9 the last.
ALGORITHM 2
1. Make 2
Returns 5 if the center of the board is blank
(if board[5]=2)
2. Posswin(p)
• Returns 0 if player cannot win in his next move, otherwise it
returns the number of the square that constitutes a winning
move.
• Posswin operates by checking, one at a time, each of the rows,
columns and diagonals.
• To check for a win of either ‘O’ or ‘X’, multiplying the board
positions enables us to determine the win
✓ X wins when the product is 18 (3*3*2) 2 2 2 2 2 2
ADVANTAGES
• Efficient in terms of space
• Lot easier to understand the program’s strategy or to
change the strategy if desired.
DISADVANTAGES
• Program has to check several conditions before making
each move
PROGRAM 2’
• This program is identical to Program 2 except for one
change in the representation of the board.
• This numbering of the board produces a magic square,
all the rows, columns and diagonals sum up to 15.
• This simplifies the process of checking for a possible
win.
Data Structures
DIALOGUE 2
Q: Why did Russia do this?
A: Because Russia wanted to increase its political influence over
Czechoslovakia.
Q: What should the United states do?
A: The U.S should denounce the Russian action in the U.N
Conclusion
DATA STRUCTURES
1. EnglishKnow
• A description of the words, grammar, and appropriate semantic
interpretations of a large enough subset of English to account for the input
texts that the system will see.
• EnglishKnow is used to map input sentences into an internal, meaning-
oriented form and to map from such internal forms back into English.
• The former process is used when English text is being read; the latter is
used to generate English answers from the meaning-oriented form that
constitutes the program's knowledge base.
2. InputText: The input text in a character form.
3. StructuredText:
• A structured representation of the content of the input text. This
structure attempts to capture the essential knowledge contained in the
text, independently of the exact way that the knowledge was stated in
English.
• Some things that were not explicit in the English text, such as the
referents of pronouns, have been made explicit in this form.
• Representing knowledge such as this is an important issue in the
design of almost all AI programs. Existing programs exploit a variety of
frameworks for doing this.
• There are three important families of such knowledge representation
systems: production rules (of the form "if x then y"), slot-and-filler
structures, and statements in mathematical logic
4. InputQuestion: The input question in character form
5. StructQuestion: A structured representation of the content of the user’s
question.
Structured Representation of a Sentence
ALGORITHM
1. Convert the question to structured form, using the knowledge
contained in EnglishKnow. Some special marker in the structure
is used to indicate the part of the structure that should be
returned as the answer. This marker will often correspond to
the occurrence of a question word (like "who" or "what") in the
sentence.
2. Match this structured form against StructuredText.
3. Return as the answer those parts of the text that match the
requested segment of the question.
Examples
Q1: This question is answered straightforwardly with, “a new coat”.
Q2: This one is also answered successfully with, “a red coat”.
Q3: This one, cannot be answered, since there is no direct response
to it in the text.
ADVANTAGES & DISADVANTAGES
• This approach can answer most questions to which replies are
contained in the text with respect to the exact forms of the text
and the questions.
• This increased flexibility due to the time spent searching the
various knowledge bases. (EnglishKnow, StructuredText)
• The problem of producing a knowledge base for English that is
powerful enough to handle a wide range of English inputs is very
difficult.
PROGRAM 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 the above augmented knowledge
structure.
DATA STRUCTURES
1. WorldModel:
• A structured representation of background world knowledge. This structure
contains knowledge about objects, actions and situations that are
described in the input text.
• This structure is used to construct IntegratedText from the input text
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
PROBLEM CHARACTERISTICS
In order to choose the most appropriate method (or
combination of methods) for a particular problem, it is
necessary to analyze the problem along several
dimensions
1. Is the problem decomposable into a set of (nearly)
independent smaller or easier subproblems?
2. Can solution steps be ignored or at least undone if they
prove unwise?
3. Is the problem’s universe predictable?
4. Is 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 requires interaction with the
person.
8. Problem Classification
1. IS THE PROBLEM DECOMPOSABLE?
Statement:
The eight tile puzzle consist of a 3 by 3 (3*3) square
frame board which holds 8 movable tiles numbered 1
to 8. One square is empty, allowing the adjacent tiles to
be shifted. The objective of the puzzle is to find a
sequence of tile movements that leads from a starting
configuration to a goal configuration.
Formulation of 8 Puzzle Game
3. IS THE UNIVERSE PREDICTABLE
• For example, we are playing a 8-puzzle game, every
time we make a move it is possible to plan an entire
sequence of moves and eventually the resulting
state.
• We can use planning to avoid having to undo actual
moves, although it will still be necessary to
backtrack past those moves one at a time during
the planning process.
• Whereas while playing cards (eg. rummy), its hard
to figure out the next state in the game as it is
probabilistic in nature.
4. IS A GOOD SOLUTION ABSOLUTE OR
RELATIVE
• Problem of answering questions based on a database
of simple facts (any-path problem)
• By representing these facts in a formal language,
such as predicate logic and then using inference
methods to derive an answer to the question
S.NO FACT
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 79A.D
6 No mortal lives longer than 150 years
7 It is now 1991 A.D
TWO POSSIBLE SOLUTIONS
TRAVELING SALESMAN PROBLEM(best-path problem)
5. IS THE SOLUTION A STATE OR A PATH