pushdown-automaton

Error Compiling an Deterministic Pushdown Automaton in C (DPDA)

守給你的承諾、 提交于 2020-01-06 05:31:06
问题 I was reading about how to implement a DPDA and found this code in the following Internet address: http://code.zhoubot.com/, This c file implements a simple pushdown automata. The automata will read in a description of their transition function and input, perform its computation on the input, and then print their output. The input format is like: e01:e0$:000111:a:ad:aeeb$:b0eb0:b10ce:c10ce:ce$de The input is separated by a semicolon “:”, first section is “input alphabet”, second is “stack

Pushdown automaton for (a^n b^n)^m c^m

浪子不回头ぞ 提交于 2020-01-06 04:46:10
问题 I'm stuck building the transition functions for this automaton. I suppose I should stack a 1 for each a and unstack it for each b The number of c's equals the number of ab pairs, so I think I should stack a 0 for each b I encounter. Thing is: how do I unstack 1s and add 0s at the same time? 回答1: Don't push a 0 onto the stack each time you encounter a b . Instead, push a 0 onto the stack each time you encounter a b and the stack is empty or the top of the stack is a 0 . So, using your

For a context free grammar, how do i convert it to an equivalent push down automaton?

痴心易碎 提交于 2019-12-23 04:15:06
问题 For a context-free grammar G over Σ = {0, 1, 2}, with start variable S: S → 0S0 | 1S1 | 2S2 | Y Y → 22 How do i turn this into an equivalent Push-Down automaton 回答1: A pushdown automaton can push symbols on top of a stack and pop them off. It can also base its transitions on the topmost stack symbol. We need to think of a mechanism that will allow us accept the right language by manipulating our stack. The language your grammar generates has the following characteristics: It has 22 in the

Checking if a string consists of balanced parenthesis

一个人想着一个人 提交于 2019-12-12 08:24:38
问题 I wrote the following program to check strings for balanced parenthesis: isBalanced xs = isBalanced' xs [] isBalanced' [] [] = True isBalanced' [] _ = False isBalanced' ('(':xs) ys = isBalanced' xs (')':ys) isBalanced' ('[':xs) ys = isBalanced' xs (']':ys) isBalanced' ('{':xs) ys = isBalanced' xs ('}':ys) isBalanced' _ [] = False isBalanced' (x:xs) (y:ys) = (x == y) && (isBalanced' xs ys) Here is some example data: positives = [ isBalanced "", isBalanced "()", isBalanced "[]", isBalanced "{}"

How does a pushdown automaton know how to read a palindrome?

孤人 提交于 2019-12-11 07:54:31
问题 For example, how does a PDA know how to read a palindrome in L = {a, b}*? PDA that accepts palindromes over {a,b}* : So, based on my drawing of the PDA: How does it know when the first half of the string is on the final terminal (letter of the alphabet), and therefore knows to go from state 0 to state 1 (and furthermore knowing to "pop" letters from the stack backwards, hence creating the palindrome)? 回答1: This is a nondeterministic pushdown automata. The answer to your question is that it

PDA to accept a language of strings containing more a's than b's

纵饮孤独 提交于 2019-12-09 06:54:34
问题 Produce a PDA to recognise the following language : the language of strings containing more a's than b's I have been struggling with this question for several days now, I seem to have hit a complete mental block. Would any one be able to provide some guidance or direction to how I can solve this problem? 回答1: Your problem of "more a's than b's" can be solved by PDA. All you have to do is: When input is a and the stack is either empty or has an a on the top, push a on the stack; pop b , if b

NPDA with exactly 2 states that might need 3 transitions to final state

孤街醉人 提交于 2019-12-08 09:10:00
问题 Let's say we want to draw the transition graph with two states of a NPDA that accepts that language L. And let's also say that this NPDA will have exactly 2 states. My thinking on this would be to do everything in the first state then use the second state as the grand finale. Like so: But I'm not sure that the lambda transitions will result in q1 or if there is a better way to do this, which there likely is a better way since I'm trying to teach this to myself. Perhaps someone can get me back

Finite automata, Pushdown automata and Turing machine examples

大兔子大兔子 提交于 2019-12-08 02:56:19
问题 I'm looking for some good source of Finite automata, pushdown automata and Turing machine tasks examples (for solving manually, by hand). I was searching around but didn't find nothing special so I'm wondering if someone's got some good examples. Thanks in advance. 回答1: Your best bet might be to get a book on the subject, such as Introduction to the Theory of Computation, Third Edition by Michael Sipser, and then work through the exercises. For a collection of problem sets on automata, along

For a context free grammar, how do i convert it to an equivalent push down automaton?

北慕城南 提交于 2019-12-07 07:55:29
For a context-free grammar G over Σ = {0, 1, 2}, with start variable S: S → 0S0 | 1S1 | 2S2 | Y Y → 22 How do i turn this into an equivalent Push-Down automaton A pushdown automaton can push symbols on top of a stack and pop them off. It can also base its transitions on the topmost stack symbol. We need to think of a mechanism that will allow us accept the right language by manipulating our stack. The language your grammar generates has the following characteristics: It has 22 in the middle It is a palindrome over {0, 1, 2} . That is, it reads the same forwards as backwards. We need to

Finite automata, Pushdown automata and Turing machine examples

拥有回忆 提交于 2019-12-06 09:33:06
I'm looking for some good source of Finite automata, pushdown automata and Turing machine tasks examples (for solving manually, by hand). I was searching around but didn't find nothing special so I'm wondering if someone's got some good examples. Thanks in advance. Your best bet might be to get a book on the subject, such as Introduction to the Theory of Computation, Third Edition by Michael Sipser, and then work through the exercises. For a collection of problem sets on automata, along with solutions, check out Stanford's introductory course in the theory of computation . Problem Sets 5, 6,