简体   繁体   English

为 L={a^mb^n 其中 n<=m<=2n} 构造一个下推自动机?

[英]construct a pushdown automata for L={a^mb^n where n<=m<=2n}?

I was looking to understand the construction of pushdown automata for L={a^nb^m where n<=m<=2n} ?我想了解L={a^nb^m where n<=m<=2n}的下推自动机的构造? I found this question on stack over itself.我在堆栈上发现了这个问题。

here is what the answer said which I understood:这是我理解的答案所说的:

Here's the strategy: we can easily make a PDA that accepts a^nb^n, and we can easily make one that accepts a^nb^2n.策略如下:我们可以很容易地制作一个接受 a^nb^n 的 PDA,我们也可以很容易地制作一个接受 a^nb^2n 的 PDA。 Our language is a superset of these languages that also accepts anything with a number of b in between n and 2n.我们的语言是这些语言的超集,它也接受 n 到 2n 之间的任何 b 数。 We can make use of nondeterminism to allow this as follows: for every a we put onto the stack, we can nondeterministically decide whether to consume one or two b before popping the a.我们可以利用非确定性来实现这一点,如下所示:对于我们放入堆栈的每个 a,我们可以在弹出 a 之前不确定地决定是消耗一个还是两个 b。 If our NPDA chooses to consume one each time, we get a^nb^n.如果我们的 NPDA 选择每次消耗一个,我们得到 a^nb^n。 If it choose to consume two each time, we get a^nb^2n.如果它选择每次消耗两个,我们得到 a^nb^2n。 If it chooses some of both, we get a number of b in between these extremes.如果它选择两者中的一些,我们会在这些极端之间得到一些 b。 We only accept when we exhaust the input with an empty stack.只有当我们用空堆栈耗尽输入时,我们才会接受。

Now, I changed the question a little bit(interchanged the powers of a and b).现在,我稍微改变了问题(交换了 a 和 b 的幂)。 The language is now L={a^mb^n where n<=m<=2n} ?语言现在是L={a^mb^n where n<=m<=2n} How would this strategy change now if the powers are interchanged?如果权力互换,这种策略现在将如何变化?

We can make use of nondeterminism to allow this as follows: for every a we put onto the stack, we can nondeterministically decide whether to consume one or two b before popping the a.我们可以利用非确定性来实现这一点,如下所示:对于我们放入堆栈的每个 a,我们可以在弹出 a 之前不确定地决定是消耗一个还是两个 b。

Just exchange a 's and b 's in this sentence and you should have your answer.只需在这句话中交换ab ,您就应该得到答案。

Hint: instead of putting a 's on the stack, you put b 's, and then "consume" one or two a 's before popping.提示:不是将a放入堆栈,而是放入b ,然后在弹出之前“消耗”一两个a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM