0% found this document useful (0 votes)
17 views59 pages

CH 2 - Fundamental Structures

The document provides an overview of fundamental set theory concepts including sets, subsets, unions, intersections, complements and identities. It defines these concepts and provides examples to illustrate them. The document is intended to introduce students to the basics of set theory.

Uploaded by

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

CH 2 - Fundamental Structures

The document provides an overview of fundamental set theory concepts including sets, subsets, unions, intersections, complements and identities. It defines these concepts and provides examples to illustrate them. The document is intended to introduce students to the basics of set theory.

Uploaded by

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

CS104 : Discrete Structures

Chapter II
Fundamental Structures

Dr. Arfan Jaffar


Department of Computer Science

09/03/23 Prepared by Dr. Zakir H. Ahmed 1


Set Theory

09/03/23 Prepared by Dr. Zakir H. Ahmed 2


Set Theory - Set

Set: A set is an unordered collection of well-defined


objects. The objects in a set are also called the
elements or members of the set. A set is said to
contain its elements
Some examples:
• A={1, 2, 3} is the set containing “1” and “2” and
“3”. So, 1, 2, 3  A, but 5  A.
• {1, 1, 2, 3, 3} = {1, 2, 3}, since repetition is
irrelevant.
• {1, 2, 3} = {3, 2, 1}, since sets are unordered.
• V={a, e, i, o, u} is the set of all vowels in English
alphabet

09/03/23 Prepared by Dr. Zakir H. Ahmed 3


Set Theory - Set
Note:   {}
Some more examples:
  = {} is the empty set, or the set containing no
elements.
• B = {b} is the singleton set, or the set
containing only one element.
• N = {1, 2, 3, …} is a way we denote an infinite
set, set of natural numbers
• Z = {….., -2, -1, 0, 1, 2, …….} is the set of
integers
• Q = {p/q | pZ, qZ, q≠0} is the set of rational
numbers
• R = Q U Qc, set of real numbers
• C = {a + ib | a, b  R, i = √-1}, set of complex
numbers
09/03/23 Prepared by Dr. Zakir H. Ahmed 4
Set Theory – Subset and Superset

Subset: The set A is said to be a subset of the set B


if and only if every element of A is also an element
of B, and B is said to be superset of A.

A  B means “A is a subset of B.” Venn Diagram


or, “B contains A.”
or, “every element of A is also in B.”
or, x ((x  A) => (x  B)). A
and B  A means “B is a superset of A.”
Example: Let A = {a, b, c} B
B = {a, b, c, d},
C = { a, c, d, e}
then A  B and B  A, but A is not subset of C.
09/03/23 Prepared by Dr. Zakir H. Ahmed 5
Set Theory – Equal sets

Equal sets: Two sets A = B if and only if A and B have


exactly the same elements.
A = B iff, A  B and B  A
iff, x ((x  A) <=> (x  B)).
Example: If A = {a, b, c, d} and B = {a, b, c, d} , then
AB and BA, so A = B.
Note: For any set S,
(i) Ø  S and (ii) S  S

09/03/23 Prepared by Dr. Zakir H. Ahmed 6


Set Theory – Proper subset

Proper subset: A  B means “A is a proper subset of


B”, i.e., A  B, and A  B.
Examples:
• {1, 2, 3}  {1, 2, 3, 4, 5}
• {1, 2, 3}  {1, 2, 3, 4, 5}
Questions:
• Is   {1, 2, 3}?
• Is {x}  {x}?
• Is {x}  {x}?
• Is {x}  {x, {x}}?
• Is {x}  {x, {x}}?
09/03/23 Prepared by Dr. Zakir H. Ahmed 7
Set Theory - Power set

Power set: If S is a set, then the power set of S is


the set of all subsets of the set S. The power set
of S is denoted by P(S). i.e., P(S) = { x | x  S }.
Examples:
• If S={a}, then P(S)={, {a}}.
• If S = {a, b}, then P(S)={, {a}, {b}, {a, b}}.
Questions:
• If S = , then P(S)=?
• If S = {,{}}, then P(S)=?
Fact: If S is finite, |P(S)| = 2|S|. (if |S|=n, |P(S)|=2n)

09/03/23 Prepared by Dr. Zakir H. Ahmed 8


Set Theory - Cartesian Product

Cartesian Product: Let A and B be two sets. The


Cartesian Product of A and B, denoted by AXB, is
the set of all ordered pairs (a, b), where a  A and b
 B. i.e.,
A x B = { (a, b) | a  A and b  B}
Examples:
• If A={1, 2}, B={a, b, c} then AXB={(1, a), (1, b), (1,
c), (2, a), (2, b), (2, c)}
Questions:
• If A and B be two finite sets, the |AXB|=?
• |A|+|B|, |A+B|, or |A||B|
Facts: AXB ≠ BXA
• A1 x A2 x … x An = {(a1, a2,…, an) | ai  Ai, for i=1, 2,
…, n}
09/03/23 Prepared by Dr. Zakir H. Ahmed 9
Set Theory – Union and Intersection

Union: The union of two sets A and B, denoted by AB,


is the set that contains those elements that are
either in A or in B, or in both:
A= {1, 2, 3} b= {1, 4, 5} A U b = { 1, 2, 3, 4,5}
A  B = { x | x  A or x  B}
Intersection: The intersection of two sets A and B,
denoted by AB, is the set containing those
elements in both A and B:
A  B = { x | x  A and x  B}
B A B A

09/03/23 Prepared by Dr. Zakir H. Ahmed 10


Set Theory – Union and Intersection

Example: If A={1, 2, 3}, B={1, 3, 5} then A  B ={1, 2, 3,


5} and AB={1, 3}
Questions: If A = {x : x is a CS major student}, and B =
{x : x is a MS major student}, then AB and AB=?
• If A = {x : x is a US president}, and B = {x : x is
deceased}, then AB=?
• If A = {x : x is a US president}, and B = {x : x is in
this room}, then AB=?
Generalized Unions and Intersections:
n
n

A  A  A i 1 2    An A  A  A
i 1 2    An

i1 
i1

09/03/23 Prepared by Dr. Zakir H. Ahmed 11

 
Set Theory – Disjoint Set

Disjoint sets: Two sets are said to be disjoint if their


intersection is the empty set.
Examples:
• If A = {1, 3, 5, 7, 9}, and B = {2, 4, 6, 8, 10}, then
AB=Ø
• If A = {x | x is a CS major student} and B = {x | x
is a PS major student}, then AB=Ø
Questions:
• Give some examples of two sets A and B such that
AB=Ø

09/03/23 Prepared by Dr. Zakir H. Ahmed 12


Set Theory – Difference of sets

Difference: The difference of two sets A and B,


denoted by A-B, is the set containing those elements
that are in A but not in B: A – B = { x | xA and xB}
Examples:
• If A = {1, 3, 5}, and B = {1, 2, 3}, then A-B = {5},
and B-A = {2}. So, A-B  B-A.

A
B

09/03/23 Prepared by Dr. Zakir H. Ahmed 13


Set Theory - Complement

Complement: Let U be the universal set. The


complement of the set A, denoted by Ac or Ā, is set
containing those elements that are not in A:
Ac = { x | x  A}
Examples:
• If U={1, 2, …, 10}, A={1, 3, 5, 7, 9}, then Ac={2, 4, 6,
8, 10}.
• If A = {x : x is bored}, then Ac = {x : x is not
bored} U
Facts: A

• Uc = Ø and Øc = U
• A - B = A  Bc
09/03/23 Prepared by Dr. Zakir H. Ahmed 14
Set Theory – Set Identities

Prove the following law using Membership table:


A  (B  C) = (A  B)  (A  C)
Proof:
A B C BC A  (B  C) AB AC (A  B)  (A  C)
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
09/03/23 Prepared by Dr. Zakir H. Ahmed 15
Set Theory – Set Identities

Prove the following law using Venn diagram:


A  (B  C) = (A  B)  (A  C)
Proof:
U U
A B A B

C C

A  (B  C) (A  B)  (A  C)

09/03/23 Prepared by Dr. Zakir H. Ahmed 16


Set Theory - Famous Identities

Identities Name
AU=A
Identity laws
AU=A
AUU=U
Domination laws
A=
AUA=A
Idempotent laws
AA=A
(Ac)c = A Complementation law
AUB=BUA
Commutative laws
AB=BA
A U (B U C) = (A U B) U C
Associative laws
A  (B  C) = (A  B)  C

09/03/23 Prepared by Dr. Zakir H. Ahmed 17


Set Theory - Famous Identities

Identities Name
A U (B  C) = (A U B)  (A U C)
Distributive laws
A  (B U C) = (A  B) U (A U C)
(A U B)c = Ac  Bc
De Morgan’s laws
(A  B)c = Ac U Bc
A U (A  B) = A
Absorption laws
A  (A U B) = A
A U Ac = U
Complement laws
A  Ac = 

Question:
Prove the above identities by using Venn diagram
and Membership tables ??
09/03/23 Prepared by Dr. Zakir H. Ahmed 18
Cardinality of a set

Cardinality of a set: Let S be a set. If there are


exactly n distinct elements in S, where n is a non-
negative integer, we say that S is a finite set and
that n is the cardinality of S. The cardinality of S is
denoted by |S|.
Example:
Let A be the set of English alphabets, then |A|=26.
Questions:
• |Ø|=?
• If B={1, 1, 1}, then |B|=?
• If S = { , {}, {,{}} }, then |S|=?
09/03/23 Prepared by Dr. Zakir H. Ahmed 19
Set Theory – Inclusion-exclusion

Inclusion-exclusion theory: We are interested in finding


cardinality of the union sets.
Question Example:
|A| = How many people are wearing a watch?
|B| = How many people are wearing jackets?
|A  B| = How many people are wearing a watch OR
jackets?
Answer:

B A Wrong or right?

09/03/23 Prepared by Dr. Zakir H. Ahmed 20


Set Theory – Inclusion-exclusion

Answer:
• Note that |A|+|B| counts each element that is in
A but not in B, or in B not in A, exactly once.
• Each element that is in both A and B will be
counted twice
• So, elements in A  B will be subtracted the
result, i.e.,
|A  B| = |A| + |B| - |A  B|
Question: Generalize the formula for 3 sets

09/03/23 Prepared by Dr. Zakir H. Ahmed 21


Set Theory – Inclusion-exclusion

Example:
There are 150 CS majors CS530
100 are taking CS530 CS520
70 are taking CS520
30 are taking both

Question:
How many are taking neither?

Answer:
150 – (100 + 70 - 30) = 10

09/03/23 Prepared by Dr. Zakir H. Ahmed 22


Set Theory – Computer representation

• Let U be a finite universal set. Let a1, a2,…, an be an arbitrary ordering


of the elements of U.
• Represent a subset A of U with the bit string of length n, where

th 1 if ai  A
i bit  
0 if ai  A
Examples:
• Let U={1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and
• Then the set A={1, 3, 5, 7, 9} can be represented by
the string of bits: 10 1010 1010
• The set B={1, 2, 4, 9} can be represented as:
11 0100 0010
09/03/23 Prepared by Dr. Zakir H. Ahmed 23

0001 0010 0100 1001


Set Theory – Computer representation

Examples:
• A: 10 1010
1010
• B: 11 0100
0010
• The set A U B can be represented as: 11 1110 1010
• The set A  B can be represented as:10 0000 0010
Questions:
• If C={1, 6, 8, 10}, express following sets with bit
strings
A-B, Ac, A U (B  C) and A  (B U C)
09/03/23 Prepared by Dr. Zakir H. Ahmed 24
Functions

09/03/23 Prepared by Dr. Zakir H. Ahmed 25


Functions – Definition

Definition: Let A and B be two


sets. A function f : A  B is
f(a)
an assignment of exactly one a b=f(a)
element of B to each element
of A. We write f(a)=b if b is B
A
the unique element of B
assigned by the function f to f
the element a of A.
Example 1: Hussain
Let A = {Hussain, Muhammad, Amina
Hassan, Eisa} Muhammad Fatima
B = {Amina, Fatima, Khadiza, Hassan Khadiza
Mariyam}
Eisa Mariyam
Also, let f: A  B be defined as
f(a) = mother(a). A
B

09/03/23 Prepared by Dr. Zakir H. Ahmed 26


Functions - Examples

Example 2: Let S={Ahmed, Hussain, Muhammad, Musa,


Badr} be a set of students enrolled in CS100 course.
Each student is assigned a letter grade from the set
G={A,B,C,D,F} as follows:

Ahmed A Functions are


Hussain B
Muhammad C sometimes called
Musa D mappings or
Badr F transformations

This assignment is an example of a function.


Questions: Give some examples of functions?

09/03/23 Prepared by Dr. Zakir H. Ahmed 27


Functions – Examples

Example 3: Suppose we have


following graph:
And I ask you to
describe the red
function.
What’s the function?

Notation: f: RR,
codomain f(x) = -(1/2)x - 25
domain
f(x) = -(1/2)x - 25

09/03/23 Prepared by Dr. Zakir H. Ahmed 28


Functions – Image and Preimage

Definition: If the function f : A  B, then A is the


domain and B is the codomain of f. If f(a)=b, we say
that b is the image of a and a is a preimage of b. The
range of f is the set of all images of elements of A.
Also, if f is a function from A to B, we say that f
maps A to B.
Example 4: - image({Hussain, Hassan}) = {Fatima}
image(A) = B – {Khadiza}, range of f is the set
{Amina, Fatima, Mariyam}

Hussain Amina
Muhammad Fatima
Hassan Khadiza
Eisa Mariyam
09/03/23 Prepared by Dr. Zakir H. Ahmed 29
A B
Functions – Image and Pre-image

Example 5: - preimage({Fatima}) = {Hussain, Hassan}


preimage (B) = A
For any set P  A, image(P) = {b : a  P, f(a) = b}
For any Q  B, preimage(Q) = {a: b  Q, f(a) = b}
image(P) = f(P) pre-image(Q) = f-1(Q)

Hussain Amina
Muhammad Fatima
Hassan Khadiza

Eisa Mariyam

09/03/23 Prepared by Dr. Zakir H. Ahmed 30


A B
Functions – Image and Pre-image

Example 6: - Let f be the function that assigns the last


two bits of a bit string of length 2 or greater to that
string. For example, f(11010) = 10. then, the domain of
f is the set of all bits of length 2 or greater, and
both the codomain and range are the set {00, 01, 10,
11}.
Example 7: - The domain and codomain of functions are
specified in programming languages. E.g.,
the Java statement: int floor (float real) { ….. }, and
Pascal statement function floor (x: real): integer
state that the domain of floor function is the set of
real numbers, and codomain is set of the integers.
09/03/23 Prepared by Dr. Zakir H. Ahmed 31
Functions – On Real Number

Definition: Let f1 and f2 be two functions from A to R. Then


f1+f2 and f1f2 are also functions from A to R defined by
(f1+f2)(x) = f1(x) + f2(x),
(f1f2)(x) = f1(x)f2(x).
Example 8: Let f1 and f2 be two functions from R to R such
that f1(x) = x2 and f2(x) = x – x2. What are the functions
f1+f2, f1f2?
Solution: From the definitions,
(f1+f2)(x) = f1(x) + f2(x) = x2 + (x – x2) = x,
(f1f2)(x) = f1(x)f2(x) = x2(x – x2) = x3 – x4.

09/03/23 Prepared by Dr. Zakir H. Ahmed 32


Functions – Injection and Surjection

Injection: A function f from the set A to the set B is


said to be one-one (injective, an injection), if and
only if f(a) = f(b) implies that a = b for all a and b in
the domain of f. Every x  B has at most 1 preimage.
Surjection: A function f from A to B is said to be onto
(surjective, an surjection), if and only every element
b  B, there is an element a  A with f(a) = b. Every
b  B has at least 1 preimage.
Neither injection
Amina nor surjection
Hussain
Muhammad Fatima
Hassan Khadiza
Eisa Mariyam
09/03/23 A Prepared by Dr. Zakir H. Ahmed B 33
Functions – Bijection

Bijection: A function f from the set A to the set B is


said to be one-to-one correspondence (bijective, an
bijection), if it is both injection and surjection. Every
b  B has exactly 1 preimage.

Muhammad Amina
Hassan Fatima
Eisa Mariyam

A B
An important implication of this characteristic:
The preimage (f-1) is a function!

09/03/23 Prepared by Dr. Zakir H. Ahmed 34


Functions – Examples

Example 9: Determine whether the function f: {a, b, c,


d}  {1, 2, 3, 4, 5} with f(a) = 4, f(b) = 5, f(c) = 1,
and f(d) = 3 is injective.

Example 10: Determine whether the function f: Z  Z,


f(x) = x2 is injective.

Example 11: Determine whether the function f: {a, b, c,


d}  {1, 2, 3} with f(a) = 3, f(b) = 2, f(c) = 1, and f(d)
= 3 is surjective.

09/03/23 Prepared by Dr. Zakir H. Ahmed 35


Functions – Examples

Example 12: Determine whether the function f: Z  Z,


f(x) = x2 is surjective.
Sol: The function f is not onto since, for instance,
there is no integer x with x2 = -1.
Example 13: Determine whether the function f: {a, b,
c, d}  {1, 2, 3, 4} with f(a) = 4, f(b) = 2, f(c) = 1,
and f(d) = 3 is bijective.
Sol: The function f is one-to-one since no two values in
the domain are assigned the same function value. It
is also onto because all four elements of the
codomain are images of elements in the domain.
Hence, f is a bijection.
09/03/23 Prepared by Dr. Zakir H. Ahmed 36
Functions – Examples

:Example 14

09/03/23 Prepared by Dr. Zakir H. Ahmed 37


Functions – Questions [Assignment Due
24-11 – Hard Copy in Class]
Q1. Suppose f: R+  R+,
f(x) = x2.
Is f one-to-one?
Is f onto?
Is f bijective?

Q2. Suppose f: R  R+,


f(x) = x2.
Is f one-to-one?
Is f onto?
Is f bijective?
09/03/23 Prepared by Dr. Zakir H. Ahmed 38
Functions – Questions

Q3. Suppose f: R  R,
f(x) = x2.
Is f one-to-one?
Is f onto?
Is f bijective?
Q4. Let f be a function
from {a, b, c, d} to
{1, 2, 3, 4} with f(a)=4,
f(a)=3, f(b)=2, f(c)=1
and f(d)=3.
Is f one-to-one?
Is f onto?
Is f bijective?

09/03/23 Prepared by Dr. Zakir H. Ahmed 39


Functions – Inverse Functions

Definition: Let f be an one-to-one correspondence


from the set A to the set B. The inverse function of
f is the function that assigns to an element b є B the
unique element a є A such that f(a) = b. The inverse
function of f is denoted by f-1. Hence, f-1(b) = a when
f(a) = b.
A one-to-one correspondence is called invertible, since
we can define an inverse of this function.
A function is not invertible, if it is not one-to-one
correspondence f-1(b)
a=f-1(b) . . b=f(a)
f(a)
f-1

A f B
09/03/23 Prepared by Dr. Zakir H. Ahmed 40
Functions – Examples

Example 15: Find out whether the function f: {a, b, c}


 {1, 2, 3} with f(a) = 2, f(b) = 3, and f(c) = 1 is
invertible. And if yes, what is its inverse?
Sol: The function f is invertible, since it is bijective.
The inverse function f-1 reverses the
correspondence given by f, so f-1(1) = c, f-1(2) = a,
and f-1(3) = b
Example 16: Determine whether the function f: R  R,
with f(x) = x2 is invertible.
Sol: The function f is not one-to-one, since for
instance, f(-2) = f(2) = 4, but 2 ≠ -2.

Q5: find out whether the function f: Z  Z, with f(x)


= x+1 is invertible. And if yes, what is its inverse?
09/03/23 Prepared by Dr. Zakir H. Ahmed 41
Functions – Compositions of Functions

Definition: - Let g:AB, and f:BC be functions. Then


the composition of f and g, denoted by f o g, is
defined by (f o g)(x) = f(g(x))
Note that the composition f o g can not be defined
unless the range of g is a subset of the domain of f.

(f o g)(a)
. g(a) . f(g(a)) .
a g(a) f(g(a))
g f
A B C
fog
09/03/23 Prepared by Dr. Zakir H. Ahmed 42
Functions – Examples

Example 17: Let g:{a, b, c}{a, b, c} with g(a)=b, g(b)=c,


g(c)=a. Also, let f:{a, b, c}{1, 2, 3} with f(a)=3,
f(b)=2, f(c)=1. What are the compositions of f and g,
i.e., (f o g), and g and f, i.e., (g o f)?
Sol: The composition f o g, is defined by
(f o g)(a) = f(g(a)) = f(b) = 2,
(f o g)(b) = f(g(b)) = f(c) = 1, and
(f o g)(c) = f(g(c)) = f(a) = 3.
Note that g o f is not defined, because the range of
f is not subset of the domain of g.

Q6: Let g:{a, b, c}{a, b, c} with g(a)=a, g(b)=b, g(c)=c.


Also, let f:{a, b, c}{1, 2, 3} with f(a)=1, f(b)=2,
f(c)=3. What are the compositions (f o g) & (g o f)?
09/03/23 Prepared by Dr. Zakir H. Ahmed 43
Functions – Examples

Example 18: Let f:ZZ with f(x) = 2x+3, and g:ZZ


with g(x) = 3x+2. What are the compositions (f o g)
and (g o f)?
Sol: Both compositions (f o g) and (g o f) are defined.
(f o g)(x) = f(g(x)) = f(3x+2) = 2(3x+2)+3 = 6x+7, and
(g o f)(x) = g(f(x)) = g(2x+3) = 3(2x+3)+2 = 6x+11.

Definition: Let A and B be two sets and f: AB be a


function. The graph of the function f is the set of
ordered pairs
{(a, b) | , a  A and f(a) = b}.

Note: The graph of f:AB is a subset of AXB.

09/03/23 Prepared by Dr. Zakir H. Ahmed 44


Functions – Examples

:Example 19

Graph of f(n)=2n+1 from Z to Z Graph of f(n)=n2 from Z to Z

09/03/23 Prepared by Dr. Zakir H. Ahmed 45


Functions – Properties

Some properties:
• f(Ø) = Ø
• f({a}) = {f(a)}
• f(A U B) = f(A) U f(B)
• f(A  B)  f(A)  f(B)
• f-1-1() =  -1
• f-1(A U B) = f-1(A) U f-1-1(B)
• f (A  B) = f (A)  f (B)

09/03/23 Prepared by Dr. Zakir H. Ahmed 46


Functions – Familiar functions

Polynomials: f(x) = a0xn + a1xn-1 + … + an-1x1 + anx0


Example: f(x) = x3 - 2x2 + 15
Exponentials: f(x) = cdx
Example: f(x) = 310x, f(x) = ex
Logarithms: log2 x = y, where 2y = x.
Ceiling: f(x) = x the least integer y so that x  y.
Example: 1.2 = 2; -1.2 = -1; 1 = 1
Floor: f(x) = x the greatest integer y so that x  y.
Example: 1.8 = 1; -1.8 = -2; -5 = -5
Question: what is -1.2 + 1.1 ?
09/03/23 Prepared by Dr. Zakir H. Ahmed 47
Relations

09/03/23 Prepared by Dr. Zakir H. Ahmed 48


Relations – Definition

Relation: Let A and B be two sets. A binary relation (R)


from A to B is a subset of A x B, i.e., R  AxB.
Example 1: Let A = Set of students; B = Set of courses.
R = {(a,b) | student a is enrolled in course b}
Example 2: Let A = Set of cities; B = Set of countries.
Define the relation R by specifying that (a, b)
belongs to R if city a is the capital of b. For
instance, (Riyadh, Saudi Arabia), (Delhi, India),
(Washington, USA) are in R.
Example 3: Let A={0, 1, 2} and B={a, b}. {(0, a), (0, b), (1,
a), (2, b)} is a relation from A to B. This means, 0Ra,
but 1Rb.

09/03/23 Prepared by Dr. Zakir H. Ahmed 49


Relations – On a Set

Relation: A relation on the set A is a relation from A to A.


That is, a relation on a set A is a subset of A x A.
Example 4: Let A = {1, 2, 3, 4}. Which ordered pairs are in
the relation R={(a, b) | a divides b}?
Sol: (a, b)єR iff. a and b are positive integers not
exceeding 4 such that a divides b, we see that
R={(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}
The pairs in R are displayed graphically and in tabular
form:
1. .1 R 1 2 3 4
1 X X X X
2. .2
2 X X
3. .3 3 X
4. .4 4 X
09/03/23 Prepared by Dr. Zakir H. Ahmed 50
Relations – Examples

Example 5: Consider the relations on the set of integers:


R1= {(a, b) | a ≤ b},
R2={(a, b) | a > b},
R3={(a, b) | a = b or a = -b},
R4={(a, b) | a = b},
R5={(a, b) | a = b+1},
R6={(a, b) | a+b ≤ 3},
Which of these relations contain each of the pairs (1, 1),
(1, 2), (2, 1), (1, -1) and (2, 2)?
Sol: The pair (1, 1) is in R1, R3, R4 and R6; (1, 2) is in R1and R6; (2,
1) is in R2, R5 and R6; (1, -1) is in R2, R3 and R6; and finally, (2,
2) is in R1, R3 and R4.
09/03/23 Prepared by Dr. Zakir H. Ahmed 51
Relations – Properties

Reflexivity: A relation R on a set A is called reflexive


if for all a  A, (a, a)  R.
Symmetry: A relation R on a set A is called symmetric
if (b, a)  R whenever (a, b)  R, for all a, b  A.
Antisymmetry: A relation R on A is called
antisymmetric if for all a, b  A, if (a, b)  R and
(b, a)  R, then a = b.
Transitivity: A relation on A is called transitive if
(a, b)  R and (b, c)  R imply (a, c)  R, for all a, b,
c  A.

09/03/23 Prepared by Dr. Zakir H. Ahmed 52


Relations – Examples

Example 6: Which of the relations from Example 5 are


reflexive and symmetric?
-b},
Sol: The reflexive relations from Example 5 are R1
(because a ≤ a, for all integer a), R3 and R4.
For each of the other relations in this example it is
easy to find a pair of the form (a, a) that is not in the
relation.
The symmetric relations are R3, R4 and R6.
R3 is symmetric, for if a=b or a=-b, then b=a or b=-a.
R4 is symmetric, since a=b implies b=a.
R6 is symmetric, since a+b ≤ 3 implies b+a ≤ 3.
None of the other relations is symmetric.
09/03/23 Prepared by Dr. Zakir H. Ahmed 53
Relations – Examples

Example 7: Which of the relations from Example 5 are


antisymmetric?
Sol: The antisymmetric relations from Example 5 are
R1, R2, R4 and R5. R1 is antisymmetric, since the
inequalities a ≤ b and b ≤ a imply that a = b. R2 is
antisymmetric, since it is impossible for a>b and b>a.
R4 is antisymmetric because two elements are
related with respect to R4 iff. they are equal. R2 is
also antisymmetric, since it is impossible that a = b+1
and b = a+1. None of the other relations is
antisymmetric.

09/03/23 Prepared by Dr. Zakir H. Ahmed 54


Relations – Examples

Example 8: Which of the relations from Example 5 are


transitive?
Sol: The transitive relations from Example 5 are R1, R2,
R3 and R4. R1 is transitive, since a ≤ b and b ≤ c imply a
≤ c. R2 is transitive, since a > b and b > c imply a > c.
R3 is transitive, since a = ±b and b = ±c imply a = ±c.
R4 is transitive, since a = b and b = c imply a = c. R5
and R6 are not transitive.

09/03/23 Prepared by Dr. Zakir H. Ahmed 55


Relations – Question

Q1: Consider following relations on {1, 2, 3}:


R1= {(1, 1), (1, 2), (2, 1), (2, 2), (2, 3)},
R2={(1, 1), (1, 2), (2, 2), (3, 2), (3, 3)},
R3={(2, 1), (2, 3), (3, 1)}
R4={(2, 3)},
Which of the relations are reflexive, symmetric,
antisymmetric and transitive?

09/03/23 Prepared by Dr. Zakir H. Ahmed 56


Relations – Equivalence relations

Definition: A relation on a set A is called an equivalence


relation if it is reflexive, symmetric, and transitive.
1. Reflexive ( a  A, aRa)
2. Symmetric (aRb => bRa)
3. Transitive (aRb and bRc => aRc)
Example 13: Let R be the relation on the set of real numbers
such that aRb iff. a-b is an integer. Is R an equivalence
relation?
Sol: As a-a = 0 is an integer for all real numbers a. So, aRa
for all real numbers a. Hence R is reflexive.
Let aRb, then a-b is an integer, so b-a also an integer.
Hence bRa, i.e., R is symmetric.
If aRb and bRc, then a-b and b-c are integers. So, a-c =
(a-b) + (b-c) is also an integer. Hence, aRc. Thus R is
transitive. Consequently, R is an equivalence relation.
09/03/23 Prepared by Dr. Zakir H. Ahmed 57
Relations – Example

Example 14: Is the relation “divides” on the set of


positive integers equivalence relation?
Sol: As a | a , whenever a is a positive integer, the
“divides” relation is reflexive.
Let a | b and b | c. Then there are positive integers
k and l such that b = ak and c = bl. Hence, c = a(kl).
So, a | c. It follows that the relation is transitive.
This relation is not symmetric, as 1 | 2, but 2 ∤ 1.
Hence, the relation is not an equivalence relation.
Q2: Let R be the relation on the set of integers such
that aRb iff. a=b or a=-b. Is R an equivalence
relation?
Q3: Is the relation “≤” on the set of real numbers
equivalence relation?
09/03/23 Prepared by Dr. Zakir H. Ahmed 58
End of Chapter-II

09/03/23 Prepared by Dr. Zakir H. Ahmed 59

You might also like