AI Notes PDF
AI Notes PDF
AI Notes PDF
Chapter 1:
Introduction to Artificial
Definition: Intelligence
"It is a branch of computer science by which intelligent machines is created which can behave
like a human, think like humans, and able to make decisions."
Or
According to the father of Artificial Intelligence, John McCarthy, it is “The science and
engineering of making intelligent machines, especially intelligent computer programs”.
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."
Components of Intelligence:
1) Learning
2)Reasoning
3)Linguistic Intelligence
4)Perception
5) Problem solving
1) Learning:
2) Reasoning − It is the set of processes that enables us to provide basis for judgement,
making decisions, and prediction.
3)Problem Solving − It is the process in which one perceives and tries to arrive at a desired
solution from a present situation by taking some path, which is blocked by known or unknown
hurdles.
Page 1
Artificial Intelligence (6th sem) BCA
Problem solving also includes decision making, which is the process of selecting the best
suitable alternative out of multiple alternatives to reach the desired goal are available.
5)Linguistic Intelligence − It is one’s ability to use, comprehend, speak, and write the verbal
and written language. It is important in interpersonal communication.
7) Spatial Learning − It is learning through visual stimuli such as images, colors, maps, etc. For
Example, A person can create roadmap in mind before actually following the road.
Philosophy of AI
While exploiting the power of the computer systems, the curiosity of human, lead him to wonder,
“Can a machine think and behave like humans do?”
Thus, the development of AI started with the intention of creating similar intelligence in
machines that we find and regard high in humans.
Types of AI
o Narrow AI is a type of AI which is able to perform a dedicated task with intelligence. The
most common and currently available AI is Narrow AI in the world of Artificial
Intelligence.
o Narrow AI cannot perform beyond its field or limitations, as it is only trained for one
specific task. Hence it is also termed as weak AI. Narrow AI can fail in unpredictable ways
if it goes beyond its limits.
Page 2
Artificial Intelligence (6th sem) BCA
o Apple Siri is a good example of Narrow AI, but it operates with a limited pre-defined range
of functions.
o IBM's Watson supercomputer also comes under Narrow AI, as it uses an Expert system
approach combined with Machine learning and natural language processing.
o Some Examples of Narrow AI are playing chess, purchasing suggestions on e-commerce
site, self-driving cars, speech recognition, and image recognition.
2. General AI:
o General AI is a type of intelligence which could perform any intellectual task with
efficiency like a human.
o The idea behind the general AI to make such a system which could be smarter and think
like a human by its own.
o Currently, there is no such system exist which could come under general AI and can
perform any task as perfect as a human.
o The worldwide researchers are now focused on developing machines with General AI.
o As systems with general AI are still under research and it will take lots of efforts and time
to develop such systems.
3. Super AI:
Goals of AI
To Create Expert Systems − The systems which exhibit intelligent behavior, learn,
demonstrate, explain, and advice its users.
Page 3
Artificial Intelligence (6th sem) BCA
It is the ability to speak, recognize and use the mechanism of grammar, semantic and
phonology, It is an ability to think and express the scenario easily as user understands
2) Musical Intelligence
3) Spatial Intelligence
It is an ability to think in virtualization this builds the capacity to visualize the things
manipulate the images, construct 3D images etc.
4) Interpersonal Intelligence
5) Intrapersonal Intelligence
Page 4
Artificial Intelligence (6th sem) BCA
It is the capacity to manipulate the object by using physical skills this involves timings,
perfection
7) Logical-mathematical Intelligence
Knowledge
Humans are best at understanding, reasoning, and interpreting knowledge. Human knows things,
which is knowledge and as per their knowledge they perform various actions in the real
world. But how machines do all these things comes under knowledge representation and
reasoning. Hence we can describe Knowledge representation as following:
o Knowledge representation and reasoning (KR, KRR) is the part of Artificial intelligence
which concerned with AI agents thinking and how thinking contributes to intelligent
behavior of agents.
o It is responsible for representing information about the real world so that a computer can
understand and can utilize this knowledge to solve the complex real world problems such
as diagnosis a medical condition or communicating with humans in natural language.
o It a way which describes to represent knowledge in artificial intelligence. Knowledge
representation is not just storing data into some database, but it also enables an intelligent
machine to learn from that knowledge and experiences so that it can behave intelligently
like a human.
Page 5
Artificial Intelligence (6th sem) BCA
Object: All the facts about objects in our world domain. E.g., Guitars contains strings,
trumpets are brass instruments.
Events: Events are the actions which occur in our world.
Performance: It describe behavior which involves knowledge about how to do things.
Meta-knowledge: It is knowledge about what we know.
Facts: Facts are the truths about the real world and what we represent.
Knowledge-Base: The central component of the knowledge-based agents is the knowledge
base. It is represented as KB. The Knowledgebase is a group of the Sentences (Here,
sentences are used as a technical term and not identical with the English language).
Types of knowledge
1. Declarative Knowledge:
2. Procedural Knowledge
3. Meta-knowledge:
4. Heuristic knowledge:
5. Structural knowledge:
Page 6
Artificial Intelligence (6th sem) BCA
2) Frame Representation
3) Production rules
4) Logical representation
In this approach knowledge is represented in the form of graphical network here the nodes
are represents objects and they describes their relationship between the object.
It is easy to understand
It is easy to extend the
knowledge Example
Jerry is a cat
Jerry is a mammal
Jerry is owned by priya
Jerry is brown in color
All mammals are animals
In the above example Jerry, cat, priya, brown, animals, mammals are the objects and the
relationship between the objects are represented by using IS-A,IN-COLOR,IS-OWNED_BY,etc
relationships as shown below .
Page 7
Artificial Intelligence (6th sem) BCA
2) Frame representation
The frame is record like a structure which contains collection of attribute and its
value to describe real world entity.
The frame is a data structure in AI which is a collection of values for single slot.
This is also called as slot filter knowledge representation
Ex: priya is a doctor and her age is 30 she lives in delhi and she is married.
Name Priya
Profession Doctor
Age 30
Place Delhi
Marital status Married
3) Production rules:
Page 8
Artificial Intelligence (6th sem) BCA
The condition contains the production rules if it matches the condition then it
performs corresponding action.
This is also called as recognize act cycle
4) Logical representation:
The logical representation means drawing the conclusion based on various condition.
Each sentence can be translated into the logic using syntax and semantics and it is categorized
into 2 types
1) Propositional logic
2) Predicate logic
1) Propositional logic
2) Predicate logic
It is extended form of a propositional logic it is also called as first order predicate logic .
It contains objects, relations and function.
It has connectors like for all and there exit’s.
Page 9
Artificial Intelligence (6th sem) BCA
Modification in the program leads to Can modify even a minute piece of information
change in its structure. of program without affecting its structure.
History of AI
In 1950, Alan Turing devised the Turing test. If a machine could carry on a conversation
that was indistinguishable from a conversation with a human being, then it was
reasonable to say that the machine was thinking.
1956 to 74 is called as the golden era for AI. The Wabot project in 1967 built a robot that
could measure distances and directions to objects using external receptors, artificial eyes,
and ears. And its conversation system allowed it to communicate with a person in
Japanese, with an artificial mouth.
In the 1980s a form of AI program called Expert Systems was adopted by corporations
around the world and knowledge became the focus of mainstream AI research.
A new paradigm called Intelligent Agents became widely accepted during the 1990s. It is
a system that perceives its environment and takes actions that maximize its chances of
success.
In the first decades of the 21st century, access to large amounts of data, faster computers,
and advanced machine learning techniques was successfully applied to many problems
throughout the economy.
Page 10
Artificial Intelligence (6th sem) BCA
In 2000, Professor Cynthia Breazeal developed Kismet, a robot that could recognize and
simulate emotions with its face. It was structured like a human face with eyes, lips,
eyelids, and eyebrows.
In 2009, Google secretly developed a driverless car. By 2014, it passed Nevada’s
self- driving test.
Research areas of AI
1. Expert System
Ex : procto, mycin
It is the branch of AI that deals with interaction between the computer and the
humans using natural language.
The objective of NLP is to read, understand and make a sense of human
3) Fuzzy logic
4) Neural network
Page 11
Artificial Intelligence (6th sem) BCA
5) Robotics
It is the branch of AI and engineering that involves conception, design, manufacture and
operation of robots
It deals with study of creating intelligent and efficient machines.
Its is used in industries for cutting, welding, drilling etc.
It is used in military, medical field, entertainment.
Applications of AI
Gaming − AI plays crucial role in strategic games such as chess, poker, tic-tac-toe, etc.,
where machine can think of large number of possible positions based on heuristic
knowledge.
Natural Language Processing − It is possible to interact with the computer that
understands natural language spoken by humans.
Expert Systems − There are some applications which integrate machine, software, and
special information to impart reasoning and advising. They provide explanation and
advice to the users.
Vision Systems − These systems understand, interpret, and comprehend visual input on
the computer.
For example,
A spying aero plane takes photographs, which are used to figure out spatial
information or map of the areas.
Doctors use clinical expert system to diagnose the patient.
Police use computer software that can recognize the face of criminal with the
stored portrait made by forensic artist.
Page 12
Artificial Intelligence (6th sem) BCA
Task domains of AI
1) Formal Task (rules and regulations)
This task having fixed rules and logics to be applied.
It includes developing Games
It includes developing mathematical applications, theorem -proving, mathematical
calculations.
3) Expert Task
These are the task that are done by same domain experts
It contains the task like fault finding, manufacturing, monitoring etc.
It is used in mission planning for under water vehicles, matlabs etc.
It contains task in the field of scientific analysis, financial analysis, medical
diagnosis.
Page 13
Chapter 2: Agent and Environment
Agent:
An agent is anything that can be viewed as perceiving its environment through sensors
and acting upon that environment through actuators.
An Agent runs in the cycle of perceiving, thinking, and acting.
The agent receives the information from the environment from sensors and store and
process the information in the agent program do the actions by using the effectors.
Sensors:
Sensor is a device which detects the change in the environment and sends the information
to other electronic devices.
Sensors can be camera, infrared ray’s devices, keyboard, eye, ear
etc. Effectors:
Effectors are the devices which affect the environment.
Effectors can be legs, wheels, arms, fingers, wings, fins, and display
screen. Actuators:
Actuators are the component of machines that converts energy into motion.
The actuators are only responsible for moving and controlling a system.
An actuator can be an electric motor, gears, rails,
etc The agent can be
1) Software as agent Software agent can have keystrokes, file contents as sensory input and act
on those inputs and display output on the screen.
2) Robot as an agent A robotic agent can have cameras, infrared range finder, NLP for sensors
and various motors for actuators.
Chapter 2: Agent and Environment
3) Human as an agent A human agent has eyes, ears, and other organs which work for sensors
and hand, legs, vocal tract work for actuators.
Terminologies related to Agent:
Percept (Sense): It is the agent’s perceptual data at the present
instance. Example: The automated AC detects the temperature at 10 o
clock.
Percept Sequence: It is the history of all the percept the agent receives till
now. Example: The automated AC can store the temperature it sensed till now.
Agent Function: An agent function is a map from the percept sequence (history of all
that an agent has perceived till date) to an action.
Agent program: It is an implementation of agent function.
Performance of the agent: It is the criteria used to determine how the agent is successful
in its action.
Example: if it is a self driving car performance is analyzed by the time it takes to reach
the destination .if it reaches the destination at the given time then that agent is successful
in its task and user says that it is performing well.
Behavior of the agent: It is the action that agent performs after any given sequence of
percepts.
Example: For the self driving if the car applies break properly if any vehicle comes in
front of it suddenly then we will say it is acting correctly to the received actions.
Structure of the Agent
An intelligent agent is a combination of Agent Program and Architecture.
Intelligent Agent = Agent Program + Architecture
Architecture is a machine in which the agent runs.
The agent program is an implementation of an agent function.
Example:
Washing Machine is an AI agent so it consists of two things
The agent program is programming chip the machine contains.
The architecture is the washing machine’s hardware parts or washing machine
itself. Example of an agent, environment and its structure
Chapter 2: Agent and Environment
Consider the above vacuum cleaner and list the following properties for it.
Environment: Room A and Room B.
Status of environment: Dirty, Clean
Percept: [location and status] i.e. [A,
dirty] Action: left, right, suck no
operation.
Agent function: it is mapping between the percept sequence and the action
In the above example the vacuum cleaner will works in two room A and B,it will
move from A and B automatically if current room it clean
Its moving actions are left and right and it will perform suck operation if it detects
the dirt.
Observe the following list of percept and actions
Percept Actions
[A, dirty] Suck
[A, clean] Right
[B. dirty] suck
[B, clean] Left
[A, clean][A, dirty] suck
Intelligent Agent :
An agent which acts in a way that is expected to maximize to its performance measure,
given the evidence provided by what it perceived and whatever built-in knowledge it has.
Rationality is nothing but status of being reasonable, sensible, and having good sense of
judgment.
Rationality of Agent:
It is the performance measure of the agent which would defines the criteria of success.
Example:
Chapter 2: Agent and Environment
Consider the vacuum cleaner which cleanse two rooms A and B, it can take rest for some
time by going to sleep mode. It may make the noise while sucking.
So to measure the performance its cleanliness is not only the criteria but we must
consider its noise, it’s time to travel between two rooms, its sleeping time etc will come
into picture while deciding its performance.
Rationality of the agent is measured by following criteria:
The performance measure that defines the criterion of success.
The agent prior knowledge of the environment.
The possible actions that the agent can
perform. The agent’s percept sequence to date.
PEAS
Task environment of any agent is decided by PEAS.
Following are the Properties of the agent to be listed while designing the rational agent.
P: Performance of the AI system.
E: Environment in which it acts.
A: Actuators
S: Sensors
PEAS for Self driving car
Performance: Safety, time, legal drive, comfort.
Environment: Roads, other cars, pedestrians, road signs.
Actuators: Steering, accelerator, brake, signal, horn.
Sensors: Camera, sonar, GPS, Speedometer, odometer, accelerometer, engine sensors,
keyboard.
PEAS for Vacuum cleaner
Performance: cleanness, efficiency: distance traveled to clean,battery life, security.
Environment: room, table, wood floor, carpet, different obstacles.
Actuators: wheels, different brushes, vacuum extractor.
Sensors: camera, dirt detection sensor, cliff sensor, bump sensors, infrared wall sensors.
Chapter 2: Agent and Environment
Simple reflex agents act only on the basis of the current percept.
The agent function is based on the condition-action rule i.e If (condition) then else
A condition-action rule is a rule that maps a state i.e, condition to an action.
If the condition is true, then the action is taken, else not.
Example: if( temp>40 )
Then
Turn on the AC.
This agent function only succeeds when the environment is fully observable
environment. Limitations:
Very limited intelligence.
No knowledge of non-perceptual parts of state.
Usually too big to generate and store.
Chapter 2: Agent and Environment
If there occurs any change in the environment, then the collection of rules need to be
updated.
2) Model Reflex agent
These are the agents with memory. It stores the information about the previous state, the
current state and performs the action accordingly.
It mainly has two parts
1) Model: It represents the knowledge about the world.it stores the complete aspects of the task
that agent is performing.
Example: If it is a self driving car then Model contains complete knowledge about driving car .
2) Internal representation: It represents the mapping between the current percept and the
previous history of the agent.
Example: while driving, if the driver wants to change the lane, he looks into the mirror to
know the present position of vehicles behind him. While looking in front, he can only see
the vehicles in front, and as he already has the information on the position of vehicles
behind him (from the mirror a moment ago), he can safely change the lane.
The previous and the current state get updated quickly for deciding the
action. It works well in partially observable environment
3) Goal Based Agent:
Chapter 2: Agent and Environment
These agents are used when there is multiple options to achieve the goal and to determine
which option is best.
The utility based agent chooses the best option based on the users preferences, utility
describes the happiness of the agent along with reaching the goal.
i.e. Sometimes achieving the desired goal is not enough. We may look for a quicker,
safer, cheaper trip to reach a destination.
The utility based agent chooses the action which gives maximum degree of happiness or
satisfaction.
Example: for a self driving car the destination is known, but there are multiple
routes. Choosing an appropriate route also matters to the overall success of the agent.
There are many factors in deciding the route like the shortest one, the comfortable
one, etc.
Chapter 2: Agent and Environment
5) Learning Agent:
A learning agent in AI is the type of agent which can learn from its past experiences or it
has learning capabilities.
It starts to act with basic knowledge and then able to act and adapt automatically through
learning.
A learning agent has mainly four conceptual components, which are:
Learning element: It is responsible for making improvements by learning from the environment
Critic: Learning element takes feedback from critic (Analysis )which describes how well the
agent is doing with respect to a fixed performance standard.
Performance element: It is responsible for selecting external action
Problem Generator: This component is responsible for suggesting actions that will lead to new
and informative experiences.
Example: Human is the best example for learning agent who can learn the things from
environment and can analyze whether it is right or wrong and act on the environment
when it is required.
Types of environment
1. Fully Observable vs. Partially Observable
When an agent sensor is capable to sense or access the complete state of an agent at each
point in time, it is said to be a fully observable environment.
If an agent is not capable to sense the complete state of the agent at each point of time is
called as it is partially observable.
Chapter 2: Agent and Environment
Example:
Vacuum cleaner in the room whose environment will not change as the it cleans the room
every time so it is static environment
Chess game the coins will move each and every minutes so it is dynamic environment
5. Discrete vs. Continuous
If an environment consists of a finite number of actions that can be deliberated in the
environment to obtain the output, it is said to be a discrete environment.
The environment in which the actions performed cannot be numbered ie. is not discrete,
is said to be continuous.
Example:
Self-driving cars are an example of continuous environments as their actions is driving,
parking, etc. which cannot be numbered.
The game of chess is discrete environment as it has only a finite number of moves. The
number of moves might vary with every game, but still, it’s finite.
If in an environment an action on current situation will not affects the actions on present
and previous sates then it is called as episodic environment.
Here set of actions will perform based on current percept and it will not affect the next
actions.
Example:-
Chat bot: It is the best example of episodic environment because it will answers the
particular question we asked and the next answer will not be linked to the previous
questions.
Chess: This is an example of sequential because every move in chess will depends on its
previous moves and the every current move will affect next move.
7. Known vs Unknown
Chapter 2: Agent and Environment
o Known and unknown are not actually a feature of an environment, but it is an agent's
state of knowledge to perform an action.
o In a known environment, the results for all actions are known to the agent. While in
unknown environment, agent needs to learn how it works in order to perform an action.
8. Accessible vs Inaccessible
o If an agent can obtain complete and accurate information about the state's environment,
then such an environment is called an Accessible environment else it is called
inaccessible.
o An empty room whose state can be defined by its temperature is an example of an
accessible environment.
o Information about an event on earth is an example of Inaccessible environment.
S
Chapter 3: Popular Search Algorithms
The essential properties of search algorithms to compare the efficiency of the algorithms are as
follows:
Space Complexity: It is the maximum storage space required at any point during the search, as
the complexity of the problem.
Based on the search problems the search algorithms are classified into uninformed (Blind
search) search and informed search (Heuristic search) algorithms.
Uninformed/Blind Search:
The uninformed search does not contain any domain knowledge such as closeness, the
location of the goal.
It operates in a brute-force way as it only includes information to traverse the tree and to
identify leaf and goal nodes.
S
Chapter 3: Popular Search Algorithms
Uninformed search applies a way in which search tree is searched without any
information about the search space like initial state operators and test for the goal, so it is
also called blind search.
It examines each node of the tree until it achieves the goal node.
It is divided into five main types:
o Breadth-first search
o Uniform cost search
o Depth-first search
o Iterative deepening depth-first search
o Bidirectional Search
Informed Search
Informed search algorithms use domain knowledge. In an informed search, problem
information is available which guides the search.
An informed search strategy finds a solution more efficiently than an uninformed search
strategy. Informed search is also called a Heuristic search.
A heuristic is a way, which might not always be guaranteed for best solutions but
guaranteed to find a good solution in reasonable time.
Informed search can solve much complex problem, which could not be solved in another
way.
Informed search algorithms is categorized into two types
1. Greedy Search
2. A* Search
It provides the direction regarding the No suggestion is given regarding the solution in
solution. it.
Greedy Search, A* Search, Graph Search Depth First Search, Breadth First Search
1. Breadth-first Search
2. Depth-first Search
Breadth-first Search:
Breadth-first search is the most common search strategy for traversing a tree or graph. This
algorithm searches breadth wise in a tree or graph, so it is called breadth-first search.
BFS algorithm starts searching from the root node of the tree and expands all successor nodes at
the current level before moving to nodes of next level.
The breadth-first search algorithm is an example of a general-graph search algorithm.
Breadth-first search implemented using FIFO queue data structure.
S
Chapter 3: Popular Search Algorithms
Advantages:
BFS will provide a solution if any solution exists.
If there is more than one solution for a given problem, then BFS will provide the minimal
solution, which requires the least number of steps.
Disadvantages:
It requires lots of memory since each level of the tree must be saved into memory to
expand the next level.
BFS needs lots of time if the solution is far away from the root node.
Example:
In the below tree structure, the traversing of the tree using BFS algorithm from the root node S to
goal node K is performed. BFS search algorithm traverse in layers, so it will follow the path,
which is shown by the dotted arrow, and the traversed path will be:
Time Complexity: Time Complexity of BFS algorithm is obtained by the number of nodes
traversed in BFS until the shallowest Node.
Where d= depth of shallowest solution
b is a node at every state.
Space Complexity: Space complexity of BFS algorithm is given by the Memory size which is
given by O(bd)
Completeness: BFS is complete, which means if the shallowest goal node is at some finite
depth, then BFS will find a solution.
Optimality: BFS is optimal if path cost is a non-decreasing function of the depth of the node.
Depth-first Search
Depth-first search is a recursive algorithm for traversing a tree or graph data structure.
It is called the depth-first search because it starts from the root node and follows each path to its
greatest depth node before moving to the next path.
DFS uses a stack data structure for its implementation and the process of the DFS algorithm is
similar to the BFS algorithm.
Note: Backtracking is an algorithm technique for finding all possible solutions using recursion.
Advantage:
DFS requires very less memory as it only needs to store a stack of the nodes on the path from root
node to the current node.
It takes less time to reach to the goal node than BFS algorithm (if it traverses in the right path).
Disadvantage:
There is the possibility that many states keep re-occurring, and there is no guarantee of finding the
solution.
DFS algorithm goes for deep down searching and sometime it may go to the infinite loop.
S
Chapter 3: Popular Search Algorithms
Example:
In the below search tree, it will follow the order as: Root node--->Left node > right node.
It start searching from root node S, and traverse A, then B, then D and E, after traversing E, it
will backtrack the tree as E has no other successor and still goal node is not found. After
backtracking it will traverse node C and then G, and here it will terminate as it found goal node.
Completeness: DFS search algorithm is complete within finite state space, as it will expand every
node within a limited search tree.
Time Complexity: Time complexity of DFS will be equivalent to the node traversed by the
algorithm.
It is given by: T(n)= 1+ n2+ n3 +........+ nm=O(nm)
Where, m= maximum depth of any node and this can be much larger than d (Shallowest
solution depth)
S
Chapter 3: Popular Search Algorithms
Space Complexity: DFS algorithm needs to store only single path from the root node, hence
space complexity of DFS is equivalent to the size of the fringe set, which is O(bm).
Optimal: DFS search algorithm is non-optimal, as it may generate a large number of steps or
high cost to reach to the goal node.
The informed search algorithm is more useful for large search space. Informed search algorithm
uses the idea of heuristic, so it is also called Heuristic search.
Heuristics function:
Heuristic is a function which is used in Informed Search, and it finds the most promising path. It
takes the current state of the agent as its input and produces the estimation of how close agent is
from the goal.
The heuristic method, might not always give the best solution, but it guaranteed to find a good
solution in reasonable time.
Heuristic function estimates how close a state is to the goal.
It is represented by h (n), and it calculates the cost of an optimal path between the pair of states.
The value of the heuristic function is always positive.
Admissibility of the heuristic function is given as:
Hence heuristic cost should be less than or equal to the estimated cost.
In the best first search algorithm, expand the node which is closest to the goal node and the
closest cost is estimated by heuristic function, i.e.f(n)= h(n).
Advantages:
Best first search can switch between BFS and DFS by gaining the advantages of both the
algorithms.
This algorithm is more efficient than BFS and DFS algorithms.
Disadvantages:
It can behave as an unguided depth-first search in the worst case scenario.
It can get stuck in a loop as DFS.
This algorithm is not optimal.
Example:
Consider the below search problem, traverse it using greedy best-first search. At each iteration,
each node is expanded using evaluation function f(n)=h(n) , which is given in the below table.
S
Chapter 3: Popular Search Algorithms
In this search example, two lists are created, which are OPEN and CLOSED Lists.
Following are the iteration for traversing the above example.
S
Chapter 3: Popular Search Algorithms
Iteration2: Open[E,F,A],Closed[S,B]
: Open [E, A], Closed [S, B, F]
Iteration3: Open[I,G,E,A],Closed[S,B,F]
: Open [I, E, A], Closed [S, B, F, G]
Time Complexity: The worst case time complexity of Greedy best first search is O(bm).
Space Complexity: The worst case space complexity of Greedy best first search is O(bm).
Where, m is the maximum depth of the search space.
Complete: Greedy best-first search is also incomplete, even if the given state space is finite.
Optimal: Greedy best first search algorithm is not optimal.
A* Search Algorithm:
Algorithm of A* search:
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation function ,
if node n is goal node then return success and stop, otherwise
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each
successor n', check whether n' is already in the OPEN or CLOSED list, if not then compute
evaluation function for n' and place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back
pointer which reflects the lowest g(n') value.
Advantages:
A* search algorithm is the best algorithm than other search algorithms.
A* search algorithm is optimal and complete.
This algorithm can solve very complex problems.
Disadvantages:
It does not always produce the shortest path as it mostly based on heuristics and
approximation.
A* search algorithm has some complexity issues.
The main drawback of A* is memory requirement as it keeps all generated nodes in the
memory, so it is not practical for various large-scale problems.
Example:
The heuristic value of all states is given in the below table. Calculate the f(n) of each state using
the formula f(n)= g(n) + h(n), where g(n) is the cost to reach any node from start state.
S
Chapter 3: Popular Search Algorithms
Solution:
S
Chapter 3: Popular Search Algorithms
Iteration3: {(S--> A-->C--->G, 6), (S--> A-->C--->D, 11), (S--> A-->B, 7), (S-->G, 10)}
Iteration 4 will give the result, as S--->A--->C--->G it provides the optimal path with cost 6.
Points to remember:
A* algorithm returns the path which occurred first, and it does not search for all
remaining paths.
The efficiency of A* algorithm depends on the quality of heuristic.
Optimal: If the heuristic function is admissible, then A* tree search will always find the least
cost path.
If the heuristic function is admissible, then A* tree search will always find the least cost path.
Time Complexity: The time complexity of A* search algorithm depends on heuristic function,
and the number of nodes expanded is exponential to the depth of solution d. So the time
complexity is O(bd), where b is the branching factor.
Hill climbing algorithm is a local search algorithm, which continuously moves in the direction
of increasing elevation/value to find the peak of the mountain or best solution to the problem.
It terminates when it reaches a peak value where no neighbor has a higher value.
Hill climbing algorithm is a technique, which is used for optimizing the mathematical problems.
S
Chapter 3: Popular Search Algorithms
It is also called greedy local search as it only looks to its good immediate neighbor state and not
beyond that.
A node of hill climbing algorithm has two components, which are state and value.
Hill Climbing is mostly used when a good heuristic is available.
Algorithm
S
Chapter 3: Popular Search Algorithms
Local Maximum: Local maximum is a state, which is better than its neighbor states, but
there is also another state, which is higher than it.
Global Maximum: Global maximum is the best possible state of state space landscape.
It has the highest value of objective function.
Current state: It is a state in a landscape diagram where an agent is currently present.
Flat local maximum: It is a flat space in the landscape where all the neighbor states of
current states have the same value.
Shoulder: It is a plateau region, which has an uphill edge.
1. Local Maximum: A local maximum is a peak state in the landscape which is better than each
of its neighboring states, but there is another state also present which is higher than the local
maximum.
Solution: Backtracking technique can be a solution of the local maximum in state space
landscape. Create a list of the promising path so that the algorithm can backtrack the search
space and explore other paths as well.
S
Chapter 3: Popular Search Algorithms
2. Plateau: A plateau is the flat area of the search space in which all the neighbor states of the
current state contains the same value, because of this algorithm does not find any best direction
to move. A hill-climbing search might be lost in the plateau area.
Solution: The solution for the plateau is to take big steps or very little steps while searching, to
solve the problem. Randomly select a state, which is far away from the current state so it is
possible that the algorithm could find non-plateau region.
3. Ridges: A ridge is a special form of the local maximum. It has an area which is higher than its
surrounding areas, but itself has a slope, and cannot be reached in a single move.
Solution: With the use of bidirectional search, or by moving in different directions, we can
improve this problem.
S
Chapter 3: Popular Search Algorithms
Simulated Annealing:
A hill-climbing algorithm, which never makes a move towards a lower value, guaranteed to be
incomplete because it can get stuck on a local maximum. In addition, if algorithm applies a
random walk, by moving a successor, then it may complete but not efficient.
Simulated Annealing is an algorithm, which yields both efficiency and completeness.
In mechanical term Annealing is a process of hardening a metal or glass to a high temperature
then cooling gradually, so this allows the metal to reach a low-energy crystalline state. The
same process is used in simulated annealing in which the algorithm picks a random move,
instead of picking the best move.
If the random move improves the state, then it follows the same path. Otherwise, the algorithm
follows the path which has a probability of less than 1 or it moves downhill and chooses
another path.
there is a clear tradeoff between the quality of the solutions and the time required to compute
them
In this algorithm, it holds k number of states at any given time. At the start, these states are
generated randomly. The successors of these k states are computed with the help of objective
function. If any of these successors is the maximum value of the objective function, then the
algorithm stops.
Otherwise the (initial k states and k number of successors of the states = 2k) states are placed in a
pool. The pool is then sorted numerically. The highest k states are selected as new initial states.
This process continues until a maximum value is reached.
S
Chapter 3: Popular Search Algorithms
Algorithm
The conventional logic block that a computer can understand takes precise input and produces a
definite output as TRUE or FALSE, which is equivalent to human’s YES or NO.
The human decision making includes a range of possibilities between YES and NO, such as
CERTAINLY YES
POSSIBLY YES
CANNOT SAY
POSSIBLY NO
S
Chapter 4: Fuzzy logic Systems
CERTAINLY NO
The fuzzy logic works on the levels of possibilities of input to achieve the definite
output.
Implementation
It can be implemented in systems with various sizes and capabilities ranging from small
micro-controllers to large, networked, workstation-based control systems.
Rule base: It contains the set of rules and the IF-THEN conditions provided by the experts to
govern the decision-making system, based on linguistic information. Recent developments in
fuzzy theory offer several effective methods for the design and tuning of fuzzy controllers.
Fuzzification – This step converts inputs or the crisp numbers into fuzzy sets. You can measure
the crisp inputs by sensors and pass them into the control system for further processing. It splits the
input signal into five steps such as
Inference Engine: It determines the degree of match between fuzzy input and the rules.
According to the input field, it will decide the rules that are to be fired. Combining the fired
rules, form the control actions.
Defuzzification – The Defuzzification process converts the fuzzy sets into a crisp value. There
are different types of techniques available, and need to select the best-suited one with an expert
system.
It is used in the aerospace field for altitude control of spacecraft and satellite.
This controls the speed and traffic in the automotive systems.
It is used for decision-making support systems and personal evaluation in the large
company business.
It also controls the pH, drying, chemical distillation process in the chemical industry.
Fuzzy logic is used in Natural language processing and various intensive applications in
Artificial Intelligence.
It is extensively used in modern control systems such as expert systems.
Fuzzy Logic mimics how a person would make decisions, only much faster and used in
Neural Networks.
Membership Function
The membership function is a graph that defines how each point in the input space is mapped to
membership value between 0 and 1. It allows you to quantify linguistic terms and represent a
fuzzy set graphically. A membership function for a fuzzy set A on the universe of discourse X is
defined as μA:X → [0,1]
The design of a fuzzy logic system starts with a set of membership functions for each input and a
set for each output. A set of rules is then applied to the membership functions to yield a crisp
output value.
Algorithm
Development
Step 1 − Define linguistic variables and terms
Linguistic variables are input and output variables in the form of simple words or sentences. For
room temperature, cold, warm, hot, etc., are linguistic terms.
Temperature (t) = {very-cold, cold, warm, very-warm, hot}
Every member of this set is a linguistic term and it can cover some portion of overall
temperature values.
Step 2 − Construct membership functions for them
The membership functions of temperature variable are as shown
Step3 − Construct knowledge base rules
Create a matrix of room temperature values versus target temperature values that an air
conditioning system is expected to provide.
Build a set of rules into the knowledge base in the form of IF-THEN-ELSE structures.
Condition Action
Speech
Written Text
Components of NLP
There are two components of NLP as given −
It is the process of producing meaningful phrases and sentences in the form of natural
language from some internal representation.
It involves −
Text planning − It includes retrieving the relevant content from knowledge base.
Sentence planning − It includes choosing required words, forming meaningful
phrases, setting tone of the sentence.
Text Realization − It is mapping sentence plan into sentence structure.
The NLU is harder than NLG.
Difficulties in NLU
For example, “He lifted the beetle with red cap.” − Did he use cap to lift the beetle or
he lifted a beetle that had red cap?
Referential ambiguity − Referring to something using pronouns. For example, Rima
went to Gauri. She said, “I am tired.” − Exactly who is tired?
One input can mean different meanings.
Many inputs can mean the same thing.
NLP Terminology
Phonology − It is study of organizing sound systematically.
Morphology − It is a study of construction of words from primitive meaningful units.
Morpheme − It is primitive unit of meaning in a language.
Syntax − It refers to arranging words to make a sentence. It also involves determining the structural r
Semantics − It is concerned with the meaning of words and how to combine words into meaningful phr
Pragmatics − It deals with using and understanding sentences in different situations and how the interpr
Discourse − It deals with how the immediately preceding sentence can affect the interpretation of the
World Knowledge − It includes the general knowledge about the world.
Tokenization- Tokenization is, generally, an early step in the NLP process, a step which splits longer stri
Normalization Normalization generally refers to a series of related tasks meant to put all text on a level p
Stop Words Stop words are those words which are filtered out before further processing
of text, since these words contribute little to overall meaning. For instance, "the," "and,"
and
"a," while all required words in a particular passage.
Parts-of-speech (POS) Tagging
POS tagging consists of assigning a category tag to the tokenized parts of a sentence.
The most popular POS tagging would be identifying words as nouns, verbs, adjectives,
etc.
Corpus In linguistics and NLP, corpus (literally Latin for body) refers to a collection of
texts. Such collections may be formed of a single language of texts, or can span multiple
languages -- there are numerous reasons for which multilingual corpora (the plural of
corpus) may be useful.
Steps in NLP
Pragmatic Analysis − During this, what was said is re-interpreted on what it actually
meant. It involves deriving those aspects of language which require real world
knowledge.
Context-Free Grammar
Top-Down Parser
Context-Free Grammar
It is the grammar that consists rules with a single symbol on the left-hand side of the rewrite
rules.
“The bird pecks the grains”
Articles (DET) − a | an | the
Nouns − bird | birds | grain | grains
Noun Phrase (NP) − Article + Noun | Article + Adjective + Noun
= DET N | DET ADJ N
Verbs − pecks | pecking | pecked
Verb Phrase (VP) − NP V | V NP
Adjectives (ADJ) − beautiful | small | chirping
The parse tree breaks down the sentence into structured parts so that the computer can easily
understand and process it. In order for the parsing algorithm to construct this parse tree, a set
of rewrite rules, which describe what tree structures are legal, need to be constructed.
. According to first order logic rule, if there are two strings Noun Phrase (NP) and Verb
Phrase (VP), then the string combined by NP followed by VP is a sentence. The rewrite
rules for the sentence are as follows −
S → NP VP
NP → DET N | DET ADJ N
VP → V NP
Lexocon −
DET → a | the
ADJ → beautiful | perching
N → bird | birds | grain | grains
V → peck | pecks | pecking
The parse tree can be created as shown –
Chapter 5 Natural Language Processing
Top-Down Parser
Here, the parser starts with the S symbol and attempts to rewrite it into a sequence
of terminal symbols that matches the classes of the words in the input sentence until it
consists entirely of terminal symbols.
These are then checked with the input sentence to see if it matched. If not, the process is
started over again with a different set of rules. This is repeated until a specific rule is found
which describes the structure of the sentence.
Merit − It is simple to implement.
Demerits −
Chapter 5 Natural Language Processing
High performance
Understandable
Reliable
Highly responsive
Demonstrating
Deriving a solution
Diagnosing
Explaining
Interpreting input
Predicting results
Knowledge Base
Inference Engine
User Interface
Knowledge Base
It contains domain-specific and high-quality knowledge.
Knowledge is required to exhibit intelligence. The success of any ES majorly
depends upon the collection of highly accurate and precise knowledge.
Knowledge Definition
The data is collection of facts. The information is organized as data and facts about the task
domain. Data, information, and past experience combined together are termed as
knowledge.
Knowledge representation
It is the method used to organize and formalize the knowledge in the knowledge base. It is in
the form of IF-THEN-ELSE rules.
Knowledge Acquisition
The success of expert system depends on the quality, completeness, and accuracy of the
information stored in the knowledge base.
The knowledge base is formed by readings from various experts, scholars, and
the Knowledge Engineers. The knowledge engineer is a person with the qualities of
empathy, quick learning, and case analyzing skills.
He acquires information from subject expert by recording, interviewing, and observing him
at work, etc. He then categorizes and organizes the information in a meaningful way, in the
form of IF-THEN-ELSE rules, to be used by interference machine. The knowledge engineer
also monitors the development of the ES.
Inference Engine
Use of efficient procedures and rules by the Inference Engine is essential in deducting a
correct, flawless solution.
In case of knowledge-based ES, the Inference Engine acquires and manipulates the
knowledge from the knowledge base to arrive at a particular solution.
Applies rules repeatedly to the facts, which are obtained from earlier rule application.
Resolves rules conflict when multiple rules are applicable to a particular case.
Forward Chaining
Backward Chaining
ARTIFICIAL INTELLIGENCE BCA
Forward Chaining
It is a strategy of an expert system to answer the question, “What can happen next?”
Here, the Inference Engine follows the chain of conditions and derivations and finally
deduces the outcome. It considers all the facts and rules, and sorts them before concluding to
a solution.
This strategy is followed for working on conclusion, result, or effect. For example,
prediction of share market status as an effect of changes in interest rates.
Backward Chaining
With this strategy, an expert system finds out the answer to the question, “Why this
happened?”
On the basis of what has already happened, the Inference Engine tries to find out which
conditions could have happened in the past for this result. This strategy is followed for
finding out cause or reason. For example, diagnosis of blood cancer in humans.
ARTIFICIAL INTELLIGENCE BCA
User Interface
User interface provides interaction between user of the ES and the ES itself. It
is generally Natural Language Processing so as to be used by the user who is
well-versed in the task domain. The user of the ES need not be necessarily an
expert in Artificial Intelligence.
The user interface makes it easy to trace the credibility of the deductions.
Its technology should be adaptable to user’s requirements; not the other way round.
o It can be broadly used for designing and manufacturing physical devices such as
The two popular ES used for this domain is an advisor and a tax advisor.
activity, and advise bankers that if they should provide loans for business or not.
o (PROLOG).
o Large databases.
Tools − They reduce the effort and cost involved in developing an expert system to
large extent.
ARTIFICIAL INTELLIGENCE BCA
Shells − A shell is nothing but an expert system without knowledge base. A shell
provides the developers with knowledge acquisition, inference engine, user interface,
and explanation facility. For example, few shells are given below −
o Java Expert System Shell (JESS) that provides fully developed Java API for
creating an expert system.
Know and establish the degree of integration with the other systems and databases.
Realize how the concepts can represent the domain knowledge best.
Unit 7 ROBOTICS
Introduction
Robots are the artificial agents acting in real world environment.
Objective
Robots are aimed at manipulating the objects by perceiving, picking, moving, modifying the
physical properties of object, destroying it, or to have an effect thereby freeing manpower
from doing repetitive functions without getting bored, distracted, or exhausted.
What is Robotics?
Robotics is a branch of AI, which is composed of Electrical Engineering, Mechanical
Engineering, and Computer Science for designing, construction, and application of robots.
Aspects of Robotics
The robots have mechanical construction, form, or shape designed to accomplish a
particular task.
They have electrical components which power and control the machinery.
They contain some level of computer program that determines what, when and how
a robot does something.
AI PROGRAMS ROBOTS
Robot Locomotion
Locomotion is the mechanism that makes a robot capable of moving in its environment.
ARTIFICIAL INTELLIGENCE BCA
Legged
Wheeled
Combination of Legged and Wheeled Locomotion
Tracked slip/skid
Legged Locomotion
This type of locomotion consumes more power while demonstrating walk, jump, trot,
hop, climb up or down, etc.
It comes with the variety of one, two, four, and six legs. If a robot has multiple legs
then leg coordination is necessary for locomotion.
The total number of possible gaits (a periodic sequence of lift and release events for each of
the total legs) a robot can travel depends upon the number of its legs.
In case of a two-legged robot (k=2), the number of possible events is N = (2k-1)! = (2*2-1)!
= 3! = 6.
Wheeled Locomotion
It requires fewer numbers of motors to accomplish a movement. It is little easy to implement
as there are less stability issues in case of more number of wheels. It is power efficient as
compared to legged locomotion.
Standard wheel − Rotates around the wheel axle and around the contact
Castor wheel − Rotates around the wheel axle and the offset steering joint.
Swedish 45o and Swedish 90o wheels − Omni-wheel, rotates around the contact
point, around the wheel axle, and around the rollers.
Slip/Skid Locomotion
In this type, the vehicles use tracks as in a tank. The robot is steered by moving the tracks
with different speeds in the same or opposite direction. It offers stability because of large
contact area of track and ground.
ARTIFICIAL INTELLIGENCE BCA
Components of a Robot
Power Supply − The robots are powered by batteries, solar power, hydraulic, or
pneumatic power sources.
Pneumatic Air Muscles − They contract almost 40% when air is sucked in them.
Muscle Wires − They contract by 5% when electric current is passed through them.
Sensors − They provide knowledge of real time information on the task environment.
Robots are equipped with vision sensors to be to compute the depth in the
environment. A tactile sensor imitates the mechanical properties of touch receptors
of human fingertips.
Computer Vision
This is a technology of AI with which the robots can see. The computer vision plays vital
role in the domains of safety, security, health, access, and entertainment.
Computer vision automatically extracts, analyzes, and comprehends useful information from
a single image or an array of images. This process involves development of algorithms to
accomplish automatic visual comprehension.
Power supply
A processor
A software
Face Detection − Many state-of-the-art cameras come with this feature, which
enables to read the face and take the picture of that perfect expression. It is used to
let a user access the software on correct match.
Agriculture
Autonomous vehicles
Biometrics
Character recognition
Face recognition
Gesture analysis
Geoscience
Medical imagery
Pollution monitoring
Process control
ARTIFICIAL INTELLIGENCE BCA
Remote sensing
Robotics
Transport
Applications of Robotics
Military − Autonomous robots can reach inaccessible and hazardous zones during
war. A robot named Daksh, developed by Defense Research and Development
Organization (DRDO), is in function to destroy life-threatening objects safely.
Medicine − The robots are capable of carrying out hundreds of clinical tests
simultaneously, rehabilitating permanently disabled people, and performing complex
surgeries such as brain tumors.
Exploration − The robot rock climbers used for space exploration, underwater
drones used for ocean exploration are to name a few.
The inventor of the first neurocomputer, Dr. Robert Hecht-Nielsen, defines a neural network
as "a computing system made up of a number of simple, highly interconnected processing
elements, which process information by their dynamic state response to external inputs.”
The human brain is composed of 86 billion nerve cells called neurons. They are connected
to other thousand cells by Axons. Stimuli from external environment or inputs from sensory
organs are accepted by dendrites. These inputs create electric impulses, which quickly travel
through the neural network. A neuron can then send the message to other neuron to handle
the issue or does not send it forward.
ARTIFICIAL INTELLIGENCE BCA
ANNs are composed of multiple nodes, which imitate biological neurons of human brain.
The neurons are connected by links and they interact with each other. The nodes can take
input data and perform simple operations on the data. The result of these operations is
passed to other neurons. The output at each node is called its activation or node value.
Each link is associated with weight. ANNs are capable of learning, which takes place by
altering weight values. The following illustration shows a simple ANN −
There are two Artificial Neural Network topologies − FeedForward and Feedback.
FeedForward ANN
In this ANN, the information flow is unidirectional. A unit sends information to other unit
from which it does not receive any information. There are no feedback loops. They are used
in pattern generation/recognition/classification. They have fixed inputs and outputs.
ARTIFICIAL INTELLIGENCE BCA
FeedBack ANN
Here, feedback loops are allowed. They are used in content addressable memories.
ARTIFICIAL INTELLIGENCE BCA
Working of ANNs
In the topology diagrams shown, each arrow represents a connection between two neurons
and indicates the pathway for the flow of information. Each connection has a weight, an
integer number that controls the signal between the two neurons.
If the network generates a “good or desired” output, there is no need to adjust the weights. If
the network generates a “poor or undesired” output or an error, then the system alters the
weights in order to improve subsequent results.
ANNs are capable of learning and they need to be trained. There are several learning
strategies −
Supervised Learning − It involves a teacher that is scholar than the ANN itself. For
example, the teacher feeds some example data about which the teacher already
knows the answers.
ARTIFICIAL INTELLIGENCE BCA
For example, pattern recognizing. The ANN comes up with guesses while
recognizing. Then the teacher provides the ANN with the answers. The network then
compares it guesses with the teacher’s “correct” answers and makes adjustments
according to errors.
In these networks, each node represents a random variable with specific propositions. For
example, in a medical diagnosis domain, the node Cancer represents the proposition that a
patient has cancer.
The edges connecting the nodes represent probabilistic dependencies among those random
variables. If out of two nodes, one is affecting the other then they must be directly connected
in the directions of the effect. The strength of the relationship between variables is
quantified by the probability associated with each node.
There is an only constraint on the arcs in a BN that you cannot return to a node simply by
following directed arcs. Hence the BNs are called Directed Acyclic Graphs (DAGs).
BNs are capable of handling multivalued variables simultaneously. The BN variables are
composed of two dimensions −
Range of prepositions
Consider a finite set X = {X1, X2, …,Xn} of discrete random variables, where each
variable Xi may take values from a finite set, denoted by Val(Xi). If there is a directed link
from variable Xi to variable, Xj, then variable Xi will be a parent of variable Xj showing direct
dependencies between the variables.
The structure of BN is ideal for combining prior knowledge and observed data. BN can be
used to learn the causal relationships and understand various problem domains and to predict
future events, even in case of missing data.
A knowledge engineer can build a Bayesian network. There are a number of steps the
knowledge engineer needs to take while building it.
Example problem − Lung cancer. A patient has been suffering from breathlessness. He
visits the doctor, suspecting he has lung cancer. The doctor knows that barring lung cancer,
there are various other possible diseases the patient might have such as tuberculosis and
bronchitis.
Is the patient a smoker? If yes, then high chances of cancer and bronchitis.
Is the patient exposed to air pollution? If yes, what sort of air pollution?
What values can they take? In which state can they be?
For now let us consider nodes, with only discrete values. The variable must take on exactly
one of these values at a time.
Ordered values − A node Pollution might represent and take values from {low,
medium, high} describing degree of a patient’s exposure to pollution.
For example, what causes a patient to have lung cancer? - Pollution and smoking. Then add
arcs from node Pollution and node Smoker to node Lung-Cancer.
Similarly if patient has lung cancer, then X-ray result will be positive. Then add arcs from
node Lung-Cancer to node X-Ray.
ARTIFICIAL INTELLIGENCE BCA
They can perform tasks that are easy for a human but difficult for a machine −
Aerospace − Autopilot aircrafts, aircraft fault detection.
Financial − Real estate appraisal, loan advisor, mortgage screening, corporate bond
rating, portfolio trading program, corporate financial analysis, currency value
prediction, document readers, credit application evaluators.
Medical − Cancer cell analysis, EEG and ECG analysis, prosthetic design, transplant
time optimizer.