Reputation: 567
I am trying to understand how to generate a regular expression for some grammars that I suppose are kind of "Infinite". I have the following a Σ = {0,1}
I thought of the following three cases and here are the guesses that I gave.
0
and ending in 11
. The regular expression that I have is the following: 0+ [1*] [0*] 1+ 1
. However, I know that this expression won't cover all the set of the existing strings in that set.1
s. The regular expression that I have is the following: 1 1+ [0+] [1+] 1
. Same issue as the first point. 0
s and not having two consecutive 1
s. The regular expression that I have is the following: 0+ 1 0+ 1 [0+]
. Same issue as the first and second point. My question is the following: Is there a possibility to express these languages that have infinite number of strings with a finite regular expression. If yes, how exactly? Thank you.
Upvotes: 0
Views: 384
Reputation: 2383
Yes, ANY regular language can be recognized by a finite automaton, and a regular language MAY express an infinite number of matching strings. Addressing your three examples:
0 (0|1)* 1 1
(0|1)* 1 1 (0|1)*
0+ (1 0+)+ 1?
Upvotes: 3