如何将正则表达式转换为有限自动机?
如何将以下正则表达式更改为有限自动机?
(abUb)(bUaaa)b*b((a*b)*Ub)*
注意:在这种情况下,U 表示并集
How would I change the following regular expression to finite automata?
(abUb)(bUaaa)b*b((a*b)*Ub)*
note: U means union in this case
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该正则表达式有五个顶级串联组件。根据可从 Kleene 定理的一部分恢复的算法,您可以为它们创建 NFA-Lambda,然后通过将一个的最终状态连接到下一个的初始状态来形成串联。
当您看到联合时,这意味着您创建了两台机器,并通过使用两个 lambda 转换创建一个新的启动状态来将它们组合起来。
Kleene 闭包涉及更多一些,但基本上是为正在重复的事情制作机器,然后通过添加新的接受开始状态和从旧的最终状态到它的循环来转换它。
基本情况是单个字母的机器,它有两种状态,初始状态和最终状态,并带有适当标记的转换。
从最简单的机器(最里面的子表达式)递归到整个事情,并根据需要进行组合。根据需要简化结果,可能会转换为最小 DFA。
There are five top-level concatenated components of this regex. According to the algorithm recoverable from a part of Kleene's theorem, you can make NFA-Lambdas for these, then form the concatenation by connecting final states of one to initial states of the next.
When you see a union, that means you make two machines and combine them by making a new start state with two lambda transitions.
Kleene closure is a little more involved, but basically make the machine for the thing being repeated, then transform it by adding a new accepting start state and a loop to it from the old final states.
The base case is the machine for a single letter, which is two states, initial and final, with the appropriately labelled transition.
Work recursively from the simplest machines (innermost subexpressions) up to the whole thing, combining as necessary. Simplify the result as much as you like, possibly converting to a minimal DFA.
有一个名为“正则表达式和有限自动机自动 Java 代码生成器”的应用程序,它可以自动生成给定正则表达式或有限自动机的 NFA、DFA(包括转换表)和 Java 代码。可以从此链接下载:www.s-solutions.info 您可以随时检查您的解决方案是否适用正确与否。
There is an application called Automatic Java Code Generator for Regular Expressions and Finite Automata, that automatically generates the NFA, DFA (including the transition table), and Java Code for a given regular expression or finite automata. It can be downloaded from this link: www.s-solutions.info You can always check if your solution is correct or not.