Download presentation

Presentation is loading. Please wait.

Published byChase Bell Modified over 3 years ago

1
**Lecture adapted from CS3511,Discrete Methods Kees van Deemter**

Discrete Mathematics and its Applications 3/28/2017 Lecture adapted from CS3511,Discrete Methods Kees van Deemter Slides originally adapted from Michael P. Frank’s Course Based on the Text Discrete Mathematics & Its Applications (5th Edition) by Kenneth H. Rosen A word about organization: Since different courses have different lengths of lecture periods, and different instructors go at different paces, rather than dividing the material up into fixed-length lectures, we will divide it up into “modules” which correspond to major topic areas and will generally take 1-3 lectures to cover. Within modules, we have smaller “topics”. Within topics are individual slides. The instructor can bring several modules to each lecture with him, to make sure he has enough material to fill the lecture, or in case he wants to preview or review slides from upcoming or recent past lectures. 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

2
**Adaptation of Module #4: 1. Functions**

Rosen 5th ed., §1.8 ~45 slides, ~1 lecture 3/28/2017 Michael P. Frank / Kees van Deemter

3
**Michael P. Frank / Kees van Deemter**

Functions From calculus, you know the concept of a real-valued function f, which assigns to each number xR one particular value y=f(x), where yR. Example: f defined by the rule f(x)=x2 The notion of a function can be generalized to the concept of assigning elements of any set to elements of any set. Functions are also called operators. 3/28/2017 Michael P. Frank / Kees van Deemter

4
**Michael P. Frank / Kees van Deemter**

Functions Functions were the key concept in lambda calculus and Haskell: x.x+2 is the function that sends any appropriate argument x to the corresponding value x+2 After the Haskell definition f x = x+2, f denotes that same function x.x+2 Let’s be more precise about functions, working towards a classification of functions 3/28/2017 Michael P. Frank / Kees van Deemter

5
**Function: Formal Definition**

A function f from (or “mapping”) A to B (f:AB) is an assignment of exactly one element f(x)B to each element xA. Generalizations: Functions of n arguments: f: (A1 x A2... x An) B. A partial (non-total) function f assigns zero or one elements of B to each element xA. 3/28/2017 Michael P. Frank / Kees van Deemter

6
**Michael P. Frank / Kees van Deemter**

Graphs of Functions We can represent a function f:AB as a set of ordered pairs f ={(a,f(a)) | aA}. This makes f a relation between A and B: f is a subset of A x B. But functions are special: for every aA, there is at least one pair (a,b). Formally: aAbB((a,b)f) for every aA, there is at most one pair (a,b). Formally: a,b,c((a,b)f (a,c)f bc) A relation over numbers can be represent as a set of points on a plane. (A point is a pair (x,y).) A function is then a curve (set of points), with only one y for each x. 3/28/2017 Michael P. Frank / Kees van Deemter

7
**Discrete Mathematics and its Applications**

3/28/2017 Functions can be represented graphically in several ways: A B f • • f • • • • y • a b • Note that the inverses of the functions in the two diagrams on the left are not functions. Note also that the plot has gaps if the domain of the function is not the set R • • • x A B Bipartite Graph Plot Like Venn diagrams 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

8
**Functions that you’ve seen before**

A set S over universe U can be viewed as a function from the elements of U to … 3/28/2017 Michael P. Frank / Kees van Deemter

9
**Michael P. Frank / Kees van Deemter**

Still More Functions A set S over universe U can be viewed as a function from the elements of U to … … {T, F}, saying for each element of U whether it is in S. (This is called the characteristic function of S) Suppose U={0,1,2,3,4}. Then S={1,3} S(0)=S(2)=S(4)=F, S(1)=S(3)=T. 3/28/2017 Michael P. Frank / Kees van Deemter

10
**Michael P. Frank / Kees van Deemter**

Still More Functions A set operator, such as or , can be viewed as a function from … to … 3/28/2017 Michael P. Frank / Kees van Deemter

11
**Michael P. Frank / Kees van Deemter**

Still More Functions A set operator such as or can be viewed as a function … … from (ordered) pairs of sets, to sets. Example: (({1,3},{3,4})) = {3} 3/28/2017 Michael P. Frank / Kees van Deemter

12
**Michael P. Frank / Kees van Deemter**

A new notation Sometimes we write YX to denote the set F of all possible functions f: XY. Thus, f YX is another way of saying that f: XY. (This notation is especially appropriate, because for finite X, Y, we have |F| = |Y||X|. ) 3/28/2017 Michael P. Frank / Kees van Deemter

13
**Some Function Terminology**

If f:AB, and f(a)=b (where aA & bB), then we say: A is the domain of f. B is the codomain of f. b is the image of a under f. a is a pre-image of b under f. In general, b may have more than 1 pre-image. The range RB of f is R={b | a f(a)=b }. We also say the signature of f is A→B. 3/28/2017 Michael P. Frank / Kees van Deemter

14
**Michael P. Frank / Kees van Deemter**

Range versus Codomain The range of a function may not be its whole codomain. The codomain is the set that the function is declared to map all domain values into. The range is the particular set of values in the codomain that the function actually maps elements of the domain to. (The range is the smallest set that could be used as its codomain.) 3/28/2017 Michael P. Frank / Kees van Deemter

15
**Choosing the right (co)domain**

Consider the function f = λx.100/x Is f a (total) function from Int to R? f is a partial function from Int to R f is a (total) function from Int-{0} to R Consider g = λx.√x Is g a (total) function from R to R? g is a total function from R+ to RxR e.g. g(4)= (2,-2) 3/28/2017 Michael P. Frank / Kees van Deemter

16
**Images of Sets under Functions**

Given f:AB, and SA, The image of S under f is the set of all images (under f) of the elements of S. f(S) : {f(s) | sS} : {b | sS: f(s)=b}. The range of f equals the image (under f) of ... 3/28/2017 Michael P. Frank / Kees van Deemter

17
**Images of Sets under Functions**

Given f:AB, and SA, The image of S under f is the set of all images (under f) of the elements of S. f(S) : {f(s) | sS} : {b | sS: f(s)=b}. The range of f equals the image (under f) of f’s domain. 3/28/2017 Michael P. Frank / Kees van Deemter

18
**Michael P. Frank / Kees van Deemter**

One-to-One Functions A function is one-to-one (1-1), or injective, or an injection, iff every element of its range has only 1 pre-image. Formally: given f:AB, “f is injective” : (x,y: xy f(x)f(y)). In other words: only one element of the domain is mapped to any given one element of the range. In this case, domain & range have same cardinality. What about codomain? 3/28/2017 Michael P. Frank / Kees van Deemter

19
**Michael P. Frank / Kees van Deemter**

Codomain may be larger. 3/28/2017 Michael P. Frank / Kees van Deemter

20
**One-to-One Illustration**

Are these relations one-to-one functions? • • • • • • • • • • • • • • • • • • • • • • • • • • • 3/28/2017 Michael P. Frank / Kees van Deemter

21
**One-to-One Illustration**

Are these relations one-to-one functions? • • • • • • • • • • • • • • • • • • • • • • • • • • • One-to-one 3/28/2017 Michael P. Frank / Kees van Deemter

22
**One-to-One Illustration**

Are these relations one-to-one functions? • • • • • • • • • • • • • • • • • • • • • • • • • • • Not one-to-one One-to-one 3/28/2017 Michael P. Frank / Kees van Deemter

23
**One-to-One Illustration**

Are these relations one-to-one functions? • • • • • • • • • • • • • • • • • • • • • • • • • • • Not one-to-one Not even a function! One-to-one 3/28/2017 Michael P. Frank / Kees van Deemter

24
**Sufficient Conditions for 1-1ness**

For functions f over numbers, we say: f is strictly increasing iff x>y f(x)>f(y) for all x,y in domain; f is strictly decreasing iff x>y f(x)<f(y) for all x,y in domain; If f is either strictly increasing or strictly decreasing, then f must be one-to-one. Does the converse hold? 3/28/2017 Michael P. Frank / Kees van Deemter

25
**Onto (Surjective) Functions**

A function f:AB is onto or surjective or a surjection iff its range is equal to its codomain (bB, aA: f(a)=b). Consider “country of birth of”: AB, where A=people, B=countries. Is this a function? Is it an injection? Is it a surjection? 3/28/2017 Michael P. Frank / Kees van Deemter

26
**Onto (Surjective) Functions**

A function f:AB is onto or surjective or a surjection iff its range is equal to its codomain Consider “country of birth of”: AB, where A=people, B=countries. Is this a function? Yes (always 1 c.o.b.) Is it an injection? No (many have same c.o.b.) Is it a surjection? Probably yes .. 3/28/2017 Michael P. Frank / Kees van Deemter

27
**Onto (Surjective) Functions**

A function f:AB is onto or surjective or a surjection iff its range is equal to its codomain In predicate logic: 3/28/2017 Michael P. Frank / Kees van Deemter

28
**Onto (Surjective) Functions**

A function f:AB is onto or surjective or a surjection iff its range is equal to its codomain. In predicate logic: bBaA f(a)=b 3/28/2017 Michael P. Frank / Kees van Deemter

29
**Onto (Surjective) Functions**

A function f:AB is onto or surjective or a surjection iff its range is equal to its codomain (bBaA f(a)=b). E.g., for domain & codomain Z, the function x.x+1 is injective and surjective. 3/28/2017 Michael P. Frank / Kees van Deemter

30
**Michael P. Frank / Kees van Deemter**

Claim: if f:ZZ and f =x.x+1 then f is 1-to-1 and also onto. (Z is the set of all integers) Proof that f is onto: Consider any arbitrary element a of Z. We have f(a-1)=a, where a Z. Proof that f is 1-to-1: Suppose f(u)=f(w)=a. In other words, u+1=a and w+1=a. It follows that u=a-1 and w=a-1, so u=w. 3/28/2017 Michael P. Frank / Kees van Deemter

31
**Michael P. Frank / Kees van Deemter**

Illustration of Onto Are these functions onto their depicted co-domains? • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 3/28/2017 Michael P. Frank / Kees van Deemter

32
**Michael P. Frank / Kees van Deemter**

Illustration of Onto Are these functions onto? • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 3/28/2017 Michael P. Frank / Kees van Deemter

33
**Michael P. Frank / Kees van Deemter**

Illustration of Onto Are these functions onto? • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • onto not onto onto not onto 3/28/2017 Michael P. Frank / Kees van Deemter

34
**Michael P. Frank / Kees van Deemter**

Illustration of Onto Are these functions 1-1? • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • onto not onto onto not onto 3/28/2017 Michael P. Frank / Kees van Deemter

35
**Michael P. Frank / Kees van Deemter**

Illustration of Onto Are these functions 1-1? • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • not 1-1 onto not 1-1 not onto 1-1 onto 1-1 not onto 3/28/2017 Michael P. Frank / Kees van Deemter

36
**Michael P. Frank / Kees van Deemter**

Bijections A function is said to be a one-to-one correspondence, or a bijection iff it is both one-to-one and onto. 3/28/2017 Michael P. Frank / Kees van Deemter

37
**Two terminologies for talking about functions**

injection = one-to-one surjection = onto bijection = one-to-one correspondence 3 = 1&2 3/28/2017 Michael P. Frank / Kees van Deemter

38
**Michael P. Frank / Kees van Deemter**

Bijections For bijections f:AB, there exists a function that is the inverse of f, written f 1: BA Intuitively, this is the function that undoes everything that f does Formally, it’s the unique function such that ... 3/28/2017 Michael P. Frank / Kees van Deemter

39
**Michael P. Frank / Kees van Deemter**

Bijections For bijections f:AB, there exists an inverse of f, written f 1: BA Intuitively, this is the function that undoes everything that f does Formally, it’s the unique function such that (the identity function on A) 3/28/2017 Michael P. Frank / Kees van Deemter

40
**Michael P. Frank / Kees van Deemter**

Bijections Example 1: Let f: ZZ be defined as f(x)= x+1. What is f1 ? Example 2: Let g: ZN be defined as g(x)= |x|. What is g1 ? 3/28/2017 Michael P. Frank / Kees van Deemter

41
**Michael P. Frank / Kees van Deemter**

Bijections Example 1: Let f: ZZ be defined as f(x)=x+1. What is f1 ? f1 is the function (let’s call it h) h: ZZ defined as h(x)=x-1. Proof: h(f(x)) = (x+1)-1 = x 3/28/2017 Michael P. Frank / Kees van Deemter

42
**Michael P. Frank / Kees van Deemter**

Bijections Example 2: Let g: ZN be defined as g(x)=|x|. What is g1 ? This was a trick question: there is no such function, since g is not a bijection: There is no function h such that h(|x|)=x and h(|x|)=x (NB There is a relation h for which this is true.) 3/28/2017 Michael P. Frank / Kees van Deemter

43
**The Diagonalisation Method**

Discrete Mathematics and its Applications 3/28/2017 The Diagonalisation Method Georg Cantor (1873): Can we compare the sizes of infinite sets? Example: card(N ) = card({0*1*})? Both are infinite But is one larger than the other? Cantor’s idea: The size (cardinality) of a set should not depend on the identity of its elements Two finite sets A and B have the same size if we can pair the elements of A with elements of B Formally: there exists a bijection between A and B 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

44
**Correspondences (Cont’d)**

Discrete Mathematics and its Applications 3/28/2017 Correspondences (Cont’d) Example: Let N be the set of natural numbers {1, 2, 3, …} E be the set of even natural numbers {2, 4, 6, …} Using Cantor’s definition of size, we can show that N and E have the same size: Bijection (!): f (n) = 2n Intuitively, E is smaller than N, but Pairing each element of N with its corresponding element in E is possible, So we declare these two set to be the same size This even though E N (E is a real subset of N ) 6 3 4 2 1 f (n) n … 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

45
**Discrete Mathematics and its Applications**

3/28/2017 Countable sets A set X is finite if it has n elements, for some n in N. A set is countable if either It is finite or It has the same size as N, the natural numbers For example, N is countable, and so are all its subsets: E is countable {0,1,2,3} is countable is countable How about supersets of N? 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

46
**An Even Stranger Example…**

Discrete Mathematics and its Applications 3/28/2017 An Even Stranger Example… Let Q be the set of positive rational numbers Q = { m/n | m,n N } Just like E, the set Q has the same size as N ! We show this giving a bijection from Q to N Q is thus countable One way is to enumerate (i.e., to list) X’s elements. For example, for X=Q : Pair the first element of X with 1 from N And so on, making sure every member of Q appears only once in the list 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

47
**An Even Stranger Example… (Cont’d)**

Discrete Mathematics and its Applications 3/28/2017 An Even Stranger Example… (Cont’d) To build a list with the elements of Q make inf. matrix with all positive rational numbers i -th row contains all numbers with numerator i j -th column has all numbers with denominator j i /j is in i -th row and j -th column 1/1 1/2 1/3 1/4 1/5 2/1 2/2 2/3 2/4 2/5 3/1 3/2 3/3 3/4 3/5 4/1 4/2 4/3 4/4 4/5 5/1 5/2 5/3 5/4 5/5 . . . 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

48
**An Even Stranger Example… (Cont’d)**

Discrete Mathematics and its Applications 3/28/2017 An Even Stranger Example… (Cont’d) Now we turn the previous matrix into a list A bad way: begin list with first row Since rows are infinite, we will never get to 2nd row! 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

49
**An Even Stranger Example… (Cont’d)**

Discrete Mathematics and its Applications 3/28/2017 An Even Stranger Example… (Cont’d) Instead, we list the elements along diagonals: 1/1 1/2 1/3 1/4 1/5 2/1 2/2 2/3 2/4 2/5 3/1 3/2 3/3 3/4 3/5 4/1 4/2 4/3 4/4 4/5 5/1 5/2 5/3 5/4 5/5 . . . We should, however, eliminate repeated elements 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

50
**An Even Stranger Example… (Cont’d)**

Discrete Mathematics and its Applications 3/28/2017 An Even Stranger Example… (Cont’d) We list elements along diagonals w/o repetitions: 1/1 1/2 1/3 1/4 1/5 2/1 2/2 2/3 2/4 3/1 3/2 3/3 4/1 4/2 5/1 . . . 1/1, 2/1, 1/2, 3/1, 1/3, … 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

51
**Discrete Mathematics and its Applications**

3/28/2017 Uncountable sets Some sets have no correspondence with N These sets are simply too big! They are not countable: we say uncountable Theorem: The set of real numbers between 0 and 1 (e.g., 0.244, ) is uncountable Call this set R0,1 (Some sets are even larger. “Serious” set theory is all about theorems that concern infinite sets. – Most of this is irrelevant for this course.) 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

52
**Finally: diagonalisation**

Theorem: | R0,1 | > |N|. Proof strategy: | R0,1 |>=|N|. Suppose | R0,1 |=|N| and derive a contradiction: Each member of R0,1 can be written as a zero followed by a dot and a countable sequence of digits. Suppose there existed a complete enumeration of R, (using whatever order) <e1,e2,e3,...>. 3/28/2017 Michael P. Frank / Kees van Deemter

53
**Cantor’s diagonalisation trick:**

(starting from an arbitrary list) e e e e ... 3/28/2017 Michael P. Frank / Kees van Deemter

54
**Now construct a Real number n that’s not in the enumeration:**

n’s first digit (after the dot) = [e1’s first digit] + 1 n’s second digit = [e2’s second digit] General: n’s i-th difit = [e-i’s i-th digit] + 1 i: n differs from e-i in its i-th digit Contradiction: <e1,e2,e3,...> is not a (complete) enumeration after all. QED 3/28/2017 Michael P. Frank / Kees van Deemter

55
**Adaptation of Module #3: 2. Sets and the Russell Paradox**

Rosen 5th ed., §1.6 especially ex. 30 on p. 86 3/28/2017 Michael P. Frank / Kees van Deemter

56
**Michael P. Frank / Kees van Deemter**

Basic Set Notations Set enumeration {a, b, c} and set-builder {x|P(x)}. relation, and the empty set . Set relations =, , , , , , etc. Venn diagrams. Cardinality |S| and infinite sets N, Z, R. Power sets P(S). 3/28/2017 Michael P. Frank / Kees van Deemter

57
**Discrete Mathematics and its Applications**

3/28/2017 Axiomatic set theory Various axioms, e.g., saying that the union of two sets is also a set One key axiom: Given a Predicate P, construct a set. The set consists of all those elements x such that P(x) is true. But, the resulting theory turns out to be logically inconsistent! This means, there exist set theory propositions p such that you can prove that both p and p follow logically from the axioms of the theory! The conjunction of the axioms is a contradiction! This theory is fundamentally uninteresting, because any possible statement in it can be (very trivially) “proved” by contradiction! This is a nice exercise. We won’t worry about this particular inconsistency (Russell’s paradox) in this course, because the extra restrictions on the theory that need to be imposed to prevent the problem are of a rather esoteric and technical nature, and they don’t really affect anything about the way we apply sets in everyday practice. So, we will go ahead and just use naïve set theory with the understanding that all of our arguments could be replaced almost word-for-word by arguments based on some more well-founded version of set theory. One of the most popular set theories that has no known internal contradictions is Zermelo-Fraenkel (ZF) Set Theory. It is sometimes also augmented with an extra axiom called the “Axiom of Choice,” producing another widely-used set theory, ZFC (Zermelo-Fraenkel with Choice). However, the Axiom of Choice has been proven to be independent of the other axioms, which means that you could just as validly add the negation of the axiom of choice to ZF instead. In other words, not only is the axiom of choice not provable from ZF, but is has no inherent truth value within the context of ZF. We are free to make up whatever truth value we want for it, and then explore the resulting theory. This is just an illustration of the more general principle that what we are doing in mathematics is ultimately just inventing an arbitrary set of axioms to start out with, that have no inherent “truth” in and of themselves, and exploring what results from them. Ultimately, the only absolute mathematical “truths” are the tautologies saying that such-and-such consequence follows logically from such-and-such axioms. 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

58
**This version of Set Theory is inconsistent**

Discrete Mathematics and its Applications 3/28/2017 This version of Set Theory is inconsistent Russell’s paradox: Consider the set that corresponds with the predicate x x : S = {x | xx }. Now ask: is SS? Turn into exercise! See note about ZF in the earlier slide near the start of this module. Bertrand Russell was the guy who discovered this particular pathalogical example. The question of whether it is a member of itself is known as “Russell’s Paradox.” 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

59
**Discrete Mathematics and its Applications**

3/28/2017 Russell’s paradox Let S = {x | xx }. Is SS? If SS, then S is one of those objects x for which xx. In other words, SS With Proof by Contradiction, we have SS If SS, then S is not one of those objects x for which xx. In other words, SS With Proof by Contradiction, we have SS We conclude that both SS nor SS Paradox! Turn into exercise! See note about ZF in the earlier slide near the start of this module. Bertrand Russell was the guy who discovered this particular pathalogical example. The question of whether it is a member of itself is known as “Russell’s Paradox.” 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

60
**Discrete Mathematics and its Applications**

3/28/2017 To avoid inconsistency, set theory must somehow change Turn into exercise! See note about ZF in the earlier slide near the start of this module. Bertrand Russell was the guy who discovered this particular pathalogical example. The question of whether it is a member of itself is known as “Russell’s Paradox.” Bertrand Russell 3/28/2017 Michael P. Frank / Kees van Deemter (c) , Michael P. Frank

61
**One technique to avoid the problem:**

Given a set S and a predicate P, construct a new set, consisting of those elements x of S such that P(x) is true. You’ve seen this technique in use: Haskell’s list comprehensions allow us to write [x | x [1..] , even x], but not simply [x | even x], 3/28/2017 Michael P. Frank / Kees van Deemter

62
**Another technique to avoid the problem:**

Russell’s paradox arises from the fact that we can write xx (or xx, for that matter). Forbid such expressions using types. You’ve seen this technique in use: Haskell’s use of typing. Applied to the present case: give a type that forbids it from relating two things of the same type. 3/28/2017 Michael P. Frank / Kees van Deemter

63
**Our focus: computability**

We shall not worry about “saving” set theory from paradoxes like Russell’s Instead, we shall use the Russell paradox in a different setting Before we do this, we need to talk about computability and Turing Machines. 3/28/2017 Michael P. Frank / Kees van Deemter

64
**Michael P. Frank / Kees van Deemter**

3/28/2017 Michael P. Frank / Kees van Deemter

Similar presentations

Presentation is loading. Please wait....

OK

310409-THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.

310409-THEORY OF COMPUTATION Komate AMPHAWAN 1. 2.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on trial and error dennis Ppt on film industry bollywood songs Convert free pdf to ppt online convertor Ppt on asian continent animals Ppt on do's and don'ts of group discussion tips Free ppt on motivational skills Ppt on viruses and antivirus for computers Ppt on new zealand culture clothing Ppt on water quality standards Ppt on minimum wages act 2015