Indin Institute of Informtion Technology Design nd Mnufcturing, Kncheepurm Chenni 600 7, Indi An Autonomous Institute under MHRD, Govt of Indi An Institute of Ntionl Importnce wwwiiitdmcin COM05T Discrete Structures for Computing-Lecture Notes Instructor NSdgopn Scrie: SDhnlkshmi Functions nd Infinite Sets Ojective: We shll introduce functions, specil functions nd relted counting prolems We shll see the importnce of functions in the context of innite sets nd discuss innite sets in detil Further, we introduce the notion of counting in the context of innite sets Denition (Function) Let A nd B e two non-empty sets A function or mpping f from A to B, written s f : A B, where every element A is mpped to unique element B Note: The element B is clled the imge of under f nd is written s f() If f() = then is clled the pre-imge of under f A is clled the domin of f nd {f() A} is clled the rnge of f B is clled the co-domin of f Exmples for function: ) Domin = Set of pples nd Rnge = weight of pples ) Domin = Set of students nd Rnge = CGPA of students 5 Every function is reltion ut the converse is not true ie Every reltion is not function 6 For every element A, there exist n imge f() ie, f() is well dened 7 Let A = n nd B = m The numer of dierent functions f : A B is m n, where A represents the crdinlity of A, the numer of elements of A 8 Let A = n nd B = m If X = {R R is reltion dened wrt (A, B)} nd Y = {R R is function wrt (A, B)} then, X Y (Since, X = mn nd Y = m n ) Things to know: Is there function f : A B, if A = nd B? Yes, n empty function Is there function f : A B, if A nd B =? No Is there function f : A B, if A = nd B =? Yes, void function Denition (One-one function/injective) A function is sid to e injective if for every element in the rnge there exists unique pre-imge ie, no two elements in the domin mp to sme element in the co-domin Denition (Onto function/surjective) A function is sid to e surjective if for every element in the co-domin there exists pre-imge A function is sid to e ijective if it is oth one-one nd onto function
A B A B c c d d e () () A B A B c c d (c) (d) Fig () Not one-one nd not onto () one-one ut not onto (c) onto ut not one-one (d) one-one nd onto Let A = B = N(set of nturl numers) - Give n exmple of function f : N N, tht is one-one nd not onto? f(x) = x + - Give n exmple of function f : N N, tht is not one-one ut onto? f(x) = x - Give n exmple of function f : N N, tht is one-one nd onto? f(x) = x Let A = B = I(set of integers) - Give n exmple of function f : I I, tht is one-one nd not onto? f(x) = x - Give n exmple of function f : I I, tht is not one-one ut onto? f(x) = x, if x nd f(x) = x, if x 0 - Give n exmple of function f : I I, tht is one-one nd onto? f(x) = x Give ijective function f : (0, ) (, 5) in rel numers? f(x) = x + Let A = n nd B = m The numer of dierent one-one functions re m Cn n! = m Pn Food for Thought Let A = n nd B = m The numer of dierent onto functions? Let A = n nd B = m The numer of dierent ijective functions? Give ijective function f : (0, ) (, ) in rel numers?
An invittion to innite sets Motivtion: - Mny interesting sets such s (i) Set of prime numers (ii) Set of C-progrms (iii) Set of C-progrms with exctly three sttements re innite in nture - Between I nd N, which set is igger? - Between I nd N N, which set is igger? - Is [0, ] is igger thn R? - Cn we list ll C-progrms? Denition (Finite) A set A is nite if there exists n N, n-represents the crdinlity of A such tht there is ijection f : {0,,, n } A A is innite if A is not nite Denition 5 (Innite) Let A e set If there exists function f : A A such tht f is n injection nd f(a) A then A is innite Let B e nite set, B = {,,, 0} Cn you estlish - function f : B B such tht f(b) B? No Cn you estlish - function f : N N such tht f(n) N? Yes, f(x) = x + Every - function from f : B B is lso ijection from B B if B is nite Prolem : Show tht N is innite Proof y contrdiction: Suppose N is nite By denition, there exists n, n represents the crdinlity of N such tht f(n) = n Let K = MAX{f(0), f(),, f(n )} + There does not exist x {0,,, n } such tht f(x) = k Therefore, f is not onto nd thus, f is not ijection Hence, our ssumption is wrong nd N is innite Prolem : Show tht R is innite Proof: To prove R is innite, estlish function f : R R such tht f is - nd f(r) R Consider f : R R such tht f(x) = x +, if x 0 nd f(x) = x, if x < 0 This function f is - ut not onto (Since, 0 does not hve pre-imge) nd f(r) R Hence, R is innite Prolem : Let = {, } nd f : Show tht is innite Proof: To prove is innite, estlish function f : such tht f is - nd f( ) Consider f : such tht f(x) = x The elements ɛ,,,, will not hve preimge Therefore f is not onto ut - nd f( ) Hence, is innite
Prolem : Show tht [0, ] is innite Proof: Consider f : [0, ] [0, ] such tht f(x) = x This function f is - ut not onto (Since, (, ] does not hve pre-imge) nd f([0, ]) [0, ] Hence, [0, ] is innite Clim: Let A e suset of A If A is innite then A is innite Proof: Given A is innite Therefore, there exist function g : A A such tht g is - nd g(a ) A Consider function f : A A such tht f(x) = x, if x A\A nd f(x) = g(x), if x A The function f is lso - nd f(a) A (Since, g is - nd g(a ) A ) Thus, A is innite Corollry: Every suset of nite set is nite set Clim : Let f : A B e n injection If A is innite then B is innite Proof: Since f is - nd A is innite, f(a) is innite By previous clim, B is innite (since, f(a) B) Prolem 5: A is innite Show tht (i) P (A), power set of A is innite (ii) A B is innite (iii) A B is innite (iv) A B, the set of ll functions from B to A, is innite Solutions: (i) Consider function f : A P (A) such tht f(x) = {x} The function f is - ut not onto ie,a P (A) Thus, P (A) is innite (ii) We know tht, A A B Since A is innite, A B is innite (y clim ) (iii) Consider function f : A A B such tht f(x) = (x, ) for some B Clerly, the function f is - ut not onto Thus, A B is innite (iv) Every element in A B is function from B A Consider function f : A A B such tht f(x) = g, g is function from B A such tht g() = x, B This function f is - ut not onto Thus, A B is innite Denition 6 (Countle) A set A is countle if A is nite or if A hs n enumertion (Listing elements of A) or if there exists ijection from N to A A set A is sid to e Countly innite if there exist ijection from N to A or if there exists n enumertion Countle sets re either countly nite or countly innite A = B if nd only if there exists ijection from A to B Prolem 6: Prove: N = I Solution: To prove there exist ijection from N to I Consider the function f : N I such tht f(x) = (x+), if x = k +, for some integer k nd f(x) = x, if x = k, for some integer k Clerly, this function is - nd onto Thus, N = I Prolem 7: Prove tht the set P of prime numers is innite Solution: For every prime numer x, we know tht there exists prime numer y > x Therefore,
we estlish mp etween N nd the set of prime numers f : N P such tht f(i) = P i ie, i th nturl numer mps to P i Therefore, there exists n enumertion nd hence P is countly innite Prolem 8: Prove tht the set of positive rtionl numers, Q +, is innite Solution: We elow enumerte(list) elements of Q + in systemtic wy s illustrted in the Figure We then estlish ijective function from N to Q + y following the rrows s illustrted in the gure This yields n enumertion nd mpping to N, therefore Q + is innite Thus, Q + is countly innite Numertor 0 0/ / / / N 0 f + Q 0/ 0/ / / / / Denomintor 0/ / / / / / Enumertion without repetitions Fig Enumertion of Q + Prolem 9: Prove tht the crdinlity of is countly innite Solution: We shll estlish this clim y listing the elements of using stndrd ordering ie, we rst list strings of length one, followed y strings of length two, nd so on Strings hving sme length will e listed s per lexicogrphic ordering An illustrtion s per stndrd ordering is shown elow N 0 5 6 f E * 0 Fig Enumertion nd ijective function from N to Prolem 0: Prove tht the numer of C-progrms is countly innite Solution: Let = {,,, z, A, B,, Z, $, {, }, \, } nd = {ɛ, String, String, } Note tht is precisely the set of keys ville in key ord (ASCII chrcters) It is esy to 5
see tht every C-progrm is n element in, ie, imgine the cse where we write C-progrm in horizontl fshion insted of verticl fshion Also, we re not concerned out whether the C-progrm is syntcticlly correct or not We know tht is countly innite, thus, numer of C-progrms is countly innite Prolem : Prove tht the numer of C-progrms with exctly sttements is countly innite? Solution: Let progrm- e x = x +, progrm- e x = x +,, progrm- e x = x + Clerly, the set of progrms (Progrm-,) is innite We further know from the previous clim tht the numer of C-progrms is countly innite Since this set is only suset of ll C-progrms, implies tht, the numer of C-progrms with exctly -sttements is countly innite Uncountle Sets In erlier sections, we introduced innite sets nd techniques for showing set is innite Further, we lso presented n pproch to count innite sets (countly innite) We now sk; is every set countle? ie, either countly nite or countly innite We nswer this in negtive nd show tht there re uncountle sets We next introduce cntor's fmous technique, digonliztion technique using which we show tht the set [0, ], the set of rel numers etween 0 nd is uncountle Prolem : Show tht [0, ] uncountle Solution: We present proof y contrdiction Suppose [0, ] is countle then there exists n enumertion, ie, listing of elements in [0, ] in systemtic wy; ENUM: x, x, Further, there exists ijection from N to ENUM Let x = 0x x x x x = 0x x x x x 0 = 0x x x x We now show tht the ove listing is incomplete y exhiiting n element y [0, ] nd y is not listed in ENUM Consider y = 0y y y y, such tht y i =, if x ii = nd y i =, if x ii Clerly, y [0, ] nd ny x i nd y will dier t one position (t lest one) Therefore, y is not enumerted in x, x, Thus, ENUM is incomplete nd our ssumption tht [0, ] is countle is wrong Therefore, [0, ] uncountle Note: Since [0, ] is uncountle, the set of rel numers R is uncountle Clim: Countle union of countle sets is countle Proof: Let A, A,, e set of countle sets Since ech set A i is countle, then there exists n enumertion of A i Construct mtrix with the rst row listing the elements of A, the second row listing the elements of A, nd so on Now, similr to the proof showing the set of rtionl numers is countle, enumerte the elements of the constructed mtrix to get nturl mpping to the set of nturl numers Therefore, the clim follows 6
Prolem : Is irrtionl numers countle? Solution: Assume tht irrtionl numers re countle Since rtionl numers re countle nd y the ove clim union of rtionl numers nd irrtionl numers is countle, however, this is precisely the set of rel numers, which is contrdiction Thus, the set of ll irrtionl numers re uncountle Prolem : Given tht is countly innite Is P ( ) countly innite? Solution: Suppose P ( ) is countly innite Since is countly innite we cn enumerte s x, x, x, Since P ( ) is countly innite, there exists n enumertion A, A, A,, where ech A i is suset of We now construct mtrix with row representing the sets (A i s) nd column representing x Tle entries s illustrted in Figure re lled s follows; if you nd x i in A j, plce in the corresponding cell, else plce 0 We now show tht there is suset in which is not listed s prt of the enumertion Choose x x x x A 0 0 A A 0 0 0 Fig Listing P ( ) nd in Mtrix B = {x j (A j, x j ) = 0} B P ( ) ut not listed s prt of the enumertion Therefore, the enumertion is incomplete Thus our ssumption is wrong Hence, P ( ) is uncountle Prolem 5: How mny computtionl prolems re there? Is it countle/uncountle Solution: Let prolem- sks for printing {0}, prolem- sks for printing {0, },, prolem-i sks for printing set contining i elements from N ie, ech prolem prints suset of N This prolem collection is sme s counting i element suset of P (N), power set of N Clerly, ll re computtionl prolems (well dened input nd output) nd hence the numer of computtionl prolems is strictly greter thn P (N) We hve lredy shown tht P (N) is uncountle, therefore, the numer of computtionl prolems is uncountle Solution: In the erlier section, while showing the numer of C-progrms is countly innite, we ssumed tht the lphet is nite lphet contining ll ASCII chrcters This ssumption is true while counting the numer of progrms s progrm size is nite However, this ssumption need not e true for descriing the prolem In other words, consider computtionl prolem, Print the irrtionl numer 0567, this description contins n innite string s sustring So, the prolem description tkes innite chrcters, which is P ( ) Thus, the numer of computtionl prolems is uncountle 7
Remrk on Solvility/Unsolvility: Every prolem is either solvle or unsolvle A prolem is sid to e solvle if there exists n lgorithm/progrm A prolem is sid to e unsolvle if there does not exists n lgorithm (Exmple: Print N, Print I) Prolem 6: How mny solvle prolems re there? Since ech solvle prolem hs n lgorithm or progrm, this count is equivlent to the numer of C-progrms nd therefore, the numer of solvle prolems is countly innite Prolem 7: How mny unsolvle prolems re there? Consider the set of progrms print [i, j] where i, j R, ech progrm in this set is unsolvle prolem s there is no lgorithm to list ll vlues of the closed intervl [0, ] nd this is true for ll [i, j] Since the size of this set is R, the numer of unsolvle prolems is uncountle Acknowledgements: Lecture contents presented in this module nd susequent modules re sed on the text ooks mentioned t the reference nd most importntly, lectures y discrete mthemtics exponents lited to IIT Mdrs; Prof PSreenivs Kumr, Prof Kml Krithivsn, Prof NSNrynswmy, Prof SAChoudum, Prof Arindm Singh, nd Prof RRm Author sincerely cknowledges ll of them Specil thnks to Teching Assistnts MrRenjithP nd MsDhnlkshmiS for their sincere nd dedicted eort nd mking this scrie possile This lecture scrie is sed on the course 'Discrete Structures for Computing' oered to BTech COE 0 tch during Aug-Nov 05 The uthor gretly eneted y the clss room interctions nd wishes to pprecite the following students: MrVignesh Sirj, MsKritik Prksh, nd MsLlith Finlly, uthor expresses sincere grtitude to MrSreerjR for thorough proof reding nd vlule suggestions for improving the presenttion of this rticle His vlule comments hve resulted in etter rticle References: KHRosen, Discrete Mthemtics nd its Applictions, McGrw Hill, 6th Edition, 007 DFStnt nd DFMcAllister, Discrete Mthemtics in Computer Science, Prentice Hll, 977 CLLiu, Elements of Discrete Mthemtics, Tt McGrw Hill, 995 8