Automata and Formal Language
Quan Thanh Tho
Course Overview
An introduction to the fundamental theories and algorithms
for computing on digital computer.
–
Automation: A model producing input from
acceptable output based on self-made
decision
–
Formal Language: An abstraction of
programming language syntax.
Course Outline
Chapter 1: Introduction
Chapter 2: Finite Automata
Chapter 3: Regular Language and Regular Grammar
Chapter 4: Properties of Regular Language
Chapter 5: Context-Free Grammar
Chapter 6: Simplification of Context-Free Grammar
Chapter 7: Pushdown Automata
Reading Materials
•
Giáo trình lý thuyết automat và ngôn ngữ hình thức.
Hồ Văn Quân
•
An introduction to formal languages and automata.
Peter Linz
•
Introduction to automata theory, languages, and computation.
John Hopcroft & Jeffrey Ullman
Assessment
Assignment: 30%
Final Exam: 70%
Related Issues
Digital Circuit Design
Compiler
Programming Languages
Required Background
Set and Graph Theory
Induction and Contradiction-based Methods
Three Basic Concepts
Languages
Grammars
Automata
Languages
•
Alphabet: a finite and nonempty set of symbols
Σ = {a, b}
•
Example 1.1
•
Roman Alphabet: A,B,C, ,Z.
•
Greek Alphabet: α,β,…
Language (cont’d)
•
String: finite sequence of symbols from Σ
λ: empty string
Σ*: the set of all strings on Σ (Σ+ = Σ* − {λ})
Example 1.2:
Given Σ = {a,b} =>
Σ* = {λ, a, b, aa, ab, ba, aaa, }
w = abaaa is a string of Σ
L = {anbn | n ≥ 0} = {λ, ab, aabb, } is a set of strings of Σ
Language (cont’d)
•
Language: a subset L of Σ*
•
Sentence: a string in L
•
Example 1.3: In Example 1.2, L is a language on Σ, w is a
string of Σ but not a sentence in L
Language Concatenation
L
1
L
2
= {xy | x∈L
1
, y∈L
2
}
Ln = L L L (n times)
L0 = {λ}
Language Concatenation (cont’d)
•
Example 1.4:
L = {anbn | n ≥ 0}
L2 = {anbnambm | n ≥ 0, m ≥ 0}
Closure Operators
Star-Closure: L* = L0
∪ L1 ∪ L2
Positive-Closure: L+ = L1 ∪ L2
Grammar
Grammar for a natural language: a set of rules to construct vocabulary and
sentences
Example 1.5: A simple English grammar
<sentence> → <noun-phrase><predicate>
<noun-phrase> → <article><noun>
<predicate> → <verb>
<article> → a | the
<noun> → boy | dog
<verb> → runs | walks
Hands-on Exercise 1.1:
Find all of possible sentences of the grammar given in
Example 1.5
Formal Grammar
•
Formal grammar:
G = (V, T, S, P)
V: finite set of variables
T: finite set of terminal symbols
S∈V: start variable
P: finite set of productions
Formal Grammar (cont’d)
•
Productions: x → y, x∈(V ∪T )+, y∈(V ∪T )*
•
Example 1.6:
G = ({S}, {a, b}, S, P)
P: S → aSb
S → λ
Directly Derive
•
w = uxv derives z = uyv if x y is a production
w ⇒ z
w
1
⇒* w
n
(w
1
⇒ w
2
⇒ ⇒ w
n
| w
1
= w
n
)
w
1
⇒+ w
n
Directly Derive (cont’d)
•
Example 1.7:
Take into consideration the grammar given in
Example 1.6:
S ⇒ aSb ⇒ aaSbb
⇒ aabb
S ⇒* aabb
Generated Language
G = (V, T, S, P)
L(G) = {w∈T* | S ⇒* w}
•
Example 1.8:
Take into consideration the grammar given in
Example 1.6:
L(G) = {a
n
b
n
| n ≥ 0}
Derivation
S ⇒ w
1
⇒ w
2
⇒ ⇒ w
n
⇒ w∈L(G)
Example 1.9: The sequence of directly deriving given in
Example 1.6 is a derivation
S ⇒ aSb ⇒ aaSbb
⇒ aabb
Sequential Forms
•
S
,
w
1
,
w
2
, ,
w
n
(containing variables) with
S
⇒
w
1
⇒
w
2
⇒ ⇒
w
n
⇒
w
is a derivation
•
Example 1.10: S ⇒ aSb ⇒ aaSbb
⇒ aabb
aabb: sentence aaSbb: sentential form
Automata
“An automaton (plural: automata) is a self-operating
machine. The word is sometimes used to describe a robot,
more specifically an autonomous robot. Used colloquially, it
refers to a mindless follower.” (Wiki)
An abstract model of digital computer:
Automaton Structure
Control unit
Input file
Output
Storage