简体   繁体   English

可以将任何有限状态自动机转换为正则表达式吗?

[英]Can any finite state automata be translated into a regular expression?

Let's assume that we have a fsa as follows: 假设我们有如下的fsa:

fsa = {0:{'a': 1, else: 2},1:{'b': 1, else: 2},2:{else: 2}}

This means: at state 0, if input is 'a', it goes to state 1, otherwise it goes to state 2; 这意味着:在状态0,如果输入为'a',则进入状态1,否则进入状态2;否则,进入状态2。 at state 1, if input is 'b', it goes to state 1, otherwise it goes to state 2; 在状态1,如果输入为'b',则进入状态1,否则进入状态2; at state 2, for any input, it goes to state 2. 在状态2,对于任何输入,它都会进入状态2。

Assume, state 0 is a starting state, state 1 is an accepting state and state 2 is the failure state. 假设状态0是开始状态,状态1是接受状态,状态2是失败状态。 Then this fsa can be translated as regex "ab*". 然后,可以将此fsa转换为正则表达式“ ab *”。 In fact, there are a few algorithms that translate fsa to regex, such as Brzozowski algebraic method. 实际上,有几种算法可以将fsa转换为正则表达式,例如Br​​zozowski代数方法。

My question: can any fsa defined in the above form be translated into a regex? 我的问题:以上形式中定义的任何fsa都可以翻译成正则表达式吗? Is there any limitation? 有什么限制吗?

没有限制-所有有限状态自动机都等效于某些正则表达式,并且所有正则表达式都等效于某些有限状态自动机。

Yes, they are equivalent. 是的,它们是等效的。 From the wikipedia page on regular languages , these are all equivalent definitions of regular languages. Wikipedia页面上的常规语言来看,这些都是常规语言的等效定义。

  1. it is the language of a regular expression 它是正则表达式的语言
  2. it is the language accepted by a nondeterministic finite automaton (NFA) 它是非确定性有限自动机(NFA)接受的语言
  3. it is the language accepted by a deterministic finite automaton (DFA) 它是确定性有限自动机(DFA)接受的语言
  4. it can be generated by a regular grammar 它可以由常规语法生成
  5. it is the language accepted by an alternating finite automaton 它是交替有限自动机接受的语言
  6. it can be generated by a prefix grammar 它可以由前缀语法生成
  7. it can be accepted by a read-only Turing machine 只读图灵机可以接受它
  8. it can be defined in monadic second-order logic (Büchi-Elgot-Trakhtenbrot theorem) 可以用一元二阶逻辑(Büchi-Elgot-Trakhtenbrot定理)定义它
  9. it is recognized by some finite monoid, meaning it is the preimage of a subset of a finite monoid under a homomorphism from the free monoid on its alphabet 它可以被某些有限的半定形词识别,这意味着它是有限半定形子集的子集的原像,该子集是同字母的自由半定形词同态的

Yes. 是。 A every finite automaton will have a corresponding regular expression. 每个有限的自动机都会有一个对应的正则表达式。 Kleene's theorem proves this result. 克莱因定理证明了这一结果。 The theorem is proved by using the principle of mathematical induction by partitioning the Finite Automata into the union of a number of smaller Finite Automatas. 通过将有限自动机划分为多个较小的有限自动机的并集,使用数学归纳原理证明了该定理。 The proof can be found here . 证明可以在这里找到。

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

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