18CS71 - Module 1
18CS71 - Module 1
Artificial Intelligence
What is 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.
• 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.
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.
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.
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.
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.
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
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.
• 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
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.
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?
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.
• 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.
• 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.
•
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.
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.
•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.
• 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.
•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?
Monotonic Non-monotonic