0% found this document useful (0 votes)
51 views91 pages

AI Notes

Uploaded by

devillucifer2411
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)
51 views91 pages

AI Notes

Uploaded by

devillucifer2411
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/ 91

Artificial Intelligence

UNIT 1
Introduction: Definition of AI, History of AI, nature of AI problems, examples of AI
problems. Problem solving by search: Uninformed Search: Depth First Search (DFS),
Breadth First Search (BFS). Informed Search: Best First Search, A*. Local Search: Hill
Climbing. Problem Reduction Search: AO*. Population Based Search: Ant Colony
Optimization, Genetic Algorithm. Game Playing:MinMax Algorithm, Alpha-Beta Pruning.

UNIT 2
Knowledge Representation: Types of Knowledge, Knowledge Representation
Techniques/schemes: Propositional Logic, Predicate Logic, Semantic nets, Frames.
Knowledge representation issues. Rule based systems.

UNIT 3
Reasoning under Uncertainty: Basics of Probability Theory, Probabilistic Reasoning,
Bayesian Reasoning, Dempster-Shafer Theory. Planning: Introduction to Planning,
Representation of Planning, Partial-order Planning.

UNIT 4
Learning: Introduction to Learning, Types of Learning: Learning by Induction, Rote
Learning, Symbol Based Learning, Identification Trees, Explanation Based Learning,
Transformational Analogy, Introduction to Neural Networks, Expert Systems, Current
trends in Artificial Intelligence
List of Program:
1. Write a Program to Implement Breadth First Search using Python.
2. Write a Program to Implement Depth First Search using Python.
3. Write a Program to Implement Tic-Tac-Toe game using Python.
4. Write a Program to Implement 8-Puzzle problem using Python.
5. Write a Program to Implement Water-Jug problem using Python.
6. Write a Program to Implement Travelling Salesman Problem using Python.
7. Write a Program to Implement Tower of Hanoi using Python.
8. Write a Program to Implement Monkey Banana Problem using Python.
9. Write a Program to Implement Missionaries-Cannibals Problems using Python.
10. Write a Program to Implement 8-Queens Problem using Python.

25 Marks
5 presentation
5 assignment
5 Internal
10 presence
Unit 1

16/Jan/2024

AI is one of the latest fields of science and engineering. Term AI or Artificial Intelligence
introduced in 1956. AI currently covered a huge variety of subfields, ranging from the
general (learning and perception) to the specific, such as playing chess, proving
mathematical theorems, writing poetry, driving a car on a crowded street, and
diagnosing diseases. AI is relevant to any intellectual task, that’s why we can say it is a
universal field.

· Intelligence is the ability to acquire, understand and apply the knowledge to achieve
goals in the world.

· AI is the study of the mental faculties through the use of computational models

· AI is the study of intellectual/mental processes as computational processes.

· AI program will demonstrate a high level of intelligence that equals or exceeds the
intelligence required of a human in performing some tasks.

· It can be described as an attempt to build machines that like humans can think and
act, able to learn and use knowledge to solve problems on their own.

History

· In 1931, Goedel Layed the foundation of Theoretical Computer Science1920-30s:

He published the first universal formal language and showed that math itself is either
flawed or allows for unprovable but true statements.

· In 1936, Alan Turing's work during World War II laid the foundation for computer
science and AI, and invented a Turing machine.

· In 1956, John McCarthy introduced the term "Artificial Intelligence" as the topic of the
Dartmouth Conference, the first conference devoted to the subject.

· In 1958, John McCarthy (MIT) invented the Lisp language.

· In 1972, Prolog developed by Alain Colmerauer.

Application of AI:

AI has a wide range of applications across various industries, transforming how


tasks are performed and enabling the development of innovative solutions. Here are
some notable applications of AI:
Healthcare:

Disease Diagnosis: AI systems can analyze medical data, such as images and
patient records, to assist in diagnosing diseases like cancer or identifying anomalies.

Drug Discovery: AI accelerates the drug discovery process by analyzing molecular


interactions and predicting potential drug candidates.

Finance:

Fraud Detection: AI algorithms analyze transaction patterns to identify and prevent


fraudulent activities in banking and finance.

Algorithmic Trading: AI is used to develop trading strategies by analyzing market


data and making real-time investment decisions.

Retail:

Personalized Recommendations: AI-driven recommendation engines analyze


customer behavior to provide personalized product recommendations.

Inventory Management: AI helps optimize inventory levels, reducing costs and


ensuring products are available when needed.

Customer Service:

Chatbots: AI-powered chatbots provide instant and automated responses to


customer queries, improving customer support efficiency.

Voice Assistants: Virtual assistants like Siri and Alexa use natural language
processing to understand and respond to voice commands.

Education:

Personalized Learning: AI systems analyze student performance data to tailor


educational content and provide personalized learning experiences.

Automated Grading: AI can automate the grading process for assessments and
provide immediate feedback to students.
Transportation:

Autonomous Vehicles: AI enables self-driving cars and trucks by processing real-


time sensor data and making decisions based on the environment.

Traffic Management: AI algorithms optimize traffic flow and reduce congestion


through predictive modeling and real-time adjustments.

Manufacturing:

Predictive Maintenance: AI analyzes equipment sensor data to predict when


machinery is likely to fail, allowing for proactive maintenance.

Quality Control: Computer vision systems inspect products for defects on the
production line, ensuring high-quality output.

Marketing:

Targeted Advertising: AI analyzes user behavior and preferences to deliver


targeted advertisements to specific audiences.

Market Forecasting: AI models can predict market trends and consumer behavior,
helping businesses make informed decisions.

Human Resources:

Recruitment Automation: AI assists in screening resumes, conducting initial


interviews, and identifying suitable candidates for job positions.

Employee Engagement: AI tools can analyze employee feedback and behavior to


improve workplace satisfaction and productivity.

Cybersecurity:

Threat Detection: AI systems analyze network traffic and user behavior to detect
and respond to cybersecurity threats in real-time.

Anomaly Detection: AI algorithms identify unusual patterns that may indicate a


security breach or unauthorized access.
Agriculture:

Precision Farming: AI analyzes data from sensors, satellites, and drones to


optimize farming practices, such as irrigation and crop management.

Crop Monitoring: Computer vision helps monitor crop health and identify diseases
or pests early on.

Environmental Conservation:

Wildlife Monitoring: AI-powered cameras and sensors assist in monitoring and


protecting endangered species.

Climate Modeling: AI is used to analyze large datasets and simulate climate


scenarios to understand and address environmental challenges.

Intelligent Systems: In order to design intelligent systems, it is important to categorize


them into four categories (Luger and Stubberfield 1993), (Russell and Norvig, 2003)

1. Systems that think like humans

2. Systems that think rationally

3. Systems that behave like humans

4. Systems that behave rationally


Scientific Goal: To determine ideas about knowledge representation, learning, rule
systems search, and so on, explain various sorts of real intelligence.

Engineering Goal: To solve real world problems using AI techniques such as


Knowledge representation, learning, rule systems, search, and so on. Traditionally,
computer scientists and engineers have been more interested in the engineering goal,
while psychologists, philosophers and cognitive scientists have been more interested in
the scientific goal.

Cognitive Science: Think Human-Like

a. Requires a model for human cognition. Precise enough models allow simulation by
computers.

b. Focus is not just on behavior and I/O, but looks like reasoning process.

c. Goal is not just to produce human-like behavior but to produce a sequence of steps
of the reasoning process, similar to the steps followed by a human in solving the same
task.

Laws of thought: Think Rationally

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.

b. Focus is on inference mechanisms that are probably correct and guarantee an


optimal solution.

c. Goal is to formalize the reasoning process as a system of logical rules and


procedures of inference.

d. Develop systems of representation to allow inferences to be like

“Socrates is a man. All men are mortal. Therefore Socrates is mortal”

Turing Test: Act Human-Like

a. The art of creating machines that perform functions requiring intelligence when
performed by people; that it is the study of, how to make computers do things which, at
the moment, people do better.

b. Focus is on action, and not intelligent behavior centered around the representation of
the world

c. Example: Turing Test

3 rooms contain: a person, a computer and an interrogator.


The interrogator can communicate with the other 2 by teletype (to avoid the
machine imitate the appearance of voice of the person)

The interrogator tries to determine which the person is and which the machine is.

The machine tries to fool the interrogator to believe that it is the human, and the
person also tries to convince the interrogator that it is the human.

If the machine succeeds in fooling the interrogator, then conclude that the
machine is intelligent.

Rational agent: Act Rationally

a. Tries to explain and emulate intelligent behavior in terms of computational


process; that it is concerned with the automation of the intelligence.

b. Focus is on systems that act sufficiently if not optimally in all situations.

c. Goal is to develop systems that are rational and sufficient


The difference between strong AI and weak AI:

Strong AI makes the bold claim that computers can be made to think on a level
(at least) equal to humans.

Weak AI simply states that some "thinking-like" features can be added to


computers to make them more useful tools... and this has already started to
happen (witness expert systems, drive-by-wire cars and speech recognition
software).

AI problems

AI problems can be broadly categorized based on the type of intelligence. Here are
some common types of problems in the field of Artificial Intelligence:

Classification Problems: Classifying input data into predefined categories or classes.


Ex. Spam email detection, image classification, sentiment analysis.

Clustering Problems: Grouping similar data points together based on certain features.
Ex: Customer segmentation, document clustering, anomaly detection.

Natural Language Processing (NLP) Problems: Understanding and generating


human language. Ex: Machine translation, chatbots, sentiment analysis, speech
recognition.

Computer Vision Problems: Processing and interpreting visual information from the
world. Ex: Object detection, facial recognition, image segmentation.

Reinforcement Learning Problems: Training agents to make sequences of decisions


in an environment to maximize a reward signal. Ex: Game playing (e.g., AlphaGo),
robotic control, autonomous vehicles.

Generative Problems: Creating new, meaningful data that resembles a given dataset.
Ex: Generative Adversarial Networks (GANs) for image synthesis, text generation.

Anomaly Detection: Identifying patterns or instances that deviate significantly from the
norm. Ex: Fraud detection, network intrusion detection.

Sequential Decision Making: Making a series of decisions over time based on


changing conditions. Ex: Stock trading, recommendation systems, autonomous
navigation.

Knowledge Representation and Reasoning: Representing and manipulating


information to draw conclusions. Ex: Expert systems, rule-based reasoning, semantic
web applications.
Robotics Problems: Enabling robots to perceive their environment and perform
physical actions.

Example: Object manipulation, autonomous navigation, robot-assisted surgery.

Optimization Problems: Finding the best solution from a set of possible solutions.

Ex: Resource allocation, route optimization, scheduling

Nature of AI Problems

Artificial Intelligence (AI) has brought on numerous disruptive changes in today's


technology-intensive world. There have been many debates surrounding the challenges
of AI, from the proliferation of AI-powered weaponry to replacing human jobs.

The incorporation of AI is one that is characterized by highs and lows. Numerous


benefits have been drawn, while there is fear of AI creating bigger issues for the human
race. Let us explore the various problems of AI today and learn in-depth about its
complexities and limitations.

Understanding AI Problems

1. AI lacks Transparency

One of the biggest challenges of AI is that AI and its core component of deep learning
models, neural networks, etc. are complicated and difficult to understand. This renders
a lack of transparency on the premise of how AI draws the conclusion, its mechanism of
using algorithms or making biased decisions, etc.

Example: One of the best examples of AI Problems is the Black box problem.

2. AI Automation Leading to Job Loss

This is one of the top challenges of AI that the world is constantly debating about. The
process of task automation powered by AI can result in a negative impact on human
workers. This has become a pressing issue as almost every industry adopts technology
for automating tasks.

AI-powered technologies, machines and robots have come about with a high potential
of being more dexterous and smarter at tasks that may require massive human work.

Example: One of the most recent examples would be US companies laying off about
3900 people due to AI integration in May, as reported by a Chicago-based firm
Challenger, Gray & Christmas, Inc.

3. Issue of Data Privacy with AI Tools

This is a long-debated concern and one of the biggest AI problems. AI tools collect data
from the user of the AI-powered technology or program.

AI systems collect personal data to train the models for a more customized user
experience for the users. This often raises the question of how and where such data is
used, and the data collected may not be secured.

Example: The finest example of this AI problem may be the case that occurred in 2023
with ChatGPT, wherein a bug incident exposed an active user's chat history to some
other users.

Hence, data, especially confidential and sensitive data, are not secure in AI and AI tools
cannot be considered an accountable tool for securing personal information.

4. Responsibility Issue

With the implementation of AI technology, the issue of identifying the factor responsible
for any hardware malfunction has become relatively difficult. In AI there is a
responsibility gap in AI-powered technology and machine.
Example: In self-driving cars when accidents occur it becomes complicated to identify
the causal factor of the accident. Whether it is a malfunction in the data or the machines
in the car, etc. when the vehicle's performances are modelled and designed on the
basis of the data fed to the machine.

5. Ethical Challenges

One of the top AI problems is the ethical issue. Developers are designing and grooming
chatbots with the potential of generating human-like conversation, making it difficult to
discern between real human customer support and a machine.

AI works on algorithms that are fed with data for training, and AI makes predictions
based on the training it receives. These predictions are labelled based on the data
assumption. This leaves the scope for bias and inaccuracy which is one of the most
prominent challenges of AI.

6. AI is expensive

One of the most pressing and challenging AI problems is its cost, as adopting AI and
deploying AI-powered machines and technologies requires expertise and field experts.
Also, AI works on a colossal amount of data that requires great computational power.

22/1/2024

An Introduction to Problem-Solving using Search Algorithms

In computer science, problem-solving refers to artificial intelligence techniques,


including various techniques such as forming efficient algorithms, heuristics, and
performing root cause analysis to find desirable solutions.

The basic crux of artificial intelligence is to solve problems just like humans.

Examples of Problems in Artificial Intelligence


In today’s fast-paced digitized world, Artificial Intelligence techniques are used widely to
automate systems that can use the resources and time efficiently. Some of the well-
known problems experienced in everyday life are games and puzzles. Using AI
techniques, we can solve these problems efficiently.

In this sense, some of the most common problems resolved by AI are

● Travelling Salesman Problem


● Tower of Hanoi Problem
● Water-Jug Problem
● N-Queen Problem
● Chess
● Sudoku
● Crypt-arithmetic Problems
● Magic Squares
● Logical Puzzles and so on.

Problem Solving Techniques

In artificial intelligence, problems can be solved by using searching algorithms,


evolutionary computations, knowledge representations, etc.

In this article, I am going to discuss the various searching techniques that are used to
solve a problem.

In general, searching is referred to as finding information one needs.

The process of problem-solving using searching consists of the following steps.

● Define the problem


● Analyze the problem
● Identification of possible solutions
● Choosing the optimal solution
● Implementation

Let’s discuss some of the essential properties of search algorithms.

Properties of search algorithms

Completeness
A search algorithm is said to be complete when it gives a solution or returns any
solution for a given random input.

Optimality

If a solution found is best (lowest path cost) among all the solutions identified, then that
solution is said to be an optimal one.

Time complexity

The time taken by an algorithm to complete its task is called time complexity. If the
algorithm completes a task in a lesser amount of time, then it is an efficient one.

Space complexity

It is the maximum storage or memory taken by the algorithm at any time while
searching.
These properties are
also used to compare the efficiency of the different types of searching algorithms.

Types of search algorithms

Now let’s see the types of the search algorithm.

Based on the search problems, we can classify the search algorithm as

● Uninformed search
● Informed search

Uninformed search algorithms

The uninformed search algorithm does not have any domain knowledge such
as closeness, location of the goal state, etc. it behaves in a brute-force way.
It only knows the information about how to traverse the given tree and how to
find the goal state. This algorithm is also known as the Blind search algorithm
or Brute -Force algorithm.

The uninformed search strategies are of six types.

They are-
● Breadth-first search
● Depth-first search
● Depth-limited search
● Iterative deepening depth-first search
● Bidirectional search
● Uniform cost search

Let’s discuss these six strategies one by one.

1. Breadth-first search

It is of the most common search strategies. It generally starts from the root node and
examines the neighbor nodes and then moves to the next level. It uses First-in First-out
(FIFO) strategy as it gives the shortest path to achieving the solution.

BFS is used where the given problem is very small and space complexity is not
considered.

Now, consider the following tree.

Here, let’s take node A as the start state and node F as the goal state.

The BFS algorithm starts with the start state and then goes to the next level and visits
the node until it reaches the goal state.

In this example, it starts from A and then travel to the next level and visits B and C and
then
travel to the next level and visits D, E, F and G. Here, the goal state is defined as F. So,
the traversal will stop at F.

The path of traversal is:

A —-> B —-> C —-> D —-> E —-> F

Let’s implement the same in python programming.

Complexities

The time complexity of the BFS algorithm is represented in the form of O(V + E), where
V is the number of nodes and E is the number of edges.

The space complexity of the algorithm is O(V).

Python Code:
graph = {
'5' : ['3','7'],
'3' : ['2', '4'],
'7' : ['8'],
'2' : [],
'4' : ['8'],
'8' : []
}

visited = [] # List for visited nodes.


queue = [] #Initialize a queue

def bfs(visited, graph, node): #function for BFS


visited.append(node)
queue.append(node)
while queue: # Creating loop to visit each node
m = queue.pop(0)
print (m, end = " ")
for neighbour in graph[m]:
if neighbour not in visited:
visited.append(neighbour)
queue.append(neighbour)

# Driver Code
print("Following is the Breadth-First Search")
bfs(visited, graph, '5') # function calling

BFS Algorithm Applications

● To build index by search index


● For GPS navigation
● Path finding algorithms
● In Ford-Fulkerson algorithm to find maximum flow in a network
● Cycle detection in an undirected graph
● In minimum spanning tree

Advantages of BFS

● BFS will never be trapped in any unwanted nodes.


● If the graph has more than one solution, then BFS will return the optimal solution
which provides the shortest path.

Disadvantages of BFS

● BFS stores all the nodes in the current level and then go to the next level. It
requires a lot of memory to store the nodes.
● BFS takes more time
to reach the goal state which is far away.

2. Depth-first search

The depth-first search uses Last-in, First-out (LIFO) strategy and hence it can be
implemented by using stack. DFS uses backtracking. That is, it starts from the initial
state and explores each path to its greatest depth before it moves to the next path.
DFS will follow

Root node —-> Left node —-> Right node

Now, consider the same example tree mentioned above.

Here, it starts from the start state A and then travels to B and then it goes to D. After
reaching
D, it backtracks to B. B is already visited, hence it goes to the next depth E and then
backtracks to B. as it is already visited, it goes back to A. A is already visited. So, it
goes to C and then to F. F is our goal state and it stops there.

The path of traversal is:

A —-> B —-> D —-> E —-> C —-> F

Python Code
graph = {
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F', 'G'],
'D' : [],
'E' : [],
'F' : [],
'G' : []
}
goal = 'F'
visited = set()
def dfs(visited, graph, node):
if node not in visited:
print (node)
visited.add(node)
for neighbour in graph[node]:
if goal in visited:
break
else:
dfs(visited, graph, neighbour)
dfs(visited, graph, 'A')

Complexity of Depth-first search algorithm

The time complexity of the DFS algorithm is O(V+E), where V is the number of vertices
and E is the number of edges in the graph.

The space complexity of the DFS algorithm is O(V).


Advantages of DFS

● It takes lesser memory as compared to BFS.


● The time complexity is lesser when compared to BFS.
● DFS does not require much more search.

Disadvantages of DFS

● DFS does not always guarantee to give a solution.


● As DFS goes deep down, it may get trapped in an infinite loop.

29/Jan/2024

Informed Search in AI?

Uninformed search algorithms look for all possible solutions of the problem in search
space without having any additional knowledge about search space. But an informed
search algorithm contains a list of knowledge such as how far we are from the goal,
path cost, how to reach the goal node, etc. This knowledge helps agents to explore less
of the search space and find the goal node.
Algorithms have information on the goal state which helps in more efficient searching.
This information is obtained by a function that estimates how close a state is to the goal
state.
Informed search in AI is a type of search algorithm that uses additional information to
guide the search process, allowing for more efficient problem-solving compared to
uninformed search algorithms.
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 the agent is from the goal. The heuristic method,
however, might not always give the best solution, but it is 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.
Pure Heuristic Search
An informed search algorithm employed in artificial intelligence which expands nodes
based on heuristic values is called a pure heuristic search algorithm. These algorithms
use heuristics, which are shortcuts or general rules of thumb that direct the search
process in the direction of the desired state. In addition, pure heuristic search algorithms
use domain-specific knowledge to increase search efficiency instead of uninformed
search algorithms, which have no prior knowledge of the problem area.
The A* algorithm is one of the most widely used pure heuristic search methods. The
cost of moving from the current state to the objective state is estimated by the A*
algorithm using a heuristic function.

In the informed search we will discuss two main algorithms which are given below:

○ Best First Search Algorithm(Greedy search)

○ A* Search Algorithm

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:

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

○ Step 2: If the OPEN list is empty, Stop and return failure.

○ 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.

○ Step 4: Expand the node n, and generate the successors of node n.

○ 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.
○ 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.

○ Step 7: Return to Step 2.

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, and we will 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.

In this search example, we are using two lists which are OPEN and CLOSED Lists.
Following are the iteration for traversing the above example.
Expand the nodes of S and put in the CLOSED list

Initialization: Open [A, B], Closed [S]

Iteration 1: Open [A], Closed [S, B]

Iteration 2: Open [E, F, A], Closed [S, B]


: Open [E, A], Closed [S, B, F]

Iteration 3: Open [I, G, E, A], Closed [S, B, F]


: Open [I, E, A], Closed [S, B, F, G]

Hence the final solution path will be: 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.


2.) A* Search Algorithm:
It is a searching algorithm that is used to find the shortest path between an initial and a
final point.
It is a handy algorithm that is often used for map traversal to find the shortest path to be
taken. A* was initially designed as a graph traversal problem, to help build a robot that
can find its own course. It still remains a widely popular algorithm for graph traversal.
It searches for shorter paths first, thus making it an optimal and complete algorithm. An
optimal algorithm will find the least cost outcome for a problem, while a complete
algorithm finds all the possible outcomes of a problem.
A* search is the most commonly known form of best-first search. It uses heuristic
function h(n), and cost to reach the node n from the start state g(n). It has combined
features of UCS(Uninformed Cost Search) and greedy best-first search, by which it
solve the problem efficiently. A* search algorithm finds the shortest path through the
search space using the heuristic function. This search algorithm expands less search
tree and provides optimal result faster. A* algorithm is similar to UCS except that it uses
g(n)+h(n) instead of g(n).

In A* search algorithm, we use search heuristic as well as the cost to reach the node.
Hence we can combine both costs as following, and this sum is called as a fitness
number.

At each point in the search space, only those node is expanded which have the lowest
value of f(n), and the algorithm terminates when the goal node is found.

Algorithm of A* search:

Step1: Place the starting node in the OPEN list.

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 (g+h), 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.

Step 6: Return to Step 2.

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:
In this example, we will traverse the given graph using the A* algorithm. The heuristic
value of all states is given in the below table so we will 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.
Here we will use OPEN and CLOSED list.
Solution:

Initialization: {(S, 5)}

Iteration1: {(S--> A, 4), (S-->G, 10)}

Iteration2: {(S--> A-->C, 4), (S--> A-->B, 7), (S-->G, 10)}

Iteration3: {(S--> A-->C--->G, 6), (S--> A-->C--->D, 11), (S--> A-->B, 7), (S-->G, 10)}
Iteration4 will give the final 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.

○ A* algorithm expands all nodes which satisfy the condition f(n)

Complete: A* algorithm is complete as long as:

○ Branching factor is finite.

○ Cost at every action is fixed.

Optimal: A* search algorithm is optimal if it follows below two conditions:

○ Admissible: the first condition requires for optimality is that h(n) should be an
admissible heuristic for A* tree search. An admissible heuristic is optimistic in
nature.

○ Consistency: Second required condition is consistency for only A* graph-


search.

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(b^d), where b is the branching factor.

Space Complexity: The space complexity of A* search algorithm is O(b^d)


Hill Climbing Algorithm

○ 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. One of the widely discussed examples of Hill climbing
algorithm is Traveling-salesman Problem in which we need to minimize the
distance traveled by the salesman.

○ 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.

○ In this algorithm, we don't need to maintain and handle the search tree or graph
as it only keeps a single current state.

Features of Hill Climbing:


Following are some main features of Hill Climbing Algorithm:

○ Generate and Test variant: Hill Climbing is the variant of Generate and Test
method. The Generate and Test method produce feedback which helps to decide
which direction to move in the search space.

○ Greedy approach: Hill-climbing algorithm search moves in the direction which


optimizes the cost.

○ No backtracking: It does not backtrack the search space, as it does not


remember the previous states.
State-space Diagram for Hill Climbing:
The state-space landscape is a graphical representation of the hill-climbing algorithm
which is showing a graph between various states of algorithm and Objective
function/Cost.

On Y-axis we have taken the function which can be an objective function or cost
function, and state-space on the x-axis. If the function on Y-axis is cost then, the goal of
search is to find the global minimum and local minimum. If the function of Y-axis is
Objective function, then the goal of the search is to find the global maximum and local
maximum.

Different regions in the state space landscape:


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.


Types of Hill Climbing Algorithm:

○ Simple hill Climbing:

○ Steepest-Ascent hill-climbing:

○ Stochastic hill Climbing:

1. Simple Hill Climbing:

Simple hill climbing is the simplest way to implement a hill climbing algorithm. It only
evaluates the neighbor node state at a time and selects the first one which
optimizes current cost and set it as a current state. It only checks it's one successor
state, and if it finds better than the current state, then move else be in the same state.
This algorithm has the following features:

○ Less time consuming

○ Less optimal solution and the solution is not guaranteed

Algorithm for Simple Hill Climbing:

○ Step 1: Evaluate the initial state, if it is goal state then return success and Stop.

○ Step 2: Loop Until a solution is found or there is no new operator left to apply.

○ Step 3: Select and apply an operator to the current state.

○ Step 4: Check new state:

a. If it is goal state, then return success and quit.

b. Else if it is better than the current state then assign new state as a current
state.

c. Else if not better than the current state, then return to step2.

○ Step 5: Exit.

2. Steepest-Ascent hill climbing:


The steepest-Ascent algorithm is a variation of a simple hill climbing algorithm. This
algorithm examines all the neighboring nodes of the current state and selects one
neighbor node which is closest to the goal state. This algorithm consumes more time as
it searches for multiple neighbors

Algorithm for Steepest-Ascent hill climbing:

○ Step 1: Evaluate the initial state, if it is goal state then return success and stop,
else make current state as initial state.

○ Step 2: Loop until a solution is found or the current state does not change.

a. Let SUCC be a state such that any successor of the current state will be
better than it.

b. For each operator that applies to the current state:

a. Apply the new operator and generate a new state.

b. Evaluate the new state.

c. If it is goal state, then return it and quit, else compare it to the


SUCC.

d. If it is better than SUCC, then set new state as SUCC.

e. If the SUCC is better than the current state, then set current state to
SUCC.

○ Step 5: Exit.

3. Stochastic hill climbing:

Stochastic hill climbing does not examine for all its neighbor before moving. Rather, this
search algorithm selects one neighbor node at random and decides whether to choose
it as a current state or examine another state.

Problems in Hill Climbing Algorithm:


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.

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.
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. And 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.

Problem Reduction:
Problem reduction is an algorithm design technique that takes a complex problem and
reduces it to a simpler one. The simpler problem is then solved and the solution of the
simpler problem is then transformed to the solution of the original problem.
Problem reduction is a powerful technique that can be used to simplify complex
problems and make them easier to solve. It can also be used to reduce the time and
space complexity of algorithms.
Approach 1:
To solve the problem one can iterate through the multiples of the bigger element (say X)
until that is also a multiple of the other element. This can be written as follows:
Select the bigger element (say X here).
Iterate through the multiples of X:
If this is also a multiple of Y, return this as the answer.
Otherwise, continue the traversal.
Algorithm:
Algorithm LCM(X, Y):
if Y > X:
swap X and Y
end if
for i = 1 to Y:
if X*i is divisible by Y
return X*i
end if
end for
Python Program
def LCM(x, y):

if y > x:

x, y = y, x

for i in range(1, y+1):

if (x*i) % y == 0:

return i*x

return x*y

print(LCM(10, 15))

Time Complexity: O(Y) as the loop can iterate for maximum Y times [because
X*Y is always divisible by Y]
Auxiliary Space: O(1)

AO* Algorithm:
Best-first search is what the AO* algorithm does. 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.
In the above figure, the buying of a car may be broken down into smaller problems or
tasks that can be accomplished to achieve the main goal in the above figure, which is
an example of a simple AND-OR graph. The other task is to either steal a car that will
help us accomplish the main goal or use your own money to purchase a car that will
accomplish the main goal. The AND symbol is used to indicate the AND part of the
graphs, which refers to the need that all subproblems containing the AND to be resolved
before the preceding node or issue may be finished.
The start state and the target state are already known in the knowledge-based search
strategy known as the AO* algorithm, and the best path is identified by heuristics. The
informed search technique considerably reduces the algorithm’s time complexity. The
AO* algorithm is far more effective in searching AND-OR trees than the A* algorithm.
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.

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 work 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.
Population Based Search
Population Based Search is a broad term that encompasses several different types of
algorithms used for optimization and problem-solving. These algorithms share the
common characteristic of working with a population of potential solutions, rather than
just a single solution at a time. These algorithms work by maintaining a population of
candidate solutions, which are then iteratively improved and refined through various
mechanisms.

Here are some key points about Population Based Search:

● Types of algorithms: Some common examples of Population Based Search


algorithms include:
○ Evolutionary algorithms: These algorithms are inspired by natural
selection and evolution, and involve operations like crossover, mutation,
and selection to improve the population of solutions over successive
generations.
○ Swarm intelligence algorithms: These algorithms are inspired by the
behavior of groups of animals, such as flocks of birds or schools of fish,
and use individual interactions and communication to explore the search
space.
○ Artificial immune system algorithms: These algorithms are inspired by
the immune system of the human body, and use mechanisms like antigen-
antibody recognition and clonal selection to identify and eliminate "bad"
solutions.
● Benefits: Population Based Search algorithms offer several benefits over
traditional search algorithms, including:
○ Robustness: They are less likely to get stuck in local optima and can find
good solutions even in complex and noisy search spaces.
○ Parallelization: They can be easily parallelized, which makes them
suitable for solving large-scale problems on multiple processors.
○ Adaptivity: They can adapt their search strategy based on the information
they gather during the search process.
● Applications: Population Based Search algorithms have a wide range of
applications in various fields, including:
○ Engineering design: Optimizing the design of complex systems like
airplanes, cars, and robots.
○ Financial modeling: Optimizing investment portfolios and trading
strategies.
○ Scheduling and resource allocation: Scheduling tasks and allocating
resources efficiently.
○ Data mining: Identifying patterns and trends in large datasets.

Key concepts:

● Population: A set of candidate solutions to the problem being tackled.


● Search space: The space containing all possible solutions.
● Fitness function: Measures how good a solution is, guiding the search.
● Evolutionary operators: Mechanisms like selection, crossover, and mutation
that modify the population over generations.

Benefits:

● Robustness: Can handle complex problems with large search spaces.


● Parallelization: Can be easily parallelized to improve speed.
● Heuristic nature: Don't need precise problem definitions, making them versatile.

Examples:

● Evolutionary Algorithms: Genetic algorithms, particle swarm optimization,


differential evolution.
● Swarm Intelligence: Ant colony optimization, bee colony optimization.
● Artificial Immune Systems: Inspired by the immune system's ability to learn
and adapt.

Applications:

● Optimization: Engineering design, scheduling, resource allocation.


● Machine Learning: Feature selection, neural network training.
● Data Mining: Pattern recognition, clustering.

To help me understand your specific interest:

● What kind of problem are you trying to solve?


● Do you have any specific population-based search algorithms in mind?
● What information are you looking for?
To learn more about Population based search Algorithms
(https://arxiv.org/ftp/arxiv/papers/2101/2101.10901.pdf)

Ant Colony Optimization (ACO)


It is a Population Based Search algorithm inspired by the foraging behavior of real
ants. Here's a deeper dive into its specifics:

Inspiration:

Imagine a colony of ants searching for food. They explore randomly at first, leaving a
trail of pheromones along their paths. When an ant finds food, it returns to the nest,
reinforcing the pheromone trail with its own scent. As more ants find the food source,
they follow the stronger pheromone trail, ultimately leading to the shortest and most
efficient path.
Algorithm:

In ACO, artificial ants mimic this behavior. They move through a virtual "world"
represented as a graph, with nodes representing cities or tasks and edges representing
connections between them. Each ant:

1. Chooses a path probabilistically:


○ Shorter paths with stronger pheromone trails have a higher chance of
being chosen.
○ A random component allows exploration of new paths.
2. Deposits pheromone on the chosen path:
○ Successful ants (who find good solutions) deposit more pheromone.
3. Pheromone evaporates over time:
○ This prevents stagnation and encourages exploration of new paths.

Applications:

ACO is versatile and used in various domains like:

● Traveling salesman problem: finding the shortest route to visit all cities once.
● Vehicle routing: optimizing delivery routes.
● Scheduling: assigning tasks to machines or people efficiently.
● Telecommunication network optimization: finding efficient routing paths for
data packets.

Advantages:

● Efficient for complex problems with large search spaces.


● Able to find good solutions without getting stuck in local optima.
● Adaptable to various problems by modifying the cost function and pheromone
update rules.

Disadvantages:

● Can be slow for very large problems.


● Parameter tuning can be challenging.
● Not guaranteed to find the absolute optimal solution.

Genetic Algorithms

Genetic Algorithms (GAs) are powerful tools in the AI toolbox, particularly for
optimization problems. They work by mimicking the process of natural selection,
where "fitter" solutions survive and reproduce, leading to better solutions over
generations. Here's a deeper look:
How it works:

1. Representation: Each potential solution is encoded as a "chromosome,"


typically a string of bits or numerical values.
2. Population: A set of initial chromosomes (solutions) forms the population.
3. Fitness evaluation: Each chromosome is evaluated based on its "fitness" (how
well it solves the problem).
4. Selection: Based on fitness, some chromosomes are selected for "breeding"
(combining their features).
5. Crossover: Selected chromosomes exchange parts of their genetic material,
creating new offspring.
6. Mutation: Random changes are introduced to some offspring, promoting
diversity and avoiding local optima.
7. Replacement: Less fit individuals in the population are replaced by the new
offspring.
8. Repeat: Steps 3-7 are repeated, iteratively improving the population until a
satisfactory solution is found.

Applications in AI:

● Machine learning: Optimizing hyperparameters of models, feature selection,


generating neural network architectures.
● Game playing: Evolving winning strategies in games like chess or Go.
● Robotics: Designing and optimizing robot controllers for specific tasks.
● Image processing: Optimizing image filters or segmentation algorithms.
● Financial modeling: Finding optimal investment strategies.

Strengths:

● Can handle complex problems with large search spaces.


● Able to find good solutions without getting stuck in local optima.
● Can be used with various data types and problems.

Weaknesses:

● Can be computationally expensive for large problems.


● Requires careful design of the fitness function and selection criteria.
● Not guaranteed to find the absolute optimal solution.

Compared to other AI techniques:

● Neural networks excel at learning complex patterns from data but may require
substantial training data and struggle with optimization problems.
● Reinforcement learning can find optimal solutions, but the learning process can
be slow and require interaction with the environment.
● GAs offer a unique balance between exploration and exploitation, making them
valuable for diverse AI applications.
Game Playing
Game Playing is an important domain of artificial intelligence. Games don’t require
much knowledge; the only knowledge we need to provide is the rules, legal moves and
the conditions of winning or losing the game. Both players try to win the game. So, both
of them try to make the best move possible at each turn. Searching techniques like
BFS(Breadth First Search) are not accurate for this as the branching factor is very high,
so searching will take a lot of time. So, we need another search procedures that
improve –
● Generate procedure so that only good moves are generated.
● Test procedure so that the best move can be explored first.
Game playing is a popular application of artificial intelligence that involves the
development of computer programs to play games, such as chess, checkers, or Go.
The goal of game playing in artificial intelligence is to develop algorithms that can learn
how to play games and make decisions that will lead to winning outcomes.
● One of the earliest examples of successful game playing AI is the chess program
Deep Blue, developed by IBM, which defeated the world champion Garry
Kasparov in 1997. Since then, AI has been applied to a wide range of games,
including two-player games, multiplayer games, and video games.
There are two main approaches to game playing in AI, rule-based systems and machine
learning-based systems.
1. Rule-based systems use a set of fixed rules to play the game.
2. Machine learning-based systems use algorithms to learn from experience
and make decisions based on that experience.
In recent years, machine learning-based systems have become increasingly popular, as
they are able to learn from experience and improve over time, making them well-suited
for complex games such as Go. For example, AlphaGo, developed by DeepMind, was
the first machine learning-based system to defeat a world champion in the game of Go.
Game playing in AI is an active area of research and has many practical applications,
including game development, education, and military training. By simulating game
playing scenarios, AI algorithms can be used to develop more effective decision-making
systems for real-world applications.
Mini-Max Algorithm in Artificial Intelligence
○ 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 the opponent is also playing optimally.
○ Mini-Max algorithm uses recursion to search through the game-tree.
○ The Min-Max algorithm is mostly used for game playing in AI. Such as Chess,
Checkers, tic-tac-toe, go, and various two-players games. This Algorithm
computes the minimax decision for the current state.
○ In this algorithm two players play the game, one is called MAX and other is called
MIN.
○ Both the players fight it as the opponent player gets the minimum benefit while
they get the maximum benefit.
○ Both Players of the game are opponent of each other, where MAX will select the
maximized value and MIN will select the minimized value.
○ The minimax algorithm performs a depth-first search algorithm for the exploration
of the complete game tree.
○ The minimax algorithm proceeds all the way down to the terminal node of the
tree, then backtrack the tree as the recursion.

Pseudo-code for MinMax Algorithm:

1. function minimax(node, depth, maximizingPlayer) is


2. if depth ==0 or node is a terminal node then
3. return static evaluation of node
4. if MaximizingPlayer then // for Maximizer Player
5. maxEva= -infinity
6. for each child of node do
7. eva= minimax(child, depth-1, false)
8. maxEva= max(maxEva,eva) //gives Maximum of the values
9. return maxEva
10. else // for Minimizer player
11. minEva= +infinity
12. for each child of node do
13. eva= minimax(child, depth-1, true)
14. minEva= min(minEva, eva) //gives minimum of the values
15. return minEva

Initial call:

Minimax(node, 3, true)

Working of Min-Max Algorithm:


○ The working of the minimax algorithm can be easily described using an example.
Below we have taken an example of game-tree which is representing the two-
player game.

○ In this example, there are two players, one is called Maximizer and the other is
called Minimizer.

○ Maximizer will try to get the Maximum possible score, and Minimizer will try to get
the minimum possible score.

○ This algorithm applies DFS, so in this game-tree, we have to go all the way
through the leaves to reach the terminal nodes.

○ At the terminal node, the terminal values are given so we will compare those
values and backtrack the tree until the initial state occurs. Following are the main
steps involved in solving the two-player game tree:

Step-1: In the first step, the algorithm generates the entire game-tree and apply the
utility function to get the utility values for the terminal states. In the below tree diagram,
let's take A is the initial state of the tree. Suppose maximizer takes first turn which has
worst-case initial value =- infinity, and minimizer will take next turn which has worst-case
initial value = +infinity.
Step 2:
Now, first we find the utilities value for the Maximizer, its initial value is -, so we will compare each va

○ For node D max(-1,- -) => max(-1,4)= 4

○ For Node E max(2, -) => max(2, 6)= 6

○ For Node F max(-3, -) => max(-3,-5) = -3

○ For node G max(0, -) = max(0, 7) = 7


Step 3:
In the next
rd step, it's a turn for minimizer, so it will compare all nodes value with +, and will find the 3
layer node values.

○ For node B= min(4,6) = 4

○ For node C= min (-3, 7) = -3


Step 4: Now it's a turn for Maximizer, and it will again choose the maximum of all nodes
values and find the maximum value for the root node. In this game tree, there are only 4
layers, hence we reach immediately to the root node, but in real games, there will be
more than 4 layers.

○ For node A max(4, -3)= 4


That was the complete workflow of the minimax two player game.

Properties of Mini-Max algorithm:

○ Complete- Min-Max algorithm is Complete. It will definitely find a solution (if


exist), in the finite search tree.

○ Optimal- Min-Max algorithm is optimal if both opponents are playing optimally.

○ Time complexity- As it performs DFS for the game-tree, so the time complexity
of Min-Max algorithm is O(bm), where b is branching factor of the game-tree, and
m is the maximum depth of the tree.

○ Space Complexity- Space complexity of Mini-max algorithm is also similar to


DFS which is O(bm).

Limitation of the minimax Algorithm:


The main drawback of the minimax algorithm is that it gets really slow for complex
games such as Chess, go, etc. This type of games has a huge branching factor, and the
player has lots of choices to decide. This limitation of the minimax algorithm can be
improved from alpha-beta pruning which we have discussed in the next topic.

Alpha-Beta Pruning

○ Alpha-beta pruning is a modified version of the minimax algorithm. It is an


optimization technique for the minimax algorithm.

○ 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.

○ 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.

○ 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 + .

○ 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.

Condition for Alpha-beta pruning:

The main condition which required for alpha-beta pruning is:


1. α>=β

Key points about alpha-beta pruning:

○ The Max player will only update the value of alpha.

○ The Min player will only update the value of beta.

○ While backtracking the tree, the node values will be passed to upper nodes
instead of values of alpha and beta.

○ We will only pass the alpha, beta values to the child nodes.

Pseudo-code for Alpha-beta Pruning:

1. function minimax(node, depth, alpha, beta, maximizingPlayer) is


2. if depth ==0 or node is a terminal node then
3. return static evaluation of node
4. if MaximizingPlayer then // for Maximizer Player
5. maxEva= -infinity
6. for each child of node do
7. eva= minimax(child, depth-1, alpha, beta, False)
8. maxEva= max(maxEva, eva)
9. alpha= max(alpha, maxEva)
10. if beta<=alpha
11. break
12. return maxEva
13. else // for Minimizer player
14. minEva= +infinity
15. for each child of node do
16. eva= minimax(child, depth-1, alpha, beta, true)
17. minEva= min(minEva, eva)
18. beta= min(beta, eva)
19. if beta<=alpha
20. break
21. return minEva

Working of Alpha-Beta Pruning:

Let's take an example of two-player search tree to understand the working of Alpha-beta
pruning

Step 1:
At the first step the, Max player will start first move from node A where = - and = +, these value of alph

Step 2: At Node D, the value of α will be calculated as its turn for Max. The value of α is
compared with firstly 2 and then 3, and the max (2, 3) = 3 will be the value of α at node
D and node value will also 3.
Step 3:
Now algorithm backtrack to node B, where the value of will change as this is a turn of Min, Now = +, w

In the next step, algorithm traverse the next successor of Node B which is node E, and the values of = -, and = 3

Step 4:
At node E, Max will take its turn, and the value of alpha will change. The current value of alpha will be
Step 5:
At next step, algorithm again backtrack the tree, from node B to node A. At node A, the value of alpha

At node C, =3 and = +, and the same values will be passed on to node F.

Step 6: At node F, again the value of α will be compared with left child which is 0, and
max(3,0)= 3, and then compared with right child which is 1, and max(3,1)= 3 still α
remains 3, but the node value of F will become 1.
Step 7:
Node F returns the node value 1 to node C, at C = 3 and = +, here the value of beta will be changed, it w
Step 8: C now returns the value of 1 to A here the best value for A is max (3, 1) = 3.
Following is the final game tree which is the showing the nodes which are computed
and nodes which has never computed. Hence the optimal value for the maximizer is 3
for this example.

Move Ordering in Alpha-Beta pruning:

The effectiveness of alpha-beta pruning is highly dependent on the order in which each
node is examined. Move order is an important aspect of alpha-beta pruning.

It can be of two types:

○ Worst ordering: In some cases, alpha-beta pruning algorithm does not prune
any of the leaves of the tree, and works exactly as minimax algorithm. In this
case, it also consumes more time because of alpha-beta factors, such a move of
pruning is called worst ordering. In this case, the best move occurs on the right
side of the tree. The time complexity for such an order is O(bm).
○ Ideal ordering: The ideal ordering for alpha-beta pruning occurs when lots of
pruning happens in the tree, and best moves occur at the left side of the tree. We
apply DFS hence it first search left of the tree and go deep twice as minimax
algorithm in the same amount of time. Complexity in ideal ordering is O(bm/2).

Rules to find good ordering:

Following are some rules to find good ordering in alpha-beta pruning:

○ Occur the best move from the shallowest node.

○ Order the nodes in the tree such that the best nodes are checked first.

○ Use domain knowledge while finding the best move. Ex: for Chess, try order:
captures first, then threats, then forward moves, backward moves.

○ We can bookkeep the states, as there is a possibility that states may repeat.
What is knowledge representation?

Humans are best at understanding, reasoning, and interpreting knowledge. Human


know 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:

○ 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.

○ 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.

○ It is also a way which describes how we can 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.

What to Represent:

Following are the kind of knowledge which needs to be represented in AI systems:

○ 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).

Knowledge: Knowledge is awareness or familiarity gained by experiences of facts,


data, and situations. Following are the types of knowledge in artificial intelligence:

Types of knowledge

Following are the various types of knowledge:

1. Declarative Knowledge:

○ Declarative knowledge is to know about something.


○ It includes concepts, facts, and objects.

○ It is also called descriptive knowledge and expressed in declarative sentences.

○ It is simpler than procedural language.

2. Procedural Knowledge

○ It is also known as imperative knowledge.

○ Procedural knowledge is a type of knowledge which is responsible for knowing


how to do something.

○ It can be directly applied to any task.

○ It includes rules, strategies, procedures, agendas, etc.

○ Procedural knowledge depends on the task on which it can be applied.

3. Meta-knowledge:

○ Knowledge about the other types of knowledge is called Meta-knowledge.

4. Heuristic knowledge:

○ Heuristic knowledge is representing knowledge of some experts in a filed or


subject.

○ Heuristic knowledge is rules of thumb based on previous experiences,


awareness of approaches, and which are good to work but not guaranteed.

5. Structural knowledge:

○ Structural knowledge is basic knowledge to problem-solving.

○ It describes relationships between various concepts such as kind of, part of, and
grouping of something.
○ It describes the relationship that exists between concepts or objects.

The relation between knowledge and intelligence:

Knowledge of real-worlds plays a vital role in intelligence and same for creating artificial
intelligence. Knowledge plays an important role in demonstrating intelligent behavior in
AI agents. An agent is only able to accurately act on some input when he has some
knowledge or experience about that input.

Let's suppose if you met some person who is speaking in a language which you don't
know, then how you will able to act on that. The same thing applies to the intelligent
behavior of the agents.

As we can see in below diagram, there is one decision maker which act by sensing the
environment and using knowledge. But if the knowledge part will not present then, it
cannot display intelligent behavior.

AI knowledge cycle:
An Artificial intelligence system has the following components for displaying intelligent
behavior:

○ Perception

○ Learning

○ Knowledge Representation and Reasoning

○ Planning

○ Execution

The above diagram is showing how an AI system can interact with the real world and
what components help it to show intelligence. AI system has Perception component by
which it retrieves information from its environment. It can be visual, audio or another
form of sensory input. The learning component is responsible for learning from data
captured by Perception comportment. In the complete cycle, the main components are
knowledge representation and Reasoning. These two components are involved in
showing the intelligence in machine-like humans. These two components are
independent with each other but also coupled together. The planning and execution
depend on analysis of Knowledge representation and reasoning.

Approaches to knowledge representation:

There are mainly four approaches to knowledge representation, which are given below:

1. Simple relational knowledge:

○ It is the simplest way of storing facts which uses the relational method, and each
fact about a set of the object is set out systematically in columns.

○ This approach of knowledge representation is famous in database systems


where the relationship between different entities is represented.

○ This approach has little opportunity for inference.

Example: The following is the simple relational knowledge representation.

Player Weight Age

Player1 65 23

Player2 58 18

Player3 75 24

2. Inheritable knowledge:
○ In the inheritable knowledge approach, all data must be stored into a hierarchy of
classes.

○ All classes should be arranged in a generalized form or a hierarchal manner.

○ In this approach, we apply inheritance property.

○ Elements inherit values from other members of a class.

○ This approach contains inheritable knowledge which shows a relation between


instance and class, and it is called instance relation.

○ Every individual frame can represent the collection of attributes and its value.

○ In this approach, objects and values are represented in Boxed nodes.

○ We use Arrows which point from objects to their values.

○ Example:

3. Inferential knowledge:
○ Inferential knowledge approach represents knowledge in the form of formal
logics.

○ This approach can be used to derive more facts.

○ It guaranteed correctness.

○ Example: Let's suppose there are two statements:

a. Marcus is a man

b. All men are mortal


Then it can represent as;

man(Marcus)

4. Procedural knowledge:

○ Procedural knowledge approach uses small programs and codes which


describes how to do specific things, and how to proceed.

○ In this approach, one important rule is used which is If-Then rule.

○ In this knowledge, we can use various coding languages such as LISP language
and Prolog language.

○ We can easily represent heuristic or domain-specific knowledge using this


approach.

○ But it is not necessary that we can represent all cases in this approach.

Requirements for knowledge Representation system:

A good knowledge representation system must possess the following properties.

1. 1. Representational Accuracy:
KR system should have the ability to represent all kind of required knowledge.
2. 2. Inferential Adequacy:
KR system should have ability to manipulate the representational structures to
produce new knowledge corresponding to existing structure.

3. 3. Inferential Efficiency:
The ability to direct the inferential knowledge mechanism into the most
productive directions by storing appropriate guides.

4. 4. Acquisitional efficiency- The ability to acquire the new knowledge easily


using automatic methods.

Techniques of knowledge representation

There are mainly four ways of knowledge representation which are given as follows:

1. Logical Representation

2. Semantic Network Representation

3. Frame Representation

4. Production Rules
1. Logical Representation

Logical representation is a language with some concrete rules which deals with
propositions and has no ambiguity in representation. Logical representation means
drawing a conclusion based on various conditions. This representation lays down some
important communication rules. It consists of precisely defined syntax and semantics
which supports the sound inference. Each sentence can be translated into logics using
syntax and semantics.

Syntax:

○ Syntaxes are the rules which decide how we can construct legal sentences in the
logic.

○ It determines which symbol we can use in knowledge representation.

○ How to write those symbols.

Semantics:
○ Semantics are the rules by which we can interpret the sentence in the logic.

○ Semantic also involves assigning a meaning to each sentence.

Logical representation can be categorised into mainly two logics:

a. Propositional Logics

b. Predicate logics

Advantages of logical representation:

1. Logical representation enables us to do logical reasoning.

2. Logical representation is the basis for the programming languages.

Disadvantages of logical Representation:

1. Logical representations have some restrictions and are challenging to work with.

2. Logical representation technique may not be very natural, and inference may not
be so efficient.

2. Semantic Network Representation

Semantic networks are alternative of predicate logic for knowledge representation. In


Semantic networks, we can represent our knowledge in the form of graphical networks.
This network consists of nodes representing objects and arcs which describe the
relationship between those objects. Semantic networks can categorize the object in
different forms and can also link those objects. Semantic networks are easy to
understand and can be easily extended.

This representation consist of mainly two types of relations:

a. IS-A relation (Inheritance)


b. Kind-of-relation

Example: Following are some statements which we need to represent in the form of
nodes and arcs.

Statements:

a. Jerry is a cat.

b. Jerry is a mammal

c. Jerry is owned by Priya.

d. Jerry is brown colored.

e. All Mammals are animal.

In the above diagram, we have represented the different type of knowledge in the form
of nodes and arcs. Each object is connected with another object by some relation.

Drawbacks in Semantic representation:


1. Semantic networks take more computational time at runtime as we need to
traverse the complete network tree to answer some questions. It might be
possible in the worst case scenario that after traversing the entire tree, we find
that the solution does not exist in this network.

2. Semantic networks try to model human-like memory (Which has 1015 neurons
and links) to store the information, but in practice, it is not possible to build such a
vast semantic network.

3. These types of representations are inadequate as they do not have any


equivalent quantifier, e.g., for all, for some, none, etc.

4. Semantic networks do not have any standard definition for the link names.

5. These networks are not intelligent and depend on the creator of the system.

Advantages of Semantic network:

1. Semantic networks are a natural representation of knowledge.

2. Semantic networks convey meaning in a transparent manner.

3. These networks are simple and easily understandable.

3. Frame Representation

A frame is a record like structure which consists of a collection of attributes and its
values to describe an entity in the world. Frames are the AI data structure which divides
knowledge into substructures by representing stereotypes situations. It consists of a
collection of slots and slot values. These slots may be of any type and sizes. Slots have
names and values which are called facets.

Facets: The various aspects of a slot is known as Facets. Facets are features of
frames which enable us to put constraints on the frames. Example: IF-NEEDED facts
are called when data of any particular slot is needed. A frame may consist of any
number of slots, and a slot may include any number of facets and facets may have any
number of values. A frame is also known as slot-filter knowledge representation in
artificial intelligence.

Frames are derived from semantic networks and later evolved into our modern-day
classes and objects. A single frame is not much useful. Frames system consist of a
collection of frames which are connected. In the frame, knowledge about an object or
event can be stored together in the knowledge base. The frame is a type of technology
which is widely used in various applications including Natural language processing and
machine visions.

Example: 1

Let's take an example of a frame for a book

Slots Filters

Title Artificial Intelligence

Genre Computer Science

Author Peter Norvig

Edition Third Edition


Year 1996

Page 1152
Example 2:

Let's suppose we are taking an entity, Peter. Peter is an engineer as a profession, and
his age is 25, he lives in city London, and the country is England. So following is the
frame representation for this:

Slots Filter

Name Peter

Profession Doctor

Age 25

Marital status Single

Weight 78

Advantages of frame representation:

1. The frame knowledge representation makes the programming easier by grouping


the related data.
2. The frame representation is comparably flexible and used by many applications
in AI.

3. It is very easy to add slots for new attribute and relations.

4. It is easy to include default data and to search for missing values.

5. Frame representation is easy to understand and visualize.

Disadvantages of frame representation:

1. In frame system inference mechanism is not be easily processed.

2. Inference mechanism cannot be smoothly proceeded by frame representation.

3. Frame representation has a much generalized approach.

4. Production Rules

Production rules system consist of (condition, action) pairs which mean, "If condition
then action". It has mainly three parts:

○ The set of production rules

○ Working Memory

○ The recognize-act-cycle

In production rules agent checks for the condition and if the condition exists then
production rule fires and corresponding action is carried out. The condition part of the
rule determines which rule may be applied to a problem. And the action part carries out
the associated problem-solving steps. This complete process is called a recognize-act
cycle.

The working memory contains the description of the current state of problems-solving
and rule can write knowledge to the working memory. This knowledge match and may
fire other rules.
If there is a new situation (state) generates, then multiple production rules will be fired
together, this is called conflict set. In this situation, the agent needs to select a rule from
these sets, and it is called a conflict resolution.

Example:

○ IF (at bus stop AND bus arrives) THEN action (get into the bus)

○ IF (on the bus AND paid AND empty seat) THEN action (sit down).

○ IF (on bus AND unpaid) THEN action (pay charges).

○ IF (bus arrives at destination) THEN action (get down from the bus).

Advantages of Production rule:

1. The production rules are expressed in natural language.

2. The production rules are highly modular, so we can easily remove, add or modify
an individual rule.

Disadvantages of Production rule:

1. Production rule system does not exhibit any learning capabilities, as it does not
store the result of the problem for the future uses.

2. During the execution of the program, many rules may be active hence rule-based
production systems are inefficient.
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.

Example:

1. a) It is Sunday.
2. b) The Sun rises from West (False proposition)
3. c) 3+3= 7(False proposition)
4. d) 5 is a prime number.

Following are some basic facts about propositional logic:

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


○ 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.
○ Propositions can be either true or false, but it cannot be both.
○ Propositional logic consists of an object, relations or function, and logical
connectives.
○ These connectives are also called logical operators.
○ The propositions and connectives are the basic elements of the propositional
logic.
○ Connectives can be said as a logical operator which connects two sentences.
○ A proposition formula which is always true is called tautology, and it is also
called a valid sentence.
○ A proposition formula which is always false is called Contradiction.
○ A proposition formula which has both true and false values is called
○ Statements which are questions, commands, or opinions are not propositions
such as "Where is Rohini", "How are you", "What is your name", are not
propositions.

Syntax of propositional logic:

The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:

a. Atomic Propositions
b. Compound propositions
○ Atomic Proposition: Atomic propositions are the simple propositions. It consists
of a single proposition symbol. These are the sentences which must be either
true or false.

Example:

1. a) 2+2 is 4, it is an atomic proposition as it is a true fact.


2. b) "The Sun is cold" is also a proposition as it is a false fact.
○ Compound proposition: Compound propositions are constructed by combining
simpler or atomic propositions, using parenthesis and logical connectives.

Example:

1. a) "It is raining today, and street is wet."


2. b) "Ankit is a doctor, and his clinic is in Mumbai."

Logical Connectives:

Logical connectives are used to connect two simpler propositions or representing a


sentence logically. We can create compound propositions with the help of logical
connectives. There are mainly five connectives, which are given as follows:

1. Negation: A sentence such as ¬ P is called negation of P. A literal can be either


Positive literal or negative literal.
2. Conjunction: A sentence which has connective such as, P Q is called a
conjunction.
Example: Rohan is intelligent and hardworking. It can be written as,
P= Rohan is intelligent,
Q= Rohan is hardworking. P Q .
3. Disjunction: A sentence which has connective, such as P Q . is called
disjunction, where P and Q are the propositions.
Example: "Ritika is a doctor or Engineer",
Here P= Ritika is Doctor. Q= Ritika is Doctor, so we can write it as P Q .
4. Implication:
A sentence such as P Q, is called an implication. Implications are also known as if-then ru
If
it is raining, then the street is wet.

5. Biconditional: A sentence such as


P Q is a Biconditional sentence, example If I am breathing, then I am alive
P= I am breathing, Q= I am alive, it can be represented as P Q.

Following is the summarized table for Propositional Logic Connectives:


Truth Table:

In propositional logic, we need to know the truth values of propositions in all possible
scenarios. We can combine all the possible combination with logical connectives, and
the representation of these combinations in a tabular format is called Truth table.
Following are the truth table for all logical connectives:
Truth table with three propositions:
We can build a proposition composing three propositions P, Q, and R. This truth table is
made-up of 8n Tuples as we have taken three proposition symbols.

Precedence of connectives:

Just like arithmetic operators, there is a precedence order for propositional connectors
or logical operators. This order should be followed while evaluating a propositional
problem. Following is the list of the precedence order for operators:

Precedence Operators

First Precedence Parenthesis

Second Precedence Negation

Third Precedence Conjunction(AND)

Fourth Precedence Disjunction(OR)

Fifth Precedence Implication


Six Precedence Biconditional

Logical equivalence:

Logical equivalence is one of the features of propositional logic. Two propositions are
said to be logically equivalent if and only if the columns in the truth table are identical to
each other.

Let's take two propositions A and B, so for logical equivalence, we can write it as AB. In below truth table we ca

Properties of Operators:

○ Commutativity:
○ P Q= Q P, or
○P Q = Q P.
○ Associativity:
○ (P Q) R= P (Q R),
○ (P Q) R= P (Q R)
○ Identity element:
○ P True = P,
○ P True= True.
○ Distributive:
○ P (Q R) = (P Q) (P R).

P (Q R) = (P Q) (P R).
○ DE Morgan's Law:
○ ¬ (P Q) = (¬P) (¬Q)
○¬ (P Q) = (¬ P) (¬Q).
○ Double-negation elimination:
○ ¬ (¬P) = P.

Limitations of Propositional logic:

○ We cannot represent relations like ALL, some, or none with propositional logic.
Example:
a. All the girls are intelligent.
b. Some apples are sweet.
○ Propositional logic has limited expressive power.
○ In propositional logic, we cannot describe statements in terms of their properties
or logical relationships.

Predicate Logic

Predicate Logic deals with predicates, which are propositions, consist of variables.

Predicate Logic - Definition

A predicate is an expression of one or more variables determined on some specific


domain. A predicate with variables can be made a proposition by either authorizing a
value to the variable or by quantifying the variable.

The following are some examples of predicates.

○ Consider E(x, y) denote "x = y"


○ Consider X(a, b, c) denote "a + b + c = 0"
○ Consider M(x, y) denote "x is married to y."

Quantifier:

The variable of predicates is quantified by quantifiers. There are two types of quantifier
in predicate logic - Existential Quantifier and Universal Quantifier.

Existential Quantifier:

If p(x) is a proposition over the universe U. Then it is denoted as x p(x) and read as "There exists at least one val

There are several ways to write a proposition, with an existential quantifier, i.e.,
(xA)p(x) or xA such that p (x) or (x)p(x) or p(x) is true for some x A.

Universal Quantifier:

If p(x) is a proposition over the universe U. Then it is denoted as x,p(x) and read as "For every xU,p(x) is true."

There are several ways to write a proposition, with a universal quantifier.

xA,p(x) or p(x), x A Or x,p(x) or p(x) is true for all x A.

Negation of Quantified Propositions:

When we negate a quantified proposition, i.e., when a universally quantified proposition


is negated, we obtain an existentially quantified proposition,and when an existentially
quantified proposition is negated, we obtain a universally quantified proposition.

The two rules for negation of quantified proposition are as follows. These are also called
DeMorgan's Law.

Example: Negate each of the following propositions:

1.x p(x) y q(y)

Sol:
~.x p(x) y q(y))

2. (xU) (x+6=25)

Sol:
~( xU) (x+6=25)

3. ~( x p(x) y q(y)

Sol:
~( x p(x) y q(y))

Propositions with Multiple Quantifiers:


The proposition having more than one variable can be quantified with multiple
quantifiers. The multiple universal quantifiers can be arranged in any order without
altering the meaning of the resulting proposition. Also, the multiple existential quantifiers
can be arranged in any order without altering the meaning of the proposition.

The proposition which contains both universal and existential quantifiers, the order of those quantifiers can't be e

Example: Write the negation for each of the following. Determine whether the resulting
statement is true or false. Assume U = R.

2
1. x m(x <m)

2 2 2
Sol: Negation of x m(x <m) is x m (x m). The meaning of x m (x
2m) is that there exists for some x such that x
2m, for every m. The statement is true as there is some greater x such that x
m, for every m.

2
2. m x(x <m)

2
Sol: Negation of m x (x <m) is mx (x 2 m). The meaning of mx (x 2
2m) is that for every m, there exists for some x such that x
2m. The statement is true as for every m, there exists for some greater x such that x
m.

What is a frame in ai?


A frame in AI is a data structure used to represent knowledge, concepts, or entities
within an AI system. It provides a way to organize information and facilitates the
understanding of complex relationships between various elements. Essentially, frames
serve as a set of attributes that define a specific entity or concept, allowing AI systems
to comprehend and process information in a more structured manner.

Knowledge representation issues:


Knowledge representation (KR) is a crucial aspect of Artificial Intelligence (AI) as it
dictates how information is encoded for AI systems to understand and utilize. While
significant advancements have been made in this field, several challenges persist,
hindering the development of truly intelligent and versatile AI. Here are some key issues
in knowledge representation:

1. Choosing the Right Representation:

● Selection: Selecting the most suitable representation format for a specific


domain or task can be complex. Different approaches, like logic-based methods,
semantic networks, or probabilistic models, each have strengths and
weaknesses. Choosing the wrong one can limit the AI system's ability to reason
and learn effectively.
● Generalization and Specialization: Representing knowledge in a way that
allows for both generalization (applying concepts to broader categories) and
specialization (handling specific exceptions) is crucial. This balance is essential
for AI systems to handle diverse situations effectively.
● Reasoning about Values: Reasoning about the values of attributes, beyond
what is explicitly stated, is an ongoing challenge. For instance, an AI system
might need to understand that an object's height must be in a unit of length or
that a person's age cannot exceed their parents' age.

2. Efficient Knowledge Access and Retrieval:

● Scalability: As the amount of knowledge stored in an AI system grows,


efficiently accessing and retrieving relevant information becomes increasingly
challenging. This is particularly crucial for real-world applications where vast
amounts of data are involved.
● Dynamic Knowledge Base Maintenance: Keeping the knowledge base up-to-
date and consistent with the ever-changing world is essential. This includes
incorporating new information, removing outdated data, and resolving potential
inconsistencies.

3. Knowledge Representation for Commonsense Reasoning and Natural


Language Processing:

● Commonsense Knowledge: Encoding the vast amount of commonsense


knowledge humans possess, which allows us to understand and navigate the
world, remains a significant challenge. This knowledge includes everyday facts,
social norms, and physical laws, which are crucial for AI systems to interact with
the real world effectively.
● Natural Language Processing: Representing knowledge in a way that
facilitates natural language processing (NLP) is crucial for AI systems to
understand and generate human language effectively. This involves bridging the
gap between the symbolic representations used in AI and the richness and
ambiguity of natural language.

Addressing these knowledge representation issues is critical for advancing the field of
AI. By developing more expressive, efficient, and comprehensive knowledge
representation techniques, we can pave the way for the creation of truly intelligent and
versatile AI systems capable of reasoning, learning, and interacting with the world in a
more human-like manner.

Rule based systems:


A rule-based system is a computational framework that relies on a predefined set
of explicit rules to make decisions or draw conclusions within a specific domain.
In technical terms, these rules are typically formulated as “if-then” statements,
where specific conditions trigger corresponding actions. The strength of rule-
based systems lies in their transparency and ease of interpretation. However,
their drawback is the need for explicit rules, making them less adaptable to
complex scenarios or situations where patterns are not easily expressible in rule
form. Despite these limitations, rule-based systems remain valuable in various
applications, especially when dealing with well-defined problems and clear
decision logic.
For example, in cybersecurity, a rule-based system might be employed to detect
malicious activities on a network. A rule could be defined as follows: “If a system
receives more than a specified number of connection requests within a short time
frame (indicating a potential cyberattack), then block that IP address.” In this
scenario, the rule acts as a security measure to protect the network from
potential threats.

Advantages of Rule-based system

1. It provides a clear and understandable way to express logical


relationships, enhancing transparency in decision-making.
2. The explicit nature of rules enables users to trace the decision-making
process, creating transparency in system actions.
3. Rule-based systems facilitate easy maintenance and debugging in the
process.
4. They are scalable and adaptable to changing requirements.

Limitation of Rule-based system

1. Rule-based systems lack the ability to learn from experience, restricting


their capacity to adapt and improve over time.
2. Rule-based systems may struggle with uncertain or ambiguous
information, leading to potential inaccuracies in decision-making.
3. Managing a large number of rules can become complex, posing
challenges in organization.
What is a rule-based system in AI?
A rule-based system in AI is a system that applies human-made rules to store,
sort and manipulate data. In doing so, it mimics human intelligence.
Rule based system in AI require a set of facts or source of data, and a set of
rules for manipulating that data. These rules are sometimes referred to as ‘If
statements’ as they tend to follow the line of ‘IF X happens THEN do Y’.
The steps can be simplified to:
● First comes the data or new business event
● Then comes the analysis: the part where the system conditionally
processes the data against its rules
● Then comes any subsequent automated follow-up actions
Some of the important elements of rule-based system in AI include:

A set of facts
These facts are assertions or anything that is relevant to the beginning state
of the system.

Set of Rules
This set contains all the actions that should be performed within the scope of
a problem and defines how to act on the assertion set. In the set of rules facts
are represented in an IF-THEN form.

Termination Criteria or Interpreter


This determines whether a solution exists or not and figures out when the
process should be terminated.
Source: Science Direct

What are the characteristics of rule-


based systems?
Some of the features of rule-based systems are:
● They are made up of the combined knowledge of human experts in the
problem domain.
● They represent knowledge in a very declarative manner.
● They make it possible to use various knowledge representations
paradigms.
● They support the implementation of non-deterministic search and
control strategies.
● They help in describing fragmentary, ill-structured, heuristic,
judgemental knowledge.
● They are robust and have the ability to operate using uncertain or
incomplete knowledge.
● They can help with rule based decision making.

How does a rule based system in AI


work?
Rule-based systems in AI outlines triggers & the actions that should follow (or
are triggered). For example, a trigger might be an email containing the word
“invoice”. An action might then be to forward the email to the finance team.
These rules most often take the form of "if" statements. "IF" outlines the
trigger, "THEN" specifies the action to complete. So, if you want to create a
rule-based system capable of handling 100 different actions, you’d have to
write 100 different rules. If you want to then update the system and add
actions, then you would need to write new rules.
In short, you use rules to tell a machine what to do, and the machine will do
exactly as you tell it. From there, rule-based systems will execute the actions
until you tell it to stop.
But remember: if you tell it to do something incorrectly, it will do it incorrectly.

What are the main components of a


rules-based system?

A typical rule-based system has seven basic components:

The knowledge base


It holds the domain knowledge that is necessary for problem solving. In a
rules-based system, the knowledge gets represented as a set of rules. Every
rule specifies a relation, recommendation, directive, strategy or heuristic and
has the IF (condition) THEN (action) structure. As soon as the condition part
of the rule is satisfied, the rule gets triggered and the action part gets
executed.

The database
In a rule based based approach the database has a set of facts that are used
to compare against the IF (condition) part of the rules that are held in the
knowledge base.

The inference engine


The inference engine is used to perform the reasoning through which the
expert system comes to a solution. The job of the inference engine is to link
the rules that are defined in the knowledge base with the facts that are stored
in the database. The inference engine is also known as the semantic
reasoner. It infers information or performs required actions on the basis of
input and the rule base that's present in the knowledge base. The semantic
reasoner involves a match-resolve-act cycle that works like this:
● Match - A section of the production rule system gets matched with the
contents of the working memory to gain a conflict, where there are
several instances of the satisfied productions.
● Conflict-Resolution - After the production system is matched, one of
the production instances in the conflict is selected for execution for the
purpose of determining the progress of the process.
● Act - The production instance selected in the previous stage is
executed, impacting the contents of the working memory.

Explanation facilities
The explanation facilities make it possible for the user to ask the expert
system how a specific conclusion was reached and why a specific fact is
required. The expert system needs to be able to explain its reasoning and
justify its advice, analysis, or conclusion.

User interface
In a rule based approach the user interface is the means through which the
user seeking a solution to a problem communicates with the expert system.
The communication should be as meaningful and friendly as possible and the
user interface should be as intuitive as possible.
These five elements are critical for any rule-based system. They are the core
components of the rule-based system. But the system might have some
additional components as well. A couple of these components could be the
external interface and the working memory.

External interface
The external interface enables an expert system to work with external data
files and programs that are written in conventional programming languages
like C, Pascal, FORTRAN and Basic.

Working memory
The working memory stores temporary information and data.

How are rules-based systems different


from learning-based systems?
In contrast to Rule-Based Systems, Learning Systems observe data and
continuously learn from it.
That is, while Rules Based Systems quickly become out of date, Learning
Systems automatically improve over time. And Learning Systems improve
without the massive expense of having people maintain complex rules.
Learning systems find patterns and treat similar things similarly. Think of how
Netflix or Hulu keep track and learn from what you watch, and then compare it
to what people like you watch to make recommendations and keep you binge-
watching. There is some complexity in execution, but it's a much simpler
concept. And a concept more in line with how humans also learn.
Finally, Learning Systems' results are necessarily more measurable. It's the
only way they can improve over time; because if they cannot measure results,
they could not learn what actions are better and what actions are worse.

Construction of rule-based systems


Data-based construction follows a machine learning method, which is in
general domain-independent. Machine learning techniques can be
categorized into two sub-types: supervised learning and unsupervised
learning.
Supervised learning means learning with assistance. This is because all
instances from a data set are labeled. This type of learning aims to predict
attribute values for unknown instances by using the known data instances.
The predicted value of an attribute may be either discrete or continuous in the
construction. Therefore, supervised learning could be involved in both
classification and regression tasks that can be used for categorical prediction
and numerical prediction respectively.
On the other hand, unsupervised learning means learning without any
assistance. This is because all instances from a data set are unlabeled. This
type of learning aims to find earlier unknown patterns from data sets. It
includes association, which aims to find relationships among attributes about
their values, and clustering, which aims to find a group of objects that are
similar from data sets.
In general, all three types of rule-based systems can be constructed with the
following steps: Data collection->Data pre-processing->Learning from data-
>Testing. However, there are different requirements for different learning
tasks.
In other words, to build a high-quality model by using machine learning
techniques, it is important to find algorithms that are suitable for the chosen
data sets concerning the characteristics of data. From this point of view, data
preprocessing may not be necessary if the chosen algorithms are good fits. In
addition, different types of dimensionality reduction techniques (such as
feature selection), a type of data preprocessing, may be required for different
tasks. If it is a classification or regression task, supervised feature selection
techniques may be required in general.

What are advantages of the rule-based


system in AI?
1. A rule-based system is generally cost-efficient and accurate in terms of
its results.
2. The outputs generated by the system are dependent on rules so the
output responses are stable and not random.
3. The coverage for different circumstances is less, whatever scenarios
are covered by the Rule Based system will provide high accuracy. The
error rate goes down because of the predefined rules.
4. It's feasible to reduce the amount of risk in terms of system accuracy.
5. Optimizing the speed of the system is easier as you know all the parts.
So providing instant outputs, is not a big issue.

What are the disadvantages of the rule-


based system in AI?
1. A rule-based system is built upon a lot of data, deep knowledge of the
domain, and a lot of manual work.
2. Writing and generating rules for a complex system is quite challenging
and time-consuming.
3. The self-learning capacity in a rule-based system is less as it generates
the result as per the rules.
4. Complex pattern identification is a challenging task in the Rule Based
method as it takes a lot of time and analysis.

You might also like