cs104 : discrete structures chapter ii fundamental structures
TRANSCRIPT
CS104 : Discrete Structures
Chapter IIFundamental Structures
04/19/23 Prepared by Dr. Zakir H. Ahmed 2
Set Theory
Set Theory - Set
04/19/23 Prepared by Dr. Zakir H. Ahmed 3
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
Set Theory - Set
04/19/23 Prepared by Dr. Zakir H. Ahmed 4
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 | pZ, qZ, 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
Note: {}
Set Theory – Subset and Superset
04/19/23 Prepared by Dr. Zakir H. Ahmed 5
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.”or, “B contains A.”or, “every element of A is also in B.”or, x ((x A) => (x B)).and B A means “B is a superset of A.”Example: Let A = {a, b, c} B = {a, b, c, d},
C = { a, c, d, e}then A B and B A, but A is not subset of C.
Venn Diagram
A
B
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 Aiff, x ((x A) <=> (x B)).
Example: If A = {a, b, c, d} and B = {a, b, c, d} , then AB and BA, so A = B.
Note: For any set S,(i) Ø S and (ii) S S
04/19/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}}?04/19/23 Prepared by Dr. Zakir H. Ahmed 7
Set Theory - Power set
04/19/23 Prepared by Dr. Zakir H. Ahmed 8
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)
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}
04/19/23 Prepared by Dr. Zakir H. Ahmed 9
Set Theory – Union and Intersection
04/19/23 Prepared by Dr. Zakir H. Ahmed 10
Union: The union of two sets A and B, denoted by AB, is the set that contains those elements that are either in A or in B, or in both:A B = { x | x A or x B}
Intersection: The intersection of two sets A and B, denoted by AB, is the set containing those elements in both A and B:A B = { x | x A and x B}
AB AB
Set Theory – Union and Intersection
Aii1
n
A1 A2 An
Aii1
n
A1 A2 An
04/19/23 Prepared by Dr. Zakir H. Ahmed 11
Example: If A={1, 2, 3}, B={1, 3, 5} then A B ={1, 2, 3, 5} and AB={1, 3}
Questions: If A = {x : x is a CS major student}, and B = {x : x is a MS major student}, then AB and AB=?
• If A = {x : x is a US president}, and B = {x : x is deceased}, then AB=?
• If A = {x : x is a US president}, and B = {x : x is in this room}, then AB=?
Generalized Unions and Intersections:
Set Theory – Disjoint Set
04/19/23 Prepared by Dr. Zakir H. Ahmed 12
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 AB=Ø
•If A = {x | x is a CS major student} and B = {x | x is a PS major student}, then AB=Ø
Questions:
•Give some examples of two sets A and B such that AB=Ø
Set Theory – Difference of sets
04/19/23 Prepared by Dr. Zakir H. Ahmed 13
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 | xA and xB}
Examples:
•If A = {1, 3, 5}, and B = {1, 2, 3}, then A-B = {5}, and B-A = {2}. So, A-B B-A.
AB
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}
Facts:
•Uc = Ø and Øc = U
•A - B = A Bc 04/19/23 Prepared by Dr. Zakir H. Ahmed 14
AU
Set Theory – Set Identities
A B C
B CA (B C)A BA C(A B) (A C)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
01110111
00000111
00000011
00000101
00000111
04/19/23 Prepared by Dr. Zakir H. Ahmed 15
Prove the following law using Membership table:A (B C) = (A B) (A C)
Proof:
Set Theory – Set Identities
04/19/23 Prepared by Dr. Zakir H. Ahmed 16
Prove the following law using Venn diagram:A (B C) = (A B) (A C)
Proof:
A B AU
C C
UB
A (B C) (A B) (A C)
Set Theory - Famous Identities
IdentitiesName
A U = AA U = A
Identity laws
A U U = UA = Domination laws
A U A = AA A = A
Idempotent laws
(Ac)c = AComplementation
law
A U B = B U AA B = B A
Commutative laws
A U (B U C) = (A U B) U CA (B C) = (A B)
CAssociative laws
04/19/23 Prepared by Dr. Zakir H. Ahmed 17
Set Theory - Famous Identities
IdentitiesName
A U (B C) = (A U B) (A U C)
A (B U C) = (A B) U (A U C)
Distributive laws
(A U B)c = Ac Bc
(A B)c = Ac U BcDe Morgan’s laws
A U (A B) = AA (A U B) = A
Absorption laws
A U Ac = UA Ac = Complement laws
04/19/23 Prepared by Dr. Zakir H. Ahmed 18
Question:Prove the above identities by using Venn diagram and Membership tables ??
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|=?
04/19/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:
04/19/23 Prepared by Dr. Zakir H. Ahmed 20
AB Wrong or right?
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
04/19/23 Prepared by Dr. Zakir H. Ahmed 21
Set Theory – Inclusion-exclusion
Example:There are 150 CS majors100 are taking CS53070 are taking CS52030 are taking both
Question:How many are taking neither?
Answer:
04/19/23 Prepared by Dr. Zakir H. Ahmed 22
150 – (100 + 70 - 30) = 10
CS530CS520
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
Aaif
Aaifbiti
i
ith
0
1
04/19/23 Prepared by Dr. Zakir H. Ahmed 23
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
Set Theory – Computer representation
04/19/23 Prepared by Dr. Zakir H. Ahmed 24
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)
04/19/23 Prepared by Dr. Zakir H. Ahmed 25
Functions
Functions – Definition
Definition: Let A and B be two sets. A function f : A B is an assignment of exactly one element of B to each element of A. We write f(a)=b if b is the unique element of B assigned by the function f to the element a of A.
Example 1:Let A = {Hussain,
Muhammad, Hassan, Eisa} B = {Amina, Fatima,
Khadiza, Mariyam}Also, let f: A B be defined as
f(a) = mother(a).
04/19/23 Prepared by Dr. Zakir H. Ahmed 26
a
A
b=f(a)
B
f(a)
f
Hussain
Muhammad
Hassan
Eisa
Amina
Fatima
Khadiza
MariyamA B
Functions - Examples
04/19/23 Prepared by Dr. Zakir H. Ahmed 27
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 AHussain BMuhammad CMusa DBadr F
This assignment is an example of a function.Questions: Give some examples of functions?
Functions are sometimes called
mappings or transformations
Functions – Examples
Example 3: Suppose we have following graph:And I ask you to describe the red function.What’s the function?
Notation: f: RR,
f(x) = -(1/2)x - 25
04/19/23 Prepared by Dr. Zakir H. Ahmed 28
f(x) = -(1/2)x - 25domai
n
codomain
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}
04/19/23 Prepared by Dr. Zakir H. Ahmed 29
HussainMuhammad
Hassan Eisa
AminaFatimaKhadizaMariyam
A B
Functions – Image and Pre-image
Example 5: - preimage({Fatima}) = {Hussain, Hassan}
preimage (B) = AFor any set P A, image(P) = {b : a P, f(a) = b}For any Q B, preimage(Q) = {a: b Q, f(a) =
b}
04/19/23 Prepared by Dr. Zakir H. Ahmed 30
Hussain
Muhammad
Hassan
Eisa
Amina
Fatima
Khadiza
Mariyam
pre-image(Q) = f-1(Q)image(P) = f(P)
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): integerstate that the domain of floor function is the set of real numbers, and codomain is set of the integers.
04/19/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.04/19/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-to-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.
04/19/23 Prepared by Dr. Zakir H. Ahmed 33
Neither injection nor surjectionHussain
MuhammadHassan Eisa
AminaFatimaKhadizaMariyam
A B
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.
04/19/23 Prepared by Dr. Zakir H. Ahmed 34
Muhammad
Hassan
Eisa
Amina
Fatima
Mariyam
An important implication of this characteristic:The preimage (f-1) is a function!
A B
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.
Sol: The function f is one-to-one since f takes on different values at the four elements of its domain.
Example 10: Determine whether the function f: Z Z, f(x) = x2 is injective.
Sol: The function f is not one-to-one since, for instance, f(1) = f(-1) = 1, but 1 ≠ -1.
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.
Sol: The function f is onto, since three elements of the codomain are images of elements in the domain.
04/19/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.
04/19/23 Prepared by Dr. Zakir H. Ahmed 36
Functions – Examples
04/19/23 Prepared by Dr. Zakir H. Ahmed 37
Example 14:
Functions – Questions
Q1. Suppose f: R+ R+, f(x) = x2.Is f one-to-one?
Is f onto?
Is f bijective?
04/19/23 Prepared by Dr. Zakir H. Ahmed 38
Q2. Suppose f: R R+, f(x) = x2.Is f one-to-one?
Is f onto?
Is f bijective?
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?
04/19/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
04/19/23 Prepared by Dr. Zakir H. Ahmed 40
a=f-1(b) .
A
. b=f(a)
B
f-1(b)
f(a)
f-1
f
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?
04/19/23 Prepared by Dr. Zakir H. Ahmed 41
Functions – Compositions of Functions
Definition: - Let g:AB, and f:BC 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.
04/19/23 Prepared by Dr. Zakir H. Ahmed 42
.a
A
.g(a)
B
.f(g(a))
Cg f
g(a) f(g(a))
(f o g)(a)
f o g
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)?
04/19/23 Prepared by Dr. Zakir H. Ahmed 43
Functions – Examples
Example 18: Let f:ZZ with f(x) = 2x+3, and g:ZZ 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: AB 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:AB is a subset of AXB.04/19/23 Prepared by Dr. Zakir H. Ahmed 44
Functions – Examples
04/19/23 Prepared by Dr. Zakir H. Ahmed 45
Graph of f(n)=2n+1 from Z to Z
Graph of f(n)=n2 from Z to Z
Example 19:
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() = • f-1(A U B) = f-1(A) U f-1(B)• f-1(A B) = f-1(A) f-1(B)
04/19/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 = 1Floor: f(x) = x the greatest integer y so that x y.Example: 1.8 = 1; -1.8 = -2; -5 = -5Question: what is -1.2 + 1.1 ?
04/19/23 Prepared by Dr. Zakir H. Ahmed 47
04/19/23 Prepared by Dr. Zakir H. Ahmed 48
Relations
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.
04/19/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 thatR={(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:
04/19/23 Prepared by Dr. Zakir H. Ahmed 50
1. .1
2. .2
3. .3
4. .4
R1 2 3 41234
X X X X X X X X
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.
04/19/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.
04/19/23 Prepared by Dr. Zakir H. Ahmed 52
Relations – Examples
Example 6: Which of the relations from Example 5 are reflexive and symmetric?
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.
04/19/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.
04/19/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.
04/19/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?
04/19/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.
04/19/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?
04/19/23 Prepared by Dr. Zakir H. Ahmed 58
04/19/23 Prepared by Dr. Zakir H. Ahmed 59
End of Chapter-II