0% found this document useful (0 votes)
0 views

COMP208Lecture 1 Introduction

The document outlines the Theory of Automata course (COMP 208), covering topics such as finite automata, regular languages, and Turing machines. It includes course structure, textbooks, and useful tools like JFLAP for experimenting with formal languages. Additionally, it discusses the history of automata theory and fundamental concepts like alphabets, strings, and formal languages.

Uploaded by

andrewatef757
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

COMP208Lecture 1 Introduction

The document outlines the Theory of Automata course (COMP 208), covering topics such as finite automata, regular languages, and Turing machines. It includes course structure, textbooks, and useful tools like JFLAP for experimenting with formal languages. Additionally, it discusses the history of automata theory and fundamental concepts like alphabets, strings, and formal languages.

Uploaded by

andrewatef757
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Theory of Automata

COMP208: Lecture 1
Introduction
11-2-2025
Automata
• Automata theory is the study of abstract
computing models, or “machines”.

• The word automata (the plural of automaton)


is a Greek word means "self-acting".
Course Information
• Course Code: COMP 208
• Course Title: Theory of Automata
• Credit Hours: 3
– Lecture hours: 2
– Tutorial hours: 2
• Final Exam (duration): 2 Hours
• Total Marks: 150
• 105 Final Exam.
• 37 Mid-Term Exam.
• 8 Oral Exam.
Textbooks
1. J.E. Hopcroft, R. Motwani, and J.D. Ullman,
Introduction to Automata Theory, Languages,
and Computation, 2nd Edition, Addison-
Wesley, 2001
2. M. Sipser, Introduction to the Theory of
Computation, 3rd Edition, Thomson 2014.
Useful tools
http://www.jflap.org/
JFLAP (Java Formal Languages and Automata Package):
• A software for experimenting with formal languages
topics including nondeterministic finite automata,
nondeterministic pushdown automata, multi-tape
Turing machines, and more.
Course Outlines
• Course introduction, basic notions of
alphabets, strings and formal languages.
• Finite Automata (FA):
– Deterministic FA (DFA), Non-Deterministic FA,
(NFA), and the conversion of NFA to DFA.
– Nondeterministic FA with ε-transitions, (εNFA),
and the conversion of εNFA to DFA .
• Regular Expressions, Regular Languages,
operations on Regular Languages.
Course Outlines (Cont.)
• Converting DFA into Regular expressions.
• Converting Regular expressions to εNFA.
• Finite-State transducer: Moore or Mealy
machines.
• Proving the Non-regularity of languages;
Pumping lemma.
• Push-Down Automata.
• Introduction to Turing Machines.
Agenda of Lecture 1
• History.
• Alphabets, ∑.
• Star Clouse (Closure) (∑∗ ).
• Languages over ∑.
• Functions.
History
1930
• Alane Turing's studied an abstract machine
that had all the capacities of today’s computers
(in terms of what it can compute)
History
• Turing’s goal was to describe precisely the
boundary between what a computing machine
could do and what it could not do.
• His conclusions apply not only to his abstract
(Turing machines) but to today's real
machines.
History
1940 and 1950
• Simpler kinds of machines, which we today
call “finite automata”, were studied by a
number of researchers.
• These automata, originally proposed to model
brain function, turned out to be extremely
useful for a variety of other purposes.
History
The late of 1950
• The linguist N. Chomsky began the study of
formal “grammars”.
• These grammars have close relationships to
abstract automata and serve today as the basis
of some important software components,
including parts of compilers.
History
The late of 1969
• S. Cook extended Turing's study of what could
and what could not be computed.
• Cook was able to separate those problems that can
be solved efficiently by computer from those
problems that can in principle be solved, but in
practice take so much time that computers are
useless for all but very small instances of the
problem.
• This class of problems is called "intractable,“ or
"NP-hard."
Alphabets
• The alphabet is a non-empty finite set, ∑ or Γ,
of symbols or characters.
• Examples of a valid alphabets:
– ∑ = {0, 1}
– ∑ = {a, b}
– ∑ = {a, b, …, z}
• φ, ℕ and ℤ cannot be used as an alphabet.
Strings
• From the elements of ∑ we construct strings,
which are finite sequences of symbols from the
alphabet.
• The strings with no elements is called the empty
string and we denote it by ε (or λ).
Example
For the alphabet, ∑ = {0, 1}, the following are
strings over this alphabet ∑:
01, 011, 0110, 0001100
Length of strings
• The length of a string w, denoted by |w| is the
number of symbols in the string.

Example
• if w = 10110111, then |w| = 8
• |ε|=0
Reverse of a string
• The reverse of a string u, denoted by 𝑢𝑟 , is
obtained by writing the symbols in reverse
order.
Example
if u = cabdbbca then 𝑢𝑟 = acbbdbac
Concatenation of 2 strings
The concatenation of 2 strings is the string
formed by writing the first, followed by the
second with no intervening space.
Example
let ∑ = {a, b, c, d},
u = cabdbbca v = bbabab
u and v are strings from ∑ , then
uv = cabdbbcabbabab , vu = bbababcabdbbca
Notes
1. uv ≠ vu
2. |uv | = |vu|
Question
If ∑ = {a, b, c}, u = abc and v = bcc, what is
the length of (𝑢 𝑣)𝑟
1. 12
2. 9
3. 6
Palindrome
• A palindrome is a string that reads the same
forward and backward.
Example
• The string abababa is a palindrome.
• The string baa is not a palindrome.
Properties of strings

1. |𝑢| = |𝑢𝑟 |
2. 𝑢𝜀 = 𝑢 = 𝜀𝑢
Examples
1. ∑ = {0, 1}, then the following are strings
over this alphabet:
11, 000111, 101010

2. ∑ = {𝑠, +, (, ) } , some strings over ∑ are:


( s+, s + s , ss++ )
Powers of an Alphabet
• If ∑ is an alphabet, ∑ 𝑘 is the set of strings of
length k (if every symbol in ∑ has length 1), each of
whose symbols is in ∑.
• For example, if ∑ ={0, 1}, then
– ∑1 = {0, 1}
– ∑ 2 = {00, 01, 10, 11}
– ∑ 3 = {000, 001, 010, 011, 100, 101, 110, 111}

How many strings are there in ∑ 4 ?


Note
• ∑ 0 = {ε} regardless of what alphabet ∑ is.
That is, ε is the only string whose length is 0.
∑∗

• ∑ ∗ is the set of all strings over an alphabet ∑.


• For example,
{0, 1}∗ = {ε, 0, 1, 00, 01, 10, 11, 000, …}
• This means that:
∑ ∗ = ∑ 0 ∪ ∑1 ∪ ∑ 2 ∪ …
• The set ∑ ∗ always contains ε.
• To exclude the empty string, we define:
∑ + = ∑ ∗ − {ε}
∑ + = ∑1 ∪ ∑ 2 ∪ ∑ 3 ∪ …
Language or Formal Language
• English language
– is a set of strings over the alphabet that consists of all the
letters.
– ∑ ={a, b , c,…z, A, B,…Z}.
Language or Formal Language
• A formal language is a set of strings all of which are
chosen from some ∑ ∗ over the alphabet ∑.

• If ∑ is an alphabet and L ⊆ ∑ ∗ , then L is a


language over ∑.
Example 1
Let ∑ = { a, b, c}. The following are languages
over ∑:
▪ Ø,
▪ {ε},
▪ {a, b, bc, bac, bbb, aab},
▪ {aa, ab, ac, ababc, b},
▪ ∑+
▪ ∑∗
Example 2
∑ = {a}, the language L of strings of odd length
over ∑ is:
L = {a, aaa, aaaaa, …}
L = { 𝑎2𝑛+1 , n ϵ N}
Example 3
• The language of all strings consisting of n
number 0’s followed by n number of 1’s, n ≥ 0:
{ 0𝑛 1𝑛 : n≥ 0}
{ε, 01, 0011, 000111,…}
Example 4
• The set of strings of 0’s and 1’s with an equal
number of each:
{ε, 01, 10, 0011, 0101,1001, 1100, 1010, 0110…}
Example 5
Let ∑={a, b}, the following are languages over ∑:
1. M1 = {am bn : m, n ≥ 0}
2. M2 = {an bn : n ≥ 0}
3. M3 = {an bn+2 : n ≥ 1}
4. M5 is the set of all palindrome
Closure (or Star, or Kleene Clouse ) of
a Language
For any language L and any natural number n,
define:
𝐿0 = ε
𝐿1 = 𝐿
𝐿2 = 𝐿𝐿

𝐿𝑛 = 𝐿 𝐿𝑛−1
𝐿∗ = ∪𝑖≥0 𝐿𝑖 , 𝐿+ = ∪𝑖≥1 𝐿𝑖
Example 1
If 𝐿 = 𝑏, 𝑎𝑏
Then
𝐿2 = 𝐿𝐿 = 𝑏𝑏, 𝑏𝑎𝑏, 𝑎𝑏𝑏, 𝑎𝑏𝑎𝑏
And
𝐿3 = 𝐿𝐿2 =
= { 𝑏𝑏𝑏, 𝑏𝑏𝑎𝑏, 𝑏𝑎𝑏𝑏, 𝑏𝑎𝑏𝑎𝑏, 𝑎𝑏𝑏𝑏, 𝑎𝑏𝑏𝑎𝑏, 𝑎𝑏𝑎𝑏𝑏, 𝑎𝑏𝑎𝑏𝑎𝑏}
Example 2
Let 𝐿 = 𝑎 , then:
𝐿∗ = {ε, 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎, … , 𝑎𝑛 ,… }
𝐿+ = { 𝑎, 𝑎𝑎, 𝑎𝑎𝑎, 𝑎𝑎𝑎𝑎, … , 𝑎𝑛 ,… }
Example 3
The language that contains the substring 110
over ∑ = {0, 1} is:
L = {110, 0110, 1100,…}
L = { u 110 v : u, v ϵ ∑ ∗ }
Question
If 𝐿 = {𝑎, 𝑎𝑏}, which of the following words is
NOT in 𝐿∗ :
1. bb
2. aaa
3. ε
Question
If 𝐿 = {𝑎, 𝑎𝑏}, which of the following words is
NOT in 𝐿∗ :
1. bb
2. aaa
3. ε
Properties of Formal Languages
1. L+ = L∗ , if ε ∊ L
Example: L = {ε, aa, ab}

2. L+ = L∗ - { ε } , if ε ∉ L
3. {ε}∗ = {ε }
4. Ø∗ = {ε }
Properties of Formal Languages
(Cont.)
5. 𝐿∗ 𝐿∗ = 𝐿∗

6. 𝐿∗∗ = 𝐿∗

7. 𝐿Ø = Ø = ØL

8. 𝐿 ε = 𝐿 = ε 𝐿
Operations on Languages
Languages have been defined above as sets of
strings, and thus the usual set-theoretic
operations can be defined by them:
If L, M ⊆ ∑ ∗ , then the operations are:
1. 𝐿 ∪ 𝑀 = { 𝑤 ∈ ∑ ∗ : w ∈ 𝐿 or 𝑤 ∈ 𝑀}
2. 𝐿 ∩ 𝑀 = { 𝑤 ∈ ∑ ∗ : w ∈ 𝐿 and 𝑤 ∈ 𝑀}
3. 𝐿 − 𝑀 = { 𝑤 ∈ ∑ ∗ : w ∈ 𝐿 and 𝑤∉𝑀}
4. 𝐿 = ∑ ∗ − L
Example
Let ∑ = {a}, the following are languages over ∑:
▪ 𝐿1 = { 𝑎𝑛 : n is odd}
▪ 𝐿2 = { 𝑎𝑛 : n is even}
▪ 𝐿3 = { 𝑎𝑛 : n is prime} 𝑎29 ∊𝐿3
▪ 𝐿4 = { 𝑎𝑛 : n ≥ 0}
Note that:
𝐿1 ∪ 𝐿2 = ∑ ∗ , 𝐿3 - {aa} ⊂ 𝐿1 , 𝐿1 ∩ 𝐿2 = Ø
Concatenation of Languages
The concatenation of 2 languages 𝐿, 𝑀 ⊆ ∑ ∗ is
the set of all strings obtained by the
concatenating any string of L with any string of
M, i.e.
𝐿𝑀 = { uv :u ∈ 𝐿 and v ∊ M }
Notes
• ∅ is a language over any alphabet.
• ∑∗ is a language over any alphabet.
• {ε} is a language over any alphabet.
• ∅ ≠ {ε}
Question
• If L={ab, bb}, which of the following words is
NOT in L*:
1. abab
2. abbb
3. bbb
4. bbab
Question
• If L={ab, bb}, which of the following words is
NOT in L*:
1. abab
2. abbb
3. bbb
4. bbab
Questions
Find L in
L {a, b} = { a, baa, b, bab}
1. L = {a, ba}
2. L= {b, ab}
3. L = {ba, ε }
Questions
Find L in
L {a, b} = { a, baa, b, bab}
1. L = {a, ba}
2. L= {b, ab}
3. L = {ba, ε }
Questions
Find L in
{a , aa, ab} L = {ab, aab, abb, aa, aaa, aba}
1. L= {a, b}
2. L = {b, ab}
3. L= {ba, ε}
Questions
Find L in
{a , ab, ε} L = {b, ab, ba, aba, abb, abba}
1. L= {a, ba}
2. L = {b, ba}
3. L= {ba, ε}
Questions
• Let ∑ = {𝑥, 𝑦, 𝑧}, A = {𝑥𝑦}, B = {ε, 𝑥}
• Determine AB, BA.
Question
• Let A= {a, b}, B={1, 2, 3}
• A x B is …. ….
• |A x B| is … …
Question
• Let A= {a, b}, B={1, 2, 3}, C = {c, d}
• A x B x C = {(a, 1, c), (a, 1, d), (a, 2, c), (a, 2,
d), (a, 3, c), (a, 3, d), (b, 1, c), (b, 1, d), (b, 2,
c), (b, 2, d), (b, 3, c), (b, 3, d)}
• |A x B x C| = |A| * |B| * |C|
= 2 * 3*2
Question
• Select a correct answer:
If A = {3, 4, 6, 7} and B = {5, 7}, which of
the following is in A x B:
1. 7
2. (7, 7)
3. (5, 6)
4. {7, 7}
Question
• If ∑ = {a, b, c}, w is a string over ∑ and |www| = 18,
what is the length of w?
1. 18
2. 12
3. 6
4. 3
Question
Let M = {a, b} and N = {aa, bb}, Find MN and M x N
• MN = {aaa, abb, baa, bbb}
• M x N = {(a, aa), (a, bb), (b, aa), (b, bb)}
Question
• Q = {a, b}, A = {2, 3}
• Find Q ∪ A and Q . A
Q ∪ A = {a, b, 2, 3}
Q . A = {a2, a3, b2, b3}
Question
• Q= {a, b}, A = {2, 3}
• Find 2𝑄 𝑋 𝐴 (power set of Q x A)
Functions
• For nonempty sets A and B, a function f from a
set A to a set B, denoted by f: A → B, is an
association of each element of A with a unique
element of B.
A B
f: •



Functions (Cont.)
If A = {1, 2, 3, 4} and B = {a, b, c}, then f is a
function from A to B:
A B
1 a
f: 2 b
3 c
4
The function f can be written as:
f = {(1, c), (2, a), (3, b), (4, b)}
Functions (Cont.)
In other words, a function f is a binary relation
from A to B (any subset from A x B is a binary
relation) with the following property:
• for each a ∈ A, there is exactly one ordered
pair in f with the first component a.
Functions (Cont.)
We write b = f(a) when (a, b) ∈ f
• b is called the image of a under f
• A is called the domain of f
• B is called the codomain of f
• Range of f = { f(𝑥) : 𝑥∊ A } = f(A)

Note that: range of f is a subset of B.


In C++ Programming Langauge

int fact ( int x ) { if (x ==1) return 1;


else return x * fact (x-1);
}
domain

codomain
Example 1
Let A = {1,2,3,4} and B = {a, b, c}.
Then f = {(1, a), (2, a), (3,b ), (4, b)
is a function from A to B
Example 2
Let A = {1, 2, 3, 4} and B = {a, b, c}.
Then f = { (1, a), (2, a), (3, b), (3, c), (4, b) }
is NOT a function from A to B

There are 2 ordered pair: (3, b) and (3, c) with 3 as a first component
Example 3
Let A = {1, 2, 3, 4} and B = {a, b, c}.
Then g = { (1, a), (3, b ), (4, b) }
is NOT a function from A to B

why?
Example 4
f: Z → {0, 1} , where

0 if 𝑥 is even
f(𝑥) = ቊ
1 otherwise

is a function from Z to {0, 1}


Questions
Let X = {1, 2, 3, 4, 5} and Y = {6, 7, 8, 9, 10} and
f:X→ Y defined by:
n f(n(
1 6
2 7
3 6
4 7
5 6

1. Write the function f as a set of ordered pairs.


2. What are the domain, codomain, and range of the function f ?
Question
• Select a correct function f: {a, b, c} → {1, 2, 3}
1. f = {(a, 2), (b, 1), (c, 2)}
2. f = {(c, 2), (b, 1)}
3. f = {(a, 2), (b, 1), (c, 2), (b, 3)}
4. f = {(a, 2), (b, 1), (a, 3)}
Question
• Let Q = {p, q, r}, ∑ = {0, 1}, and f is a function
f: Q x ∑ → Q
What is the domain of this function?
Question
• Let Q = {p, q, r}, ∑ = {0, 1}, and f is a function
f: Q x ∑ → Q
What is the domain of this function?

{(p, 0), (p, 1), (q, 0), (q, 1), (r, 0), (r, 1)}
Question
• Let Q = {p, q, r} and ∑ = {0, 1}, Select a well-
defined function, f: Q x ∑ → Q:
1. f = { ((p, 0), p) , (( p, 1), q), ((p, 0), q), ((q, 1), q), ((r, 0), r),
((r, 1), r)}
2. f = { ((p, 0), p) , (( p, 1), q), ((q, 0), p), ((q, 1), q), ((q, 0), r),
((r, 1), q)}
3. f = { ((p, 0), p) , (( p, 1), p), ((q, 0), p), ((q, 1), p), ((r, 0), p),
((r, 1), p)}
Lecture Summary
• Alphabet.
• Strings and its properties.
• Formal languages and its properties.
• Operations of languages.
• Functions.

You might also like