Chapter 3
Chapter 3
Regular grammars
Automata
Finite State Automata (FSA)
Regular expressions
Minimization of DFSA
Identification of non-regular languages
Pumping Lemma for Regular languages
Example:
Let G=(N, T, P, S) be a regular grammar with
P: SaA|bB
AaA|a
BbB|b
Draw a transition diagram that represents G
Abstract machines
Characteristics
Input: input values (from an input alphabet ∑) are applied
to the machine
Output: outputs of the machine
States: at any instant, the automation can be in one of the
several states
State relation: the next state of the automation at any
instant is determined by the present state and the present
input
Output relation: output is related to either state only or to
both the input and the state
Types of automata
Final State Automata (FSA)
Deterministic FSA (DFSA)
Nondeterministic FSA (NFSA)
Push Down Automata (PDA)
Deterministic PDA (DPDA)
Nondeterministic PDA (NPDA)
Turing Machine (TM)
Definition
A DFSA is a 5-tuple M=(Q, ∑, t, qo, F)
where:
i. Q is a finite set of states
ii. ∑ is an input alphabet
iii. t is a, possibly partial, function
t: QX ∑ Q
iv. qo Є Q is the initial state
v. FC Q is a finite set of final states
Formal Language Theory 8
DFSA: cont’d
A a
B C b D
a
b
State Input Next state Check whether the following
S a A strings are accepted or not:
S b B
A a A • ab
A b C • ba
B b B • bbaba
B a C • aa
C b D • aaabbaaa
D a D
Extensions of t
t needs to be extended as:
t: Q X Σ* Q
let x ε Σ*, then
i) x = λ
ii) x = ay, a ε Σ, y ε Σ*
Then i) t(q, λ) = q
ii) t(q, x) = t(q, ay)
= t(t(q, a), y)
Eg. a) t(S, ab)
b) t(S, bbba)
c) t(S, aaa)
Extensions of t:
1. t: Q X Σ 2Q to t: 2Q X Σ 2Q by defining
t(Q’, a) = Ut(q, a), qЄQ’, Q’CQ, a Є Σ
1. t: 2Q X Σ 2Q to t: 2Q X Σ* 2Q
let x Є Σ*, then
i) x = λ t(Q’,x) = Q’
ii) x = ay, a Є Σ, y Є Σ*
t(Q’, x) = t(Q’, ay) = t(t(Q’, a), y)
Example: Evaluate the following using the NFSA in the previous
slide
a) t(S, aaa)
b) t(S, aaba)
Let M be an NFSA,
L(M) = set of strings accepted by M
= {x Є Σ* | t(qo, x) n F ≠ Ø}
i) t({A,C},abba)
ii) Let x=aab
b a
q2 q3
S
b
b
q1 q2
b
b
a
Example:
α = a*(b+c)
L(α) = L(a*(b+c))
= L(a*)L(b+c)
= L(a)*(L(b) U L(c))
= {a}*({b} U {c})
= {a}*({b,c})
Note: In the absence of parentheses, the hierarchy of operations is as
follows: iteration, concatenation, and union.
ØR = RØ = R
λ* = λ, Ø*λ
R+R = R
R*R* = R*
RR* = R*R
(R*)* = R*
λ + RR* = R* = λ + R*R
(PQ)*P = P(QP)*
a b
b b a b
b
3 4 5
a
a
a 3 5
a
1 b
b
b
a
2 4
a, b