Turning regular expressions to NFAs
- There is a general ‘mechanical’ proecedure that converts any regular expression to an NFA such that . So every regular language is accepted by some automaton.
- There is a general ‘mechanical’ procedure that converts any NFA to a regular expression such that . So every language that is accepted by some automaton is regular. This algorithm is out of scope.
title: Regular langauges are <u>precisely those</u> languages that are accepted by finite automata.Procedure
The procedure which converts any regular expression to an NFA such that operates along the recursive description of the regular expression .
Basis Cases
-
If then .
digraph { rankdir=LR init[shape=point] node[label="" shape=doublecircle]; node[shape=circle]; init->s } -
If then .
digraph { rankdir=LR init[shape=point] node[label="" shape=doublecircle color=purple] s; node[shape=circle]; init->s } -
If then .
digraph { rankdir=LR init[shape=point] node[label="" shape=doublecircle color=purple] a; node[shape=circle color=""] s; init->s s->a [label=a] }
Assumptions for recursive cases
-
: accepts
-
: accepts
digraph { subgraph cluster0 { label="R" init[shape=point] node[label="" shape=doublecircle color=purple] a, b; node[shape=circle color=""] s, c, d; init->s } subgraph cluster1 { label="Z" init2[shape=point] node[label="" shape=doublecircle color=purple] f, g; node[shape=circle color=""] e, h, i; init2->e } }
Recursive Cases: Automaton accepting (accepted by )
digraph {
node[label=""]
init[shape=point]
init->z
z->s [label=ε]
z->e [label=ε]
subgraph cluster0 {
label="R"
node[label="" shape=doublecircle color=purple] a, b;
node[shape=circle color=""] s, c, d;
}
subgraph cluster1 {
label="Z"
node[label="" shape=doublecircle color=purple] f, g;
node[shape=circle color=""] e, h, i;
}
}Recursive Cases: Automaton accepting (accepted by )
digraph {
node[label=""]
subgraph cluster1 {
label="Z"
node[label="" shape=doublecircle color=purple] f, g;
node[shape=circle color=""] e, h, i;
}
subgraph cluster0 {
label="R"
init[shape=point]
node[shape=circle color=""] s, c, d;
init->s
a->e [label=ε];
b->e [label=ε];
}
}Recursive Cases: Automaton accepting (accepted by )
digraph {
init[shape=point];
node[label="" shape=doublecircle color=purple] w;
init->w
node[shape=circle color=""]
w->s
a->w
b->w
subgraph cluster0 {
label="R"
node[shape=circle color=""] a, b, s, c, d;
}
}