
Today’s topics On to section 1.8… Functions • Functions • From calculus, you are familiar with the – Notations and terms – One-to-One vs. Onto concept of a real-valued function f, – Floor, ceiling, and identity which assigns to each number xR a particular value y=f(x), where yR. • Reading: Sections 1.8 • But, the notion of a function can also be • Upcoming – Algorithms naturally generalized to the concept of assigning elements of any set to elements of any set. (Also known as a map.) CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.1 4.2 Function: Formal Definition Graphical Representations • For any sets A, B, we say that a function f • Functions can be represented graphically in from (or “mapping”) A to B (f:AB) is a several ways: particular assignment of exactly one f AB element f(x)B to each element xA. • • f • • ••• y • Some further generalizations of this idea: a b • • – A partial (non-total) function f assigns zero or • • x one elements of B to each element xA. A B Bipartite Graph Plot – Functions of n arguments; relations (ch. 6). Like Venn diagrams CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.3 4.4 Functions We’ve Seen So Far A Neat Trick • A proposition can be viewed as a function • Sometimes we write YX to denote the set F from “situations” to truth values {T,F} of all possible functions f:XY. – A logic system called situation theory. • This notation is especially appropriate, |X| – p=“It is raining.”; s=our situation here,now because for finite X, Y, we have |F| = |Y| . – p(s){T,F}. • If we use representations F0, T1, 2: {0,1}={F,T}, then a subset TS is just a • A propositional operator can be viewed as function from S to 2, so the power set of S a function from ordered pairs of truth (set of all such fns.) is 2S in this notation. values to truth values: e.g., ((F,T)) = T. Another example: ((T,F)) = F. CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.5 4.6 Some Function Terminology Range versus Codomain • If it is written that f:AB, and f(a)=b • The range of a function might not be its (where aA & bB), then we say: whole codomain. – A is the domain of f. We also say • The codomain is the set that the function is – B is the codomain of f. – B is the codomain of f. the signature declared to map all domain values into. – b is the image of a under f. of f is AB. – a is a pre-image of b under f. • The range is the particular set of values in • In general, b may have more than 1 pre-image. the codomain that the function actually – The range RB of f is R={b | a f(a)=b }. maps elements of the domain to. CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.7 4.8 Range vs. Codomain - Example Operators (general definition) • Suppose I declare to you that: “f is a • An n-ary operator over (or on) the set S is function mapping students in this class to any function from the set of ordered n- the set of grades {A,B,C,D,E}.” tuples of elements of S, to S itself. • At this point, you know f’s codomain is: • E.g., if S={T,F}, ¬ can be seen as a unary __________, and its range is ________. operator, and , are binary operators on S. • Suppose the grades turn out all As and Bs. • Another example: and are binary • Then the range of f is _________, but its operators on the set of all sets. codomain is __________________. CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.9 4.10 Constructing Function Operators Function Operator Example • If • (“dot”) is any operator over B, then we • +, (“plus”,“times”) are binary operators can extend • to also denote an operator over R. (Normal addition & multiplication.) over functions f:AB. • Therefore, we can also add and multiply • E.g.: Given any binary operator •:BBB, functions f,g:RR: and functions f,g:AB, we define – (f + g):RR, where (f + g)(x) = f(x) + g(x) (f • g):AB to be the function defined by: – (f g):RR, where (f g)(x) = f(x) g(x) aA, (f • g)(a) = f(a)•g(a). CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.11 4.12 Function Composition Operator Images of Sets under Functions Note match here. • For functions g:AB and f:BC, there is a • Given f:AB, and SA, special operator called compose (“”). • The image of S under f is simply the set of – It composes (creates) a new function out of f all images (under f) of the elements of S. and g by applying f to the result of applying g. f(S) : {f(s) | sS} – We say (fg):AC, where (fg)(a) : f(g(a)). : {b | sS: f(s)=b}. – Note g(a)B, so f(g(a)) is defined and C. • Note the range of f can be defined as – Note that (like Cartesian , but unlike +,, simply the image (under f) of f’s domain! ) is non-commuting. (Generally, fg gf.) CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.13 4.14 One-to-One Functions One-to-One Illustration • A function is one-to-one (1-1), or injective, or an injection, iff every • Bipartite (2-part) graph representations of element of its range has only 1 pre-image. – Formally: given f:AB, functions that are (or not) one-to-one: “x is injective” : (¬x,y: xy f(x)=f(y)). • Only one element of the domain is mapped to any given one element • • • • of the range. • • • • • • • – Domain & range have same cardinality. What about codomain? • • • • • • • Memory jogger: Each element of the domain is injected into a • • • • • • • different element of the range. • – Compare “each dose of vaccine is injected into a different patient.” • • – Compare “each dose of vaccine is injected into a different patient.” Not one-to-one Not even a One-to-one function! CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.15 4.16 Sufficient Conditions for 1-1ness Onto (Surjective) Functions • For functions f over numbers, we say: • A function f:AB is onto or surjective or a – f is strictly (or monotonically) increasing iff surjection iff its range is equal to its x>y f(x)>f(y) for all x,y in domain; codomain (bB, aA: f(a)=b). – f is strictly (or monotonically) decreasing iff • Think: An onto function maps the set A x>y f(x)<f(y) for all x,y in domain; onto (over, covering) the entirety of the set • If f is either strictly increasing or strictly B, not just over a piece of it. 3 decreasing, then f is one-to-one. E.g. x • E.g., for domain & codomain R, x3 is onto, – Converse is not necessarily true. E.g. 1/x whereas x2 isn’t. (Why not?) CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.17 4.18 Illustration of Onto Bijections • Some functions that are, or are not, onto • A function f is said to be a one-to-one their codomains: correspondence, or a bijection, or reversible, or invertible, iff it is • • • • • • • • • both one-to-one and onto. • • • • • • • • • • • For bijections f:AB, there exists an • • • • • • • • inverse of f, written f 1:BA, which is the • • • • • • • • unique function such that 1 Onto Not Onto Both 1-1 1-1 but unique function such that f o f = I A (but not 1-1) (or 1-1) and onto not onto – (where IA is the identity function on A) CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.19 4.20 The Identity Function Identity Function Illustrations • For any domain A, the identity function I:A • The identity function: A (variously written, IA, 1, 1A) is the unique function such that aA: I(a)=a. • Some identity functions you’ve seen: • • • y y = I(x) = x – +ing 0, ·ing by 1, ing with T, ing with F, • • ing with , ing with U. • • • Note that the identity function is always • • both one-to-one and onto (bijective). Domain and range x CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.21 4.22 Graphs of Functions Aside About Representations • We can represent a function f:AB as a set of • It is possible to represent any type of discrete structure (propositions, bit-strings, ordered pairs {(a,f(a)) | aA}. The function’s graph. numbers, sets, ordered pairs, functions) in • Note that a, there is only 1 pair (a,b). terms of virtually any of the other structures (or some combination thereof). – Later (ch.6): relations loosen this restriction. structures (or some combination thereof). • Probably none of these structures is truly • For functions over numbers, we can represent more fundamental than the others an ordered pair (x,y) as a point on a plane. (whatever that would mean). However, – A function is then drawn as a curve (set of points), strings, logic, and sets are often used as with only one y for each x. the foundation for all else. E.g. in CompSci 102 © Michael Frank CompSci 102 © Michael Frank 4.23 4.24 A Couple of Key Functions Visualizing Floor & Ceiling • In discrete math, we will frequently use the • Real numbers “fall to their floor” or “rise to following two functions over real numbers: their ceiling.” 3 1.6=2 2 .
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages7 Page
-
File Size-