You are on page 1of 38

CM0081 Automata and Formal Languages

The Central Concepts of Automata Theory

Andrés Sicard-Ramírez

Universidad EAFIT

Semester 2021-2
Preliminaries

Convention
The number assigned to chapters, examples, exercises, figures, sections,
and theorems on these slides correspond to the numbers assigned in the
textbook [Hopcroft, Motwani and Ullman 2007].

The Central Concepts of Automata Theory 2/38


Alphabets and Strings

Definition
An alphabet is a finite, non-empty set of symbols.

The Central Concepts of Automata Theory 3/38


Alphabets and Strings

Definition
An alphabet is a finite, non-empty set of symbols.

Examples

Σ1 = {0, 1},
Σ2 = {𝑎, 𝑏, … , 𝑧},
Σ3 = { 𝑥 ∣ 𝑥 is a Unicode codepoint }.

The Central Concepts of Automata Theory 4/38


Alphabets and Strings

Definition
A string (or word or event) is a finite sequence of symbols of an alphabet.

The Central Concepts of Automata Theory 5/38


Alphabets and Strings

Definition
A string (or word or event) is a finite sequence of symbols of an alphabet.

Definition
The empty string, denoted by 𝜀, is the string with zero occurrences of
symbols.

Remark
The empty string may be chosen from any alphabet.

The Central Concepts of Automata Theory 6/38


Alphabets and Strings

Definition
A string (or word or event) is a finite sequence of symbols of an alphabet.

Definition
The empty string, denoted by 𝜀, is the string with zero occurrences of
symbols.

Remark
The empty string may be chosen from any alphabet.

Conventions
Alphabets: Σ, Γ, …
Symbols: 𝑎, 𝑏, 𝑐, …
Strings: 𝑤, 𝑥, 𝑦, 𝑧, …

The Central Concepts of Automata Theory 7/38


All Strings over an Alphabet

Definition
Let Σ be an alphabet. The set of all the strings over 𝚺 (including
the empty string), denoted Σ∗ , can be inductively defined by the follow-
ing clauses:

i) 𝜀 ∈ Σ∗ (basis step),
ii) 𝑥 ∈ Σ∗ , 𝑎 ∈ Σ ⇒ 𝑥𝑎 ∈ Σ∗ (inductive step).

Or, equivalently,
𝑥 ∈ Σ∗ 𝑎∈Σ
𝜀 ∈ Σ∗ 𝑥𝑎 ∈ Σ∗

The Central Concepts of Automata Theory 8/38


Operations on Strings

Definition
Let Σ be an alphabet. The length of a string is recursively defined by

|−| ∶ Σ∗ → ℕ
|𝜀| = 0
|𝑥𝑎| = |𝑥| + 1

The Central Concepts of Automata Theory 9/38


Operations on Strings

Definition
Let Σ be an alphabet. The concatenation of strings is recursively defined by

(−) · (−) ∶ Σ∗ × Σ∗ → Σ∗
𝑥·𝜀=𝑥
𝑥 · 𝑦𝑎 = (𝑥 · 𝑦)𝑎

The Central Concepts of Automata Theory 10/38


Operations on Strings

Definition
Let Σ be an alphabet. The concatenation of strings is recursively defined by

(−) · (−) ∶ Σ∗ × Σ∗ → Σ∗
𝑥·𝜀=𝑥
𝑥 · 𝑦𝑎 = (𝑥 · 𝑦)𝑎

Note: 𝑥 · 𝜀 = 𝜀 · 𝑥 = 𝑥 (that implies an algebraic structure)

The Central Concepts of Automata Theory 11/38


Operations on Strings

Definition
Let Σ be an alphabet. The concatenation of strings is recursively defined by

(−) · (−) ∶ Σ∗ × Σ∗ → Σ∗
𝑥·𝜀=𝑥
𝑥 · 𝑦𝑎 = (𝑥 · 𝑦)𝑎

Note: 𝑥 · 𝜀 = 𝜀 · 𝑥 = 𝑥 (that implies an algebraic structure)


Notation
We remove the dot in the concatenation.

The Central Concepts of Automata Theory 12/38


Operations on Strings

Example
Let Σ be an alphabet and let 𝑥 and 𝑦 be strings over Σ. Prove that

|𝑥𝑦| = |𝑥| + |𝑦|.

The Central Concepts of Automata Theory 13/38


Operations on Strings

Proof
By structural induction on 𝑦.
Basis step (𝑦 = 𝜀):

|𝑥𝜀| = |𝑥| (def. of concatenation)


= |𝑥| + |𝜀| (def. of length)

Induction step (𝑦 = 𝑤𝑎):

|𝑥(𝑤𝑎)| = |(𝑥𝑤)𝑎| (def. of concatenation)


= |𝑥𝑤| + 1 (def. of length)
= |𝑥| + |𝑤| + 1 (IH)
= |𝑥| + |𝑤𝑎| (def. of length)

The Central Concepts of Automata Theory 14/38


Operations on Strings

Proof
By structural induction on 𝑦 (or by mathematical induction on |𝑦|).
Basis step (𝑦 = 𝜀) (or |𝑦| = 0, then 𝑦 = 𝜀):

|𝑥𝜀| = |𝑥| (def. of concatenation)


= |𝑥| + |𝜀| (def. of length)

Induction step (𝑦 = 𝑤𝑎) (or |𝑦| = 𝑛 + 1, then 𝑦 = 𝑤𝑎 where |𝑤| = 𝑛):

|𝑥(𝑤𝑎)| = |(𝑥𝑤)𝑎| (def. of concatenation)


= |𝑥𝑤| + 1 (def. of length)
= |𝑥| + |𝑤| + 1 (IH)
= |𝑥| + |𝑤𝑎| (def. of length)

The Central Concepts of Automata Theory 15/38


Operations on Strings

Strings, length and concatenation in Haskell

data List a = Nil ∣ Cons a (List a)


data RList a = Lin ∣ Snoc (RList a) a

The Central Concepts of Automata Theory 16/38


Operations on Strings

Strings, length and concatenation in Haskell

data List a = Nil ∣ Cons a (List a)


data RList a = Lin ∣ Snoc (RList a) a

lengthR ∶∶ RList a → Int


lengthR Lin =0 -- Eq. 1
lengthR (Snoc xs x) = 1 + lengthR xs -- Eq. 2

The Central Concepts of Automata Theory 17/38


Operations on Strings

Strings, length and concatenation in Haskell

data List a = Nil ∣ Cons a (List a)


data RList a = Lin ∣ Snoc (RList a) a

lengthR ∶∶ RList a → Int


lengthR Lin =0 -- Eq. 1
lengthR (Snoc xs x) = 1 + lengthR xs -- Eq. 2

(+++) ∶∶ RList a → RList a → RList a


(+++) xs Lin = xs -- Eq. 1
(+++) xs (Snoc ys y) = Snoc (xs +++ ys) y -- Eq. 2

The Central Concepts of Automata Theory 18/38


Operations on Strings

Example
Prove that lengthR (xs +++ ys) = lengthR xs + lengthR ys.

The Central Concepts of Automata Theory 19/38


Operations on Strings

Example
Prove that lengthR (xs +++ ys) = lengthR xs + lengthR ys.

Proof by structural recursion on ys


Basis step (ys is Lin):

lengthR (xs +++ Lin)


= lengthR xs (Eq. 1 of (+++))
= lengthR xs +++ lengthR Lin (Eq. 1 of lengthR)

The Central Concepts of Automata Theory 20/38


Operations on Strings

Proof by structural recursion on ys (continuation)


Induction step (ys is Snoc ys′ y′ ):

lengthR (xs +++ (Snoc ys′ y′ ))


= lengthR (Snoc (xs +++ ys′ ) y′ )) (Eq. 2 of (+++))

= 1 + lengthR (xs +++ ys ) (Eq. 2 of lengthR)

= 1 + (lengthR xs + lengthR ys ) (IH)

= lengthR xs + (1 + lengthR ys ) (arithmetic)

= lengthR xs + lengthR (Snoc ys y) (Eq. 2 of lengthR)

The Central Concepts of Automata Theory 21/38


Operations on Strings and Alphabets

Definition
Let Σ be an alphabet, 𝑥 ∈ Σ∗ and 𝑛 ∈ ℕ. The power of strings 𝑥𝑛 , is
recursively defined by

(−)(−) ∶ Σ∗ × ℕ → Σ∗
𝑥0 = 𝜀
𝑥𝑛+1 = 𝑥𝑛 · 𝑥

The Central Concepts of Automata Theory 22/38


Operations on Strings and Alphabets

Definition
The 𝐤-power of an alphabet Σ, denoted Σ𝑘 , is the set of strings of length 𝑘
over Σ.

Examples
Given Σ = {0, 1} then

Σ0 = {𝜀},
Σ1 = {0, 1},
Σ2 = {00, 01, 10, 11},
Σ3 = {000, 001, 010, 011, 100, 101, 110, 111}.

The Central Concepts of Automata Theory 23/38


Operations on Strings and Alphabets

Example
Let Σ be an alphabet. Then

Σ∗ = Σ0 ∪ Σ1 ∪ Σ2 ∪ ⋯

The Central Concepts of Automata Theory 24/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

The Central Concepts of Automata Theory 25/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet

The Central Concepts of Automata Theory 26/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet
The set of string of 0’s and 1’s with equal number of each

{𝜀, 01, 10, 0011, 0110, 1001, 1100, … }

The Central Concepts of Automata Theory 27/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet
The set of string of 0’s and 1’s with equal number of each

{𝜀, 01, 10, 0011, 0110, 1001, 1100, … }


{ 0 𝑛 1𝑛 ∣ 𝑛 ≥ 1 }

The Central Concepts of Automata Theory 28/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet
The set of string of 0’s and 1’s with equal number of each

{𝜀, 01, 10, 0011, 0110, 1001, 1100, … }


{ 0 𝑛 1𝑛 ∣ 𝑛 ≥ 1 }
{𝜀} ≠ ∅

The Central Concepts of Automata Theory 29/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet
The set of string of 0’s and 1’s with equal number of each

{𝜀, 01, 10, 0011, 0110, 1001, 1100, … }


{ 0 𝑛 1𝑛 ∣ 𝑛 ≥ 1 }
{𝜀} ≠ ∅
The set of binary numbers whose value is a prime

The Central Concepts of Automata Theory 30/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet
The set of string of 0’s and 1’s with equal number of each

{𝜀, 01, 10, 0011, 0110, 1001, 1100, … }


{ 0 𝑛 1𝑛 ∣ 𝑛 ≥ 1 }
{𝜀} ≠ ∅
The set of binary numbers whose value is a prime
The set of legal C programs

The Central Concepts of Automata Theory 31/38


Languages

Definition
If Σ is an alphabet and 𝐿 ⊆ Σ∗ then 𝐿 is a language over Σ.

Examples
∅ and Σ∗ are languages over any alphabet
The set of string of 0’s and 1’s with equal number of each

{𝜀, 01, 10, 0011, 0110, 1001, 1100, … }


{ 0 𝑛 1𝑛 ∣ 𝑛 ≥ 1 }
{𝜀} ≠ ∅
The set of binary numbers whose value is a prime
The set of legal C programs
The set of legal English words

The Central Concepts of Automata Theory 32/38


Problems

Definition
Let 𝐿 ⊆ Σ∗ be a language and let 𝑤 ∈ Σ∗ be string. To decide whether or
not 𝑤 ∈ 𝐿 is the decision problem on the language 𝐿.

The Central Concepts of Automata Theory 33/38


Problems

Definition
Let 𝐿 ⊆ Σ∗ be a language and let 𝑤 ∈ Σ∗ be string. To decide whether or
not 𝑤 ∈ 𝐿 is the decision problem on the language 𝐿.
Problem or decision problem?

The Central Concepts of Automata Theory 34/38


Problems

Definition
Let 𝐿 ⊆ Σ∗ be a language and let 𝑤 ∈ Σ∗ be string. To decide whether or
not 𝑤 ∈ 𝐿 is the decision problem on the language 𝐿.
Problem or decision problem?
It is a language or a problem?

The Central Concepts of Automata Theory 35/38


Problems

Definition
Let 𝐿 ⊆ Σ∗ be a language and let 𝑤 ∈ Σ∗ be string. To decide whether or
not 𝑤 ∈ 𝐿 is the decision problem on the language 𝐿.
Problem or decision problem?
It is a language or a problem?
Is the problem decidable or undecidable?

The Central Concepts of Automata Theory 36/38


Problems

Definition
Let 𝐿 ⊆ Σ∗ be a language and let 𝑤 ∈ Σ∗ be string. To decide whether or
not 𝑤 ∈ 𝐿 is the decision problem on the language 𝐿.
Problem or decision problem?
It is a language or a problem?
Is the problem decidable or undecidable?
Is the problem tractable or intractable?

The Central Concepts of Automata Theory 37/38


References

Hopcroft, J. E., Motwani, R. and Ullman, J. D. (2007). Introduction to Auto-


mata theory, Languages, and Computation. 3rd ed. Pearson Education (cit.
on p. 2).

The Central Concepts of Automata Theory 38/38

You might also like