pushdown automaton part in README
This commit is contained in:
parent
3eea4b0199
commit
b474e6596f
69
README.md
69
README.md
@ -1,2 +1,71 @@
|
|||||||
# IN620
|
# IN620
|
||||||
|
|
||||||
|
## pushdown automaton
|
||||||
|
Input word = i0, I, K
|
||||||
|
+ i0 total length of input word
|
||||||
|
+ I = i1, J
|
||||||
|
* i1, size of automaton input word
|
||||||
|
* J automaton input, list of integers
|
||||||
|
+ K, list of transitions
|
||||||
|
### transition (q, a, A, w, q')
|
||||||
|
+ q : state before
|
||||||
|
+ q' : state after
|
||||||
|
* 0 : start state
|
||||||
|
* 1 : accepting state
|
||||||
|
+ a : symbol in input
|
||||||
|
* 2 : ε
|
||||||
|
+ A : symbol on stack (pop operation)
|
||||||
|
* 2 : ε (no pop)
|
||||||
|
* 3 : stack start symbol
|
||||||
|
+ w : word to push on stack
|
||||||
|
* w = u, V
|
||||||
|
u : length of V, 0 if nothing to push
|
||||||
|
V : list of integers to push (Vn, Vn-1... V0)
|
||||||
|
Leftmost element of the list will be at the top of the stack after the transition (Vn here).
|
||||||
|
|
||||||
|
output:
|
||||||
|
+ 0 : accept
|
||||||
|
+ 1 : reject
|
||||||
|
|
||||||
|
### examples :
|
||||||
|
transition (q, a, A, w, q') = (0, 3, 4, 54, 1)
|
||||||
|
```
|
||||||
|
(0, 3, 4, 2, 5, 4, 1)
|
||||||
|
```
|
||||||
|
transition (q, a, A, w, q') = (0, ε, 1, ε, 1)
|
||||||
|
```
|
||||||
|
(0, 2, 1, 2, 0, 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 0<sup>n</sup>1<sup>n</sup>
|
||||||
|
0<sup>n</sup>1<sup>n</sup> automaton:
|
||||||
|
```
|
||||||
|
(0, 0, 3, 2, 1, 3, 0) // stack empty, read 0, push 1, stay in state 0
|
||||||
|
(0, 0, 1, 2, 1, 1, 0) // stack with 1 on top, read 0, push 1, stay in state 0
|
||||||
|
(0, 1, 1, 0, 2) // stack with 1 on top, read 1, pop 1, go to state 2
|
||||||
|
(2, 1, 1, 0, 2) // stack with 1 on top, read 1, pop 1, stay in state 2
|
||||||
|
(2, 2, 3, 1, 3, 1) // stack empty in state 2, go to accepting state
|
||||||
|
```
|
||||||
|
#### 0<sup>n</sup>1<sup>n</sup> inputs
|
||||||
|
|
||||||
|
0<sup>n</sup>1<sup>n</sup>
|
||||||
|
input 000111 (output should be 0)
|
||||||
|
```
|
||||||
|
(37, 6, 0, 0, 0, 1, 1, 1, 0, 0, 3, 2, 1, 3, 0, 0, 0, 1, 2, 1, 1, 0, 0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 2, 2, 3, 1, 3, 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
0<sup>n</sup>1<sup>m</sup> n<m
|
||||||
|
input 001111 (output should be 1)
|
||||||
|
```
|
||||||
|
(37, 6, 0, 0, 1, 1, 1, 1, 0, 0, 3, 2, 1, 3, 0, 0, 0, 1, 2, 1, 1, 0, 0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 2, 2, 3, 1, 3, 1)
|
||||||
|
```
|
||||||
|
0<sup>n</sup>1<sup>m</sup> n>m
|
||||||
|
input 000011 (output should be 1)
|
||||||
|
```
|
||||||
|
(37, 6, 0, 0, 0, 0, 1, 1, 0, 0, 3, 2, 1, 3, 0, 0, 0, 1, 2, 1, 1, 0, 0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 2, 2, 3, 1, 3, 1)
|
||||||
|
```
|
||||||
|
!=0<sup>n</sup>1<sup>m</sup>
|
||||||
|
input 001011 (output should be 1)
|
||||||
|
```
|
||||||
|
(37, 6, 0, 0, 1, 0, 1, 1, 0, 0, 3, 2, 1, 3, 0, 0, 0, 1, 2, 1, 1, 0, 0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 2, 2, 3, 1, 3, 1)
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user