ICS 253: Discrete Structures I

Slides:



Advertisements
Similar presentations
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Advertisements

Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Functions Section 2.3 of Rosen Fall 2008
Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
CSE115/ENGR160 Discrete Mathematics 02/22/11 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 02/16/12 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 02/21/12
Sets Section 2.1. Introduction Sets are one of the basic building blocks for the types of objects considered in discrete mathematics. Important for counting.
Sets 1.
CSE115/ENGR160 Discrete Mathematics 02/10/11 Ming-Hsuan Yang UC Merced 1.
Sets 1.
modified from UCI ICS/Math 6D, Fall Sets+Functions-1 Sets “Set”=Unordered collection of Objects “Set Elements”
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Functions, Sequences, and Sums
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sifth Edition, Mc Graw-Hill, 2007 Chapter 2: Basic Structures: Sets, Functions, Sequences.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
Week 15 - Wednesday.  What did we talk about last time?  Review first third of course.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 2 The Language of Mathematics.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (2)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Basic Structures: Sets, Functions, Sequences, and Sums CSC-2259 Discrete Structures Konstantin Busch - LSU1.
2. 1 Basic structures Sets Set Operations Functions Sequences & Sums
Chapter 5 – Relations and Functions. 5.1Cartesian Products and Relations Definition 5.1: For sets A, B  U, the Cartesian product, or cross product, of.
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Discrete Mathematics R. Johnsonbaugh
MATH 224 – Discrete Mathematics
CompSci 102 Discrete Math for Computer Science
Sets. Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration.
Chapter 2 With Question/Answer Animations. Chapter Summary Sets The Language of Sets Set Operations Set Identities Functions Types of Functions Operations.
Chapter 2 With Question/Answer Animations. Section 2.1.
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
Chapter 2 With Question/Answer Animations. Section 2.1.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
CPCS 222 Discrete Structures I
ICS 253: Discrete Structures I
CSE15 Discrete Mathematics 02/13/17
Dr. Ameria Eldosoky Discrete mathematics
Sets Section 2.1.
CS 2210:0001 Discrete Structures Sets and Functions
CSE15 Discrete Mathematics 02/15/17
MATH 224 – Discrete Mathematics
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Discrete Math (2) Haiming Chen Associate Professor, PhD
CS100: Discrete structures
Lecture 7 Functions.
CSE15 Discrete Mathematics 02/27/17
CS100: Discrete structures
ICS 253: Discrete Structures I
The aim of education is to teach students how to think rather than what to think. Sets The set is the fundamental discrete structure on which all other.
ICS 253: Discrete Structures I
Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007
Presentation transcript:

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

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

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.

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

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}

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

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.

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

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}}}

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

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}}}

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.

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

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

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)

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”

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.

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

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}.

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|?

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

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

Set Identities Verification Prove that Using the definitions Using membership tables

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 ?

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.

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

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?

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

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

Examples

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

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………………

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).

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.

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

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.

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.

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.

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))

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

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}

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

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.

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

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

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

Useful Properties of the Floor and Ceiling Functions

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

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

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 .

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 ……

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?

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, …

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, 362880, 3628800,...

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, . . .

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

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

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

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?

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

Examples

Some Useful Summations

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

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, ...

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."

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.

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

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

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