0% found this document useful (0 votes)
18 views

A.I Notes

The document discusses artificial intelligence and provides information on what AI is, how it works, intelligent agents, the agent and environment model, rationality, problem solving in AI, uninformed search algorithms like breadth-first search and depth-first search, and informed search algorithms.

Uploaded by

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

A.I Notes

The document discusses artificial intelligence and provides information on what AI is, how it works, intelligent agents, the agent and environment model, rationality, problem solving in AI, uninformed search algorithms like breadth-first search and depth-first search, and informed search algorithms.

Uploaded by

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

What is artificial intelligence (AI)?

Artificial intelligence is the simulation of human intelligence processes by machines,


especially computer systems. Specific applications of AI include expert
systems, natural language processing, speech recognition and machine vision.

How does AI work?


As the hype around AI has accelerated, vendors have been scrambling to promote how
their products and services use it. Often, what they refer to as AI is simply a
component of the technology, such as machine learning. AI requires a foundation of
specialized hardware and software for writing and training machine learning
algorithms. No single programming language is synonymous with AI, but Python, R,
Java, C++ and Julia have features popular with AI developers.

Intelligent agents in AI are autonomous entities that act upon an


environment using sensors and actuators to achieve their goals. In
addition, intelligent agents may learn from the environment to achieve
those goals. Driverless cars and the Siri virtual assistant are examples
of intelligent agents in AI.

What are Agent and Environment?


An agent is anything that can perceive its environment
through sensors and acts upon that environment through effectors.

 A human agent has sensory organs such as eyes, ears, nose,


tongue and skin parallel to the sensors, and other organs such
as hands, legs, mouth, for effectors.
 A robotic agent replaces cameras and infrared range finders for
the sensors, and various motors and actuators for effectors.
 A software agent has encoded bit strings as its programs and
actions.
Agent Terminology
 Performance Measure of Agent − It is the criteria, which
determines how successful an agent is.
 Behavior of Agent − It is the action that agent performs after any
given sequence of percepts.
 Percept − It is agent’s perceptual inputs at a given instance.
 Percept Sequence − It is the history of all that an agent has
perceived till date.
 Agent Function − It is a map from the precept sequence to an
action.

Rationality
Rationality is nothing but status of being reasonable, sensible, and
having good sense of judgment.

Rationality is concerned with expected actions and results


depending upon what the agent has perceived. Performing actions
with the aim of obtaining useful information is an important part of
rationality.

The Nature of Environments


Some programs operate in the entirely artificial environment confined
to keyboard input, database, computer file systems and character
output on a screen.
In contrast, some software agents (software robots or softbots)
exist in rich, unlimited softbots domains. The simulator has a very
detailed, complex environment. The software agent needs to choose
from a long array of actions in real time. A softbot designed to scan
the online preferences of the customer and show interesting items
to the customer works in the real as well as an artificial environment.
The most famous artificial environment is the Turing Test environment, in
which one real and other artificial agents are tested on equal
ground. This is a very challenging environment as it is highly
difficult for a software agent to perform as well as a human.

The Structure of Intelligent Agents


Agent’s structure can be viewed as −

 Agent = Architecture + Agent Program


 Architecture = the machinery that an agent executes on.
 Agent Program = an implementation of an agent function.

Simple Reflex Agents

 They choose actions only based on the current percept.


 They are rational only if a correct decision is made only on the
basis of current precept.
 Their environment is completely observable.

Problem Solving in Artificial Intelligence


The reflex agent of AI directly maps states into action. Whenever these agents fail to
operate in an environment where the state of mapping is too large and not easily
performed by the agent, then the stated problem dissolves and sent to a problem-solving
domain which breaks the large stored problem into the smaller storage area and resolves
one by one. The final integrated action will be the desired outcomes.

There are basically three types of problem in artificial intelligence:

1. Ignorable: In which solution steps can be ignored.


2. Recoverable: In which solution steps can be undone.
3. Irrecoverable: Solution steps cannot be undo.
Steps problem-solving in AI: The problem of AI is directly associated with the
nature of humans and their activities. So we need a number of finite steps to
solve a problem which makes human easy works.
These are the following steps which require to solve a problem :
 Problem definition: Detailed specification of inputs and acceptable system
solutions.
 Problem analysis: Analyse the problem thoroughly.
 Knowledge Representation: collect detailed information about the problem
and define all possible techniques.
 Problem-solving: Selection of best techniques.
Problem solving agent: The problem-solving agent performs precisely
by defining problems and several solutions. So we can say that
problem solving is a part of artificial intelligence that encompasses a
number of techniques such as a tree, B-tree, heuristic algorithms to
solve a problem.

Uninformed Search Algorithms


Uninformed search is a class of general-purpose search algorithms which operates
in brute force-way. Uninformed search algorithms do not have additional
information about state or search space other than how to traverse the tree, so it
is also called blind search.

Following are the various types of uninformed search algorithms:

1. Breadth-first Search
2. Depth-first Search

Breadth-first Search:
o Breadth-first search is the most common search strategy for traversing a tree or
graph. This algorithm searches breadthwise in a tree or graph, so it is called
breadth-first search.
o BFS algorithm starts searching from the root node of the tree and expands all
successor node at the current level before moving to nodes of next level.
o The breadth-first search algorithm is an example of a general-graph search
algorithm.
o Breadth-first search implemented using FIFO queue data structure.

Advantages:

o BFS will provide a solution if any solution exists.


o If there are more than one solutions for a given problem, then BFS will provide
the minimal solution which requires the least number of steps.

Disadvantages:
o It requires lots of memory since each level of the tree must be saved into memory
to expand the next level.
o BFS needs lots of time if the solution is far away from the root node.

Depth-first Search
o Depth-first search isa recursive algorithm for traversing a tree or graph data structure.
o 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.
o DFS uses a stack data structure for its implementation.
o The process of the DFS algorithm is similar to the BFS algorithm.

Advantage:

o 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.
o It takes less time to reach to the goal node than BFS algorithm (if it traverses in
the right path).

Disadvantage:

o There is the possibility that many states keep re-occurring, and there is no
guarantee of finding the solution.
o DFS algorithm goes for deep down searching and sometime it may go to the
infinite loop.

Informed Search Algorithms : Informed search


algorithm contains an array of knowledge such as how far we are from the goal, path cost, how
to reach to goal node, etc. This knowledge help agents to explore less to the search space and
find more efficiently the goal node.

1.) Best-first Search Algorithm (Greedy


Search):
Greedy best-first search algorithm always selects the path which appears best at that
moment. It is the combination of depth-first search and breadth-first search algorithms.
It uses the heuristic function and search. Best-first search allows us to take the
advantages of both algorithms. With the help of best-first search, at each step, we can
choose the most promising node. In the best first search algorithm, we expand the node
which is closest to the goal node and the closest cost is estimated by heuristic function,
i.e.

1. f(n)= g(n).

Were, h(n)= estimated cost from node n to the goal.

The greedy best first algorithm is implemented by the priority queue.

Best first search algorithm:

o Step 1: Place the starting node into the OPEN list.


o Step 2: If the OPEN list is empty, Stop and return failure.
o Step 3: Remove the node n, from the OPEN list which has the lowest value of
h(n), and places it in the CLOSED list.
o Step 4: Expand the node n, and generate the successors of node n.
o Step 5: Check each successor of node n, and find whether any node is a goal
node or not. If any successor node is goal node, then return success and
terminate the search, else proceed to Step 6.
o Step 6: For each successor node, algorithm checks for evaluation function f(n),
and then check if the node has been in either OPEN or CLOSED list. If the node
has not been in both list, then add it to the OPEN list.
o Step 7: Return to Step 2.

Advantages:

o Best first search can switch between BFS and DFS by gaining the advantages of
both the algorithms.
o This algorithm is more efficient than BFS and DFS algorithms.

Disadvantages:

o It can behave as an unguided depth-first search in the worst case scenario.


o It can get stuck in a loop as DFS.
o This algorithm is not optimal.
A* Search Algorithm

A* Search Algorithm is a simple and efficient search algorithm that can be used to find the
optimal path between two nodes in a graph. It will be used for the shortest path finding. It is an
extension of Dijkstra’s shortest path algorithm (Dijkstra’s Algorithm). The extension here is that,
instead of using a priority queue to store all the elements, we use heaps (binary trees) to store
them. The A* Search Algorithm also uses a heuristic function that provides additional
information regarding how far away from the goal node we are. This function is used in
conjunction with the f-heap data structure in order to make searching more efficient.

Applications of A* Algorithm

The A* algorithm is widely used in various domains for pathfinding and optimization
problems. It has applications in robotics, video games, route planning, logistics, and
artificial intelligence. In robotics, A* helps robots navigate obstacles and find optimal
paths. In video games, it enables NPCs to navigate game environments intelligently.
Route planning applications use A* to find the shortest or fastest routes between
locations. Logistics industries utilize A* for vehicle routing and scheduling. A* is also
employed in AI systems, such as natural language processing and machine learning, to
optimize decision-making processes. Its versatility and efficiency make it a valuable
algorithm in many real-world scenarios.

 ‘g’ is the distance it takes to get to a certain square on the grid from the starting point,
following the path we generated to get there.
 ‘h’ is the heuristic, which is the estimation of the distance it takes to get to the finish
line from that square on the grid.

AO* search:
The AO* method divides any given difficult problem into a smaller
group of problems that are then resolved using the AND-OR graph
concept. AND OR graphs are specialized graphs that are used in
problems that can be divided into smaller problems. The AND side of the
graph represents a set of tasks that must be completed to achieve the
main goal, while the OR side of the graph represents different methods
for accomplishing the same main goal.

 Working of AO* algorithm:


 The evaluation function in AO* looks like this:
f(n) = g(n) + h(n)
f(n) = Actual cost + Estimated cost
here,
f(n) = The actual cost of traversal.
g(n) = the cost from the initial node to the current node.
h(n) = estimated cost from the current node to the goal state.

Means End Analysis: Means-Ends Analysis is problem-solving techniques used in


Artificial intelligence for limiting search in AI programs.

o It is a mixture of Backward and forward search technique.


o The MEA technique was first introduced in 1961 by Allen Newell, and Herbert A.
Simon in their problem-solving computer program, which was named as General
Problem Solver (GPS).
o The MEA analysis process centered on the evaluation of the difference between
the current state and goal state.

The means-ends analysis process can be applied recursively for a problem. It is a


strategy to control search in problem-solving. Following are the main Steps which
describes the working of MEA technique for solving a problem.

a. First, evaluate the difference between Initial State and final State.
b. Select the various operators which can be applied for each difference.
c. Apply the operator at each difference, which reduces the difference between the
current state and goal state.
Difference between the A* Algorithm and AO*
algorithm
 A* algorithm and AO* algorithm both works on the best first search.
 They are both informed search and works on given heuristics values.
 A* always gives the optimal solution but AO* doesn’t guarantee to give the
optimal solution.
 Once AO* got a solution doesn’t explore all possible paths but A* explores
all paths.
 When compared to the A* algorithm, the AO* algorithm uses less memory.
 opposite to the A* algorithm, the AO* algorithm cannot go into an
endless loop.

1) What is Adversarial Search?

Adversarial search in artificial intelligence is used to resolve two-person games in


which one player seeks to maximize their score while the other tries to minimize it.
Chess, checkers, and tic-tac-toe are the three most popular games that can be solved
via adversarial search. In many real-world applications, such as financial decision-
making and military operations, adversarial search is used. To give players clever
opponents in video games, it is also deployed.

2) A game can be defined as a type of search in AI which can be formalized of the


following elements:

o Initial state: It specifies how the game is set up at the start.


o Player(s): It specifies which player has moved in the state space.
o Action(s): It returns the set of legal moves in state space.
o Result(s, a): It is the transition model, which specifies the result of moves in the
state space.
o Terminal-Test(s): Terminal test is true if the game is over, else it is false at any
case. The state where the game ends is called terminal states.
o Utility(s, p): A utility function gives the final numeric value for a game that ends
in terminal states s for player p. It is also called payoff function.
3) Zero-Sum Game:
A zero-sum game is one in which no wealth is created or destroyed. So,
in a two-player zero-sum game, whatever one player wins, the other
loses. In this game, we can include at least two and a maximum to an
infinite number of contestants. It assumes a version of perfect competition
and perfect information.
Let us consider a game in which n contestant takes part, and
contestant i has Ni courses of action available to him. Then the number of
outcomes to a play of the game will be N1, N2,……………, Nn. So, consider a
possible outcome θ result in payment p(i, θ) to a contestant i. Then, the game is
called a Zero-Sum Game, if every possible result θ, we have
Poker, Gambling, Chess, Tennis are also some examples of Zero-Sum Game.

4) What is Minimax Search:

Mini- Max Algorithm: Mini-max algorithm is a recursive or backtracking algorithm


which is used in decision-making and game theory. It provides an optimal move for the
player assuming that opponent is also playing optimally.

o Mini-Max algorithm uses recursion to search through the game-tree.


o Min-Max algorithm is mostly used for game playing in AI. Such as Chess,
Checkers, tic-tac-toe, go, and various tow-players game. This Algorithm
computes the minimax decision for the current state.
o In this algorithm two players play the game, one is called MAX and other is called
MIN.
o Both the players fight it as the opponent player gets the minimum benefit while
they get the maximum benefit.
o Both Players of the game are opponent of each other, where MAX will select the
maximized value and MIN will select the minimized value.
o The minimax algorithm performs a depth-first search algorithm for the
exploration of the complete game tree.
o The minimax algorithm proceeds all the way down to the terminal node of the
tree, then backtrack the tree as the recursion.
5)
Alpha-Beta Pruning: Alpha-beta pruning is a modified version of the minimax
algorithm. It is an optimization technique for the minimax algorithm.

o As we have seen in the minimax search algorithm that the number of game states
it has to examine are exponential in depth of the tree. Since we cannot eliminate
the exponent, but we can cut it to half. Hence there is a technique by which
without checking each node of the game tree we can compute the correct
minimax decision, and this technique is called pruning. This involves two
threshold parameter Alpha and beta for future expansion, so it is called alpha-
beta pruning. It is also called as Alpha-Beta Algorithm.
o Alpha-beta pruning can be applied at any depth of a tree, and sometimes it not
only prune the tree leaves but also entire sub-tree.
o The two-parameter can be defined as:

a. Alpha: The best (highest-value) choice we have found so far at any point
along the path of Maximizer. The initial value of alpha is -∞.
b. Beta: The best (lowest-value) choice we have found so far at any point
along the path of Minimizer. The initial value of beta is +∞.
o The Alpha-beta pruning to a standard minimax algorithm returns the same move
as the standard algorithm does, but it removes all the nodes which are not really
affecting the final decision but making algorithm slow. Hence by pruning these
nodes, it makes the algorithm fast.

The main condition which required for alpha-beta pruning is: α>=β

Key points about alpha-beta pruning:


o The Max player will only update the value of alpha.
o The Min player will only update the value of beta.
o While backtracking the tree, the node values will be passed to upper nodes
instead of values of alpha and beta.
o We will only pass the alpha, beta values to the child nodes.

UNIT – II

o Knowledge Based Agents: An intelligent agent needs knowledge about the


real world for taking decisions and reasoning to act efficiently.
o Knowledge-based agents are those agents who have the capability
of maintaining an internal state of knowledge, reason over that knowledge,
update their knowledge after observations and take actions. These agents
can represent the world with some formal representation and act
intelligently.
o Knowledge-based agents are composed of two main parts:
o Knowledge-base and
o Inference system.

A knowledge-based agent must able to do the following:

o An agent should be able to represent states, actions, etc.


o An agent Should be able to incorporate new percepts
o An agent can update the internal representation of the world
o An agent can deduce the internal representation of the world
o An agent can deduce appropriate actions.

The architecture of knowledge-based agent:


the above diagram is representing a generalized architecture for a knowledge-based
agent. The knowledge-based agent (KBA) take input from the environment by
perceiving the environment. The input is taken by the inference engine of the agent and
which also communicate with KB to decide as per the knowledge store in KB. The
learning element of KBA regularly updates the KB by learning new knowledge.

Knowledge base: Knowledge-base is a central component of a knowledge-based


agent, it is also known as KB. It is a collection of sentences (here 'sentence' is a technical
term and it is not identical to sentence in English). These sentences are expressed in a
language which is called a knowledge representation language. The Knowledge-base of
KBA stores fact about the world.

Why use a knowledge base?


Knowledge-base is required for updating knowledge for an agent to learn with
experiences and take action as per the knowledge.

Inference system
Inference means deriving new sentences from old. Inference system allows us to add a
new sentence to the knowledge base. A sentence is a proposition about the world.
Inference system applies logical rules to the KB to deduce new information.

Inference system generates new facts so that an agent can update the KB. An inference
system works mainly in two rules which are given as:
o Forward chaining
o Backward chaining

Operations Performed by KBA


Following are three operations which are performed by KBA in order to show the
intelligent behavior:

1. TELL: This operation tells the knowledge base what it perceives from the
environment.
2. ASK: This operation asks the knowledge base what action it should perform.
3. Perform: It performs the selected action.

Various levels of knowledge-based


agent:
1. Knowledge level
Knowledge level is the first level of knowledge-based agent, and in this level, we
need to specify what the agent knows, and what the agent goals are. With these
specifications, we can fix its behavior. For example, suppose an automated taxi
agent needs to go from a station A to station B, and he knows the way from A to
B, so this comes at the knowledge level.

2. Logical level:
At this level, we understand that how the knowledge representation of
knowledge is stored. At this level, sentences are encoded into different logics. At
the logical level, an encoding of knowledge into logical sentences occurs. At the
logical level we can expect to the automated taxi agent to reach to the
destination B.

3. Implementation level:
This is the physical representation of logic and knowledge. At the implementation
level agent perform actions as per logical and knowledge level. At this level, an
automated taxi agent actually implement his knowledge and logic so that he can
reach to the destination.
Approaches to designing a knowledge-based
agent:
There are mainly two approaches to build a knowledge-based agent:

1. 1. Declarative approach: We can create a knowledge-based agent by initializing


with an empty knowledge base and telling the agent all the sentences with which
we want to start with. This approach is called Declarative approach.
2. 2. Procedural approach: In the procedural approach, we directly encode desired
behavior as a program code. Which means we just need to write a program that
already encodes the desired behavior or agent.

The Wumpus World Description


The Wumpus World's agent is an example of a knowledge-based agent that
represents Knowledge representation, reasoning and planning. Knowledge-Based
agent links general knowledge with current percepts to infer hidden characters of
current state before selecting actions.

Problem Statement:
The Wumpus world is a cave with 16 rooms (4×4). Each room is connected to
others through walkways (no rooms are connected diagonally). The knowledge-
based agent starts from Room[1, 1]. The cave has – some pits, a treasure and
a beast named Wumpus. The Wumpus can not move but eats the one who
enters its room. If the agent enters the pit, it gets stuck there. The goal of the
agent is to take the treasure and come out of the cave. The agent is rewarded,
when the goal conditions are met. The agent is penalized, when it falls into a pit
or being eaten by the Wumpus.
Some elements support the agent to explore the cave, like -The wumpus’s
adjacent rooms are stenchy. -The agent is given one arrow which it can use to
kill the wumpus when facing it (Wumpus screams when it is killed). – The
adjacent rooms of the room with pits are filled with breeze. -The treasure room
is always glittery.

1.

Sensors:
Devices which helps the agent in sensing the following from the
environment.
 Breeze
 Stench
 Glitter
 Scream (When the Wumpus is killed)
 Bump (when the agent hits a wall)

Logic in Artificial Intelligence


Logic can be defined as the proof or validation behind any reason provided. It is
simply the ‘dialectics behind reasoning’. It was important to include logic in
Artificial Intelligence because we want our agent (system) to think and act
humanly, and for doing so, it should be capable of taking any decision based on
the current situation. If we talk about normal human behavior, then a decision is
made by choosing an option from the various available options. There are
reasons behind selecting or rejecting an option. So, our artificial agent should
also work in this manner.

Types of logics in Artificial Intelligence


In artificial Intelligence, we deal with two types of logics:

1. Deductive logic
2. Inductive logic
1) Deductive logic
In deductive logic, the complete evidence is provided about the truth of the
conclusion made. Here, the agent uses specific and accurate premises that lead
to a specific conclusion. An example of this logic can be seen in an expert system
designed to suggest medicines to the patient. The agent gives the complete
proof about the medicines suggested by it, like the particular medicines are
suggested to a person because the person has so and so symptoms.

2) Inductive logic
In Inductive logic, the reasoning is done through a ‘bottom-up’ approach. What
this means is that the agent here takes specific information and then generalizes
it for the sake of complete understanding. An example of this can be seen in the
natural language processing by an agent in which it sums up the words according
to their category, i.e. verb, noun article, etc., and then infers the meaning of that
sentence.

Propositional logic in Artificial intelligence


Propositional logic (PL) is the simplest form of logic where all the statements are made by
propositions. A proposition is a declarative statement which is either true or false. It is a
technique of knowledge representation in logical and mathematical form.

o Propositional logic is also called Boolean logic as it works on 0 and 1.


o In propositional logic, we use symbolic variables to represent the logic, and we
can use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
o Propositions can be either true or false, but it cannot be both.
o Propositional logic consists of an object, relations or function, and logical
connectives.
o These connectives are also called logical operators.
o The propositions and connectives are the basic elements of the propositional
logic.
o Connectives can be said as a logical operator which connects two sentences.
o A proposition formula which is always true is called tautology, and it is also
called a valid sentence.
o A proposition formula which is always false is called Contradiction.
o A proposition formula which has both true and false values is called

You might also like