Regular Languages
Regular Languages
REGULAR LANGUAGES
Automata
Inputs: assumed to be sequences of symbols selected from a finite set I of input signals.
Namely, set I is the set {x1, x2, x3... xk} where k is the number of inputs.
Outputs: sequences of symbols selected from a finite set Z. Namely, set Z is the set {y1,
y2, y3 ... ym} where m is the number of outputs.
States: finite set Q, whose definition depends on the type of automaton.
1. Finite-state automata
2. Push-down automata
3. Linear-bounded automata
4. Turing machine
Finite-state automata
A Finite State automata or finite automata (FA) means an automata with a set of states, and
its “control” moves from state to state in response to external “inputs”. FA provides the
simplest model of a computing device. It has a central processor of finite capacity and it is
based on the concept of state. It can also be given a formal mathematical definition. Finite
automata are used for pattern matching in text editors, for compiler lexical analysis.
Page | 1
2. Non-Deterministic finite automata
Characteristics of DFA:
Symbols used in FA
A deterministic finite state automaton (DFA) is a simple language recognition device. It can
be seen as a machine working to give an indication about strings which are given in input or
it can be given a mathematical definition.
Strings are fed into the device by means of an input tape, which is divided into squares, each
one holding one symbol. The main part of the machine itself is a black box which is, at any
specified moment, in one of a finite number of distinct internal states, among which we
distinguish an initial state and some final states. This black box, called the finite control,
can sense what symbol is written at any position of the input tape by means of a movable
reading head. Initially, the reading head is placed at the leftmost square of the tape and the
finite control is set in a designated initial state.
Page | 2
A Deterministic Finite Automaton (DFA), denoted by M, is a quintuple algebraic system
(more specifically, a semi group):
M = (Q, , δ, q0, F),
Where
1. Q is a finite set of internal states,
2. is the input alphabet,
3. q0∈ Q is the initial state,
4. F Q is the set of final states, or accepting states,
5. δ is the state transition function
δ:Qx →Q .
The above DFA is defined without output; we can, of course, define it with output as follows:
M = (Q, , U, δ, σ, qo, F), where
1. U is the output alphabet,
2. σ is the output function
σ: Q x →U.
String acceptance by DFA or DFSA
Example: Let M be a DFA defined by M = (Q, , δ, q0, F)
= ({A, B, C}, {0, 1}, δ, A, {B})
Find whether this machine can accept words or strings of 00011 and 000110?
Page | 3
The machine defined above can read a given finite input tape containing a word and either
accepts the word or rejects it. The word is accepted if after reading the tape, the machine is in
any one of the accepting states.
Consider the machine defined in above Example. Suppose now that the machine reads the
word 00011. Then the following are the actions of the machine as it reads 00011:
Page | 4
Since the machine is in the final state B after having read the input word, then the word
00011 is accepted by this machine. However, the machine cannot accept the word 000110,
because
That is, the machine does not stop at the final state B after having read the word 000110. In
fact, it stopped at the state C which is not a final state. There are several other ways to
Page | 5
describe actions of an automaton. One very useful way can describe as follows (for the same
automaton defined above and the same word 00011):
It is plain to verify that the automaton described in Figure 2.3 can accept the following
words:
Result- This DFA machine is accepting String00011 and it is not accepting string 000110.
Non-Deterministic Finite Automata (NFA)
In contrast to deterministic automata, non-determinism allows a machine to select arbitrarily
from several possible responses to a given situation, including the possibility of selecting
from several initial states. If one of the various responses to a word leaves the machine in an
accepting state, then the word is said to be accepted. In this subsection, we study non-
deterministic finite automata.
A Non-deterministic Finite Automaton (NFA), M, is a quintuple algebraic system:
M = (Q, , δ, S, F),
Page | 6
Find whether this machine can accept strings or words of four consecutive 0’s and 1’s?
Page | 7
Result- This machine is accepting strings or words of two consecutive 0’s and 1’s.
Page | 8
Regular Expressions
Example
Page | 9
Example
Page | 10
Example
Page | 11
Regular Grammar
Page | 12
Example 1:
Page | 13
**************END**************
Page | 14