Presentation is loading. Please wait.

Presentation is loading. Please wait.

ICS 253: Discrete Structures I

Similar presentations


Presentation on theme: "ICS 253: Discrete Structures I"— Presentation transcript:

1 ICS 253: Discrete Structures I
King Fahd University of Petroleum & Minerals Information & Computer Science Department ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums

2 Reading Assignment K. H. Rosen, Discrete Mathematics and Its Applications, 6th Ed., McGraw-Hill, 2006. Chapter 2

3 Introduction Many important discrete structures are built using sets.
For example: combinations used extensively in counting, relations, graphs and finite state machines. Functions play important roles throughout discrete mathematics. For example, they are used to represent the computational complexity of algorithms, to study the size of sets, to count objects, etc. Sequences and strings are special types of functions. We will introduce some important types of sequences, and will address the problem of identifying a pattern for the terms of a sequence from its first few terms. Using the notion of a sequence, we will define what it means for a set to be countable. Adding consecutive terms of a sequence, making a sum, will prove to be helpful in many discrete structures applications.

4 Section 2.1: Sets A Set is an unordered collection of “objects”.
Defined by Cantor 1895 Objects in a set are also called elements or members of a set. Example: A set of vowels, V= {a, e, i, o, u} Bertrand Russel in 1902 showed that this definition may lead to paradoxes. A paradox means a logical inconsistency. Paradoxes occur if no “restriction” is made on the objects of a set Q38 pp. 121: Russel’s Paradox: Let S contain all sets x where x does not belong to itself, i.e. S = { x | x  x}. Show that S is not well-defined by showing that both SS and SS lead to a contradiction

5 Examples Q1(a) pp 119: List the members of these sets. a) {x | x is a real number such that x2 = 1} Q2 (b,c) pp 119: Use set builder notation to give a description of each of these sets. b) {-3, -2, -1,0,1,2, 3} c) {m,n,o,p}

6 Some Notations and Preliminaries
ℕ = {0,1,2,…} set of natural numbers ℤ = {…, -2, -1, 0, 1, 2, …} set of integers ℝ: set of real numbers ℚ: set of rational numbers Two sets are equal if and only if they have the same elements. i.e. order and repetitions are irrelevant. The set A is a subset of B if and only if every element of A is also an element of B, denoted by A  B. i.e. x(xA  xB) Prove that   S for all sets S

7 Venn Diagrams Used to graphically represent sets Universal set is represented by a rectangle, all other subsets are represented by circles and/or other geometric shapes. Q#12 pp.120: Use a Venn diagram to illustrate the relationship A  B and B  C.

8 Proper Subset More Preliminaries Theorem 1: For every set S   S
Proof: Proper Subset

9 Examples Q5 pp 119: For each of the following sets, determine whether 2 is an element of that set. a) {xℝ | x is an integer greater than 1} b) {xℝ | x is the square of an integer} c) {2,{2}} d) {{2},{{2}}} e) {{2},{2,{2}}} f) {{{2}}}

10 More Preliminaries Definition: Let S be a set. If there are exactly n distinct elements in S, where n is a non-negative integer, we say that S is a finite set of cardinality n, denoted by |S|=n. Otherwise, the set is infinite. What is the cardinality of the set of vowels in the English language? Given a set S, the power set of S is the set of all subsets of the set S, and is denoted by P(S). If |S|=n, |P(S)|=2n elements

11 Examples What is the power set of
{1,2} {} {{1,2}} What is the cardinality of each of the following sets {a} {{a}} {a,a,a,a} {a,{a},{a,{a}}}

12 Cartesian Products The ordered n-tuple (a1, a2,…, an) is the ordered collection that has a1 as its first element, a2 as its second element, …, an as its nth element. Two ordered tuples (a1, a2,…,am) and (b1, b2,…, bn) are said to be equal if and only if m = n and ai= bi for 1  i  n. An ordered 2-tuple is called an ordered pair. The Cartesian product of the sets A1, A2, …, An, denoted by A1 A2  …  An is the set of ordered n-tuples (a1, a2,…, an), where ai belongs to Ai, for i=1,2,…, n.

13 Examples What is the Cartesian product of A={1,2}, B={3,4} and C={5}? Q23 pp 120: Let A={a, b, c, d} and B={y, z}. Find a) A  B b) B  A

14 Using Set Notation with Quantifiers
xS (P(x)) is shorthand for x(xS  P(x)). Similarly, xS (P(x)) is shorthand for …………… Note that x P(x) is true over the domain U if and only if the truth set of P is the set U. Likewise, x P(x) is true over the domain U if and only if the truth set of P is nonempty. Truth Sets of Quantifiers

15 Examples Q33 pp120: Translate each of these quantifications into English and determine its truth value. a) xℝ (x2  – 1) b) xℤ (x2 = 2) c) xℤ (x2 > 0) d) xℝ (x2 = x)

16 Examples Q35 pp120: Find the truth set of each of these predicates where the domain is the set of integers, ℤ: a) P(x): “x2 < 3” b) Q(x): “x2 > x” c) R(x): “2x + 1 = 0”

17 Section 2.2: Set Operations
Let A and B be sets. The union of the sets A and B, denoted by AB, is the set that contains those elements that are either in A or in B, or in both. The intersection of the sets A and B, denoted by AB, is the set containing those elements in both A and B. A and B are called disjoint sets if their intersection is the empty set. The difference of A and B, denoted by A  B, is the set containing those elements that are in A but not in B. The difference of A and B is also called the complement of B with respect to A.

18 Question 4 page 95: Let A={a,b,c,d,e} and B={a,b,c,d,e,f,g,h}. Find:
Complement of a Set Let U be the universal set. The complement of the set A, denoted by A, is the complement of A with respect to U, i.e. U  A. Question 4 page 95: Let A={a,b,c,d,e} and B={a,b,c,d,e,f,g,h}. Find: A  B A  B A  B B  A

19 Example Q32 pp 131: The symmetric difference of A and B, denoted by A  B, is the set containing those elements in either A or B, but not in both A and B. Find the symmetric difference of { 1, 3, 5} and {1, 2, 3}.

20 Cardinality of Some Set Operations
Given finite sets A and B, |AB| = |A| + |B| – |A  B|. Can you come up with a law for the |A – B|?

21 Set Identities Identity Laws Domination Laws Idempotent Laws
Complementation Law Commutative Laws

22 Set Identities (Cont.) Associative Laws Distributive Laws De Morgan’s
Absorption Laws Complement Laws

23 Set Identities Verification
Prove that Using the definitions Using membership tables

24 Examples Q30 pp 131: Can we conclude that A = B if A, B and C are sets such that A  C = B  C ? A  C = B  C ?

25 Generalized Union and Intersection
The union of a collection of sets is the set that contains those elements that are members of at least one set in the collection. The intersection of a collection of sets is the set that contains those elements that are members of all the sets in the collection.

26 Examples Q47 pp 131: Let Ai be the set of all nonempty bit strings (i.e. bit strings of length at least one) of length not exceeding i. Find

27 Computer Representation of Sets
Although sets are unordered, representing the universal set in a specific order in computers has a lot of advantages U must be finite, with number of elements not exceeding available memory The members of U are given an arbitrary order, i.e. {a1, a2, …, an} Any subset A of U is represented with a n-bit string S, where n=|U|, such that for each element e  U at position j: If e  A then Sj=1 else Sj=0 What is the representation of U and ? What is the intersection, union, difference?

28 Example Q55 (a,c) pp 132: Show how bitwise operations on bit strings can be used to find these combinations of A = {a, b, c, d, e}, B={b, c, d, g, p, t, v}, C = {c, e, i, 0, u, x , y, z} and D = {d, e, h, i, n, o, t, u, x, y}. a) A  B c) (A  D)  (B  C) *) A  B

29 Section 2.3: Functions The concept of a function is important in discrete mathematics Sequences and strings Algorithm efficiency in space and time Algorithm development through recursive functions Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A f(a) = b b is the image of a and a is the preimage of b. f : A  B (f maps A to B) A: Domain of f. B: Codomain of f. Range of f: Set of all images of elements in A. Functions are sometimes called mappings or transformations

30 Examples

31 Examples Q5 pp 146: Find the domain and range of these functions. Note that in each case, to find the domain, determine the set of elements assigned values by the function. a) the function that assigns to each bit string the number of ones minus the number of zeros b) the function that assigns to each bit string twice the number of zeros in that string c) the function that assigns the number of bits left over when a bit string is split into bytes (which are blocks of 8 bits) d) the function that assigns to each positive integer the largest perfect square not exceeding this integer

32 Examples The domain and codomain of functions are often specified in programming languages. For instance, the Java statement int floor(float real) { . . .} specifies that the domain and range of the function floor are………………

33 Some Operations on Functions
Let f1 and f2 be functions from A to ℝ. Then f1 + f2 is a function from A to ℝ. f1f2 is a function from A to ℝ. Is f1/f2 a function? Let f be a function from set A to set B and let S be a subset of A. The image of S is a subset of B that consists of the images of the elements of S, denoted by f(S).

34 Some Functional Properties
A function f is said to be one-to-one or injective if and only if f(x)=f(y) implies that x=y for all x and y in the domain of f. The function is said to be an injection. A function f from A to B is said to be onto or surjective if and only if for every element bB there is an element aA with f(a)=b. The function is said to be a surjection. A function f is called a one-to-one correspondence, or a bijection, if it is both one-to-one and onto.

35 Examples Q10 and 11 pp 146: Determine whether each of these functions from {a, b, c, d} to itself is one-to-one or onto. f(a) = b, f(b) = a, f(c) = c, f(d) = d f(a) = b, f(b) = b, f(c) = d, f(d) = c f(a) = d, f(b) = b, f(c) = c, f(d) = d Q12 and 13 pp 146: Determine whether each of these functions from ℤ to ℤ is one-to-one or onto. a) f(n) = n – 1 b) f(n) = n2 + 1 c) f(n) = n3 d) f(n) = n/2

36 More Properties A function f whose domain and co-domain are subsets of ℝ is called strictly increasing if f(x) < f(y) whenever x < y and x and y are in the domain of f. A function f whose domain and co-domain are subsets of ℝ is called strictly decreasing if f(x) > f(y) whenever x < y and x and y are in the domain of f.

37 Example Q21 pp 147: Let f: ℝ  ℝ and f(x) > 0. Show that f(x) is strictly decreasing if and only if the function g(x) = 1/f(x) is strictly increasing.

38 Inverse Functions Let f be a 1:1 correspondence from the set A onto the set B. The inverse function of f, denoted by f -1, is the function that assigns to an element b  B the unique element aA such that f(a)=b. f –1(b)=a when f(a) = b Find the inverse function for each 1:1 correspondence in the previous slide.

39 Composition of Functions
Let g be a function from the set A to the set B and let f be a function from the set B to the set C. The composition of the functions f and g, denoted by f  g is defined by (f  g)(a) = f (g(a))

40 Example Q32 pp 147: Find f  g and g  f, where f(x)=x2 + 1 and g(x)=x + 2, are functions from ℝ to ℝ.

41 Graphs of Functions Let f be a function from the set A to the set B. The graph of the function f is the set of ordered pairs {(a,b) | a  A and f(a) = b}

42 Graph of f(n)=1 – n2 from ℤ to ℤ

43 Some Important Functions
The floor function assigns to the real number x the largest integer that is less than or equal to x, denoted by x. The ceiling function assigns to the real number x the smallest integer that is greater than or equal to x, denoted by x. 1/2 = 1/2 = -1/2 = -1/2 = The factorial function f: ℕ ℤ+, denoted by f(n) = n!, is the product of the first n positive integers, so f(n) = n (n – 1) … (2)(1) and f(0)=1.

44 Graph of f(x)= x for x in ℝ

45 Graph of f(x)= x for x in ℝ

46 Q60 pp 148: Graph of f(x)= x/2 for x in ℝ

47 Useful Properties of the Floor and Ceiling Functions

48 Example Prove that  x + n  =  x  + n, where x  ℝ and n  ℤ

49 Section 2.4: Sequences and Summations
A sequence is a function from a subset of the set of integers (usually either the set {0, 1, 2, . . .} or the set {1, 2, 3, . . .}) to a set S. We use the notation an to denote the image of the integer n. We call an a term of the sequence. The notation {an} is used to describe the sequence

50 Notation A geometric progression is a sequence of the form a, ar, ar 2 ,..., ar n ,... where the initial term a and the common ratio r are real numbers. A geometric progression is a discrete analogue of the exponential function f (x) = ar x .

51 Notation An arithmetic progression is a sequence of the form a, a + d, a + 2d, , a + n d, . . . where the initial term a and the common difference d are real numbers. An arithmetic progression is a discrete analogue of the linear function ……

52 Examples Q2 pp 160: 2. What is the term a8 of the sequence {an} if an equals a) 2n – l? b) 7? c) 1 + (–1)n ? d) –(–2)n?

53 Sequence Generalization
The problem is how to generalize a sequence from its first few terms. Examples 1, 1/2, 1/4, 1/8, 1/16, … 1, 3, 5, 7, 9, … 1, –1, 1, –1 , 1, … 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, … 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, …

54 A Table to Memorize! nth term First 10 terms n2
1, 4, 9, 16, 25, 36, 49, 64, 81, 100, ... n3 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, ... n4 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000, ... 2n 2, 4, 8, 16, 32, 64, 128, 256 , 512, 1024, ... 3n 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, ... n! 1, 2, 6, 24, 120, 720, 5040, 40320, , ,...

55 More Examples 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, 59047, … Q10 (b,c) pp 161: For each of these lists of integers, provide a simple formula or rule that generates the terms of an integer sequence that begins with the given list. Assuming that your formula or rule is correct, determine the next three terms of the sequence. b) 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, ... c) 1, 10, 11, 100, 101, 110, 111, 1000, 1001 , 1010, 1011, . . .

56 b) 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, ... c) 1, 10, 11, 100, 101, 110, 111, 1000, 1001 , 1010, 1011, . . .

57 Summations Important rule:
j : index of summation, can be replaced by any arbitrary variable m: lower limit n: upper limit Important rule:

58 Examples Express the sum of the first 100 terms of the sequence {an}, where an = 1/n for n = 1, 2, 3, …

59 Index Changes in the Summation
Consider the summation and assume that we want the index to start from 0 to n – 1 rather than 1 to n. How do we change the index?

60 Theorem 1 If a and r are real numbers and r  0, then Proof

61 Examples

62 Some Useful Summations

63 More Examples Find Let x be a real number with |x|<1. Find

64 More Examples Q10 (a) pp 161: For each of these lists of integers, provide a simple formula or rule that generates the terms of an integer sequence that begins with the given list. Assuming that your formula or rule is correct, determine the next three terms of the sequence. 3, 6, 11, 18, 27, 38, 51, 66, 83, 102, ...

65 Cardinality Definition: The sets A and B have the same cardinality if and only if there is a one-to-one correspondence from A to B. Definition: A set that is either finite or has the same cardinality as the set of positive integers is called countable. A set that is not countable is called uncountable. When an infinite set S is countable, we denote the cardinality of S by  0 (where 0 is aleph, the first letter of the Hebrew alphabet). We write |S| = 0 and say that S has cardinality "aleph null."

66 Cardinality Question: What do we need to do to find whether a set is countable or not? Example 1: Show that the set of odd positive integers is a countable set.

67 Cardinality Example 2: Show that the set of all integers is countable.

68 Cardinality Example 3: Show that the set of positive rational numbers is countable.

69 Cardinality Example 4: Show that the set of real numbers is an uncountable set.


Download ppt "ICS 253: Discrete Structures I"

Similar presentations


Ads by Google