sets and set operations
play

Sets and Set Operations Dr. Philip C. Ritchey Set Notation Set: an - PowerPoint PPT Presentation

CSCE 222 Discrete Structures for Computing Sets and Set Operations Dr. Philip C. Ritchey Set Notation Set: an unordered collection of objects (members, elements) is a member of , is


  1. CSCE 222 Discrete Structures for Computing Sets and Set Operations Dr. Philip C. Ritchey

  2. Set Notation • Set: an unordered collection of objects (“members”, “elements”) • 𝑏 ∈ 𝑇 • “ 𝑏 is a member of 𝑇 ”, “ 𝑏 is an element of 𝑇 ” • 𝑏 ∉ 𝑇 • “ 𝑏 is not a member of 𝑇 ”, “ 𝑏 is not an element of 𝑇 ” • Roster method • S = 1,2,3,4 • Set Builder • 𝑇 = 𝑦 ∣ 𝑦 𝑗𝑡 𝑏 𝑞𝑝𝑡𝑗𝑢𝑗𝑤𝑓 𝑗𝑜𝑢𝑓𝑕𝑓𝑠 𝑚𝑓𝑡𝑡 𝑢ℎ𝑓𝑜 5 • 𝑇 = 𝑦 ∣ 𝑦 ∈ ℤ + ∧ 𝑦 < 5

  3. Exercise • Jumping Jacks! • Kidding… • List the members of the set: 𝑦 ∣ 𝑦 𝑗𝑡 𝑢ℎ𝑓 𝑡𝑟𝑣𝑏𝑠𝑓 𝑝𝑔 𝑏𝑜 𝑗𝑜𝑢𝑓𝑕𝑓𝑠 𝑏𝑜𝑒 𝑦 < 100 • 0,1,4,9,16,25,36,49,64,81 • 𝑦 ∣ 𝑦 2 = 2 • − 2, 2 • • Use set builder notation to describe the set: 0,3,6,9,12 • 3𝑦 ∣ 𝑦 𝑗𝑡 𝑏𝑜 𝑗𝑜𝑢𝑓𝑕𝑓𝑠 𝑏𝑜𝑒 0 ≤ 𝑦 ≤ 4 • −3, −2, −1,0,1,2,3 • 𝑦 ∣ 𝑦 𝑗𝑡 𝑏𝑜 𝑗𝑜𝑢𝑓𝑕𝑓𝑠 𝑏𝑜𝑒 𝑦 ≤ 3 •

  4. Common Sets • ℤ = … , −2, −1,0,1,2, … , the set of integers • ℤ + , the positive integers • ℤ − , the negative integers • ℕ = [0, ]1,2,3, … , the set of natural numbers 𝑞 • ℚ = 𝑟 ∣ 𝑞, 𝑟 ∈ ℤ, 𝑟 ≠ 0 , the set of rational numbers • ℝ , the set of real numbers • ℝ + , the set of positive reals • ℝ − , the set of negative reals • ℂ , the set of complex numbers • 𝑽 : the universal set ( set of discourse ) • ∅ : the empty set, ∅ is a non-empty singleton set •

  5. Interval Notation • Shortcuts for sets containing numbers • [ , ] mean inclusive . Closed interval. • ( , ) mean exclusive . Open interval. 𝑏, 𝑐 = 𝑦 ∣ 𝑏 ≤ 𝑦 ≤ 𝑐 𝑏, 𝑐 = 𝑦 ∣ 𝑏 < 𝑦 < 𝑐 𝑏, 𝑐 = 𝑦 ∣ 𝑏 ≤ 𝑦 < 𝑐 𝑏, 𝑐 = 𝑦 ∣ 𝑏 < 𝑦 ≤ 𝑐

  6. Exercise • Push Ups! • Kidding… • Use interval notation to describe the number line: −7, −1 ∪ 3,7 • • Express 𝑦 ≠ 9 using: • Set builder 𝑦 ∈ ℝ ∣ 𝑦 ≠ 9 • • Interval Notation −∞, 9 ∪ 9, ∞ •

  7. Set Equality and Subsets • Proper Subset, 𝐵 ⊂ 𝐶 • Set Equality, 𝐵 = 𝐶 • 𝐵 ⊂ 𝐶 ≔ 𝐵 ⊆ 𝐶 ∧ 𝐵 ≠ 𝐶 • 𝐵 = 𝐶 ≔ ∀𝑦 𝑦 ∈ 𝐵 ↔ 𝑦 ∈ 𝐶 1,9 ⊂ 1,3,5,7,9 • 1,3,5 = 3,1,5 • 1,9 ⊄ 1,9 • 1,3,5 = 1,3,3,3,5,5,5,5,5 ? • • ∅ ⊆ 𝐵 , for any set 𝐵 • Subset, 𝐵 ⊆ 𝐶 • 𝐵 ⊆ 𝐵 , for any set 𝐵 • 𝐵 ⊆ 𝐶 ≔ ∀𝑦 𝑦 ∈ 𝐵 → 𝑦 ∈ 𝐶 1,9 ⊆ 1,3,5,7,9 • 1,9 ⊆ 1,9 • • How can we express equality in terms of subsets? • 𝐵 = 𝐶 ↔ 𝐵 ⊆ 𝐶 ∧ 𝐶 ⊆ 𝐵

  8. Set Size and Power Sets • Set size • The number of distinct elements in the set • 𝑇 = 𝑜, 𝑜 ≥ 0, 𝑜 is finite • “cardinality” • Power set • The set of all subsets of a set • ℘ 𝑇 • Ex: 𝑇 = 1,2,3 • ℘ 𝑇 = ∅, 1 , 2 , 3 , 1,2 , 1,3 , 2,3 , 1,2,3 = 2 𝑇 • ℘ 𝑇

  9. Cartesian Products • 𝐵 × 𝐶 = 𝑏, 𝑐 ∣ 𝑏 ∈ 𝐵 ∧ 𝑐 ∈ 𝐶 • 𝐵 1 × 𝐵 2 × ⋯ × 𝐵 𝑜 = 𝑏 1 , 𝑏 2 , … , 𝑏 𝑜 ∣ 𝑏 𝑗 ∈ 𝐵 𝑗 𝑏 1 , 𝑏 2 , … , 𝑏 𝑜 is an 𝑜 -tuple • • 𝐵 2 = 𝐵 × 𝐵 • 𝐵 𝑜 = 𝑏 1 , 𝑏 2 , … , 𝑏 𝑜 ∣ 𝑏 𝑗 ∈ 𝐵 • 𝐵 × 𝐶 ≠ 𝐶 × 𝐵 • Exceptions: 𝐵 = ∅, 𝐶 = ∅, 𝐵 = 𝐶 • A subset of a Cartesian product is called a Relation from 𝐵 to 𝐶 • We will cover Relations soon.

  10. Exercise • Let 𝐵 be the set of all airlines and 𝐶 be the set of all US cities. • What is the Cartesian product 𝐵 × 𝐶 2 ? 𝑏, 𝑐, 𝑑 ∣ 𝑏 𝑗𝑡 𝑏𝑜 𝑏𝑗𝑠𝑚𝑗𝑜𝑓, 𝑐 𝑗𝑡 𝑏 𝑉𝑇 𝑑𝑗𝑢𝑧 𝑏𝑜𝑒 𝑑 𝑗𝑡 𝑏 𝑉𝑇 𝑑𝑗𝑢𝑧 • • How can this Cartesian product be used? • Each element is a route that an airline flies, from one city to another • Could be used for route planning • Does 𝐵 × 𝐶 × 𝐷 × 𝐸 = 𝐵 × 𝐶 × 𝐷 × 𝐸 ? 𝑏, 𝑐 , 𝑑, 𝑒 ≠ 𝑏, 𝑐, 𝑑 , 𝑒 • No.

  11. Set Operations • Set Union, 𝐵 ∪ 𝐶 • 𝐵 ∪ 𝐶 = 𝑦 ∣ 𝑦 ∈ 𝐵 ∨ 𝑦 ∈ 𝐶 • 1,2,3 ∪ 3,4 = 1,2,3,4 • Set Intersection, 𝐵 ∩ 𝐶 • 𝐵 ∩ 𝐶 = 𝑦 ∣ 𝑦 ∈ 𝐵 ∧ 𝑦 ∈ 𝐶 • 1,2,3 ∩ 3,4 = 3 • If 𝐵 ∩ 𝐶 = ∅ , then 𝐵 and 𝐶 are disjoint . • Principle of inclusion-exclusion • 𝐵 ∪ 𝐶 = 𝐵 + 𝐶 − 𝐵 ∩ 𝐶

  12. Set Operations • Set Difference, 𝐵 − 𝐶 • 𝐵 − 𝐶 = 𝑦 ∣ 𝑦 ∈ 𝐵 ∧ 𝑦 ∉ 𝐶 • 8,6,7,5,3,0,9 − 0,2,4,6,8 = ? • Complement, 𝐵 • 𝐵 = 𝑦 ∣ 𝑦 ∉ 𝐵 • 𝐵 = 𝑉 − 𝐵 • How can we express set difference using the other set operations? • 𝐵 − 𝐶 = 𝐵 ∩ 𝐶

  13. Venn Diagrams • Draw a rectangle to represent 𝑉 . 𝑉 a • Draw geometric shapes u e 𝑊 inside to represent sets. • Use points to represent o i particular elements.

  14. Venn Diagrams 𝑉 = 𝐵 𝐵

  15. Venn Diagrams 𝑉 = 𝐵 ∪ 𝐶 𝐶 𝐵

  16. Venn Diagrams 𝑉 = 𝐵 ∩ 𝐶 𝐶 𝐵

  17. Venn Diagrams 𝑉 = 𝐵 − 𝐶 𝐶 𝐵

  18. Set Identities • Same as for propositional logic! • Identity, domination, idempotent, double negation, commutativity, associativity, distributivity, DeMorgan, absorption, negation • Operators map from logic to sets • 𝑞 ∨ 𝑟 ⇒ 𝑄 ∪ 𝑅 • 𝑞 ∧ 𝑟 ⇒ 𝑄 ∩ 𝑅 • ¬𝑞 ⇒ 𝑄 • 𝑞 → 𝑟 ⇒ 𝑄 ⊆ 𝑅 • 𝑞 ↔ 𝑟 ⇒ 𝑄 = 𝑅

  19. Set Identities (DeMorgan) • Ex: 𝐵 ∩ 𝐶 = 𝐵 ∪ 𝐶 ⊆ 𝐵 ∩ 𝐶 • Show 𝐵 ∩ 𝐶 ⊆ 𝐵 ∪ 𝐶 • Show 𝐵 ∪ 𝐶 → 𝑦 ∈ 𝐵 ∩ 𝐶 • Show 𝑦 ∈ 𝐵 ∪ 𝐶 • Show 𝑦 ∈ 𝐵 ∩ 𝐶 → 𝑦 ∈ 𝐵 ∪ 𝐶 • Assume 𝑦 ∈ 𝐵 ∩ 𝐶 • Assume 𝑦 ∈ 𝐵 ∪ 𝐶 • Then, 𝑦 ∉ 𝐵 ∩ 𝐶 • Then, 𝑦 ∈ 𝐵 ∨ 𝑦 ∈ 𝐶 • ¬ 𝑦 ∈ 𝐵 ∩ 𝐶 𝑦 ∉ 𝐵 ∨ 𝑦 ∉ 𝐶 • • ¬ 𝑦 ∈ 𝐵 ∧ 𝑦 ∈ 𝐶 • ¬ 𝑦 ∈ 𝐵 ∨ ¬ 𝑦 ∈ 𝐶 • ¬ 𝑦 ∈ 𝐵 ∧ 𝑦 ∈ 𝐶 • ¬ 𝑦 ∈ 𝐵 ∨ ¬ 𝑦 ∈ 𝐶 𝑦 ∉ 𝐵 ∨ 𝑦 ∉ 𝐶 • ¬ 𝑦 ∈ 𝐵 ∩ 𝐶 • • 𝑦 ∈ 𝐵 ∨ 𝑦 ∈ 𝐶 • 𝑦 ∉ 𝐵 ∩ 𝐶 • 𝑦 ∈ 𝐵 ∪ 𝐶 • 𝑦 ∈ 𝐵 ∩ 𝐶 • □ • □

  20. Truth tables ⇒ Membership tables Verify that 𝐵 ∩ 𝐶 = 𝐵 ∪ 𝐶 ∪ 𝑪 𝑩 𝑪 𝑩 ∩ 𝑪 𝑩 ∩ 𝑪 𝑩 𝑪 𝑩 0 0 0 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 1 1 1 1 0 0 0 0

  21. XOR • 𝐵 ⊕ 𝐶 : elements in 𝐵 , or in 𝐶 , but not in both. • Symmetric difference • Draw the Venn diagram • Claim: 𝐵 ⊕ 𝐶 = 𝐵 ∪ 𝐶 − 𝐵 ∩ 𝐶 • Proof?

Recommend


More recommend