Sei sulla pagina 1di 17

Deterministic PDAs Closure properties of DCFLs Complementing DPDAs

Deterministic PDAs
Deepak DSouza
Department of Computer Science and Automation
Indian Institute of Science, Bangalore.
21 October 2011
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Outline
1
Deterministic PDAs
2
Closure properties of DCFLs
3
Complementing DPDAs
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Deterministic PDAs
a a b a b a a b

X
X
Y
X
q
b a
A PDA with restrictions that:
At most one move possible in any conguration.
For any state p, a A, and X : at most one move of the
form (p, a, X) (q, ) or (p, , X) (q, ).
Effectively, a DPDA must see the current state, and top of
stack, and decide whether to make an -move or read input
and move.
Accepts by nal state.
We need a right-end marker for the input.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Example DPDA
Example DPDA for {a
n
b
n
| n 0}
(s, a, ) (p, A)
(p, a, A) (p, AA)
(p, b, A) (q, )
(q, b, A) (q, )
(q, , ) (t , )
(s, , ) (t , ).
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Closure Properties of DCFLs
DCFL
CFL
All languages over A
Regular
a
n
b
n
a
n
b
n
c
n
a
n
b
n
c
n
Closed?
Complementation

Union X
Intersection X
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Closure Properties of DCFLs
DCFL
CFL
All languages over A
Regular
a
n
b
n
a
n
b
n
c
n
a
n
b
n
c
n
Closed?
Complementation

Union
X
Intersection X
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Closure Properties of DCFLs
DCFL
CFL
All languages over A
Regular
a
n
b
n
a
n
b
n
c
n
a
n
b
n
c
n
Closed?
Complementation

Union X
Intersection
X
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Closure Properties of DCFLs
DCFL
CFL
All languages over A
Regular
a
n
b
n
a
n
b
n
c
n
a
n
b
n
c
n
Closed?
Complementation

Union X
Intersection X
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
DCFLs are closed under complementation
Theorem (Closure under complementation)
The class of languages denable by Deterministic Pushdown
Automata (i.e. DCFLs) is closed under complementation.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Problem with complementing a DPDA
Try ipping nal and non-nal states: Problems?

Loops denote an innite sequence of -moves.


Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Desirable form of DPDA

Now we can make r

unique accepting state, to accept


complement of M.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Construction - Step 1
Let M = (Q, A, , s, , , F) be given DPDA. First construct DPDA
M

which
Does not get stuck due to no transition or stack empty.
Has only sink nal states.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Construction - Step 1
Dene M

= (Q Q

{s
1
, r, r

}, A, {}, s
1
,

, , F

) where
Q

= {q

| q Q} and F

= {f

| f F}.

is obtained from as follows:


Assume M is complete (does not get stuck due to no
transition). (If not, add a dead state and add transitions to it.)
Make sure M

never empties its stack, keep track of whether


we have seen end of input (primed states) or not (unprimed
states):
(s
1
, , ) (s, )
(p, , ) (r, ) (p Q)
(p

, , ) (r

, ) (p

)
(p, , X) (q

, ) if (p, , X) (q, ) .
(p

, , X) (q

, ) if (p, , X) (q, ) .
(r, a, X) (r, X)
(r, , X) (r

, X)
(r

, , X) (r

, X)
(f

, , X) (f

, X) (f F) Also drop trans. going from f

.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
After Step 1
DPDA M

only has the following kinds of behaviours now:

Loops denote an innite sequence of -moves.


Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Construction - Step 2
A spurious transition in M

is a transition of the form


(p, , X) (q, ) such that
(p, , X)

(p, , X)
for some stack contents .
p
X
p
X

Identify spurious transitions in M

and remove them:


If (p, , X) (q, ) is a spurious transition, replace it with
(p, , X) (r, X) If p Q
(p, , X) (r

, X) If p Q

.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Correctness
Argue that:
Deleting a spurious transition (starting from a non-F

-nal
state) does not change the language of M

.
All innite loops use a spurious transition.
Look at graph of stack height along innite loop, and argue that
there are innitely many future minimas.
Further look at transitions applied at these points and observe
that one must repeat.
Thus replacing spurious transitions as described earlier will
remove the remaining undesirable loops from M

s behaviours.
Deterministic PDAs Closure properties of DCFLs Complementing DPDAs
Complementing
Resulting M

has the desired behaviour (every run either


reaches a nal sink state or the reject sink state r

.).

Now make r

unique nal state to complement the language


of M.

Potrebbero piacerti anche