What are regular languages?
A language is a regular language if and only if a finite state machine recognizes it. To understand this concept better, we need to understand what a finite state machine is.
Finite state machine
A finite state machine, also known as finite automata, is the simplest form of computation and has limited memory. Let’s have a look at some of the prerequisites of the finite state machine:
Symbol: Any character or element can be considered a symbol, for example,
. Alphabet: An alphabet is denoted by
(sigma) and is a collection of symbols, for example, , , and so on. String: A sequence of symbols is known as a string, for example,
, , , , and so on. Language: A set of strings is known as a language. Let’s look at the following examples:
Let us say that we have the alphabet
We have language
The possible strings for language
We have language
The possible strings for language
We have language
The possible strings for language
The languages
Powers of Σ
Let’s say that we have the alphabet
A special case where the power of
Now, let’s look at what finite state machines are.
States: A finite state machine has a finite set of states represented by the notation
. Each state represents a particular setting or arrangement of the system under modeling. There can only be one state of the machine at once.
The machine can be defined by using the following five tuples:
Transitions: Based on input events or circumstances, transitions—represented by arrows or edges—define the permitted state transitions. Transitions show how the machine changes states in response to particular inputs.
Input alphabet: A finite set of symbols or events that can cause state transitions serves as the input alphabet for the machine. The machine reads one input symbol at a time, which then responds by switching between states.
Transition function: Using the transition function,
, we can determine how the machine reacts to inputs. The following state to which the machine should transition is specified for the current state, , and input symbol, , by . The machines’s behavior is encapsulated in this function. The output is the next state to which the machine will transition. Start state: The machine starts at one state, known as the start state
. It symbolizes the system’s starting point. Accept states: Some state(s) may be designated as accept state(s) or final state(s). These states denote the completion of a particular pattern. Accept states are frequently used by finite state machines that recognize particular languages or patterns, such as regular expressions.
Output (optional): Based on the output behavior, finite state machines can be divided into two categories:
Moore machine: Only the current state can determine the output. Each state is connected to a predetermined output.
Mealy machine: The input as well as the output are dependent on one another. There may be associated output values for transitions.
Let’s take an example of a finite state machine:
Regular languages
As stated earlier, a language is said to be a regular language if and only if a finite state machine recognizes it.
So, what languages are not regular?
A language which is not recognized by a finite state machine
A language that requires memory
Why is that? This is because the memory of a finite-state machine is very limited. It only stores the current state and it cannot store or count strings. This makes such a language "not regular."
Let’s have a look at some examples:
Language:
following the rule that the first five letters ' ' should be repeated. The machine will have to keep track of the five letters that need to be repeated and store them, so this requires extra memory Language:
following the rule that the number of bs must be equal to the number of as. Let’s see if a finite-state machine can be designed for this example. The machine will have to keep track of the count of as and then will need to keep track of the count of bs to see if they are equal, so this requires extra memory.
Therefore, by counter-example, we now know what regular languages are.
Quiz yourself
Test your knowledge of the regular languages.
What is a finite state machine (FSM)?
A machine with unlimited memory.
A machine that can recognize any language.
A simple computational model with limited memory.
A machine used only for graphics rendering.
Free Resources