regular language
a language is called a regular language if some finite automaton recognizes it.
[cite:@sipser_comp_2012 definition 1.16]
[cite:@sipser_comp_2012 definition 1.16]
the class of regular languages is closed under the concatenation operation. given regular languages
and
, we can construct a finite automaton that recognizes
.
[cite:@sipser_comp_2012 theorem 1.26]
[cite:@sipser_comp_2012 theorem 1.47]
[cite:@sipser_comp_2012 theorem 1.26]
[cite:@sipser_comp_2012 theorem 1.47]
the class of regular languages is closed under the star operation.
[cite:@sipser_comp_2012 theorem 1.49]
[cite:@sipser_comp_2012 theorem 1.49]
the class of regular languages is closed under union.
[cite:@sipser_comp_2012 theorem 1.25]
[cite:@sipser_comp_2012 theorem 1.45]
[cite:@sipser_comp_2012 theorem 1.25]
[cite:@sipser_comp_2012 theorem 1.45]
we have regular languages
and
and want to prove that
is regular. the idea is to take two NFAs,
and
for
and
, and combine them into one new NFA,
.
machine
must accept its input if either
or
accepts this input. the new machine has a new start state that branches to the start states of the old machines with
arrows. in this way, the new machine nondeterministically guesses which of the two machines accepts the input. if one of them accepts the input,
will accept it, too.
we represent this construction in fig-reglang-1. on the left, we indicate the start and accept states of machines
and
with large circles and some additional states with small circles. on the right, we show how to combine
and
into
by adding additional transition arrows.
let
recognize
, and
recognize
.
construct
to recognize
.
machine
we represent this construction in fig-reglang-1. on the left, we indicate the start and accept states of machines
construct
-
. the states of
are all the states of
and
, with the addition of a new start state
.
- the state
is the start state of
.
- the set of accept states
. the accept states of
are all the accept states of
and
. that way,
accepts if either
accepts or
accepts.
- define
so that for any
and any
, \begin{equation} \delta(q,a) =
\end{equation}
if
is a DFA that recognizes language
, swapping the accept and nonaccept states in
yields a new DFA recognizing the complement of
. consequently, the class of regular languages is closed under complement.
[cite:@sipser_comp_2012 exercise 1.14]
[cite:@sipser_comp_2012 exercise 1.14]
the class of regular languages is closed under difference.
[cite:@lewenstein_automata]
[cite:@lewenstein_automata]
the class of regular languages is closed under intersection.
let
recognize
, where
, and
recognize
, where
.
construct
to recognize
, where
.
, which will help us:
where
, and so by induction, we can turn it into:
we need to show that
by [[blk:def-dfa-reglang][definition]], the language that
recognizes is
by eq-reglang-1, [[blk:eq-reglang-2]] and eq-reglang-3 are equivalent.
[cite:@lewenstein_automata]
construct
-
. this set is the cartesian product of sets
and
and is written
.
-
, the alphabet, is the same as in
and
. we assume for simplicity that both
and
have the same input alphabet
. the theorem remains true if they have different alphabets,
. we would then modify the proof to let
.
-
, the transition function, is defined as follows. for each
and each
, let
. hence
gets a state of
(which actually is a pair of states from
and
, together with an input symbol, and returns
next state.
-
is the pair
.
-
[cite:@sipser_comp_2012]
let
be regular languages, we denote by
the language of those words in
that have a prefix in
. prove that
is a regular language.
let
be the DFAs of
, respectively. we can construct the DFA that recognizes
as:
where
and
.
for simplicity its assumed that
are over the same alphabet, so
, the proof that
recognizes
can be done by induction.
for simplicity its assumed that
let
be a regular language, define
. describe
with words and prove
is a regular language
let
let
, prove
is a regular language.
let
be the DFAs recognizing
, i.e.
, such that
, we define
such that
. the NFA
recognizes
. this works because the words are disjoint (dont share the same letters).
regular languages are closed under reversal.
let
be a regular language, prove
is a regular language.
let
be a DFA such that
, define
such that
.
recognizes
.
the language
is irregular.
assume in contradiction that
is regular, by [[blk:lem-reglang-difference-closure]], regular languages are closed under difference, so the language
would also be regular, but this contradicts with [[blk:exa-pumping-lemma-1]], which means that our assumption that
is regular cannot be true.
let
be a regular language,
, defined by
is also a regular language.
[cite:@lewenstein_automata]
[cite:@lewenstein_automata]
let
be a DFA such that
, we construct
such that
.
the idea is: for every state in
that has a path to an accept state in
we define an accept state in
, the construction is as follows:
we need to show the correctness of the construction, i.e.
, we show this by double inclusion, for
:
such that
such that
where
. i.e. there exists
such that
where
. thus
and thus
where
(because the transitions of
are the same as those of
) and thus
. for
:
where
. because the transitions in
are similar to those in
and
,
where
such that
(by definition of
). thus there exists
such that
thus
.
the idea is: for every state in
given
are regular languages,
, defined by
is also a regular language.
[cite:@lewenstein_automata]
[cite:@lewenstein_automata]