Formal Languages and Automata

Formal Languages and Automata
Artificial Intelligence & Computer Vision Lab
School of Computer Science and Engineering
Seoul National University
Course Information
Instructor
• Professor S.I. Yoo (유석인 교수)
• Office : 302-321, E-mail: [email protected]
Teaching Assistant
• Suil Son (손수일)
• Office : 302-317-1, E-mail: [email protected]
Text
• An Introduction to Formal Languages and Automata (Fourth Edition)
(by Peter Linz)
• Lecture Notes: http://ailab.snu.ac.kr/courses/am15.php
Prerequisite
• Discrete Mathematics in Computer Science
Grading Policy
• 3 Equally Weighted Exams (90%) + Class Attendance (10 %)
AI & CV Lab, SNU
Formal Languages & Automata
Schedule
1. Introduction
2. Finite Automata and Regular Grammars
2.1 Finite Automata
2.2 Regular Languages and Regular Grammars
2.3 Properties of Regular Languages
(Exam 1)
3. Pushdown Automata and Context-Free Grammars
3.1 Context-Free Languages
3.2 Simplification of Context-Free Grammars and Normal Forms
3.3 Pushdown Automata
3.4 Properties of Context-Free Languages
(Exam 2)
AI & CV Lab, SNU
Formal Languages & Automata
Schedule (cont.)
4. Turing Machines
4.1 Turing Machines
4.2 Other Models of Turing Machines
4.3 Unrestricted Grammars and Associated Languages
4.4 Limits of Algorithmic Computation
(Exam 3)
AI & CV Lab, SNU
Formal Languages & Automata
Formal Languages and Automata
Artificial Intelligence & Computer Vision Lab
School of Computer Science and Engineering
Seoul National University
1. Introduction
AI & CV Lab, SNU
Formal Languages & Automata
Automaton, Formal language, and Algorithm
• Automaton (pl. Automata): An abstract model of the computer
hardware consisting of indispensable features of a digital
computer.
• Formal language: An abstract model of general characteristics
of programming languages consisting of a set of symbols and
some rules of formation by which these symbols can be
combined into entities called sentences.
• Algorithm: A formalized concept of a mechanical computation
or the computation by mechanical means.
AI & CV Lab, SNU
6
Formal Languages & Automata
Mathematical Preliminaries and Notation
Definition:
• Set
• Relation
− R ⊆ A × B (binary relation R from A to B)
− R ⊆ A × A (binary relation R on A)
− Reflexive, irreflexive, symmetric, asymmetric, antisymmetric,
transitive
• Function
− A relation f from A to B is a function, denoted by f: A → B, if for
every x in A, there is a unique y in B such that <x, y>∈ f
− One to one (injective), onto (surjective), one to one and onto
(bijective)
AI & CV Lab, SNU
7
Formal Languages & Automata
Mathematical Preliminaries and Notation
Definition:
• Graph
− G = <N, E> where N is a set of vertices and E is a set of edges
− Directed graph / undirected graph
− A walk: a sequence of edges, a path: a walk with no edges repeated,
a simple path: a path with no vertices repeated, a cycle with base v: a
walk from one vertex v to itself, a simple cycle: a cycle with no
vertices other than the base repeated, a loop: an edge from a vertex to
itself
• Tree
− A directed graph that has no cycles, and that has one distinct node,
called the root such that there is exactly one path from the root to
every other vertex
− Leaf/ parent/ child/ level/ height/ ordered tree
AI & CV Lab, SNU
8
Formal Languages & Automata
Mathematical Preliminaries and Notation (cont.)
Proof by induction and proof by contradiction
• Induction
Basis : for some k ≥ 1, P1, P2, …, Pk are true.
Induction step : for any n ≥ k,
the truths of P1, P2, …, Pn imply the truth of Pn+1
• Contradiction
To prove P, assume that P is false and derive that a conclusion is false.
AI & CV Lab, SNU
9
Formal Languages & Automata
Basic Concepts
Definition:
• Alphabet, Σ
− a finite nonempty set of symbols
• String on Σ
− a finite sequence of symbols from Σ
ex. Σ = {a, b, c}, string : aaa, ab, bc, ca, …
− a substring (prefix and suffix of a string)
• Concatenation of two strings
− w1w2 = aaaab if w1 = aaa and w2= ab
• Reverse of a string
− if w = ab, wR = ba
AI & CV Lab, SNU
10
Formal Languages & Automata
Basic Concepts (cont.)
Definition:
• Length of a string
− the number of symbols in the string
− w = aaa, |w| = 3
• Empty string, λ
− |λ| = 0
− wλ = λw = w, and w0 = λ
• Σ+ = Σ* − {λ} where Σ is an alphabet.
• Σ* =  ∑n where Σ* is countably infinite if Σ is finite.
∞
n=0
AI & CV Lab, SNU
11
Formal Languages & Automata
Basic Concepts (cont.)
Definition:
A language is a subset of Σ* where a string in a language is called a
sentence
Definition:
A grammar is G=(V, T, S, P)
where
V = a finite set of variables,
T = a finite set of terminal symbols,
S ∈ V is a special symbol called the start variable, and
P is a finite set of productions, x→y, where
x ∈ (V ∪ T)+ and y ∈ (V ∪ T)*.
AI & CV Lab, SNU
12
Formal Languages & Automata
Basic Concepts (cont.)
Definition:
A language generated by G is L(G) such that
* w}.
L(G) = {w ∈ T*: S ⇒
If w ∈ L(G), then the sequence S⇒w1⇒w2⇒ …⇒wn⇒ w is a derivation of
the sentence w where w is said to be derived from S. Each string of S,
w1, w2,…, and w is called a sentential form of the derivation.
ex. G = ({S}, {a, b}, S, P) where P: S → aSb, S → λ
S ⇒ aSb ⇒ aaSbb ⇒ aabb
*
S ⇒ aabb
L(G) = {λ, ab, aabb, aaabbb, … } = {anbn, n ≥ 0}
Definition:
Two grammars G1 and G2 are said to be equivalent if and only if L(G1) = L(G2).
AI & CV Lab, SNU
13
Formal Languages & Automata
Basic Concepts (cont.)
Automata: Abstract model of a digital computer.
Input file, Storage device, Control unit (be in some internal state).
Configuration = Particular state of the control unit,
input file, and temporary storage.
Move = Transition of an automaton from one
configuration to the next configuration.
Input file
Control unit
storage
output file
AI & CV Lab, SNU
14
Formal Languages & Automata
Automata Classification
Structural Characteristics
1. Function of machine
• Transducer (input and output tapes)
• Accepter (no output tape)
• Generator (no input tape)
2. Presence or a absence of a storage tape
3. Number of symbols in storage tape alphabet
AI & CV Lab, SNU
15
Formal Languages & Automata
Automata Classification (cont.)
Behavioral Characteristics
1. Type of operation:
• Deterministic
• Nondeterministic
2. Motion if input tape head:
• One way (left to right)
• Two way (arbitrary motion)
3. Storage tape access restrictions:
• Last in, first out (pushdown storage)
• Arbitrary access within a region whose length is bounded
• linearly by that of its input
• Unrestricted access
AI & CV Lab, SNU
16
Formal Languages & Automata
Automata Classification (cont.)
Finite state automata
• Regular grammar − No storage tape
Pushdown automata
• Context-free grammar − One pushdown storage tape
(Nondeterministic operation)
Linear bounded automata
• Context-sensitive grammar − One linear-bounded storage tape
(Nondeterministic operation)
Turing machine
• Unrestricted grammar − One arbitrarily accessed storage tape
AI & CV Lab, SNU
17
Formal Languages & Automata