Notation To Specify A Language: Theory of Computation - Regular Expressions
Notation To Specify A Language: Theory of Computation - Regular Expressions
Notation To Specify A Language: Theory of Computation - Regular Expressions
Expressions
Notation to specify a language
Declarative
S
Start
1 1
Start 3 1 2
0
DFA RE Example
(Eliminate
2) State 1:
0 0+1
1 1
Start 3 1 2
0+10 0+1
11
Start 3 2
Answer: (0+10)*11(0+1)*
Convert ing a RE t o
an Automata
We have shown we can convert an automata to
aRE. To show equivalence we must also go
the other direction, convert a RE to an
automaton.
We can do this easiest by converting a RE to
an NFA
Inductive construction
Startwith a simple basis, use that to build
more complex parts of the NFA
RE t o
NFA:
Basi
s: R=a
a
R=ε ε
R=Ø
ε S ε
R=S+T
ε ε
T
R=ST ε
S T
ε ε
R=S*
S
ε
RE t o NFA
Example
Convert R= (ab+a)* to an NFA
We proceed in stages, starting from simple elements
and working our way up
a
a
b
b
a ε b
ab
RE to NFA Example
( 2):
ab+a
a ε b
ε ε
a
ε ε
(ab+a)*
a ε b
ε ε
ε ε
a
ε ε
ε
Algebraic Laws f or
RE’
Justslike we have an algebra for arithmetic, we
also have an algebra for regular expressions.
While there are some similarities to arithmetic
algebra, it is a bit different with regular
expressions.
Algebra for RE’s:
Commutative law for union:
L + M= M+ L
Associative law for union:
( L + M) + N = L + (M + N)
Associative law for concatenation:
(LM)N = L(MN)
Note that there is no commutative law for
concatenation, i.e. LM ML
Algebra f or RE’ s
(2L):+ Ø = Ø + L = L
T h e identity for union is:
The identity for concatenation is:
L ε = εL = L
T h e annihilator for concatenation
is:
Ø L = LØ = Ø
Left distributive law:
L(M + N) = LM + LN
Right distributive law:
( M + N)L = LM + LN
Idempotent law:
L + L= L
Laws Involving Closure:
(L*)* = L*
i . e . closing an already closed expression does
not change the language
Ø* =ε
ε* =
ε
= LL* =
L * L*L
= L ++
L+
ε
End of
23
Slides