From b474e6596f9ab27704ae162ee03a1d7e3cd36b76 Mon Sep 17 00:00:00 2001 From: Sam Hadow Date: Thu, 11 Apr 2024 22:00:08 +0200 Subject: [PATCH] pushdown automaton part in README --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/README.md b/README.md index 69d56c9..976f2fb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,71 @@ # 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) +``` + +#### 0n1n +0n1n 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 +``` +#### 0n1n inputs + +0n1n +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) +``` + +0n1m nn1m 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) +``` +!=0n1m +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) +``` \ No newline at end of file