简体   繁体   English

PDA for equal number of as and b's where n>=1

[英]PDA for equal number of as and b's where n>=1

How to design Push Down Automata for the language that has equal number of as and b's where n>=1如何为具有相等数量的 as 和 b 的语言设计下推自动机,其中 n>=1

I got how to do it for n>=O, not able to get it for n>=1我知道如何为 n>=O 做到这一点,但无法为 n>=1 做到这一点

The intersection of a context-free language and a regular language is also context-free, and this can be shown using the same Cartesian-product-machine construction used to show the intersection of two regular languages is also regular.上下文无关语言和常规语言的交集也是上下文无关的,这可以使用用于显示两种常规语言的交集的相同笛卡尔积机结构来显示,这也是规则的。 This construction gives you a way of finding the PDA for the intersection of a context-free language and a regular language, if a PDA and DFA are known.如果已知 PDA 和 DFA,此构造为您提供了一种查找上下文无关语言和常规语言交集的 PDA 的方法。

A DFA for the language of strings that are non-empty is easy: it has two states, q0 and q1, with q1 accepting and q0 not, and all transitions go to q1.非空字符串语言的 DFA 很简单:它有两个状态,q0 和 q1,其中 q1 接受而 q0 不接受,所有转换 go 到 q1。

You say you already have a PDA for the language of strings where #a(w) = #b(w);你说你已经有一个字符串语言的 PDA,其中 #a(w) = #b(w); call its states Q, its accepting states A, its initial state q*, its alphabet S, its stack alphabet Z and its transitions f: Q x S x Z -> Q x Z.称它的状态为 Q,它的接受状态 A,它的初始 state q*,它的字母表 S,它的堆栈字母表 Z 和它的转换 f:Q x S x Z -> Q x Z。

We can define a PDA that accepts the intersection of non-empty strings with the strings that have #a(w) = #b(w) as follows:我们可以定义一个 PDA,它接受非空字符串与具有 #a(w) = #b(w) 的字符串的交集,如下所示:

  1. Q' = {q0, q1} x Q Q' = {q0, q1} x Q
  2. A' = {(q1, q) | A' = {(q1, q) | q in A} A中的q}
  3. S' = S S' = S
  4. Z' = Z Z' = Z
  5. f'(q, s, z) = ((q1, q'), z') where (q', z') = f(q, s, z) f'(q, s, z) = ((q1, q'), z') 其中 (q', z') = f(q, s, z)
  6. initial state (q0, q*)初始 state (q0, q*)

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

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