简体   繁体   English

pda 接受语言 L={a^nb^m | n <m}< div><div id="text_translate"><p> 我知道如何解决 m&lt;n,但我很难理解 m&gt;n 的逻辑。</p><p> 在 m&lt;n 中,我们将所有 a 压入堆栈,当我们得到 b 时,我们弹出一个 a,当输入以包含 mn a 的堆栈结束时,机器应该进入最终的 state</p><p> 我该怎么办 m&gt;n.... </p></div></m}<>

[英]pda to accept the language L={a^n b^m | n<m}

I know how to solve for m<n but I'm struggling to understand the logic for m>n.我知道如何解决 m<n,但我很难理解 m>n 的逻辑。

In m<n we push all a's in the stack and when we get b we popped out one a, when the input ends with a stack containing mn a's the machine should enter the final state在 m<n 中,我们将所有 a 压入堆栈,当我们得到 b 时,我们弹出一个 a,当输入以包含 mn a 的堆栈结束时,机器应该进入最终的 state

How can I do for m>n....我该怎么办 m>n....

The intial configuration is the same.初始配置是一样的。 But you've got two separate states for reading 'b's:但是你有两个不同的状态来读取'b':

  • State B1: I'm popping 'b's, but the stack hasn't been empty. State B1:我正在弹出“b”,但堆栈不是空的。

    • If the top of the stack is an 'a' and you read a 'b': stay in that state如果堆栈的顶部是“a”并且您读取了“b”:留在那个 state
    • If the stack is empty and you read a 'b': go to state B2如果堆栈为空并且您读取了“b”:go 到 state B2
  • State B2: I'm popping 'b's, and the stack is empty. State B2:我正在弹出'b',堆栈是空的。

    • If the top of the stack is empty and you read a 'b', stay in that state如果堆栈的顶部是空的并且您读取了“b”,请留在那个 state
    • Otherwise fail.否则失败。

You've read more b's than a's if you're in state B2.如果您在 state B2 中,您阅读的 b 比 a 多。

The strings which are generated by the given language are as follows −由给定语言生成的字符串如下 -

L={a,abb,aabbbb,aaabbbbbb,….} L={a,abb,aabbbb,aaabbbbbb,….}

Here no.这里没有。 of a's are less than no.的一个小于没有。 of b's b的

Whenever 'a' comes, push 'a', When 'b' comes then pop one 'a' from the stack each time.每当'a'到来时,压入'a',当'b'到来时,每次从堆栈中弹出一个'a'。 For further input 'b' leave like that.对于进一步的输入'b'离开这样。 Finally at the end of the string, if nothing is left in the STACK, then we can declare that language is accepted in the PDA.最后在字符串的末尾,如果堆栈中没有任何内容,那么我们可以声明该语言在 PDA 中被接受。

The PDA for the problem is as follows − Transition functions The transition functions are as follows −该问题的 PDA 如下 - 转换函数 转换函数如下 -

Step 1: δ(q0, a, Z) = (q0, aZ)第 1 步:δ(q0, a, Z) = (q0, aZ)

Step 2: δ(q0, a, a) = (q0, aa)第 2 步:δ(q0, a, a) = (q0, aa)

Step 3: δ(q0, b, a) = (q1, ε)第三步:δ(q0, b, a) = (q1, ε)

Step 4: δ(q1, b, a) = (q1, ε)第 4 步:δ(q1, b, a) = (q1, ε)

Step 5: δ(q1, b, Z) = (qf, Z)第 5 步:δ(q1, b, Z) = (qf, Z)

Explanation Step 1 − Consider input string: "abb" which satisfies the given condition.解释步骤 1 - 考虑输入字符串:满足给定条件的“abb”。

Step 2 − Scan string from left to right. Step 2 - 从左到右扫描字符串。

Step 3 − For input 'a' and STACK alphabet Z, then push 'a' into the stack.第 3 步 - 对于输入“a”和堆栈字母 Z,然后将“a”推入堆栈。

Step 4 − For input 'b' and STACK alphabet 'a', then Step 4 - 对于输入'b'和堆栈字母'a',然后

Pop one 'a' from STACK: (b,a/ε) and state will be q1.从堆栈中弹出一个“a”:(b,a/ε) 和 state 将是 q1。

Step 5 − For any no.第 5 步 - 对于任何没有。 of input 'b' and top of the stack Z and state q1, then move to final state qf.输入“b”和堆栈顶部 Z 和 state q1,然后移动到最终的 state qf。

Step 6− We reached end of the string, for input ε and STACK alphabet Z,第 6 步 - 我们到达字符串的末尾,输入 ε 和 STACK 字母 Z,

Go to final state(qf): (ε, Z/Z) Go 到最终状态(qf):(ε,Z/Z)

暂无
暂无

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

相关问题 L = {a^na^nb^m |m, n ≥ 0} 是规则语言还是不规则语言? - Is L = {a^n a^n b^m |m, n ≥ 0} a regular or irregular language? 什么是语言a ^ mb ^ n的PDA(下推式自动机),其中n &lt;m - What would be the PDA (pushdown automata) of the language a^mb^n where n<m PDA M 中的堆栈大小可以增长到最多容纳 k 个符号。 L(M) 是什么语言? - the stack size in a PDA M can grow to hold at most k symbols. What kind of language is L(M)? 为定义在 Σ = {0, 1} 上的以下语言构建 NFA。 D = {0^n 10^m10^q |n, m, q ∈ N, q ≡ nm (mod 5)} - Construct a NFA for the following language defined over Σ = {0, 1}. D = {0^n 10^m10^q |n, m, q ∈ N, q ≡ nm (mod 5)} L1 = {a ^ n b ^ n | n <4}且L2 = {a ^ n b ^ n | n <10 ^ 10 ^ 10},常规语言? - Are L1 = {a^n b^n | n < 4 } and L2 = {a^n b^n | n < 10^10^10 }, regular languages? O(n + log(m)) 可以简化吗? - Can O(n + log(m)) be simplified? 如果L = {0 ^ n 1 ^ n | n&gt; 0} L ^ c(L的补码)是否规则? - If L = {0^n 1^n | n > 0 } is L^c (complement of L) regular? 这是语法{a ^ nb ^ 2n | n&gt; = 0}是否正常? - Is this grammar {a^n b^2n | n >= 0} regular or not? 语言A = {0 ^ n 1 ^ n 0 ^ n}是否上下文无关? - Is the language A = {0^n 1^n 0^n} context free? 试图理解为什么使用 BFS 搜索网格的空间复杂度是 O(m * n),其中 m 不是。 行数,n 为否。 列数 - Trying to understand why the Space Complexity of searching through a grid using BFS is O(m * n), where m is no. of rows and n is no. of cols
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM