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

sets and set operations
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Sets and Set Operations

  • Dr. Philip C. Ritchey

CSCE 222 Discrete Structures for Computing

slide-2
SLIDE 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
slide-3
SLIDE 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
slide-4
SLIDE 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
slide-5
SLIDE 5

Interval Notation

  • Shortcuts for sets containing numbers
  • [ , ] mean inclusive. Closed interval.
  • ( , ) mean exclusive. Open interval.

𝑏, 𝑐 = 𝑦 ∣ 𝑏 ≤ 𝑦 ≤ 𝑐 𝑏, 𝑐 = 𝑦 ∣ 𝑏 < 𝑦 < 𝑐 𝑏, 𝑐 = 𝑦 ∣ 𝑏 ≤ 𝑦 < 𝑐 𝑏, 𝑐 = 𝑦 ∣ 𝑏 < 𝑦 ≤ 𝑐

slide-6
SLIDE 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, ∞
slide-7
SLIDE 7

Set Equality and Subsets

  • Set Equality, 𝐵 = 𝐶
  • 𝐵 = 𝐶 ≔ ∀𝑦 𝑦 ∈ 𝐵 ↔ 𝑦 ∈ 𝐶
  • 1,3,5 = 3,1,5
  • 1,3,5 = 1,3,3,3,5,5,5,5,5 ?
  • Subset, 𝐵 ⊆ 𝐶
  • 𝐵 ⊆ 𝐶 ≔ ∀𝑦 𝑦 ∈ 𝐵 → 𝑦 ∈ 𝐶
  • 1,9 ⊆ 1,3,5,7,9
  • 1,9 ⊆ 1,9
  • Proper Subset, 𝐵 ⊂ 𝐶
  • 𝐵 ⊂ 𝐶 ≔ 𝐵 ⊆ 𝐶 ∧ 𝐵 ≠ 𝐶
  • 1,9 ⊂ 1,3,5,7,9
  • 1,9 ⊄ 1,9
  • ∅ ⊆ 𝐵, for any set 𝐵
  • 𝐵 ⊆ 𝐵, for any set 𝐵
  • How can we express equality in terms
  • f subsets?
  • 𝐵 = 𝐶 ↔ 𝐵 ⊆ 𝐶 ∧ 𝐶 ⊆ 𝐵
slide-8
SLIDE 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 𝑇

slide-9
SLIDE 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.
slide-10
SLIDE 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.

𝑏, 𝑐 , 𝑑, 𝑒 ≠ 𝑏, 𝑐, 𝑑 , 𝑒

slide-11
SLIDE 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
  • 𝐵 ∪ 𝐶 = 𝐵 + 𝐶 − 𝐵 ∩ 𝐶
slide-12
SLIDE 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?
  • 𝐵 − 𝐶 = 𝐵 ∩ 𝐶
slide-13
SLIDE 13

Venn Diagrams

  • Draw a rectangle to

represent 𝑉.

  • Draw geometric shapes

inside to represent sets.

  • Use points to represent

particular elements.

𝑉 𝑊

a e i

  • u
slide-14
SLIDE 14

Venn Diagrams

= 𝐵 𝐵 𝑉

slide-15
SLIDE 15

Venn Diagrams

= 𝐵 ∪ 𝐶 𝐵 𝑉 𝐶

slide-16
SLIDE 16

Venn Diagrams

= 𝐵 ∩ 𝐶 𝐵 𝑉 𝐶

slide-17
SLIDE 17

Venn Diagrams

= 𝐵 − 𝐶 𝐵 𝑉 𝐶

slide-18
SLIDE 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
  • 𝑞 ∨ 𝑟 ⇒ 𝑄 ∪ 𝑅
  • 𝑞 ∧ 𝑟 ⇒ 𝑄 ∩ 𝑅
  • ¬𝑞 ⇒ 𝑄
  • 𝑞 → 𝑟 ⇒ 𝑄 ⊆ 𝑅
  • 𝑞 ↔ 𝑟 ⇒ 𝑄 = 𝑅
slide-19
SLIDE 19

Set Identities

  • Ex: 𝐵 ∩ 𝐶 = 𝐵 ∪ 𝐶

(DeMorgan)

  • Show 𝐵 ∩ 𝐶 ⊆ 𝐵 ∪ 𝐶
  • Show 𝑦 ∈ 𝐵 ∩ 𝐶 → 𝑦 ∈ 𝐵 ∪ 𝐶
  • Assume 𝑦 ∈ 𝐵 ∩ 𝐶
  • Then, 𝑦 ∉ 𝐵 ∩ 𝐶
  • ¬ 𝑦 ∈ 𝐵 ∩ 𝐶
  • ¬ 𝑦 ∈ 𝐵 ∧ 𝑦 ∈ 𝐶
  • ¬ 𝑦 ∈ 𝐵 ∨ ¬ 𝑦 ∈ 𝐶
  • 𝑦 ∉ 𝐵 ∨ 𝑦 ∉ 𝐶
  • 𝑦 ∈ 𝐵 ∨ 𝑦 ∈ 𝐶
  • 𝑦 ∈ 𝐵 ∪ 𝐶
  • Show 𝐵 ∪ 𝐶

⊆ 𝐵 ∩ 𝐶

  • Show 𝑦 ∈ 𝐵 ∪ 𝐶

→ 𝑦 ∈ 𝐵 ∩ 𝐶

  • Assume 𝑦 ∈ 𝐵 ∪ 𝐶
  • Then, 𝑦 ∈ 𝐵 ∨ 𝑦 ∈ 𝐶
  • 𝑦 ∉ 𝐵 ∨ 𝑦 ∉ 𝐶
  • ¬ 𝑦 ∈ 𝐵 ∨ ¬ 𝑦 ∈ 𝐶
  • ¬ 𝑦 ∈ 𝐵 ∧ 𝑦 ∈ 𝐶
  • ¬ 𝑦 ∈ 𝐵 ∩ 𝐶
  • 𝑦 ∉ 𝐵 ∩ 𝐶
  • 𝑦 ∈ 𝐵 ∩ 𝐶
slide-20
SLIDE 20

Truth tables ⇒ Membership tables

𝑩 𝑪 𝑩 ∩ 𝑪 𝑩 ∩ 𝑪 𝑩 𝑪 𝑩 ∪ 𝑪 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Verify that 𝐵 ∩ 𝐶 = 𝐵 ∪ 𝐶

slide-21
SLIDE 21

XOR

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