Finite Automata

Part II. Finite Automata

Different classes of automata exist; examples include finite automata and pushdown automata. Of these, the finite automaton is the simplest. In the Chomsky hierarchy, Type-3 (regular) languages are recognised by finite automata.

Part II. Finite Automata

Formal definition and components

A finite automaton M is a 5-tuple

M = (Q, Σ, q0, δ, F)

  • Q is a finite set of states.
  • Σ (sigma) is a finite set called the input alphabet (set of input symbols).
  • q0 ∈ Q is the start state (there is exactly one start state for the automata considered here).
  • δ is the transition function that describes state changes on input symbols. Its precise type depends on whether the machine is deterministic or nondeterministic (explained below).
  • F ⊆ Q is the set of final (accepting) states.

The following figure is an example of a finite automaton M:

Formal definition and components

For the automaton shown above, its components can be identified as follows.

  • Q = { q0, q1, q2, q3, q4 } - the set of states is shown as circles in the diagram.
Formal definition and components
  • Σ = { a, b, c } - the input alphabet. Arrows (transitions) are labelled with these symbols.
Formal definition and components
  • q0 is the start state. A start state is usually indicated by an arrow coming from the empty space.
Formal definition and components
  • δ describes the operation of the finite automaton. For a transition example,

δ(q0, a) = q1

This means: given the current state q0 and the input symbol a, the automaton moves (transits) to state q1.

Other example transitions (from the figure) are:

δ(q1, b) = q2

δ(q2, c) = q3

δ(q1, c) = q4

δ(q3, b) = q4

  • F = { q2, q4 } - the set of final (accepting) states. Final states are commonly drawn with double circles.

Transition diagrams and transition tables

A finite automaton is often represented as a transition diagram, where states are nodes and transitions are labelled arrows. The same automaton can also be described by a transition table that lists, for every state and input symbol, the resulting state(s).

Transition diagrams and transition tables
Transition diagrams and transition tables

Notation used in diagrams or tables:

  • → q0 denotes that q0 is the start state.
  • ∗ q denotes that state q is a final (accepting) state. For example, a star before q2 and q4 indicates those are final states.

Language acceptability by a finite automaton

Informally, a finite automaton is used to check whether an input string is valid according to the rules encoded by its transitions. Formally, for a deterministic automaton the extended transition function δ* : Q × Σ* → Q maps a state and a string to the state reached after processing the entire string. For nondeterministic automata δ* maps to a set of states. A string w ∈ Σ* is accepted by M if the state(s) reached after processing w include at least one state from F. The language of M is L(M) = { w ∈ Σ* | M accepts w }.

String processing by a finite automaton - worked examples

Example 1:

Consider the following finite automaton M:

String processing by a finite automaton - worked examples

Check whether the string abcb is accepted by this automaton.

Processing begins at the start state q0. Each line below shows the extended transition after reading the next symbol of the string.

δ(q0, abcb) = q1

δ(q1, abcb) = q2

δ(q2, abcb) = q3

δ(q3, abcb) = q4

String processing by a finite automaton - worked examples

After processing the whole string we end in q4, which is a final state. Therefore the string abcb is accepted by M.

Example 2:

Consider the finite automaton M shown below:

String processing by a finite automaton - worked examples

Check whether the string abc is accepted by M.

Processing from the start state q0:

δ(q0, abc) = q1

δ(q1, abc) = q2

δ(q2, abc) = q3

After processing all symbols the automaton halts at q3. Since q3 is not a final state, the string abc is rejected by M.

Example 3:

Consider the finite automaton M:

String processing by a finite automaton - worked examples

Check whether the string abca is accepted by M.

Processing from q0:

δ(q0, abca) = q1

δ(q1, abca) = q2

δ(q2, abca) = q3

At this point we must process the final symbol a from state q3, but there is no transition defined for (q3, a).

Because the automaton cannot process the entire input string, the string abca is rejected by M.

Language of a finite automaton

Given a finite automaton M, its language L(M) consists of all strings accepted by M. For the automaton shown below:

Language of a finite automaton

Examples of membership in the language L(M):

  • The string abcb belongs to L.
  • The string abc does not belong to L.
  • The string abca does not belong to L.
  • The string ab belongs to L.
  • The string ac belongs to L.
  • The string abcbc does not belong to L.

Types of finite automata

Finite automata are classified mainly into two types:

  • Non-deterministic Finite Automata (NFA)
  • Deterministic Finite Automata (DFA)

Non-deterministic Finite Automata (NFA)

An NFA allows, from a given state and input symbol, multiple possible next states (or no next state). Thus the next move is not uniquely determined by the current state and the input symbol. Formally, for an NFA the transition function is

δ : Q × (Σ ∪ {ε}) → P(Q)

where P(Q) denotes the power set of Q and ε denotes the empty (epsilon) transition if epsilon transitions are present.

Example:

Non-deterministic Finite Automata (NFA)

In the figure above, from state q0 with input symbol 0 there are two possible next states: q0 or q1. From q1 on input 1 the next state can be q1 or q2. Such nondeterministic choices characterise an NFA.

Example 1:

Consider the NFA below:

Non-deterministic Finite Automata (NFA)

Check whether the string 0100 is accepted.

Processing along one possible path from the start state q0:

δ(q0, 0100) = q0

δ(q0, 0100) = q0

δ(q0, 0100) = q3

δ(q3, 0100) = q4

Since q4 is a final state, the string 0100 is accepted by the NFA (existence of at least one accepting path is sufficient).

Example 2:

Consider the NFA:

Non-deterministic Finite Automata (NFA)

Check whether the string 01101 is accepted.

One possible sequence of moves is:

δ(q0, 01101) = q0

δ(q0, 01101) = q0

δ(q0, 01101) = q0

δ(q0, 01101) = q1

δ(q1, 01101) = q2

Since q2 is final, the string 01101 is accepted.

Example 3:

Consider the NFA shown below:

Non-deterministic Finite Automata (NFA)

Check whether the string abbaa is accepted.

One accepting path is:

δ(q0, abbaa) = q0

δ(q0, abbaa) = q0

δ(q0, abbaa) = q1

δ(q1, abbaa) = q2

δ(q2, abbaa) = qf

qf is a final state, so abbaa is accepted.

NFA with epsilon (ε) transitions

An NFA may include transitions labelled with ε (epsilon). An ε-transition moves the automaton from one state to another without consuming any input symbol. Epsilon transitions allow the automaton to change state spontaneously. The ε-closure of a state is the set of states reachable from it by zero or more ε-transitions.

Example:

NFA with epsilon (ε) transitions

Check whether the string 100110 is accepted.

One sequence of moves:

δ(q0, 100110) = q0

δ(q0, 100110) = q0

δ(q0, 100110) = q0

δ(q0, 100110) = q1

δ(q1, 100110) = q2

δ(q2, 100110) = q2

δ(q2, ε) = q4

Since q4 is final, the string 100110 is accepted. Note that the ε-move from q2 to q4 did not consume any input symbol.

Example 2:

Consider the NFA:

NFA with epsilon (ε) transitions

Check whether the string 0012 is accepted.

Processing along one path:

δ(q0, 0012) = q0

δ(q0, 0012) = q0

δ(q0, ε) = q1

δ(q1, 0012) = q1

δ(q1, ε) = q2

δ(q2, 0012) = q2

q2 is final, so 0012 is accepted.

Deterministic Finite Automata (DFA)

A DFA is a finite automaton in which, for every state and every input symbol, there is exactly one defined next state and no ε-transitions. Formally,

δ : Q × Σ → Q

In a DFA, the next move is uniquely determined by the current state and the input symbol.

Example:

Deterministic Finite Automata (DFA)

In the automaton above the input alphabet is {0, 1, 2}. From every state and for every symbol there is exactly one transition defined; hence the machine is deterministic. No ε transitions are present in a DFA.

Example 1:

The following transition diagram is a DFA:

Deterministic Finite Automata (DFA)

The same DFA can be written as a transition table:

Deterministic Finite Automata (DFA)

Check whether the string aaba is accepted.

Processing from the start state q0:

δ(q0, aaba) = q0

δ(q0, aaba) = q0

δ(q0, aaba) = q1

δ(q1, aaba) = q1

After processing all symbols the automaton reaches q1, which is a final state. Therefore aaba is accepted.

Example 2:

Consider the DFA shown below and check whether the string aabba is accepted.

One path of deterministic transitions yields:

δ(q0, aabba) = q0

δ(q0, aabba) = q0

δ(q0, aabba) = q1

δ(q1, aabba) = q0

δ(q0, aabba) = q0

After processing the whole string the automaton ends in q0, which is not a final state. Thus aabba is rejected.

Important properties and remarks

  • Equivalence: For every NFA (possibly with ε-transitions) there exists an equivalent DFA recognising the same language. The standard method to convert an NFA to a DFA is the subset construction (powerset construction).
  • Expressive power: DFAs and NFAs recognise exactly the same class of languages: the class of regular languages (Type-3 languages).
  • Decidability: Many problems for finite automata are decidable and have efficient algorithms, for example, testing whether a DFA accepts a given string is done in linear time in the string length.
  • Applications: Finite automata are used in lexical analysis (token recognition), regular expression matching, network protocol design, hardware design (control circuits), and simple pattern matching tasks.

Summary

A finite automaton is a simple, yet powerful mathematical model for recognising regular languages. Its formal definition M = (Q, Σ, q0, δ, F) captures the essential elements: states, input alphabet, start state, transition function and accepting states. Deterministic and nondeterministic variants are equivalent in expressive power, and both are fundamental tools in theory and practice for processing and recognising regular patterns.

The document Finite Automata is a part of the Computer Science Engineering (CSE) Course Theory of Computation.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

FAQs on Finite Automata

1. What is a finite automaton in computer science engineering?
A finite automaton, also known as a finite state machine, is a computational model used to recognize and process patterns in input data. It consists of a set of states, a set of input symbols, a transition function, an initial state, and a set of accepting states. It operates by transitioning between states based on the input symbols it receives, and it can either accept or reject an input sequence based on whether it reaches an accepting state.
2. What is the significance of finite automata in computer science engineering?
Finite automata are essential in various areas of computer science engineering, including compiler design, natural language processing, and network protocols. They provide a compact and efficient way to model and analyze complex systems, allowing engineers to design algorithms and programs that can recognize patterns, process data, and make decisions based on the input they receive.
3. How does a finite automaton differ from a regular expression?
A finite automaton and a regular expression are both used to describe and recognize patterns in input data, but they have different representations and expressive power. A finite automaton is a computational model that operates by transitioning between states based on input symbols, while a regular expression is a string pattern that describes a set of strings. Finite automata can recognize regular languages, which are a subset of the languages described by regular expressions, but regular expressions can express more complex patterns and are often more concise.
4. Are all problems solvable using finite automata?
No, not all problems can be solved using finite automata. Finite automata are limited in their computational power and can only recognize regular languages. Some problems require more powerful computational models, such as pushdown automata or Turing machines, to be solved. These models can recognize more complex languages, including context-free and recursively enumerable languages.
5. What are the different types of finite automata?
There are two main types of finite automata: deterministic finite automata (DFA) and non-deterministic finite automata (NFA). In a DFA, for every state and input symbol, there is exactly one transition defined. It follows a unique path for each input sequence. In contrast, an NFA can have multiple transitions for a state and input symbol, allowing for non-determinism. NFAs can also have ε-transitions, which allow them to transition without consuming any input symbol. Both DFA and NFA have equivalent expressive power, meaning they can recognize the same set of languages.
Explore Courses for Computer Science Engineering (CSE) exam
Get EduRev Notes directly in your Google search
Related Searches
Previous Year Questions with Solutions, Sample Paper, Finite Automata, study material, Free, past year papers, Extra Questions, shortcuts and tricks, Summary, Exam, ppt, mock tests for examination, Important questions, Finite Automata, Viva Questions, video lectures, practice quizzes, Objective type Questions, pdf , Semester Notes, MCQs, Finite Automata;