CM10196 Topic 4: Functions and Relations

Similar documents
Lecture 3: Equivalence Relations

Coalgebra, Lecture 15: Equations for Deterministic Automata

Parse trees, ambiguity, and Chomsky normal form

378 Relations Solutions for Chapter 16. Section 16.1 Exercises. 3. Let A = {0,1,2,3,4,5}. Write out the relation R that expresses on A.

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Improper Integrals. The First Fundamental Theorem of Calculus, as we ve discussed in class, goes as follows:

2.4 Linear Inequalities and Interval Notation

Vectors , (0,0). 5. A vector is commonly denoted by putting an arrow above its symbol, as in the picture above. Here are some 3-dimensional vectors:

Infinite Geometric Series

Homework 3 Solutions

Bases for Vector Spaces

CMPSCI 250: Introduction to Computation. Lecture #31: What DFA s Can and Can t Do David Mix Barrington 9 April 2014

Convert the NFA into DFA

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

Things to Memorize: A Partial List. January 27, 2017

Lecture 2e Orthogonal Complement (pages )

Riemann Sums and Riemann Integrals

8. Complex Numbers. We can combine the real numbers with this new imaginary number to form the complex numbers.

Minimal DFA. minimal DFA for L starting from any other

Riemann Sums and Riemann Integrals

set is not closed under matrix [ multiplication, ] and does not form a group.

The area under the graph of f and above the x-axis between a and b is denoted by. f(x) dx. π O

Analytically, vectors will be represented by lowercase bold-face Latin letters, e.g. a, r, q.

Designing finite automata II

1 Nondeterministic Finite Automata

Formal Languages and Automata

Definite Integrals. The area under a curve can be approximated by adding up the areas of rectangles = 1 1 +

Lecture 3. In this lecture, we will discuss algorithms for solving systems of linear equations.

Nondeterminism and Nodeterministic Automata

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

The Evaluation Theorem

AUTOMATA AND LANGUAGES. Definition 1.5: Finite Automaton

Recitation 3: More Applications of the Derivative

CS 373, Spring Solutions to Mock midterm 1 (Based on first midterm in CS 273, Fall 2008.)

Review of Gaussian Quadrature method

Strong Bisimulation. Overview. References. Actions Labeled transition system Transition semantics Simulation Bisimulation

Farey Fractions. Rickard Fernström. U.U.D.M. Project Report 2017:24. Department of Mathematics Uppsala University

Handout: Natural deduction for first order logic

CS 310 (sec 20) - Winter Final Exam (solutions) SOLUTIONS

Regular Language. Nonregular Languages The Pumping Lemma. The pumping lemma. Regular Language. The pumping lemma. Infinitely long words 3/17/15

10. AREAS BETWEEN CURVES

Designing Information Devices and Systems I Spring 2018 Homework 7

Continuous Random Variables Class 5, Jeremy Orloff and Jonathan Bloom

7.2 The Definite Integral

Chapter Five: Nondeterministic Finite Automata. Formal Language, chapter 5, slide 1

CS103B Handout 18 Winter 2007 February 28, 2007 Finite Automata

Surface maps into free groups

Lecture 2 : Propositions DRAFT

Properties of Integrals, Indefinite Integrals. Goals: Definition of the Definite Integral Integral Calculations using Antiderivatives

CSE396 Prelim I Answer Key Spring 2017

The Regulated and Riemann Integrals

Quadratic Forms. Quadratic Forms

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

CSCI 340: Computational Models. Kleene s Theorem. Department of Computer Science

4 VECTORS. 4.0 Introduction. Objectives. Activity 1

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. Comparing DFAs and NFAs (cont.) Finite Automata 2

MAT 215: Analysis in a single variable Course notes, Fall Michael Damron

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

20 MATHEMATICS POLYNOMIALS

Matrix Algebra. Matrix Addition, Scalar Multiplication and Transposition. Linear Algebra I 24

7.1 Integral as Net Change and 7.2 Areas in the Plane Calculus

Types of Finite Automata. CMSC 330: Organization of Programming Languages. Comparing DFAs and NFAs. NFA for (a b)*abb.

Closure Properties of Regular Languages

, if x 1 and f(x) = x, if x 0.

Finite-State Automata: Recap

Chapter 0. What is the Lebesgue integral about?

CMSC 330: Organization of Programming Languages

MTH 505: Number Theory Spring 2017

Section 6: Area, Volume, and Average Value

Lecture 6. Notes. Notes. Notes. Representations Z A B and A B R. BTE Electronics Fundamentals August Bern University of Applied Sciences

First Midterm Examination

Linear Systems with Constant Coefficients

Math 4310 Solutions to homework 1 Due 9/1/16

p-adic Egyptian Fractions

Resources. Introduction: Binding. Resource Types. Resource Sharing. The type of a resource denotes its ability to perform different operations

expression simply by forming an OR of the ANDs of all input variables for which the output is

A study of Pythagoras Theorem

A negative answer to a question of Wilke on varieties of!-languages

Linear Inequalities. Work Sheet 1

Regular expressions, Finite Automata, transition graphs are all the same!!

and that at t = 0 the object is at position 5. Find the position of the object at t = 2.

Symbolic enumeration methods for unlabelled structures

Intuitionistic Fuzzy Lattices and Intuitionistic Fuzzy Boolean Algebras

First Midterm Examination

Bridging the gap: GCSE AS Level

MA123, Chapter 10: Formulas for integrals: integrals, antiderivatives, and the Fundamental Theorem of Calculus (pp.

Unit #9 : Definite Integral Properties; Fundamental Theorem of Calculus

Finite Automata. Informatics 2A: Lecture 3. Mary Cryan. 21 September School of Informatics University of Edinburgh

UNIFORM CONVERGENCE. Contents 1. Uniform Convergence 1 2. Properties of uniform convergence 3

Finite Automata. Informatics 2A: Lecture 3. John Longley. 22 September School of Informatics University of Edinburgh

1 Probability Density Functions

Lecture 2: Fields, Formally

7. Indefinite Integrals

Riemann is the Mann! (But Lebesgue may besgue to differ.)

(e) if x = y + z and a divides any two of the integers x, y, or z, then a divides the remaining integer

Finite Automata-cont d

Improper Integrals, and Differential Equations

List all of the possible rational roots of each equation. Then find all solutions (both real and imaginary) of the equation. 1.

Fundamentals of Computer Science

Special Numbers, Factors and Multiples

Transcription:

CM096 Topic 4: Functions nd Reltions Guy McCusker W. Functions nd reltions Perhps the most widely used notion in ll of mthemtics is tht of function. Informlly, function is n opertion which tkes n input vlue nd gives n output vlue. We cn (nd will) e more precise out this. From the computer science perspective, functions ply vitl role: much of wht we do when progrmming is writing code to compute prticulr function. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions / 6 Reltions A more generl notion thn function is tht of reltion. Roughly speking, reltion is something which provides n ssocition etween elements of sets. For instnce, on the set of ll people there is the reltion is in the sme fmily s. This reltion reltes two people (two elements of the set) exctly when those people re relted in the usul informl sense. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 3 / 6

Crtesin product of sets To mke precise definition of reltion, nd lter of function, we will mke use of the notion of Crtesin product of sets. The Crtesin product is used to tlk out pirs of things, one from one set nd one from nother. The Crtesin product of sets A nd B, written A B, is defined s the set of pirs {(x, y) x A y B}. The nottion (x, y) mens pir of elements: we sy tht (x, y) = (z, w) if nd only if x = z nd y = w. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 4 / 6 Crtesin product Exmple If A = {,, c} nd B = {0, } then A B is the set {(, 0), (, ), (, 0), (, ), (c, 0), (c, )}. If A = {x x is rel numer, 0 x } nd B = {x x is rel numer, x } then A B cn e thought of s rectngle in the plne whose corners (vertices) hve coordintes (0, ), (0, ), (, ) nd (, ). 3 If A is the set of students t Bth nd B is the set of cndidte numers, then A B is the set of ll possile student-cndidte numer pirs. The ctul mpping from students to their rel cndidte numers is suset of this. The ide of mpping eing suset of the Crtesin product is wht will underlie our forml definitions of reltion nd function. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 5 / 6 lert! You should y now e jumping up nd down nd pnicking out the possiility tht the nottion (, ) for pirs of things is not well-defined. Well, perhps not, ut it is question worth sking. Wht do we men y such pir? We certinly do not men two-element set: the pirs (0, ) nd (, 0) re supposed to e different, while the sets {0, } nd {, 0} re the sme. Rememer tht for sets, the vitl ingredient ws tht sets re equl when they contin the sme elements For pirs, the key is tht pirs re equl when they contin the sme elements, listed in the sme order. Tht is, (, ) = (c, d) = c = d. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 6 / 6

Forml definition of pirs It is proly resonle simply to ccept tht such pirs exist. However, if we were doing forml foundtions of mthemtics, we d hve to mke some kind of precise definition like: given elements nd, the pir (, ) is defined to e the set {{}, {, }}. If you re so inclined, you cn check tht this definition stisfies the requirement we lid out for pirs. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 7 / 6 Reltions Given two sets A nd B, reltion etween A nd B is suset of A B. Exmple If P is the set of ll people, nd D is the set of dys of the yer, then the set of pirs of the form (person, person s irthdy) is reltion etween P nd D. The set of pirs of the form (person, child of person) is reltion etween P nd itself. This sort of thing is clled inry reltion on P. 3 The reltion < is inry reltion on Z: it is defined y the set of pirs {(x, y) x Z, y Z, x < y}. We usully write x < y insted of (x, y) <, of course. 4 The reltion of equlity, =, is inry reltion on ny set. On the integers, for exmple, it is the set of pirs {(x, x) x Z}. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 8 / 6 Nottion The lst two exmples introduce useful piece of nottion: given reltion R etween A nd B, we often write R to men tht (, ) R. Red R s is relted to y R or something similr. For the cse of reltions like <,, = nd so on, this nottion is exctly wht we re used to. The reltion of equlity on ny set A is clled the identity reltion ecuse it reltes identicl things nd nothing else. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 9 / 6

Directed grphs A directed grph is structure contining: set V of vertices (lso clled nodes) set A of rcs (lso clled edges) where ech rc connects one vertex to nother, nd the direction of the rc is importnt. The vertex where n rc strts is its source; the vertex where it ends is its trget. Smll grphs cn redily e drwn s collections of dots (for the vertices) nd rrows etween the dots (for the rcs). G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 0 / 6 Directed grphs Here s picture of directed grph. In this cse, the nodes re the numers from to 6, nd there is n rc from one vertex to nother if nd only if the first numer divides the second. 4 5 3 6 G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions / 6 Directed grphs re reltions This kind of directed grph is relly the sme s inry reltion on set: the set of vertices is the set on which the reltion works the set of rcs defines set of pirs (, ) where is the source vertex of n rc nd is the trget vertex. The picture we drew on the previous slide descries the reltion { } (, ), (, ), (3, 3), (4, 4), (5, 5), (6, 6), (, ), (, 3), (, 4), (, 5), (, 6), (, 4), (, 6), (3, 6) which we could lterntively define s {(, ), Z, 6, 6, divides }. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions / 6

Other kinds of grphs While we re tlking out grphs, we should mention tht there re other kinds of grphs: undirected grphs, where the direction of n rc doesn t mtter lelled grphs, where rcs re lelled with some informtion grphs in which there cn e more thn one rc from one vertex to nother... G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 3 / 6 Grphs in computing Grphs re n importnt concept in computer science. They re useful for modelling gret mny things, for exmple rod or ril networks: vertex is plce, nd n rc is route from one plce to nother. If we lel the rcs with informtion out the time it tkes to trvel long n rc, then we cn sk questions like how long does it tke to get from Bker Street to Mornington Crescent? wht s the est wy to Turnhm Green? There re powerful lgorithms for discovering this kind of informtion from such grphs. If you re interested, look up Dijkstr s Algorithm. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 4 / 6 Clssifying reltions Looking t the picture of the divisiility reltion we drew ove: 4 5 3 we notice tht every node hs loop ttched to it: tht is, every element of the set is relted to itself. This is specil property of certin inry reltions, clled reflexivity. 6 G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 5 / 6

Clssifying reltions A inry reltion R on set A is reflexive if R for every A. Tht is to sy, every node hs loop ttched. Exmples of reflexive reltions include divides, reltion on the integers, lso on the integers lives t the sme ddress s, on the set of people the identity reltion on ny set. Other reltions, like <, never relte n element to itself: A inry reltion R is clled irreflexive if we do not hve R for ny A. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 6 / 6 Clssifying reltions Another property which some reltions possess is trnsitivity. On grphs, this is the property tht if you cn get from to (i.e. there s n rc connected to ) nd from to c, then there s n rc from to c. A inry reltion R on set A is clled trnsitive if whenever R nd R c, we lso hve R c. In picture: c Whenever the solid rcs exist, the dshed rc must lso exist. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 7 / 6 Exmples The following reltions re trnsitive: divides <, = nd is younger thn on the set of people is n ncestor of on the set of people The following re not trnsitive: is within 5 minutes drive of on the set of us stops on the Numer 8 route. et t home in the 006-7 footll seson, on the set of premiership footll tems. = on the set of integers. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 8 / 6

Clssifying reltions Another key property is symmetry: on grphs, this is the property tht if you cn get from to, you cn lso get ck from to. (Think of the difference etween one-wy nd two-wy streets.) A inry reltion R on set A is symmetric if whenever R we lso hve R. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 9 / 6 Exmples The following reltions re symmetric: =, the identity reltion on ny set is mrried to on the set of people These ones re not: < nd is younger thn on the set of people is n ncestor of on the set of people Question: do you expect tht the reltion is within five minutes drive of on numer 8 us stops is symmetric? G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 0 / 6 Clssifying reltions Another property, it like never hving symmetry, is ntisymmetry. A reltion R on set A is ntisymmetric if, whenever R nd R, it is the cse tht =. This sys tht the only entries in the reltion which cn e flipped round to yield new entry in the reltion re those of the form (, ). Exmples: is ntisymmetric: if nd then =. < is lso ntisymmetric: if < then we never hve < so there s nothing to check. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions / 6

Equivlence reltions We ve seen tht equlity is reltion (on ny set). We cn generlize this to cpture those reltions which ehve like equlity. They re clled equivlence reltions. A inry reltion R on set A is n equivlence reltion if it is reflexive trnsitive, nd symmetric. This sys tht notion of equivlence should stisfy every element is equivlent to itself if is equivlent to then is equivlent to if is equivlent to nd is equivlent to c then is equivlent to c. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions / 6 Exmple A key exmple of equivlence reltion is equlity modulo p for some numer p. Given integers m, n nd p, we define m = n mod p if there re integers, nd c, with 0 c < p such tht m = p + c n = p + c. Exercise Prove tht this is indeed n equivlence reltion. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 3 / 6 Equivlence reltions in computing Equivlence reltions ply n importnt role in computing, in mny wys. One wy is this. When progrmming, we often set up dt structures to represent informtion tht we re recording. For instnce, we might use n rry to collect together the nmes of students on course. Wht we relly cre out here is the set of nmes recorded in the rry: the order does not mtter. So multiple different rrys cn represent the sme informtion. We cn cpture this notion of representing the sme informtion with n equivlence reltion. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 4 / 6

Equivlence clsses We often use symols like for equivlence reltions. Given set A with n equivlence reltion, for every element A we define the equivlence clss of, written [], s the set { A }. Notice tht we lwys hve [] nd if then [] = []. (Check tht these fcts relly re fcts.) G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 5 / 6 Equivlence clsses: exmple Let S e the set of students on this course. Define n equivlence reltion such tht if nd only if nd re in the sme tutor group. Then [] is the set of students in the sme tutor group s. Other exmples: for the identity reltion, the equivlence clss of n element is the singleton set {}. for the reltion equlity modulo on the integers, the equivlence clss [0] is ll even numers, nd the equivlence clss [] is ll odd numers. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 6 / 6 Equivlence clsses re prtitions Given set A, set S of susets of A is clled prtition of A if: every pir of sets in S is disjoint: if P S nd P S with P P then P P = every element of A is contined in some P S. Tht is to sy, the sets in S split the whole of A up into chunks. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 7 / 6

Equivlence clsses nd prtitions The set of equivlence clsses of n equivlence reltion gives us prtition on the set; nd ny prtition genertes n equivlence reltion. Theorem If is n equivlence reltion on A then the set of equivlence clsses forms prtition of A. {[] A} Conversely, if S is prtition of A, then the reltion defined y {(, ) P S. P P} is n equivlence reltion, whose equivlence clsses re exctly the memers of S. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 8 / 6 Proof of the theorem We ll prove the first prt of the theorem. Given n equivlence reltioon on A, we hve to show tht the set of equivlence clsses of prtitions A. Suppose [] [] is non-empty. Then there is some c [] [], so tht c nd c. By symmetry nd trnsitivity,, so [] = []. For ny A, []. Tht s ll we needed to show! G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 9 / 6 Quotient of set Given set A nd equivlence reltion on A, the set of equivlence clsses is clled the quotient of A y nd is written A/. Its importnce for computing is, mong other things, the notion of dt representton we mentioned efore. If A is our set of representtions, nd is the correct notion of equivlence, then A/ is ( good representtion of) the set of things we re encoding. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 30 / 6

Exmple: representing integers using nturls In previous lectures we discussed how to set up the theory of the nturl numers using Peno rithmetic. In this development, the numer 3 is represented s S(S(S(0))), for exmple. Once we ve done this, nd defined opertions like + nd so on, we cn go on to represent the integers. One wy to represent n integer is s pir (m, n) of nturl numers; we think of this s representing the integer m n. This of course mens tht given integer hs infinitely mny representtions: 3 is represented y ny of (0, 3) (, 4) (, 5) (3, 6)... G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 3 / 6 Why use this representtion? This representtion hs its enefits, though. For exmple, it is esy to define ddition on integers using nturl numer ddition: (m, n ) + (m, n ) = (m + m, n + n ). It is lso esy to define multipliction y : nd hence sutrction (m, n) = (n, m) (m, n ) (m, n ) = (m + n, n + m ). Exercise Define multipliction of integers in this representtion. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 3 / 6 An equivlence reltion Since our representtion gives infinitely mny wys of encoding n integer, we need wy of telling when two such encodings re the sme integer. We cn define n equivlence reltion (m, n ) (m, n ) m + n = m + n. Now two encodings of the sme integer re relted y, so there is close correspondence etween integers nd equivlence clsses of representtions. Tht is, we cn think of N N/ s eing the set of integers. We ll sy little more out this lter. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 33 / 6

Prtil orders Another common form of reltion is the ordering reltion, like. A inry reltion R on set A is clled prtil order if it is reflexive trnsitive, nd ntisymmetric. This sys tht notion of ordering should stisfy every element is less thn or equl to itself if is less thn or equl to nd is less thn or equl to c then is less thn or equl to c if is less thn or equl to nd is less thn or equl to then =. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 34 / 6 Exmples The following reltions re prtil orders: on the integers = on ny set on the set of susets of some set A (tht is, the powerset P(A)). Note tht < is not prtil order: it is not reflexive. Our notion of prtil order is non-strict, tht is, it generlizes less thn or equl -style orderings. Exercise Define notion of strict prtil order, which generlizes <-style orderings. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 35 / 6 The suset reltion s grph Omitting the reflexive nd trnsitive rcs, the suset reltion on P{,, c} looks like this: {,, c} {, } {, c} {, c} {} {} {c} G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 36 / 6

Composition of reltions Consider the reltions is prent of nd is grndprent of. It should e cler tht we cn define the grndprent reltion from the prent reltion. A person is grndprent of person c if is prent of someody,, nd is prent of c. More generlly, if we hve reltion R etween A nd B, nd reltion S etween B nd C, we cn define reltion S R y {(, c) B. R S c}. The grndprent reltion is prent prent. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 37 / 6 Inverse Given reltion R etween A nd B, we cn define reltion R etween B nd A y {(, ) R }. Tht is, we just flip round the reltion R to get R. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 38 / 6 Symmetry nd trnsitivity gin Theorem A inry reltion R on set A is symmetric if nd only if R = R. R is trnsitive if nd only if R R R. Exercise Prove this theorem! G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 39 / 6

Picturing reltions etween sets We might drw reltion from one set to nother like this: d c 3 G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 40 / 6 Oservtions d c 3 Notice tht: not every element of the left hnd set is relted to something on the right (i.e. is the source of n rc) some elements of the left hnd set re relted to more thn one thing on the right (i.e. they re the source of more thn one rc) not every element of the right hnd set is the trget of n rc some elements re the trget of more thn one rc. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 4 / 6 Picturing composition Let s see wht the composition of two reltions looks like. d 3 3 c z y d c 3 z y G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 4 / 6

Functions A function f from set A to set B is reltion such tht every A is relted to exctly one B. Tht is: A. B.(, ) f, nd A., B.(, ) f (, ) f =. When f is function from A to B we write f : A B nd use the nottion f () = to men tht (, ) f. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 43 / 6 Functions Thus function is reltion such tht every element of the left-hnd set A is the source of exctly one rc to n element of B. A function is sid to mp the elements of A into B, nd so functions re lso clled mps or mppings. It is still possile tht n element of B my e the trget of no rcs, or more thn one. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 44 / 6 Exmples Most of the usul opertions on numers nd so on re functions: ddition is function from Z Z to Z for exmple. The identity reltion on ny set is function from tht set to itself. We cll it the identity function. The reltion which connects students to their cndidte numers is function from the set of ll students to the set of ll cndidte numers. The reltion connecting students tking CM096 to their mrks on prolem sheet 4 is function from the set of students to the set {0,,,..., 0}. Mny computer progrms compute function from the set of possile inputs to the set of possile outputs. Not ll progrms do, though. Why not? G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 45 / 6

Exmples There re four possile functions from the set {, } to the set {0, }. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 46 / 6 Crdinlity, product nd function spce For finite set A, define A, the crdinlity of A, to e the numer of elements in the set A. Theorem Given sets A nd B, A B is A B. The set of ll functions from A to B hs crdinlity B A Prtly motivted y this, the set of functions from A to B is sometimes written s B A. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 47 / 6 Composition of functions Since functions re reltions, we cn compose them just like reltions. Given f : A B nd g : B C, the composite g f : A C is {(, c) B.f () = g() = c}. Tht is, (g f )() = g(f ()). Exmple If f is the mp tking x to x + nd g is the mp tking x to x (so tht oth f nd g go from Z to itself), then g f is the function tking x to (x + ). G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 48 / 6

Inverses Since function f is specil reltion, its inverse, the reltion f, lwys exists. Normlly, though, when we sy tht function hs n inverse, we men tht the inverse is itself function. Under wht circumstnces does the inverse reltion f give us function? It is the reltion {(, ) f () = }. For this to e function, we need two properties: every must e sent somewhere, i.e. for every B there must exist some A such tht f () =. every must e sent to exctly one plce, i.e. if f ( ) = nd f ( ) = then =. These two specil properties of f re very importnt. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 49 / 6 Surjective functions A function f : A B is clled surjective, or onto, if for every B there is some A with f () =. Such function is lso clled surjection. The condition sys tht the function hits everything in B. Tht is to sy, we do not hve this kind of sitution: 3 Nothing hits 3 in this exmple. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 50 / 6 Exmples The function tking numer x to x + is surjective s function from Z to Z. It is not surjective s function from N to N. The function tking x to x 3 is surjective on the rel numers: every rel numer hs cue root. For ny route on the London Underground (i.e. chosen line, nd chosen direction of trvel) we cn define function tking sttion to the next sttion on the route. These functions re not usully surjective (think out the first sttion on the route) except for the Circle Line, which goes round in circle. On the set {0,,, 3, 4}, the function which tkes x to x mod 5 is surjective. Exercise Check tht the lst clim is true! G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 5 / 6

Injective functions A function f : A B is clled injective, or -, if whenever f ( ) = f ( ), we hve =. We lso sy tht f is n injection. The condition sys tht no two distinct elements of A re mpped to the sme plce, i.e. we don t hve this sort of picture: G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 5 / 6 Exmples of injections The following functions re injective: the identity function on ny set the function tking ny integer x to x + the function tking ny integer x to x the function tking nturl numer x to x is injective; Note tht the function tking x to x is not injective when seen s function on integers, ecuse (for exmple), ( ) = =. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 53 / 6 Inverse gin Now we cn stte theorem: Theorem Given function f : A B, the reltion f is itself function if nd only if f is oth injective nd surjective. Functions which re oth injective nd surjective re so specil tht they hve specil nme: they re clled ijective. Some exmples: the function mpping x to x on the integers is ijective the function mpping x to x 3 on the rel numers is ijective the function mpping n to n is ijection from the integers to the even integers the function mpping n to n mod is ijection from {0,,, 3, 4} to itself the identity mp on ny set is ijective. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 54 / 6

Some theorems Theorem Let f : A B nd g : B C. if f nd g re oth injective, then g f is injective if f nd g re oth surjective, then g f is surjective if f nd g re oth ijective, then g f is ijective (this follows from the previous two fcts) if f is ijective so is f if g f is injective then f is injective if g f is surjective then g is surjective G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 55 / 6 Proof of one of these fcts Let s prove the lst of these: if g f is surjective then g is surjective. Suppose tht g f is surjective, nd try to show tht g is surjective, tht is, tht for ny c C we cn find some B such tht g() = c. Since g f is surjective, there is some A such tht (g f )() = c, tht is, g(f ()) = c, so letting = f () estlishes wht we need. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 56 / 6 Remrk If g f is surjective, it does not necessrily follow tht f is surjective, s the picture elow shows: d 3 c z y A f B g C G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 57 / 6

Functions nd equivlence reltions Rememer our representtion of the integers using pirs of nturls: pir (m, n) represents the integer m n. We defined n equivlence reltion on pirs: (m, n ) (m, n ) if nd only if m + n = m + n. We then sid two things: the equivlence clsses ehve like integers we cn define functions on these pirs, like sutrction: (m, n ) (m, n ) = (m + n, n + m ). Do these things relly mke sense together? G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 58 / 6 Functions on equivlence clsses If we ve got set A with n equivlence reltion, nd function f : A A, we d sometimes like to use f s function on equivlence clsses. Tht is, we d like to define function g from A/ to itself y g([]) = [f ()]. The question is, does this mke sense? G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 59 / 6 Functions tht respect equivlence In order for this to define function, it hs to e the cse tht f ( ) f ( ). When we hve [ ] = [ ], so we need [f ( )] = [f ( )] or g will not e function. If f hs this property we sy tht f respects. The vitl fct out our opertions on the integers s pirs representtion is tht they ll respect the equivlence reltion in this wy. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 60 / 6

Sutrction respects Let s verify tht sutrction respects. Suppose (m, n ) (m, n ) nd (m, n ) (m, n ). We shll show tht (m, n ) (m, n ) (m, n ) (m, n ). This is just question of unpcking definitions. By definition (m, n ) (m, n ) = (m + n, n + m ) (m, n ) (m, n ) = (m + n, n + m ) so we hve to check tht these things re equivlent, i.e. tht m + n + n + m = m + n + n + m. But we know tht m + n = n + m nd m + n = n + m so the required fct follows. G.A.McCusker@th.c.uk (W.) CM096 Topic 4: Functions nd Reltions 6 / 6