Set Theory

1 / 43

# Set Theory - PowerPoint PPT Presentation

Set Theory. Section 2.1 Tuesday 20 May. Definition: A set is an unordered collection of objects, called the elements or members of the set. A set is said to contain its elements. The definition does not require any relationship among the members of a set.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Set Theory' - moanna

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Set Theory

Section 2.1

Tuesday 20 May

SETS

Definition: A set is an unordered collection of objects, called the elements or members of the set. A set is said to contain its elements.

The definition does not require any relationship among the members of a set.

In a set, repeated elements are ignored.

Notation:

x Sdenotes “x is an element of the set S”

x S denotes “xis not an element of the set S”

What is a Set?

SETS

Enumerate it members, enclosed by curly braces (‘{‘ and ‘}’). Examples:

vowels = { ‘a’, ‘e’, ‘i’, ‘o’, ‘u’, ‘y’}

weekdays = {“Mon”, “Tue”, “Wed”, “Thu”, “Fri”}

N = { 0, 1, 2, … }

Setbuilder notation: describe how to “build” the set

{ exp | predicate } or { expU | predicate }

evens = { y | y is even and yN }

evens = { yN | y is even }

evens = { y | n ( nN y = 2n )}

evens = { 2y | yN }

Describing a Set

SETS

The set of Natural Numbers:N= {0, 1, 2, …}

The set of Integers:Z= { …, -2, -1, 0, 1, 2, …}

The set of Positive Integers: Z+ = {1, 2, …}

The set of Rational Numbers:Q= { p/q | p  Zq  Zq ≠ 0 }

The set of Real Numbers: R

Some Important Sets

SETS

Definition: Two sets are equal if and only if they contain the same elements.

Formally, let S and X be sets. Then S = X if and only if the following proposition is true:[x (x S→ x X )][x (x X → x S)]

Set Equality

SETS

The universal set, denoted U, is the set of all possible elements under consideration.

The emptyset, denoted { } or Ø, is the set containing no elements.

Note that {Ø} is not the same as Ø.

Why not?????

Other Special Sets

SETS

An informal way to picture a set is using Venn diagrams.

Here, we are displaying the set {1,3,5}

U

• 3
• 5
Venn Diagram

SETS

Definition: A set A is a subset of a set B, written A B, if and only if every element of A is also an element of B.

Exercise: How would you express this in Pred. Logic?

A B  x (xA → x  B)

Ais aproper subsetof B, writtenA B, if and only if (A B) (A  B ).

Exercise: Express A B as a predicate logic formula.

A B  ( x (xA → x  B)  ∃x (x∉A x  B) )

One way to show that A = B is to show that A  B and B  A.

That is: A = B (A B) (B  A)

Subsets of a Set

SETS

The empty set Ø is a subset of all sets:

S (Ø  S )

How would you prove this proposition?

Every set is a subset of itself:

S ( S  S )

How would you prove this proposition?

Subsets ….

SETS

Definition: Let S be a set. If there are exactly n (distinct) elements in S, we say that S is a finite set, and that n is the cardinality of S, written |S|.

vowels = { ‘a’, ‘e’, ‘i’, ‘o’, ‘u’, ‘y’ } is finite and |vowels| = 6.

weekdays = {“Mon”, “Tue”, “Wed”, “Thu”, “Fri”} is finite and |weekdays| = 5.

Definition:A set is infinite if it is not finite.

The set of natural numbers N is infinite

The set of real numbers R is infinite

Cardinality of a Set

SETS

Definition:Given a set S, the power set of S, denotedP(S), is the set of all subsets of S.

Example:P({1,2,5}) = {Ø, {1},{2},{5}, {1,2},{1,5},{2,5}, {1,2,5}}

Exercise:

If |S| = 0, what is|P(S)|?

If |S| = 1, what is|P(S)|?

If |S| = 2, what is|P(S)|?

If |S| = 3, what is|P(S)|?

What do you conjecture more generally about |P(S)| ?

Power Set of a Set

SETS

Definition:An ordered n-tuple, written (a1, a2, …, an), is the ordered collection that has a1 as its first element, a2as its second element,…, and an as its nth element.

Two n-tuples are equal if and only if each corresponding pair of their elements is equal.

(a1, a2, …, an) = (b1, b2, …, bn)  a1 = b1  a2 = b2  …  an= bn

Tuples

SETS

Tuples

2-tuples are called (ordered) pairs.

(a, b) = (c, d)iff a = c and b = d

(a, b)≠(b, a)unless a = b

3-tuples are called (ordered) triples.

(a, b, c) = (d, e, f )iff a = d and b = e and c = f

(a, b, c)≠(c, b, a)unless a = c

13

SETS

Definition:Let A and B be sets. The Cartesian product of A andB, denoted A × B, is the set of all ordered pairs (a, b) where aA andbB.

That is:A × B ={ (a, b)| aAbB}

Given:weekdays = {“Mon”, “Tue”, “Wed”, “Thu”, “Fri” }amStartTimes = { “8:00a”, “9:00a”, “10:00a”, “11:00a” }

A calendar for scheduling morning meetings:

weekdays × amStartTimes

IfA ≠ and B ≠ , then(A × B = B × A)  (A=B)

How would you prove this?

Cartesian Product

SETS

Cartesian Product

Definition:Let A1, A2, …, An be sets. The Cartesian product of A1, A2, …, An, denoted A1× A2 × … × An, is the set of all ordered n-tuples (a1, a2, …, an ) where aiAi fori = 1, 2, …, n.

That is:A1× A2 × …× An={ (a1, a2, …, an )| aiAi fori = 1, …, n}

Example:

Given: weekdays, amStartTimes, as defined previously, andcseLabs = { PRIP, SENS, ELANS, LINKS, METLAB, DEVOLAB }

All possible triples indicating a potential morning start time and day for a meeting of a CSE lab: weekdays ×amStartTimes×cseLabs

15

SETS

Relation

Every subset of a Cartesian product is a Relation

One possible schedule for the CSE conference room:{(“Mon”, “9:00a”, PRIP), (“Mon”, “11:00a”, SENS), (“Tue”, “10:00a”, GEM), (“Thu”, “10:00a”, GEM), (“Thu”, “11:00a”, ELAN) }weekdays × amStartTimes × cseLabs

An example binary relation:{(0,0), (1,1), (2,4), (3,9), (4, 16), …}  N × N

What well-know function does this relation describe?

sq = { (n, n2) | n N }

Chapter 8 is all about relations

16

SETS

### Set Operations

Section 2.2

SET THEORY

A

B

U

Set Union
• Definition: Let A and B be sets. The unionof A and B, denoted A B, is the set containing those elements that are either in A or in B, or in both.
• Formally, A B = {x | xA  xB}
• Venn Diagram

SET THEORY

U

A

B

Set Intersection
• Definition: Let A and B be sets. The intersection of A and B, denoted by A ∩B, is the set containing those elements which are in both A and B.
• Formally, A ∩B = { x | xAxB }

SET THEORY

Set Complement
• Definition: Let U be the universal set. The complement of a set S, denoted S,is the set containing elements of U which are not in S.
• Formally, S= { x  U | x S }
• Venn Diagram:

U

S

S

SET THEORY

A

Set Difference
• Definition:Let A andB be sets. The differenceof A and B, denoted A ‒ B, is the set containing those elements that are in A but are not in B.
• A ─Bis the complement of B with respect to A.
• A ─B={x | xAx B}

U

A – B

B

SET THEORY

Exercise:

Let:n range over the natural numbers NA = { 6n | 6n< 41 }B = { 9n | 9n< 41 }

Find the following:

AB

A∩B

A – B

A∩B

A × B

SET THEORY

Membership table for set operators
• Represent conditions for membership in table form

. . .

1= an element in the set 0 = an element is not in the set

What similarities do you notice between membership tables and truth tables?

SET THEORY

Set Identities
• Setstogether withtheoperators { , ∩, ∪} define a special class of Boolean algebraic structures.

SET THEORY

Proving Set Identities – Example.
• (A B) = A B
• To show this identity we can:
• Use the definition thatS = T (S T ) (T  S) (x S)  (x T)
• Use Set Builder notation
• Use membership tables

SET THEORY

Example – Using Membership Table

1= an element in the set 0 = an element is not in the set

SET THEORY

ExampleWe can use proven identities to prove new identities.

Thus, we have proved that:

(A (BC)) = (AB) (AC)

SET THEORY

Proof of Set Identities…
• We can use Venn diagrams to get some ideas about the correctness of identities.
• But, we cannotprove identities using Venn diagrams.

SET THEORY

Generalized Union
• Definition:The union of a collection (set) of sets is the set containing those elements that are members of at least one set in the collection.
• In the case of a finite collection of sets,A0, A1, …, An-1:
• In the case of an infinite collection of sets, A0, A1, …:where N is the set of natural number, N = {0, 1, 2, …}.

SET THEORY

Example
• Let Ai = { i, i + 1, i + 2, ….}.

SET THEORY

Generalized Intersection
• Definition:Theintersection of a collection (set) of sets is the set containing those elements that are members of all the sets in the collection.
• In the case of a finite collection of sets,A0, A1, …, An:
• In the case of an infinite collection of sets, A0, A1, …:

SET THEORY

Example
• Let Ai = { i, i + 1, i + 2, ….}.

SET THEORY

Exercise
• Let
• Find

SET THEORY

Disjoint Sets

• Definition: Two sets A and B are disjointif their intersection is the empty set, i.e., if A ∩B =Ø.
• Definition: The sets A0, A1, …, An-1 are pairwise disjoint if each pair of them is disjoint, i.e., if, for all 0 ≤i, j ≤ n-1, Ai ∩Aj= Ø unless i= j .
• Observation: If A0, A1, …, An-1 are finite sets, then the sets are pairwise disjoint and only if
• Assume this “observation” is an axiom for now.
• To prove it we need a formal definition for the cardinality of a set (see next section).

SET THEORY

Principle of inclusion-exclusion 1:

Set identities can be

be proved using any

of the three methods

just discussed

(exercise).

• If A and B are finite sets, then

|A B| = |A| + |B| - |A ∩B|

Proof: As A  B = (A – B)  (A ∩ B) (B – A)and the sets on the right side are pairwise disjoint, the previous observation implies |A  B| = |A – B| + |A ∩ B|+ |B – A| (*).

U

A

B

Moreover, as A = (A – B)  (A ∩ B) and B = (B – A)  (A ∩ B), this

same observation implies that |A| = |A – B| + |A ∩ B| (**) and that

|B| = |B – A| + |A ∩ B| (***). Solving (**) and (***) for |A – B|

and |B – A|, respectively, and substituting them in (*), we get:|A  B| = (|A| – |A ∩ B|) + |A ∩ B|+ (|B| – |A ∩ B|) = |A| + |B| – |A ∩ B|.

SET THEORY

• Let S be the set of all sets which do not contain themselves.

That is, S = { T | T  T }

• Does S contain itself???

SET THEORY

Computer Representation of Finite Sets
• Use an arbitrary ordering of the elements of the finite universal set U: (a0, a1, …, an-1)
• Represent a subset A of U with the bit string of length n: ith bit is: 1, ifai  A;0, if ai  A
• Example:For A = { 6n | n< 40 } and B = { 9n | n< 40 }, we can use strings of length 40:A: (1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,…) B: (1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,…)
• What string represents Ø? What string represents U?

SET THEORY

Computer Representation…
• With the string representation of a set, and the following conventions, we can do any operation
• Set complementation: Invert each bit (0 to 1, 1 to 0)
• Set union: Do a bit-wise “addition”
• 0 + 1 = 1 + 0 = 1
• 1 + 1 = 1, 0 + 0 = 0
• Set Intersection: Do a bit-wise “multiplication”
• 0 × 1 = 1 × 0 = 0
• 1 × 1 = 1, 0 × 0 = 0

SET THEORY

Exercise:

Using:A: (1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0) B: (1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0)

Find the following:

AB

A∩B

A – B

A∩B

SET THEORY

Note on computer implementations

• Some programming languages have the finite set as a standard data type.
• The Standard Template Library of C++ has a set class. (The multiset allows repeated elements.)
• Real numbers (floats, doubles) typically cannot be members of practical sets because uniqueness ( = test) is not well defined.
• Set ops are typically O(log n) or better in execution time, where n is the set size

SET THEORY