Professional Documents
Culture Documents
Lec02 Concepts
Lec02 Concepts
Firat Akba
TED University
Department of Computer Engineering
Spring 2023
Topics
Mathematical preliminaries
I Sets
I Relations and functions
I Equivalence relations
I Proof by induction
Material:
Sections 1.1–1.6 in Finnish lecture notes
(or Chapter 0 in the Sipser book)
Mathematical Preliminaries
1.1 Sets
A set is a collection of elements.
The elements can be given by enumerating, e.g.,
X = {0,
/ {1}, {2}, {1, 2}}.
The family of sets formed by taking all the subsets of a base set A
is called the power set over A and is denoted with P (A).
As an example,
[Because the power set over a base set with n elements contains
2n elements, the notation 2A is also used in the literature.]
Observe that A ⊆ B if and only if A ∈ P (B).
Pay attention to the empty set:
0/ 6= {0},
/ P (0)
/ = {0},
/ P ({0})
/ = {0,
/ {0}}.
/
The most common operations used to combine sets are:
Union
A ∪ B = {x | x ∈ A or x ∈ B},
E.g. {1, 2, 3} ∪ {1, 4} = {1, 2, 3, 4}.
Intersection
A ∩ B = {x | x ∈ A and x ∈ B},
E.g. {1, 2, 3} ∩ {1, 4} = {1}.
Difference
A − B = {x | x ∈ A and x ∈
/ B},
E.g. {1, 2, 3} − {1, 4} = {2, 3}.
[The notation A \ B is also used for set difference.]
The union and intersection operations are associative:
A ∪ (B ∪ C) = (A ∪ B) ∪ C
A ∩ (B ∩ C) = (A ∩ B) ∩ C
and commutative:
A∪B = B∪A
A∩B = B∩A
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
If all the sets we consider are subsets of some common “universal set”
U , we call the difference U − A the complement of A (in U ) and denote
it by Ā.
The union, intersection and complement operations are related by the
important De Morgan laws:
A ∪ B = Ā ∩ B̄
A ∩ B = Ā ∪ B̄
A − B = A ∩ B̄
If the elements of a set family A are indexed, e.g.
A = {A1 , A2 , A3 , . . . },
we define the following notation:
[ \
Ai = A1 ∪ A2 ∪ A3 · · · and Ai = A1 ∩ A2 ∩ A3 · · ·
i≥1 i≥1
The indices do not need to be natural numbers. The index set can be
any set I . In such a case, we use the notations
A = {Ai | i ∈ I}
and [ \
Ai , Ai .
i∈I i∈I
1.2 Relations and functions
Let A and B be sets.
An ordered pair of two elements a ∈ A and b ∈ B is denoted by
(a, b).
Observe that for sets we have {a, b} = {b, a}, but (a, b) 6= (b, a)
whenever a 6= b.
The Cartesian product of A and B is defined as
Example
{1, 2, 3} × {1, 4} = {(1, 1), (1, 4), (2, 1), (2, 4), (3, 1), (3, 4)}
{a, b} × N = {(a, 0), (b, 0), (a, 1), (b, 1), (a, 2), (b, 2), ...}
{a, b} × 0/ = 0/
A relation R between a set A and a set B is a subset of the
Cartesian product A × B:
R ⊆ A × B.
R = {(a, b), (a, c), (b, d), (c, d), (d, d)}
c d c d
A relation f ⊆ A × B is a function if each a ∈ A is in relation f with
exactly one b ∈ B. In this case, one uses the usual function
notations f : A → B and f (a) = b.
Everything above that applies to relations thus also applies to
functions; however for historical reasons function composition is
written from right to left.
That is, if f : A → B and g : B → C are functions, then their
function composition is defined as (g ◦ f )(a) = g(f (a)), i.e. as the
relation
Proposition 1.4
Let R ⊆ A × A be an equivalence relation. Then the equivalence
classes of R partition A into mutually disjoint non-empty subsets, i.e.
R[a] 6= 0/ for each a ∈ A,
S
A= a∈A R[a], and
if R[a] 6= R[b], then R[a] ∩ R[b] = 0/ , for all a, b ∈ A.
P(n) : (1 + 2 + · · · + n)2 = 13 + 23 + · · · + n3 .
Proof.
1. Induction basis P(0) : 0 2 = 0.
(continues)
2. Induction hypothesis and step: assume that, for some given
k ≥ 0, the formula
P(k) : (1 + 2 + · · · + k)2 = 13 + 23 + · · · + k3
(1 + 2 + · · · + k + (k + 1))2
= (1 + · · · + k)2 + 2(1 + · · · k)(k + 1) + (k + 1)2
k(k + 1)
= 13 + · · · + k 3 + 2 · · (k + 1) + (k + 1)2
2
= 13 + · · · + k3 + k(k + 1)2 + (k + 1)2
= 13 + · · · + k3 + (k + 1)3 .
We have thus shown that whenever P(k) holds, then also P(k + 1)
holds, i.e., that P(k) ⇒ P(k + 1) for all k ≥ 0. By induction, we can
thus deduce that the formula P(n) holds for all n ∈ N.
Automata and Formal Languages
Automata theory ∼ general theory of discrete I/O-mechanisms.
Input Output
”1011” Automaton ”yes”/”no”
Example:
If Σ = {0, 1}, then Σ∗ = {ε, 0, 1, 00, 01, 10, 11, 000, . . .}.
Example:
If Σ = {0, 1}, then the following are formal languages over Σ:
0/
{ε, 0, 110110110011100}
{0, 1, 11, 111, 1111, ...}
Σ∗ = {ε, 0, 1, 00, 01, 10, 11, 000 . . .}
1.6 Automata and languages
Let M be an automaton whose inputs are strings over an
alphabet Σ, and the outputs are simply of form “input accepted” or
“input rejected”. (Abbreviated as 1/0.)
Denote the output of M on input x by M(x), and the set of all
inputs accepted by M by AM , i.e.
AM = {x ∈ Σ∗ | M(x) = 1}.
We say that M recognises the language AM ⊆ Σ∗ .
A main idea in automata theory: the structure of an automaton M
is reflected in the properties of the language AM .
Conversely: suppose that we are interested in an I/O-mapping
f : Σ∗ → {0, 1}. By studying the language
Af = {x ∈ Σ∗ | f (x) = 1}
we may deduce what kind of an automaton is needed to
implement the function f .
1.7 Common notation
Example:
Let Σ be an alphabet. The reversal wR of a string w ∈ Σ∗ is defined
inductively with the following rules:
1. εR = ε
2. if w = ua, u ∈ Σ∗ , and a ∈ Σ, then wR = abuR .
Such an inductive (“recursive”) definition can naturally be used in
calculations, e.g.,
(xw)R = (xya)R
= ab(xy)R [definition of R]
= ab(yR xR ) [induction hypothesis]
= (abyR )xR [associativity of b]
= (ya)R xR [definition of R]
= wR xR .