pushdown automata - wichita state universitysinha/teaching/fall15/cs720/slide/pda1.pdf · rationale...
TRANSCRIPT
![Page 1: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/1.jpg)
Pushdown Automata
October 14, 2015
Pushdown Automata
![Page 2: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/2.jpg)
Rationale
I CFG are specification mechanisms, i.e., a CFG generates acontext-free language.
I Pushdown-automata are recognizing mechanisms, i.e., a PDArecognizes a context-free language.
I CFG are like regular expressions and PDA are like FA.
Pushdown Automata
![Page 3: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/3.jpg)
Rationale
I CFG are specification mechanisms, i.e., a CFG generates acontext-free language.
I Pushdown-automata are recognizing mechanisms, i.e., a PDArecognizes a context-free language.
I CFG are like regular expressions and PDA are like FA.
Pushdown Automata
![Page 4: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/4.jpg)
Rationale
I CFG are specification mechanisms, i.e., a CFG generates acontext-free language.
I Pushdown-automata are recognizing mechanisms, i.e., a PDArecognizes a context-free language.
I CFG are like regular expressions and PDA are like FA.
Pushdown Automata
![Page 5: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/5.jpg)
Rationale
I CFG are specification mechanisms, i.e., a CFG generates acontext-free language.
I Pushdown-automata are recognizing mechanisms, i.e., a PDArecognizes a context-free language.
I CFG are like regular expressions and PDA are like FA.
Pushdown Automata
![Page 6: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/6.jpg)
A new type of computation model
I Pushdown automata, PDA, are a new type of computationmodel
I PDAs are like NFAs but have an extra component called astack
I The stack provides additional memory beyond the finiteamount available in the control
I The stack allows PDA to recognize some nonregular languages
Pushdown Automata
![Page 7: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/7.jpg)
A new type of computation model
I Pushdown automata, PDA, are a new type of computationmodel
I PDAs are like NFAs but have an extra component called astack
I The stack provides additional memory beyond the finiteamount available in the control
I The stack allows PDA to recognize some nonregular languages
Pushdown Automata
![Page 8: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/8.jpg)
A new type of computation model
I Pushdown automata, PDA, are a new type of computationmodel
I PDAs are like NFAs but have an extra component called astack
I The stack provides additional memory beyond the finiteamount available in the control
I The stack allows PDA to recognize some nonregular languages
Pushdown Automata
![Page 9: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/9.jpg)
A new type of computation model
I Pushdown automata, PDA, are a new type of computationmodel
I PDAs are like NFAs but have an extra component called astack
I The stack provides additional memory beyond the finiteamount available in the control
I The stack allows PDA to recognize some nonregular languages
Pushdown Automata
![Page 10: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/10.jpg)
A new type of computation model
I Pushdown automata, PDA, are a new type of computationmodel
I PDAs are like NFAs but have an extra component called astack
I The stack provides additional memory beyond the finiteamount available in the control
I The stack allows PDA to recognize some nonregular languages
Pushdown Automata
![Page 11: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/11.jpg)
PDA and CFG
I PDA are equivalent in specification power with CFGI This is useful because it gives us two options for proving that
a language is context-free:
1. construct a CFG that generates the language or2. construct a PDA that recognizes the language
Pushdown Automata
![Page 12: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/12.jpg)
PDA and CFG
I PDA are equivalent in specification power with CFG
I This is useful because it gives us two options for proving thata language is context-free:
1. construct a CFG that generates the language or2. construct a PDA that recognizes the language
Pushdown Automata
![Page 13: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/13.jpg)
PDA and CFG
I PDA are equivalent in specification power with CFGI This is useful because it gives us two options for proving that
a language is context-free:
1. construct a CFG that generates the language or2. construct a PDA that recognizes the language
Pushdown Automata
![Page 14: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/14.jpg)
PDA and CFG
I PDA are equivalent in specification power with CFGI This is useful because it gives us two options for proving that
a language is context-free:
1. construct a CFG that generates the language or
2. construct a PDA that recognizes the language
Pushdown Automata
![Page 15: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/15.jpg)
PDA and CFG
I PDA are equivalent in specification power with CFGI This is useful because it gives us two options for proving that
a language is context-free:
1. construct a CFG that generates the language or2. construct a PDA that recognizes the language
Pushdown Automata
![Page 16: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/16.jpg)
Note
Some CFL are more easily described in terms of their generators,whereas others are more easily described in terms of theirrecognizers
Pushdown Automata
![Page 17: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/17.jpg)
Schematic representation of a PDA
Figure 1 contrasts the schematic representations of PDA and NFA :
Finite
Control
�rInput
a a b b
Schematic of a NFA
Finite
Control
�rInput
a a b b
-�r/wx y z . . .
Stack
Schematic of a PDA
Figure 1 : Schematic representations
Note: in Figure 1, r stands for read and w stands for write.
Pushdown Automata
![Page 18: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/18.jpg)
More on PDA informal
I A PDA can write symbols on the stack and read them backlater
I Writing a symbol “pushes down” all the other symbols on thestack
I The symbol on the top of the stack can be read and removed.
I When the top symbol is removed the remaining symbols moveup
Pushdown Automata
![Page 19: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/19.jpg)
More on PDA informal
I A PDA can write symbols on the stack and read them backlater
I Writing a symbol “pushes down” all the other symbols on thestack
I The symbol on the top of the stack can be read and removed.
I When the top symbol is removed the remaining symbols moveup
Pushdown Automata
![Page 20: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/20.jpg)
More on PDA informal
I A PDA can write symbols on the stack and read them backlater
I Writing a symbol “pushes down” all the other symbols on thestack
I The symbol on the top of the stack can be read and removed.
I When the top symbol is removed the remaining symbols moveup
Pushdown Automata
![Page 21: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/21.jpg)
More on PDA informal
I A PDA can write symbols on the stack and read them backlater
I Writing a symbol “pushes down” all the other symbols on thestack
I The symbol on the top of the stack can be read and removed.
I When the top symbol is removed the remaining symbols moveup
Pushdown Automata
![Page 22: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/22.jpg)
More on PDA informal
I A PDA can write symbols on the stack and read them backlater
I Writing a symbol “pushes down” all the other symbols on thestack
I The symbol on the top of the stack can be read and removed.
I When the top symbol is removed the remaining symbols moveup
Pushdown Automata
![Page 23: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/23.jpg)
Terminology
I Writing a symbol on the stack is referred to as pushing thesymbol
I Removing a symbol from the stack is referred to as poppingthe symbol
I All access to the stack may be done only at the top
In other words: a stack is a last-in first-out storage device
Pushdown Automata
![Page 24: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/24.jpg)
Terminology
I Writing a symbol on the stack is referred to as pushing thesymbol
I Removing a symbol from the stack is referred to as poppingthe symbol
I All access to the stack may be done only at the top
In other words: a stack is a last-in first-out storage device
Pushdown Automata
![Page 25: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/25.jpg)
Terminology
I Writing a symbol on the stack is referred to as pushing thesymbol
I Removing a symbol from the stack is referred to as poppingthe symbol
I All access to the stack may be done only at the top
In other words: a stack is a last-in first-out storage device
Pushdown Automata
![Page 26: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/26.jpg)
Terminology
I Writing a symbol on the stack is referred to as pushing thesymbol
I Removing a symbol from the stack is referred to as poppingthe symbol
I All access to the stack may be done only at the top
In other words: a stack is a last-in first-out storage device
Pushdown Automata
![Page 27: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/27.jpg)
Benefits of the stack
I A stack can hold an unlimited amount of information
I A PDA can recognize a language like {0n1n|n ≥ 0} because itcan use the stack to remember the number of 0s it has seen
Pushdown Automata
![Page 28: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/28.jpg)
Benefits of the stack
I A stack can hold an unlimited amount of information
I A PDA can recognize a language like {0n1n|n ≥ 0} because itcan use the stack to remember the number of 0s it has seen
Pushdown Automata
![Page 29: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/29.jpg)
Benefits of the stack
I A stack can hold an unlimited amount of information
I A PDA can recognize a language like {0n1n|n ≥ 0} because itcan use the stack to remember the number of 0s it has seen
Pushdown Automata
![Page 30: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/30.jpg)
PDA recognizing {0n1n|n ≥ 0}
Informal algorithm:
1. Read symbols from the input. As each 0 is read push it onto the stack
2. As soon as a 1 is read, pop a 0 off the stack for each 1 read
3. If input finishes when stack becomes empty, accept; if stack becomes emptywhile there is still input or input finishes while stack is not empty, reject
Pushdown Automata
![Page 31: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/31.jpg)
PDA recognizing {0n1n|n ≥ 0}
Informal algorithm:1. Read symbols from the input. As each 0 is read push it onto the stack
2. As soon as a 1 is read, pop a 0 off the stack for each 1 read
3. If input finishes when stack becomes empty, accept; if stack becomes emptywhile there is still input or input finishes while stack is not empty, reject
Pushdown Automata
![Page 32: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/32.jpg)
PDA recognizing {0n1n|n ≥ 0}
Informal algorithm:1. Read symbols from the input. As each 0 is read push it onto the stack
2. As soon as a 1 is read, pop a 0 off the stack for each 1 read
3. If input finishes when stack becomes empty, accept; if stack becomes emptywhile there is still input or input finishes while stack is not empty, reject
Pushdown Automata
![Page 33: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/33.jpg)
PDA recognizing {0n1n|n ≥ 0}
Informal algorithm:1. Read symbols from the input. As each 0 is read push it onto the stack
2. As soon as a 1 is read, pop a 0 off the stack for each 1 read
3. If input finishes when stack becomes empty, accept; if stack becomes emptywhile there is still input or input finishes while stack is not empty, reject
Pushdown Automata
![Page 34: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/34.jpg)
Nature of PDA
I PDA may be nondeterministic and this is a crucial featurebecause nondeterminism adds power
I Some languages, such as {0n1n|n ≥ 0} do not requirenondeterminism, but other do. Such a language is{wwR|w ∈ {0, 1}∗}
Pushdown Automata
![Page 35: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/35.jpg)
Nature of PDA
I PDA may be nondeterministic and this is a crucial featurebecause nondeterminism adds power
I Some languages, such as {0n1n|n ≥ 0} do not requirenondeterminism, but other do. Such a language is{wwR|w ∈ {0, 1}∗}
Pushdown Automata
![Page 36: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/36.jpg)
Nature of PDA
I PDA may be nondeterministic and this is a crucial featurebecause nondeterminism adds power
I Some languages, such as {0n1n|n ≥ 0} do not requirenondeterminism, but other do. Such a language is{wwR|w ∈ {0, 1}∗}
Pushdown Automata
![Page 37: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/37.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 38: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/38.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 39: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/39.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 40: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/40.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 41: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/41.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 42: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/42.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 43: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/43.jpg)
Toward PDA formalization
I Formal definition of a PDA is similar to a NFA, except the stack
I PDA my use different alphabets for input and stack, we will denote them by Σand Γ
I Nondeterminism allows PDA to make transitions on empty input. Hence we willuse Σε = Σ ∪ {ε} and Γε = Γ ∪ {ε}
I Domain of the PDA transition function is Q × Σε × Γε where Q is the set ofstates
I Since a PDA can write on the stack while performing nondeterministictransitions the range of the PDA transition function is P(Q × Γε)
In conclusion: δ : Q × Σε × Γε → P(Q × Γε)
Pushdown Automata
![Page 44: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/44.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 45: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/45.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 46: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/46.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 47: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/47.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 48: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/48.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 49: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/49.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 50: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/50.jpg)
Definition 2.8
A pushdown automaton is a 6-tuple (Q,Σ, Γ, δ, q0,F ) where Q, Σ,Γ, and F are finite sets, and:
1. Q is a set of states
2. Σ is the input alphabet
3. Γ is the stack alphabet
4. δ : Q × Σε × Γε → P(Q × Γε) is the transition function
5. q0 ∈ Q is the start state
6. F ⊆ Q is the set of accept states
Pushdown Automata
![Page 51: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/51.jpg)
PDA computation
A PDA M = (Q,Σ, Γ, δ, q0,F ) computes as follows:
I M inputs w = w1w2 . . .wm, where each wi ∈ Σε
I There are a sequence of states r0, r1, . . . , rm ∈ Q and a sequence of strings
s0, s1, . . . , sm ∈ Γ∗ that satisfy the conditions:
1. r0 = q0,s0 = ε, i.e., M starts in the start state with emptystack
2. For i = 0, 1, . . . ,m − 1 we have (ri+1, b) ∈ δ(ri ,wi+1, a) wheresi = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ∗, i.e., Mmoves properly according to the state, stack, and input symbol
3. rm ∈ F , i.e., an accept state occurs at the input end
Pushdown Automata
![Page 52: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/52.jpg)
PDA computation
A PDA M = (Q,Σ, Γ, δ, q0,F ) computes as follows:I M inputs w = w1w2 . . .wm, where each wi ∈ Σε
I There are a sequence of states r0, r1, . . . , rm ∈ Q and a sequence of strings
s0, s1, . . . , sm ∈ Γ∗ that satisfy the conditions:
1. r0 = q0,s0 = ε, i.e., M starts in the start state with emptystack
2. For i = 0, 1, . . . ,m − 1 we have (ri+1, b) ∈ δ(ri ,wi+1, a) wheresi = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ∗, i.e., Mmoves properly according to the state, stack, and input symbol
3. rm ∈ F , i.e., an accept state occurs at the input end
Pushdown Automata
![Page 53: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/53.jpg)
PDA computation
A PDA M = (Q,Σ, Γ, δ, q0,F ) computes as follows:I M inputs w = w1w2 . . .wm, where each wi ∈ Σε
I There are a sequence of states r0, r1, . . . , rm ∈ Q and a sequence of strings
s0, s1, . . . , sm ∈ Γ∗ that satisfy the conditions:
1. r0 = q0,s0 = ε, i.e., M starts in the start state with emptystack
2. For i = 0, 1, . . . ,m − 1 we have (ri+1, b) ∈ δ(ri ,wi+1, a) wheresi = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ∗, i.e., Mmoves properly according to the state, stack, and input symbol
3. rm ∈ F , i.e., an accept state occurs at the input end
Pushdown Automata
![Page 54: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/54.jpg)
PDA computation
A PDA M = (Q,Σ, Γ, δ, q0,F ) computes as follows:I M inputs w = w1w2 . . .wm, where each wi ∈ Σε
I There are a sequence of states r0, r1, . . . , rm ∈ Q and a sequence of strings
s0, s1, . . . , sm ∈ Γ∗ that satisfy the conditions:
1. r0 = q0,s0 = ε, i.e., M starts in the start state with emptystack
2. For i = 0, 1, . . . ,m − 1 we have (ri+1, b) ∈ δ(ri ,wi+1, a) wheresi = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ∗, i.e., Mmoves properly according to the state, stack, and input symbol
3. rm ∈ F , i.e., an accept state occurs at the input end
Pushdown Automata
![Page 55: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/55.jpg)
PDA computation
A PDA M = (Q,Σ, Γ, δ, q0,F ) computes as follows:I M inputs w = w1w2 . . .wm, where each wi ∈ Σε
I There are a sequence of states r0, r1, . . . , rm ∈ Q and a sequence of strings
s0, s1, . . . , sm ∈ Γ∗ that satisfy the conditions:
1. r0 = q0,s0 = ε, i.e., M starts in the start state with emptystack
2. For i = 0, 1, . . . ,m − 1 we have (ri+1, b) ∈ δ(ri ,wi+1, a) wheresi = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ∗, i.e., Mmoves properly according to the state, stack, and input symbol
3. rm ∈ F , i.e., an accept state occurs at the input end
Pushdown Automata
![Page 56: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/56.jpg)
PDA computation
A PDA M = (Q,Σ, Γ, δ, q0,F ) computes as follows:I M inputs w = w1w2 . . .wm, where each wi ∈ Σε
I There are a sequence of states r0, r1, . . . , rm ∈ Q and a sequence of strings
s0, s1, . . . , sm ∈ Γ∗ that satisfy the conditions:
1. r0 = q0,s0 = ε, i.e., M starts in the start state with emptystack
2. For i = 0, 1, . . . ,m − 1 we have (ri+1, b) ∈ δ(ri ,wi+1, a) wheresi = at and si+1 = bt for some a, b ∈ Γε and t ∈ Γ∗, i.e., Mmoves properly according to the state, stack, and input symbol
3. rm ∈ F , i.e., an accept state occurs at the input end
Pushdown Automata
![Page 57: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/57.jpg)
Example PDA
The PDA that recognizes the language {0n1n|n ≥ 0} isM1 = (Q,Σ, Γ, δ, q1,F ) where:
Q = {q1, q2, q3, q4}, Σ = {0, 1}, Γ = {0, $}, F = {q1, q4}δ is defined by the table:
Σε 0 1 εQ/Γε 0 $ ε 0 $ ε 0 $ εq1 {(q2, $)}q2 {(q2, 0)} {(q3, ε)}q3 {(q3, ε)} {(q4, ε)}q4
Notation: δ(q ∈ Q,w ∈ Σε, a ∈ Γε) = {(r ∈ Q, b ∈ Γε)} means qw,a→b−→ (r, b).
Pushdown Automata
![Page 58: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/58.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 59: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/59.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 60: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/60.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 61: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/61.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 62: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/62.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input
2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 63: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/63.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack
3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 64: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/64.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 65: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/65.jpg)
Transition diagrams of PDA
I We can use state transition diagrams to describe PDA
I Such diagrams are similar to state transition diagrams used todescribe finite automata
I To show how PDA uses the stack we write “a, b → c” tosignify that the machine:
1. is reading a from input2. may replace the symbol b on top of the stack3. with the symbol c
where any of a, b, c may be ε
Pushdown Automata
![Page 66: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/66.jpg)
Interpretation
I If a is ε, the machine makes this transaction without readingany symbol from the input
I If b is ε, the machine makes this transaction without poppingany symbol from the stack
I If c is ε, the machine makes this transaction without pushingany symbol on the stack
Pushdown Automata
![Page 67: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/67.jpg)
Transition diagram of PDA M1
Figure 2 show the state transition diagram of M1 recognizing thelanguage {0n1n|n ≥ 0}
-��������q1 -ε, ε→ $����
q2
9
0, ε→ 0
?1, 0→ ε
��������q4 �
ε, $→ ε����
q3
9
1, 0→ ε
Figure 2 : Transition diagram for PDA M1
Pushdown Automata
![Page 68: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/68.jpg)
Note 1
I The formal definition of a PDA contains no explicitmechanism for testing the empty stack
I PDA in Figure 2 test empty stack by initially placing a specialsymbol, $, on the stack
I If ever it sees $ again on the stack, it knows that the stack iseffectively empty
This is the procedure we use to test empty stack
Pushdown Automata
![Page 69: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/69.jpg)
Note 2
I The PDA has no mechanism to test explicitly the reaching ofend of the input
I The PDA in Figure 2 is able to achieve this effect because theaccept state takes effect only when the machine is at the endof the output
Thus, from now on we assume that PDA can test for end of input,and we know that we can implement it in the same manner
Pushdown Automata
![Page 70: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/70.jpg)
Example 2.10
This example provides the PDA M2 that recognizes the language{aibjck |i , j , k ≥ 0 and i = j or i = k}
Informal description:
I The PDA first reads and push a’s on the stack
I When this is done, it can match as with bs or cs
I Since machine does not know in advance whether as are matched with bs or cs,nondeterminism helps
I Using nondeterminism the machine can guess: the machine has two branches,one for each possible guess
I If either of these branches match, that branch accepts and the entire machineaccepts
Pushdown Automata
![Page 71: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/71.jpg)
Example 2.10
This example provides the PDA M2 that recognizes the language{aibjck |i , j , k ≥ 0 and i = j or i = k}
Informal description:I The PDA first reads and push a’s on the stack
I When this is done, it can match as with bs or cs
I Since machine does not know in advance whether as are matched with bs or cs,nondeterminism helps
I Using nondeterminism the machine can guess: the machine has two branches,one for each possible guess
I If either of these branches match, that branch accepts and the entire machineaccepts
Pushdown Automata
![Page 72: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/72.jpg)
Example 2.10
This example provides the PDA M2 that recognizes the language{aibjck |i , j , k ≥ 0 and i = j or i = k}
Informal description:I The PDA first reads and push a’s on the stack
I When this is done, it can match as with bs or cs
I Since machine does not know in advance whether as are matched with bs or cs,nondeterminism helps
I Using nondeterminism the machine can guess: the machine has two branches,one for each possible guess
I If either of these branches match, that branch accepts and the entire machineaccepts
Pushdown Automata
![Page 73: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/73.jpg)
Example 2.10
This example provides the PDA M2 that recognizes the language{aibjck |i , j , k ≥ 0 and i = j or i = k}
Informal description:I The PDA first reads and push a’s on the stack
I When this is done, it can match as with bs or cs
I Since machine does not know in advance whether as are matched with bs or cs,nondeterminism helps
I Using nondeterminism the machine can guess: the machine has two branches,one for each possible guess
I If either of these branches match, that branch accepts and the entire machineaccepts
Pushdown Automata
![Page 74: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/74.jpg)
Example 2.10
This example provides the PDA M2 that recognizes the language{aibjck |i , j , k ≥ 0 and i = j or i = k}
Informal description:I The PDA first reads and push a’s on the stack
I When this is done, it can match as with bs or cs
I Since machine does not know in advance whether as are matched with bs or cs,nondeterminism helps
I Using nondeterminism the machine can guess: the machine has two branches,one for each possible guess
I If either of these branches match, that branch accepts and the entire machineaccepts
Pushdown Automata
![Page 75: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/75.jpg)
Example 2.10
This example provides the PDA M2 that recognizes the language{aibjck |i , j , k ≥ 0 and i = j or i = k}
Informal description:I The PDA first reads and push a’s on the stack
I When this is done, it can match as with bs or cs
I Since machine does not know in advance whether as are matched with bs or cs,nondeterminism helps
I Using nondeterminism the machine can guess: the machine has two branches,one for each possible guess
I If either of these branches match, that branch accepts and the entire machineaccepts
Pushdown Automata
![Page 76: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/76.jpg)
M2 recognizing {aibjck |i , j , k ≥ 0 ∧ i = j ∨ i = k}
The transition diagram is in Figure 3
- jq1 -ε, ε→ $ jq2
6a, ε→ a
-ε, ε→ ε jq5
6b, ε→ ε
-ε, ε→ ε jq6
6c, a→ ε
-ε, $→ ε jhq7
����3
ε, ε→ ε
jq3
?
b, a→ ε
-ε, $→ ε jhq4
?
c, ε→ ε
Figure 3 : Transition diagram of PDA M2
Pushdown Automata
![Page 77: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/77.jpg)
Example 2.11
This example provides the PDA M3 that recognizes the language{wwR|w ∈ {0, 1}∗}.
Recall: wR means w written backwards.
Pushdown Automata
![Page 78: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/78.jpg)
Informal description
1. M3 begins by pushing the symbols that are read onto the stack
2. At each point M3 nondeterministically guesses that the middle of the input hasbeen reached
3. When middle of the word has reached the machine starts popping off the stackfor each symbol read, checking to see that what is read and what is popped offis the same symbol
4. If the symbol read from the input and popped out from the stack is the sameand the stack empties as the same time as input is finished, accept; otherwisereject
Pushdown Automata
![Page 79: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/79.jpg)
Informal description
1. M3 begins by pushing the symbols that are read onto the stack
2. At each point M3 nondeterministically guesses that the middle of the input hasbeen reached
3. When middle of the word has reached the machine starts popping off the stackfor each symbol read, checking to see that what is read and what is popped offis the same symbol
4. If the symbol read from the input and popped out from the stack is the sameand the stack empties as the same time as input is finished, accept; otherwisereject
Pushdown Automata
![Page 80: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/80.jpg)
Informal description
1. M3 begins by pushing the symbols that are read onto the stack
2. At each point M3 nondeterministically guesses that the middle of the input hasbeen reached
3. When middle of the word has reached the machine starts popping off the stackfor each symbol read, checking to see that what is read and what is popped offis the same symbol
4. If the symbol read from the input and popped out from the stack is the sameand the stack empties as the same time as input is finished, accept; otherwisereject
Pushdown Automata
![Page 81: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/81.jpg)
Informal description
1. M3 begins by pushing the symbols that are read onto the stack
2. At each point M3 nondeterministically guesses that the middle of the input hasbeen reached
3. When middle of the word has reached the machine starts popping off the stackfor each symbol read, checking to see that what is read and what is popped offis the same symbol
4. If the symbol read from the input and popped out from the stack is the sameand the stack empties as the same time as input is finished, accept; otherwisereject
Pushdown Automata
![Page 82: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/82.jpg)
Informal description
1. M3 begins by pushing the symbols that are read onto the stack
2. At each point M3 nondeterministically guesses that the middle of the input hasbeen reached
3. When middle of the word has reached the machine starts popping off the stackfor each symbol read, checking to see that what is read and what is popped offis the same symbol
4. If the symbol read from the input and popped out from the stack is the sameand the stack empties as the same time as input is finished, accept; otherwisereject
Pushdown Automata
![Page 83: Pushdown Automata - Wichita State Universitysinha/teaching/fall15/cs720/slide/pda1.pdf · Rationale I CFG are speci cation mechanisms, i.e., a CFG generates a context-free language](https://reader030.vdocuments.us/reader030/viewer/2022020416/5d213d9c88c993ea218dc08d/html5/thumbnails/83.jpg)
Transition diagram of PDA M3
Figure 4 shows the state transition diagram of M4 recognizing thelanguage {wwR|w ∈ {0, 1}}
-��������q1 -ε, ε→ $����
q2
90, ε→ 0
1, ε→ 1
?ε, ε→ ε
��������q4 �
ε, $→ ε����
q3
90, 0→ ε
1, 1→ ε
Figure 4 : Transition diagram for PDA M3
Pushdown Automata