简体   繁体   English

L = {a^nb^m : m ≥ n, mn 为偶数的 PDA

[英]PDA for L = {a^nb^m : m ≥ n, m-n is even}

Design a PDA for the following language为以下语言设计一个 PDA

L = {a^nb^m : m ≥ n, mn is even}. L = {a^nb^m : m ≥ n, mn 是偶数}。

Let's start with a PDA for a^nb^m where m >= n.让我们从 a^nb^m 的 PDA 开始,其中 m >= n。 A PDA can push an a to the stack for every a it sees, pop ab for every b it sees, and if it runs out of b while there are still a on the stack, it rejects. PDA 可以针对它看到的每个 a 将 a 压入堆栈,针对它看到的每个 b 弹出 a b,如果 b 用完而堆栈中仍有 a,它就会拒绝。

Now, what else do we need to do to exclude the case where m - n is odd?现在,我们还需要做什么来排除 m - n 是奇数的情况? Well, m - n is odd means we have some b left over in the input.好吧,m - n 是奇数意味着我们在输入中还剩下一些 b。 We can simply modify our accepting state so that on further b, it moves to a new state (encoding odd b) and then back to the accepting state on the next b, encoding the requirement that the residual b must be even.我们可以简单地修改我们的接受状态,以便在进一步的 b 上,它移动到一个新状态(编码奇数 b),然后在下一个 b 上返回到接受状态,编码残差 b 必须是偶数的要求。

A full PDA might look like this:完整的 PDA 可能如下所示:

q    s    S    q'    S'
q0   a    Z    q0    aZ
q0   a    ax   q0    aax
q0   b    Zx   q2    Z
q0   b    ax   q1    x
q1   b    ax   q1    x
q1   b    Z    q2    Z
q2   b    Z    q1    Z

Check that to see if it works, there might be some bugs.检查它是否有效,可能有一些错误。 The way to read this is:阅读本文的方法是:

From state q, on input s, with stack configuration S, the PDA can transition to state q' and update the stack configuration to S'.从状态 q,在输入 s 上,使用堆栈配置 S,PDA 可以转换到状态 q'并将堆栈配置更新为 S'。

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

相关问题 正则表达式 L(r) = {a^nb^m : n + m 是偶数}, r =? - REGEX L(r) = {a^n b^m : n + m is even}, r =? PDA {a^nb^m | n&lt;=m&lt;=2n} - PDA for {a^n b^m | n<=m<=2n} 如何构造 L={a^nb^m where n&lt;=m&lt;=2n} 的下推自动机? - How to construct a pushdown automata for L={a^nb^m where n<=m<=2n}? 关于 L = {a^nb^(2n) | PDA 的说明 n&gt;=1} - Clarification regarding PDA for L = {a^nb^(2n) | n>=1} 语言图灵机 L={a^mb^na^mb^n ∣ m,n≥0} - Turing machine for language L={a^m b^n a^m b^n ∣ m,n≥0} L = {a^nb^m | n,m&gt;=1, n?= 3m} 不规则? - How L = {a^n b^m | n,m>=1, n != 3m} is not regular? L = {a ^ nb ^ nc ^ md ^ m:n&gt; = 1,m&gt; = 1} U {a ^ nb ^ mc ^ md ^ n:n&gt; = 1,m&gt; = 1} isRegular? - L = { a^n b^n c^m d^m : n >= 1, m >= 1 } U { a^n b^m c^m d^n : n >= 1, m >= 1 } isRegular? 构造一个生成L = {a ^ pb ^ mc ^ n | n&gt; = 0,m&gt; = 0,p = m + n}的语法 - Construct a grammar that generates L = {a^p b^m c^n|n>=0, m>=0, p=m+n} 什么是语言a ^ mb ^ n的PDA(下推式自动机),其中n &lt;m - What would be the PDA (pushdown automata) of the language a^mb^n where n<m 为 L={a^mb^n 其中 n&lt;=m&lt;=2n} 构造一个下推自动机? - construct a pushdown automata for L={a^mb^n where n<=m<=2n}?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM