Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.

Slides:



Advertisements
Similar presentations
Prof. Johnnie Baker Module Basic Structures: Sets
Advertisements

Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Lecture 2.3: Set Theory, and Functions* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren.
Discrete Structures & Algorithms Functions & Asymptotic Complexity.
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.
Sets 1.
Sets 1.
modified from UCI ICS/Math 6D, Fall Sets+Functions-1 Sets “Set”=Unordered collection of Objects “Set Elements”
CS104 : Discrete Structures Chapter II Fundamental Structures.
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.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
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,
ICS 253: Discrete Structures I
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.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
Discrete Mathematics CS 2610 September 12, Agenda Last class Functions  Vertical line rule  Ordered pairs  Graphical representation  Predicates.
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
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.
Basic Structures: Functions Muhammad Arief download dari
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
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.
Lecture 2.1: Sets and Set Operations CS 250, Discrete Structures, Fall 2014 Nitesh Saxena Adopted from previous lectures by Cinda Heeren.
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.
Discrete Mathematics. Set Theory - Definitions and notation A set is an unordered collection of elements. Some examples: {1, 2, 3} is the set containing.
Lecture 2.3: Set Theory, and Functions*
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
Discrete Mathematics CS 2610 January 27, part 2.
Chapter 2 With Question/Answer Animations. Section 2.1.
CSC102 - Discrete Structures Functions
CSci 2011 Discrete Mathematics Lecture 9, 10
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Discrete Mathematics CS 2610 August 31, Agenda Set Theory Set Builder Notation Universal Set Power Set and Cardinality Set Operations Set Identities.
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.
FUNCTIONS.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
ICS 253: Discrete Structures I
Discrete Mathematical
Discrete Mathematical The Set Theory
CS 2210:0001 Discrete Structures Sets and Functions
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
CS100: Discrete structures
Functions.
Lecture 2.1: Sets and Set Operations*
ICS 253: Discrete Structures I
Lecture 2.3: Set Theory, and Functions
Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007
Lecture 2.3: Set Theory, and Functions
Presentation transcript:

Sets Set Operations Functions

1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products

1.1 Introduction and notation {1, 2, 3} is the set containing “1” and “2” and “3.” {1, 1, 2, 3, 3} = {1, 2, 3} since repetition is irrelevant. {1, 2, 3} = {3, 2, 1} since sets are unordered. {0,1, 2, 3, …} is a way we denote an infinite set (in this case, the natural numbers).  = {} is the empty set, or the set containing no element. Note:   {  }. A set is an unordered collection of elements.. Introduction :A set is an unordered collection of elements. Examples.

1.1 Definitions and notation x  S means “x is an element of set S.” x  S means “x is not an element of set S.” A  B means “A is a subset of B.” Venn Diagram or, “B contains A.” or, “every element of A is also in B.” or,  x ((x  A)  (x  B)). B A

1.1 Definitions and notation A  B means “A is a subset of B.” A  B means “A is a superset of B.” A = B if and only if A and B have exactly the same elements iff, A  B and B  A iff, A  B and A  B iff,  x ((x  A)  (x  B)). So to show equality of sets A and B, show: A  BA  B B  AB  A

1.1 Definitions and notation A  B means “A is a proper subset of B.” A  B, and A  B. A  B, and A  B.  x ((x  A)  (x  B))  x ((x  A)  (x  B))   x ((x  B)  (x  A)) A B

1.1 Definitions and notation Quick examples: {1,2,3}  {1,2,3,4,5} {1,2,3}  {1,2,3,4,5} {1,2,3}  {1,2,3,4,5} {1,2,3}  {1,2,3,4,5} Is   {1,2,3}? Yes!  x (x   )  (x  {1,2,3}) holds, because (x   ) is false. Is   {1,2,3}? No! Is   { ,1,2,3}? Yes! Is   { ,1,2,3}? Yes!

1.1 Definitions and notation Is {x}  {x}? Is {x}  {x,{x}}? Is {x}  {x,{x}}? Is {x}  {x}? Yes No Quiz time:

Ways to define sets Explicitly: {John, Paul, George, Ringo} Explicitly: {John, Paul, George, Ringo} Implicitly: {1,2,3,…}, or {2,3,5,7,11,13,17,…} Implicitly: {1,2,3,…}, or {2,3,5,7,11,13,17,…} Set builder: { x : x is prime }, { x | x is odd }. Set builder: { x : x is prime }, { x | x is odd }. In general { x : P(x)}, where P(x) is some predicate. In general { x : P(x)}, where P(x) is some predicate. We read “the set of all x such that P(x)”

Ways to define sets In general { x : P(x)}, where P(x) is some predicate Ex. Let D(x,y) denote the predicate “x is divisible by y” And P(x) denote the predicate  y ((y > 1)  (y < x))   D(x,y) Then { x :  y ((y > 1)  (y < x))   D(x,y) }. is precisely the set of all primes

1.2 Cardinality If S is finite, then the cardinality of S, |S|, is the number of distinct elements in S. If S = {1,2,3} |S| = 3. If S = {3,3,3,3,3} If S =  If S = { , {  }, { ,{  }} } |S| = 1.|S| = 0. |S| = 3. If S = {0,1,2,3,…}, |S| is infinite. (more on this later)

1.3 Power sets If S is a set, then the power set of S is = 2 S = { x : x  S }. P(S) = 2 S = { x : x  S }. If S = {a} If S = {a,b} If S =  If S = { ,{  }} We say, “P(S) is the set of all subsets of S.” 2 S = { , {a}}. 2 S = { , {a}, {b}, {a,b}}. 2 S = {  }.2 S = { , {  }, {{  }}, { ,{  }}}. Fact: if S is finite, |2 S | = 2 |S|. (if |S| = n, |2 S | = 2 n )

1.4 Cartesian Product The Cartesian Product of two sets A and B is: A B = { (a, b) : a  A  b  B} A  B = { (a, b) : a  A  b  B} If A = {Charlie, Lucy, Linus}, and B = {Brown, VanPelt}, then A,B finite  |A  B| = |A||B| A 1  A 2  …  A n = = {(a 1, a 2,…, a n ): a 1  A 1, a 2  A 2, …, a n  A n } A  B = {(Charlie, Brown), (Lucy, Brown), (Linus, Brown), (Charlie, VanPelt), (Lucy, VanPelt), (Linus, VanPelt)} We’ll use these special sets soon!

2. Set Operations 2.1 Introduction 2.2 Sets Identities 2.3 Generalized Set Operations 2.4 Computer Representation of Sets

2.1 Introduction The union of two sets A and B is: A  B = { x : x  A  x  B} If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi}, then A  B = {Charlie, Lucy, Linus, Desi} A B

2.1 Introduction The intersection of two sets A and B is: A  B = { x : x  A  x  B} If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi}, then A  B = {Lucy} A B

2.1 Introduction The intersection of two sets A and B is: A  B = { x : x  A  x  B} If A = { x : x is a US president}, and B = { x : x is in this room}, then A  B = { x : x is a US president in this room} =  Sets whose intersection is empty are called disjoint sets B A

2.1 Introduction The complement of a set A is: If A = {x : x is not shaded}, then  = U and U =  A U

2.1 Introduction The symmetric difference, A  B, is: A  B = { x : (x  A  x  B)  (x  B  x  A)}  = (A – B)  (B – A) = { x : x  A  x  B} U A – B B – A

2.2 Set Identities Identity A  U = A Identity A  U = A A   = A Domination Domination A  U = U A   =  Idempotent Idempotent A  A = A A  A = A

2.2 Set Identities Excluded Middle Excluded Middle Uniqueness Uniqueness Double complement Double complement

2.2 Set Identities Commutativity A  B = B  A Commutativity A  B = B  A A  B = B  A A  B = B  A Associativity (A  B)  C = A  (B  C) Associativity (A  B)  C = A  (B  C) (A  B)  C =A  (B  C) (A  B)  C =A  (B  C) Distributivity Distributivity A  (B  C) = (A  B)  (A  C) A  (B  C) = (A  B)  (A  C)

2.2 Set Identities DeMorgan’s I DeMorgan’s I DeMorgan’s II DeMorgan’s II

4 ways to prove identities Show that A  B and that A  B. Show that A  B and that A  B. Use a membership table. Use a membership table. Use previously proven identities. Use previously proven identities. Use logical equivalences to prove equivalent set definitions. Use logical equivalences to prove equivalent set definitions. New & important Like truth tablesLike  Not hard, a little tedious

4 ways to prove identities Prove that Not a particularly interesting example, sorry.

4 ways to prove identities using a membership table. 0 : x is not in the specified set 1 : otherwise AB A  B Haven’t we seen this before? Prove that

4 ways to prove identities Prove that using logically equivalent set definitions (A  B) = {x :  (x  A  x  B)} = {x :  (x  A)   (x  B)} = {x : (x  A)  (x  B)} = A  B

4 ways to prove identities 4 ways to prove identities Prove that using known identities

2.3 Generalized Set Operations Ex. Let U = N, and define: Then Generalized Union A i ={i, i+1, i+2, …}

Generalized Intersection Ex. Let U = N, and define: Then A i ={i, i+1, i+2, …}

2.4 Computer Representation of Sets Let U = {x 1, x 2,…, x n }, and choose an arbitrary order of the elements of U, say x 1, x 2,…, x n Let A  U. Then the bit string representation of A is the bit string of length n : a 1 a 2 … a n such that a i =1 if x i  A, and 0 otherwise. Ex. If U = {x 1, x 2,…, x 6 }, and A = {x 1, x 3, x 5, x 6 }, then the bit string representation of A is (101011)

Sets as bit strings Ex. If U = {x 1, x 2,…, x 6 }, A = {x 1, x 3, x 5, x 6 }, and B = {x 2, x 3, x 6 }. Then we have a quick way of finding the bit string corresponding to of A  B and A  B. A B A  B A  B Bit-wise ORBit-wise AND

3. Functions 3.1 Introduction 3.2 One-to-One and Onto Functions. 3.3 Inverse Functions and Composition of Functions 3.4 The Graphs of Functions 3.5 Some Important Functions

3.1 Introduction Definition. A function (mapping,map) f is a rule that assigns to each element x in a set A exactly one element y=f(x) in a set B x a y=f(x) b=f(a) AB f  A is the domain, B is the codomain of f.

3.1 Introduction  b = f(a) is the image of a and a is the preimage of b.  A}  The range of f is the set {f(a), a  A} x a y=f(x) b=f(a) AB f

A = {Michael, Tito, Janet, Cindy, Bobby} B = {Katherine Scruse, Carol Brady, Mother Teresa} Let f : A  B be defined as f(a) = mother( a ). Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa Example.

So, image({Michael, Tito}) = {Katherine Scruse} image(A) = B – {Mother Teresa} What about the range? Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa For any set S  A, image(S) = {b :  a  S, f(a) = b }= f(S) Some say it means codomain, others say, image.

Algebra of functions: let f and g be functions with domains A and B. Then the functions f+g, f –g, fg and f/g are defined as follows: domain = A  B domain = {x  A  B /g(x)  0}

Example: let f(x) = x 2, f(x) = x – x 2 be functions from R to R, find f + g and fg. Solution: We have (f + g)(x) = x 2 +(x –x 2 ) = x And (fg)(x) = x 2 (x –x 2 ) = x 3 –x 4

3.2 One-to-One and Onto Functions Definition.A function f: A  B is one-to-one (injective, an injection) if  x,y (f(x) = f(y)  x = y) Not one-to- one Every b  B has at most 1 preimage. Michae l Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa

 A function f is strictly increasing on an interval I  R if  x,y (x < y  f(x) < f(y))  f is strictly decreasing on I if  x,y (x f(y))  It is clear that a strictly increasing or strictly decreasing function is one-to-one. Remark. A function f: A  B is one-to-one iff  x,y (x  y  f(x)  f(y)) Recall that

Onto Functions Definition. A function f: A  B is onto (surjective, a surjection) if  b  B,  a  A f(a) = b Not onto Every b  B has at least 1 preimage. Michael Tito Janet Cindy Bobby Katherine Scruse Carol Brady Mother Teresa

Onto Functions Example. Is the function f(x) = x 2 from Z to Z onto? Solution: The function f is not onto since there is no x in Z such that x 2 = –1 Example. Is the function f(x) = x + 1 from Z to Z onto? Solution: The function f is onto since for every y in Z, there is an element x in Z such that x + 1 = y (by taking x = y –1)

Bijection Definition. A function f: A  B is bijective if it is one-to-one and onto. Every b  B has exactly 1 preimage. Isaak Bri Lynette Aidan Evan Cinda Dee Deb Katrina Dawn

3.3 Inverse Functions and Compositions of Functions Definition. Let f : A  B be a bijection. Then the inverse function of f, denoted by f –1 is the function that assigns each element b in B the unique element a in A such that f(a) = b. Thus f –1 (b) = a. f –1 (Cinda) = Isaak, f –1 (Dee) = Bri, …, f –1 (Dawn) = Evan Isaak Bri Lynette Aidan Evan Cinda Dee Deb Katrina Dawn

Example. Is the function f(x) = x 2 from Z to Z invertible? (i.e. the inverse function exists) Solution: The function f is not onto. Therefore it is not a bijection, and hence not invertible Example. Is the function f(x) = x + 1 from Z to Z invertible? Solution: The function f is a bijection so it is invertible.

Example. Is the function f(x) = x + 1 from Z to Z invertible? What is its inverse? Solution: The function f is a bijection so it is invertible. f(x) = x + 1. To find the inverse, let y be any element in Z, we find the element x in Z such that y = f(x) = x + 1. Solving this equation we obtain Solving this equation we obtain x = y –1. f –1 (y) = Hence f –1 (y) = y –1. f –1 (x) = We also write f –1 (x) = x –1.

A  B B  C A  C Definition. The composition of a function g: A  B and a function f : B  C is the function f o g : A  C defined by Note. The domain of f o g is also the domain of g, and the codomain of f o g is also the codomain of f. g x (input) g(x) f(g(x)) (output ) f o g(x) = f(g(x)) f

xx  g(x)  f(g(x)) g f f o g Arrow diagram for f o g A BC

Example. let f(x) = x 2 and g(x) = x – 3 are functions from R to R. Solution. (f o g)(x) = f(g(x)) = f(x – 3) = (x –3) 2 (g o f)(x) = g(f(x)) = g(x 2 ) = x 2 – 3 This shows that in general: f o g  g o f Find the compositions f o g and g o f

3.4 The Graph of a Function Definition. Let f : A  B be a function. Then the graph of f, is the set of ordered pair (a, b) with a in A and f(a) = b. Example. The graph of the function f : R  R such that f(x) = – x/2 – 25

Example. The graph of the function f : R  R such that f(x)=x 2

Example. The average CO 2 level in the atmosphere is a function of time given by the following table Year CO 2 (in ppm) The graph of this function ppm:parts per million

3.5 Some Important Functions Ceiling. f(x) =  x  the least integer y so that x  y. Ex:  1.2  = 2;  -1.2  = -1;  1  = 1 Floor. f(x) =  x  the greatest integer y so that y  x. Ex:  1.8  = 1;  -1.8  = -2;  -5  = -5 Quiz: what is   1.1  ? 0

The graph of the floor function The graph of the ceiling function