0% found this document useful (0 votes)
49 views113 pages

5th Sem BCS515B - AI - Module3

Uploaded by

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

5th Sem BCS515B - AI - Module3

Uploaded by

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

Sri Sri Sri Dr.

Nirmalanandanatha Maha Swamiji


Padmabhushana Sri Sri Sri
President, Sri Adichunchanagiri Shikshana Trust ®
Dr. Balagangadharanath Maha Swamiji

Sri Sri Dr. Prakashanatha Swamiji


Managing Director, BGS &
SJB Group Of Institutions & Hospitals

Prof. B. G. Sangameshwara, ME., Ph.D


Dr. K. V. Mahendra Prashanth, ME., Ph.D Advisor, SJBIT
Principal

21CS735, IoT- Bhaktavatsala Shivaram, Associate Professor, CSE 1


Artificial Intelligence
5th Sem, CSE,
BCS515B

Bhaktavatsala Shivaram
Associate Professor
BCS515B, AI - Bhaktavatsala Shivaram, Associate Professor, CSE 3
BCS515B, AI - Bhaktavatsala Shivaram, Associate Professor, CSE 4
Problem Solving
Module 3
• Informed Search Strategies (3.5)
• Heuristic Functions (3.6)
Logical Agents
• Knowledge based agents (7.1)
• The Wumpus World (7.2)
• Logic (7.2)
• Propositional Logic (7.3)
• Reasoning patterns in Propositional Logic (7.4)

BCS515B, AI - Bhaktavatsala Shivaram, Associate Professor, CSE 5


Model 2: Informed Search
B INFORMED SEARCH UNINFORMED SEARCH
a
• Search with Information • Search without Information
c
k • Use Knowledge to find steps to • No Knowledge
g solution
r
• Quick Solution • Time Consuming
o
u • Less Complexity • More Complexity (Time, Space)
n • Eg: A*, Heuristic DFS, Best First • Depth First Search, Breadth First
d
Search Search, etc..
• Also called as “Heuristic” search • Also called as “Blind” search

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 6


Model 2: Informed Search
B INFORMED SEARCH • Informed search algorithm contains
a
• Search with Information an array of knowledge such as how
c
• Use Knowledge to find steps to far we are from the goal, path cost,
k
g solution how to reach to goal node, etc. This
r knowledge help agents to explore
• Quick Solution
o less to the search space and find
u • Less Complexity more efficiently the goal node.
n • Eg: A*, Heuristic DFS, Best First • The informed search algorithm is
d
Search more useful for large search space.
• Also called as “Heuristic” search • Informed search algorithm uses the
idea of heuristic, so it is also called
Heuristic search.

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 7


Model 2: Informed Search
B INFORMED SEARCH
a
• Heuristic
c
k
• is a technique designed for problem solving more quickly when classic
g methods are too slow for finding an exact or approximate solution, or
r when classic methods fail to find any exact solution in a search space.
o
u
n
• Heuristic Function
d
• A heuristic function, also simply called a heuristic, is a function that
ranks alternatives in search algorithms at each branching step based
on available information to decide which branch to follow.

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 8


Model 2: Informed Search Strategies – Greedy Best First Search
G
Greedy Best First Search:
r
e • is an AI search algorithm that attempts to find the most
e promising path from a given starting point to a goal.
d
y
• It prioritizes paths that appear to be the most promising,
regardless of whether or not they are actually the shortest
B path.
e
s
• The algorithm works by evaluating the cost of each possible
t path and then expanding the path with the lowest cost.
• This process is repeated until the goal is reached.
S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 9
Model 2: Informed Search Strategies – Greedy Best First Search
G
Greedy Best First Search AI Algorithm:
r
e • Use heuristic function to determine which path is the most
e promising.
d
y
• The heuristic function takes into account the cost of the
current path and the estimated cost of the remaining
B paths.
e
s
• If the cost of the current path is lower than the estimated
t cost of the remaining paths, then the current path is
chosen.
S
e
• This process is repeated until the goal is reached.
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 10
Model 2: Informed Search Strategies – Greedy Best First Search
G • Always selects the path which Algorithm
r appears best at the moment
e • Priority Queue “Y” containing
• It is a combination of depth-first
e initial states
d
search and breadth-first search Loop
y • It uses the heuristic function and • If Y= Empty Return Fail
• Else
search • Node <- Remove- First (Y)
B • With the help of best-first search, • If Node = Goal
e • Return path from Initial
at each step, we can choose the
s state
t
most promising node. • Else
• In the best first search algorithm, • Generate all successors of
NODE
S we expand the node which is • And insert newly generated
e closest to the goal node and the NODE
a minimum cost is estimated by • Into Y according to cost
r value
heuristic function. End Loop
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 11
Model 2: Informed Search Strategies – Greedy Best First Search
G • The evaluation function is f(n) = h(n)
r where, h(n) = estimated cost from node n to the goal
e
e • Greedy search ignores the cost of the path that has already been
d traversed to reach n.
y • Therefore, the solution given is not necessarily optimal.
B
e
s
t

S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 12
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example1
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [E,C,B]
y E
111
99 3. [F,G,C,B] [A, E]
B D 80
F 4. [I,G,C,B] [A, E, F]
e
G
s 211 5. [E,B,D] [A, E, F, I]
97
t

H 101
S I Traverse Path = A -> E -> F-> I
e Distance (A-E-F-I) =253+178+0 = 431
a
r
Path Cost (A-E-F-I) =140+99+211 = 450
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 13
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example1
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [E,C,B]
y E
111
99 3. [F,G,C,B] [A, E]
B D 80
F 4. [I,G,C,B] [A, E, F]
e
G
s 211 5. [G, C,D] [A, E, F, I]
97
t

H 101
S I Traverse Path = A -> E -> F-> I
e Distance (A-E-F-I) =253+178+0 = 431
a
r
Path Cost (A-E-F-I) =140+99+211 = 450
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 14
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example1
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [E,C,B]
y E
111
99 3. [F,G,C,B] [A, E]
B D 80
F 4. [I,G,C,B] [A, E, F]
e
G
s 211 5. [E,B,D] [A, E, F, I]
97
t

H 101
S I Traverse Path = A -> E -> F-> I
e Distance (A-E-F-I) =253+178+0 = 431
a
r
Path Cost (A-E-F-I) =140+99+211 = 450
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 15
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example1
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [E,C,B]
y E
111
99 3. [F,G,C,B] [A, E]
B D 80
F 4. [I,G,C,B] [A, E, F]
e
G
s 211 5. [G, C,D] [A, E, F, I]
97
t

H 101
S I Traverse Path = A -> E -> F-> I
e Distance (A-E-F-I) =253+178+0 = 431
a
r
Path Cost (A-E-F-I) =140+99+211 = 450
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 16
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example1
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [E,C,B]
y E
111
99 3. [F,G,C,B] [A, E]
B D 80
F 4. [I,G,C,B] [A, E, F]
e
G
s 211 5. [G, C,D] [A, E, F, I]
97
t

H 101
S I Traverse Path = A -> E -> F-> I
e Distance (A-E-F-I) =253+178+0 = 431
a
r
Path Cost (A-E-F-I) =140+99+211 = 450
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 17
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example2
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [C,E,B]
y E
111
99 3. [D,E,B] [A, C]
80 ** 220
B D
F
e
s G
211 INFINITE LOOP
97
t

H 101
S I
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 18
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example2
r
e A 75 f(n) = h(n) = straight Open Closed
118 B
e 140 Line distance heuristic 1. [A] []
d [A]
C 2. [C,E,B]
y E
111
99 3. [D,E,B] [A, C]
80 ** 220
B D
F
e
s G
211 INFINITE LOOP
97
t

H 101
S I
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 19
Model 2: Informed Search Strategies – Greedy Best First Search
G • Greedy best first search can start down an infinite path and
r
e
never return to try other possibilities, it is incomplete
e • Because of its greediness the search makes choice that can
d
y
lead to a dead end; then one backs up in the search tree to
the deepest unexpanded node.
B
▪ Greedy best first search resembles depth-first search in the way it
e
s
prefers to follow a single path all the way to the goal, but will back up
t when it hits a dead end.
▪ The quality of the heuristic function determines the practical usability
S of greedy search
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 20
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example3
r
e A 7 Straight Line Distance Open Closed
11 D
e 14 Given (say): 1. [A] []
d B 18 A -> G = 40 2. [C,B,D] [A]
25
y C B -> G = 32
10 C -> G = 25 3. [F,E,B,D] [A, C]
15
8
B
F
D -> G = 35 4. [G,E,B,D] [A, C, F]
e E E -> G = 19
s 20 F -> G = 17 5. [E,B,D] [A, C, F, G]
9
t G -> G = 0
H 10 H -> G = 10
S G Traverse Path = A -> C -> F-> G
e Path Cost (A-C-F-G) = 14+10+20 = 44
a
r
Distance (A-C-F-G) = 40+19+17 = 66
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 21
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example3
r
e A 7 Straight Line Distance Open Closed
11 D
e 14 Given (say): 1. [A] []
d B 18 A -> G = 40 2. [C,B,D] [A]
25
y C B -> G = 32
10 C -> G = 25 3. [F,E,B,D] [A, C]
15
8
B
F
D -> G = 35 4. [G,E,B,D] [A, C, F]
e E E -> G = 19
s 20 F -> G = 17 5. [E,B,D] [A, C, F, G]
9
t G -> G = 0
H 10 H -> G = 10
S G Traverse Path = A -> C -> F-> G
e Path Cost (A-C-F-G) = 14+10+20 = 44
a
r
Distance (A-C-F-G) = 40+19+17 = 66
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 22
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example3
r
e A 7 Straight Line Distance Open Closed
11 D
e 14 Given (say): 1. [A] []
d B 18 A -> G = 40 2. [C,B,D] [A]
25
y C B -> G = 32
10 C -> G = 25 3. [F,E,B,D] [A, C]
15
8
B
F
D -> G = 35 4. [G,E,B,D] [A, C, F]
e E E -> G = 19
s 20 F -> G = 17 5. [E,B,D] [A, C, F, G]
9
t G -> G = 0
H 10 H -> G = 10
S G Traverse Path = A -> C -> F-> G
e Path Cost (A-C-F-G) = 14+10+20 = 44
a
r
Distance (A-C-F-G) = 40+19+17 = 66
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 23
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example4
r
e S Node (n) ->H(n) Open Closed
3
e 2
A -> 12 1. [S] []
d B -> 4 [S]
A B 2. [B,A]
y 4 C -> 7
1
3 1
D -> 3 3. [F,E,A] [S, B]
B E -> 8 4.
C E F [G,I,E,A] [S, B, F]
e D 5 F -> 2
2 3
s G -> 0 5. [I,E,A] [S, B, F, G]
t H -> 4
H I
G I -> 9
S Traverse Path = S -> B -> F-> G
S -> 13
e Path Cost (S-B-F-G) = 2+1+3 = 6
a
r
Distance (S-B-F-G) = 13+4+2+0 = 19
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 24
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example4
r
e S Node (n) ->H(n) Open Closed
3
e 2
A -> 12 1. [S] []
d B -> 4 [S]
A B 2. [B,A]
y 4 C -> 7
1
3 1
D -> 3 3. [F,E,A] [S, B]
B E -> 8 4.
C E F [G,I,E,A] [S, B, F]
e D 5 F -> 2
2 3
s G -> 0 5. [I,E,A] [S, B, F, G]
t H -> 4
H I
G I -> 9
S Traverse Path = S -> B -> F-> G
S -> 13
e Path Cost (S-B-F-G) = 2+1+3 = 6
a
r
Distance (S-B-F-G) = 13+4+2+0 = 19
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 25
Model 2: Informed Search Strategies – Greedy Best First Search
G Greedy Search Example4
r
e S Node (n) ->H(n) Open Closed
3
e 2
A -> 12 1. [S] []
d B -> 4 [S]
A B 2. [B,A]
y 4 C -> 7
1
3 1
D -> 3 3. [F,E,A] [S, B]
B E -> 8 4.
C E F [G,I,E,A] [S, B, F]
e D 5 F -> 2
2 3
s G -> 0 5. [I,E,A] [S, B, F, G]
t H -> 4
H I
G I -> 9
S Traverse Path = S -> B -> F-> G
S -> 13
e Path Cost (S-B-F-G) = 2+1+3 = 6
a
r
Distance (S-B-F-G) = 13+4+2+0 = 19
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 26
Model 2: Informed Search Strategies – Greedy Best First Search
G • Greedy search is not optimal
r
e
• Greedy search is incomplete without systematic checking of repeated
e states.
d • In the worst case, the Time and Space Complexity of Greedy Search
y
are both same = O (bm)
B
where b – branching factor and m – max path length
e
s
t

S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 27
Model 2: Informed Search Strategies – Greedy Best First Search
G Advantages: Disadvantages:
r
• Simple and Easy to Implement • Inaccurate Results
e
• Fast and Efficient • Local Optima
e
• Low Memory Requirements • Heuristic Function
d
• Flexible • Lack of Completeness
y
• Efficiency
B
e
s
t

S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 28
Model 2: Informed Search Strategies – Greedy Best First Search
G Few applications of Greedy Best First Search
r
Pathfinding: used to find the shortest path between two points in a graph. It is used
e
in many applications such as video games, robotics, and navigation systems.
e
Machine Learning: used in machine learning algorithms to find the most promising
d
path through a search space.
y
Optimization: used to optimize the parameters of a system in order to achieve the
desired result.
B
Game AI: used in game AI to evaluate potential moves and chose the best one.
e
Navigation: used to navigate to find the shortest path between two locations.
s
Natural Language Processing: used in natural language processing tasks such as
t
language translation or speech recognition to generate the most likely sequence of
words.
S
Image Processing: used in image processing to segment image into regions of
e
interest.
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 29
Model 2: Informed Search Strategies – A* Search
A • Always selects the path which Algorithm
* appears best at the moment
• Priority Queue “Y” containing
• It is a combination of depth-first
S initial states
e
search and breadth-first search Loop
a • It uses the heuristic function and • If Y= Empty Return Fail
• Else
r search • Node <- Remove- First (Y)
c • With the help of best-first search, • If Node = Goal
h • Return path from Initial
at each step, we can choose the
state
most promising node. • Else
• In the best first search algorithm, • Generate all successors of
NODE
we expand the node which is • And insert newly generated
closest to the goal node and the NODE
minimum cost is estimated by • Into Y according to cost
value
heuristic function. End Loop
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 30
Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 31


Model 2: Informed Search Strategies – A* Search
A The Romania Problem is a popular example in Artificial Intelligence to illustrate search
* algorithms, where the goal is to find the shortest path between cities on a map of
Romania. Using Greedy Search, the algorithm prioritizes visiting the next city closest to
S the goal, measured by straight-line distance (heuristic).
e Example:
a The map of Romania includes cities like Arad, Sibiu, Fagaras, and Bucharest (the goal
r city). Distances are represented as straight-line heuristics, not road distances.
c Problem Setup:
h •Start City: Arad
•Goal City: Bucharest
•Heuristic Values (h(n)): Straight-line distances from each city to Bucharest.
For example:
•Arad → Bucharest: 366
•Sibiu → Bucharest: 253
•Fagaras → Bucharest: 176
•Bucharest → Bucharest: 0
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 32
Model 2: Informed Search Strategies – A* Search
A Algorithm Steps:
* 1.Start at Arad.
S
1.Possible next cities: Sibiu, Timisoara, Zerind.
e 2.Choose the city with the lowest heuristic: Sibiu (253).
a 2.Move to Sibiu.
r 1.Possible next cities: Arad, Fagaras, Rimnicu Vilcea.
c 2.Choose Fagaras (176).
h
3.Move to Fagaras.
1.Possible next city: Bucharest (0).
4.Reach Bucharest.

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 33


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 34


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 35


Model 2: Informed Search Strategies – A* Search
A Path:
* Arad → Sibiu → Fagaras → Bucharest.
S
Characteristics of Greedy Search in this Example:
e •Advantages:
a • Simple and fast due to focus on immediate goals.
r • May find the goal quickly if the heuristic is well-designed.
c •Disadvantages:
h
• Not guaranteed to find the shortest path (optimal solution).
• May get stuck in loops or dead ends if heuristic values are misleading.

In this example, the path found by Greedy Search is not guaranteed to be


the shortest but depends on the heuristic values provided. It illustrates
how the algorithm prioritizes immediate gain without backtracking.
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 36
Model 2: Informed Search Strategies – A* Search
A A* (A-star) Search is a widely used algorithm in Artificial
*
Intelligence for finding the shortest path. It combines the
S advantages of both Greedy Search and Uniform Cost Search by
e considering both the cost to reach a node and the estimated cost
a
r
to the goal.
c In the Romania Problem, the goal is to find the shortest path
h from Arad to Bucharest on a map. The heuristic h(n)h(n)h(n) is
the straight-line distance from each city to Bucharest, while the
actual cost g(n)g(n)g(n) is the road distance traveled so far.

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 37


Model 2: Informed Search Strategies – A* Search
A Problem Setup:
* •Start City: Arad
•Goal City: Bucharest
S •Heuristic Values (h(n)):
e • Arad → Bucharest: 366
a • Sibiu → Bucharest: 253
r • Fagaras → Bucharest: 176
c • Rimnicu Vilcea → Bucharest: 193
h • Bucharest → Bucharest: 0
•Road Costs (g(n)):
• Arad → Sibiu: 140
• Arad → Timisoara: 118
• Sibiu → Fagaras: 99
• Sibiu → Rimnicu Vilcea: 80
• Rimnicu Vilcea → Pitesti: 97
• Pitesti → Bucharest: 101
• Fagaras → Bucharest:21CS54,
211AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 38
Model 2: Informed Search Strategies – A* Search
A Algorithm Steps:
* A* Search calculates f(n)=g(n)+h(n)f(n) = g(n) + h(n)f(n)=g(n)+h(n) at each
step and selects the node with the smallest f(n)f(n)f(n).
S
e
Step-by-Step Execution:
a 1.Start at Arad:
r 1.g(Arad)=0g(Arad) = 0g(Arad)=0, h(Arad)=366h(Arad) =
c 366h(Arad)=366, f(Arad)=0+366=366f(Arad) = 0 + 366 =
h
366f(Arad)=0+366=366.
2.Possible next cities: Sibiu, Timisoara, Zerind.
2.Choose Sibiu (lowest f(n)f(n)f(n)):
1.g(Sibiu)=140g(Sibiu) = 140g(Sibiu)=140 (Arad → Sibiu road cost),
2.h(Sibiu)=253h(Sibiu) = 253h(Sibiu)=253, f(Sibiu)=140+253=393f(Sibiu)
= 140 + 253 = 393f(Sibiu)=140+253=393.
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 39
Model 2: Informed Search Strategies – A* Search
A 3. Expand Sibiu:
* 1. Possible next cities: Fagaras, Rimnicu Vilcea.
2. Calculate f(n)f(n)f(n) for both:
S 1.f(Fagaras)=g(Sibiu)+g(Sibiu→Fagaras)+h(Fagaras)=140+99+176=415f(Fagaras) =
e g(Sibiu) + g(Sibiu → Fagaras) + h(Fagaras) = 140 + 99 + 176 =
a 415f(Fagaras)=g(Sibiu)+g(Sibiu→Fagaras)+h(Fagaras)=140+99+176=415.
r 2.f(RimnicuVilcea)=g(Sibiu)+g(Sibiu→RimnicuVilcea)+h(RimnicuVilcea)=140+80+
c 193=413f(Rimnicu Vilcea) = g(Sibiu) + g(Sibiu → Rimnicu Vilcea) + h(Rimnicu
h Vilcea) = 140 + 80 + 193 =
413f(RimnicuVilcea)=g(Sibiu)+g(Sibiu→RimnicuVilcea)+h(RimnicuVilcea)=140+
80+193=413.
4. Choose Rimnicu Vilcea (lower f(n)f(n)f(n)):
1. g(RimnicuVilcea)=220g(Rimnicu Vilcea) = 220g(RimnicuVilcea)=220 (140 + 80),
2. h(RimnicuVilcea)=193h(Rimnicu Vilcea) = 193h(RimnicuVilcea)=193,
f(RimnicuVilcea)=220+193=413f(Rimnicu Vilcea) = 220 + 193 =
413f(RimnicuVilcea)=220+193=413.
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 40
Model 2: Informed Search Strategies – A* Search
A 5. Expand Rimnicu Vilcea:
* •Possible next city: Pitesti.
•f(Pitesti)=g(RimnicuVilcea)+g(RimnicuVilcea→Pitesti)+h(Pitesti)=220+97+101=
S 418f(Pitesti) = g(Rimnicu Vilcea) + g(Rimnicu Vilcea → Pitesti) + h(Pitesti) =
e 220 + 97 + 101 =
a 418f(Pitesti)=g(RimnicuVilcea)+g(RimnicuVilcea→Pitesti)+h(Pitesti)=220+97+1
r 01=418.
c 6. Expand Pitesti:
h •Possible next city: Bucharest.
•f(Bucharest)=g(Pitesti)+g(Pitesti→Bucharest)+h(Bucharest)=317+101+0=418f(
Bucharest) = g(Pitesti) + g(Pitesti → Bucharest) + h(Bucharest) = 317 + 101 + 0
=
418f(Bucharest)=g(Pitesti)+g(Pitesti→Bucharest)+h(Bucharest)=317+101+0=41
8.
7. Goal Reached:
•The shortest path is Arad → Sibiu → Rimnicu Vilcea → Pitesti →
Bucharest. 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 41
Model 2: Informed Search Strategies – A* Search
A Characteristics of A* Search:
*
•Optimal: Finds the shortest path.
S •Complete: Guaranteed to find a solution if one exists.
e •Efficient: Uses a heuristic to guide the search, reducing
a
r
unnecessary exploration.
c The total cost for this path is 418418418. A* successfully balances
h exploration (minimizing road costs) and exploitation (prioritizing
cities closer to Bucharest).

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 42


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 43


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 44


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 45


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 46


Model 2: Informed Search Strategies – A* Search
A
*

S
e
a
r
c
h

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 47


Model 2: Informed Search Strategies – Greedy Best First Search
G • The evaluation function is f(n) = h(n)
r where, h(n) = estimated cost from node n to the goal
e
e • Greedy search ignores the cost of the path that has already been
d traversed to reach n.
y • Therefore, the solution given is not necessarily optimal.
B
e
s
t

S
e
a
r
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 48
Model 2: Informed Search – Heuristic Function
B Heuristic Function
a • It takes the current state of the agent as its input and produces the estimation of
c how close agent is from the goal.
k • The heuristic method, however, might not always give the best solution, but it
g guaranteed to find a good solution in reasonable time.
r • Heuristic function estimates how close a state is to the goal.
o • It is represented by h(n), and it calculates the cost of an optimal path between the
u pair of states.
n • The value of the heuristic function is always positive.
d
Admissibility of the heuristic function is given as:
h(n) <= h*(n)
Where, h(n) is heuristic cost, and h*(n) is the estimated cost.

Heuristic cost should be less than or equal to the estimated


cost.
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 49
Model 2: Heuristic Search and Heuristic Function
B
a
Heuristic Search and Heuristic function are used
c in informed search
k
g
r • Heuristic search is a simple searching technique that
o tries to optimize a problem using Heuristic Function
u
n
d
• Optimization means
• Solve problem in minimum number of steps or
cost

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 50


Model 2: Heuristic Function
B
a
Heuristic function
c ▪ Function H(n) that gives an estimation on the cost of getting
k from node ‘n’ to the goal state.
g ▪ It helps in selecting optimal node for expansion
r
o
u R1
35 Km 175 Km
n
d

City A City B
(Start) (Goal)

20 Km 215 Km
R2

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 51


Model 2: Logical Agents
L
Logical Agents
o
g
i
c
a
l

A
g
e
n
g
t
s

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 52


Model 2: Logical Agents
L
Logical Agents
o
g • Logical agents use formal logic to represent knowledge and
i make decisions.
c
a • Combine knowledge-based reasoning with automated
l inference.
• Operate in a Knowledge Base (KB), consisting of facts and
A
g
rules about the world.
e • Key Characteristics:
n
g
• Symbolic reasoning
t • Deductive problem-solving
s

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 53


Model 2: Logical Agents
L
Knowledge Based Agent
o
g
i
c
a
l

A
g
e
n
t
s

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 54


Model 2: Logical Agents
L
Knowledge Based Agent
o
g
i
c
a
l

A
g
e
n
t
s

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 55


Role of Knowledge-Based Agents
• Components:
• 1. Knowledge Base (KB): Contains information in a formal language.
• 2. Inference Mechanism: Derives new knowledge from existing facts.

• Example:
• If Rain(X) → Wet(Grass(X)) and Rain(Today), the agent deduces
Wet(Grass(Today)).
Model 2: Logical Agents
L
Knowledge Based Agent
o
g
i
c
a
l

A
g
e
n
t
s

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 57


Model 2: Logical Agents
L
Knowledge Based Agent
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 58


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 59


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i PEAS?
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 60


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 61


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 62


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 63


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 64


Model 2: Logical Agents
L
Wumpus World
o
g Solution:
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 65


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 66


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 67


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 68


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 69


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 70


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 71


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 72


Model 2: Logical Agents
L
Wumpus World
o
g Behavior
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 73


Model 2: Logical Agents
L
Wumpus World
o
g
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 74


Model 2: Logical Agents
L
Wumpus World
o
g
i
c
a
l

A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 75


BCS515B, AI - Bhaktavatsala Shivaram, Associate Professor, CSE 76
Logical Foundations
• - Propositional Logic:
• Deals with facts (true or false).
• Example: It is raining = True.
• - First-Order Logic (FOL):
• Extends propositional logic with quantifiers and
relationships.
• Example: For all x, if x is a bird, then x can fly (Bird(x) →
Fly(x)).
Example of Propositional Logic
in Logical Agents
• Given Knowledge:
• 1. If it rains, the grass will be wet.
• 2. It is raining.

• Formal Representation:
• 1. Rain → WetGrass
• 2. Rain

• Inference:
• Using Modus Ponens:
• WetGrass is true.
Example of First-Order Logic
• Scenario:
• All humans are mortal. Socrates is human.

• Representation in FOL:
• 1. ∀x (Human(x) → Mortal(x))
• 2. Human(Socrates)

• Inference:
• Using Universal Elimination: Mortal(Socrates).
- Environment: Grid-based world with a Wumpus
(monster), pits, and gold.
- Agent Goals:
- Avoid pits and the Wumpus.
- Grab the gold.
Logical Reasoning Example:
1. If Breeze → There is a pit nearby.
2. No breeze in [1,1], so [1,2] is safe.
[Visualization placeholder: Add Wumpus World
image here]
Module 5: Logic Agents
P
r
Proportional Logic
o
p
o
r
t
i
o
n
a
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 81
Module 5: Logic Agents
P
r
Proportional Logic
o
Propositional logic in Artificial intelligence
p
o The simplest kind of logic is propositional logic (PL), in which all
r statements are made up of propositions.
t
i
o The term "Proposition“ refers to a declarative statement that can be
n true or false. It's a method of expressing knowledge in logical and
a mathematical terms.
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 82
Module 5: Logic Agents
P
r
Proportional Logic
o
p Example:
o
r 1.It is Sunday.
t 2.The Sun rises from West (False proposition)
i
o 3.3 + 3 = 7 (False proposition)
n 4.5 is a prime number.
a
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 83
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Following are some basic facts about propositional logic:
o •Because it operates with 0 and 1, propositional logic is also
r
t
known as Boolean logic.
i •In propositional logic, symbolic variables are used to express
o
n
the logic, and any symbol can be used to represent a
a proposition, such as A, B, C, P, Q, R, and so on.
a
l
•Propositions can be true or untrue, but not both at the same
time.
L
o
•An object, relations or functions, and logical connectives make
g up propositional logic.
i
c
•Logical operators are another name for these connectives.
21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 84
Module 5: Logic Agents
P
r
Proportional Logic
o
p
•The essential parts of propositional logic are propositions and
o connectives.
r
t
•Connectives are logical operators that link two sentences
i together.
o
n
•Tautology, commonly known as a legitimate sentence, is a
a proposition formula that is always true.
a
l
•Contradiction is a proposition formula that is always false.
•Statements that are inquiries, demands, or opinions are not
L
o
propositions, such as "Where is Rohini","How are you",
g and "What is your name" are not propositions.
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 85
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Syntax of propositional logic:
o The allowed sentences for knowledge representation are
r
t
defined by the syntax of propositional logic. Propositions are
i divided into two categories:
o
n
1.Atomic Propositions.
a 2.Compound propositions.
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 86
Module 5: Logic Agents
P
r
Proportional Logic
o •Atomic propositions: Simple •Compound proposition: Simpler or
p
o assertions are referred to as atomic atomic statements are combined
r propositions. It is made up of only with parenthesis and logical
t one proposition sign. These are the connectives to form compound
i
o
sentences that must be true or propositions.
n untrue in order to pass.
a Example:
a
l
Example: • "It is raining today, and street is
• 2+2 is 4, it is an atomic wet."
L proposition as it is a true fact. • "Ankit is a doctor, and his clinic
o
g
• "The Sun is cold" is also a is in Mumbai."
i proposition as it is a false fact.
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 87
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Logical Connectives:
o Logical connectives are used to link two simpler ideas or to logically
r represent a statement. With the use of logical connectives, we can form
t
i
compound assertions. There are five primary connectives, which are
o listed below:
n 1.Negation:
a
2.Conjunction:
a
l 3.Disjunction:
4.Implication:
L
5.Biconditional:
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 88
Module 5: Logic Agents
P
r
Proportional Logic
o 1.Negation: A statement like ¬P is referred to as a negation of
p
o P. There are two types of literals: positive and negative literals.
r Example: Rohan is intelligent and hardworking.
t
i It can be written as,
o P = Rohan is intelligent,
n
a Q = Rohan is hardworking. →P ∧ Q.
a
l 2. Conjunction: A conjunction is a sentence that
L
contains ∧ connective such as, P ∧ Q.
o Example: "Ritika is a doctor or Engineer",
g
i
Here P = Ritika is Doctor. Q = Ritika is Doctor, so we can write it
c as P ∨ Q. 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 89
Module 5: Logic Agents
P
r
Proportional Logic
o
p 3. Disjunction: A disjunction is a sentence with a connective ∨
o , such as P ∨ Q, where P and Q are the propositions.
r
t
i
o
n 4. Implication: An implication is a statement such as P → Q. If-
a then rules are another name for implications.
a
l
It can be expressed as follows: If it rains, the street is flooded.
L
o Because P denotes rain and Q denotes a wet street, the
g situation is written as P and Q
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 90
Module 5: Logic Agents
P
r
Proportional Logic
o
p 5. Biconditional: A sentence like P Q, for example, is a
o biconditional sentence.
r
t
i I am alive if I am breathing.
o
n P= I am breathing, Q = I am alive, it can be represented as P ⇔
a Q.
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 91
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Following is the summarized table for Propositional Logic Connectives:
o
r Connective Technical Term Word Example
t Symbol
i
o ∧ Conjunction AND P∧Q
n
a V Disjunction OR PVQ
a
l → Implication Implies P→Q
L
o
⇔ Biconditional If and only If P⇔Q
g
i ¬ or ~ Negation Not ¬P or ¬Q
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 92
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Truth Table:
o We need to know the truth values of propositions in all feasible
r contexts in propositional logic. With logical connectives, we can
t
combine all possible combinations, and the representation of these
i
o combinations in a tabular manner is known as a truth table.
n
a The truth table for all logical connectives is as follows:
a
l For Negation:
L P ¬P
o
g
true false
i
c
false true 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 93
Module 5: Logic Agents
P
r
Proportional Logic
o
p For Conjunction:
o
r
t P Q P∧Q
i
o true true true
n
a true false false
a
l false true false
L
o
false false false
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 94
Module 5: Logic Agents
P
r
Proportional Logic
o
p For Disjunction:
o
r P Q PVQ
t
i true true true
o
n
a
true false true
a
l
false true true
L false false false
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 95
Module 5: Logic Agents
P
r
Proportional Logic
o
p For Implication:
o
r
t
P Q P→Q
i
o true true true
n
a true false false
a
l
false true true
L
o false false true
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 96
Module 5: Logic Agents
P
r
Proportional Logic
o
p For Biconditional:
o
r
t P Q P⇔Q
i
o true true true
n
a
a
true false false
l
false true false
L
o
false false true
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 97
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Truth table with three propositions:
o You can build a proposition composing three propositions P, Q, and R.
r The truth table is made up of 8Xn Tuples as we have taken three
t
i
proposition symbols
o
n
a
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 98
Module 5: Logic Agents
P
r
Proportional Logic
o P Q R ¬R PVQ P V Q → ¬R
p
o true true true false true false
r
t
true true false true true true
i true false true false true false
o
n true false false true true true
a
a
false true true false true false
l false true false true true true
L false false true false true true
o
g
false false false true true true
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 99
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Precedence of connectives:
o Propositional connectors or logical operators, like arithmetic
r
t
operators, have a precedence order. When evaluating a
i propositional problem, this order should be followed. The
o
n
following is a list of the Operators
Precedence operator precedence order:
a First Precedence Parenthesis
a Second Precedence Negation
l
Third Precedence Conjunction(AND)
L Forth Precedence Disjunction(OR)
o
g Fifth Precedence Implication
i Sixth Precedence Biconditional
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 100
Module 5: Logic Agents
P
r
Proportional Logic
o
p
Precedence of connectives:
o Propositional connectors or logical operators, like arithmetic
r
t
operators, have a precedence order. When evaluating a
i propositional problem, this order should be followed. The
o
n
following is a list of the Operators
Precedence operator precedence order:
a First Precedence Parenthesis
a Second Precedence Negation
l
Third Precedence Conjunction(AND)
L Forth Precedence Disjunction(OR)
o
g Fifth Precedence Implication
i Sixth Precedence Biconditional
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 101
Module 5: Logic Agents
P
r
Proportional Logic
o
p Note: Use parenthesis to make sure of the correct
o interpretations for a better understanding.
r
t
i For example: ¬R∨ Q, It can be interpreted as (¬R) ∨ Q.
o
n
a
a
l

L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 102
Module 5: Logic Agents
P
r
Proportional Logic
o Logical equivalence:
p
o
One of the characteristics of propositional logic is logical equivalence.
r If and only if the truth table's columns are equal, two assertions are
t said to be logically comparable. Let's take two propositions P and Q,
i
o
so for logical equivalence, we can write it as P⇔Q. In below truth
n table we can see that column for ¬P ∨ Q and P→Q, are identical hence
a P is Equivalent to P P Q ¬P ¬P V Q P → Q
a
l T T F T T
T F F F F
L
o F T T T T
g
i F F T T T
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 103
Module 5: Logic Agents
P
r
Proportional Logic
o Properties of Operators:
p
o
•Commutativity:
r • P ∧ Q= Q ∧ P, or
t • P ∨ Q = Q ∨ P.
i
•Associativity:
o
n • (P ∧ Q) ∧ R = P ∧ (Q ∧ R),
a • (P ∨ Q) ∨ R= P ∨ (Q ∨ R).
a •Identity element:
l
• P ∧ True = P,
L • P ∨ True= True.
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 104
Module 5: Logic Agents
P
r
Proportional Logic
o Properties of Operators:
p
o
•Distributive:
r • P ∧ (Q ∨ R) = (P ∧ Q) ∨ (P ∧ R).
t • P ∨ (Q ∧ R) = (P ∨ Q) ∧ (P ∨ R).
i
•DE Morgan's Law:
o
n • ¬(P ∧ Q) = (¬P) ∨ (¬Q),
a • ¬(P ∨ Q) = (¬ P) ∧ (¬Q).
a •Double-negation elimination:
l
• ¬(¬P) = P.
L
o
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 105
Module 5: Logic Agents
P
r
Proportional Logic
o
p Limitations of Propositional logic:
o •This is not possible to represent relations like ALL, some, or
r
t none with propositional logic.
i •Example:
o
n • All the girls are intelligent.
a • Some apples are sweet.
a
l •The expressive power of propositional logic is restricted.
•We can't explain propositions in propositional logic in terms of
L
o their qualities or logical relationships.
g
i
c 21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 106
Module 5: Logic Agents
L
o
g
i
c

A
g
e
n
t
s

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 107


Model 2: Logical Agents
L
Propositional Logic:
o
g • Deals with facts (true or false).
i
• Example: It is raining = True.
c
a • First-Order Logic (FOL):
l • - Extends propositional logic with quantifiers and relationships.
• - Example: For all x, if x is a bird, then x can fly (Bird(x) → Fly(x)).
A
g
e
n
t

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 108


Model 2: Logical Agents
L
Logical Foundations
o
g • Given Knowledge:
i • 1. If it rains, the grass will be wet.
c
• 2. It is raining.
a
l
• Formal Representation:
A • 1. Rain → WetGrass
g • 2. Rain
e
n
t • Inference:
• Using Modus Ponens:
• WetGrass is true.

21CS54, AI&ML - Bhaktavatsala Shivaram, Adjunct Faculty, CSE 109


Logical Inference Mechanisms
• 1. Modus Ponens: If A → B and A is true, then B is true.
• 2. Resolution: A method for automated theorem proving.
• 3. Forward Chaining: Derive conclusions from known facts.
• 4. Backward Chaining: Start with a goal and work backward to
determine necessary facts.
Challenges in Logical Agents
• - Computational Complexity: Inference can be slow in large KBs.
• - Incomplete Knowledge: Cannot make decisions with missing
information.
• - Non-monotonic Reasoning: Cannot retract conclusions easily.
Applications of Logical Agents
• - Expert systems (e.g., medical diagnosis).
• - Game playing (e.g., chess).
• - Natural language processing (NLP).
• - Automated planning and scheduling.
Conclusion
• - Logical agents use formal logic for knowledge representation and
inference.
• - Propositional and First-Order Logic are key tools.
• - Widely applicable but computationally intensive.

• Final Thought: Logical reasoning is fundamental to building intelligent


systems.

You might also like