1 / 60

CPSC 121: Models of Computation 2011 Winter Term 1

CPSC 121: Models of Computation 2011 Winter Term 1. Functions Steve Wolfman, based on notes by Patrice Belleville and others. Outline. Prereqs, Learning Goals, and Quiz Notes Functions as “Computation Abstractions” Terminology (out-of-class) Properties: Injective, Surjective, Bijective

Download Presentation

CPSC 121: Models of Computation 2011 Winter Term 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CPSC 121: Models of Computation2011 Winter Term 1 Functions Steve Wolfman, based on notes by Patrice Belleville and others

  2. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  3. Learning Goals: Pre-Class By the start of class, you should be able to: • Define the terms domain, co-domain, range, image, and pre-image • 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.

  4. Learning Goals: In-Class By the end of this unit, you should be able to: • Define the terms injective (one-to-one), surjective (onto), bijective (one-to-one correspondence), and inverse. • Determine whether a given function is injective, surjective, and/or bijective. • Apply your proof skills to proofs about the properties (e.g., injectiveness, surjectiveness, bijectiveness, and function-ness) of functions and their inverses. Discuss point of learning goals.

  5. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  6. What is this? data1 output data2 control

  7. What is this? data1 output data2 control

  8. What is this? data1 output data2 control

  9. data1 output data2 control What is this? In the lab, you implemented a multiplexer and then used it as a piece in larger circuits. You abstracted from the concrete implementation to a description of its function: f(control, data1, data2) = output= (~control  data1)  (control  data2) = data1 if control is 0, but data2 otherwise

  10. Functions, Abstraction, and CPSC 121 Computer scientists use many abstraction levels, with reasoning and execution tools at each level. In 121, we encounter abstraction levels like: wiring physical gates, computer-based hardware design techniques, propositional logic, predicate logic, sets, … Functions are a model that let us talk about how computations work and fit together. Bonus: functions alone are enough for all of computation, using the “λ calculus”.

  11. Functions We’ve Used • Any combinational logic circuit • Lists, as long as they’re immutable (unchangeable): A(i) = the ith value in A. • The Power Set operation (mapping a set to another set) • Addition, subtraction, multiplication, ... Sequential circuits and mutable lists aren’t functions. Why not?(Actually we can model them as functions by making time explicit)

  12. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  13. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) What is a Function? Mostly, a function is what you learned it was all through K-12 mathematics, with strange vocabulary to make it more interesting… A functionf:A  Bmaps values from its domainA to its co-domainB. DomainCo-domain f(x) = x3 f(x) = x mod 4 f(x) = x Look, sets!

  14. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) Plotting Functions f(x) = x3 f(x) = x mod 4 f(x) = x Not every function is easy to plot!

  15. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) What is a Function? Not every function has to do with numbers… A functionf:A  Bmaps values from its domainA to its co-domainB. DomainCo-domain f(x) = ~x f(x,y) = x  y f(x) = x’s phone #

  16. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) What is a Function? A functionf:A  Bmaps values from its domainA to its co-domainB. f(control, data1, data2)= (~control  data1)  (control  data2) Domain? Co-domain?

  17. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) What is a Function? A functionf:A  Bmaps values from its domainA to its co-domainB. Domain? Co-domain? Alan Steve 111 121 Paul 211 Patrice Karon George Other examples?

  18. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) What is a Function? A functionf:A  Bmaps values from its domainA to its co-domainB. f can’t map one element of its domain to more than one element of its co-domain: x  A, y1,y2  B, [(f(x) = y1)  (f(x) = y2)]  (y1 = y2). Why insist on this? f A B

  19. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) Not a Function Why isn’t this a function? (The Laffer Curve: a non-functional tax policy.)

  20. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) Function Terminology A functionf:A  Bmaps values from its domainA to its co-domainB. For f to be a function, it must map every element in its domain: x  A, y  B, f(x) = y. Why insist on this? f A B Warning: some mathematicians would say that makes f “total”.

  21. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) Not a Function Anne Alan Steve 111 121 Paul 211 Patrice Karon George Foiled by sabbatical.

  22. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) Function Terminology A functionf:A  Bmaps values from its domainA to its co-domainB. f(x) is called the image of x (under f). x is called the pre-image of f(x) (under f). f A B x y

  23. CORRESPONDS TO TEXTBOOK READING(NOT COVERED IN CLASS) Trying out Terminology f(x) = x2 What is the image of 16? What is the range of f? f(x) x

  24. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  25. Function Properties: Injective A function f:A  B is injective (also one-to-one) if each image is associated with at most one pre-image: xA, yA, xy  f(x)  f(y). Injective? Injective? 111 Alan Alan 121/202 Steve Steve 111 121/203 121 Paul Paul 121/BCS 211 Patrice Patrice 211/201 Karon Karon 211/202 George George 211/BCS

  26. Trying out Terminology f(x) = x2 Injective? What if f:R+ R+? f(x) x

  27. Trying out Terminology • f(x) = |x| (the absolute value of x) • Injective? • Yes, if f:R R+ • Yes, if f:R+ R • Yes, for some other domain/co-domain • No, not for any domain/co-domain • None of these is correct f(x) x

  28. Trying out Terminology • f:{s|s is a 121 student}  {A+, A, …, D, F} • f(s) = s’s mark in 121 • Is f injective? • Yes • No • Not enough information

  29. Trying out Terminology • f:{s|s is a 121 student}  {A+, A, …, D, F} • f(s) = s’s mark in 121 • What if we didn’t know what f represented, only its “type” and the fact that there are lots of 121 students: • f:{s|s is a 121 student}  {A+, A, …, D, F} • Is f injective? • Yes • No • Not enough information

  30. Nifty Injective Function: Error-Detecting Codes Error-detecting codes must be injective. Why?

  31. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  32. Function Properties: Surjective f:A  B is surjective (also onto) if every element of the co-domain has a pre-image: y  B, x  A, y = f(x). Surjective? Surjective? 111 Alan Alan 121/202 Steve Steve 121/203 121 Paul Paul 121/BCS 211 Patrice Patrice 211/201 Karon Karon 211/202 George George 211/BCS Can we define “surjective” in terms of “range” and “co-domain”?

  33. Trying out Terminology f(x) = x2 f:R R0? Surjective? What if f:R R? What if f:Z Z0? f(x) x

  34. Trying out Terminology • f(x) = x • Is fsurjective? • Yes, for f:R R0? • Yes, for f:R0 R? • Yes, for f:R Z? • No, not for any domain/co-domain • None of these is correct f(x) x

  35. Trying out Terminology • f:{s|s is a 121 student}  {A+, A, …, D, F} • f(s) = s’s mark in 121 • Is fsurjective? • Yes • No • Not enough information • Could we ever know that f was surjective just by knowing f’s domain and co-domain?

  36. Trying out Terminology • Could we ever know that f was surjective just by knowing f’s domain and co-domain (and their cardinalities)? • Yes • No • Not enough information

  37. Nifty Surjective Function: Cryptographic Hash “Good” cryptographic hashes should be but don’t have to be surjective… but they must not be injective.

  38. Surjective Functions So Far Which combinational circuits with one output are surjective? • Every such circuit. • Any such circuit that represents a contingency (neither a tautology nor contradiction). • Only the ones equivalent to an inverter. • No such circuit is surjective. • None of these is correct.

  39. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  40. Function Properties: Bijective A function f:A  B is bijective (also one-to-one correspondence) if it is both one-to-one and onto (both injective and surjective). Every element in the domain has exactly one unique image. Every element in the co-domain has exactly one unique pre-image.

  41. Function Properties: Bijective A function f:A  B is bijective (also one-to-one correspondence) if it is both one-to-one and onto. Bijective? Bijective? Alan Alan 121/202 111 Steve Steve 121/203 121 Paul Paul 121/BCS 211 Patrice Patrice 211/201 Karon Karon 211/202 George George 211/BCS

  42. Trying out Terminology f(x) = x2 f:?  ? Bijective for what domain/co-domain? f(x) x

  43. Nifty Bijective Function: Encryption/Lossless Compression Two sets have the same cardinality if we can put them in a bijection. What does that say about lossless compression?

  44. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  45. Function Operations: Inverse The inverse of a function f:A  B is f-1:B  A. f(x) = y  f-1(y) = x. How can we tell whether f-1 is a function? (Hint: what would make f-1not a function?) Can we prove it?

  46. Trying out Terminology What’s the inverse of each of these fs? Alan Alan 121/202 111 Steve Steve 121/203 121 Paul Paul 121/BCS 211 Patrice Patrice 211/201 Karon Karon 211/202 George George 211/BCS

  47. Trying out Terminology f(x) = x2 What’s the inverse of f? What should the domain/co-domain be? f(x) x

  48. Outline • Prereqs, Learning Goals, and Quiz Notes • Functions as “Computation Abstractions” • Terminology (out-of-class) • Properties: Injective, Surjective, Bijective • Inverse Operation • Function Proofs • Next Lecture Notes

  49. Proving a function injective Recall: A function f : A  Bis injective exactly when: xA, yA, xy  f(x)  f(y). A typical approach is to prove the contrapositive by antecedent assumption: assume f(x) = f(y) and show that x = y.

  50. Problem: x3 + 5 is injective Theorem: f(x) = x3 + 5 is injective, where f : Z  Z.

More Related