Set Theory

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Sets

A B

C
Basic Set Theory

• Basic Definitions

• Properties of Sets

• Operations on Sets
Defining Sets
Definition: A set is an unordered collection of objects.
The objects in a set are called the elements or
members of the set S, and we say S contains its
elements.

We can define a set by directly listing all its elements.


e.g., S = {2, 3, 5, 7, 11, 13, 17, 19},
S = {Comprog, Dastruc, OOProg21, AppsDev}

After we define a set, the set is a single mathematical


object, and it can be an element of another set.
e.g. S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}
Examples of Sets
Well known sets: • the set of all real numbers,
• the set of all complex numbers,
• the set of all integers,
• the set of all positive integers
• empty set, , the set with no elements.

Other examples:

The set of all polynomials with degree at most three: {1, x, x2, x3, 2x+3x2,…}.

The set of all n-bit strings: {000…0, 000…1, …, 111…1}

The set of all triangles without an obtuse angle: { , ,… }

The set of all graphs with four nodes: { , , , ,…}


Venn Diagram: Example
• A set can be represented graphically using a Venn
Diagram.

U x y B
A
z

a
C
Membership

Order, number of occurence are not important.

e.g. {a,b,c} = {c,b,a} = {a,a,b,c,b}

The most basic question in set theory is whether an element is in a set.

x is an element of A x is not an element of A


x is in A x is not in A

e.g.,

Let P be the set of all prime numbers. Then and

Let Q be the set of all rational numbers. Then and


Size of a Set

In this course we mostly focus on finite sets.

Definition: The size of a set S, denoted by |S|,


is defined as the number of elements contained in S.

e.g. if S = {2, 3, 5, 7, 11, 13, 17, 19}, then |S|=8.


if S = {Comprog, Dastruc, OOProg21, AppsDev}, then |S|=4.
if S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}, then |S|=6.
Cardinality

• If S is finite, then the cardinality of S, |S|, is


the number of distinct elements in S.

If S = {1,2,3}, |S| = 3.

If S = {3,3,3,3,3}, |S| = 1.

If S = , |S| = 0.

If S = { , {}, {,{}} }, |S| = 3.

If S = {0,1,2,3,…}, |S| is infinite.


Subset

Definition: Given two sets A and B, we say A is a subset of B,


denoted by , if every element of A is also an element of B.

A B
not a subset

• If A={4, 8, 12, 16} and B={2, 4, 6, 8, 10, 12, 14, 16}, then but

• because every element in A is an element of A.

• for any A because the empty set has no elements.

• If A is the set of prime numbers and B is the set of odd numbers, then

Fact: If , then |A| <= |B|.


Practice Activity
1. Let A be the set of odd
positive integers less than 10.

Then, |A| = ?
2. Let S be the set of letters
in the English alphabet.

Then |S| = ?
3. Because the null set has no
elements, it follows that

|∅| = ?
Properties of Sets
Properties of Sets
1.The change in order of writing the elements
does not make any changes in the set.

• The order in which the elements of a set are


written is not important.
• The set {a, b, c} can also be written as {a, c, b}
or {b, c, a} or {b, a, c} or {c, a, b} or {c, b, a}.

Examples:
{4, 6, 7, 8, 9} = {8, 4, 9, 7, 6}
{4, 6, 7, 8, 9} = {8, 4, 9, 7, 6}
{w, x, y, z} = {x, z, w, y} = {z, w, x, y}
Properties of Sets
2. If one or many elements of a set are repeated, the set
remains the same.

• The elements of a set should be distinct.


• Thus, {1, 1, 2, 2, 3, 3, 4, 4, 4} = {1, 2, 3, 4}
• The set of letters in the word ‘GOOGLE’ = {G, O, L, E}

Examples
1. A = {5, 6, 7, 6, 8, 5, 9} is same as set A= {5, 6, 7, 8, 9}

2. If T is a set of letters of the word ‘moon’: then T = {m, o, n},


3. If U = {letters of the word ‘COMMITTEE’};
then U = {I, C, O, M, T, E}
Operations on Sets
Intersection
• Definition: The intersection of two sets A
and B is the set that contains all elements that
are element of both A and B.

• We write: A  B = { x | (a  A)  (b  B) }

U
A B
Intersection
• A ∩ B = {x| x is in A and x is in B}

Examples:
1. A={1, 3, 5, 7, 9} and B={1, 2, 3, 4, 5}
A ∩ B = {1, 3, 5}

2. The intersection of the sets {1, 3, 5} and


{1, 2, 3} is the set {1, 3}
Disjoint Sets
• Definition: Two sets are said to be disjoint if
their intersection is the empty set: A  B = 

U
A B
21

Disjoint Sets
Examples:
1. If A = {x : x is a US president}, and
B = {x : x is in this room},
then A  B = 

2. Let A = {1, 3, 5, 7, 9} and


B = {2, 4, 6, 8, 10}.
Because A ∩ B = ∅, A and B are disjoint.
Union
• Definition: The union of two sets A and B is
the set that contains all elements in A, B, or
both. We write:
AB = { x | (a  A)  (b  B) }

U
A B
Union
• A U B = {x| x is in A or x is in B}

• Examples:
1. A={1, 3, 5, 7, 9} and B={1, 2, 3, 4, 5}
A U B = {1, 2, 3, 4, 5, 7, 9}

2. The union of the sets {1, 3, 5} and {1, 2, 3} is


the set {1, 2, 3, 5}
Difference
• Definition: The difference of two sets A and
B, denoted A\B or A−B, is the set containing
those elements that are in A but not in B

U
A B
25

Difference
Examples:
1. A = {a, b}, B = {b, c, d},
A-B = {a}

2. A= {1, 3, 5} and B= {1, 2, 3}


A-B = {5}
Complement
• Definition: The complement of a set A, denoted A ,
consists of all elements not in A.
• That is the difference of the universal set and
U: U\A
• A’ = {x| x is not in set A}.
• A= AC = {x | x  A }

U A
A
Complement
Examples:

1. U={1,2,3,4,5}, A={1,2}, then A’ = {3, 4, 5}

2. Let A = {a, e, i, o, u} (where the universal set is


the set of letters of the English alphabet).
A’ = {b, c, d, f, g, h, j, k, l,m, n, p, q, r, s, t, v, w,
x, y, z}
Practice Activity
1.
If A = {Charlie, Lucy, Linus}, and
B = {Lucy, Desi}, then,

AB=?
2.
If A = {Charlie, Lucy, Linus}, and
B = {Lucy, Desi}, then

AB=?
3.
A = {1, 3, 6, 8, 10} B = {2, 4, 6, 7, 10}

A B=?
4.
A = {1, 3, 6, 8, 10} B = {2, 4, 6, 7, 10}

AB=?
5.
A = {1, 3, 6, 8, 10} B = {2, 4, 6, 7, 10}

A-B = ?
6.
Let A be the set of positive integers
greater than 10 (with universal set -
the set of all positive integers)

A’ = ?

You might also like