discrete mathematics
play

Discrete Mathematics -- Chapter 5: Relations and Ch t 5 R l ti d - PowerPoint PPT Presentation

Discrete Mathematics -- Chapter 5: Relations and Ch t 5 R l ti d Functions Hung-Yu Kao ( ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U Outline 5.1 Cartesian Products


  1. Discrete Mathematics -- Chapter 5: Relations and Ch t 5 R l ti d Functions Hung-Yu Kao ( 高宏宇 ) Department of Computer Science and Information Engineering, N National Cheng Kung University l Ch K U

  2. Outline � 5.1 Cartesian Products and Relations � 5.2 Functions: Plain and One-to-One � 5.3 Onto Functions: Stirling Numbers of the Second Kind � 5 4 Special Functions � 5.4 Special Functions � 5.5 The Pigeonhole Principle � 5.6 Function Composition and Inverse Functions 5 6 F ti C iti d I F ti � 5.7 Computational Complexity � 5.8 Analysis of Algorithms 2 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  3. Introduction The same problem! 3 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  4. 5.1 Cartesian Products and Relations For sets A , B, the Cartesian product (cross product), of A and B is � × = ∈ ∈ A B {( a , b ) | a A , b B }. denoted by E g {a b} × {1 2 3} = {(a 1) (b 1) (a 2) (b 2) (a 3) (b 3)} E.g., {a,b} × {1,2,3} = {(a,1),(b,1),(a,2),(b,2),(a,3),(b,3)} � � Extension of the Cartesian product: � × × ⋅ ⋅ ⋅ × = ⋅ ⋅ ⋅ ∈ ≤ ≤ A A A {( a , a , , a ) | a A , 1 i n }. 1 2 n 1 2 n i i × = ∈ Ex 5.2 : is recognized as the real plane of R R {( x , y ) | x , y R } � coordinate geometry and two dimensional calculus coordinate geometry and two-dimensional calculus. + × R + The subset is the interior of the first quadrant of this plane. R � R 3 represents Euclidean three-space, where the three-dimensional p p , � interior of any sphere, and two-dimensional planes, and one- dimensional lines are subsets of importance. 4 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  5. Cartesian Products and Relations � Ex 5.1 : Let A = {2, 3, 4}, B = {4, 5}. Then � Ex 5 1 : Let A = {2 3 4} B = {4 5} Then × = a) A B {(2, 4), (2,5), (3,4), (3,5), (4,4), (4,5)} × = b) b) B B A A {(4 {(4, 2) 2), (4 3) (4,3), (4,4), (4 4) (5,2), (5 2) (5,3), (5 3) (5,4)} (5 4)} = × = c) B B B {(4, 4), (4,5), (5,4), (5,5)} 2 = × × = ∈ ∈ d) B B B B {(a, b, c) | a, b, c B }; e.g., (4,5,5) B 3 3 � Ex 5.3: Tree diagram C = {x, y} � |A x B x C| = 12 � = 3 * 2 * 2 = |A||B||C| 5 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  6. Cartesian Products and Relations A × B � Definition 5.2: For sets A , B , any subset of is called a (binary) A × A relation from A to B. Any subset of is called a (binary) relation on A relation on A. � In short, we say “aRb” if and only if (a,b) ∈ R. � Ex 5.5 : The following are some of the relations from A to B . E 5 5 Th f ll i f h l i f A B φ × , {( 2 , 4 ), ( 3 , 5 )}, A B � � × × = = ∴ ∴ 6 | | A A B B | | 6 6 , 2 2 possible possible relations relations from from A A to to B B Q Q � = = mn General formula : | A | m , | B | n , 2 relations from A to B � How many relations from B to A? 6 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  7. Cartesian Products and Relations + + = ℜ ℜ ≤ ≤ A A Z Z , we may d fi define a relation l ti on set t A A as {( {(x, y) ) | | x y} } � Ex 5.7 : E 5 7 ℜ is the relation " is less than or equal to". ∈ ∈ ℜ ℜ ℜ ℜ ℜ ℜ (7,7), (7,7), (7,11) (7,11) , , or or 7 7 7, 7, 7 7 11 11 ∉ ℜ ℜ / (8,2) , or 8 2 × φ φ = φ φ φ φ × = φ φ A A , A A For any set A, F A � 7 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  8. Cartesian Products and Relations � Theorem 5.1: For any sets Th 5 1 F t h : h ⊆ A , B , C × ∩ = × ∩ × a) A ( B C) ( A B ) ( A C) × × ∪ ∪ = = × × ∪ ∪ × × b) b) A A ( ( B B C) C) ( ( A A B B ) ) ( ( A A C) C) ∩ × = × ∩ × c) ( A B ) C ( A C) ( B C ) ∪ × = × ∪ × d) ( A B ) C ( A C) ( B C) � Proof ∀ ∈ × ∩ ⇔ ∈ ∈ ∩ (a) a , b A ( B C) a A and b ( B C) ⇔ ⇔ ∈ ∈ ∈ ∈ ∩ ∩ ∈ ∈ ⇔ ⇔ ∈ ∈ ∈ ∈ ∈ ∈ ∈ ∈ a a A A and and b b B B b b C C a a A A , , b b B B and and a a A A , , b b C C ⇔ ∈ × ∈ × ( a , b ) A B and ( a , b ) A C ⇔ ∈ × ∩ × ( a , b ) ( A B ) ( A C) 8 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  9. 5.2: Functions: Plain and One-to-One → Definition 5.3: for nonempty sets A, B, , a function (mapping) D fi iti 5 3 f t t A B f ti ( i ) f f : A A B B � from A to B , is a relation from A to B in which every element of A appears exactly once as the first component of an ordered pair in the relation. f ( a ) = b when ( a , b ) is an ordered pair in the function f. � ( a , b ) ∈ f , b is called the image of a under f , whereas a is a preimage � of b of b . f is a method for associating with each a ∈ A the unique element f ( a ) � = b ∈ B. ( a , b ), ( a , c ) ∈ f , implies b = c. � � Ex 5.9 : = = A { 1 , 2 , 3 }, B { w , x , y , z } = f {( 1 , w ), ( 2 , x ), ( 3 , x )} is a function and a relation ℜ ℜ = ℜ ℜ = {( {( 1 1 , , w w ), ), ( ( 2 2 , , x x )}, )}, {( {( 1 1 , , w w ), ), ( ( 2 2 , , w w ), ), ( ( 2 2 , , x x ), ), ( ( 3 3 , , z z )} )} are are relations, relations, but but not not functions. functions. 1 1 2 2 9 2009 Spring 2009 Spring Discrete Mathematics – Discrete Mathematics – CH5 CH5

  10. Functions: Plain and One-to-One → D fi iti Definition 5.4: Function , A is called the domain of f and B the 5 4 F ti A i ll d th d i f f d B th f f : A A B B � codomain of f . The subset of B consisting of those elements that appear as second � components in the ordered pairs of f is called the range of f and is also denoted by f ( A ) because it is the set of images (of the elements of A ) under f . � In Example 5.9, f • f = • a the domain of { 1 , 2 , 3 } f ( a )= b = the codomain of f { w , x , y , z } f ( A ) = = the range of f f ( A ) { w , x } A B A C++ compiler can be thought of as a function that transforms a source � program (the input) into its corresponding object program (the output). 10 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  11. Functions: Plain and One-to-One Ex 5.10 Many interesting function arise in computer science. � (a) Greatest integer function (floor function) � ⎣ ⎦ ⎣ ⎦ → → = = f f : : R Z , , f f ( ( x x ) ) x x the e greatest g ea es integer ege less ess than a o or equal equa to o x x . . ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ ⎣ ⎦ = = − = − − = − 1) 3 . 8 3 , 3 3 , 3 . 8 4 , 3 3 ⎣ + ⎦ = ⎣ ⎦ = = + = ⎣ ⎦ + ⎣ ⎦ 2) 7 . 1 8 . 2 15 . 3 15 7 8 7 . 1 8 . 2 ⎣ ⎣ + ⎦ ⎦ = ⎣ ⎣ ⎦ ⎦ = ≠ = + = ⎣ ⎣ ⎦ ⎦ + ⎣ ⎣ ⎦ ⎦ 3) ) 7 . 7 8 . 4 16 . 1 16 15 7 8 7 . 7 8 . 4 (b) Ceiling function � → = ⎡ ⎤ = g : R Z , g ( x ) x the least integer greater th an or equal to x . ⎡ ⎤ ⎡ ⎤ = = ⎡ ⎡ ⎤ ⎤ = = ⎡ ⎡ ⎤ ⎤ = = = = ⎡ ⎤ ⎡ ⎡ ⎤ ⎡ − ⎤ ⎤ = = − ⎡ ⎡ − ⎤ ⎤ = = ⎡ ⎡ − ⎤ ⎤ = = − 1) 1) 3 3 3 3 , 3 3 . 01 01 3 3 . 7 7 4 4 4 4 , 3 3 3 3 , 3 3 . 01 01 3 3 . 7 7 3 3 ⎡ + ⎤ = ⎡ ⎤ = = + = ⎡ ⎤ + ⎡ ⎤ 2) 3.6 4.5 8 . 1 9 4 5 3 . 6 4 . 5 ⎡ + ⎤ = ⎡ ⎤ = ≠ = + = ⎡ ⎤ + ⎡ ⎤ 3) 3.3 4.2 7 . 5 8 9 4 5 3 . 3 4 . 2 (c) Truncation (trunc) function: delete the fractional part of a real number � trunc(3.78) = 3, trunc(5) = 5, trunc(-7.22) = -7 � ⎣ ⎦ ⎡ ⎤ = = − = − = − trunc ( 3 . 78 ) 3 . 78 3 , trunc ( 3 . 78 ) 3 . 78 3 � 11 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

  12. Functions: Plain and One-to-One � (d) Access function: storing a m × n matrix in a one-dimensional array Use the row major implementation h j i l i � = − + formula : f ( a ) ( i 1 ) n j � ij a 11 a 12 … a 1n a 21 a 22 … a 2n a 31 … a ij … a mn 1 2 … n n+1 n+2 … 2n 2n+1 … (i-1)n+j … (m-1)n+n=mn 12 2009 Spring 2009 Spring Discrete Mathematics Discrete Mathematics – – CH5 CH5

Recommend


More recommend