Covers IGNOU MCS-212 §1.4.1, 1.4.2, E18–E20; programme guide: representing relations using matrices and digraphs
A relation such as “student s s s is enrolled in course c c c ” connects elements of one set with elements of another. To describe it precisely we first need pairs of elements where the order matters, and the set of all such pairs.
Ordered pairs and the Cartesian product
Definition 1.13 · Ordered pair and Cartesian product
An ordered pair ( x , y ) (x, y) ( x , y ) has a first element x x x and a second element y y y ; ( x , y ) = ( a , b ) (x, y) = (a, b) ( x , y ) = ( a , b ) if and only if x = a x = a x = a and y = b y = b y = b . The Cartesian product of A A A and B B B is A × B = { ( a , b ) ∣ a ∈ A , b ∈ B } A \times B = \{(a, b) \mid a \in A,\ b \in B\} A × B = {( a , b ) ∣ a ∈ A , b ∈ B } . More generally, A 1 × ⋯ × A n A_1 \times \dots \times A_n A 1 × ⋯ × A n is the set of n n n -tuples ( a 1 , … , a n ) (a_1, \dots, a_n) ( a 1 , … , a n ) with each a i ∈ A i a_i \in A_i a i ∈ A i .
If ∣ A ∣ = m |A| = m ∣ A ∣ = m and ∣ B ∣ = n |B| = n ∣ B ∣ = n , then ∣ A × B ∣ = m n |A \times B| = mn ∣ A × B ∣ = mn . Usually A × B ≠ B × A A \times B \neq B \times A A × B = B × A : { 1 } × { 2 } = { ( 1 , 2 ) } \{1\} \times \{2\} = \{(1, 2)\} { 1 } × { 2 } = {( 1 , 2 )} but { 2 } × { 1 } = { ( 2 , 1 ) } \{2\} \times \{1\} = \{(2, 1)\} { 2 } × { 1 } = {( 2 , 1 )} .
Geometrically, R × R \mathbb{R} \times \mathbb{R} R × R is the plane. { 2 } × R = { ( 2 , y ) } \{2\} \times \mathbb{R} = \{(2, y)\} { 2 } × R = {( 2 , y )} is the vertical line x = 2 x = 2 x = 2 , and R × { 2 } = { ( x , 2 ) } \mathbb{R} \times \{2\} = \{(x, 2)\} R × { 2 } = {( x , 2 )} is the horizontal line y = 2 y = 2 y = 2 . A database table with columns (name, city) is a subset of Names × \times × Cities.
Example 1.14 Computing a Cartesian product
Goal. For X = { a , b , c } X = \{a, b, c\} X = { a , b , c } and Y = { 1 , 2 } Y = \{1, 2\} Y = { 1 , 2 } , find X × Y X \times Y X × Y , X × X X \times X X × X and X × ∅ X \times \emptyset X × ∅ (compare E18).
Step. X × Y X \times Y X × Y : pair every element of X X X with every element of Y Y Y : { ( a , 1 ) , ( a , 2 ) , ( b , 1 ) , ( b , 2 ) , ( c , 1 ) , ( c , 2 ) } \{(a,1), (a,2), (b,1), (b,2), (c,1), (c,2)\} {( a , 1 ) , ( a , 2 ) , ( b , 1 ) , ( b , 2 ) , ( c , 1 ) , ( c , 2 )} — 3 × 2 = 6 3 \times 2 = 6 3 × 2 = 6 pairs.
Step. X × X X \times X X × X : { ( a , a ) , ( a , b ) , ( a , c ) , ( b , a ) , ( b , b ) , ( b , c ) , ( c , a ) , ( c , b ) , ( c , c ) } \{(a,a), (a,b), (a,c), (b,a), (b,b), (b,c), (c,a), (c,b), (c,c)\} {( a , a ) , ( a , b ) , ( a , c ) , ( b , a ) , ( b , b ) , ( b , c ) , ( c , a ) , ( c , b ) , ( c , c )} — 3 × 3 = 9 3 \times 3 = 9 3 × 3 = 9 pairs; note that ( a , b ) (a, b) ( a , b ) and ( b , a ) (b, a) ( b , a ) are both included.
Step. X × ∅ X \times \emptyset X × ∅ : there is no second element to choose, so it is ∅ \emptyset ∅ (3 × 0 = 0 3 \times 0 = 0 3 × 0 = 0 pairs).
Result. ∣ X × Y ∣ = 6 |X \times Y| = 6 ∣ X × Y ∣ = 6 , ∣ X × X ∣ = 9 |X \times X| = 9 ∣ X × X ∣ = 9 , X × ∅ = ∅ X \times \emptyset = \emptyset X × ∅ = ∅ .
Correction · Answers to E18(i), E19 and E20
Study material says: In §1.7, the answer to E18(i) lists X × X X \times X X × X for X = { a , b , c } X = \{a, b, c\} X = { a , b , c } with only 6 pairs; E19 says A × B = B × A A \times B = B \times A A × B = B × A “iff A = B A = B A = B ”; E20 says R × { 2 } \mathbb{R} \times \{2\} R × { 2 } is “the line parallel to Y axis”.
Correct version: X × X X \times X X × X has 3 × 3 = 9 3 \times 3 = 9 3 × 3 = 9 pairs; the pairs ( b , a ) (b, a) ( b , a ) , ( c , a ) (c, a) ( c , a ) , ( c , b ) (c, b) ( c , b ) are missing. A × B = B × A A \times B = B \times A A × B = B × A if and only if A = B A = B A = B or A = ∅ A = \emptyset A = ∅ or B = ∅ B = \emptyset B = ∅ . R × { 2 } = { ( x , 2 ) ∣ x ∈ R } \mathbb{R} \times \{2\} = \{(x, 2) \mid x \in \mathbb{R}\} R × { 2 } = {( x , 2 ) ∣ x ∈ R } is the line y = 2 y = 2 y = 2 , which is parallel to the X-axis.
Why: ∣ A × B ∣ = ∣ A ∣ ∣ B ∣ |A \times B| = |A|\,|B| ∣ A × B ∣ = ∣ A ∣ ∣ B ∣ , and ordered pairs with different order are different. If B = ∅ B = \emptyset B = ∅ , both A × B A \times B A × B and B × A B \times A B × A are ∅ \emptyset ∅ even when A ≠ B A \neq B A = B . In ( x , 2 ) (x, 2) ( x , 2 ) the second coordinate (height) is fixed, so the points form a horizontal line (the printed figure itself is labelled "y = 2 y = 2 y = 2 ").
Relations
Definition 1.15 · Relation
A relation from A A A to B B B is any subset R ⊆ A × B R \subseteq A \times B R ⊆ A × B . A relation on A A A is a subset of A × A A \times A A × A . We write a R b a \mathrel{R} b a R b when ( a , b ) ∈ R (a, b) \in R ( a , b ) ∈ R and say ”a a a is related to b b b ”.
For example, on A = { 1 , 2 , 3 , 4 } A = \{1, 2, 3, 4\} A = { 1 , 2 , 3 , 4 } the relation “divides” is R = { ( 1 , 1 ) , ( 1 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 2 ) , ( 2 , 4 ) , ( 3 , 3 ) , ( 4 , 4 ) } R = \{(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)\} R = {( 1 , 1 ) , ( 1 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 2 ) , ( 2 , 4 ) , ( 3 , 3 ) , ( 4 , 4 )} .
Theorem 1.16 · Number of relations
If ∣ A ∣ = m |A| = m ∣ A ∣ = m and ∣ B ∣ = n |B| = n ∣ B ∣ = n , there are 2 m n 2^{mn} 2 mn relations from A A A to B B B ; in particular there are 2 n 2 2^{n^2} 2 n 2 relations on an n n n -element set.
This holds because the relations are exactly the subsets of A × B A \times B A × B , a set with m n mn mn elements, so there are 2 m n 2^{mn} 2 mn of them (by the power-set theorem).
Representing a relation by a matrix or a digraph
Definition 1.17 · Relation matrix and digraph
For A = { a 1 , … , a m } A = \{a_1, \dots, a_m\} A = { a 1 , … , a m } and B = { b 1 , … , b n } B = \{b_1, \dots, b_n\} B = { b 1 , … , b n } , the matrix of R ⊆ A × B R \subseteq A \times B R ⊆ A × B is the m × n m \times n m × n zero–one matrix M R M_R M R with entry m i j = 1 m_{ij} = 1 m ij = 1 if ( a i , b j ) ∈ R (a_i, b_j) \in R ( a i , b j ) ∈ R and 0 0 0 otherwise. For a relation on a set A A A , the directed graph (digraph) has one vertex for each element and an arrow from a a a to b b b for each pair ( a , b ) ∈ R (a, b) \in R ( a , b ) ∈ R (an arrow from a a a to itself is a loop ).
Intuition
A relation matrix is like a seating chart for an exam: rows are students, columns are rooms, and a 1 marks “this student sits in this room”. A digraph is a map with one-way roads: an arrow from a a a to b b b means ”a a a is related to b b b ”.
Example 1.18 Matrix and digraph of the 'divides' relation
Goal. Represent ”a a a divides b b b ” on A = { 1 , 2 , 3 } A = \{1, 2, 3\} A = { 1 , 2 , 3 } as a set of pairs, a matrix and a digraph.
Step. Pairs: 1 1 1 divides 1 , 2 , 3 1, 2, 3 1 , 2 , 3 ; 2 2 2 divides 2 2 2 ; 3 3 3 divides 3 3 3 . So R = { ( 1 , 1 ) , ( 1 , 2 ) , ( 1 , 3 ) , ( 2 , 2 ) , ( 3 , 3 ) } R = \{(1,1), (1,2), (1,3), (2,2), (3,3)\} R = {( 1 , 1 ) , ( 1 , 2 ) , ( 1 , 3 ) , ( 2 , 2 ) , ( 3 , 3 )} .
Step. Matrix (rows and columns in the order 1, 2, 3):
M R = ( 1 1 1 0 1 0 0 0 1 ) M_R = \begin{pmatrix} 1 & 1 & 1 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} M R = 1 0 0 1 1 0 1 0 1
Step. Digraph:
Digraph of 'divides' on {1, 2, 3} Copy ↻ ↻
1 ─────────► 2
│
└──────────► 3 ↻
(↻ = loop: each number divides itself)
Result. R R R has 5 pairs; its matrix has five 1s; its digraph has three loops and arrows 1 → 2 1 \to 2 1 → 2 and 1 → 3 1 \to 3 1 → 3 .
Common mistake
Treating ordered pairs like sets. { 1 , 2 } = { 2 , 1 } \{1, 2\} = \{2, 1\} { 1 , 2 } = { 2 , 1 } , but ( 1 , 2 ) ≠ ( 2 , 1 ) (1, 2) \neq (2, 1) ( 1 , 2 ) = ( 2 , 1 ) . In A × A A \times A A × A both orders appear separately.
Common mistake
Mixing up the row and column of a relation matrix. Entry in row a a a , column b b b is 1 when ( a , b ) ∈ R (a, b) \in R ( a , b ) ∈ R — the first element picks the row.
Key idea
A relation from A A A to B B B is just a set of ordered pairs, i.e. a subset of A × B A \times B A × B ; it can equally be shown as a zero–one matrix or, for a relation on one set, as a directed graph.
TEE Exam note
Typical questions: “Find A × B A \times B A × B ”, “How many relations are there from A A A to B B B ?”, “Represent the relation … as a matrix and a digraph”. Answers: E18(ii) X × Y X \times Y X × Y has the 9 pairs ( x , y ) (x, y) ( x , y ) with x ∈ { a , b , c } x \in \{a, b, c\} x ∈ { a , b , c } , y ∈ { 1 , 2 , 3 } y \in \{1, 2, 3\} y ∈ { 1 , 2 , 3 } ; E18(iii) X × ∅ = ∅ X \times \emptyset = \emptyset X × ∅ = ∅ ; E19 and E20 as in the correction box.
Key takeaways
A × B A \times B A × B is the set of ordered pairs ( a , b ) (a, b) ( a , b ) ; ∣ A × B ∣ = ∣ A ∣ ∣ B ∣ |A \times B| = |A|\,|B| ∣ A × B ∣ = ∣ A ∣ ∣ B ∣ .
A × B = B × A A \times B = B \times A A × B = B × A only if A = B A = B A = B or one of them is empty.
A relation is a subset of A × B A \times B A × B ; there are 2 m n 2^{mn} 2 mn relations from an m m m -set to an n n n -set.
Relations can be shown as zero–one matrices and as digraphs.
Practice questions Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 1 · multiple choice If ∣ A ∣ = 3 |A| = 3 ∣ A ∣ = 3 and ∣ B ∣ = 4 |B| = 4 ∣ B ∣ = 4 , how many elements does A × B A \times B A × B have?
A 7 B 12 C 64 D 81
Check answer
Show answer Answer: B. 12
∣ A × B ∣ = 3 × 4 = 12 |A \times B| = 3 \times 4 = 12 ∣ A × B ∣ = 3 × 4 = 12 . Option 1 adds instead of multiplying.
Question 2 · multiple choice How many relations are there on a set with 3 elements?
A 8 B 9 C 64 D 512
Check answer
Show answer Answer: D. 512
A × A A \times A A × A has 3 2 = 9 3^2 = 9 3 2 = 9 pairs, so there are 2 9 = 512 2^9 = 512 2 9 = 512 relations. Option 2 counts the pairs, not the subsets.
Question 3 · multiple choice Which set is the horizontal line y = 2 y = 2 y = 2 in the plane?
Check answer
Show answer Answer: A. R × { 2 } \mathbb{R} \times \{2\} R × { 2 }
R × { 2 } = { ( x , 2 ) } \mathbb{R} \times \{2\} = \{(x, 2)\} R × { 2 } = {( x , 2 )} : any x x x , height 2. Option 2 is the vertical line x = 2 x = 2 x = 2 .
Question 4 · multiple choice Let A = { 1 , 2 } A = \{1, 2\} A = { 1 , 2 } and B = ∅ B = \emptyset B = ∅ . Which is true?
Check answer
Show answer Answer: C. A × B = B × A = ∅ A \times B = B \times A = \emptyset A × B = B × A = ∅
With no element in B B B , no pairs can be formed in either order. Option 2 is the usual case, but the empty set is the exception.
Question 5 · multiple choice In the matrix of a relation R R R on { 1 , 2 , 3 } \{1, 2, 3\} { 1 , 2 , 3 } (rows and columns in order 1, 2, 3), what does a 1 in row 3, column 1 mean?
Check answer
Show answer Answer: D. ( 3 , 1 ) ∈ R (3, 1) \in R ( 3 , 1 ) ∈ R
The row gives the first element and the column the second. Option 1 reverses the order.
Question 6 · short answer
Let A = { 1 , 2 , 3 , 4 } A = \{1, 2, 3, 4\} A = { 1 , 2 , 3 , 4 } and R = { ( a , b ) ∣ a < b } R = \{(a, b) \mid a < b\} R = {( a , b ) ∣ a < b } on A A A . List R R R and write its matrix.
Show worked answer R = { ( 1 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 4 ) } R = \{(1,2), (1,3), (1,4), (2,3), (2,4), (3,4)\} R = {( 1 , 2 ) , ( 1 , 3 ) , ( 1 , 4 ) , ( 2 , 3 ) , ( 2 , 4 ) , ( 3 , 4 )} (6 pairs). Matrix with rows and columns in order 1, 2, 3, 4: row 1: 0 1 1 1; row 2: 0 0 1 1; row 3: 0 0 0 1; row 4: 0 0 0 0. All 1s lie above the main diagonal, because a < b a < b a < b .