Table of contents
Set Theory
Parent: Discrete Mathematics
Subject: Computer Science
Type: Semester
SL#: 2401121104
Status: Current

Set

A set is a collection of objects. Each such objects are known as set elements.

E.g.: A set of vowels represented as:

A={a,e,i,o,u}A=\{a,e,i,o,u\}

E.g.: A set of positive integers represented as:

A={0,1,2,3,...}A=\{0,1,2,3,...\}

Set Notation

There are two kinds of set notations:

  1. Tabular method
  2. Set builder method

Tabular method

When the set is written with the actual data of elements, the form is said to be tabular.

E.g.: A set of positive integers:

A={0,1,2,3,...} A=\{0,1,2,3,...\}

Set builder method

When the set is written in a generalized way, which denotes all available set elements within it, the form is said to be set builder.

E.g.: A set of positive integers:

A={xx0,xZ}={xxZ+}A=\{x|x\geq0,x\in{Z}\}=\{x|x\in{Z^+}\}

E.g. A set of numbers divisible by 5:

A={xx MOD 5=0,xZ+}A=\{x|x\textnormal{ MOD }5=0,x\in{Z^+}\}

Example 1: Write a set of letters of the word GOOGLEGOOGLE in both set builder and tabular form.

In tabular form:

A={G,O,L,E}A=\{G,O,L,E\}

In set builder form:

A={xxA}={xx{G,O,L,E}}A=\{x|x\in{A}\}=\{x|x\in\{G,O,L,E\}\}

Example 2: Write the set B={xxZ+,z9}B=\{x|x\in{Z^+},z\leq9\} in tabular form.

In tabular form:

B={0,1,2,3...9}B=\{0,1,2,3...9\}

Subset

Let AA and BB be two sets. If every element of AA is also an element of BB, then AA is a subset of BB, and is written as ABA\subseteq{B}.

E.g.: Consider the following two sets AA and BB:

A={2,3,4}A=\{2,3,4\} B={1,2,3,4}B=\{1,2,3,4\}

Since, all elements of AA are in BB, therefore ABA\subseteq{B}.

A set is also its own subset.

Power Set

Let AA be a set containing nn elements. The set of all subsets of AA is called the power set of AA. It consists of 2n2^n elements. It power set of set AA is denoted as:

P(A)\mathcal{P}(A)

E.g.: Considering the set A={a,b,c}A=\{a,b,c\}, then its powerset will be:

P(A)={{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c},{ϕ}}\mathcal{P}(A)=\{\{a\},\{b\},\{c\},\{a,b\},\{b,c\},\{a,c\},\{a,b,c\},\{\phi\}\}

Null set ϕ\phi is a subset of every set.

The following relations between numbers always hold true:

NZRN\subseteq{Z}\subseteq{R}

where,

  • NN: natural numbers
  • ZZ: integer numbers
  • RR: real numbers

Compliment of a Set

Let AA and BB be two sets. The set consisting of all elements of BB, which are not in AA, is called compliment of BB, and is denoted as BAB-A.

Considering the following sets as an example:

B={5,9,8,12,15}B=\{5,9,8,12,15\} A={9,8,11,15}A=\{9,8,11,15\}

Then, the compliment of BB would be:

BA={5,12}B-A=\{5,12\}

Basic Operations on Sets

Following are the operations on sets:

  1. Union
  2. Intersection
  3. Symmetric difference

Union

Let AA and BB be two sets. The set consists of all elements of AA or BB or both, is called the union of AA and BB. It is written as ABA\cup{B}.

Figure 1: Venn diagram for ABA\cup B:

Figure 1: Venn diagram for A\cup B

E.g.: Considering two sets: B={5,9,8}B=\{5,9,8\} and, A={1,5,9,3}A=\{1,5,9,3\}. Their union would be:

AB={1,3,5,8,9}A\cup{B}=\{1,3,5,8,9\}

Intersection

Let AA and BB be two sets. The set elements which are both in AA and BB defines the intersection of AA and BB. It is written as ABA\cup B.

Figure 2: Venn diagram for ABA\cap B:

Figure 2: Venn diagram for A\cap B

E.g.: Considering two sets:

A={1,5,9,3}A=\{1,5,9,3\} B={5,9,8}B=\{5,9,8\}

Then, AB={5,9}A\cap B=\{5,9\}

Symmetric difference

Symmetric difference between two sets AA and BB is defined by the set of all elements that belong to AA or BB, but not to both. It is denoted by ABA\bigoplus B.

Figure 3: Venn diagram for ABA\bigoplus B:

Figure 3: Venn diagram for A\bigoplus B

E.g.: Considering A={1,5,9,3}A=\{1,5,9,3\} and, B={5,9,8}B=\{5,9,8\}. Then, AB={1,3,8}A\bigoplus B=\{1,3,8\}

Example 3: If A={1,2,3,4}A=\{1,2,3,4\}, and B={1,3,5,7,11}B=\{1,3,5,7,11\}. Then prove that AB=(AB)(BA)A\bigoplus B=(A-B)\cup(B-A).

LHS=AB={2,4,5,7,11}\textnormal{LHS}=A\bigoplus B=\{2,4,5,7,11\} RHS=(AB)(BA)={2,4}{5,7,11}={2,4,5,7,11}\textnormal{RHS}=(A-B)\cup(B-A)\\=\{2,4\}\cup\{5,7,11\}\\=\{2,4,5,7,11\} AB=(AB)(BA)\therefore A\bigoplus B=(A-B)\cup(B-A)

LHS=RHS\therefore \textnormal{LHS}=\textnormal{RHS}, hence proved.

Principle of Inclusion and Exclusion

Let us suppose there are two sets AA and BB, and they share elements between each other. If we want to find the total no. of elements in AA and BB, without repeating any common element, then the principle of inclusion and exclusion states the following:

AB=A+BAB|A\cup B|=|A|+|B|-|A\cap B|

The number of elements of AA is added with all elements in BB. The sum is then subtracted from the common elements in AA and BB, which was added twice.

Principle of inclusion and exclusion of three variables

Let the three sets be AA, BB, and CC.

Then,

ABC=A(BC)=A+BCA(BC)|A\cup B\cup C|=|A\cup(B\cup C)|\\ =|A|+|B\cup C|-|A\cap(B\cup C)|\\

By distributive law, we know that A(BC)=(AB)(AC)A\cap(B\cup C)=(A\cap B)\cup(A\cap C). Therefore,

=A+B+CBC(AB)(AC)=A+B+CBC{AB+ACABAC}=|A|+|B|+|C|-|B\cap C|-|(A\cap B)\cup(A\cap C)|\\ =|A|+|B|+|C|-|B\cap C|-\{|A\cap B|+|A\cap C|-|A\cap B\cap A\cap C|\}\\

Since, AA=AA\cap A=A, therefore:

=A+B+CBC{AB+ACABC}=A+B+CBCABAC+ABC=|A|+|B|+|C|-|B\cap C|-\{|A\cap B|+|A\cap C|-|A\cap B\cap C|\}\\ =|A|+|B|+|C|-|B\cap C|-|A\cap B|-|A\cap C|+|A\cap B\cap C|

Therefore,

(ABC)=A+B+CABACBC+ABC(A\cup B\cup C)=|A|+|B|+|C|-|A\cap B|-|A\cap C|-|B\cap C|+|A\cap B\cap C|

Practice questions

  1. Let U={xxZ+,x9}U=\{x|x\in Z^+,x\leq9\}, A={1,3,5,7}A=\{1,3,5,7\}, B={2,4,6}B=\{2,4,6\}, and C={1,2,3,4}C=\{1,2,3,4\}. Find:
    • (a) ABA\cap B and ACA\cap C
    • (b) ABA\cup B and BCB\cup C
    • (c) Bˉ\bar{B} and Cˉ\bar{C}
    • (d) ABA\bigoplus B and BCB\bigoplus C
    • (e) (AC)B(A\cup C)-B, ABA\cup B, (BC)A(B\bigoplus C)-A
  2. Using Venn diagram, show the following sets:
    • (a) (AB)C(A\cup B)\cap C
    • (b) A(BC)A-(B-C)
    • (c) A(BC)A\cap(B\bigoplus C)
    • (d) A(BC)A-(B\cup C)
    • (e) Aˉ(CB)\bar{A}\cap(C-B)
    • (f) Aˉ(BC)\bar{A}\cap(B\cap C)
  3. Answer the following questions:
    • (a) If A={6,2,3}A=\{6,2,3\}, find P(A)\mathcal{P}(A).
    • (b) What is A|A| and P(A)|\mathcal{P}(A)|?
  4. Let U={xxZ+,x9}U=\{x|x\in Z^+,x\leq9\}, A={1,2,4,6,8}A=\{1,2,4,6,8\}, B={2,4,5}B=\{2,4,5\}, C={xxZ+,x29}C=\{x|x\in Z^+,x^2\leq9\}, and D={7,8}D=\{7,8\}. Compute the following:
    • (a) ABA-B
    • (b) BAB-A
    • (c) Cˉ\bar{C}
    • (d) BCB\bigoplus C
    • (e) CDC\bigoplus D
    • (f) ABˉ\bar{A\cup B}
    • (g) A(CˉD)A\cap(\bar{C}\cup D)
  5. In MIT, from a batch of 125 students, 100 students of Mathematics opt for one of the following languages: PASCAL, FORTRAN, and C++. 45 students opt for PASCAL, 25 students opt for FORTRAN, 10 students opt for C++, 5 students opt for both PASCAL and FORTRAN, 20 students opt for both FORTRAN and C++, 7 students opt for PASCAL and C++. Answer the following questions:
    • (a) How many students study all languages?
    • (b) How many students study only FORTRAN?
    • (c) How many students do not study any of the languages?
Docs
AnanyaGB
About
© MIT - 2024