CPSC 121: Models of Computation 2016W2

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.
Functions Section 2.3 of Rosen Fall 2008
Great Theoretical Ideas in Computer Science.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Functions Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 DFAs in Depth Benjamin Israel Notes heavily borrowed from Steve Wolfman’s,
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 12 Number theory Mathematical induction Proof by induction Examples.
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.
Index FAQ Advanced Calculus Lecture for first year by Nguyen Xuan Hung.
 Let A and B be any sets A binary relation R from A to B is a subset of AxB Given an ordered pair (x, y), x is related to y by R iff (x, y) is in R. This.
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
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,
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
Math 344 Winter 07 Group Theory Part 2: Subgroups and Isomorphism
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
1 Melikyan/DM/Fall09 Discrete Mathematics Ch. 7 Functions Instructor: Hayk Melikyan Today we will review sections 7.3, 7.4 and 7.5.
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.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
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.
Sequences Lecture 11. L62 Sequences Sequences are a way of ordering lists of objects. Java arrays are a type of sequence of finite size. Usually, mathematical.
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]
Morgan Kaufmann Publishers
The Acceptance Problem for TMs
Relations, Functions, and Matrices
CPSC 121: Models of Computation 2008/9 Winter Term 2
CPSC 121: Models of Computation 2011 Winter Term 1
CPSC 121: Models of Computation 2012 Summer Term 2
CS 2210:0001 Discrete Structures Sets and Functions
Applied Discrete Mathematics Week 2: Functions and Sequences
MATH 224 – Discrete Mathematics
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Cardinality of Sets Section 2.5.
Functions Defined on General Sets
… and the following mathematical appetizer is about…
Functions.
Sets Set Identities Sets and propositional logic have some similar properties In fact both are forms of boolean algebra Compare Set Identities table (p.
Lecture 7 Functions.
Functions.
Yet another important mathematical concept
Propositional Logic Defining Propositional Logic
… and the following mathematical appetizer is about…
Functions CS 202 Epp section 7.1.
CPSC 121: Models of Computation 2013W2
CPSC 121: Models of Computation 2016W2
A Brief Summary for Exam 1
Functions.
Copyright © Cengage Learning. All rights reserved.
Introduction to Relations and Functions
Ch 5 Functions Chapter 5: Functions
Copyright © Cengage Learning. All rights reserved.
College Algebra Fifth Edition
… 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.
CPSC 121: Models of Computation
CPSC 121: Models of Computation
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Copyright © Zeph Grunschlag,
Presentation transcript:

CPSC 121: Models of Computation 2016W2 Functions Steve Wolfman, based on notes by Patrice Belleville and others TODO (future terms): update term

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

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.

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.

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

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 abstracted computations work and fit together. Bonus: functions alone are enough for all of computation, using the “λ calculus”.

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)

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

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 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 Look, sets!

Plotting Functions f(x) = x3 f(x) = x mod 4 f(x) = x 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!

What is a Function? Not every function has to do with numbers… CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) What is a Function? 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 #

CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 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?

CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 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?

CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) 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

Why isn’t this a function? 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.)

Function Terminology f A B CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) Function Terminology 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”.

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

Function Terminology f A B CORRESPONDS TO TEXTBOOK READING (NOT COVERED IN CLASS) Function Terminology 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

Trying out Terminology 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

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

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 Paul 121/BCS Paul 121 Patrice Patrice 211 211/201 Karon Karon 211/202 George George 211/BCS

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

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

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

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: Is f injective? Yes No Not enough information

Nifty Injective Function: Error-Detecting Codes An error-detecting code encodes a normal number (or text) as a longer number (or text) in such a way that a small error in transcribing the encoded value will obviously not be a result of the code’s function (and furthermore, for error-correcting codes, will be “closer” to one particular valid code than any other). If it were not injective, then applying it would conflate two of the inputs, causing exactly the sort of error/confusion that the code is intended to avoid! Error-detecting codes must be injective. Why?

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

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 Paul 121 121/BCS Paul Patrice Patrice 211 211/201 Karon Karon 211/202 George George 211/BCS Can we define “surjective” in terms of “range” and “co-domain”?

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

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

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?

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

Nifty Surjective Function: Cryptographic Hash 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. “Good” cryptographic hashes should be but don’t have to be surjective… but they must not be injective.

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.

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

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.

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 Paul Paul 121 121/BCS Patrice Patrice 211 211/201 Karon Karon 211/202 George George 211/BCS

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

Nifty Bijective Function: Encryption/Lossless Compression What it says is that if lossless compression actually compresses some of the time, there must be other cases where it fails to compress (since it’s mapping bijectively from one domain (legal files) to the same domain). Try compressing things like executables, JPEG images, and already-compressed files, and you’ll see what we mean! (these compress poorly and sometimes actually expand.. Although many compression programs will simply not perform the compression if the file would expand.) Two sets have the same cardinality if we can put them in a bijection. What does that say about lossless compression?

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

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-1 not a function?) Can we prove it?

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

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

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

Proving a function injective Recall: A function f : A  B is 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.

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

Proving a function surjective Recall: A function f : A  B is surjective exactly when: y  B, x  A, y = f(x). That existential gives us a lot of freedom to pick a witness! A typical approach is to “solve for” the necessary x given a y.

Problem: w + 2z is surjective Theorem: f(w,z) = w + 2z is surjective, where f : (Z  Z)  Z.

Proving a function bijective Prove that it’s injective. Prove that it’s surjective. Done.

Proving a function has an inverse Prove that it’s bijective. Done.

An Inverse Proof Theorem: If f:A  B is bijective, then f-1 : B  A is a function. Recall that f-1(f(x)) = x.

Aside: Functions are Just Sets We can define functions in terms of sets and tuples (and we can define tuples in terms of sets!). The function f:A  B is the set {(x, f(x)) | x  A}. f is a subset of A  B!

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

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.

Learning Goals: “Pre-Class” (REPEAT) The pre-class goals are to be able to: Trace the operation of a deterministic finite-state automaton (represented as a diagram) on an input, including indicating whether the DFA accepts or rejects the input. Deduce the language accepted by a simple DFA after working through multiple example inputs.

Extra Slides…