Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview of Sets an Functions for ICS 6D

Similar presentations


Presentation on theme: "Overview of Sets an Functions for ICS 6D"— Presentation transcript:

1 Overview of Sets an Functions for ICS 6D
Prof. Sandy Irani

2 Sets A set is an unordered collection of items.
For example, S = {a, b, c, d} Curly braces {} denote that order does not matter: {a, b, c, d} = {b, a, d, c} Each item is called an element of the set. b is an element of S (b ∈ S) e is not an element of S (e ∉ S)

3 Cardinality of Sets An infinite set has an infinite number of elements. Example: the set of all integers. A finite set has a finite number of elements. Example: the set of students enrolled in ICS 6D Spr 2016. If S is a finite set, then the cardinality of S (denoted |S|) is the number of elements in S. Example: S = {a, b, c, d}. |S| =

4 Famous Sets ℤ = the set of all integers ℝ = the set of real numbers
ℚ = the set of rational numbers (A number x is rational if x = c/d, where c and d are integers and d ≠ 0.) ℕ = natural numbers (positive integers)  the empty set (sometimes denoted as {})

5 Specifying a Set Roster notation: List the elements with curly braces
{1, 3, 5, 9} List elements with an inferred pattern in ellipses {1, 3, 5, …., 99} Set builder notation {x : x ∈ S and some additional conditions on x} {x ∈ S : additional conditions on x} S is a larger set that has already been defined “:” is read as “such that”

6 Subsets T is a subset of S (T ⊆ S): To show T ⊈ S, Example:
If x ∈ T then x ∈ S To show T ⊈ S, Find x ∈ T and x ∉ S. Example: S = {a, b, c, d} T = {a, b, c} V = {a, e}

7 Set Operations Union: x ∈ A ∪ B ↔ x ∈ A ∨ x ∈ B Intersection:
Complement: x ∈ A ↔ (x ∈ A) (all elements and sets contained in a Universe set, usually denoted by U)

8 Set Operations Example
A = { x ∈ ℤ : x is odd } U = ℤ B = { x ∈ ℤ : 0 < x 20 } C = {4, 5, 6, 7} A ∩ B C ∩ A C ⊆ B? B ⊆ A? 6 ∈ A ∪ C ? 26 ∈ A ∪ C ?

9 Power Set Let A be a finite set. Power set of A (denoted P(A)) is the set of all subsets of A. Example: A = {a, b, c} P(A) = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} } {a, b} ∈ P(A) ? { {a} } ⊆ P(A) ? {a, b} ⊆ P(A) ? Ø ⊆ P(A) ? a ∈ P(A) ? Ø ∈ P(A) ? {a} ∈ P(A) ?

10 Pairs, Triplets and Tuples
(a, b) is an ordered pair. Parens (as opposed to {}) indicate that order matters: (a, b) ≠ (b, a) {a, b} = {b, a} (a, b, c) is an ordered triplet b is the second entry of the triplet (a, b, c) (a, b, c, d) is an ordered 4-tuple (a1, a2 , …, an) is an ordered n-tuple.

11 Cartesian Product S x T = { (s, t) : s ∈ S and t ∈ T }
Let S and T be sets Cartesian product of S and T is S x T = { (s, t) : s ∈ S and t ∈ T } Example: S = {a, b, c} T = {1, 2} S x T = { (a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2) }

12 Cartesian Product T = {1, 2}
T x T = T2 = { (1, 1), (1, 2), (2, 1), (2, 2) } T ⊆ T2 ? What is ℝ x ℝ? ℤ x ℤ?

13 Cartesian Product A1, …, An sets:
Example: Drink = {OJ, Coffee} Main = {Waffles, Eggs, Pancakes} Side = {Hash browns, Toast} Breakfast Selections = Drink x Main x Side (OJ, Eggs, Toast) ∈ Drink x Main x Side A1, …, An sets: A1x … x An = { (a1, …, an) : ai in Ai for 1 ≤ i ≤ n }

14 Cartesian Product Let S be a set:
Sn = S x S x … x S = { (s1, .., sn) : each si in S, for 1 ≤ i ≤ n } Example: {0, 1}5 Example: ℝ4

15 N-tuples and Strings If  is a set of single characters, elements in n can be denoted without the punctuation, in which case they are called strings. Example:  = {a, b} (a, b, a, b) ∈  (denoted as an n-tuple) abab ∈  (denoted as a string) {0, 1}3 = set of all binary strings with 3 bits: {0, 1}3 = { 000, 001, 010, 011, 100, 101, 110, 111 } n-tuple punctuation is important if the underlying set is not a set of single characters!

16 Strings x  = x = x Example: |abba| = 4. Concatenation:
x = abba y = bab Concatenation of x and y is xy = abbabab Concatenation of x and a is abbaa Empty string  has no characters: x  = x = x The length of a string x (denoted by |x|) is the number of characters in the string: Example: |abba| = 4.

17 Infinite sets of strings
The set of all strings of any length over an alphabet : * = 0 ∪ 1 ∪ 2 ∪ ….. Example: {0, 1}* = {, 0, 1, 00, 01, 10, 11, 000,….} + = 1 ∪ 2 ∪ 3 ∪ ….. Example: {0, 1}+ = {0, 1, 00, 01, 10, 11, 000,….}

18 Functions f: A → B A function maps elements of one set onto another:
A is the domain A = {a, b, c, d} B is the target B = {1, 2, 3, 4, 5} 1 a 2 b A function maps each element of the domain to a unique element in the target set. 3 c 4 d 5

19 Functions f: A → B A function maps elements of one set onto another:
A is the domain A = {a, b, c, d} B is the target B = {1, 2, 3, 4, 5} 1 a 2 b The range is the set of elements y in the target for which there is an element x in the domain such that f(x) = y. 3 c 4 d 5

20 Functions on ℝ specified by an explicit formula
f(x) = x2 - 4x + 3 Examples of non-functions: f(x) = ±√x f(x) = 2/x

21 Functions: one-to-one
A function f: D → T is one-to-one if no two elements in the domain map on to the same element in the target: ∀ x ∈ D, x’ ∈ D, (x ≠ x’) → f(x) ≠ f(x’) 1 a 1 a 2 b 2 b 3 c 3 c 4 d 4 d 5 5

22 One-to-one Examples f: ℝ → ℝ f(x) = x2 f: ℤ → ℤ f(x) = 2x + 3
f: {0, 1}3 → {0, 1}3 replace the last bit with 0, f(111) = 110 f: {0, 1}3 → {0, 1}4 add a 0 to the end f(101) = 1010 A = {a, b, c} f: P(A) → ℤ. For X ⊆ A, f(X) = |X|

23 One-to-one examples f: {0, 1}3 → {0, 1}2 drop the last bit f(101) = 10
000 001 00 010 01 If f: D → T is one-to-one, then |D| ≤ |T| 011 10 100 11 101 If f: D → T and |D| > |T| The f can not be one-to-one. 110 111

24 Functions: onto A function f: D → T is onto if every element in the target is mapped to by some element in the domain For every y ∈ T, there is an x ∈ D, such that f(x) = y a 1 a 1 b 2 b 2 c 3 c 3 d d

25 Onto Examples f: ℝ → ℝ f(x) = x2 f: ℤ → ℤ f(x) = 2x + 3
f: {0, 1}3 → {0, 1}3 replace the last bit with 0, f(111) = 110 f: {0, 1}3 → {0, 1}2 drop the last bit f(101) = 10 f: {0, 1}3 → {0, 1}3 remove the last bit and concatenate it at the beginning of the string: f(101) = f(100) = 010

26 Onto Examples If f:D →T is onto, then |T| ≤ |D| If f:D →T and
Example f: {0, 1}2 → {0, 1}3 add a 0 to the end f(10) = 100 000 001 00 010 If f:D →T is onto, then |T| ≤ |D| 01 011 10 100 11 101 If f:D →T and |T| > |D| The f can not be onto. 110 111

27 Bijections Definition: A function f:D→T is a bijection if it is
one-to-one and onto a 1 b 2 c 3 d 4 If f:D→T and f is a bijection, then |D| = |T|

28 Inverse of a function A function f is a bijection if and only if
f: D → T The inverse of f (if it exists) is a function f-1: T → D For every x ∈ D and y ∈ T, f(x) = y ↔ f-1(y) = x a 1 1 a A function f is a bijection if and only if f has an inverse b 2 2 b c 3 3 c d 4 4 d f f-1

29 Inverse of a function example
A string is a palindrome if it is the same after it is reversed. Let P6 be the set of all 6-bit strings that are also palindromes. Bijection between {0, 1}3 and P6 f: {0, 1}3 → P6 f(x) = xxR (xR is the reverse of x)


Download ppt "Overview of Sets an Functions for ICS 6D"

Similar presentations


Ads by Google