Sets
Sets
Sets
Sets and
Membership
❑ A set is to be thought of as any collection of objects
whatsoever.
❑ The elements contained in each set need not have
anything in common.
❑ There is no restriction on the number of elements
allowed in a set.
❑ We should be able to decide (in principle) whether the
object belongs to the set.
Notation
❑ Use upper-case letters to denote sets and lower-case
letters to denote elements.
❑ The symbol ∈ denotes ‘belongs to’ or ‘is an element of’.
❑ For example:
a є A means the element a belongs to the set A.
and
a ∉ A means the element a does not belongs to set A
Defining Sets
❑ The basic is to list all the elements enclosed between
curly brackets.
❑ Example 1:
b. {x : x = y2 and y is an integer}
• Example 5: Let X = {0, 1, 2}. List the elements of each of
the following sets:
a. {z : z = 2x and x ∈ X}
b. {z : z = x + y where x ∈ X and y ∈ X}
c. {z : x = z + y where x ∈ X and y ∈ X}
• Example 6: Determine the cardinality of each of the
following sets:
a. {x : x is an integer and 1/8 < x < 17/2}
b. {x : 𝑥 is an integer}
• Example 7: Use the notation {x : P(x)}, where P(x) is a
propositional function, to describe each of the following
sets.
a. {1, 2, 3, 4, 5}.
b. ∅⊆ {∅, {∅}}
c. {2} ∈ {1, 2, 3, 4, 5}
b. {A : A is a proper subset of X}
c. {A : A ⊆ X and 1 ∈ A}
• Example 13: Let 𝒰= {x : x is an integer and 2 ≤ x ≤ 10}. In
each of the following cases, determine whether A ⊆ B, B ⊆
A, both or neither:
a. A = {x : x is odd} B = {x : x is a multiple of 3}
b. A = {x : x is even} B = {x : x2 is even}
Operations on Sets
❑ Venn diagram
❑ is a useful visual representation of sets.
❑ sets are represented as regions in the plane and elements
which belong to a given set are placed inside the region
representing it.
❑ All sets are placed inside a box which represents the
universal set.
❑ To show that an element(s) belong to more than one set;
the sets involve must overlap and the element(s) is/are
placed inside the overlap.
❑ Intersection
❑ The intersection of two sets A and B, denoted by A ⋂ B is
the set of all elements that belong to both set A and set B.
❑ A ∩ B = {x : x ∈ A and x ∈ B}
❑ Union
❑ The union of two sets A and B, denoted by A ⋃ B is the set
of all elements that belongs to set A or to set B or both.
❑ A ∪ B = {x : x ∈ A or x ∈ B or both}
❑ The generalized intersection – more than two sets
⋂𝑛𝑟=1 𝐴𝑟 = A1 ∩ A2 ∩ · · · ∩ An
= {x : x ∈ A1 and x ∈ A2 and . . . and x ∈ An}
= {x : x belongs to each set Ar, for r = 1, 2, . . . , n}.
❑ The generalized union – more than two sets.
❑ ⋃𝑛𝑟=1 𝐴𝑟 = A1 ∪ A2 ∪ · · · ∪ An
= {x : x ∈ A1 or x ∈ A2 or . . . or x ∈ An}
= {x : x belongs to at least one set Ar, r = 1, . . . , n}.
❑ Disjoint
❑ Sets A and B are disjoint if they have no common element.
❑ A∩B={}
❑ The complement of a set A, denoted by 𝐴 (or A’ or Ac),
consists of all elements in 𝒰 that are not found in set A.
❑ A = {x : P(x)}, A’ = {x : ~P(x)}
❑ The difference or relative complement of two sets A and
B, denoted A − B or A \ B.
❑ A - B = {x : x ∈ A and x ∉ B}
• Example 14: Let 𝒰 = {1, 2, 3, …, 10}, A = {n є 𝒰: 1 ≤ n ≤ 7},
B = {n є 𝒰: m is a multiple of 3}. Determine: A ⋂ B, A ⋃ B, A
– B, B – A, 𝐴, 𝐴 ∪ 𝐵, 𝐴 − 𝐵
• Example 14: For each of the following, draw the Venn
diagram and shade the region corresponding to the
indicated set.
a. A – (B ⋂ C)
b. (A - B) ⋃ (A - C)
Counting
Techniques
❑ Counting Principle 1: if A and B are disjoint sets, then
|A ∪ B| = |A| + |B|.
❑ Counting Principle 2:If A1, A2, . . . , An are sets, no pair
of which have elements in common, then
|A1 ∪ A2 ∪ · · · ∪ An| = |A1| + |A2| + · · · + |An|.
❑ The Inclusion-Exclusion Principle: if A and B are finite
sets then
|A ∪ B| = |A| + |B| − |A ∩ B|.
❑ If A, B and C are finite sets, then
|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |B ∩ C|
− |C ∩ A| + |A ∩ B ∩ C|
• Example 15:Each of the 100 students in the first year of
Utopia University’s Computer Science Department studies
at least one of the subsidiary subjects: mathematics,
electronics and accounting. Given that 65 study
mathematics, 45 study electronics, 42 study accounting, 20
study mathematics and electronics, 25 study mathematics
and accounting, and 15 study electronics and accounting,
find the number who study:
a. all three subsidiary subjects;
b. mathematics and electronics but not accounting;
c. only electronics as a subsidiary subject.
• Example 16: In a survey of 1000 households, 275
owned a home computer, 455 a video, 405 two cars,
and 265 households owned neither a home computer,
nor a video, nor two cars. Given that 145 households
owned both a home computer and a video, 195 both a
video and two cars, and 110 both two cars and a home
computer, find the number of households surveyed
which owned:
a. a video only;
b. two cars, a video but not a home computer;
c. a video, a home computer but not two cars.
Family of Sets
❑ Family of sets or collection of sets - a set of sets.
❑ {A1, A2, . . . , An}, the integers 1, 2, …, n are labels to
distinguish the different sets in the collection.
❑ The collection {A1, A2, . . . , An}, the indexing set is I = {1,
2, . . ., n}, the family of set can be written as
{Ai : i ∈ I} = {A1, A2, . . . , An}
a. B ∈ P(A)
b. B ∈ A
c. A ⊆ P(A)
d. {{1}, B} ⊆ P(A)
e. { } ∈ P(A)
f. { } ⊆ P(A).
Partitions of a Set
❑ Partition of a set is a set of non-interesting subsets of
any given set.
❑ Particularly useful when counting the elements of a set.
❑ Let A be a set. A partition of A is a family {Si : i є I} of
non-empty subsets of A such that:
❑ ⋃𝑖 ∈𝐼 𝑆𝑖 = A, and
❑ Si ⋂ Sj = ∅ if i ≠ j for all i, j є I.
❑ If the second condition (previous slide) is satisfied, then
the family of sets Si are pairwise disjoint.
❑ Example 21:
a. {{1}, {2, 3}, {4, 5, 6}} is a partition of {1, 2, 3, 4, 5, 6}.
b. Each of the following is a partition of , the set of
integers.
i. {ℤ−, {0}, ℤ+}, where − and + are the sets of negative
and positive integers, respectively.
ii. {{n} : n ∈ ℤ}
• Example 22: List the elements of ℘(A) in the following
cases:
a. A = {a, b, c, d}
b. A = {{1}, {1, 2}}
• Example 23: Which of the following are partitions of the
set {2, 3, 7, 9, 10}?
a. {{2, 3}, {3, 7, 9}, {10}}
d. {2, 3, 7, 9, 10}
The Cartesian
Product
❑ The Cartesian product, X ×Y , of two sets X and Y is the
set of all ordered pairs (x, y) where x belongs to X and y
belongs to Y :
X × Y = {(x, y) : x ∈ X and y ∈ Y}
❑ Ordered pair (x, y) of objects x and y, to be such that
(x, y) = (x’, y’) if and only if x = x’ and y = y’.
❑ If X = Y, X x X denoted by X2 read as ‘X two’
• If either X or Y (or both) is empty, then X x Y is also empty.
• If X and Y are non-empty sets then X x Y = Y x X if X = Y.
• Example 24: If X = {1, 2} and Y = {a, b, c} then
X × Y = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c)}.
b. (A × X) ∩ (B × Y )
Types and Typed Set
Theory
❑ In software engineering, the notion of ‘types’ plays an
important role in the various phases of software
development: specification, design and implementation.
❑ Each operation defined on ℤ has a ‘signature’ which
describes the ‘inputs’ and ‘outputs’ of the operation. The
operations of addition, subtraction, multiplication each
take two integers as ‘input’ and give a single integer as
‘output’.
❑ Integer , Integer → Integer
❑ Examples:
1. Addition _+_ : Integer , Integer → Integer
2. Subtraction _−_ : Integer , Integer → Integer
3. Multiplication _×_ : Integer , Integer → Integer
4. Negation −_ : Integer → Integer .
5. Less than _ ≤ _: Integer , Integer → Boolean .
6. Divides _|_ : Integer , Integer → Boolean (m|n reads ‘m divides
n’)
Typed Set Theory
❑ In typed set theory, all the elements of a set are
required to have the same type.
❑ We use the notation {x : T | P(x)} to define the set of all
elements of type T for which the propositional function
P(x) is true.
❑ We read {x : T | P(x)} as ‘the set of all x of type T such that
P(x) (is true)’
❑ Thus, a set of the form {x : T | P(x)} has type Set [T ].
• Example 27: Let A = {n : Integer | −2 ≤ n ≤ 3}, then A has the
type Set[integer]
f. (x < y) ⅴ (P → Q)
g. Age(Anne) + 5 = Brian
• Example 30: Suppose the following type declarations have been
made. k, m, n : Integer; x, y, z : Real; P, Q : Boolean . Where
necessary, assume that Integer is a subtype of Real ; for example,
the division operation for real numbers _ /_ : Real , Real → Real
can take integer arguments (although the result will always be of
type Real ).
a. State the type of each of the following terms
i. m + (k × n)
ii. x (y − z)
b. Determine whether each of the following expressions is
meaningful (that is, ‘type checks’).
i. x × (k/n)
ii. (n = m) → (P ∨ Q)
iii. P ∧ (x ≥ y)