Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Maths for CS: 2013/14 Sets (2) – OPTIONAL MATERIAL John Barnden Professor of Artificial Intelligence School of Computer Science University of.

Similar presentations


Presentation on theme: "Intro to Maths for CS: 2013/14 Sets (2) – OPTIONAL MATERIAL John Barnden Professor of Artificial Intelligence School of Computer Science University of."— Presentation transcript:

1 Intro to Maths for CS: 2013/14 Sets (2) – OPTIONAL MATERIAL John Barnden Professor of Artificial Intelligence School of Computer Science University of Birmingham, UK

2 “Tuples” uA “tuple” is an ordered sequence of items of any sort. We will only deal with finite tuples. Items CAN be duplicated. l Can also be called a “vector.” uNotation:  6, JAB, 5, “JAB”, 5, , 9> Or: ( 6, JAB, 5, “JAB”, 5, , 9) uSingleton and empty tuples:, <> u,, and are all different.

3 Ordered Pairs uWe considered ordered pairs of numbers, when discussing graphs. uAn ordered pair is simply a tuple of length two:  6, JAB >  “JAB”,  >  - 6, -6 >  5, -6 >  ,  >

4 “Cartesian Products” and “Relations” uThe set of all possible tuples formed from some sets is called the Cartesian product of the sets. Notation, e.g.: D  E  F  G  H if D, E, F, G, H are the sets—not necessarily different.  Each tuple is of form where d  D, e  E, etc. uAny subset at all of that Cartesian product is called a relation on the sets in question (D, E, …) l even the whole of the product (even if infinite) l and even the empty set. uI.e., a relation on D, E, …, H is just some set of tuples that are each of form where d  D, e  E, …, h  H.

5 Examples uLet A = {3, 8, 2} and B = {‘jjj’, ‘bb’}. Then A  B = {,,,,, }. B  B = {,,, }.  A   =  =   A A  {JAB} = {,, } uSome relations on A and B: l {,, } l { }  l A  B l 

6 Changing the Sets in a Relation Around uA relation R on A, B, C, D, E, say, obviously “induces” (i.e., gives rise to, in a natural way) a relation on any reordering of the sets, such as D, A, B, E, C, just by reordering each tuple in the same way. uWhen there are just two sets A and B, the (only possible) reordering of the sets gives the inverse of R.

7 Inverse Example u Suppose R = {,, } uThen the inverse of R, notated - R -1 is the relation {,, }

8 Functional Relations (Partial Functions) uA relation R from A to B is functional if, for any a in A, there is AT MOST one (but perhaps no) b in B such that  a, b> is in R. uSo several things in A can be related to the same thing in B. uBut you can’t have several things in B related to the same thing in A. uA functional relation from A to B is also called a partial function from A to B.

9 Examples uA = {3, 8, 2, 100}, B = {‘jjj’, ‘bb’, ‘c’, ‘x’, ‘y’}. R = {,,,, } NOT functional, because 3 maps to both ‘jjj’ and ‘bb’, and … uR = {,, } IS functional (NB: 8 doesn’t map to anything, and both 3 and 2 map to ‘jjj’)

10 Totality of Relations uA relation R from A to B is total (on A) if it relates everything in A to AT LEAST one thing in B.  > l I.e., for every member a of A, there is at least one b in B such that  a, b > is in R. uA relation may be merely partial (on A above) in not being total. However, technically all relations are “partial”, with total being a special case.

11 Examples uA = {3, 8, 2, 100}, B = {‘jjj’, ‘bb’, ‘c’, ‘x’, ‘y’}. R = {,,,, } IS total (NB: 3 maps to more than one thing) uR = {,, } NOT total, because 8 fails to map to anything.

12 Functions uA total functional relation from A to B is called a function from A to B. Each thing in A is related to exactly one thing in B. (But two different things in A can be related to the same thing in B, and not everything in B needs to be related to anything in A. So the inverse relation is not necessarily either functional or total.) uCaution: every function is also a partial function.

13 Examples uA = {3, 8, 2, 100}, B = {‘jjj’, ‘bb’, ‘c’, ‘x’, ‘y’}. R = {,,,, } NOT a function, because 3 maps to more than one thing uR = {,, } NOT a function, because 8 fails to map to anything. uR = {,,, } IS a function.

14 Other Categories of Relation uA relation R from A to B is one-to-one (1-1) if, for any a in A, there is at most one b in B such that  a, b> is in R, AND for any b in B, there is at most one a in A such that  a, b> is in R. l That is, both the relation and its inverse from B to A are functional. (But they don’t need to be total.) l To put it another way: it is functional and different members of A map to (= are related to) different members of B. l Or again: Different members of A map to different members of B and different members of B map to different members of A.

15 Example uA = {3, 8, 2, 100}, B = {‘jjj’, ‘bb’, ‘c’, ‘x’, ‘y’}. R = {,, } IS 1-1

16 Other categories, contd. uA one-to-one correspondence between a set A and B is a SPECIAL one-to-one relation from A to B (or B to A): u it is not only one-to-one but also TOTAL (on A) and ONTO (B). (Or we can say: total on both A and B.)

17 Example uA = {3, 8, 2, 100}, B = {‘jjj’, ‘bb’, ‘c’, ‘y’}. R = {,, } NOT a 1-1 correspondence between A and B, even though it is 1-1, as 2 is left out from A, and ‘bb’ is left out from B. uR = {,,, } IS a 1-1 correspondence between A and B

18 Other categories, contd. uBut any 1-1 relation from A to B is a 1-1 correspondence between the subsets of A, B consisting of those members that do happen to feature in the relation!

19 Countable and Uncountable Sets [Brief Intro; Optional Material] countable one-to-one correspondence uA set X is countable if it can be placed in a one-to-one correspondence with some subset of N, the set of natural numbers from 1. uTrivial case: X = N { | x  X}. Let R be the relation { | x  X}. This is the identity relation on X. Then R is a 1-1 correspondence between X and X.

20 Countable Sets, contd 1 uSimilarly for any proper subset X of N: just use the identity relation on X again. uMore interesting case: X = the set of all whole numbers (negative, positive and zero). Let R be the relation { | x  X, x  0}  { | x  X, x | x  X, x  0}  { | x  X, x < 0 } So R = {(0,0), (-1,1), (1,2), (-2,3), (2,4), (-3,5), (3,6), …} Then R is a 1-1 correspondence between X and N.

21 Countable Sets, contd 2 uYet more interesting case: X = the set of positive rational numbers. Can get our relation R by putting the possible fractions (with positive whole number parts) in a square infinite table with numerators increasing horizontally and denominators increasing vertically: 1/1 2/1 3/1 4/1 5/1 6/1 … 1/2 2/2 3/2 4/2 5/2 6/2 … 1/3 2/3 3/3 4/3 5/3 6/3 … 1/4 2/4 2/5 2/6 : : … : : : : : : … Then traverse through the numbers in sequence by going up and down diagonals, with steps on edges as necessary, and missing out fractions that are not in simplest form (missed out ones are shown in brackets): 1/1, 2/1, 1/2, 1/3, (2/2), 3/1, 4/1, 3/2, 2/3, 1/4, 1/5, (2,4), (3,3), (4,2), 5/1, … Count as: 1 2 3 4 5 6 7 8 9 10 11

22 Uncountable Sets uAll finite sets are countable. And they needn’t be sets of numbers! The set of socks in this class is countable. uWe have seen that some infinite ones are countable … uEven if the set X contains the natural numbers as a tiny proper subset!! E.g., X = the set of rational numbers. uBut some infinite sets are not countable: notably the set of real numbers (rational and irrational numbers together), or even the set of real numbers between 0 and 1. Can be shown by a an incredibly interesting and deep “diagonalization” argument based on the decimal representations of the numbers (see next slide)…

23 Uncountable Sets: The Real Numbers uConsider the set of real numbers strictly between 0 and 1, and represent them as decimals …  … in a canonical form – i.e. don’t allow them to end with 9 recurring (e.g., use 0.38027 not 0.3802699999999….), and fill out terminating decimals with an ninfifnte sequence of zeroes at the and (so actually use 0.3802700000…..) (D) uCan show that: (D) different numbers always then have different decimal representations. uNow, suppose you could enumerate the above real numbers in some order, i.e. put them into 1-1 correspondence with natural numbers, e.g. (next slide). We will derive a contradiction.

24 The Real Numbers, contd  Here’s how the enumeration might look:  No.1: 0.56243500000000000000000000000000…  No.2: 0.08508937982987876388729878475687….  No.3: 0.9909999999996735837409870000000…..  No.4: 0.7821985874649827094073498891111…. uNow form a decimal number by where the nth digit is the nth digit of the nth decimal above: 0.5891… uNow replace each digit in that decimal by a different digit other than 9 (doesn’t matter which), e.g. to get 0.4483… (D) uThis decimal is therefore different from any in the enumeration above, because it always differs from the nth decimal in at least one digit, namely the nth. And therefore by (D) above it represents a real number between 0 and 1 not counted in the enumeration!!!!! We have our contradiction.

25 Diagonalization, contd  For deep reasons, diagonalization arguments crop up all over the place in maths and logic and especially in their application to CS.  A relatively general formulation is that when you have an function of two arguments, f(n,m), you can force both arguments to be the same, to get a new function g(n) = f(n,n). Function g is the diagonalization of f.  Why? – Just imagine setting out the values of f(n,m) in a square array. Then g(n)’s values will be on the diagonal.  In our case f(n,m) gives the nth digit of the mth decimal (in the supposed enumeration of decimals). So the values of g(n) for n=1 upwards give us a new decimal number which causes trouble.  Diagonalization is often used in other, completely different, contexts to create entities that cause trouble, typically by not being able to be accounted for in some way.


Download ppt "Intro to Maths for CS: 2013/14 Sets (2) – OPTIONAL MATERIAL John Barnden Professor of Artificial Intelligence School of Computer Science University of."

Similar presentations


Ads by Google