CPSC 121: Models of Computation

Slides:



Advertisements
Similar presentations
Functions Reading: Epp Chp 7.1, 7.2, 7.4
Advertisements

Functions Rosen 1.8.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Functions Steve Wolfman, based on notes by Patrice Belleville and others 1.
Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Functions Steve Wolfman, based on notes by Patrice Belleville and others.
Discrete Math for CS Chapter 5: Functions. Discrete Math for CS New Relation Operations: Given R, a relation on A x B, we define the inverse relation,
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
10/26/20151 … and the following mathematical appetizer is about… Functions.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
MSU/CSE 260 Fall Functions Read Section 1.8.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
MATH 224 – Discrete Mathematics
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
FUNCTIONS.
Functions 7/7/2016COCS - Discrete Structures1. Functions A function f from a set A to a set B is an assignment of exactly one element of B to each element.
Russell’s Paradox Is W in W? In words, W is the set that contains all the sets that don’t contain themselves. If W is in W, then W contains itself. But.
Functions Goals Introduce the concept of function
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Relations, Functions, and Matrices
CPSC 121: Models of Computation 2011 Winter Term 1
CS 2210:0001 Discrete Structures Sets and Functions
Applied Discrete Mathematics Week 2: Functions and Sequences
CSE 20 – Discrete Mathematics
MATH 224 – Discrete Mathematics
Functions.
Chapter 2 Sets and Functions.
Relation and function.
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Chapter 3 Relation and Function Homework 4 For each of the following relations on set A = { 1,2,3,4 }, check each of them whether they are reflexive, irreflexive,
… and the following mathematical appetizer is about…
Functions.
Functions Section 2.3.
Lecture 7 Functions.
Functions.
Yet another important mathematical concept
CSE15 Discrete Mathematics 02/27/17
CS100: Discrete structures
… and the following mathematical appetizer is about…
Functions CS 202 Epp section 7.1.
CPSC 121: Models of Computation 2016W2
Functions.
Copyright © Cengage Learning. All rights reserved.
Functions.
Introduction to Relations and Functions
Ch 5 Functions Chapter 5: Functions
… and the following mathematical appetizer is about…
Functions Rosen 6th ed., §2.3.
SE-561 Math Foundations of Software Engineering VIII. Functions
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
One-to-One and Onto, Inverse Functions
One-to-One and Onto, Inverse Functions
CPSC 121: Models of Computation 2016W2
Functions.
Lecture # 18 Types of Functions
Functions Section 2.3.
Section 3.1 Functions.
Copyright © Zeph Grunschlag,
Presentation transcript:

CPSC 121: Models of Computation Unit 12: Functions

PART 1 review of Text Reading These pages correspond to text reading and are not covered in the lectures. Unit 12: Functions

What is a Function? f(x) = x3 f(x) = x mod 4 f(x) = x Mostly, a function is what you learned it was all through K-12 mathematics, with strange vocabulary to make it more interesting… A function f:A  B maps values from its domain A to its co-domain B. Domain Co-domain f(x) = x3 f(x) = x mod 4 f(x) = x Unit 12: Functions

Plotting Functions f(x) = x3 f(x) = x mod 4 f(x) = x Not every function is easy to plot! Unit 12: Functions

What is a Function? f(x) = ~x f(x,y) = x  y f(x) = x’s phone # Not every function has to do with numbers… A function f:A  B maps values from its domain A to its co-domain B. Domain Co-domain f(x) = ~x f(x,y) = x  y f(x) = x’s phone # Unit 12: Functions

What is a Function? 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? Unit 12: Functions

What is a Function? A function f:A  B maps values from its domain A to its co-domain B. Domain? Co-domain? Alan Steve 111 Paul 121 Patrice 211 Karon George Other examples? Unit 12: Functions

What is a Function? A function f:A  B maps values from its domain A to its co-domain B. 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 Unit 12: Functions

Why isn’t this a function? Not a Function Why isn’t this a function? Unit 12: Functions (The Laffer Curve: a non-functional tax policy.)

Function Terminology f A B x  A, y  B, f(x) = y. A function f:A  B maps values from its domain A to its co-domain B. 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”. Unit 12: Functions

Not a Function Anne Alan Steve 111 Paul 121 Patrice 211 Karon George Unit 12: Functions

Function Terminology f A B A function f:A  B maps values from its domain A to its co-domain B. 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 Unit 12: Functions

Trying out Terminology f(x) = x2 What is the image of 16? What is the range of f? f(x) x Unit 12: Functions

PART 2 In Class Pages Unit 12: Functions

Pre-Class Learning Goals 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. Unit 12: Functions

Quiz 10 In General: Specific issues: Unit 12: Functions

In-Class Learning Goals 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. Determine whether the inverse of a given function is a function. Unit 12: Functions

Outline Injective Functions Surjective Functions Bijective Functions Inverse Operations. Unit 12: Functions

Injective Functions Some special types of functions: A function f : A → B is injective (one-to-one) if ∀x ∈ A, ∀y ∈ A, x ≠ y → f(x) ≠ f(y). In the arrow diagram: at most one arrow points to each element of B. Not injective: f(George) = f(Steve) Injective CPSC 110/201 George CPSC 121/202 Steve CPSC 121/203 Neil CPSC 210/BCS Kimberly CPSC 310 Gail CPSC 319 George CPSC 110 Steve CPSC 121 Gail CPSC 210 Kimberly CPSC 310 Neil CPSC 319 Unit 12: Functions

Trying out Terminology f:R  R0 f(x) = x2 Injective? What if f:R0  R0? f(x) x R0, Z0 are the sets of non-negative real, integer numbers Unit 12: Functions

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

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 Unit 12: Functions

Trying out Terminology f:{s|s is a 121 student}  {A+, A, …, D, F} What if we didn’t know what f represented, only its “type” and the fact that there are 300 CPSC 121 students: Is f injective? Yes No Not enough information Unit 12: Functions

Outline Injective Functions Surjective Functions Bijective Functions Inverse Operations. Unit 12: Functions

Surjective Functions A function f : A → B is surjective (onto) if ∀y ∈ B, ∃x ∈ A, f(x) = y. Can we define it in terms of range and co-domain? In the arrow diagram: at least one arrow points to each element of B. Not Surjective Surjective George CPSC 121/202 Steve CPSC 121/203 Neil CPSC 210/BCS Kimberly CPSC 310 CPSC 319 George Steve CPSC 121 Gail CPSC 210 Kimberly CPSC 310 Neil CPSC 319 Unit 12: Functions

Trying out Terminology f:R  R0 f(x) = x2 Surjective? What if f:R  R? What if f:Z  Z0? f(x) x R0, Z0 are the sets of non-negative real, integer numbers Unit 12: Functions

Trying out Terminology f(x) = x Is f surjective? 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 Unit 12: Functions

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

Hash Functions A hash function maps its input onto the indexes of an array so we can store arbitrary data in an array e.g. h(x ) = x mod k where k is the array size If it’s not surjective, then we “waste” entries in the array that are never mapped to! A hash function maps its input onto the indexes of an array so we can store arbitrary data in an array. If it’s not surjective, then we “waste” entries in the array that are never mapped to! Of course, if it’s not injective, then we have a different kind of trouble! Old example: Lossy compression maps a file to another, hopefully smaller file. It’s “lossy” in the sense that the original can’t necessarily be uniquely extracted after compression (so, NOT injective). It’s handy if it’s surjective (or close to it), since if it is NOT surjective, then it “wastes” encodings, forcing the encodings that are actually used to be longer and decreasing the amount of compression. Unit 12: Functions

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. Unit 12: Functions

Outline Injective Functions Surjective Functions Bijective Functions Inverse Operations. Unit 12: Functions

Bijective Functions 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). In the arrow diagram: exactly one arrow points to each element of B. Not Bijective CPSC 110/201 Not Bijective either George CPSC 121/202 Steve CPSC 121/203 Neil CPSC 210/BCS Kimberly CPSC 310 CPSC 319 George Steve CPSC 121 Gail CPSC 210 Kimberly CPSC 310 Neil CPSC 319 Unit 12: Functions

Bijective Functions This is bijective Bijective Steve CPSC 121 Gail Kimberly CPSC 310 Neil CPSC 319 Unit 12: Functions

Trying out Terminology f(x) = x2 f:?  ? Bijective for what domain/co-domain? f(x) x Unit 12: Functions

Outline Injective Functions Surjective Functions Bijective Functions Inverse Operations. Unit 12: Functions

Inverse of a Function The inverse of a function f: A → B, denoted f -1, is f-1:B  A. f-1(y) = x  f(x) = y . In other words: If we think of a function as a list of pairs. E.g. f(x) = x2 : { (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

Inverse of a Function Is f -1 a function? Can we prove it? Yes, always. No, never. Yes, but only if f is injective. Yes, but only if f is surjective. Yes, but only if f is bijective. Can we prove it? E Unit 12: Functions

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

Trying out Terminology f(x) = x2 What’s the inverse of f? What should the domain/co-domain be? f(x) x Unit 12: Functions

Appendix 3: An Inverse Proof Theorem: If f : A  B is bijective, then f-1 : B  A is a function. Proof: We proceed by antecedent assumption. Assume f : A  B is bijective. Consider an arbitrary element y of B. 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 element of B to exactly one element of A. QED Unit 12: Functions