80 likes | 217 Vues
Regular Languages Cont’d. Reading: 3.2. What we know so far…. A language is regular iff it can be described with a finite state automata. A regular expression necessarily defines a regular language. Conjecture: Every regular language can be described using a regular expression.
E N D
Regular Languages Cont’d Reading: 3.2
What we know so far… • A language is regular iff it can be described with a finite state automata. • A regular expression necessarily defines a regular language. • Conjecture: Every regular language can be described using a regular expression
Generalized Transition Graphs • FSA’s whose transitions are labeled with regular expressions rather than symbols from the alphabet. a c* a + b
Algorithm for creating a GTG from a FSA • Create arcs such that there is only one final state and that the initial state is not a final state. • Change each transition to be a regular expression • Sequentially remove each node that is not the accept state or the initial state. • Rewrite the 2-node NFA as a regular expression
e c d q q2 q1 a b ce*b ce*d ae*d q1 q2 ae*b Removing a node
Example: Convert to GTG b a,b b a b q0 q1 q2 a
r1 r3 q1 q2 r2 Writing the final regular expression r4 Regular expression is: r = r1*r2(r4+r3r1*r2)*
Example: a+b b+ab*a Regular expression is: ab*b q1 q2