Finiteness of Regular Language

前端 未结 5 1623
醉梦人生
醉梦人生 2020-12-06 09:01

We all know that (a + b)* is a regular language for containing only symbols a and b. But (a + b)* is a string of infinit

5条回答
  •  隐瞒了意图╮
    2020-12-06 09:24

    1. A regular expression describes the string generated by some language. Applying that regular expression gives you all the strings that can be described by that language.

    2. When you convert that regular expression to a finite automaton (automata with finite states) , it means that those same strings can also be generated by traversing from state-to-state on that automaton. Now, intuitively, each state here represents a group of strings belonging to that language. It says, after having "absorbed" some input, the string is now in state X.

    Example:

    If you want a regex to accept strings with even numbers of 0 , then you'll have one state (group) which indicates that even number of 0 has been observed in the input so far. And another state (group) for odd numbers --> this state would be your non-accepting state in the FA.

    As shown here, you just needed 2 (finite) states to generate an infinite number of strings, because of the grouping of odd and even we did.

    And that is why it is regular.

提交回复
热议问题