PDA example

advertisement
Top-Down PDA
Sequence of steps to which string
X= [][[][]] has to be accepted by NPDA
NT(G)
Grammar has productions sīƒ [S]S|^
We compare the moves made by NT(G) in accepting this string be leftmost
derivation of this string.
S=> [S]S =>[ ] S
=> [ ][S]S
=> [ ][ [S] S ] S
=>[ ] [[ ] S] S
=> [ ] [ [ ] [S] S] S
īƒž [ ] [ [ ] [ ] S] S
īƒž[][[][]]S
=> [ ] [ [ ] [ ] ]
Transition table for Top Down PDA NT(G)
Move#
State
Input
Stack symbol
Move
1
q0
^
Z0
(q1, SZ0)
2
q1
^
S
(q1, [S]S),
(q1, ^)
3
q1
[
[
(q1, ^)
4
q1
]
]
(q1, ^)
5
q2
^
Z0
(q2, Z0)
To the right of the each move that replace a variable on stack , we show the
corresponding step in the left most derivation.
(q0, [ ] [ [ ] [ ] ] , Z0 ) Steps are derived by using the moves in transition table
|- (q1, [ ] [ [ ][ ] ], SZ0) S
|- (q1, [ ] [ [ ] [ ] ] , [S]SZ0)
=> [S]S
|- (q1, ] [ [ ] [ ] ], S]SZ0)
|- (q1 , ] [ [ ] [ ] ], ]SZ0)
|- (q1 , [ [ ] [ ] ], SZ0)
|- (q1 , [ [ ] [ ] ], [S]SZ0) =>[ ] [S]S
|- (q1 , [ ] [ ] ], S]SZ0)
|- (q1, , [ ] [ ] ], [S] S]SZ0)
=>[ ] [ [S]S]S
|- (q1 , ] [ ] ], S] S]SZ0)
|- (q1 , ] [ ] ], ] S]SZ0)
|- (q1 , [ ] ], S]SZ0)
|- (q1 , [ ] ], [S]S]SZ0) => [ ] [ [ ] [S]S]S
|- (q1 , ] ], S]S]SZ0)
|- (q1 , ] ], ]S]SZ0)
|- (q1 , ], S]SZ0)
|- (q1 , ], ]SZ0)
|- (q1 , ^ , SZ0)
|- (q1 , ^, Z0)
=>[][[] []]
|- (q2, ^ , Z0)
These are the sequence of steps that
string x to be accepted
Thank you
Download