Download presentation
Presentation is loading. Please wait.
Published byAmelia Kathryn Pope Modified over 9 years ago
1
CS104 : Discrete Structures Chapter II Fundamental Structures
2
7/2/2015Prepared by Dr. Zakir H. Ahmed 2 Set Theory
3
Set Theory - Set 7/2/2015Prepared 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
4
Set Theory - Set 7/2/2015Prepared 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 | p Z, q Z, q≠0} is the set of rational numbers R = Q U Q c, set of real numbers C = {a + ib | a, b R, i = √-1}, set of complex numbers Note: { }
5
Set Theory – Subset and Superset 7/2/2015Prepared 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
6
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 7/2/2015Prepared by Dr. Zakir H. Ahmed 6
7
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}}? 7/2/2015Prepared by Dr. Zakir H. Ahmed 7
8
Set Theory - Power set 7/2/2015Prepared 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)|=2 n )
9
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 A 1 x A 2 x … x A n = {(a 1, a 2,…, a n ) | a i A i, for i=1, 2, …, n} 7/2/2015Prepared by Dr. Zakir H. Ahmed 9
10
Set Theory – Union and Intersection 7/2/2015 Prepared by Dr. Zakir H. Ahmed 10 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 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} A B A B
11
Set Theory – Union and Intersection 7/2/2015Prepared by Dr. Zakir H. Ahmed 11 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:
12
Set Theory – Disjoint Set 7/2/2015 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 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=Ø
13
Set Theory – Difference of sets 7/2/2015 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 | 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
14
Set Theory - Complement Complement: Let U be the universal set. The complement of the set A, denoted by A c or Ā, is set containing those elements that are not in A: A c = { x | x A} Examples: If U={1, 2, …, 10}, A={1, 3, 5, 7, 9}, then A c ={2, 4, 6, 8, 10}. If A = {x : x is bored}, then A c = {x : x is not bored} Facts: U c = Ø and Ø c = U A - B = A B c 7/2/2015Prepared by Dr. Zakir H. Ahmed 14 A U
15
Set Theory – Set Identities (A B) (A C)A CA BA (B C)B CA B C 0000011100000111 0000010100000101 0000001100000011 0000011100000111 0111011101110111 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 7/2/2015 Prepared by Dr. Zakir H. Ahmed 15 Prove the following law using Membership table: A (B C) = (A B) (A C) Proof:
16
Set Theory – Set Identities 7/2/2015 Prepared by Dr. Zakir H. Ahmed 16 Prove the following law using Venn diagram: A (B C) = (A B) (A C) Proof: A B A U C C U B A (B C)(A B) (A C)
17
Set Theory - Famous Identities IdentitiesName A U = A A U = A Identity laws A U U = U A = Domination laws A U A = A A A = A Idempotent laws (A c ) c = AComplementation law A U B = B U A A B = B A Commutative laws A U (B U C) = (A U B) U C A (B C) = (A B) C Associative laws 7/2/2015Prepared by Dr. Zakir H. Ahmed 17
18
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 = A c B c (A B) c = A c U B c De Morgan’s laws A U (A B) = A A (A U B) = A Absorption laws A U A c = U A A c = Complement laws 7/2/2015Prepared by Dr. Zakir H. Ahmed 18 Question: Prove the above identities by using Venn diagram and Membership tables ??
19
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|=? 7/2/2015Prepared by Dr. Zakir H. Ahmed 19
20
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: 7/2/2015Prepared by Dr. Zakir H. Ahmed 20 A B Wrong or right?
21
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 7/2/2015Prepared by Dr. Zakir H. Ahmed 21
22
Set Theory – Inclusion-exclusion Example: There are 150 CS majors 100 are taking CS530 70 are taking CS520 30 are taking both Question: How many are taking neither? Answer: 7/2/2015Prepared by Dr. Zakir H. Ahmed 22 150 – (100 + 70 - 30) = 10 CS530 CS520
23
Set Theory – Computer representation Let U be a finite universal set. Let a 1, a 2,…, a n be an arbitrary ordering of the elements of U. Represent a subset A of U with the bit string of length n, where 7/2/2015 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
24
Set Theory – Computer representation 7/2/2015 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, A c, A U (B C) and A (B U C)
25
7/2/2015Prepared by Dr. Zakir H. Ahmed 25 Functions
26
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). 7/2/2015Prepared by Dr. Zakir H. Ahmed 26 aAaA b=f(a) B f(a) f Hussain Muhammad Hassan Eisa Amina Fatima Khadiza Mariyam A B
27
Functions - Examples 7/2/2015Prepared 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: AhmedA HussainB MuhammadC MusaD BadrF This assignment is an example of a function. Questions: Give some examples of functions? Functions are sometimes called mappings or transformations
28
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, f(x) = -(1/2)x - 25 7/2/2015Prepared by Dr. Zakir H. Ahmed 28 f(x) = -(1/2)x - 25 domain codomain
29
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} 7/2/2015Prepared by Dr. Zakir H. Ahmed 29 Hussain Muhammad Hassan Eisa Amina Fatima Khadiza Mariyam AB
30
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} 7/2/2015Prepared by Dr. Zakir H. Ahmed 30 Hussain Muhammad Hassan Eisa Amina Fatima Khadiza Mariyam pre-image(Q) = f -1 (Q)image(P) = f(P) AB
31
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 31
32
Functions – On Real Number Definition: Let f 1 and f 2 be two functions from A to R. Then f 1 +f 2 and f 1 f 2 are also functions from A to R defined by (f 1 +f 2 )(x) = f 1 (x) + f 2 (x), (f 1 f 2 )(x) = f 1 (x)f 2 (x). Example 8: Let f 1 and f 2 be two functions from R to R such that f 1 (x) = x 2 and f 2 (x) = x – x 2. What are the functions f 1 +f 2, f 1 f 2 ? Solution: From the definitions, (f 1 +f 2 )(x) = f 1 (x) + f 2 (x) = x 2 + (x – x 2 ) = x, (f 1 f 2 )(x) = f 1 (x)f 2 (x) = x 2 (x – x 2 ) = x 3 – x 4. 7/2/2015Prepared by Dr. Zakir H. Ahmed 32
33
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 33 Neither injection nor surjection Hussain Muhammad Hassan Eisa Amina Fatima Khadiza Mariyam A B
34
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. 7/2/2015Prepared 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
35
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) = x 2 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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 35
36
Functions – Examples Example 12: Determine whether the function f: Z Z, f(x) = x 2 is surjective. Sol: The function f is not onto since, for instance, there is no integer x with x 2 = -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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 36
37
Functions – Examples 7/2/2015Prepared by Dr. Zakir H. Ahmed 37 Example 14:
38
Functions – Questions Q1. Suppose f: R + R +, f(x) = x 2. Is f one-to-one? Is f onto? Is f bijective? 7/2/2015Prepared by Dr. Zakir H. Ahmed 38 Q2. Suppose f: R R +, f(x) = x 2. Is f one-to-one? Is f onto? Is f bijective?
39
Functions – Questions Q3. Suppose f: R R, f(x) = x 2. 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? 7/2/2015Prepared by Dr. Zakir H. Ahmed 39
40
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 7/2/2015Prepared by Dr. Zakir H. Ahmed 40 a=f -1 (b). A. b=f(a) B f -1 (b) f(a) f -1 f
41
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) = x 2 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? 7/2/2015Prepared by Dr. Zakir H. Ahmed 41
42
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 42.aA.aA. g(a) B. f(g(a)) C g f g(a)f(g(a)) (f o g)(a) f o g
43
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)? 7/2/2015Prepared by Dr. Zakir H. Ahmed 43
44
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 44
45
Functions – Examples 7/2/2015Prepared by Dr. Zakir H. Ahmed 45 Graph of f(n)=2n+1 from Z to Z Graph of f(n)=n 2 from Z to Z Example 19:
46
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) 7/2/2015Prepared by Dr. Zakir H. Ahmed 46
47
Functions – Familiar functions Polynomials: f(x) = a 0 x n + a 1 x n-1 + … + a n-1 x 1 + a n x 0 Example: f(x) = x 3 - 2x 2 + 15 Exponentials: f(x) = c dx Example: f(x) = 3 10x, f(x) = e x Logarithms: log 2 x = y, where 2 y = 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 ? 7/2/2015Prepared by Dr. Zakir H. Ahmed 47
48
7/2/2015Prepared by Dr. Zakir H. Ahmed 48 Relations
49
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 49
50
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: 7/2/2015Prepared by Dr. Zakir H. Ahmed 50 1..1 2..2 3..3 4..4 1 2 3 4R X X X 12341234
51
Relations – Examples Example 5: Consider the relations on the set of integers: R 1 = {(a, b) | a ≤ b}, R 2 ={(a, b) | a > b}, R 3 ={(a, b) | a = b or a = -b}, R 4 ={(a, b) | a = b}, R 5 ={(a, b) | a = b+1}, R 6 ={(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 R 1, R 3, R 4 and R 6 ; (1, 2) is in R 1 and R 6 ; (2, 1) is in R 2, R 5 and R 6 ; (1, -1) is in R 2, R 3 and R 6 ; and finally, (2, 2) is in R 1, R 3 and R 4. 7/2/2015Prepared by Dr. Zakir H. Ahmed 51
52
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 52
53
Relations – Examples Example 6: Which of the relations from Example 5 are reflexive and symmetric? Sol: The reflexive relations from Example 5 are R 1 (because a ≤ a, for all integer a), R 3 and R 4. 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 R 3, R 4 and R 6. R 3 is symmetric, for if a=b or a=-b, then b=a or b=-a. R 4 is symmetric, since a=b implies b=a. R 6 is symmetric, since a+b ≤ 3 implies b+a ≤ 3. None of the other relations is symmetric. 7/2/2015Prepared by Dr. Zakir H. Ahmed 53
54
Relations – Examples Example 7: Which of the relations from Example 5 are antisymmetric? Sol: The antisymmetric relations from Example 5 are R 1, R 2, R 4 and R 5. R 1 is antisymmetric, since the inequalities a ≤ b and b ≤ a imply that a = b. R 2 is antisymmetric, since it is impossible for a>b and b>a. R 4 is antisymmetric because two elements are related with respect to R 4 iff. they are equal. R 2 is also antisymmetric, since it is impossible that a = b+1 and b = a+1. None of the other relations is antisymmetric. 7/2/2015Prepared by Dr. Zakir H. Ahmed 54
55
Relations – Examples Example 8: Which of the relations from Example 5 are transitive? Sol: The transitive relations from Example 5 are R 1, R 2, R 3 and R 4. R 1 is transitive, since a ≤ b and b ≤ c imply a ≤ c. R 2 is transitive, since a > b and b > c imply a > c. R 3 is transitive, since a = ±b and b = ±c imply a = ±c. R 4 is transitive, since a = b and b = c imply a = c. R 5 and R 6 are not transitive. 7/2/2015Prepared by Dr. Zakir H. Ahmed 55
56
Relations – Question Q1: Consider following relations on {1, 2, 3}: R 1 = {(1, 1), (1, 2), (2, 1), (2, 2), (2, 3)}, R 2 ={(1, 1), (1, 2), (2, 2), (3, 2), (3, 3)}, R 3 ={(2, 1), (2, 3), (3, 1)} R 4 ={(2, 3)}, Which of the relations are reflexive, symmetric, antisymmetric and transitive? 7/2/2015Prepared by Dr. Zakir H. Ahmed 56
57
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. 7/2/2015Prepared by Dr. Zakir H. Ahmed 57
58
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? 7/2/2015Prepared by Dr. Zakir H. Ahmed 58
59
7/2/2015Prepared by Dr. Zakir H. Ahmed 59 End of Chapter-II
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.