1 / 92

Prof EL-HENAWY Discrete Structures

Prof EL-HENAWY Discrete Structures. Sets and Subsets Section 1.1. Definitions of sets. A set is any well-defined collection of objects The elements or members of a set are the objects contained in the set

nyoko
Download Presentation

Prof EL-HENAWY Discrete Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prof EL-HENAWYDiscrete Structures Sets and SubsetsSection 1.1

  2. Definitions of sets • A set is any well-defined collection of objects • The elements or members of a set are the objects contained in the set • Well-defined means that it is possible to decide if a given object belongs to the collection or not.

  3. Set notation • Enumeration of sets are represented with a list of elements in curly brackets – example: {1, 2, 3} • Set labels are uppercase letters in italics – example: A, B, C • Element labels are lowercase letters – example: a, b, c •  is the label for the empty set, i.e.,  = { }

  4. Membership •  -- “is an element of” (Note that it is shaped like an “E” as in element) •  -- “is not an element of” • Example: If A = {1, 3, 5, 7}, then 1  A, but 2  A.

  5. Specifying sets with their properties: A set can be represented or defined by the rules classifying whether an object belongs to a collection or not.A = {a | a is __________}The above notation translates to “the set A is comprised of elements a where a satisfies _________.”

  6. Examples of Common Sets • Z+ = {x | x is a positive integer} • N = {x | x is a positive integer or zero} • Z = {x | x is an integer} • Q = {x | x is a rational number}Q consists of the numbers that can be written a/b, where a and b are integers and b ≠ 0. • R = {x | x is a real number}

  7. Examples of sets used in programming • unsigned int • int • float • enum

  8. Subsets • If every element of A is also an element of B, that is, if whenever x  A, then x  B, we say that A is a subset of B or that A is contained in B. • A is a subset of B if for every x, x  A means that x  B.

  9. Subset Notation •  -- “is contained in” (Note that it is shaped like a “C” as in contained in) -- “is not contained in” • “Is not contained in” does not mean that there aren’t some elements that can be in both sets. It just means that not all of the elements of A are in B

  10. Subset Examples • vowels  alphabet • letters that spell “see”  letters that spell “yes” • letters that spell “yes”  letters that spell “easy” • letters that spell “say”  letters that spell “easy” • positive integers  integers • odd integers  integers • integers  floating point values (real numbers)

  11. Venn Diagrams • Named after British logician John Venn • Graphical depiction of the relationship of sets. • Does not represent the individual elements of the sets, rather it implies their existence

  12. B A A B B A Venn Diagram Examples • A  B • A  B or

  13. A B More Venn Diagram Examples a  A, b  B, and c  A and c  B c a b

  14. Theorems on Sets • A  B and B  C implies A  C • Example: • A = {x | letters that spell “see”} = {e, s} • B = {x | letters that spell “yes”} = {e, s, y} • C = {x | letters that spell “easy”} = {a, e, s, y}

  15. B A A C B A C C B Theorems on Sets (continued) • If A  B and B  C, then A  C. • If A  B and C  B, that doesn’t mean we can say anything at all about the relationship between A and C. It could be any of the following three cases:

  16. Theorems on Sets (continued) • If A is any set, then A  A. That is, every set is a subset of itself. • Since  contains no elements, then every element of  is contained in every set. Therefore, if A is any set, the statement  A is always true. • If A  B and B  A, then A = B

  17. Universal Set • There must be some all-encompassing group of elements from which the elements of each set are considered to be members of or not. • For example, to create the set of integers, we must take elements from the universal set of all numbers.

  18. Universal Set (continued) • It’s desirable for the all-encompassing set to make sense. • Example: Although it is true that students enrolled in this class can be taken from the universal set of all mammals that roam the earth, it makes more sense for the universal set to be people enrolled at ETSU or at least limit the universal set to humans.

  19. Universal Set (continued) • The Universal Set U is the set containing all objects for which the discussion is meaningful. (e.g., examining whether a sock is an integer is a meaningless exercise.) • Any set is a subset of the universal set from which it derives its meaning • In Venn diagrams, the universal set is denoted with a rectangle. U A

  20. Final set of terms • Finite – A set A is called finite if it has n distinct elements, where n  N. • n is called the cardinality of A and is denoted by |A|, e.g., n = |A| • Infinite – A set that is not finite is called infinite. • The power set of A is the set of all subsets of A including  and is denoted P(A)

  21. Discrete Structures Operations on Sets Section 1.2

  22. Operation on Sets • An operation on a set is where two sets are combined to produce a third

  23. Union • AB = {x | x A or x B} • Example:Let A = {a, b, c, e, f} and B = {b, d, r, s}AB = {a, b, c, d, e, f, r, s} • Venn diagram

  24. Intersection • AB = {x | x A and x B} • Example: Let A = {a, b, c, e, f},B = {b, e, f, r, s}, and C = {a, t, u, v}.AB = {b, e, f}AC = {a}BC = { } • Venn diagram

  25. Disjoint Sets Disjoint sets are sets where the intersection results in the empty set Not disjoint Disjoint

  26. Unions and Intersections Across Multiple Sets Both intersection and union can be performed on multiple sets • ABC = {x | x A or x B or x C} • ABC = {x | x A and x B and x C} • Example:A = {1, 2, 3, 4, 5, 7}, B = {1, 3, 8, 9}, and C = {1, 3, 6, 8}.ABC = {1, 2, 3, 4, 5, 6, 7, 8, 9}ABC = {1, 3}

  27. Complement • The complement of A (with respect to the universal set U) – all elements of the universal set U that are not a member of A. • Denoted A • Example: If A = {x | x is an integer and x < 4} and U = Z, then A = {x | x is an integer and x > 4} • Venn diagram

  28. Complement “With Respect to…” • The complement of B with respect to A – all elements belonging to A, but not to B. • It’s as if U is in the complement is replaced with A. • Denoted A – B = {x | x A and x B} • Example: Assume A = {a, b, c} and B = {b, c, d, e}A – B = {a}B – A = {d, e} • Venn diagram A – B B – A

  29. Symmetric difference • Symmetric difference – If A and B are two sets, the symmetric difference is the set of elements belonging to A or B, but not both A and B. • Denoted AB = {x | (x A and x B) or (x B and x A)} • AB = (A – B)  (B – A) • Venn diagram

  30. Algebraic Properties of Set Operations • Commutative propertiesA  B = B  AA  B = B  A • Associative propertiesA  (B  C) = (A  B)  CA  (B  C) = (A  B)  C • Distributive propertiesA  (B  C) = (A  B)  (A  C)A  (B  C) = (A  B)  (A  C)

  31. More Algebraic Properties of Set Operations • Idempotent propertiesA  A = AA  A = A • Properties of the complement(A) = AA  A = UA  A =  = UU = A  B = A  B -- De Morgan’s lawA  B = A  B -- De Morgan’s law

  32. More Algebraic Properties of Set Operations • Properties of a Universal SetA  U = UA  U = A • Properties of the Empty SetA  = A or A  { } = AA  =  or A  { } = { }

  33. The Addition Principle • The Addition Principle associates the cardinality of sets with the cardinality of their union • If A and B are finite sets, then |A  B| = |A| + |B| – |A  B| • Let’s use a Venn diagram to prove this: • The Roman Numerals indicate how many times each segment is included for the expression |A| + |B| • Therefore, we need to remove one |A  B| since it is counted twice. A  B 1 2 1

  34. Addition Principle Example • Let A = {a, b, c, d, e} and B = {c, e, f, h, k, m} • |A| = 5, |B| = 6, and |A  B| = |{c, e}| = 2 • |A  B| = |{a, b, c, d, e, f, h, k, m}| |A  B| = 9 = 5 + 6 – 2 • If A  B = , i.e., A and B are disjoint sets, then the |A  B| term drops out leaving |A| + |B|

  35. Discrete Structures Sequences Section 1.3

  36. Sequence • A sequence is a list of objects arranged in a definite order • Difference between set and sequence • A set has no order and no duplicated elements • A sequence has a specific order and elements may be duplicated • Nomenclature: a1, a2, …an

  37. Sequence Examples • 1, 2, 3, 2, 2, 3, 1 is a sequence, but not a set • The sequences 1, 2, 3, 2, 2, 3, 1 and 2, 2, 1, 3 are made from elements of the set {1, 2, 3} • The sequences 1, 2, 3, 2, 2, 3, 1 and 2, 1, 3, 2, 2, 3, 1 only switch two elements, but that alone makes them unequal

  38. Types of Sequences • Sequence may stop after n steps (finite) or go on for ever (infinite) • Formulas can be used to describe sequences • Recursive • Explicit

  39. Recursive Sequences • In a recursive sequence, the next item in the sequence is determined from previous values • Difficult to determine say 100th element since previous 99 need to be determined first. • Example: a1 = 1a2 = 2an = an-1 + an-2

  40. Explicit Sequences • In an explicit sequence, the nth item is determined by a formula depending only on n • Easier to determine any element • Example: an = 2n

  41. Strings • Sequences can be made up of characters too • Example: W, a, k, e, , u, p • Removing the commas and you get a string: “Wake up” • Strings best illustrate difference between sequences and sets • a, b, a, b, a, b, a, … is a sequence, i.e., “abababa…” is a string • The corresponding set is {a, b}

  42. Linear Array • Principles of sequences can be applied to computers, specifically, arrays. There are some differences though. • Sequence • Well-defined • Modification of any element or its order creates new sequence • Array • May not have all elements initialized • Modification of array by software may occur • Even if the array has variable length, we’re ultimately limited to finite length

  43. Characteristic Functions • A characteristic function is a function defining membership in a set • fA(x) = • Example, for the set A = {1, 4, 6}fA(1) = 1, fA(2) = 0, fA(3) = 0, fA(4) = 1, etc. 1 if xA 0 if xA

  44. Programming Example Characteristic functions may look unfamiliar, but consider the following code:if (insert conditional statement here) return (1);else return (0); Example: A = {x | x > 4} if (x > 4) return (1); else return (0);

  45. Properties of Characteristic Functions Characteristic functions of subsets satisfy the following properties (proofs are on page 15 of textbook.) • fAB = fAfB; that is fAB(x) = fA(x)fB(x) for all x. • fAB = fA + fB – fAfB; that is fAB(x) = fA(x) + fB(x) – fA(x)fB(x) for all x. • fAB = fA + fB – 2fAfB;that is fAB(x) = fA(x) + fB(x) – 2fA(x)fB(x) for all x.

  46. Proving Characteristic Function Properties • Alternate way of doing proof is to enumerate all four cases and see how the result comes out • Example: Prove fAB = fAfB fA(a) = 0, fB(a) = 0, fA(a) fB(a) = 0  0 = 0 = fAB(a)fA(b) = 0, fB(b) = 1, fA(b) fB(b) = 0  1 = 0 = fAB(b)fA(c) = 1, fB(c) = 0, fA(c) fB(c) = 1  0 = 0 = fAB(c)fA(d) = 1, fB(d) = 1, fA(d) fB(d) = 1  1 = 1 = fAB(d) a A B d b c

  47. Representing Sets with a Computer • Remember that sets have no order and no duplicated elements. • The general need to assign each element in a set to a memory location gives it order in a computer. • We can use the characteristic function to define a set using a computer.

  48. Representing Sets with a Computer (continued) • Assume U defines a finite universal set U = {x1, x2, x3, …, xn} • We can use characteristic function to represent subsets of U • fA(x) is a sequence of 1’s and 0’s with the same number of elements as U • fA(x) = 1 is in position if corresponding element of U, x, is a member of A • fA(x) = 0 is in position if corresponding element of U, x, is not a member of A

  49. Representing Sets with a Computer Example • U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} • fA(x) = 1, 0, 1, 0, 0, 1, 1, 0, 0, 1 • A = {0, 2, 5, 6, 9}

  50. More Properties of Sequences • Any set with n elements can be arranged as a sequence of length n, but not vice versa. This is because sets have no order and duplicates are not allowed. • Each subset can be identified with its characteristic function as a sequence of 1’s and 0’s. • Characteristic function for universal set, U, is a sequence of all ones.

More Related