5th Sem BCS515B - AI - Module3
5th Sem BCS515B - AI - Module3
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)
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
S
e
a
r
c
h
S
e
a
r
c
h
S
e
a
r
c
h
S
e
a
r
c
h
S
e
a
r
c
h
S
e
a
r
c
h
S
e
a
r
c
h
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.
City A City B
(Start) (Goal)
20 Km 215 Km
R2
A
g
e
n
g
t
s
A
g
e
n
t
s
A
g
e
n
t
s
• 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
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
A
g
e
n
t
• 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