Toc CHP-2
Toc CHP-2
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 1
Example
Let L1 = the set of all string of 0’s and 1’s ending in 00, and then the equivalent regular
expression can be described as:
Any string in L1 is obtained by concatenating any string over {0, 1} and the string 00.
Since, {0, 1} is represented by 0 + 1. Hence L1 is represented by (0 + 1)*00.
L2 = the set of all string of 0’s and 1’s beginning with 0 and ending with 1, and then the
equivalent regular expression can be described as:
Any string in L2 is obtained by concatenating 0, any string over {0, 1} and 1. Thus L2
can be represented by 0(0+1)*1.
L3 = {, 11, 1111, 111111 …}, and then the equivalent regular expression can be described as:
Any element of L3 is either , or a string of even number of 1’s so L3 can be represented
by (11)*.
Notes:
* =++
(0,1)* = (0+1)* but (0+1) (0,1)
0+1 = Either 0 or 1 but not both. Thus, 0* + 1* = Either string of zeros or string of one.
01 = First consume 0 then 1. Thus, 0*1* = First string of zeros then the string of one.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 2
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 3
An automation in which the output depends only on the input is called automation without a
memory.
An automation, in which the output depends on input and the state as well, is called
automation with finite memory.
An automation in which the output depends only on state of the machine is called Moore
Machine.
An automation in which the output depends on the state as well as on the input at any instant
of time is called a Mealy Machine.
The sets of strings recognized by finite automata are called regular expression. The sets built up
from the null set, the empty string, and singleton (a set by single digit) strings by concatenations,
unions and Kleene closures, in arbitrary order is called regular sets.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 4
State: A uniquely identifiable set of values measured at various points in a digital system.
Next State
o The state to which the state machine makes the next transition, determined by the
inputs present when the device is clocked.
o At the termination of the input string the state of the FA must reach to any one final
state among the various possible final states.
Notation for FA
There are two preferred notation for describing the automata, which are:
The state diagram accept the string w in * if there exists a path which originates from some
initial states, goes along the arrows and terminate at some final state with path value w.
Example:
Let we have the transition function as: (q0, 0) q0,
(q0, 1) q1, (q1, 0) q0, (q1, 1) q1, with the
initial state q0 and the final state q1, then the
corresponding state diagram is given by:
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 5
Language of DFA
The language of DFA, A = (Q, , , q0, F) is defined by L(A) = { W: (q0, W) is in F} i.e.
the language of ‘A’ is the set of string ‘W’ that takes the start state q0 to one of the accepting
state. If language ‘L’ is L(A) for some DFA ‘A’, then we say ‘L’ is a regular language.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 6
Notice that the only difference between NFA & DFA is that the returns a set of value in
case of NFA and a single value in case of DFA.
EXERCISE – I
Formally we represent an -NFA by A = (Q, , , q0, F), where all components have their
same interpretation as for NFA except is now a function that takes as arguments: -
i. All the states lie in Q after transition.
ii. A member of {} i.e. either an input symbol or the symbol for empty string
and it cannot be the member of the alphabet only.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 7
-Closure
A string ‘w’ in will be accepted by -NFA if there exist at least one path corresponding ‘w’,
which start in an initial state and ends in one of the final states. Since this path may be formed
by - transitions as well as non-- transitions. We may require defining a function - Closure
(q), where q is a state of the automata.
The function - Closure (q) is defined as “the set of all those stats of the automata (i.e. -NFA)
which can be reached from q on a path labeled by i.e. without consuming any input symbols.
Note that if there is no for any state to transit then the - Closure (q) function for that state
will be the same state.
EXERCISE – II
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 8
Note: The representation of a given regular expression may have multiple isomorphic graphs
in conversion of equivalent deterministic finite automata.
Example
The given regular expression (R) = (1+01)* (0+00) (1+10)*
Now, the equivalent Finite Automata (FA) can be constructed as:
Since, the resulting Finite Automata is NFA, which can be converted in to the DFA as follow.
Let ’ be the new transition function for the equivalent DFA.
Thus,
’ (q0, 0) = (q0, 0) = {q5, q6, qf} (New state) → qr (Say)
’ (q0, 1) = (q0, 1) = {q0}
’ [(q5, q6, qf), 0] = (q5, 0) (q6, 0) (qf, 0) = {ϕ} {qf} {q7} = {q7, qf} (New state)
→ qs (Say)
’ [(q5, q6, qf), 1] = (q5, 1) (q6, 1) (qf, 1) = {q0} {ϕ} {qf} = {q0, qf} (New state)
→ qt (Say)
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 9
’ [(q5, q6, q7, qf), 0] = (q5, 0) (q6, 0) (q7, 0) (qf, 0) = {ϕ} {qf} {ϕ} {q7} =
{q7, qf}
’ [(q5, q6, q7, qf), 1] = (q5, 1) (q6, 1) (q7, 1) (qf, 1) = {q0} {ϕ} {qf} {qf} =
{q0, qf}
Thus, the new transition ’ of the DFA can be represented by the transition table as:
Now,
i. Acceptance of string 0011100
(q0, 0011100) = (qr, 011100)
= (qs, 11100)
= (qf, 1100)
= (qf, 100)
= (qf, 00)
= (q7, 0)
= (ϕ, )
This implies that the string is not acceptable by the Finite Automata.
EXERCISE – III
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 10
Example
For the given Transition table, the Finite Automata M = [{q0, q1, q2,
q3}, {0, 1}, , q0, {q3}] where can be defined as:
Step1: Defining the equation for each state with reference to the input symbol (Only incoming
arrows)
Here,
q0 = q0.1 + q1.1 + q2.1 + ---- I
q1 = q0.0 ---- II
q2 = q1.0 ---- III
q3 = q2.0 + q3.0 + q3.1 ---- IV
EXERCISE – IV
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 11
A. Union
Let M1 = (Q1, 1, 1, q1, F1) be NFA that accept a
regular language L = L (M1) and M2 = (Q2, 2, 2, q2,
F2) be another NFA that accept a regular language L
= L (M2). Here, we assume that Q1 and Q2 are two
disjoint sets.
, or
B. Concatenation
Let M1 = (Q1, 1, 1, q1, F1) be NFA that accept a
regular language L = L (M1) and M2 = (Q2, 2, 2, q2,
F2) be another NFA that accept a regular language L =
L (M2). Now, we construct NFA M = (Q, , , q, F),
such that it can accepts L = L (M) = L (M1) ● L (M2).
Where,
• Q = Q1 Q2
• = Set of input states = 1 2 {}
• = 1 2 [(F1, ) q2]
• q = Start state = q1
• F = F2.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 12
Where,
• Q = Q1 {q}
• = Set of input states = 1 {}
• = 1 [(q, ) q1, (q1, ) F1, (F1, ) q]
• q = Start state
• F = F1 {q}.
Here, M consists of the states of M1 and all the transition of M1 and also, any final state of
M1 is the final state of M. In addition, M has a new initial state ‘q’. The new initial state is
also final so that is accepted. From it, the state q1 can be reaches on the input , so that the
operations of M1 can be initiated after M has been started in state ‘q’. Finally, the transition
on input are added from each final state of M1 back to q1, once a string in L (M1) has been
read, computation can resume from the initial state of M1.
It follows the inspection of M that if w L (M) then either w = or w = w1, w2… wk, for k
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 13
Statement
Let M = (Q, , , q0, F) be a finite automaton with n states that accepts a regular language L. Let
w be any string such that w L and |w| n then there exists x, y, z such that
1. w = xyz,
2. y (Given assumption)
3. |xy| n (|xy| = n when z = ) and
4. xyiz L, for all i 0.
Here,
n = Number of states.
w = Any string w L
|w|= m= Length of string in w (if w = abcd, |w| = 4.)
yi = Read i at infinite times.
Proof
Let w = a1, a2, a3 … am, (m is length of string)
(q0, a1, a2, a3 … ai) = qi, (i = 1, 2, 3 … n) = Sequence of states in the path with path value
‘w’.
Q’ = {q0, q1, q2 … qn)
Now, the input string ‘w’ can be decomposed into three substrings as:
x = a1, a2, a3 … aj
y = aj+1, … ak
z = ak+1, … am
Here, on reading the string xyz (i.e. |w| = m =3), a new states are added on the existing states (i.e.
states (n) = 4). But by the definition of pumping lemma, we have, |w| n. Thus, by using Pigeon-
Hole principle, there must coincides at least two states in Q, as there are only n distinct states
defined but on applying the input string the states becomes n+1. Thus, among various pair of
repeated states, we take first as qj and qk (i.e. qj = qk) for merging & hence the path with value w
in the transition diagram of M is shown in figure below.
For |xy| n
The verification of the case is obvious by the help of the given FA defined for the regular string
‘w’. Since, w = xyz = a1, a2 …aj, aj+1…ak, ak+1… am, thus we can write 1 j < k m and this
implies that |xy| n.
Theory of Computation - Compiled by Yagya Raj Pandeya, NAST, Dhangadhi ©[email protected] Page 15