re-nfa-220110090941
re-nfa-220110090941
Expression
The language accepted by finite automata is Regular languages.
It can be easily described by simple expressions called Regular Expressions.
It defines a string as a sequence of pattern
It involves with alphabets and operators
Regular operators:
Union – represented as (+) or
Concatenation - represented as (.)
Closure :
• Kleen (star) closure - represented as (*) in power (denotes zero or more no. of symbols)
• Positive closure - represented as (+) in power (denotes one or more no. of symbols)
Precedence of regular operators:
*, . , +
E.g.: a.b*+ a is equivalent to
(a.b*)+a
should not interpreted as
REGULAR EXPRESSION
• ε also represents a Regular Expression which means the language contains a string
that is empty.
L (ε) = {ε} where ε is zero
length string
= {a,1,1a,1aa,1aaa,….}
• (a*1a*) = {{ε,a,aa,..}.{1}. {ε,a,aa,..}} =
= {1, a1, 1a, a1a, aa1a, …}
• (a+b)* = { ε, a, b, aa, ab , bb , ba, aaa, …….}
• a*+b* = {ε,a,aa,aaa,aaaa,.,b,bb,bbb,bbbb,..}
• (a+b)*abb = {abb, aabb, babb, aaabb, ……..}
• (aa)* = {ε, aa, aaaa, aaaaaa, ……….}
• ε + AA* = ε + A*A = A*
Exercis
Write a regular expression for the language containing
es
• The set of strings over {0,1,2} that end in 3 consecutive 1’s.
• The set of strings over {0,1} that have at least one 1.
• The set of strings over {0,1} that have at most one 1.
• odd number of 1s, ∑ = {0,1}.
Exercis
Write a regular expression for the language containing
es
• The set of strings over {0,1,2} that end in 3 consecutive 1’s.
R.E = (0 + 1+2)* 111
• The set of strings over {0,1} that have at least one 1.
R.E= (0|1)* 1 (0 | 1)*
• The set of strings over {0,1} that have at most one 1.
R.E= 0* 1 0*
• odd number of 1s, ∑ = {0,1}.
R.E= 0*(10*10*)*10*
(ε,,01,0101,0101,010101,,…)1={011,01011,0101011,,….}
Exercis
es containing
Write a regular expression for the language
• String of a's and b's that start and end with a.
• String of a's and b's that the character third from the last is a.
• String of a's and b's that only contains three b.
• L = {abn x | n >= 3, x є (a + b)+}
Exercis
es containing
Write a regular expression for the language
• String of a's and b's that start and end with a.
R.E = a(a|b)*a
• String of a's and b's that the character third from the last is a.
R.E = (a|b)*a (a|b) (a|b)
• String of a's and b's that only contains three b.
R.E = a*ba*ba*ba*
eg: bbb
• L = {abn x | n >= 3, x є (a + b)+}
•
R.E = ab3b*(a + b)+
Identities of Regular
• ∅* = ε
Expressions:
∅ ≠ ∅*
• ε* = ε
• AA* = A*A=A*
• A*A* = A* A={a} then A* =((ε,a,aa,aaa,…..))*
• (A*) * = A*
• (AB)*A =A(BA)*
• (a+d)* = (a*d*)* = (a*+d*)* (a+b)* ≠ a*+b*
•C+∅ =∅ +C=C
but
but C + ε ≠ C
• ∅B = B∅ = ∅
•C+ε=ε+C Aε=εA=A (a*)a=a+