Prof. Johnnie Baker Module Basic Structures: Sets

Slides:



Advertisements
Similar presentations
Discrete Mathematics I Lectures Chapter 6
Advertisements

Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
CS 173: Discrete Mathematical Structures Cinda Heeren Rm 2213 Siebel Center Office Hours: M 12:30-2:30p.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Instructor: Hayk Melikya
(CSC 102) Discrete Structures Lecture 14.
2.1 Sets ‒Sets ‒Common Universal Sets ‒Subsets 2.2 Set Operations 2.3 Functions 2.4 Sequences and Summations 1.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Section 1.6: Sets Sets are the most basic of discrete structures and also the most general. Several of the discrete structures we will study are built.
Denoting the beginning
1 Section 1.7 Set Operations. 2 Union The union of 2 sets A and B is the set containing elements found either in A, or in B, or in both The denotation.
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Copyright © Zeph Grunschlag, Set Operations Zeph Grunschlag.
Sets 1.
Sets 1.
1 Set Theory. Notation S={a, b, c} refers to the set whose elements are a, b and c. a  S means “a is an element of set S”. d  S means “d is not an element.
SETS A set B is a collection of objects such that for every object X in the universe the statement: “X is a member of B” Is a proposition.
Rosen 1.6. Approaches to Proofs Membership tables (similar to truth tables) Convert to a problem in propositional logic, prove, then convert back Use.
Sets.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
2.1 – Sets. Examples: Set-Builder Notation Using Set-Builder Notation to Make Domains Explicit Examples.
ICS 253: Discrete Structures I
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Sets Defined A set is an object defined as a collection of other distinct objects, known as elements of the set The elements of a set can be anything:
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
Lecture 2.2: Set Theory* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren.
CS201: Data Structures and Discrete Mathematics I
1. Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element of A” A = {a 1, a 2,
CompSci 102 Discrete Math for Computer Science
Section 2.1. Section Summary Definition of sets Describing Sets Roster Method Set-Builder Notation Some Important Sets in Mathematics Empty Set and Universal.
Week 6 - Friday.  What did we talk about last time?  Solving recurrence relations.
Discrete Mathematical Structures 4 th Edition Kolman, Busby, Ross © 2000 by Prentice-Hall, Inc. ISBN
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
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.
Introduction to Set theory. Ways of Describing Sets.
Discrete Mathematics SETS. What is a set? ^A set is a unordered collection of “objects”  People in a class: {A yşe, B arış, C anan }  Cities in Turkey.
Discrete Mathematics. Set Theory - Definitions and notation A set is an unordered collection of elements. Some examples: {1, 2, 3} is the set containing.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Lecture 2.2: Set Theory CS 250, Discrete Structures, Fall 2015 Nitesh Saxena Adopted from previous lectures by Cinda Heeren.
Discrete Mathematics CS 2610 January 27, part 2.
Discrete Mathematics Set.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
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.
Section 2.1. Sets A set is an unordered collection of objects. the students in this class the chairs in this room The objects in a set are called the.
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.
Week 8 - Wednesday.  What did we talk about last time?  Relations  Properties of relations  Reflexive  Symmetric  Transitive.
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)
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Discrete Mathematical The Set Theory
Set, Combinatorics, Probability & Number Theory
Sets Section 2.1.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
… and now for something completely different…
Exercises Show that (P  Q)  (P)  (Q)
CS100: Discrete structures
Set Operations Section 2.2.
Discrete Mathematics CS 2610
Lecture 2.1: Sets and Set Operations*
L5 Set Operations.
… and now for something completely different…
Lecture Sets 2.2 Set Operations.
Sets & Set Operations.
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Presentation transcript:

Prof. Johnnie Baker jbaker@cs.kent.edu Module Basic Structures: Sets Discrete Math CS 23022 Prof. Johnnie Baker jbaker@cs.kent.edu Module Basic Structures: Sets

Acknowledgement Most of these slides were either created by Professor Bart Selman at Cornell University or else are modifications of his slides

Set Theory - Definitions and notation A set is an unordered collection of objects referred to as elements. A set is said to contain its elements. Different ways of describing a set. 1 – Explicitly: listing the elements of a set {1, 2, 3} is the set containing “1” and “2” and “3.” list the members between braces. {1, 1, 2, 3, 3} = {1, 2, 3} since repetition is irrelevant. {1, 2, 3} = {3, 2, 1} since sets are unordered. {1,2,3, …, 99} is the set of positive integers less than 100; use ellipses when the general pattern of the elements is obvious. {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 elements. Note:   {}

Set Theory - Definitions and notation 2 – Implicitly: by using a set builder notations, stating the property or properties of the elements of the set. S = {m| 2 ≤ m ≤ 100, m is integer} S is the set of all m such that m is between 2 and 100 and m is integer.

Set Theory - Ways to define sets : and | are read “such that” or “where” Explicitly: {John, Paul, George, Ringo} Implicitly: {1,2,3,…}, or {2,3,5,7,11,13,17,…} Set builder: { x : x is prime }, { x | x is odd }. In general { x : P(x) is true }, where P(x) is some description of the set. Let D(x,y) denote “x is divisible by y.” Give another name for { x : y ((y > 1)  (y < x))  D(x,y) }. Primes Can we use any predicate P to define a set S = { x : P(x) }?

Set Theory - Russell’s Paradox Reveals contradiction in Frege’s naïve set theory. Set Theory - Russell’s Paradox "the set of all sets that do not contain themselves as members“  No! Can we use any predicate P to define a set S = { x : P(x) }? Define S = { x : x is a set where x  x } So S must not be in S, right? Then, if S  S, then by defn of S, S  S. ARRRGH! But, if S  S, then by defn of S, S  S. There is a town with a barber who shaves all the people (and only the people) who don’t shave themselves. Who shaves the barber?

Set Theory - Russell’s Paradox Aside: this layman’s version of Russell’s paradox has some drawbacks. Set Theory - Russell’s Paradox There is a town with a barber who shaves all the people (and only the people) who don’t shave themselves. Who shaves the barber? Does the barber shave himself? If the barber does not shave himself, he must abide by the rule and shave himself. If he does shave himself, according to the rule he will not shave himself. This sentence is unsatisfiable (a contradiction) because of the universal quantifier. The universal quantifier y will include every single element in the domain, including our infamous barber x. So when the value x is assigned to y, the sentence can be rewritten to: Contradiction!

Set Theory - Definitions and notation Important Sets N = {0,1,2,3,…}, the set of natural numbers, non negative integers, (occasionally IN) Z = { …, -2, -1, 0, 1, 2,3, …), the set of integers Z+ = {1,2,3,…} set of positive integers Q = {p/q | p  Z, q Z, and q0}, set of rational numbers R, the set of real numbers Note: Real number are the numbers that can be represented by an infinite decimal representation, such as 3.4871773339…. The real numbers include both rational, and irrational numbers such as π and the and can be represented as points along an infinitely long number line. Check wikipedia

Set Theory - 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.” or, “B contains A.” or, “every element of A is also in B.” or, x ((x  A)  (x  B)). Venn Diagram A B

Set Theory - 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  B B  A

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

Set Theory - Definitions and notation Quick examples: {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 (for all over empty domain) Is   {1,2,3}? No! Is   {,1,2,3}? Yes! Is   {,1,2,3}? Yes!

Set Theory - Definitions and notation A few more: Is {a}  {a}? Yes Is {a}  {a,{a}}? Yes Is {a}  {a,{a}}? Yes Is {a}  {a}? No

Set Theory - Cardinality If S is finite, then the cardinality of S, |S|, is the number of distinct elements in S. |S| = 3. If S = {1,2,3}, |S| = 1. If S = {3,3,3,3,3}, |S| = 0. If S = , |S| = 3. If S = { , {}, {,{}} }, If S = {0,1,2,3,…}, |S| is infinite.

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

Set Theory – Ordered Tuples Cartesian Product When order matters, we use ordered n-tuples The Cartesian Product of two sets A and B is: A x B = { <a,b> : a  A  b  B} If A = {Charlie, Lucy, Linus}, and B = {Brown, VanPelt}, then We’ll use these special sets soon! A x B = {<Charlie, Brown>, <Lucy, Brown>, <Linus, Brown>, <Charlie, VanPelt>, <Lucy, VanPelt>, <Linus, VanPelt>} AxB |A|+|B| |A+B| |A||B| A1 x A2 x … x An = {<a1, a2,…, an>: a1  A1, a2  A2, …, an  An} Size? A,B finite  |AxB| = ? nn if (i) Ai  = n

Set Theory - Operators The union of two sets A and B is: A  B = { x : x  A v x  B} If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi}, then A  B = {Charlie, Lucy, Linus, Desi} A B

Set Theory - Operators 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

Set Theory - Operators 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 deceased}, then A  B = {x : x is a deceased US president} B A

Sets whose intersection is empty are called disjoint sets Set Theory - Operators 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 A B

Set Theory - Operators = U and U =  The complement of a set A is: A = { x : x  A} If A = {x : x is bored}, then A = {x : x is not bored} A U = U and U =  I.e., A = U – A, where U is the universal set. “A set fixed within the framework of a theory and consisting of all objects considered in the theory. “

Set Theory - Operators The set difference, A - B, is: U A B A - B = { x : x  A  x  B } A - B = A  B

A  B = { x : (x  A  x  B) v (x  B  x  A)} Set Theory - Operators The symmetric difference, A  B, is: A  B = { x : (x  A  x  B) v (x  B  x  A)} = (A - B) U (B - A) like “exclusive or” A U B

Set Theory - Operators A  B = (A - B) U (B - A) Theorem: Proof: A  B = { x : (x  A  x  B) v (x  B  x  A)} = { x : (x  A - B) v (x  B - A)} = { x : x  ((A - B) U (B - A))} = (A - B) U (B - A) Q.E.D.

Set Theory - Identities Directly from defns. Semantically clear. Identity Domination Idempotent A  U = A A U  = A A  U = U A   = A A  A = A A  A = A

Set Theory – Identities, cont. Complement Laws Double complement A  A = U A  A =  A = A

Set Theory - Identities, cont. Commutativity Associativity Distributivity A U B = B U A B  A A  B = (A U B) U C = A U (B U C) A  (B  C) (A  B)  C = A U (B  C) = A  (B U C) = (A U B)  (A U C) (A  B) U (A  C)

Proof by “diagram” (useful!), but we aim for a more formal proof. DeMorgan’s I DeMorgan’s II (A U B) = A  B (A  B) = A U B Proof by “diagram” (useful!), but we aim for a more formal proof. A B

Proving identities (A U B) = A  B (De Morgan) Prove that () (x  A U B)  (x  (A U B))  (x  A and x  B)  (x  A  B) () (x ( A  B))  (x  A U B)  (x  A U B)

Haven’t we seen this before? Alt. proof (A U B) = A  B Prove that using a membership table. 0 : x is not in the specified set 1 : otherwise A B A  B A U B 1 Haven’t we seen this before? General connection via Boolean algebras (Rosen chapt. 11)

(A U B) = {x : (x  A v x  B)} Proof using logically equivalent set definitions. (A U B) = A  B (A U B) = {x : (x  A v x  B)} = {x : (x  A)  (x  B)} = {x : (x  A)  (x  B)} = A  B

Example What kind of law? Distributive law X  (Y - Z) = (X  Y) - (X  Z). True or False? Prove your response. What kind of law? (X  Y) - (X  Z) = (X  Y)  (X  Z)’ Distributive law = (X  Y)  (X’ U Z’) = (X  Y  X’) U (X  Y  Z’) =  U (X  Y  Z’) = (X  Y  Z’) = X  (Y - Z) (X  Z) = (X  Z)’ (just different notation) Note:

Example Pv that if (A - B) U (B - A) = (A U B) then ______ Suppose to the contrary, that A  B  , and that x  A  B. A = B A  B =  A-B = B-A =  Then x cannot be in A-B and x cannot be in B-A. Then x is not in (A - B) U (B - A). Do you see the contradiction yet? But x is in A U B since (A  B)  (A U B). Thus, (A - B) U (B - A) ≠ (A U B). Contradiction. Trying to prove p --> q Assume p and not q, and find a contradiction. Our contradiction was that sets weren’t equal. Thus, A  B = .

Set Theory - Generalized Union/Intersection

Set Theory - Generalized Union/Intersection Ex. Suppose that:

Example: Ex. Let U = N, and define: i=1,2,…,N A1 = {2,3,4,…} primes Note: i starts at 2 primes Primes Composites  N I have no clue. A2 = {4,6,8,…} A3 = {6,9,12,…} Union is all the composite numbers.

Set Theory - Inclusion/Exclusion 157 145 Example: There are 217 cs majors. 157 are taking CS23021. 145 are taking cs23022. 98 are taking both. How many are taking neither? 217 - (157 + 145 - 98) = 13

Generalized Inclusion/Exclusion B A Suppose we have: C What about 4 sets? And I want to know |A U B U C| |A U B U C| = |A| + |B| + |C| - |A  B| - |A  C| - |B  C| + |A  B  C|

Generalized Inclusion/Exclusion For sets A1, A2,…An we have:

Set Theory - Sets as bit strings Let U = {x1, x2,…, xn}, and let A  U. Then the characteristic vector of A is the n-vector whose elements, xi, are 1 if xi  A, and 0 otherwise. Ex. If U = {x1, x2, x3, x4, x5, x6}, and A = {x1, x3, x5, x6}, then the characteristic vector of A is (101011)

Sets as bit strings Ex. If U = {x1, x2, x3, x4, x5, x6}, A = {x1, x3, x5, x6}, and B = {x2, x3, x6}, Then we have a quick way of finding the characteristic vectors of A  B and A  B. A 1 B A  B A  B Bit-wise OR Bit-wise AND