900 likes | 2.19k Views
f ( ) =. A. B. Sets and Functions. Lecture 4: Sep 12. (based on slides in MIT 6.042). Sets. Informally : A set is a collection of mathematical objects, with the collection treated as a single mathematical object. Examples:. real numbers, complex numbers, C
E N D
f( ) = A B Sets and Functions Lecture 4: Sep 12 (based on slides in MIT 6.042)
Sets Informally: A setis a collection of mathematical objects, with the collection treated as a single mathematical object. Examples: • real numbers, • complex numbers, C • integers, • empty set, • set of all subsets of integers , pow() the power set
Membership {7, “Albert”, /2, T} order doesn’t matter x is an element of A x is inA Examples: /2 {7, “Albert”,/2, T} /3 {7, “Albert”,/2, T} 14/2 {7, “Albert”,/2, T} pow() 7 2/3 An element is in or not in a set: {7, /2, 7} is same as {7, /2} (No notion of being in the set more than once)
Containment A is a subset of B A is contained inB Every element of A is also an element of B. Examples: , C, {3}{5,7,3} every set, A A
Defining Sets The set of elements, x, in Asuch thatP(x) is true. The set of even integers: The set of prime numbers:
New Sets from Old union: intersection: difference: complement: power set: More about set operations in tutorial.
Russell’s Paradox so Let S be W and reach a contradiction: The fallacy: W is not a set! No set is a member of itself, so W = the collection of all sets, which isnot a set! NOT every mathematically well-defined collection of elements is actually a set.
Functions function, f, from set A to set B associates an element , with an element The domain of f is A. The codomain of f is B. Example: f is the string-length function: f(“aabd”) = 4. Domain is the set of strings, codomain is nonnegative integers. More examples: student ID, gender, etc.
f( ) = A B Total Functions is total iff every element of A is assigned a B-value by f exactly 1 arrow out
f( ) = Surjections is asurjectioniff every element of B is f of something 1 arrow in A B |A| ≥|B|
f( ) = A B Injections is an injection iff every element of B is f of at most 1 thing ≤ 1 arrow in total |A| ≤|B|
f( ) = A B Bijections is a bijection iff it is total, surjection, injection. exactly one arrow in exactly one arrow out |A| =|B|
Integers vs Positive Integers Now we can use functions to compare different sets. Question: Is the set of integers larger than the set of positive integers? Define a bijection between the positive integers and all integers 1 2 3 4 5 6 7 8 . . . 0 1 −1 2 −2 3 −3 4 . . . n/2, if n is even; −(n − 1)/2, if n is odd. f(n) = So, these two sets have the same cardinality! A set is countable if there is a surjection from natural numbers to it.
Rational Numbers vs Positive Integers Question: Is the set of rational number countable? The set of “pair of integers” (a,b) is not smaller than the set of rational number. We want to show that the set of “pair of integers” is countable, by defining a surjection from natural numbers. This would then imply the set of rational is countable.
Rational Numbers vs Positive Integers (0, 0), (0, 1), (0,−1), (0, 2), (0,−2), (0, 3), (0,−3), . . . (1, 0), (1, 1), (1,−1), (1, 2), (1,−2), (1, 3), (1,−3), . . . (−1, 0),(−1, 1),(−1,−1),(−1, 2),(−1,−2),(−1, 3), (−1,−3), . . . (2, 0), (2, 1), (2,−1), (2, 2), (2,−2), (2, 3), (2,−3), . . . (−2, 0),(−2, 1),(−2,−1),(−2, 2),(−2,−2), (−2, 3),(−2,−3), . . . If you map the set of positive integers to the top row first, then you will not be able to reach the second row. The trick is to visit the rational numbers diagonal by diagonal. Each diagonal is finite, so eventually every pair will be visited. Therefore, there is a surjection from the set of positive integers, to the set of pair of integers, and so we are done.
Binary Strings vs Positive Integers Question: Is the set of binary strings countable? Theorem: No surjection mapping positive integers to binary strings. The string map to the first natural number The string map to the fifth natural number It can not be in any row i because its i-th bit is different, and so this string is not mapped! The opposite of the diagonal
Diagonal Argument Similarly, real numbers and power sets can be shown to be uncountable. This argument is called Cantor’s diagonal argument. http://en.wikipedia.org/wiki/Cantor's_diagonal_argument This has been used in many places; for example the Russell’s paradox. Relations are more general than functions, will be discussed in tutorial.