cpsc 121 models of computation part 1
play

CPSC 121: Models of Computation PART 1 REVIEW OF TEXT READING Unit - PowerPoint PPT Presentation

CPSC 121: Models of Computation PART 1 REVIEW OF TEXT READING Unit 12: Functions These pages correspond to text reading and are not covered in the lectures. Based on slides by Patrice Belleville and Steve Wolfman Unit 12: Functions 2 What


  1. CPSC 121: Models of Computation PART 1 REVIEW OF TEXT READING Unit 12: Functions These pages correspond to text reading and are not covered in the lectures. Based on slides by Patrice Belleville and Steve Wolfman Unit 12: Functions 2 What is a Function? Plotting Functions f(x) = x 3 Mostly, a function is what you learned it was all through f(x) = x mod 4 K-12 mathematics, with strange vocabulary to make it more interesting… f(x) =  x  A function f:A  B maps values from its domain A to its co-domain B . Domain Co-domain f(x) = x 3 f(x) = x mod 4 f(x) =  x  Not every function is easy to plot! Unit 12: Functions Unit 12: Functions 3 5 1

  2. What is a Function? What is a Function? A function f:A  B maps values from its domain A to Not every function has to do with numbers… its co-domain B . A function f:A  B maps values from its domain A to its co-domain B . f(control, data1, data2) = (~control  data1)  (control  data2) Domain Co-domain f(x) = ~x f(x,y) = x  y Domain? Co-domain? f(x) = x ’s phone # Unit 12: Functions 7 Unit 12: Functions 9 What is a Function? What is a Function? A function f:A  B maps values from its domain A function f:A  B maps values from its domain A to its A to its co-domain B . co-domain B . f can’t map one element of its domain to more than one Alan element of its co-domain: Steve 111  x  A,  y 1 ,y 2  B, 121 [(f(x) = y 1 )  (f(x) = y 2 )]  (y 1 = y 2 ). Paul Patrice 211 f Karon Why insist on this? A B George Domain? Co-domain? Other examples? Unit 12: Functions Unit 12: Functions 11 13 2

  3. Not a Function Function Terminology A function f:A  B maps values from its domain A to its co-domain B . Why isn’t this a function? For f to be a function, it must map every element in its domain:  x  A,  y  B, f(x) = y. f Why insist on this? B A Warning: some mathematicians would say that makes f “total”. (The Laffer Curve: a non-functional tax policy.) Unit 12: Functions 15 Unit 12: Functions 17 Not a Function Function Terminology A function f:A  B maps values from its domain A to its co-domain B . Anne f(x) is called the image of x (under f ). Alan x is called the pre-image of f(x) (under f ). Steve 111 Paul 121 f Patrice 211 Karon George x B A y Unit 12: Functions Unit 12: Functions 19 21 3

  4. Trying out Terminology f(x) = x 2 What is the image of 16? PART 2 What is the range of f ? IN CLASS PAGES f(x) x Unit 12: Functions 23 Unit 12: Functions 25 Pre-Class Learning Goals Quiz 10  By the start of class, you should be able to:  In General:  Define the terms domain, co-domain, range, image, and pre- image  Specific issues:  Use appropriate function syntax to relate these terms (e.g., f : A → B indicates that f is a function mapping domain A to co-domain B).  Determine whether f : A → B is a function given a definition for f as an equation or arrow diagram. Unit 12: Functions Unit 12: Functions 26 27 4

  5. In-Class Learning Goals Outline  By the end of this unit, you should be able to:  Injective Functions  Define the terms injective (one-to-one), surjective (onto),  Surjective Functions bijective (one-to-one correspondence), and inverse.  Determine whether a given function is injective, surjective,  Bijective Functions and/or bijective.  Determine whether the inverse of a given function is a  Inverse Operations. function. Unit 12: Functions 28 Unit 12: Functions 29 Injective Functions Trying out Terminology f: R  R 0 Some special types of functions: f(x) = x 2  A function f : A → B is injective (one-to-one) if Injective? ∀ x ∈ A, ∀ y ∈ A, x ≠ y → f(x) ≠ f(y). What if f: R 0  R 0 ?  In the arrow diagram: at most one arrow points to each f(x) element of B. Not injective: f(George) = f(Steve) Injective CPSC 110/201 George CPSC 110 George CPSC 121/202 Steve CPSC 121 Steve CPSC 121/203 Gail CPSC 210 Neil CPSC 210/BCS Kimberly CPSC 310 Kimberly CPSC 310 x Neil CPSC 319 Gail CPSC 319 R 0 , Z 0 are the sets of non-negative real, integer numbers Unit 12: Functions Unit 12: Functions 30 31 5

  6. Trying out Terminology Trying out Terminology f(x) = |x| (the absolute value of x ) f:{s|s is a 121 student}  {A+, A, …, D, F} Injective? f(s ) = s’s mark in 121 a. Yes, if f: R  R 0 b. Yes, if f: R 0  R c. Yes, for some other domain/co-domain Is f injective? d. No, not for any domain/co-domain a. Yes e. None of these is correct b. No f(x) c. Not enough information x Unit 12: Functions 32 Unit 12: Functions 33 Trying out Terminology Outline  f:{s|s is a 121 student}  {A+, A, …, D,  Injective Functions F}  Surjective Functions  What if we didn’t know what f represented, only its “type” and the fact that there are 300 CPSC 121  Bijective Functions students:  Inverse Operations. Is f injective? a. Yes b. No c. Not enough information Unit 12: Functions Unit 12: Functions 34 35 6

  7. Surjective Functions Trying out Terminology  A function f : A → B is surjective (onto) if f: R  R 0 ∀ y ∈ B, ∃ x ∈ A, f(x) = y. f(x) = x 2 Can we define it in terms of range and co-domain? f(x) Surjective?  In the arrow diagram: at least one arrow points to each element of B. What if f: R  R ? What if f: Z  Z 0 ? Surjective Not Surjective George CPSC 121/202 George Steve CPSC 121 Steve CPSC 121/203 Gail CPSC 210 x Neil CPSC 210/BCS Kimberly CPSC 310 Kimberly CPSC 310 Neil CPSC 319 CPSC 319 R 0 , Z 0 are the sets of non-negative real, integer numbers Unit 12: Functions 36 Unit 12: Functions 37 Trying out Terminology Trying out Terminology f:{s|s is a 121 student}  {A+, A, …, D, F} f(x) =  x  Is f surjective? f(s ) = s’s mark in 121 f(x) a. Yes, for f: R  R 0 ? b. Yes, for f: R 0  R ?  Is f surjective? c. Yes, for f: R  Z ? a. Yes d. No, not for any b. No domain/co-domain c. Not enough information x e. None of these  Could we ever know that f was surjective just by knowing is correct f ’s domain and co -domain? Unit 12: Functions Unit 12: Functions 38 39 7

  8. Surjective Functions So Far Hash Functions  Which combinational circuits with one output are surjective?  A hash function maps its input onto the indexes of an array so we can store arbitrary data in an array Every such circuit. a. e.g. h(x ) = x mod k b. Any such circuit that represents a contingency where k is the array size (neither a tautology nor contradiction). c. Only the ones equivalent to an inverter.  If it’s not surjective , then we “waste” entries in the No such circuit is surjective. d. array that are never mapped to! None of these is correct. e. Unit 12: Functions 40 Unit 12: Functions 41 Outline Bijective Functions  A function f : A → B is bijective (also one-to-one  Injective Functions correspondence) if it is both one-to-one and onto (both  Surjective Functions injective and surjective).  In the arrow diagram: exactly one arrow points to each  Bijective Functions element of B.  Inverse Operations. Not Bijective either Not Bijective CPSC 110/201 George George CPSC 121/202 Steve CPSC 121 Steve CPSC 121/203 Gail CPSC 210 Neil CPSC 210/BCS Kimberly CPSC 310 Kimberly CPSC 310 Neil CPSC 319 CPSC 319 Unit 12: Functions Unit 12: Functions 42 43 8

  9. Bijective Functions Trying out Terminology  This is bijective f(x) = x 2 f:?  ? Bijective f(x) Bijective for what Steve CPSC 121 domain/co-domain? Gail CPSC 210 Kimberly CPSC 310 Neil CPSC 319 x Unit 12: Functions 44 Unit 12: Functions 45 Outline Inverse of a Function  The inverse of a function f: A → B, denoted f -1 , is  Injective Functions f -1 :B  A .  Surjective Functions f -1 (y) = x  f(x) = y .  Bijective Functions  In other words:  Inverse Operations.  If we think of a function as a list of pairs. E.g. f(x) = x 2 : { (1, 1), (2, 4), (3, 9), (4, 16), ... }  Then f -1 is obtained by swapping the elements of each pair: f -1 = { (1, 1), (4, 2), (9, 3), (16, 4), ... } Unit 12: Functions Unit 12: Functions 46 47 9

  10. Inverse of a Function Trying out Terminology  Is f -1 a function? What’s the inverse of each of these f s? A. Yes, always. B. No, never. Alan Alan 121/202 111 George George C. Yes, but only if f is injective. 121/203 121 Paul Paul 121/BCS D. Yes, but only if f is surjective. Steve Steve 211 211/201 Karon Karon E. Yes, but only if f is bijective. 211/202 Patrice Patrice 211/BCS  Can we prove it? Unit 12: Functions 48 Unit 12: Functions 49 Trying out Terminology Appendix 3: An Inverse Proof  Theorem : If f : A  B is bijective, then f(x) = x 2 f -1 : B  A is a function. What’s the inverse of f ?  Proof: We proceed by antecedent assumption. f(x)  Assume f : A  B is bijective. What should the  Consider an arbitrary element y of B . domain/co-domain be? Because f is surjective, there is some x in A such that f(x) = y . Because f is injective, that is the only such x .  f -1 (y) = x by definition; so, f -1 maps every x element of B to exactly one element of A . QED Unit 12: Functions Unit 12: Functions 50 53 10

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend