Escolar Documentos
Profissional Documentos
Cultura Documentos
Properties of Deterministic
Context-free Languages
1
Properties of DCFL's
1. A CFL that cannot be recognized by a DPDA
Let LCFL and LDCFL be, respectively, the classes of CFL’s and DCFL’s. The theorem
below shows that LDCFL ⊂ LCFL . In other words, it says that there is a CFL that cannot
be recognized by a DPDA, but by an NPDA. (Recall that, in contrast, every language
recognized by an NFA can also be recognized by a DFA.) This theorem can be
proved in two ways, which are both interesting.
2
Normal Form of PDA Properties of DCFL’s
We need the following lemma for the constructive proof of Theorem 1. This lemma,
which simplifies the PDA model, will also be used for the proof of Theorem 2.
Lemma 1 (Normal form of PDA). Every CFL can be recognized by a PDA which
satisfies the following conditions.
(1) The PDA never empties the stack (i.e., it does not pop Z0 ),
(2) when pushes, the machine pushes exactly one symbol, and
(3) never changes the stack-top.
3
Normal Form of PDA Properties of DCFL’s
Suppose that a PDA M does not satisfy condition (1) and has a move which pops
the bottom of the stack symbol Z0 as shown in figure (a) below. Since, with the stack
empty, the PDA cannot have any move, we can simply let it push a new stack
symbol, say X0 , on top of Z0 instead of popping it as shown in figure (b). This
modified PDA M’ recognizes the same language.
(. , Z0 /ε ) (. , z0 / X0Z0 )
start start
(. , Z0 (. , z0 / X0Z0 )
/ε )
4
Normal Form of PDA Properties of DCFL's
Now, suppose that PDA M satisfies conditions (1) and (2), except for condition (3).
We convert M to M’ such that M’ keeps the stack-top symbol of M in its finite state
control and simulates M as illustrated in the following figure. Notice that when the
stack of M is empty, M’ keeps a copy of Z0 in its finite state control. PDA M’ never
rewrites its stack top and recognizes the same language. (By keeping the stack top in
the finite state control, we are increasing the number of states of the PDA.)
(a) M A
Z0 Z0 A .. BA .. BC .. BDA N
I
(b) M' Z0 A A C A
Z0 Z0 .. B .. B .. BD
5
Properties of DCFL's
Proof of Theorem 1
x x z
[qx, Ax] qx t
Z0 Ax Z0 Ax
6
Properties of DCFL's
Proof of Theorem 1
Since M is a DPDA, for a given string x, there exists a unique pair [qx, Ax]. For the
proof of the theorem, we will first show that if M recognizes the palindrome language
L, there are two different strings x and y for which [qx, Ax] = [qy, Ay]. For such
strings x and y, we can easily find a string z such that xz ∈ L and yz ∉ L.
Let’s examine what will happen for M with input strings xz and yz. When the
machine reads up to x and y, it enters in the same state (i.e., qx = qy ) with the same
stack-top (i.e., Ax= Ay ), and never pops it while reading the remaining part z of the
input. It follows that M should either accept both xz and yz or both not. We are in a
contradiction because M is a DPDA.
x x z
[qx, Ax] qx t
Z0 Ax Z0 Ax
7
Proof of Theorem 1 Properties of DCFL's
For an arbitrary input string u ∈ {a, b}+, let α u be the content of the stack when M
has read up to the last symbol of string u (figure (a)). Let v ∈{a, b}* be a string such
that given uv as an input, the machine reduces α u to its minimum (α uv in figure (b))
by the time when M reads the last symbol of string uv.
u u v
quv
α u α uv
Z0 Z0
(a) (b)
u u v
quv
α u α uv
Z0 Z0
(a) (b)
Let [quv , Auv ] be the pair of state and the stack-top symbol (of α uv ) when M reads the last
symbol of the input string uv as figure (b) above illustrates, and define the following sets
S and T.
S = { [quv , Auv ] | u ∈ {a, b}+, and v ∈{a, b}* that gives the shortest |α uv |}
T = { uv | u ∈ {a, b}+, and v ∈{a, b}* that gives the shortest |α uv | }
Since the number of states of M and the size of the stack alphabet is finite, so is the set
S. However, T is infinite, because it contains uv for every string u ∈ {a, b}+. Clearly, for
every string x ∈ T there exists a pair [qx, Ax] ∈ S. It follows that for two distinct strings
x, y ∈ T, there must be one pair [qx, Ax] = [qy, Ay] in S.
9
Properties of DCFL's
Proof of Theorem 1
Now, with the two strings x, y ∈ T for which [qx, Ax] = [qy, Ay], we find a string z
such that xz ∈ L and yz ∉L as follows.
(1) If |x| = |y|, we let z = xR. Then clearly, xz = xxR ∈ L and yz = yxR ∉ L.
(2) If |x| ≠ |y|, we construct z as follows: Suppose that |x| < |y|. (The same logic
applies when it is assumed the other way.) Let y1 be the prefix of y such that |y1| = |x|,
and let y = y1y2. Find a string w such that |w| = |y2| and w ≠ y2 and construct string z
= wwRxR . Clearly, xz = xwwRxR ∈ L and yz = y1y2wwRxR ∉ L. (Notice that because
of the three conditions |y1| = |x|, |w| = |y2| and w ≠ y2 , string yz does not have the
palindrome property of L.)
Now, let’s examine what will happen with the DPDA M for two input strings xz
and yz. We know that for the two input strings, [qx, Ax] = [qy, Ay], which implies that
M must either accept both xz and yz, or both not, because the DPDA is computing
with the same input z starting with the same state qx ( = qy) and the same stack top Ax
( = Ay). This contradicts the supposition that M is a DPDA. It follows that L is not a
CFL recognizable by a DPDA.
10
Properties of DCFL's
2. Properties of DCFL's
11
Properties of DCFL's
Proof
A
M' M
12
Properties of DCFL's
Proof
13
Properties of DCFL's
Proof
Let’s see what will happen, if we convert the accepting state to non-accepting
state, and vice versa as shown below (figure (b)). Still the machine accepts the input,
because it enters an accepting state after reading the last symbol a. To solve this
problem, we will use a simulation technique.
(a)
(b)
14
Properties of DCFL's
Proof
We construct a DPDA M' which simulates M to recognizes the complement of L(M)
as follows. M' keeps the transition function of M in its finite state control and uses its
own stack for M. The simulation is carried out in two cases (a) and (b), depending on
whether M enters an accepting state between two moves of reading the input.
(a) If M, after reading an input symbol (a in the figure), does not enter an accepting
state till it reads the next input symbol (b in the figure), M' reads the input a and enters
an accepting state, and then simulates M reading the next input symbol b. (The ε -
transitions in between are ignored.) Notice that, M' is simulating M to recognize the
complement of L(M). If the symbol a that M reads is the last one from input string x, it
will not be accepted by M. So, to have this input string x accepted by M', we let it enter
an accepting state right after reading the symbol a.
(b) If M ever enters an accepting state in between two reading moves (i.e., non- ε -
transitions), M' simulates the two reading moves of M without entering an accepting
state.
(ε , ./..) (ε , ./..) (ε , ./..) (b, ./..)
p q
(a, ./..)
15
Properties of DCFL's
Proof
16
Properties of DCFL's
Proof
(c, b/ε )
(c, Z0/Z0)
(b) DPDA accepting
(a) DPDA accepting L2 = {aibkck | i, k ≥ 1 }
L1 = {aibick | i, k ≥ 1 }
a b c
a b c
3. Making every DPDA and DFA read up to the last input symbol
In this section we shall prove the following lemma which we have deferred while
proving Theorem 2.
Lemma 2. Every DCFL and regular language can be recognized, respectively, by a
DPDA and a DFA which read up to the last input symbol.
Proof. According to the convention, when we define the transition function (or the
transition graph) of an automaton, we may not define it for every possible tape symbol
(and the stack-top for a PDA). We assume that entering a state from which no transition
defined, the automaton rejects the input immediately without reading the input further).
To make a DFA read up to the last input symbol, we explicitly introduce a dead state
and let the machine enter it for every undefined transition. Then we let it read off all the
remaining input symbols in the dead state as the following example shows. (See also
Section 9.1.)
a b
A
start a N
b d a, b I
a, b
18
Making DPDA read the last input symbol Properties of DCFL's
Let M = (Q, ∑, Γ , δ , q0, Z0, F) be a DPDA. Recall that for every p ∈Q, a ∈ ∑
and A ∈ Γ , both δ (p, a, A) and δ (p, ε , A) give at most one value and if δ (p, a,
A) is defined δ (p, ε , A) is not defined, and vice versa.
The problem of making M read up to the last input symbol is not that simple. The
automata may hit an undefined transition as for DFA’s or end up in a cycle of ε -
moves in the middle of the computation without consuming the input. For the case of
undefined transitions, we can use the same approach as for DFA’s. Here is an
example. (Notice that this DPDA accepts the language {aibi | i ≥ 1}.)
( a, A/AA ) ( b, A/ε )
(a, Z0 /AZ0) ( b, A/ε ) (ε , Z0 /Z0) A
1 2 ∑ = {a, b}
3 4 N
start Γ = {A,
( a, A /A ) Z0} I
(b, Z0 /Z0) (X, Z0 /Z0) X ∈ {a, b}
d
Y ∈ {A, Z0}
(X, Y/Y )
19
Properties of DCFL's
Making DPDA read the last input symbol
(ε , (ε , D/ED)
(a, Z0/AZ0)
1 A/CA) 2
(ε , E/ ε ),
(ε , B/ε )
(ε , C/ ε )
(ε , B/B)
4 3
(ε , D/ ε )
(b, A/BA) (ε , A/BA)
20
Properties of DCFL's
Making DPDA read the last input symbol
Since the graph is finite and the transitions are deterministic, we can effectively
identify every entering transition which remains in the cycle, detach it from the
cycle and let it enter the dead state, where the remaining input is consumed. If the
cycle involves an accepting state, we let the transition enter an accepting state
before sending it to the dead state.
(ε , (ε , D/ED)
(a, Z0/AZ0)
X∈ 1 A/CA) 2
Σ
Y∈ (ε , E/ ε ),
Γ (X, Y/Y ) (ε , B/ε )
d (ε , C/ ε )
(ε , B/B) 4 3
(ε , D/ ε )
(b, A/BA) (ε , A/BA)
21
Properties of DCFL's
Making DPDA read the last input symbol
For more detailed approach to the conversion, refer J. Hopcroft and J. Ullman,
“Introduction to Automata Theory, Languages and Computation, Section 10.2,”
Addison Wesley, 1979, or M. Harrison, “Introduction to Formal Language
Theory, Section 5.6,” Addison Wesley, 1978.
22