Module-1 AIML
Module-1 AIML
Artificial Intelligence world through their sensors (senses). For an autonomous vehicle, input might be images
1.Introduction: from a camera and range information from a rangefinder. For a medical diagnosis
system,perception is the set of symptoms and test results that have been obtained and input
Artificial intelligence or AI refers to the simulation of human intelligence in machines that are
to thes ystem manually.
programmed to think and act like humans.. The term was coined by John McCarthy in 1956.
AI is the ability to acquire, understand and apply the knowledge to achieve goals in the 2) Reasoning
world. Inference, decision-making, classification from what is sensed and what the internal "model" is of
➢ AI is unique, sharing borders with Mathematics, Computer Science, the world. Might be a neural network, logical deduction system, Hidden Markov Model
Philosophy, Psychology, Biology, Cognitive Science and many induction,heuristic searching a problem space, Bayes Network inference, genetic algorithms, etc.
others. Includes areas of knowledge representation, problem solving, decision theory, planning, game
➢ Although there is no clear definition of AI or even Intelligence, it can be described as an theory, machine learning, uncertainty reasoning, etc.
attempt to build machines that like humans can think and act, able to learn and use 3)Action
knowledge to solve problems on their own. Biological systems interact within their environment by actuation, speech, etc. All behavior is centered
1.1.2 Applications of AI: around actions in the world. Examples include controlling the steering of a Mars rover or autonomous
vehicle, or suggesting tests and making diagnoses for a medical diagnosis system. Includes areas of robot
AI algorithms have attracted close attention of researchers and have also been applied
actuation, natural language generation, and speech synthesis.
successfully to solve problems in engineering. Nevertheless, for large and complex problems,
1.1.4 The definitions of AI:
AIalgorithms consume considerable computation time due to stochastic feature of the search
approaches
a) "The exciting new effort to make b) "The study of mental faculties
1. Business; financial strategies computers think . . . machines with through the use of computational
2. Engineering: check design, offer suggestions to create new product, expert systems for minds,in the full and literal sense" models" (Charniak and McDermott,
7. Object identification
8. Information retrieval
9. Space shuttle scheduling
1.1.3 Building AI Systems:
1) Perception
Intelligent biological systems are physically embodied in the world and experience the
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
c) "The art of creating machines that d) "A field of study that seeks to explain
and emulate intelligent behavior in Cognitive Science: Think Human-Like
perform functions that require
terms of computational processes"
intelligence when performed by people" a. Requires a model for human cognition. Precise enough models
(Schalkoff, 1 990) allow simulation by computers.
(Kurzweil, 1990)
"The branch of computer science b. Focus is not just on behavior and I/O, but looks like reasoning process.
"The study of how to make
that is concerned with the
c. Goal is not just to produce human-like behavior but to produce a sequence of steps of
Computers do things at which, at
automation of intelligent the reasoning process, similar to the steps followed by a human in solving the same task.
themoment, people are better"
behavior"
(Rich and Knight, 1 Laws of thought: Think Rationally
(Luger and Stubblefield, 1993)
99 1 ) a. The study of mental faculties through the use of computational models; that it is,
the study of computations that make it possible to perceive reason and act.
The definitions on the top, (a) and (b) are concerned with reasoning, whereas those on the
bottom, (c) and (d) address behavior. The definitions on the left, (a) and (c) measure success b. Focus is on inference mechanisms that are probably correct and guarantee an optimal solution.
interms of human performance, and those on the right, (b) and (d) measure the ideal concept of
c. Goal is to formalize the reasoning process as a system of logical rules and procedures
intelligence called rationality of inference.
1.1.5 Intelligent Systems:
d. Develop systems of representation to allow inferences to be like
In order to design intelligent systems, it is important to categorize them into four
“Socrates is a man. All men are mortal. Therefore Socrates is mortal”
categories(Luger and Stubberfield 1993), (Russell and Norvig, 2003)
Turing Test: Act Human-Like
1. Systems that think like humans
2. Systems that think rationally
a. The art of creating machines that perform functions requiring intelligence when performed
3. Systems that behave like humans by people; that it is the study of, how to make computers do things which, at the moment,
4. Systems that behave rationally people do better.
Human Rational b. Focus is on action, and not intelligent behavior centered around the representation of the world
- Like ly
c. Example: Turing Test
Cognitive Science Approach Laws of thought Approach
Think:
“Machines that think like humans” “ Machines that think Rationally” o 3 rooms contain: a person, a computer and an interrogator.
the human. • How should we do this when the payoff may be far in the future?
1.2.4 Neuroscience
o If the machine succeeds in fooling the interrogator, then conclude that
the machine is intelligent. • How do brains process information?
• What are the formal rules to draw valid conclusions? Cognitive psychology, which views the brain as an information-processing device, COGNITIVE
• What can be computed? PSYCHOLOGY an be traced back at least to the works of William James (1842–1910). Helmholtz also
• How do we reason with uncertain information? insisted that perception involved a form of unconscious logical inference.
i)Algorithm
ii)Incompleteness 1.2.6 Computer engineering
1.2.3 Economics For artificial intelligence to succeed, we need two things: intelligence and an artifact. The computer has been
• How should we make decisions so as to maximize payoff? the artifact of choice. The modern digital electronic computer was invented independently and almost
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
by scientists in three countries embattled in world war II. From the beginning, AI researchers were not shy about making predictions of their coming successes. The
1.2.7 Control theory and cybernetics following statement by Herbert Simon in 1957 is often quoted:Terms such as “visible future” can be interpreted
• How can artifacts operate under their own control? in various ways, but Simon also made more concrete predictions: that within 10 years a computer would be
Modern control theory, especially the branch known as stochastic optimal control, has as its goal the design of chess champion, and a significant mathematical theorem would be proved by machine
systemsthat maximize an objective function over time. 1.3.5 Knowledge-based systems: The key to power? (1969–1979)
1.2.8 Linguistics The picture of problem solving that had arisen during the first decade of AI research was of a general-purpose
• How does language relate to thought? In 1957, B. F. Skinner published Verbal Behavior. This was a search mechanism trying to string together elementary reasoning steps to WEAK METHOD find complete
comprehensive, solutions. Such approaches have been called weak methods because, although general, they do not scale up to
detailed account of the behaviorist approach to language learning, written by the foremost expert in The field. large or difficult problem instances. The alternative to weak methods is to use more powerful, domain-specific
Modern linguistics and AI, then, were “born” at about the same time, and grew up together, intersecting in a knowledge that allows larger reasoning steps and can more easily handle typically occurring cases in narrow
hybrid field called computational linguistics or natural language COMPUTATIONAL LINGUISTICS processing. areas of expertise.
The problem of understanding language soon turned out to be considerably more complex than it seemed in 1957. 1.3.6 AI becomes an industry (1980–present)
1.3 The History of Artificial Intelligence The first successful commercial expert system, R1, began operation at the Digital Equipment Corporation
1.3.1 The gestation of artificial intelligence (1943–1955) (McDermott, 1982). The program helped configure orders for new computer systems; by 1986, it was saving the
The first work that is now generally recognized as AI was done by Warren McCulloch and Walter Pitts (1943). company an estimated $40 million a year.
They drew on three sources: knowledge of the basic physiology and function of neurons in the brain; a formal 1.3.7 The return of neural networks (1986–present)
analysis of propositional logic due to Russell and Whitehead; and Turing’s theory of computation. They BACK-PROPAGATION In the mid-1980s at least four different groups reinvented the back-propagation
proposed a model of artificial neurons in which each neuron is characterized as being “on” or “off,” with a learning algorithm first found in 1969 by Bryson and Ho. The algorithm was applied to many learning problems
switch to “on” occurring in response to stimulation by a sufficient number of neighboring neurons. in computer science and psychology, and the widespread dissemination of the results in the collection Parallel
1.3.2 The birth of artificial intelligence (1956) Distributed Processing (Rumelhart and McClelland, 1986) caused great excitement. CONNECTIONIST These
Princeton was home to another influential figure in AI, John McCarthy. After receiving his PhD there in 1951 and so-called connectionist models of intelligent systems were seen by some as direct competitors both to the
working for two years as an instructor, McCarthy moved to Stanford and then to Dartmouth College, which symbolic models promoted by Newell and Simon and to the logicist approach of McCarthy and others.
was to become the official birthplace of the field. 1.3.8 AI adopts the scientific method (1987–present)
1.3.3 Early enthusiasm, great expectations (1952–1969) In recent years, approaches based on hidden Markov models (HMMs) have come to dominate the area
GPS was probably the first program to embody the “thinking humanly” approach. The success of GPS and 1.3.9 The emergence of intelligent agents (1995–present)
subsequent programs as models of cognition led Newell and Simon (1976) to formulate the famous physical Perhaps encouraged by the progress in solving the subproblems of AI, researchers have also started to look at the
symbol system hypothesis, which states that “a physical symbol system has the necessary and PHYSICAL “whole agent” problem again. The work of Allen Newell, John Laird, and Paul Rosenbloom on SOAR (Newell,
SYMBOL SYSTEM sufficient means for general intelligent action.” 1990; Laird et al., 1987) is the best-known example of a complete agent architecture.
1.3.4 A dose of reality (1966–1973) 1.3.10 The availability of very large data sets (2001–present)
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
some recent work in AI suggests that for many problems, it makes more sense to worry about the data and be Mathematically speaking, we say that an agent's behavior is described by the agent
less picky about what algorithm to apply. This is true because of the increasing availability of very large data functionthat maps any given percept sequence to an action.
sources: for example, trillions of words of English and billions of images from the Web . Agent program
1.4 Agents and Environments: Internally, the agent function for an artificial agent will be implemented by an agent
program. It is important to keep these two ideas distinct. The agent function is an
abstract mathematical description; the agent program is a concrete implementation,
running on theagent architecture.
To illustrate these ideas, we will use a very simple example-the vacuum-cleaner world shown in
Fig 1.4.5. This particular world has just two locations: squares A and B. The vacuum agent
perceives which square it is in and whether there is dirt in the square. It can choose to move
left,move right, suck up the dirt, or do nothing. One very simple agent function is the
following: ifthe current square is dirty, then suck, otherwise move to the other square. A partial
Fig 1.1: Agents and Environments tabulation ofthis agent function is shown in Fig 1.4.6.
Agent:
An Agent is anything that can be viewed as perceiving its environment through sensors
andacting upon that environment through actuators.
✓ A human agent has eyes, ears, and other organs for sensors and hands, legs,
mouth,and other body parts for actuators.
Fig 1.4.5: A vacuum-cleaner world with just two locations.
✓ A robotic agent might have cameras and infrared range finders for sensors
andvarious motors foractuators.
✓ A software agent receives keystrokes, file contents, and network packets as
Sensory inputs and acts on the environment by displaying on the screen, writing
files, and sending network packets.
Percept:
We use the term percept to refer to the agent's perceptual inputs at any given instant.
Percept Sequence:
An agent's percept sequence is the complete history of everything the agent has ever perceived.
Agent function:
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
The Performance measure, the environment and the agents actuators and sensors comes under the
Agent function heading task environment. We also call this as
Percept Sequence Action PEAS(Performance,Environment,Actuators,Sensors)
[A, Clean] Right
Fig 1.4.6: Partial tabulation of a simple agent function for the example: vacuum-cleaner world shown in the
Fig1.4.5
Goal-based agents:
Function REFLEX-VACCUM-AGENT ([location, status]) returns an 10
➢ A goal-based agent has an agenda.
action If status=Dirty then return Suck
➢ It operates based on a goal in front of it and makes decisions based on how best to reach that goal.
➢ A goal-based agent operates as a search and planning function, meaning it targets the goal ahead
else if location = A then return Right
andfinds the right action in order to reach it.
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
solution.
PROBLEM DEFINITION • Execution: It executes the best optimal solution from the searching algorithms to reach the goal state from the
To build a system to solve a particular problem, we need to do four things: current state.
(i) Define the problem precisely. This definition must include specification of the initial situations and
1.6 Example Problems
also final situations which constitute (i.e) acceptable solution to the problem.
(ii) Analyze the problem (i.e) important features have an immense (i.e) huge impact on the appropriateness Basically, there are two types of problem approaches:
Steps performed by Problem-solving agent depend on descriptions, but we can have a general formulation of the problem.
• Goal Formulation: It is the first and simplest step in problem-solving. It organizes the steps/sequence
Some Toy Problems
required to formulate one goal out of multiple goals as well as actions to achieve that goal. Goal formulation is
based on the current situation and the agent’s performance measure (discussed below). • 8 Puzzle Problem: Here, we have a 3×3 matrix with movable tiles numbered from 1 to 8 with a blank space.
• Problem Formulation: It is the most important step of problem-solving which decides what actions The tile adjacent to the blank space can slide into that space. The objective is to reach a specified goal state
should be taken to achieve the formulated goal. There are following five components involved in problem similar to the goal state, as shown in the below figure.
formulation: • In the figure, our task is to convert the current state into goal state by sliding digits into the blank space.
• Initial State: It is the starting state or initial step of the agent towards its goal.
• Actions: It is the description of the possible actions available to the agent.
• Transition Model: It describes what each action does.
• Goal Test: It determines if the given state is a goal state.
• Path cost: It assigns a numeric cost to each path that follows the goal. The problem- solving agent selects
a cost function, which reflects its performance measure. Remember, an optimal solution has the lowest path
cost among all the solutions.
Note: Initial state, actions, and transition model together define the state-space of the problem implicitly. State-
space of a problem is a set of all states which can be reached from the initial state followed by any sequence of actions.
The state-space forms a directed map or graph where nodes are the states, links between the nodes are actions, and In the above figure, our task is to convert the current(Start) state into goal state by sliding digits into the blank space.
• Transition Model: It returns the resulting state as per the given state and actions. • Goal test: Checks whether 8-queens are placed on the chessboard without any attack.
• Goal test: It identifies whether we have reached the correct goal-state. • Path cost: There is no need for path cost because only final states are counted. In this formulation,
• Path cost: The path cost is the number of steps in the path where the cost of each step is 1. Note: The 8-puzzle there is approximately 1.8 x 1014 possible sequence to investigate.
problem is a type of sliding-block problem which is used for testing new search algorithms in artificial
2. Complete-state formulation: It starts with all the 8-queens on the chessboard and moves them around, saving
intelligence.
from the attacks.
• 8-queens problem: The aim of this problem is to place eight queens on a chessboard in an order where no queen
may attack another. A queen can attack other queens either diagonally or in same row and column. Following steps are involved in this formulation
From the following figure, we can understand the problem as well as its correct solution.
• States: Arrangement of all the 8 queens one per column with no queen attacking the other queen.
• Actions: Move the queen at the location where it is safe from the attacks.
This formulation is better than the incremental formulation as it reduces the state space from 1.8 x 1014 to 2057, and
1. Incremental formulation: It starts from an empty state where the operator augments a queen at each step.
• Channel routing: It finds a specific route for each wire through the gaps between the cells.
Following steps are involved in this formulation :
• ROBOT NAVIGATION :It is a generalization of the route-finding problem described earlier. Rather than following a
• States: Arrangement of any 0 to 8 queens on the chessboard. discrete set of routes, a robot can move in a continuous space with (in principle) an infinite set of possible actions
and states.
Initial State: An empty chessboard
• Actions: Add a queen to any empty box. • Automatic assembly sequencing: In assembly problems, the aim is to find an order in which to assemble the
• Transition model: Returns the chessboard with the queen added in a box. parts of some object. If the wrong order is chosen, there will be no way to add some part later in the sequence without
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
undoing some of the work already done. Search algorithms require a data structure to keep track of the search tree that is being constructed. For
each node n of the tree, we have a structure that contains four components:
Protein Design: The objective is to find a sequence of amino acids which will fold into 3D protein having a
property to cure some disease. • n.STATE: the state in the state space to which the node corresponds;
• n.PARENT: the node in the search tree that generated this node
; • n.ACTION: the action that was applied to the parent to generate the node;
• n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to the node, as
1.7 Searching for solutions
indicated by the parent pointers.
We have seen many problems. Now, there is a need to search for solutions to solve them.In this section, we
will understand how searching can be used by the agent to solve a problem. Well Defined problems and solutions:
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
Together the initial state,actions and transition model implicitly defines the state space of the
problemState space: set of all states reachable from the initial state by any sequence of actions
➢ The goal test, determining whether the current state is a goal state. Here, the goal state is
{In:Bucharest} State Space Search/Problem Space Search:
➢ The path cost function, which determine the cost of each path, which is reflecting in The state space representation forms the basis of most of the AI methods.
theperformance measure. • Formulate a problem as a state space search by showing the legal problem states, the legal
we define the cost function as c(s, a, s’), where s is the current state and a is the action performed by operators, and the initial and goal states.
theagent to reach state s’. • 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
Searching
Many traditional search algorithms are used in AI applications. For complex problems, the traditional
algorithms are unable to find the solution within some practical time and space limits. Consequently,
many special techniques are developed; using heuristic functions. The algorithms that use heuristic
functions are called heuristic algorithms. Heuristic algorithms are not really intelligent; they appear to
be intelligent because they achieve better performance.Heuristic algorithms are more efficient because
they take advantage of feedback from the data to direct the search path.
Uninformed search
Also called blind, exhaustive or brute-force search, uses no information about the problem to guide
the search and therefore may not be very efficient.
Informed Search:
Also called heuristic or intelligent search, uses information about the problem to guide the search, usually
BFS illustrated:
guesses the distance to a goal state and therefore efficient, but the search may not be always possible.
Step 1: Initially frontier contains only one node corresponding to the source state A.
1.9 Uninformed Search (Blind searches):
➢ One simple search strategy is a breadth-first search. In this strategy, the root node is
expanded first, then all the nodes generated by the root node are expanded next, and
then their successors, and so on.
➢ In general, all the nodes at depth d in the search tree are expanded before the nodes at depth d Figure 1
+ 1.
Frontier: A
Breadth-first search is an instance of the general graph-search algorithmin which the shallowest
unexpanded node is chosen for expansion,.This is achieved very simply by using a FIFO queue
Step 2: A is removed from fringe. The node is expanded, and its children B and C are generated.
for the frontier. Thus, new nodes (which are always deeper than their parents) go to the back of They are placed at the back of fringe.
the queue, and old nodes, which are shallower than the new nodes, get expanded first. There is
one slight tweak on the general graph-search algorithm, which is that the goal test is applied to
each node when it is generated rather than when it is selected for expansion
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence Artificial Intelligence
Step 4: Node C is removed from fringe and is expanded. Its children D and G are added to
the back of fringe.
Figure 2
Frontier: B C
Figure 4
Step 3: Node B is removed from fringe and is expanded. Its children D, E are generated and Frontier: D E D G
Step 5: Node D is removed from fringe. Its children C and F are generated and added to the
back of fringe.
Figure 6
Frontier: D G C F
ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof ISE/Vemana Institute of Technology 2023 R.Vijaya Lakshmi,Asst.Prof
Artificial Intelligence
Figure 7
Frontier: G C F B F
Step 8: G is selected for expansion. It is found to be a goal node. So the algorithm returns the
path A C G by following the parent pointers of the node corresponding to G. The algorithm
terminates.
• Otherwise, breadth first search finds a solution with the shortest path length.
• Time complexity : O(bd )
• Space complexity : O(bd )
• Optimality :Yes
b - branching factor(maximum no of successors of
any node), d – Depth of the shallowest goal node
Maximum length of any path (m) in search space
Advantages:
Disadvantages:
➢ Requires the generation and storage of a tree whose size is exponential the depth of
the shallowest goal node.
A State Space Graph
➢ The breadth first search algorithm cannot be effectively used unless the search space is
quite small. Step 1: Initially fringe contains only the node for A.
Applications Of Breadth-First Search Algorithm
GPS Navigation systems: Breadth-First Search is one of the best algorithms used to find neighboring
locations by using the GPS system.
Broadcasting: Networking makes use of what we call as packets for communication. These packets
follow a traversal method to reach various networking nodes. One of the most commonly used traversal
methods is Breadth-First Search. It is being used as an algorithm that is used to communicate Figure 1
broad casted packets across all the nodes in a network. FRINGE: A
chosen for expansion. This must be the deepest unexpanded node because it is one deeper than its FRINGE: B C
parent—which, in turn, was the deepest unexpanded node when it was selected. Step 3: Node B is removed from fringe, and its children D and E are pushed in front of fringe.
FRINGE: D E C FRINGE: G F E C
Step 4: Node D is removed from fringe. C and F are pushed in front of fringe. The solution path A-B-D-C-G is returned and the algorithm terminates.
Figure 4 3. The space taken is linear in the depth of the search tree, O(bN).
FRINGE: C F E C Note that the time taken by the algorithm is related to the maximum depth of the search tree. If the search
tree has infinite depth, the algorithm may not terminate. This can happen if the search space is infinite. It
Step 5: Node C is removed from fringe. Its child G is pushed in front of fringe. can also happen if the search space contains cycles. The latter case can be handled by checking for cycles
in the algorithm. Thus Depth First Search is not complete.
Figure 5
Figure 5
FRINGE: G F E C
Step 6: Node G is expanded and found to be a goa node.