简体   繁体   English

下推自动机和算术表达式

[英]pushdown automata and arithmetic expressions

I am trying to figure out how to do arithmetic expressions in Pushdown Automata ?(PDA) for example L=W|W=An Bm Cn-m What i am thinking of doing is to push As then pop Bs and then either pop As with C or Bs with C depending what is left. 我试图弄清楚如何在下推式自动机(PDA)中执行算术表达式,例如L = W | W = An Bm Cn-m我想做的是先推As然后弹出B,然后再弹出As C或带有C的B,具体取决于剩余的内容。 For example aaabbc (pushing aaa then popping with Bs bba and then either pop A with C or B with C depending which one is bigger. 例如aaabbc(推aaa然后用bs bba弹出,然后用C弹出A或用C弹出B,取决于哪个更大。

For a word w to be in the language, it has to have n>=m by your definition (otherwise C^(nm) is negative, and that's impossible). 对于要在语言中使用的单词w ,根据您的定义,它必须具有n>=m (否则C^(nm)为负,这是不可能的)。

So, your automaton basically needs to: 因此,您的自动机基本上需要:

  1. Push to stack when seeing 'a' 看到“ a”时推入堆叠
  2. pop from stack upon seeing 'b' 看到“ b”时从堆栈弹出
  3. pop from stack upon seeing 'c'. 看到“ c”时从堆栈弹出。

Also, some important issues: 另外,一些重要问题:

  • You need to move between different states when seeing a 'new' character. 看到“新”字符时,您需要在不同状态之间移动。
  • Your automaton should accept w=eps (empty word). 您的自动机应接受w=eps (空字)。
  • w=a^bb^n is also in the language, make sure you take care of that. w=a^bb^n也是该语言,请确保您已做好。

I hope I gave you good enough leads to solve it on your own.. 希望我能给您足够的线索,以便您自行解决。

Good luck! 祝好运!

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

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