How to prove that a language is regular

We can prove that a language is regular by many various techniques. Several common approaches are listed below.

  • Construct a regular expression.
  • Design a finite automata.
  • Use closure properties.
  • Apply the pumping lemma.

Let’s see them in detail now.

1. Construct a regular expression

A string pattern that is recognized by a regular language is defined by a regular expression. It is proof of its regularity if we can create a regular expression that produces the required language.

Example

Let’s suppose language LL consists of all strings over the alphabet {a,b}\{a, b\} that start with an “aa” and end with a “bb”.

L={a,b}R=a(a+b)bL = \{a, b\} \\ R = a(a+b)b

According to this regular expression, the language must begin with a “aa” (aa), have zero or more instances of either “aa” or “bb((a+b))((a+b)), and conclude with a “bb” (bb).

2. Design a finite automata

Another method to demonstrate regularity is to build a finite automaton, such as a deterministic finite automaton (DFA) or a nondeterministic finite automata (NFA). It gives proof that the language is regular if we can show the automaton can recognize the relevant language.

Example

Let’s suppose language LL consists of all strings over the alphabet {a,b}\{a, b\} that start with an “aa” and end with a “bb”.

L={a,b}L = \{a, b\}

Here is a simple deterministic finite automaton (DFA) for the language LL.

DFA for language L
DFA for language L

There are three states for the automaton: q0q0, q1q1, and q2q2. When input “aa” is given, the starting state, q0q0, changes to q1q1. At state q1q1 if we read “aa” we will still be at q1q1, but if we read “bb” we will move to the final state q2q2. At state q2q2 if we read “bb” we will still be at q2q2, but if we read “aa” we will loop back to q1q1.

3. Use closure properties

Regular languages are closed under specific operations, and therefore when applied to regular languages, these operations still produce regular languages.

Example

Let’s assume that we have two regular languages, L1={a}L1=\{a\} and L2={b}L2=\{b\}, respectively. Since L1L1 and L2L2 only have one character per word, they are both regular languages. Now that we have the language L=L1.L2,L = L1.L2, which represents strings that start with an “aa” and end with a “bb”. Since the concatenation of regular languages results in a regular language, LL is also regular.

4. Apply the pumping lemma

The pumping lemma for regular languages is a useful tool for proving that a language is not regular. It may also be used to demonstrate that a language is regular by proving that it meets the pumping lemma requirements. If the pumping lemma is correctly applied and its conditions are met, it provides evidence that the language is regular.

If you want to see how the pumping lemma works you can refer to the following link.

Copyright ©2024 Educative, Inc. All rights reserved