Course Name: Foundations of AI Algorithms
Course Code: 25CAI0102
Course Credits: 3
Program: BE CSE – AIML
Semester: II
Dr. Tanvi Sood
Today’s Topics
• Introduction to Crisp relations
• Composition of classical relations
• Introduction to Fuzzy relations
RELATIONS
1. Classical binary relation:
Presence/Absence of connection/association/interaction between
the elements of 2 sets.
2. Fuzzy relation:
Allows degree of association
• Ordered r-tuple: An ordered sequence of r elements; (𝑎1 , 𝑎2 , 𝑎3 , … , 𝑎𝑟 )
• Unordered r-tuple: Collection of r elements without restrictions on
order.
Classical/ Crisp Relations
The set of all r-tuples 𝑎1 , 𝑎2 , 𝑎3 , … , 𝑎𝑟 is called Cartesian product of
(𝐴1 , 𝐴2 , 𝐴3 , … , 𝐴𝑟 ) and is denoted by (𝐴1 × 𝐴2 × 𝐴3 × ⋯ × 𝐴𝑟 )
Here 𝑎1 ∈ 𝐴1, 𝑎2 ∈ 𝐴2, 𝑎3 ∈ 𝐴3, … , 𝑎𝑟 ∈ 𝐴𝑟
Cartesian product is not same as arithmetic product.
• An r-ary relation over (𝐴1 , 𝐴2 , 𝐴3 , … , 𝐴𝑟 ) is a subset of Cartesian product.
When r = 2, the cartesian product is 𝐴1 × 𝐴2 which is a binary
relation.
When r = 3, the cartesian product is (𝐴1 × 𝐴2 × 𝐴3 ) which is a ternary
relation.
When r = 4, the cartesian product is (𝐴1 × 𝐴2 × 𝐴3 × 𝐴4 ) which is a
quaternary relation.
Classical/ Crisp Relations
Eg: A={ 0,1}
B= {a,b,c}
𝐴 × 𝐵 = {(0,a),(0,b),(0,c),(1,a),(1,b),(1,c)}
𝐴1 × 𝐴2 = { 𝑎1 , 𝑎2 , 𝑎3 , 𝑎4 , 𝑎5 , 𝑎6 }
The Cartesian product of two universes X and Y is determined as X × Y =
{(x, y) | x ∈ X, y ∈ Y} which forms an ordered pair of every x ∈ X with
every y ∈ Y.
That is, every element in universe X is related completely to every element
in universe Y.
Classical/ Crisp Relations
The strength of this relationship between ordered pairs of elements
in each universe is measured by the characteristic function, denoted
by 𝜒.
𝜒 is 1 in case of complete relationship and,
𝜒 is 0 in case of no relationship.
1 , 𝑖𝑓 (𝑎, 𝑏) ∈ 𝐴 × 𝐵
𝜒𝐴×𝐵 =
0 , 𝑖𝑓 (𝑎, 𝑏) ∉ 𝐴 × 𝐵
Classical/ Crisp Relations
Eg: 𝐴 = { 1,2,3} 𝐵 = {𝑎, 𝑏, 𝑐}
Cartesian Product:
A×B={ 1,a , 1,b , 1,c , 2,a , 2,b , 2,c , 3,a , 3,b ,(3,c)}
Relation:
R={ 1,a , 1,b , 1,c , 2,a , 2,b , 2,c , 3,a , 3,b ,(3,c)}
Relation Matrix:
1 1 1
𝑥
𝑅= 1 1 1
1
1 1 1
2
3
Relation:
R={ 1,a , 2,b , 2,c ,(3,c)}
Relation Matrix:
1 0 0
𝑅= 0 1 1
0 0 1
Constrained Binary
Relation, R ⊆ A x B
𝑦
a
b
c
Example
Consider 2 crisp sets A & B as given below:
A={1,2,3,4} B={3,5,7}
Find 𝐴 × 𝐵
𝐴 × 𝐵 is a cartesian product that gives collection of order pairs.
∴ A×B={ 1,3 , 1,5 , 1,7 , 2,3 , 2,5 , 2,7 , 3,3 , 3,5 , 3,7 ,
4,3 , 4,5 , 4,7 }
Say a relation exists between A & B, such that,
𝑅 = {(𝑎, 𝑏)|𝑏 = 𝑎 + 1, (𝑎, 𝑏) ∈ 𝐴 × 𝐵}
R={(2,3),(4,5)}
Representing R in the form of matrix:
3
5
7
0
𝑅= 1
0
0
0
0
0
1
0 1
0 2
0 3
0 4
Identity Relation and Universal Relation
Special cases of the constrained and the unconstrained Cartesian product for sets where
r = 2 (i.e., for A2) are called the identity relation and the universal relation.
Eg: A={ 1,2,3}
B= {a,b,c}
Universal Relation: UA= {(1,a), (1,b), (1,c), (2,a), (2,b), (2,c), (3,a), (3,b), (3,c)}
(Unconstrained)
1 1 1
𝑅= 1 1 1
1 1 1
Identity Relation: IA= {(1,a), (2,b), (3,c)}
(Constrained)
1 0 0
𝑅= 0 1 0
0 0 1
Composition of classical relations
• Let R be a relation that relates elements from universe X to universe Y, and S from
universe Y to universe Z. Thereafter, operation executed to get a single binary relation
is known as composition, 𝑻 = 𝑹 ∘ 𝑺.
– R = {(x1, y1), (x1, y3), (x2, y4)} ⇒ 𝑅 ⊆ 𝑋 × 𝑌
– S = {(y1, z2), (y3, z2)} ⇒ 𝑆 ⊆ 𝑌 × 𝑍
y1
– 𝑅 ∘ 𝑆 = {(x1,z2)}
x1
z2
y3
x2
y4
• There are two ways of performing composition:
1. Max – min composition:
𝜒𝑇(𝑥, 𝑧) = 𝑉(𝜒𝑅(𝑥, 𝑦) ∧ 𝜒𝑆 (𝑦, 𝑧))
𝜒𝑇(𝑥, 𝑧) = 𝑚𝑎𝑥(𝜒𝑅 𝑥, 𝑦 𝑚𝑖𝑛 𝜒𝑆 (𝑦, 𝑧))
2. Max – product (or max – dot) composition:
𝜒𝑇(𝑥, 𝑦) = 𝑉(𝜒𝑅 (𝑥, 𝑦) ⋅ 𝜒𝑆 (𝑦, 𝑧))
𝜒𝑇(𝑥, 𝑦) = 𝑚𝑎𝑥(𝜒𝑅 𝑥, 𝑦 𝑑𝑜𝑡 𝜒𝑆 (𝑦, 𝑧))
Example
Given X={1,3,5} and Y={1,3,5}
𝑅 = {(𝑥, 𝑦)|𝑦 = 𝑥 + 2};
𝑆 = {(𝑥, 𝑦)|𝑥 < 𝑦}
Find 𝑅 ∘ 𝑆 using max-min composition.
R = 𝑋 × 𝑌 = {(1,3), (3,5)}
S = 𝑋 × 𝑌 = {(1,3), (1,5), (3,5)}
0 1
𝑅= 0 0
0 0
0
1
0
0 1
𝑆= 0 0
0 0
1
1
0
Using max-min composition,
max(min 0,0 , min 1,0 , min(0,0)) 1 1
𝑅∘𝑆 =
0
0 1
0
0 0
Example
Using max-min composition,
𝑅∘𝑆
max(min 0,0 , min 1,0 , min(0,0))
=
0
0
0 𝑚𝑎𝑥(min 0,1 , min 1,1 , min(0,0))
0
0
0
0
max(0,0, 0) 0
=
0
0
0
0
0 0
= 0 0
0 0
𝑚𝑎𝑥(0,1, 0)
0
0
1
0
0
Fuzzy Relations
• X – Universe of discourse
• Y – Universe of discourse
• Elements of X are
related to
elements of Y.
This relation is achieved
via Cartesian Product.
• Fuzzy Relation maps X and Y through cartesian product
• Strength of relation is measured with membership function
• fuzzy relation is a mapping from the Cartesian space X × Y to
the interval [0,1].
Fuzzy Matrix
Let 𝑋 = {𝑥1 , 𝑥2 , 𝑥3 , … … , 𝑥𝑛 }
Let 𝑌 = {𝑦1 , 𝑦2 , 𝑦3 , … … , 𝑦𝑚 }
The relation R(X,Y) is represented as fuzzy matrix
µR(x1,y1)
µR(x2,y1)
R(X,Y) =
µR(xn,y1)
µR(x1,y2) … … µR(x1,ym)
µR(x2,y2) … … µR(x2,ym)
.
.
.
µR(xn,y2) … … µR(xn,ym)
Fuzzy Matrix
µR(x1,y1)
µR(x2,y1)
R(X,Y) =
µR(xn,y1)
µR(x1,y2) … … µR(x1,ym)
µR(x2,y2) … … µR(x2,ym)
.
.
.
µR(xn,y2) … … µR(xn,ym)
DOMAIN:
Set of all possible x-values
RANGE:
Set of all possible y-values
Example 1
2 crisp sets as below:
𝑋1 = {typhoid, viral, cold}
𝑋2 = {running nose, high temp, shivering}
Fuzzy relation is defined as
Fuzzy
relation
between 2
crisp sets
𝑅=
Running
nose
High
Temp.
Shivering
0.1
0.2
0.9
0.9
0.9
0.4
0.8
0.7
0.6
Typhoid
Viral
Cold
Example 2
A = {(𝑎1 , 0.2), (𝑎2 , 0.7), (𝑎3 , 0.4)}
B = {(𝑏1 , 0.5), (𝑏2 , 0.6)}
Find the relation between A & B using max-min composition.
Fuzzy
relation
between 2
fuzzy sets
0.2 0.2
𝐴 × 𝐵 = 0.5 0.6
0.4 0.4