set s and funct ions set s and funct ions
play

Set s and Funct ions Set s and Funct ions Reading f or COMP 364 - PowerPoint PPT Presentation

Set s and Funct ions Set s and Funct ions Reading f or COMP 364 and CSI T571 Reading f or COMP 364 and CSI T571 Cunsheng Ding Depart ment of Comput er Science HKUST, Kowloon, CHI NA Acknowledgments: Materials from Prof. Sanjain Jain at


  1. Universal Sets Universal Sets G Depending on the context of discussion, I define a set U such that all sets of interest are subsets of U. I The set U is known as a universal set. G For example, I when dealing with integers, U may be Z I when dealing with plane geometry, U may be the set of all points in the plane Discrete Math. Reading Materials 34

  2. Venn Diagrams Venn Diagrams G To visualise relationships among some sets G Each subset (of U) is represented by a circle inside the rectangle Discrete Math. Reading Materials 35

  3. Pause and Think ... Pause and Think ... G If Z is a universal set, can we replace Z by R as the universal set? Discrete Math. Reading Materials 36

  4. Lecture Topics Lecture Topics G Sets and Members, Equality of Sets G Set Notation G The Empty Set and Sets of Numbers G Subsets and Power Sets G Equality of Sets by Mutual Inclusion G Universal Sets, Venn Diagrams G Set Operations G Set Identities G Proving Set Identities Discrete Math. Reading Materials 37

  5. Set Operations Set Operations G Let A, B be subsets of some universal set U. G The following set operations create new sets from A and B. G Union I A ∪ B = { x ∈ U | x ∈ A or x ∈ B } G Intersection I A ∩ B = { x ∈ U | x ∈ A and x ∈ B } G Difference I A - B = A \ B = { x ∈ U | x ∈ A and x ∉ B } G Complement I A c = U - A = { x ∈ U | x ∉ A } Discrete Math. Reading Materials 38

  6. Set Union Set Union G An example I { 1, 2, 3 } ∪ { 2, 3, 4, 5 } = { 1, 2, 3, 4, 5 } G the Venn diagram 4 2 5 1 3 Discrete Math. Reading Materials 39

  7. Set Intersection Set Intersection G An example I { 1, 2, 3 } ∩ { 2, 3, 4, 5 } = { 2, 3 } G the Venn diagram 4 2 5 1 3 Discrete Math. Reading Materials 40

  8. Set Difference Set Difference G An example I { 1, 2, 3 } - { 2, 3, 4, 5 } = { 1 } G the Venn diagram 4 2 5 1 3 Discrete Math. Reading Materials 41

  9. Set Complement Set Complement G The Venn diagram Discrete Math. Reading Materials 42

  10. Pause and Think ... Pause and Think ... G Let A ⊆ B. I What is A - B? I What is B - A? G If A, B ⊆ C, what can you say about A ∪ B and C? G If C ⊆ A, B, what can you say about C and A ∩ B? Discrete Math. Reading Materials 43

  11. Lecture Topics Lecture Topics G Sets and Members, Equality of Sets G Set Notation G The Empty Set and Sets of Numbers G Subsets and Power Sets G Equality of Sets by Mutual Inclusion G Universal Sets, Venn Diagrams G Set Operations G Set Identities G Proving Set Identities Discrete Math. Reading Materials 44

  12. Basic Set Identities Basic Set Identities G Commutative laws I A ∪ B = B ∪ A I A ∩ B = B ∩ A G Associative laws I (A ∪ B) ∪ C = A ∪ (B ∪ C) I (A ∩ B) ∩ C = A ∩ (B ∩ C) G Distributive laws I A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) I A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) Discrete Math. Reading Materials 45

  13. Basic Set Identities (continued) Basic Set Identities (continued) G ∅ is the identity for union I ∅ ∪ A = A ∪ ∅ = A G U is the identity for intersection A ∩ U = U ∩ A = A I G Double complement law I (A c ) c = A G Idempotent laws I A ∪ A = A I A ∩ A = A Discrete Math. Reading Materials 46

  14. Basic Set Identities (continued) Basic Set Identities (continued) G De Morgan’s laws I (A ∪ B) c = A c ∩ B c I (A ∩ B) c = A c ∪ B c Discrete Math. Reading Materials 47

  15. Pause and Think ... Pause and Think ... G What is I (A ∩ B) ∩ (A ∪ B)? G What is I (A ∪ B) ∪ (A ∩ B)? Discrete Math. Reading Materials 48

  16. Lecture Topics Lecture Topics G Sets and Members, Equality of Sets G Set Notation G The Empty Set and Sets of Numbers G Subsets and Power Sets G Equality of Sets by Mutual Inclusion G Universal Sets, Venn Diagrams G Set Operations G Set Identities G Proving Set Identities Discrete Math. Reading Materials 49

  17. Proof Methods Proof Methods G There are many ways to prove set identities. G The methods include I applying existing identities, I building a membership table, I using mutual inclusion. Discrete Math. Reading Materials 50

  18. A Proof by Mutual Inclusion A Proof by Mutual Inclusion G Prove that (A ∩ B) ∩ C = A ∩ (B ∩ C). G First show that (A ∩ B) ∩ C ⊆ A ∩ (B ∩ C). G Let x ∈ (A ∩ B) ∩ C, I x ∈ (A ∩ B) and x ∈ C I x ∈ A and x ∈ B and x ∈ C I x ∈ A and x ∈ ( B ∩ C ) I x ∈ A ∩ (B ∩ C) G Then show that A ∩ (B ∩ C) ⊆ (A ∩ B) ∩ C. Discrete Math. Reading Materials 51

  19. Pause and Think ... Pause and Think ... G To prove that A ∪ A c = U by mutual inclusion, do you have to prove the inclusion A U A c ⊆ U? G To prove that A ∩ A c = ∅ by mutual inclusion, do you have to prove the inclusion ∅ ⊆ A ∩ A c ? Discrete Math. Reading Materials 52

  20. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 53

  21. “High School “ High School” ” Functions Functions G Functions are usually given by formulas. G Examples I f(x) = sin(x) I f(x) = e x I f(x) = x n I f(x) = log x G A function is a computation rule that changes one value to another value. G Effectively, a function associates, or relates, one value to another value. Discrete Math. Reading Materials 54

  22. “General “ General” ” Functions Functions G Since a function relates one value to another, we can think of a function as relating one object to another object. Objects need not be numbers. G In the previous examples, the function f relates the object x to the object f(x). G Usually we want to be able to relate each object of interest to only one object. G That is, a function is a single-valued and exhaustive relation. Discrete Math. Reading Materials 55

  23. Functions Functions G A relation f from A to B is a function from A to B iff I for every x ∈ A, there exists a unique y ∈ B such that x f y, or equivalently, (x,y) ∈ f. G Functions are also known as transformations, maps, and mappings. Discrete Math. Reading Materials 56

  24. Example 1 Example 1 G Let A = { 1, 2, 3 } and B = { a, b }. G R = { (1,a), (2,a), (3,b) } is a function from A to B. 1 a 2 b 3 Discrete Math. Reading Materials 57

  25. Example 2 Example 2 G Let A = { 1, 2, 3 } and B = { a, b }. G S = { (1,a), (1,b), (2,a), (3,b) } is not a function from A to B. 1 a 2 b 3 Discrete Math. Reading Materials 58

  26. Example 3 Example 3 G Let A = { 1, 2, 3 } and B = { a, b }. G T = { (1,a), (3,b) } is not a function from A to B. 1 a 2 b 3 Discrete Math. Reading Materials 59

  27. Pause and Think ... Pause and Think ... G Is A x { a }, where a ∈ A, a function from A to A? Discrete Math. Reading Materials 60

  28. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 61

  29. Function Notation Function Notation G Let f be a relation from A to B. That is, f ⊆ AxB. G If the relation f is a function, I we write f : A → B. I If (x,y) ∈ f, we write y = f(x). G Usually we use f, g, h, … to denote relations that are functions. Discrete Math. Reading Materials 62

  30. Notational Convention Notational Convention G Sometimes functions are given by stating the rule of transformation, for example, f(x) = x+1. G This should be taken to mean I f = { (x,f(x)) ∈ AxB | x ∈ A } I where A and B are some understood sets. Discrete Math. Reading Materials 63

  31. Pause and Think ... Pause and Think ... G Let f ⊆ A x B be a relation and (x,y) ∈ f. G Does the expression f(x) = y make sense? Discrete Math. Reading Materials 64

  32. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 65

  33. Values, Images Values, Images G Let f : A → B. G Let y = f(x). I That is, x f y, equivalently, (x,y) ∈ f. G The object y is called I the image of x under the function f, or I the value of f at x. Discrete Math. Reading Materials 66

  34. Inverse Images, Pre- Inverse Images, Pre -images images G Let f : A → B and y ∈ B. G Define I f -1 (y) = { x ∈ A | f(x) = y } G The set f -1 (y) is called the inverse image, or pre- image of y under f. Discrete Math. Reading Materials 67

  35. Images and Pre- Images and Pre -images of Subsets images of Subsets G Let f : A → B and X ⊆ A and Y ⊆ B. G We define I f(X) = { f(x) ∈ B | x ∈ X } I f -1 (Y) = { x ∈ A | f(x) ∈ Y } Discrete Math. Reading Materials 68

  36. Examples Examples G Let f : A → B be given as follows a 1 b c 2 d e 3 G f( {1,3} ) = { c, d } G f -1 ( { a, d } ) = { 3 } Discrete Math. Reading Materials 69

  37. Some Properties Some Properties G Let f : A → B and X ⊆ A and Y ⊆ B. G Clearly we have I f(A) ⊆ B I f -1 (B) = A because every element of A has an image in B Discrete Math. Reading Materials 70

  38. Pause and Think ... Pause and Think ... G Let f : A → B and X ⊆ A and Y ⊆ B. G If there are n elements in X, how many elements are there in f(X)? G If there are n elements in Y, how many elements are there in f -1 (Y)? Discrete Math. Reading Materials 71

  39. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 72

  40. Domains Domains G Let f : A → B. G The domain of function f is the set A. Discrete Math. Reading Materials 73

  41. Codomains and Ranges Codomains and Ranges G Let f : A → B. G The codomain of function f is the set B. G The range of function f is the set of images of f. I Clearly, the range of f is f(A). Discrete Math. Reading Materials 74

  42. Example 1 Example 1 f 1 p q 2 r 3 s G The domain is { 1, 2, 3 }. G The codomain is { p, q, r, s }. G The range is { p, r }. Discrete Math. Reading Materials 75

  43. Example 2 Example 2 G Consider exp : R → R . That is, exp(x) = e x . G The domain and codomain of exp are both R . G The range of exp is R + , the set of positive real numbers. Discrete Math. Reading Materials 76

  44. Pause and Think ... Pause and Think ... G Consider cos : R → R . G What are the domain, codomain, and range of cos? Discrete Math. Reading Materials 77

  45. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 78

  46. Images and Pre- Images and Pre -images of Subsets images of Subsets G Let f : A → B. G Let X, X’ ⊆ A and Y, Y’ ⊆ B. G We shall call f(X) the image of X instead of the set of images of members of X. Similarly, we shall simply call f -1 (Y) the preimage of Y. G We have I f( f -1 (Y)) ⊆ Y and X ⊆ f -1 (f(X)) I f(X ∪ X’) = f(X) ∪ f(X’), f(X ∩ X’) ⊆ f(X) ∩ f(X’) I f -1 (Y ∪ Y’) = f -1 (Y) ∪ f -1 (Y’) I f -1 (Y ∩ Y’) = f -1 (Y) ∩ f -1 (Y’) Discrete Math. Reading Materials 79

  47. 1 (Y)) (Y)) ⊆ ⊆ Y -1 f( f - Y f( f G It is possible to have strict inclusion. I When the range of f is a proper subset of its codomain, we may take Y = B to obtain I f( f -1 (B)) = f( A ) ⊂ B G To show inclusion, I let y ∈ f( f -1 (Y)). I ∃ x ∈ f -1 (Y) such that f(x) = y. I We have f(x) ∈ Y. I That is, y ∈ Y Discrete Math. Reading Materials 80

  48. f(X ∪ ∪ X ) = f(X) ∪ ∪ f(X X’ ’) = f(X) f(X’ ’) ) f(X G We can easily show that I f(X ∪ X’) ⊇ f(X) ∪ f(X’). G This is because X ∪ X’ ⊇ X, so I f(X ∪ X’) ⊇ f(X). G Similarly, we have f(X ∪ X’) ⊇ f(X’). G Consequently, f(X ∪ X’) ⊇ f(X) ∪ f(X’). Discrete Math. Reading Materials 81

  49. f(X ∪ ∪ X ) = f(X) ∪ ∪ f(X X’ ’) = f(X) f(X’ ’) ) f(X G To show f(X ∪ X’) ⊆ f(X) ∪ f(X’), I let y ∈ f(X ∪ X’). G ∃ x ∈ X ∪ X’ such that f(x) = y. G If x ∈ X, then y ∈ f(X); otherwise, y ∈ f(X’). This means y ∈ f(X) ∪ f(X’). G That is, f(X ∪ X’) ⊆ f(X) ∪ f(X’). Discrete Math. Reading Materials 82

  50. Pause and Think ... Pause and Think ... G What do the given set expressions become when f is the identity function? Discrete Math. Reading Materials 83

  51. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 84

  52. Equality of Functions Equality of Functions G Let f : A → B and g : C → D. G We define function f = function g iff I set f = set g G Note that this forces A = C but allows B ≠ D. I Some require B = D as well. Discrete Math. Reading Materials 85

  53. A Proof that Set f = Set g Implies Domain A Proof that Set f = Set g Implies Domain f = Domain g f = Domain g G Let f : A → B and g : C → D and set f = set g. G Let x ∈ A. I (x,f(x)) ∈ f I But f = g as sets I (x,f(x)) ∈ g I That is x ∈ C. I Consequently, A ⊆ C. G Similarly, we have C ⊆ A. G That is, A = C. Discrete Math. Reading Materials 86

  54. A Proof that Set f = Set g Implies f(x) = A Proof that Set f = Set g Implies f(x) = ∈ A g(x) for all x ∈ A g(x) for all x G Let f, g : A → B and set f = set g. G Let x ∈ A. I (x,f(x)) ∈ f I But f = g as sets I (x,f(x)) ∈ g I That is (x,f(x)), (x,g(x)) ∈ g. I Since g is a function, so f(x) = g(x). Discrete Math. Reading Materials 87

  55. Example Example G We consider I exp : R → R and I exp : [0,1] → R I as two different functions though the computation rule is the same --- exp(x) = e x . Discrete Math. Reading Materials 88

  56. Pause and Think ... Pause and Think ... G Let f and g be functions such that f(x) = g(x) on some set A. Can we conclude that function f = function g? Discrete Math. Reading Materials 89

  57. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 90

  58. Identity Functions Identity Functions G Consider the identity relation I A on the set A. G Clearly, for every x ∈ A, I A relates x to an unique element of A that is itself. G Consequently, we have I A : A → A . I A is also called the identity function on A. G Discrete Math. Reading Materials 91

  59. Constant Functions Constant Functions G Let f : A → B. G If f(A) = { y } for some y ∈ B, f is called a constant function of value y. . f . . . y . . . . . Discrete Math. Reading Materials 92

  60. Characteristics Functions Characteristics Functions G Consider some universal set U. G Let A ⊆ U. G The function χ A : U → { 0, 1 } defined by I χ A (x) = 1, if x ∈ A, I χ A (x) = 0, if x ∈ A c ; I is called the characteristic function of A. Discrete Math. Reading Materials 93

  61. Pause and Think ... Pause and Think ... G Let f : R → R . I If f is a constant function, what does its graph on the Cartesian X-Y plane look like? I If f is the identity function, what does its graph on the Cartesian X-Y plane look like? Discrete Math. Reading Materials 94

  62. Lecture Topics Lecture Topics G From “High School” Functions to “General” Functions G Function Notation G Values, images, inverse images, pre-images G Codomains, Domains, Ranges G Sets of Images and Pre-Images G Equality of Functions G Some Special Functions G Unary and Binary Operations as Functions G The Composition of Two Functions is a Function G The Values of Function Composition Discrete Math. Reading Materials 95

  63. Unary Operations Unary Operations G A unary operation on a set A acts on an element of A and produces another element of A. G Clearly, a unary operation uop can be thought of as a function f : A → A with f(x) = uop( x ). G Conversely, a function from A to A can be regarded as a unary operation on A. Discrete Math. Reading Materials 96

  64. Example 1 Example 1 G Let U be some universal set. G The complement operation on P(U) can be represented as a function I f: P(U) → P(U) with f(A) = A c . Discrete Math. Reading Materials 97

  65. Binary Operations Binary Operations G A binary operation on a set A acts on two elements of A and produces another element of A. G Clearly, a binary operation bop can be represented as a function I f : AxA → A with f((a,b)) = a bop b. I We write f(a,b) instead of f((a,b)). G Conversely, a function from AxA to A can be regarded as a binary operation on A. Discrete Math. Reading Materials 98

  66. Example 1 Example 1 G Let U be some universal set. G The union operation on P(U) can be represented as a function f: P(U)xP(U) → P(U) with f(A,B) = A ∪ B. Discrete Math. Reading Materials 99

  67. Pause and Think ... Pause and Think ... G Let U = { 0, 1 }. G Give the set representations of the functions for unary complement operation and the binary intersection operation. Discrete Math. Reading Materials 100

Recommend


More recommend