AI notes
AI notes
Tech-I Semester
1. Course Objectives
1. The student should be made to study the concepts of Artificial Intelligence.
2. The student should be made to learn the methods of solving problems using Artificial
Intelligence.
3. The student should be made to introduce the concepts of Expert Systems.
4. To understand the applications of AI, namely game playing, theorem proving, and
machine learning.
5. To learn different knowledge representation techniques
2. Pre-requisite
1. Knowledge in Computer Programming.
2. A course on “Mathematical Foundations of Computer Science”.
3. Background in linear algebra, data structures and algorithms, and probability.
3. Syllabus
L T P C
(23A31301T) ARTIFICIAL INTELLIGENCE 3 0 0 3
UNIT - I
UNIT - II
Searching- Searching for solutions, uniformed search strategies – Breadth first search, depth
first Search. Search with partial information (Heuristic search) Hill climbing, A*, AO*
Algorithms, Problem reduction, Game Playing-Adversial search, Games, mini-max
algorithm, optimal decisions in multiplayer games, Problem in Game playing, Alpha-Beta
pruning, Evaluation functions.
UNIT - III
UNIT - IV
Logic concepts: First order logic. Inference in first order logic, propositional vs. first order
inference, unification & lifts forward chaining, Backward chaining, Resolution, learning from
observation Inductive learning, Decision trees, Explanation based learning, Statistical
Learning methods, Reinforcement Learning.
UNIT - V
Textbooks:
Reference Books:
1. https://ai.google/
2. https://swayam.gov.in/nd1_noc19_me71/preview
4. Course Outcomes
Cognitive
Course Course Outcome /affective Course Outcome
Code Statement Level of the
course
outcome
Explain the foundations of
23A31301T AI and various Intelligent Apply L3 CO1
Agents
5. LECTURE PLAN
UNIT I
Period Period
1 Introduction- AI
Problems 1 CO1 L2 MD1,
MD5
2 Foundation of
AI, History of AI 1 CO1 L1 MD1,
MD5
3 Intelligent
Agents and 1 CO1 L2 MD1,
Environments MD5
4 The Concept of
Rationality 1 CO1 L2 MD1,
MD5
5 Nature of
environments, 1 CO1 L2 MD1,
Structure of MD5
Agents
6 Problem solving 1
agents, CO1 L2 MD1,
Problem MD5
formulation
7 Problem solving 1
agents-Example CO1 L3 MD1,
Problems MD5
UNIT - I
1. Introduction:
Artificial Intelligence (AI) refers to the “development of computer systems for
performing tasks that require human intelligence”. The goal of AI is to create
machines to carry out diverse tasks for identifying patterns and making decisions based
on the collected information. This can be achieved through AI techniques (machine
learning and neural networks to natural language processing and robotics) which
enable machines to learn, reason, and perform tasks previously reserved for human intelligence.
The field of AI is unique, sharing border with disciplines like Mathematics, Computer
Science, Philosophy, Psychology, Biology, Cognitive Science and many others.
Total Turing Test includes a video signal so that the interrogator can test the
subject’s perceptual abilities, as well as the opportunity for the interrogator to pass
physical objects ―” through the hatch”. To pass the total Turing Test, the computer
will need:
4. Systems that act rationally (The rational agent approach): It tries to define AI,
with the concept of so-called rational agents. An agent is just something that acts and
a rational agent is one that acts to achieve the best outcome when there is uncertainty.
Rational behavior means doing right thing.
1.2 AI Problems:
Problems in Artificial Intelligence (AI) come in different forms, each with its own
set of challenges and potential for innovation. From image recognition to natural
language processing, AI problems can be classified into three types of tasks:
1. Mundane Tasks: These tasks are done routinely by people and some other
animals. (For e.g. Perception, robotics, natural language, Vision, Speech)
o Recognizing people, objects.
o Communicating (through natural language).
o Navigating around obstacles on the streets.
2. Formal Tasks: Tasks which require logic and constraints to function. (For e.g.
Mathematics-logic, calculus, algebra Theorem proving, Games chess,
checkers, verification,).
3. Expert tasks: These tasks cannot be done by all people and can only be
performed by skilled specialists. (For e.g. financial analysis, medical
diagnostics, engineering, scientific analysis, consulting)
Much of the early work in the field of AI was focused on formal tasks, such as Game
Playing and Theorem proving. Initially computers could perform well at those tasks,
but no computer is fast enough to overcome the combinational explosion
generated by most problems.
Another early foray into AI focused on common-sense reasoning. Again, no attempt
was made to create a program with a large amount of knowledge.
This is the reason why AI work is more prospering in the Expert Tasks domain
now, as the expert task domain needs expert knowledge without common sense,
which can be easier to represent and handle.
1.2.1 Characteristics of AI problems:
The problems in artificial intelligence exhibit certain traits that contribute to their
complexity:
Traits Issues
Artificial Intelligence problems span a very broad spectrum. The various approaches
and techniques provide solutions to AI problems.
Approaches
1. Symbolic AI interprets human intelligence through symbol manipulation, rules and
logical reasoning. Basic concepts are broken down into symbols and the AI
processes them into something understandable to solve the problem.
3. Statistical approach is how AI solves specific problems using mathematics tools and
statistical models such as information theory, decision theory, etc., to develop AI
algorithms. This approach has resulted in greater accuracy and reproducibility in
data mining.
AI Technique:
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. “General intelligence is among the
field's long-term goals.”
7. Control theory and cybernetics: How can artifacts operate under their own
control?
Machines can modify their behavior in response to the environment
(sense/action loop). Water-flow regulator, steam engine governor, thermostat,
The theory of stable feedback systems (1894)
Weiner’s book cybernetics (1948) awoke public to the possibility of artificially
intelligent machines
8. Linguistics: How does language relate to thought?
o Modern linguistics and AI were ―born at about the same time, and grew up
together, intersecting in a hybrid field called computational linguistics or natural
language processing.
After taking a brief look at various disciplines that contribute towards AI, now let us
look at the concept of strong and weak AI which also gives foundation for developing
automated systems.
o Type-1(Based on Capabilities):
1. Narrow AI (Weak AI): This form of AI uses Machine learning which is
designed and trained for specific tasks or domains, such as speech
recognition, image classification, or recommendation systems. Narrow AI
excels within defined parameters but lacks general human-like intelligence. E.g.:
IBM’s Watson, Siri and Alexa are weak AI.
2. General AI (Strong AI): General AI aims to exhibit human-like
intelligence (machine intelligence) and cognitive abilities across a wide range of
tasks. This form of AI is hypothetical and remains a long-term goal of AI
research. It can find the solution to a problem and works beyond a
preprogrammed algorithm. E.g. Visual perception, speech recognition,
decision making, and translations between languages.
3. Super AI (Artificially Super AI): Super AI is AI that to go beyond in
excellence than human intelligence and ability (machine consciousness). E.g. It’s
the best at everything — maths, science, medicine, etc...,
3. History of AI:
The idea of artificial intelligence was introduced in the 1950s by Alan Mathison
Turing, a mathematician and computer scientist. Turing’s paper named “Computing
Machinery and Intelligence” included the question “Can machines think?”.
Later, in 1956, John McCarthy coined the term artificial intelligence during the
first AI conference held at Dartmouth College, New Hampshire. John McCarthy is
called “The Father of Artificial Intelligence”. Here is the history of AI during 20th
century −
The Deep Blue Chess Program beats the then world chess
1997
champion, Garry Kasparov.
A spying Aero plane takes photographs, which are used to figure out spatial
information or map of the areas.
Police use computer software that can recognize the face of criminal with the
stored portrait made by forensic artist.
• AI in Machine learning (ML): ML allows computers to learn from data and improve
their performance over time. This technology is used in a variety of applications, such
as predictive analytics, fraud detection, and recommendation systems.
• AI in Robotics: Robotics is the branch of AI that deals with the design, construction,
and operation of robots. Robots are used in a variety of applications, such as
manufacturing, healthcare, and space exploration.
Self-Moving Robots: AI makes robots smart at moving around on their own.
It's like giving them a built-in GPS and a clever brain.
AI in Astronomy: Machines can assist with data processing in the astronomical sector,
such as capturing new stars, extraterrestrial planets, and even dark matter.
AI in Gaming:AI plays crucial role in strategic games such as chess (Deep Blue Chess
program beat world champion Gary Kasparov), poker, tic-tac-toe, etc., where machine can
think of large number of possible positions based on heuristic knowledge.
Review Questions:
Part A – Two Marks
1. Distinguish Intelligence and Artificial Intelligence. L1, CO1
2. What is A.I. technique? Also tell the areas where it can be used. L2, CO1
3. What are the goals of AI? L1,CO1 Refer 1.2
4. List the advantages and disadvantages of AI?L1,CO1 Refer 10
5. What is meant by Turing test? Refer 1.2
Part B -Ten Marks
1. Define AI? Explain the organization of AI. L2, CO1 Refer 1,1.1
2. Describe the Turing test for machine intelligence. Highlights its important features.
L2, CO1 Refer 1.1
3. Explain about the foundations of AI. L2, CO1 Refer 2
4. Classify AI problems and Discuss the characteristics of AI Problems.L2, CO1 Refer
1.2,1.2.2
5. Write a short note on history of AI along with milestones. L2, CO1 Refer 3
An AI system is composed of an agent and its environment. The agents act in their
environment. An environment in artificial intelligence is the surrounding of the
agent.
So, we define-
Agent as “an independent program or an autonomous entity that is designed to perceive its
environment through sensors and acts upon that environment through actuators”.
A human agent has sensory organs such as eyes, ears, nose, tongue and skin parallel
to the sensors, and other organs such as hands, legs, mouth, for actuators and physical
world as environment.
A robotic agent can have cameras, infrared range finder, NLP for sensors and various
motors for actuators, physical world as environment.
A software agent can have keystrokes, file contents as sensory input and act on those
inputs and display output on the screen. Operating system as environment.
Definition- “A rational agent is an agent which has clear preference, models uncertainty, and acts
in a way to maximize its performance measure with all possible actions.”
A rational agent is said to perform the right things. A rational agent is anything
that
AI is about creating rational agents to use for game theory and decision theory for
various real-world scenarios.
Actuators These are the mechanisms through which an AI agent interacts with its
environment, such as motors, wheels, or speakers.
A partially observable environment is one in which the agent does not have
complete information about the current state of the environment. The agent
can only observe a subset of the environment, and some aspects of the
environment may be hidden or uncertain.
Example: driving a car in traffic. The environment is partially observable
because what’s around the corner is not known.
future. Example: Checkers- Where the previous move can affect all the
following moves.
4. Static (vs. dynamic): is one in which the environment does not change over
time. The state of the environment remains constant, and the agent's actions
do not affect the environment. Ex: Cross word puzzles
crossword puzzle.
An environment involving more than one agent is a multi-agent
environment. Examples: multiplayer games, traffic simulations.
4. Structure of an AI Agent:
The task of AI is to design an agent program which is an implementation of the
agent function. Structure of an Intelligent Agent is a combination of agent,
architecture and agent program and can be viewed as:
Architecture is a device with sensors and actuators that the agent executes on. for
example, a robotic car, a camera, and a PC.
Agent function is a map from the percept sequence to an action which takes the
entire percept history.
1. Simple reflex agents are programmed to only succeed in the fully observable
environment and take decisions based on the current precepts and ignore the
rest of the percept history.
The Simple reflex agent works on Condition-action rule, which means it maps
the current state to action.
Such as a Room Cleaner agent, it works only if there is dirt in the room.
which means it maps the current state to action. Such as a Room Cleaner agent,
it works only if there is dirt in the room.
A learning agent in AI is the type of agent that can learn from its past
experiences, or it has learning capabilities.
It starts to act with basic knowledge and then can act and adapt automatically
through learning.
1) Goal formulation define the problems that the agents need to solve.
2) Problem formulation is the process of deciding what actions and states to
consider, given a goal.
i. Initial State: This state requires an initial state for the problem which
starts the AI agent towards a specified goal. In this state new methods also
initialize problem domain solving by a specific class.
ii. Action: This stage of problem formulation works with function with a
specific class taken from the initial state and all possible actions done in this
stage.
iii. Transition: This stage of problem formulation integrates the actual action
done by the previous action stage and collects the final stage to forward it to
their next stage.
iv. Goal test: This stage determines that the specified goal achieved by the
integrated transition model or not, whenever the goal achieves stop the
action and forward into the next stage to determines the cost to achieve the
goal.
v. Path costing: This component of problem-solving numerical assigned what
will be the cost to achieve the goal. It requires all hardware, software and
human working cost.
3) Search: The process of looking for a sequence of actions that reaches the goal is
called search. A search algorithm takes a problem as input and returns a solution
in the form of an action sequence.
4) Solution: It finds the best algorithm out of various algorithms, which may be
proven as the best optimal solution. Finding a solution of a problem involves
following phases:
a. Problem definition: Detailed specification of inputs and acceptable
system solutions.
b. Problem analysis: Analyse the problem thoroughly.
c. Knowledge Representation: collect detailed information about the
problem and define all possible techniques.
d. Problem-solving: Selection of best techniques.
5) Execution phase: Once a solution is found, the carrying actions it recommends is
called the execution phase.
A. Toy Problems
1. 8-Puzzle Problem
States: A state of the 8-puzzle is a 3x3 grid, with eight numbered tiles and a blank
space. The objective is to reach the goal state as shown in Figure. We can slide four
adjacent tiles (left, right, above, and below) into the empty space.
• Initial State: We can start from any state as the initial state.
• Actions: Here, actions or the movement of the blank space is defined, i.e., either
left, right, up or down. The empty space cannot move diagonally and can take
only one step at a time.
• Transition Model: Given the state and action it returns the resulting state.
• Goal test: It identifies whether we have reached the correct goal-state.
• Path cost: The path cost is the number of steps in the path where the cost of each
step is 1.
2. Vacuum World
States: The state is determined by both the agent location and the dirt locations. The
agent is in one of two locations, each of which might or might not contain dirt. Thus,
there are 2 × 2^2 = 8 possible world states.
• Goal test: This checks whether all the squares are clean.
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.
State space for the vacuum world
Links denote actions: L = Left, R =Right, S = Suck.
3. 8- Queens problem
The goal of the 8-queens problem is to place 8 queens on the chessboard such that no
queen attacks any other. (A queen attacks any piece in the same row, column or
diagonal).
2. Complete-state formulation: It starts with all the 8-queens on the chessboard and
moves them around, saving from the attacks.
Following steps are involved in this formulation
States: Arrangement of all the 8 queens one per column with no queen attacking the
other queen.
Actions: Move the queen at the location where it is safe from the attacks.
This formulation is better than the incremental formulation as it reduces the state
space from 1.8 x 1014 to 2057, and it is easy to find the solutions.
B. Real-World Problems
1. Route-finding problems are defined in terms of specified locations and
transitions along links between them.
E.g. Traveling salesperson problem (TSP): It is a touring problem where
the salesman can visit each city only once. The objective is to find the
shortest tour and sell-out the stuff in each city.
Route-finding algorithms are used in a variety of applications such as Web
sites and in-car systems that provide driving directions.
2. VLSI layout problem requires positioning millions of components and
connections on a chip to minimize area, minimize circuit delays, minimize stray
capacitances, and maximize manufacturing yield.
Review Questions:
Unit-I
UNIT - II
Searching- Searching for solutions, uniformed search strategies – Breadth first search, depth
first Search. Search with partial information (Heuristic search) Hill climbing, A*, AO*
Algorithms, Problem reduction, Game Playing-Adversial search, Games, mini-max algorithm,
optimal decisions in multiplayer games, Problem in Game playing, Alpha-Beta pruning,
1. Searching:
Searching is a step-by-step procedure to solve a search-problem in search space.
“Solution to a search problem is a sequence of actions, that transforms the start state to the goal state”.
This plan is achieved through search strategies or algorithms.
b. Search Algorithm:
The search algorithm takes “a problem as input and returns a solution in the form of action
sequence”. Each of these algorithms will have:
A problem graph, containing the start node S and the goal node G.
A frontier(fringe) is a data structure Queue (FIFO), or Stack (LIFO) used to store all the
possible states (nodes) that you can go from the current states.
c. Search Tree:
A tree representation of search problem is called Search tree. The root of the search tree is
the root node which corresponds to the initial state.
For each Node of the tree, we have a structure that contains four components:
• State: The state in the state space to which the node corresponds.
• Parent node: The node in the search tree that generated this node.
• Action: The action that was applied to the parent to generate the node.
• Path-cost: The cost, traditionally denoted by g(n), of the path from the initial state
to the node, as indicated by the parent pointers.
• Depth: The number of steps along the path from initial state.
Optimality: If a solution found for an algorithm is guaranteed to be the best solution (lowest
path cost) among all other solutions, then such a solution for is said to be an optimal solution.
Time Complexity: Time complexity is a measure of time for an algorithm to complete its task.
Space Complexity: It is the maximum storage space required at any point during the search, as
the complexity of the problem.
1. Breadth-first Search
2. Depth-first Search
3. Depth-limited Search
4. Iterative deepening depth-first search
5. Uniform cost search
6. Bidirectional Search
a. Breadth-First Search Algorithm
BFS algorithm starts searching from the root node of the tree and expands all
successor node at the current level before moving to nodes of next level.
It always expands the Shallow nodes first.
BFS is implemented by calling TREE-SEARCH (problem, FIFO-QUEUE ())
Queue data structure puts all newly generated successors at the end of the queue.
Path: A-B-C-D-E-F-G-H-I-J-K
Advantages:
BFS guarantees the shortest path to the goal in terms of the number of actions.
It's also complete, meaning it will find a solution if one exists.
Limitations:
Properties:
Advantages:
It can find a solution quickly if it's not too far from the initial state.
Limitations: It does not guarantee the shortest path, and it may get stuck in infinite loops
or deep branches
Properties:
• Sensor less or conformant problem - Agent may have no sensors i.e. no idea where it
is; solution is a sequence.
• Exploration problem – When states and actions of the environment are unknown.
Informed search strategies can find a solution more efficiently than an uninformed search
strategy.
They are:
1. Hill Climbing
2. A* Search
3. AO* search
The A* (A-star) algorithm is a popular pathfinding and graph traversal algorithm used to
find the shortest path between two nodes in a graph. It employs a “heuristic estimate” as
well as the cost to reach the node. Hence, we can combine both costs as follows, and this
sum is called a fitness number f(n).
Algorithm of A* search:
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and
stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation
function (g+h), if node n is goal node, then return success and stop, otherwise
Step 4: Expand node n and generate all 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.
Limitations: The quality of the heuristic matters. If the heuristic is not admissible, the
optimality guarantee is lost.
Applications: Tower Défense is a type of strategy video game where the goal is to defend a
player’s territories or possessions by obstructing enemy attackers, usually achieved by
placing defensive structures on or along their path of attack.
Example:
In this example, we will traverse the given graph using the A* algorithm. The heuristic
value h (n) of all states is given in the below table. Here we will use OPEN and CLOSED
list.
Iteration3: {(S--> A-->C--->G, 6), (S--> A-->C--->D, 11), (S--> A-->B, 7), (S-->G, 10)}
2.3.2 Hill-Climbing:
The Hill-Climbing search algorithm is simply a loop that continually moves in the direction
of increasing value – that is, uphill.
3. Choose the neighbor with the best quality and move to that state.
4. Repeat 2 thru 4 until all the neighbouring states are of lower quality.
Algorithm:
Function HILL-CLIMBING(Problem) returns a solution state Inputs: Problem, problem
Local variables: Current, a node
Next, a node
Current = MAKE-NODE(INITIAL-STATE[Problem])
Loop do
Next = a highest-valued successor of Current
If VALUE[Next] < VALUE[Current] then return Current
Current = Next
End
• A problem can be divided into a set of sub problems, where each sub problem can be
solved separately and a combination of these will be a solution.
• The AND-OR (AO*) graphs are used for representing the solution.
The AO* method divides any given difficult problem into a smaller group of problems
that are then resolved using the AND-OR graph concept.
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.
Searches in which two or more players with conflicting goals are trying to explore the same
search space for the solution, are called adversarial searches, often known as Games.
Games are modelled as a Search problem and heuristic evaluation function, and these are the
two main factors which help to model and solve games in AI.
A game can be formally defined as a search problem with the following components:
• The initial state, which includes the board position and identifies the player to move.
• A utility function (also called an objective function or payoff function), which give a
numeric value for the terminal states.
2- Person Games
Terminal Test: A test applied to a board position which determines whether the game is
over. In chess, for example, this would be a checkmate or stalemate situation.
Utility Function: A function which assigns a numeric value to a terminal state. For
example, in chess the outcome is win (+1), lose (-1) or draw (0).
3. Use the utility of nodes at level n to derive the utility of nodes at level n-1.
5. Eventually the backed-up values reach the top of the tree, at which point Max
chooses the move that yields the highest value. This is called the minimax decision
because it maximizes the utility for Max on the assumption that Min will play
perfectly to minimize it.
α: the value of the best (i.e., highest value) choice we have found so far at any choice point
along the path of MAX.
β: the value of best (i.e., lowest value) choice we have found so far at any choice point along
the path of MIN.
The main condition which required for alpha-beta pruning is: α>=β
• 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.
Review Questions
Unit-II
Part-A
LECTURE PLAN
UNIT III
Period Period
1 Knowledge
Representation 1 CO3 L2 MD1,
issues MD5
2 Predicate logic MD1,
1 CO3 L1 MD5
3 Logic 1 MD1,
Programming CO3 L2 MD5
4 Semantic Nets
1 CO3 L1 MD1,
MD5
5 Frames and 1 CO3 L1 MD1,
Inheritance MD5
9 Reasoning 1
under CO3 L3 MD1,
uncertainty MD5
10 Review of 1 CO3 L1 MD1,
probability MD5
11 Bayes’ 1 CO3 L1 MD1,
probabilistic MD5
interferences
12 Dempster 1 CO3 L1 MD1,
Shafer theory MD5
1
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
UNIT - III
Representation of Knowledge: Knowledge representation issues, predicate logic- logic
programming, semantic nets- frames and inheritance, constraint propagation, representing
knowledge using rules, rules-based deduction propagation, representing knowledge using
rules, rules-based deduction systems. Reasoning under uncertainty, review of probability,
Bayes’ probabilistic interferences and dempster Shafer theory.
1. Introduction
As we can see in above 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.
Any knowledge representation system should possess the properties such as learning,
efficiency in acquisition, representational adequacy and inferential adequacy.
For example, a knowledge representation system might be used to build a chatbot that
can answer questions about a particular topic or a recommendation engine that can suggest
products based on a user's preferences.
2
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Perception
Learning
Planning
Execution
The knowledge that needs to be represented in AI are objects, events, performance, facts,
meta-knowledge, and Knowledgebase.
1. Objects: Objects refer to things in the world that have physical properties and can
be observed, touched, or manipulated. Object-oriented programming is an example of a
technique that uses objects to represent knowledge in AI
2. Events: Events refer to actions or occurrences that take place in the world. Event-
based systems use events to represent knowledge in AI. Examples of events include
driving a car, cooking food.
3
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
4
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
5
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
A. Predicate Logic in AI
Predicate logic in artificial intelligence, also known as first-order logic (FOL), is a
formal system used in logic and mathematics to represent and reason about complex
expressions in easier forms using predicates, variables, and quantifiers. It can represent
negation, conjunction, disjunction, and many more types of statements by using
symbols.
6
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
* Quantifiers are used to specify the scope of variables in logical expressions. There are
two types of quantifiers in predicate logic –
a) Universal Quantifier (∀): it indicates that the statement within the quantifier
is true for all objects in the domain
b) Existential Quantifier (∃): it indicates that there exists at least one object for
which the statement within the quantifier is true
Examples of Predicate Logic in AI:
1. Predicate Example: "IsHungry(x)"
Predicate Symbol: IsHungry
Argument: x (variable representing an object)
Meaning: These predicate asserts that a specific object represented by "x" is
hungry.
2. Universal Quantification: ∀x IsHuman(x) → IsMortal(x)
This statement uses the universal quantifier to claim that for all objects "x" in the
domain, if "x" is human, then "x" is mortal.
3. Existential Quantification: ∃x IsHungry(x)
This statement uses the existential quantifier to claim that there is at least one
object "x" in the domain that is hungry.
Characteristics of Predicate Logic
* The Logical inference is allowed.
7
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Logic program is a collection of logic statements which express facts and rules
about a problem domain.
Logic programming specify a computation in terms of logical relations between
entities.
Computation determines whether, a particular conclusion follows from those
logical statements.
In logic programming, using the knowledge base (collection of facts and rules),
the machine can find answers to the given questions.
8
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Definition: “It is a logical and declarative programming language designed for developing logic-
based AI applications”.
Developers can “set rules & facts” around a problem, and then Prolog’s interpreter will
use that information to automatically execute those plans to find solutions.
Prolog programs consist of set of three different Horn clauses (“: -") -
9
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Prolog uses uppercase letters for variables and lowercase for constants.
Commas separate literals in the body, and Period marks the end of a sentence
Advantages:
1. Easy to build database. Doesn’t need a lot of programming effort.
2. Pattern matching is easy. Search is recursion based.
3. It has built in list handling. Makes it easier to play with any algorithm involving
lists.
Disadvantages:
1. LISP logic programming language dominates over prolog with respect to I/O
features.
2. Sometimes input and output is not easy.
Applications of Prolog:
* It plays a vital role in automation system.
* Intelligent Database Retrieval
* Natural Language Understanding
* Specification Language
* Machine Learning
* Robot Planning
* Problem Solving
1.6 Semantic Network 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 consists of mainly two types of relations:
a. IS-A Relation (Inheritance)
10
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
b. Kind-of-Relation
Example: Statements are represented in the form of nodes and arcs.
Statements: a) Man is a human.
b) All humans has name.
In the above diagram, we have represented the different type of knowledge in the form
of nodes and arcs. Each object relates to another object by some relation.
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.
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.
2. It is not possible to build a vast semantic network to model human-like memory
(Which has 1015 neurons and links) to store the information.
3. These types of representations are inadequate as they do not have any equivalent
quantifier, e.g., for all, for some, none, etc.
4. Difficulties in modelling sophisticated knowledge structures.
5. These networks are not intelligent and depend on the creator of the system.
11
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Slots(attribute) Filler(value)
Name John Smith
Age 35
Gender Male
Address 123 Main Street
Phone Number (555) 123-4567
12
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
This frame might contain slots such as "Make," "Model," "Year," and "Color."
Each of these slots has corresponding fillers, providing specific values.
Additionally, the "Car" frame may be organized hierarchically within a larger
category called "Vehicle," inheriting certain properties and attributes.
Advantages:
Inheritance simplifies knowledge representation in several ways:
Reduces Redundancy: Inheritance eliminates the need to redundantly specify
common attributes and values for each specific frame.
Maintains Consistency: Inheritance ensures that related frames share consistent
information.
Facilitates Extensibility: New frames can be added to the hierarchy without the need
to specify all their attributes from scratch.
Enables Classification: Inheritance allows frames to be classified based on their
position in the hierarchy.
Supports Abstraction: Hierarchical frames can represent abstract and specific
concepts.
1.9 Representing Knowledge using Rules:
Rule based systems in AI express knowledge using a set of rules or production rules to
generate judgements or suggestions. Rules are expressed in the following form:
“If<condition> then <conclusion>”
13
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
1. Rules are conditional statements that define the system’s behavior. “IF condition
THEN action.”
2. Knowledge Base: This is the repository where all the rules and facts are stored.
3. Inference Engine applies the rules to the knowledge base to derive conclusions or
make decisions.
4. Working Memory: This is a dynamic component that holds the current facts. It is
updated as the inference engine applies rules.
5. User Interface allows users to interact with the system, input data, and receive
outputs or recommendations.
1.9.2 Rule-based Deduction System
A rule-based deduction system is a computer system that uses rules & reasoning to solve
problems in a specific domain. The rules are often written as if-then statements, such as
"If X happens, then do Y”.
Here’s how a rule-based system works:
1. Create rules and facts: A developer creates a list of rules and facts for the system.
2. Analyse data: The system processes the input data against the rules.
3. Perform actions: The system follows the rules and performs any programmed
functions.
Advantages
Accuracy: Rule-based systems operate by cause and effect, and only within their
rule set.
Ease of use: Rule-based systems require only small amounts of simple data to
perform tasks and repetitive processes.
Speed: With the proper training, rule-based systems can make informed decisions
quickly and efficiently.
Disadvantages:
14
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Lack of Learning Capability: Rule-based systems are exact and do not have
learning capabilities. Including too many rules can slow down a system and
introduce complexity.
Scalability: Altering existing rules or incorporating new rules can introduce
time-consuming and expensive complications.
High Maintenance Costs: To keep the rules accurate and up to date, rule-based
systems need continual maintenance.
Applications of Rule-based System
A classic example of a rule-based system is the domain-specific expert system that
uses rules to make deductions or choices.
Help a doctor choose the correct diagnosis based on a cluster of symptoms.
Select tactical moves to play a game.
2. Constraint Propagation in AI
Artificial Intelligence (AI) encompasses a variety of methods and techniques to solve
complex problems efficiently. One such technique is constraint propagation, which plays a
crucial role in areas like scheduling, planning, and resource allocation. A method of
inference that assigns values to variables characterizing a problem in such a way that some
conditions (called constraints) are satisfied. This process can result in more domain
reductions.
Key Concepts
1. Variables: Elements that need to be assigned values.
2. Domains: Possible values that can be assigned to the variables.
3. Constraints: Rules that define permissible combinations of values for the variables.
How Constraint Propagation Works
15
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Example: Consider a simple CSP with two variables, X and Y, each with domains {1, 2,
3}, and a constraint X ≠ Y.
Constraint propagation will iteratively reduce the domains as follows:
If X is assigned 1, then Y cannot be 1, so Y’s domain becomes {2, 3}.
If Y is then assigned 2, X cannot be 2, so X’s domain is reduced to {1, 3}.
This process continues until a stable state is reached.
3. Reasoning in AI
Reasoning in Artificial Intelligence refers to the “process by which AI systems analyse
information, make inferences, and draw conclusions to solve problems or make decisions”.
Types of Reasoning in AI
1) Probabilistic Reasoning in AI: Probabilistic reasoning involves dealing with
uncertainty and making decisions based on probabilities. AI systems use statistical
models to assess the likelihood of different outcomes and make informed choices.
2) Default Reasoning in AI: It is a type of non-monotonic reasoning where conclusions
are drawn based on default assumptions unless explicitly contradicted.
3) Statistical Reasoning in AI: statistical reasoning involves the use of statistical
methods to analyse data, identify patterns, and make predictions.
A) Uncertainty:
Till now, knowledge representation using first-order logic and propositional logic
gives certainty, which means we were sure about the predicates.
With this knowledge representation, we might write A→B, which means if A is true
then B is true.
But consider a situation where we are not sure about whether A is true or not then we
cannot express this statement, this situation is called uncertainty.
16
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
So, to represent uncertain knowledge, where we are not sure about the predicates, we
need uncertain reasoning or probabilistic reasoning.
B) Causes of uncertainty:
Following are some leading causes of uncertainty to occur in the real world.
1. Information occurred from unreliable sources.
2. Experimental Errors
3. Equipment fault
4. Temperature variation
5. Climate change.
C) Probabilistic Reasoning:
Probabilistic Reasoning is a way of knowledge representation where we apply the
concept of probability with logic to indicate the uncertainty in knowledge.
In probabilistic reasoning, there are two ways to solve problems with uncertain
knowledge:
o Bayes' rule
o Bayesian Statistics
3.2 Review of Probability
Let's understand some common terms:
1. Probability: Probability can be defined “as a chance that an uncertain event will occur.”
It is the numerical measure of the likelihood that an event will occur. The value of
probability always remains between 0 and 1 that represent ideal uncertainties.
* 0 ≤ P(A) ≤ 1, where P(A) is the probability of an event A.
* P(A) = 0, indicates total uncertainty in an event A.
* P(A) =1, indicates total certainty in an event A.
We can find the probability of an uncertain event by using the below formula.
17
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
It can be explained by using the below Venn diagram, where B has occurred event, so
sample space will be reduced to set B, and now we can only calculate event A when
event B has already occurred by dividing the probability of P(A⋀B) by P (B).
P (A ⋀ B) = P(A|B) P(B)
OR
P (A ⋀ B) = P(B|A) P(A)
18
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
The above equation (a) is called as Bayes' rule or Bayes' theorem. This equation is basic
of most modern AI systems for probabilistic inference.
* It is used to calculate the next step of the robot when the already executed step is
given.
* Bayes' theorem is helpful in weather forecasting.
* It can solve the Monty Hall problem.
* Applications include spam email classification, medical diagnosis, natural language
processing, and Bayesian networks.
Bayesian Network can be used for building models from data and expert’s opinions, and
it consists of two parts:
Each node corresponds to the random variables, and a variable can be continuous
or discrete.
19
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Properties:
1. Can be used to reason:
o Forward (top-down) from causes to effects -- predictive reasoning (causal
reasoning)
o Backward (bottom-up) from effects to causes -- diagnostic reasoning
2. Captures both qualitative and quantitative relationships between variables
Dempster Shafer Theory stands as a valuable tool in the field of artificial intelligence to
solve problems, handle uncertainty effectively and make more accurate decisions.
20
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
3. Mass functions: In particular, a mass function must assign a mass of zero to the
empty set (corresponding to no information), and a mass of one to the entire set
(corresponding to complete certainty).
4. Belief and plausibility: Given a mass function, we can calculate two measures of
uncertainty. They are:
a) Belief: The belief of a set A is the sum of the masses of all the focal elements
which include A. Belief represents the lower bound of uncertainty (how much
we believe A). A belief function assigns a degree of belief (or plausibility) to
each possible outcome.
b) Plausibility is the sum of the masses of all the focal elements which intersect
A. Plausibility represents the upper bound of uncertainty (how much we can
accept A). Plausibility (denoted by Pl) is thus related to Bel by:
Pl(p) = 1 − Bel(~p). It also ranges from 0 to 1
Dempster–Shafer Theory in AI, can analyse the evidence, assign masses to subsets of
possible conclusions, and calculate beliefs and plausibility where, belief<=
plausibility
21
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
*************
22
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
14. What are Frames in AI? Demonstrate with example. Refer 1.7
15. Discuss in detail about Rule Based Systems. Refer 1.9
16. How constraint propagation works in AI. Illustrate with example. Refer 2
17. Illustrate Frame Inheritance with example. Refer 1.8
18. Explain Probabilistic Reasoning under uncertainty. Refer 3.1
19. Describe Bayes’ Theorem and its application in AI. Refer 3.3
20. Elaborate Dempster Shafer Theory. Refer 3.5
***********
LECTURE PLAN
UNIT IV
S.No. Topic No. of Proposed Actual Pertaining Taxonomy Mode of
Periods lecture lecture CO(s) Level Delivery
Period Period
1
First order 1 CO4 L2 MD1,
logic MD5
2 Inference in MD1,
first order 1 CO4 L2 MD5
logic
3 Propostional 1 MD1,
vs First order CO4 L2 MD5
inference
4 Unification
& Lifts 1 CO4 L1 MD1,
MD5
5 Forward 1 CO4 L1 MD1,
chaining MD5
23
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
9 Inductive 1
learning CO4 L2 MD1,
MD5
10 Decision Tree 1 CO4 L2 MD1,
MD5
11 Explanation 1 CO4 L2 MD1,
based learning MD5
12 Statistical 1 CO4 L2 MD1,
learning MD5
methods
13 Reinforcement 1 CO4 L2 MD1,
Learning MD5
UNIT - IV
Logic concepts: First order logic. Inference in first order logic, propositional vs. first order
inference, unification & lifts forward chaining, Backward chaining, Resolution, learning from
observation Inductive learning, Decision trees, Explanation based learning, Statistical
Learning methods, Reinforcement Learning.
1. Introduction
Logical AI involves representing knowledge of an agent's world, its goals and the
current situation by sentences in logic. Logical AI deal with using knowledge base
and rule sets to make intelligent decisions.
24
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
An Inference Engine is a component of the expert system that applies logical rules to the
knowledge base to deduce new information. It interprets and evaluates the facts in the
knowledge base to provide an answer. A knowledgebase is a structured collection of facts about
the system’s domain.
1.1 First-Order logic
First Order Logic (FOL) can be defined as “a collection of objects, their attributes, and relations
among them to represent knowledge”. It's also known as Predicate Logic.
Objects: A, B, people, numbers, colors, squares, pits, wars, theories, wumpus, ......
Relations: It can be unary relation such as: red, round, is adjacent, or n-any relation
such as: the sister of, brother of, has colour, comes between
Function: Father of, best friend, third inning of, end of, ......
First-order logic also has two main parts as a natural language:
o Syntax
o Semantics
Syntax of First-Order logic: In first-order logic, the syntax of FOL determines which set of
symbols represents a logical expression.
25
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Equality ==
Quantifier ∀, ∃
a) Atomic sentences: Predicate can be used to represent atomic sentences (term1, term2,
term3......, term n).
b) Complex Sentences: Connectives are used to join atomic sentences to form complex
sentences.
c) Subject: The major component of the sentence is the subject.
d) Predicate: A predicate is a relationship that ties two atoms together in a sentence.
Consider the following statement: "x is an integer."
e) Quantifiers: These are the symbols that allow you to determine or identify the variable's
range and scope in a logical expression. There are two different kinds of quantifiers:
Universal Quantifier (for all, everyone, everything): Universal Quantifier used to express
that a statement is true for all objects in the domain.
Statement: All man drink coffee
Logic representation: ∀xman(x)→drink(coffee).
It will be read as: There are all x where x is a man who drink coffee.
Existential Quantifier, (for some, at least one): Existential quantifiers are a sort of quantifier
that expresses that a statement is true for at least one instance of something within its scope.
Statement: Some boys are intelligent.
Logic representation: ∃x: boys(x)∧intelligent(x)
It will be read as: There are some x where x is a boy who is intelligent.
1.2 Inference in First Order Logic
In artificial intelligence, we need intelligent computers which can create new logic from
old logic or by evidence, so generating the conclusions from evidence and facts is termed
as Inference. “Inference in First-Order Logic is used to deduce new facts or sentences from existing
sentences”.
A. Substitution:
26
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
There are some Inference rules that can be applied to sentences with quantifiers to
obtain sentences without quantifiers. These rules will lead us to make the conversion.
1. Universal Generalization: This rule can be used if we want to show that every
element has a similar property. It can be represented as:
Ex: IF "Every person like ice-cream"=> ∀x P(x) so, we can infer that,
“John likes ice-cream" => P(c)
3. Existential Instantiation is also known as Existential Elimination. This rule states
that one can infer P(c) from the formula given in the form of ∃x P(x) for a new
constant symbol c. It's written like this:
27
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
A. Propositional logic: Propositional logic or sentential logic, deals with propositions that can
be either true or false and uses logical connectives to form complex expressions. However,
propositional logic is limited because it cannot represent relationships between objects
or quantify over them.
Logical Connectives: Operators such as AND (∧), OR (∨), NOT (¬), IMPLIES (→)
28
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Example:
P: “It is raining.”
Q: “The ground is wet.”
Using logical connectives, we can form complex expressions like P→Q (If it is
raining, then the ground is wet).
Applications:
Digital Circuit Design: Representing and analysing the behaviour of logic gates and
circuits where each component can be represented as a true/false variable, and the
overall circuit can be analysed using logical connectives.
Expert Systems: Encoding simple rules and facts for decision-making systems.
Truth Tables: Evaluating the truth values of logical expressions based on various
combinations of input values.
B. First-order logic: First-order logic, or predicate logic, extends propositional logic by
introducing predicates and quantifiers, allowing us to express more complex statements. First-
order logic cannot represent higher-order concepts, such as statements about other
statements or sets of objects.
* Variables: Symbols that can represent any object in the domain (e.g., x, y).
* Predicates: Functions that map objects to truth values (e.g., Likes (Alice, Ice
Cream)).
* Quantifiers: Symbols that indicate the scope of a statement (e.g., ∀ (for all), ∃
(exists)).
* Logical Connectives: Same as in propositional logic.
29
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Applications:
* Ontology Modelling: Representing knowledge about categories, properties, and
relationships between concepts in a domain.
* Semantic Web: Encoding information about web resources and their relationships
to enable intelligent searching and data integration.
* Automated Reasoning: Developing systems that can reason about knowledge,
make inferences, and answer queries based on a set of axioms and rules.
* Natural Language Processing: Understanding and generating human language by
modelling the relationships and properties of words and sentences.
C. Key Differences Summarized:
Example P→Q
1.4 Unification
30
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
With both the substitutions, the first expression will be identical to the second expression
and the substitution set will be: [a/x, f(z)/y].
1.5 Lifting
Lifting is a concept that extends the utility of unification, enabling more flexible and
abstract handling of knowledge representations in AI. Lifted Inference rule require
finding substitutions that make different logical expressions look identical (same). That
is unification.
It is often associated with answer set programming (ASP), a logic programming
paradigm that serves as a foundation for AI knowledge representation and reasoning.
1.6 Resolution:
Resolution is used, if there are various statements are given, and we need to prove a
conclusion of those statements. Unification is a key concept in proofs by resolutions.
Resolution is a single inference rule which can efficiently operate on the conjunctive normal form
or clausal form. Every sentence of first-order logic can be converted into an inferentially
equivalent CNF sentence.
* Clause: Disjunction of literals (an atomic sentence) is called a clause. It is also
known as a unit clause.
31
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
This rule is also called the binary resolution rule because it only resolves exactly two
literals.
Steps for Resolution:
1. Conversion of facts into first-order logic.
2. Convert FOL statements into CNF
3. Negate the statement which needs to prove (proof by contradiction)
4. Draw resolution graph (unification).
The resolution inference rule:
The resolution rule for first-order logic is simply a lifted version of the propositional
rule. Resolution can resolve two clauses if they contain complementary literals, which
are assumed to be standardized apart so that they share no variables.
32
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Properties of Forward-Chaining:
• It is a process of making a conclusion based on known facts or data, by starting from
the initial state and reaches the goal state.
• It is a down-up approach, as it moves from bottom to top.
• Also called as data driven as we reach to the goal using available data.
• It applies inference rules (Modus Ponens) in the forward direction to extract more data
until a goal is reached.
• Slow as it must use all the rules.
• Commonly used in the Expert Systems, such as CLIPS, business, and production rule
systems.
B. Backward Chaining:
With this strategy, an expert system finds out the answer to the question, “Why
this happened?”. Based on what has already happened, the Inference Engine tries to
find out which conditions could have happened in the past for this result.
This strategy is followed for finding out cause or reason. This algorithm works
backward from the goal, chaining through rules to find known facts that support the proof.
For example, diagnosis of blood cancer in humans.
33
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
• It operates in backward direction i.e. it works from goal to reach initial state.
• The backward-chaining method mostly used a depth-first search strategy for proof.
• Its goal is to get the possible facts, or the required data based on Modus Ponens
inference rule.
• Fast as it must use only a few rules.
• Backward-chaining algorithm is used in game theory, automated theorem proving tools,
inference engines, proof assistants, and various AI applications.
2. Learning
Learning is essential for unknown environments. It modifies the agent's decision
mechanisms to improve performance.
* “Learning is constructing or modifying representations of what is being experienced”.
(Michalski, 1986)
* “A computer program learns if it improves its performance at some tasks through
experience” (Mitchell, 1997).
Machine Learning:
In the field of artificial intelligence known as machine learning, algorithms are
developed that can learn patterns and make judgments or predictions without being
explicitly programmed.
34
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
35
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
36
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
37
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
outcome of that decision. The leaves of the tree represent the final decisions or
predictions. Decision trees are used in various fields such as machine learning, data mining,
and statistics.
38
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
For example, the instance (Outlook = Sunny, Temperature = Hot, Humidity = High,
Wind = Strong) would be sorted down the leftmost branch of this decision tree and
would therefore be classified as a negative instance i.e., the tree predicts that Play
Tennis = no.
39
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
40
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
41
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
6. K-Nearest neighbour KNN: KNN is a simple, yet effective algorithm used for
classifying data points based on the majority vote of their nearest neighbors. It is suitable for
both classification and regression problems and does not require training.
In KNN, statistical measures are utilized to determine the proximity between data
points, helping to identify the nearest neighbors. The majority vote of the nearest
neighbors is then used to classify or predict the target variable.
2.6 Reinforcement Learning
Reinforcement Learning (RL) is a branch of machine learning focused on making decisions to
maximize cumulative rewards in each situation. RL involves learning through experience. In
RL, an agent learns to achieve a goal in an uncertain, potentially complex environment by
performing actions and receiving feedback through rewards or penalties.
42
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
43
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Disadvantages:
1. Reinforcement learning is not preferable to use for solving simple problems.
2. Reinforcement learning needs a lot of data and a lot of computation.
3. In RL, If the reward function is poorly designed, the agent may not learn the desired
behavior.
4. Reinforcement learning can be difficult to debug and interpret.
2.6.1 Types of Reinforcement:
1) Positive: Positive Reinforcement is defined as when an event, occurs due to a
particular behavior, increases the strength and the frequency of the behavior. In other
words, it has a positive effect on behavior.
Advantages:
* Maximizes Performance
* Sustain Change for a long period of time.
* Too much Reinforcement can lead to an overload of states which can diminish
the results.
2) Negative: Negative Reinforcement is defined as strengthening of behavior because a
negative condition is stopped or avoided.
Advantages:
* Increases Behavior.
* Provide defiance to a minimum standard of performance.
* It Only provides enough to meet up the minimum behavior.
44
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
The above image shows the robot, diamond, and fire. The goal of the robot is to get the
reward that is the diamond and avoid the hurdles that are fired. The robot learns by trying
all the possible paths and then choosing the path which gives him the reward with the
least hurdles. Each right step will give the robot a reward and each wrong step will subtract
the reward of the robot. The total reward will be calculated when it reaches the final
reward that is the diamond.
45
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Review Questions:
PART-A (TWO MARKS)
1. Mention the two fundamental logics in AI with any two key differences. Refer 1.3(C)
7. Draw the schematic diagram for Decision tree and Explanation based learning. Refer 2.3,2.4
8. Define Observational learning and list the key elements. Refer 2.1
9. Give the diagrammatic representation for the Inductive Learning Algorithm with an example.
Refer 2.2
1. Define Logic in AI. Classify FOL and Propositional logic. Refer 1.3
3. What is inference in FOL? Discuss FOL Inference rules for quantifiers. Refer 1.2
7. Elucidate the structure and working of Decision Trees with an example. Refer 2.3
46
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
10. Illustrate the working of Reinforcement Learning. Formulate Navigating a Maze problem. Refer
2.6,2.6.3
LECTURE PLAN
UNIT V
S.No. Topic No. of Proposed Actual Pertaining Taxonomy Mode of
Periods lecture lecture CO(s) Level Delivery
Period Period
1 Architecture 1 CO4 L2 MD1,
of expert MD5
systems
2 Roles of 1 CO4 L2 MD1,
expert MD5
systems
3 Knowledge 1 CO4 L2 MD1,
Acquisition MD5
47
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
UNIT - V
Expert Systems: Architecture of expert systems, Roles of expert systems – Knowledge
Acquisition Meta knowledge Heuristics. Typical expert systems – MYCIN, DART, XCON:
Expert systems shells.
1. Introduction
An expert system is an AI software that is designed to solve complex problems by using knowledge
from its knowledge base to provide decision-making ability like a human-expert. The expert
system is a part of AI, and the first ES was developed in the year 1970, which was the first
successful approach of artificial intelligence. One of the common examples of an ES is a
suggestion of spelling errors while typing in the Google search box.
1.1 Architecture of an Expert System
The process of building an expert system is often called knowledge engineering.
48
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
49
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
50
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Expert system,
5. Limited Scope: They are not suitable for handling tasks that require human intuition,
creativity, or emotional intelligence.
1.5 Applications of Expert Systems
1. Medical Diagnosis: Expert systems assist doctors by analyzing symptoms and
medical history to suggest possible diagnoses or treatment options. For example,
MYCIN, an early expert system, helped identify bacterial infections and recommend
antibiotics.
2. Financial Services: In finance, expert systems are used for credit scoring, fraud
detection, and investment advice. They analyze financial data and patterns to make
informed decisions.
3. Technical Support: Expert systems can troubleshoot and provide solutions for
technical issues. They guide users through problem-solving steps based on pre-
defined rules and knowledge.
4. Manufacturing: In manufacturing, expert systems help optimize production
processes, perform quality control, and manage inventory by analyzing data and
making recommendations.
51
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
The quality of the knowledge acquisition process directly affects the system's
performance and accuracy.
2. Meta-Knowledge
Meta-knowledge is "knowledge about knowledge." In expert systems, meta-knowledge
refers to the understanding of how the knowledge base is structured and how to use it
efficiently.
It involves knowing:
How and when to apply specific rules.
The strategies or methods to search and infer the best solution.
The level of confidence in certain rules or pieces of knowledge.
Meta-knowledge helps an expert system manage uncertainty, optimize performance,
and prioritize actions. It provides context and reasoning guidelines for the system’s
knowledge.
3. Heuristics
Heuristics are rules of thumb or practical shortcuts that help in making decisions more
efficiently. They are not guaranteed to produce the optimal solution but often lead to
good enough solutions faster.
52
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
53
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
54
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
55
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Functionality:
o Provides structured decision-making by analyzing different alternatives
based on weighted criteria.
o Supports decision-making processes in domains where multiple options
need to be evaluated against performance, risk, and other factors.
Domain Applications:
DART can be applied in various fields like business management, engineering,
finance, and healthcare, where decisions must be made by comparing alternatives
and trade-offs.
Key Features:
Multi-criteria decision-making (e.g., cost vs. benefit analysis).
Integration with inference engines and rule-based systems to automate decision-
making.
Uncertainty handling and what-if analysis.
1.8.2 MYCIN
Development: MYCIN was developed in the early 1970s at Stanford University
by Edward Shortliffe as a rule-based expert system focused on medical diagnosis
and treatment recommendations for infectious diseases, particularly bacterial
infections.
56
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Key Features:
Rule-based inference engine (over 600 rules).
Certainty factor-based reasoning to handle incomplete or uncertain data.
Natural language processing for user interaction (though limited by the
technology at the time).
Foundational for many later medical expert systems.
1.8.3 XCON (eXpert CONfigurer)
Development: XCON (originally called R1) was developed by John McDermott
at Digital Equipment Corporation (DEC) in the late 1970s to solve a specific
business problem—configuring VAX computer systems.
Purpose: XCON was designed to help DEC’s sales and manufacturing teams
configure the complex hardware components of their VAX computers, ensuring
that they were properly assembled and compatible.
57
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Functionality:
o XCON is a rule-based system with hundreds of if-then rules, which automates
the process of configuring complex hardware systems by ensuring that all the
necessary components are included and correctly interconnected.
o It applies forward chaining—starting from the facts provided by the user
(e.g., specific hardware parts required) and then working forward through rules
to arrive at a configuration solution.
Domain Applications: Primarily used in the manufacturing and sales domains
for configuring complex systems, especially for computer hardware and network
design.
Key Features:
Rule-based system designed for complex configuration tasks.
Forward chaining inference engine to apply knowledge rules to specific facts.
Used a large set of rules (eventually over 10,000) to cover a wide range of
hardware configurations.
Ensured that systems were error-free and complete, saving DEC time and
reducing human errors in configuration.
1.8.4 Comparison of DART, MYCIN, and XCON:
Diagnosis and
Primary Use VAX Computer
Decision Optimization Treatment of
Case Configuration
Infections
Enhanced decision-
Pioneering medical Successful commercial
Impact making in various
AI AI system
domains
58
Compiled By: P. Rajyalakshmi S.V.P.C.E.T
Department of CSE (AI & ML) II Year B.Tech-I Semester
Review Questions:
Part-A (Two Marks)
Define Expert system.
Compare two different expert system shells (e.g., CLIPS and Jess)
Write the functionality of XCON.
Give the architecture of MYCIN in medical diagnosis.
Draw the schematic diagram for expert system system shell.
Explain the role of the knowledge base and inference engine in the architecture of an expert system.
How do heuristics improve the performance of expert systems? Provide examples from real-world
applications.
Examine the architecture and functionality of the MYCIN expert system in medical diagnosis.
Explain the key components of an expert system shell and discuss the benefits and limitations.
59
Compiled By: P. Rajyalakshmi S.V.P.C.E.T