Module 1
Module 1
January 7, 2022
Learning Objectives and Outcomes
Sub-topic Learning Objective Learning Outcomes
Formal Grammars To understand the basics of Familarity with basics of
grammar and Formal Language Grammar
Chomsky Hierarchy To understand Chomsky To be familiar with type of
clssification of grammar grammar
Regular Expression To understand the concept of To become familar with regular
regular expression expression
Deterministic and To understand the idea behind To understand the basic idea of
Non-deterministic DFA and NDFA DFA and NDFA and their
Finite Automata difference.
Regular Expression To understand the concept of To become familar with usage
regular expression and relevance of regular
expressions
Two way Finite To understand the relevance To understand the logic behind
Automata of 2 way finite automata and importance of 2 way finite
automata
Finite Automata To understand the machine To get familiar with Mealy and
with output with output Moore machine.
Properties of To understand the properties To understand properties of
regular sets of regular set regular set
Pumping lemma To understand the idea and To understand the idea behind
for regular sets relevance of pumping lemma pumping lemma for regular sets
My-Hill-Nerode To understand My-Hill-Nerode To understand relevance of the
Theorem Theorem theroem
Department of CSE Module 1 January 7, 2022 2/120
Outline
1 Introduction
4 Formal Grammar
5 Chomsky Hierarchy
6 Regular Expression
9 My-Hill-NeroArdede Theorem
Preliminaries
Propositions (or Statements)
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
NOT (Negation)¬P
AND (Conjunction) P ∧ Q
OR (Disjunction) P ∨ Q
If.. Then... (Implication)
If and only If
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
NOT (Negation)¬P
AND (Conjunction) P ∧ Q
OR (Disjunction) P ∨ Q
If.. Then... (Implication)
If and only If
Tautology- A tautology or a universally true formula is a well
defined formula whose truth value is T for all possible
assignments of truth values to the propositional variables.
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
NOT (Negation)¬P
AND (Conjunction) P ∧ Q
OR (Disjunction) P ∨ Q
If.. Then... (Implication)
If and only If
Tautology- A tautology or a universally true formula is a well
defined formula whose truth value is T for all possible
assignments of truth values to the propositional variables.
Example-P ∨ ¬P
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
NOT (Negation)¬P
AND (Conjunction) P ∧ Q
OR (Disjunction) P ∨ Q
If.. Then... (Implication)
If and only If
Tautology- A tautology or a universally true formula is a well
defined formula whose truth value is T for all possible
assignments of truth values to the propositional variables.
Example-P ∨ ¬P
Contradiction- A contradiction (or absurdity) is well formed
formula whose truth value is F for all possible assignments of
truth values to propostion variables.
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
NOT (Negation)¬P
AND (Conjunction) P ∧ Q
OR (Disjunction) P ∨ Q
If.. Then... (Implication)
If and only If
Tautology- A tautology or a universally true formula is a well
defined formula whose truth value is T for all possible
assignments of truth values to the propositional variables.
Example-P ∨ ¬P
Contradiction- A contradiction (or absurdity) is well formed
formula whose truth value is F for all possible assignments of
truth values to propostion variables.
Example-P ∧ ¬P
Preliminaries
Propositions (or Statements)
Connectives (Propositional connectives or Logical connectives)
NOT (Negation)¬P
AND (Conjunction) P ∧ Q
OR (Disjunction) P ∨ Q
If.. Then... (Implication)
If and only If
Tautology- A tautology or a universally true formula is a well
defined formula whose truth value is T for all possible
assignments of truth values to the propositional variables.
Example-P ∨ ¬P
Contradiction- A contradiction (or absurdity) is well formed
formula whose truth value is F for all possible assignments of
truth values to propostion variables.
Example-P ∧ ¬P
Equivalence
Department of CSE Module 1 January 7, 2022 5/120
Introduction
Preliminaries
Preliminaries
Preliminaries
Logical Identities
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Associative laws- P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Associative laws- P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
Distributive laws- P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Associative laws- P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
Distributive laws- P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
Absorption laws- P ∧ (P ∨ Q) ≡ P
P ∨ (P ∧ Q) ≡ P
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Associative laws- P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
Distributive laws- P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
Absorption laws- P ∧ (P ∨ Q) ≡ P
P ∨ (P ∧ Q) ≡ P
De-morgan’s Laws- ¬(P ∨ Q) ≡ ¬P ∧ ¬Q
¬(P ∧ Q) ≡ ¬P ∨ ¬Q
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Associative laws- P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
Distributive laws- P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
Absorption laws- P ∧ (P ∨ Q) ≡ P
P ∨ (P ∧ Q) ≡ P
De-morgan’s Laws- ¬(P ∨ Q) ≡ ¬P ∧ ¬Q
¬(P ∧ Q) ≡ ¬P ∨ ¬Q
Contrapositive- P ⇒ Q ≡ ¬Q ⇒ ¬P
P ⇒ Q ≡ ¬P ∨ Q
Preliminaries
Logical Identities
Idempotent laws- P ∨ P ≡ P, P ∧ P ≡ P
Commutative laws- P ∨ Q ≡ Q ∨ P, P ∧ Q ≡ Q ∧ P
Associative laws- P ∨ (Q ∨ R) ≡ (P ∨ Q) ∨ R
P ∧ (Q ∧ R) ≡ (P ∧ Q) ∧ R
Distributive laws- P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R)
P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R)
Absorption laws- P ∧ (P ∨ Q) ≡ P
P ∨ (P ∧ Q) ≡ P
De-morgan’s Laws- ¬(P ∨ Q) ≡ ¬P ∧ ¬Q
¬(P ∧ Q) ≡ ¬P ∨ ¬Q
Contrapositive- P ⇒ Q ≡ ¬Q ⇒ ¬P
P ⇒ Q ≡ ¬P ∨ Q
Double negation- P ≡ ¬(¬P)
Questions
Show that:
(P ∧ Q) ∨ (P ∧ ¬Q) ≡ P
Questions
Show that:
(P ∧ Q) ∨ (P ∧ ¬Q) ≡ P
Show that:
(P =⇒ Q) ∧ (R =⇒ Q) ≡ (P ∨ R) =⇒ Q
Mathematical Preliminaries
Set:
A set is well defined collection of objects.
Example-Set of all students in ASET,
Collection of all books in library.
Individual objects are called Members or Elements of the
set.
Capital letter usually represent Set such as A,B,C,...
Small letters represent Elements of any set such as a,b,c,....
If a is an element of set A =⇒ a ∈ A
Mathematical Preliminaries
Set:
A set is well defined collection of objects.
Example-Set of all students in ASET,
Collection of all books in library.
Individual objects are called Members or Elements of the
set.
Capital letter usually represent Set such as A,B,C,...
Small letters represent Elements of any set such as a,b,c,....
If a is an element of set A =⇒ a ∈ A
Ways of describing set
Listing its element with no repetition
Example: {15, 30, 45, 60, 75, 90}
Mathematical Preliminaries
Set:
A set is well defined collection of objects.
Example-Set of all students in ASET,
Collection of all books in library.
Individual objects are called Members or Elements of the
set.
Capital letter usually represent Set such as A,B,C,...
Small letters represent Elements of any set such as a,b,c,....
If a is an element of set A =⇒ a ∈ A
Ways of describing set
Listing its element with no repetition
Example: {15, 30, 45, 60, 75, 90}
Describing properties of elements of set
Example: {n | nisapositiveintegerdivisibleby 15andlessthan100}
Mathematical Preliminaries
Set:
A set is well defined collection of objects.
Example-Set of all students in ASET,
Collection of all books in library.
Individual objects are called Members or Elements of the
set.
Capital letter usually represent Set such as A,B,C,...
Small letters represent Elements of any set such as a,b,c,....
If a is an element of set A =⇒ a ∈ A
Ways of describing set
Listing its element with no repetition
Example: {15, 30, 45, 60, 75, 90}
Describing properties of elements of set
Example: {n | nisapositiveintegerdivisibleby 15andlessthan100}
By recursion
Example: Set of all natural numers leaving remainder 1 when
divided by 3 can be written as
{an | a0 = 1, an+1 = an + 3}
Department of CSE Module 1 January 7, 2022 9/120
Introduction
Mathematical Preliminaries
Mathematical Preliminaries
Mathematical Preliminaries
Mathematical Preliminaries
Graph
A graph (or undirected graph) consists of:
a non-empty set V of vertices
a set E called set of edges.
a map φ which assigns to every edge a unique unordered pair of
vertices.
A directed graph or (digraph) consists of
a non-empty set V of vertices
a set E called set of edges
a map φ which assigns to every edge a unique ordered pair of
vertices.
Mathematical Preliminaries
Tree
A graph is called a tree if it is connected and has no circuits
Mathematical Preliminaries
Tree
A graph is called a tree if it is connected and has no circuits
Properties of tree:
A tree is connected graph with no circuits or loops
Mathematical Preliminaries
Tree
A graph is called a tree if it is connected and has no circuits
Properties of tree:
A tree is connected graph with no circuits or loops
there is one and only one path between every pair of vertices.
Mathematical Preliminaries
Tree
A graph is called a tree if it is connected and has no circuits
Properties of tree:
A tree is connected graph with no circuits or loops
there is one and only one path between every pair of vertices.
if a connected graph has n vertices =⇒ has n − 1 edges, implies
a tree
Automata
Discrete Automata
Model of discrete automaton:
Characteristics of Automata
Input-At a discrete instant of time t1 , t2 , .....tm , input values
I1 , I2 ....Ip take finite number of fixed values from input alphabet Σ
are applied as input to model.
Discrete Automata
Model of discrete automaton:
Characteristics of Automata
Input-At a discrete instant of time t1 , t2 , .....tm , input values
I1 , I2 ....Ip take finite number of fixed values from input alphabet Σ
are applied as input to model.
Output- O1 , O2 , ...Oq are output of model, each of which can take
finite number of fixed values from an Output.
Discrete Automata
Model of discrete automaton:
Characteristics of Automata
Input-At a discrete instant of time t1 , t2 , .....tm , input values
I1 , I2 ....Ip take finite number of fixed values from input alphabet Σ
are applied as input to model.
Output- O1 , O2 , ...Oq are output of model, each of which can take
finite number of fixed values from an Output.
States- At any instant of time, the automaton can be in one of the
states q1 , q2 , ...qn
Discrete Automata
Model of discrete automaton:
Characteristics of Automata
Input-At a discrete instant of time t1 , t2 , .....tm , input values
I1 , I2 ....Ip take finite number of fixed values from input alphabet Σ
are applied as input to model.
Output- O1 , O2 , ...Oq are output of model, each of which can take
finite number of fixed values from an Output.
States- At any instant of time, the automaton can be in one of the
states q1 , q2 , ...qn
State relation- The next state of an automaton at any instant of
time is determined by present state and present input.
Discrete Automata
Model of discrete automaton:
Characteristics of Automata
Input-At a discrete instant of time t1 , t2 , .....tm , input values
I1 , I2 ....Ip take finite number of fixed values from input alphabet Σ
are applied as input to model.
Output- O1 , O2 , ...Oq are output of model, each of which can take
finite number of fixed values from an Output.
States- At any instant of time, the automaton can be in one of the
states q1 , q2 , ...qn
State relation- The next state of an automaton at any instant of
time is determined by present state and present input.
Output relation- On reading an input symbol, automaton moves to
next state which is given by state relation.
Department of CSE Module 1 January 7, 2022 14/120
Introduction
Discrete Automata
Discrete Automata
Discrete Automata
Any sequential machine behaviour can be represented by an
automaton.
Example: Consider a 4-bit serial shift register as a finite state
machine.
Discrete Automata
Any sequential machine behaviour can be represented by an
automaton.
Example: Consider a 4-bit serial shift register as a finite state
machine.
Finite Automaton
Finite Automata
Finite Automata
Finite Automata
Finite Automata
Transition Systems
A transition system or transition graph is finite directed
labelled graph in which each vertex (node) is represented by a
state and edges are labelled with input\output.
Transition Systems
A transition system or transition graph is finite directed
labelled graph in which each vertex (node) is represented by a
state and edges are labelled with input\output.
Transition system
A transition system accepts a string w in Σ∗ if:
There exists a path which originates from some initial state, goes
along the arrows and terminates at some final state, and
The path value obtained by concatenation of all edge-labels of the
path is equal to w
Transition system
A transition system accepts a string w in Σ∗ if:
There exists a path which originates from some initial state, goes
along the arrows and terminates at some final state, and
The path value obtained by concatenation of all edge-labels of the
path is equal to w
Example
Consider the given transition system:
Determine the initial states, final states and acceptability of 101011, 111010.
Transition system
A transition system accepts a string w in Σ∗ if:
There exists a path which originates from some initial state, goes
along the arrows and terminates at some final state, and
The path value obtained by concatenation of all edge-labels of the
path is equal to w
Example
Consider the given transition system:
Determine the initial states, final states and acceptability of 101011, 111010.
Initial states:q0 and q1 ; Final State:q3
Path value q0 q0 q2 q3 for 101011 =⇒ accepted by system
But, 111010 not accepted
Department of CSE Module 1 January 7, 2022 20/120
Introduction
Transition function
Every finite automaton (Q, Σ, δ, q0 , F) can be viewd as a
transition system (Q, Σ, δ’,q0 ,F) if we take Q0 = {q0 } and
δ 0 ={(q,w,δ(q,w))| q ∈ Q, w ∈ Σ∗ }
But, a transition system need not be a finite automaton.
Example: A transition system may contain more than one
initial state.
Transition function
Every finite automaton (Q, Σ, δ, q0 , F) can be viewd as a
transition system (Q, Σ, δ’,q0 ,F) if we take Q0 = {q0 } and
δ 0 ={(q,w,δ(q,w))| q ∈ Q, w ∈ Σ∗ }
But, a transition system need not be a finite automaton.
Example: A transition system may contain more than one
initial state.
Properties of Transition Functions:
1 δ(q, ∧) = q is a finite automaton
=⇒ State of the system can be changed only by an input symbol.
2 For all strings w and input symbol a:
δ(q, aw )= δ(δ(q, a), w )
δ(q, wa)= δ(δ(q, w ), a)
Transition function
Every finite automaton (Q, Σ, δ, q0 , F) can be viewd as a
transition system (Q, Σ, δ’,q0 ,F) if we take Q0 = {q0 } and
δ 0 ={(q,w,δ(q,w))| q ∈ Q, w ∈ Σ∗ }
But, a transition system need not be a finite automaton.
Example: A transition system may contain more than one
initial state.
Properties of Transition Functions:
1 δ(q, ∧) = q is a finite automaton
=⇒ State of the system can be changed only by an input symbol.
2 For all strings w and input symbol a:
δ(q, aw )= δ(δ(q, a), w )
δ(q, wa)= δ(δ(q, w ), a)
Exercise:
Prove that for any transition function δ and for any two input
string x and y
δ(q, xy )=δ(δ(q, x), y )
Department of CSE Module 1 January 7, 2022 21/120
Introduction
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
Example
Consider the finite state machine whose transition function δ is given below in form of
a transition table. Here, Q={q0 , q1 , q2 , q3 }, Σ = {0, 1}, F = {q0 }.
Give the entire sequence of states for the input string 110101.
Input
O
State 0 1
→q0 q2 q1
q1 q3 q0
q2 q0 q3
q3 q1 q2
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 1
Contruct a deterministic automaton equivalent to M=({q0 , q1 }, {0, 1}, δ, q0 , {q0 })
where δ is defined as under:
State Input
O
0 1
→q0 q0 q1
q1 q1 q0 ,q1
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
[q0 , q1 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
[q0 , q1 ] [q0 , q1 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
[q0 , q1 ] [q0 , q1 ] [q1 , q2 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
[q0 , q1 ] [q0 , q1 ] [q1 , q2 ]
[q1 , q2 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
[q0 , q1 ] [q0 , q1 ] [q1 , q2 ]
[q1 , q2 ] [q0 ]
NDFA → DFA
Example 2
Find a deterministic acceptor equivalent to:
M= ({q0 ,q1 ,q2 },{a,b}, δ, q0 , {q2 })
where δ is given by
State Input
a b
→ q0 q0 , q1 q2
O
q1 q0 q1
q2 φ q0 , q1
State Input
a b
[q0 ] [q0 , q1 ] [q2 ]
[q2 ] φ [q0 , q1 ]
[q0 , q1 ] [q0 , q1 ] [q1 , q2 ]
[q1 , q2 ] [q0 ] [q0 , q1 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ] [q0 , q1 , q2 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ] [q0 , q1 , q2 ] [q0 , q1 , q2 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ] [q0 , q1 , q2 ] [q0 , q1 , q2 ]
[q0 , q1 , q2 , q3 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ] [q0 , q1 , q2 ] [q0 , q1 , q2 ]
[q0 , q1 , q2 , q3 ] [q0 , q1 , q2 , q3 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ] [q0 , q1 , q2 ] [q0 , q1 , q2 ]
[q0 , q1 , q2 , q3 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q2 , q3 ]
NDFA → DFA
Example 3
Construct a deterministic finite automaton equivalent to
M=({q0 , q1 , q2 , q3 },{a,b},δ,q0 ,{q3 })
where δ is as under:
State Input
a b
→ q0 q0 , q1 q0
q1 q2 q1
O
q2
q3
q3 q3
q2
State Input
a b
[q0 ] [qo , q1 ] [q0 ]
[q0 , q1 ] [q0 , q1 , q2 ] [q0 , q1 ]
[q0 , q1 , q2 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q3 ]
[q0 , q1 , q3 ] [q0 , q1 , q2 ] [q0 , q1 , q2 ]
[q0 , q1 , q2 , q3 ] [q0 , q1 , q2 , q3 ] [q0 , q1 , q2 , q3 ]
NDFA → DFA
1 Construct a DFA equivalent to NDFA ’M’ whose transition
diagram is given as:
NDFA → DFA
1 Construct a DFA equivalent to NDFA ’M’ whose transition
diagram is given as:
O
q3 q4
q4 q4 q4
Department of CSE Module 1 January 7, 2022 31/120
Deterministic and Non Deterministic Finite Automata
Example:
Initial state q0 is marked with an arrow. The table defines δ and λ:
O
State a=0 a=1 λ
→ q0 q3 q1 0
q1 q1 q2 1
q2 q2 q3 0
q3 q3 q0 0
Determine transition states and output string for input string 0111.
Example:
Initial state q0 is marked with an arrow. The table defines δ and λ:
O
State a=0 a=1 λ
→ q0 q3 q1 0
q1 q1 q2 1
q2 q2 q3 0
q3 q3 q0 0
Determine transition states and output string for input string 0111.
Solution: Transition states:
0\0 1\0 1\0 1\1
q0 −−→ q3 −−→ q0 −−→ q1 −−→ q2 0
OutputString: 00010
Example:
Consider a mealy machine for q1 as initial state.
Determine the transition of states and corresponding output string for input string
0011.
Example:
Consider a mealy machine for q1 as initial state.
Determine the transition of states and corresponding output string for input string
0011.
0\0 0\1 1\0 1\0
Solution: q1 −−→ q3 −−→ q2 −−→ q4 −−→ q3
Output String: 0100
q20 q40
q2 q4
q21 q41
Solution:
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1
q20
q21
q3
q40
q41
Department of CSE Module 1 January 7, 2022 35/120
Finite Automata with Output
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3 0
q41
Department of CSE Module 1 January 7, 2022 36/120
Finite Automata with Output
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3 0
q41 q41
Department of CSE Module 1 January 7, 2022 36/120
Finite Automata with Output
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3 0
q41 q41 1
Department of CSE Module 1 January 7, 2022 36/120
Finite Automata with Output
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3 0
q41 q41 1 q3
Department of CSE Module 1 January 7, 2022 36/120
Finite Automata with Output
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1
State State Output State Output
→ q1 q3 0 q20 0
q20 q1 1 q40 0
q21 q1 1 q40 0
q3 q21 1 q1 1
q40 q41 1 q3 0
q41 q41 1 q3 0
Department of CSE Module 1 January 7, 2022 36/120
Finite Automata with Output
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20
q20 q1 q40
q21 q1 q40
q3 q21 q1
q40 q41 q3
q41 q41 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20 1
q20 q1 q40
q21 q1 q40
q3 q21 q1
q40 q41 q3
q41 q41 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40
q3 q21 q1
q40 q41 q3
q41 q41 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1
q40 q41 q3
q41 q41 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1 0
q40 q41 q3
q41 q41 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1 0
q40 q41 q3 0
q41 q41 q3
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1 0
q40 q41 q3 0
q41 q41 q3 1
q20 q40
q2 q4
q21 q41
Solution:
Present a=0 a=1 Output
→ q0 q3 q20 0
q1 q3 q20 1
q20 q1 q40 0
q21 q1 q40 1
q3 q21 q1 0
q40 q41 q3 0
q41 q41 q3 1
Department of CSE Module 1 January 7, 2022 44/120
Finite Automata with Output
q21 q31
q2 q3
q22 q32
Language: Introduction
Language
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String A concatenation of finite symbols from the alphabet is called
a string.
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String A concatenation of finite symbols from the alphabet is called
a string.
Example: If Σ={a,b} then a, abab, aaabb,
abababababaaaaaaabaab, etc.
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String A concatenation of finite symbols from the alphabet is called
a string.
Example: If Σ={a,b} then a, abab, aaabb,
abababababaaaaaaabaab, etc.
Empty String or Null String
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String A concatenation of finite symbols from the alphabet is called
a string.
Example: If Σ={a,b} then a, abab, aaabb,
abababababaaaaaaabaab, etc.
Empty String or Null String∧ or λ or φ
=⇒ A string with no symbols
Words
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String A concatenation of finite symbols from the alphabet is called
a string.
Example: If Σ={a,b} then a, abab, aaabb,
abababababaaaaaaabaab, etc.
Empty String or Null String∧ or λ or φ
=⇒ A string with no symbols
Words =⇒ strings belonging to some language
Example: If Σ={x} then a language L can be defined as
L={x n :n=1,2,3,....} or
L={x,xx,xxx,....}
Here, x, xx, xxx ,.... are the words of L.
Language: Introduction
Language
Formal (Syntactic Languages)
Informal (Semantic Languages)
Alphabet
String A concatenation of finite symbols from the alphabet is called
a string.
Example: If Σ={a,b} then a, abab, aaabb,
abababababaaaaaaabaab, etc.
Empty String or Null String∧ or λ or φ
=⇒ A string with no symbols
Words =⇒ strings belonging to some language
Example: If Σ={x} then a language L can be defined as
L={x n :n=1,2,3,....} or
L={x,xx,xxx,....}
Here, x, xx, xxx ,.... are the words of L.
All words are strings but not all strings are words.
Language: Introduction
Language: Introduction
Language: Introduction
Language: Definition
Descriptive Definition
Recursive Definition
Using Regular Expression
Using Finite Automata, etc.
Language: Definition
Descriptive Definition
Recursive Definition
Using Regular Expression
Using Finite Automata, etc.
Solution:
1 Delete all non-reachable states.
2 Draw transition table
State \Σ 0 1
→ q0 q1 q5
O
q1 q6 q2
q2 q0 q2
q3 q2 q6
q4 q7 q5
q5 q2 q6
q6 q6 q4
q7 q6 q2
Solution:
State \Σ a b
→ q0 q1 q0
q1 q0 q2
O
q2 q3 q1
q3 q3 q0
q4 q3 q5
q5 q6 q4
q6 q5 q6
q7 q6 q3
O
q5 q1 q4
q6 q1 q3
GRAMMAR
A grammar is (VN ,Σ, P,S)
where VN is a non-empty set whose elements are called
variables.
Σ finite non-empty set whose elements are called terminals.
S is aspecial symbol called Start Symbol.
P are set of Production rules.
VN ∩ Σ 6= 0
GRAMMAR
A grammar is (VN ,Σ, P,S)
where VN is a non-empty set whose elements are called
variables.
Σ finite non-empty set whose elements are called terminals.
S is aspecial symbol called Start Symbol.
P are set of Production rules.
VN ∩ Σ 6= 0
Example
G={VN , Σ, P, S} is a Grammar, where
VN ={<sentence>, <noun>, <verb>, <adverb>}, Σ={Ram,Sam,ran,sang,fast},
S=<sentence>
P consists of following productions:
<sentence>→<noun>, <verb>
<sentence>→<noun>, <verb>, <adverb>
<noun>→ Ram
<noun>→ Sam
<verb>→ ran
<verb>→ sang
<adverb>→ fast
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
If G=({S},{a},{S → SS},S), Find the language generated by
G.
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
If G=({S},{a},{S → SS},S), Find the language generated by
G.
Solution: L(G)=φ
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
If G=({S},{a},{S → SS},S), Find the language generated by
G.
Solution: L(G)=φ
Let G=({S,C},{a,b},P,S), where P consists of S
→ aCa, C → aCa |b. Find L(G).
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
If G=({S},{a},{S → SS},S), Find the language generated by
G.
Solution: L(G)=φ
Let G=({S,C},{a,b},P,S), where P consists of S
→ aCa, C → aCa |b. Find L(G).
Solution: S =⇒ aCa =⇒ aba . So, aba ∈ L(G)
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
If G=({S},{a},{S → SS},S), Find the language generated by
G.
Solution: L(G)=φ
Let G=({S,C},{a,b},P,S), where P consists of S
→ aCa, C → aCa |b. Find L(G).
Solution: S =⇒ aCa =⇒ aba . So, aba ∈ L(G)
S =⇒ aCa (using S→ aCa)
n
=⇒ a Ca n (using S→ aCa (n-1) times)
Grammar
If G=({S},{0,1},{S→ 0S1,S→ ∧},S). Find L(G).
Solution: S→0S1 → 00S11 → 000S111.....0n S1n
0n ∧1n = 0n 1n ∈ L(G) for n ≥ 0
∴ L(G)={0n 1n |n ≥ 0}
If G=({S},{a},{S → SS},S), Find the language generated by
G.
Solution: L(G)=φ
Let G=({S,C},{a,b},P,S), where P consists of S
→ aCa, C → aCa |b. Find L(G).
Solution: S =⇒ aCa =⇒ aba . So, aba ∈ L(G)
S =⇒ aCa (using S→ aCa)
n
=⇒ a Ca n (using S→ aCa (n-1) times)
=⇒ an ban (using C → b)
Hence, an ban ∈ L(G), where n≥ 1
∴ L(G)={an ban |n ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Exercise
Construct a grammar G so that L(G) = {an bam |n, m ≥ 1}
Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Solution: Let G=({S,A},{a,b,c},P,S)
where ”P” consists of:
S → aS |A
A → bAc |bc
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Solution: Let G=({S,A},{a,b,c},P,S)
where ”P” consists of:
S → aS |A
A → bAc |bc
Let G =({S,A},{0,1,2},P,S) where P consists of
S → 0SA2 |S → 012
2A → A2
1A → 11. Show that L(G)={0n 1n 2n |n ≥ 1}
∗
− 0n−1 S(A2)n−1 by applying S → 0SA2 (n-1)
Solution: S →
times
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Solution: Let G=({S,A},{a,b,c},P,S)
where ”P” consists of:
S → aS |A
A → bAc |bc
Let G =({S,A},{0,1,2},P,S) where P consists of
S → 0SA2 |S → 012
2A → A2
1A → 11. Show that L(G)={0n 1n 2n |n ≥ 1}
∗
− 0n−1 S(A2)n−1 by applying S → 0SA2 (n-1)
Solution: S →
times
→ 0n 12(A2)n−1 by applying S → 012
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Solution: Let G=({S,A},{a,b,c},P,S)
where ”P” consists of:
S → aS |A
A → bAc |bc
Let G =({S,A},{0,1,2},P,S) where P consists of
S → 0SA2 |S → 012
2A → A2
1A → 11. Show that L(G)={0n 1n 2n |n ≥ 1}
∗
− 0n−1 S(A2)n−1 by applying S → 0SA2 (n-1)
Solution: S →
times
→ 0n 12(A2)n−1 by applying S → 012
∗
− 0n 1An−1 2n by applying 2A → A2 several times
→
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Solution: Let G=({S,A},{a,b,c},P,S)
where ”P” consists of:
S → aS |A
A → bAc |bc
Let G =({S,A},{0,1,2},P,S) where P consists of
S → 0SA2 |S → 012
2A → A2
1A → 11. Show that L(G)={0n 1n 2n |n ≥ 1}
∗
Solution: S →− 0n−1 S(A2)n−1 by applying S → 0SA2 (n-1)
times
→ 0n 12(A2)n−1 by applying S → 012
∗
− 0n 1An−1 2n by applying 2A → A2 several times
→
∗
− 0n 1n 2n by applying 1A → 11 (n-1 times)
→
Grammar
Find a grammar generating
{aj b n c n |n ≥ 1, j ≥ 0 }
Solution: Let G=({S,A},{a,b,c},P,S)
where ”P” consists of:
S → aS |A
A → bAc |bc
Let G =({S,A},{0,1,2},P,S) where P consists of
S → 0SA2 |S → 012
2A → A2
1A → 11. Show that L(G)={0n 1n 2n |n ≥ 1}
∗
Solution: S → − 0n−1 S(A2)n−1 by applying S → 0SA2 (n-1)
times
→ 0n 12(A2)n−1 by applying S → 012
∗
− 0n 1An−1 2n by applying 2A → A2 several times
→
∗
− 0n 1n 2n by applying 1A → 11 (n-1 times)
→
∴ 0n 1n 2n ∈ L(G) for all n ≥ 1
Department of CSE Module 1 January 7, 2022 63/120
Formal Grammar
Grammar
Grammar
Grammar
Grammar
Grammar
Let G=({S,A,B},{a,b},P,S) where P consists of
S → aABa, A → baABb, B → Aab, aA → baa, bBb → abab.
Test whether w = baabbabaaabbaba is in L(G).
Grammar
Let G=({S,A,B},{a,b},P,S) where P consists of
S → aABa, A → baABb, B → Aab, aA → baa, bBb → abab.
Test whether w = baabbabaaabbaba is in L(G).
Solution: S→ aABa
=⇒ baaBa
=⇒ baaAaba
=⇒ baabaABbaba
=⇒ baabbaaBbaba
=⇒ baabbaaAabbaba
=⇒ baabbabaaabbaba=w
∴ w ∈ L(G)
Grammar
Let G=({S,A,B},{a,b},P,S) where P consists of
S → aABa, A → baABb, B → Aab, aA → baa, bBb → abab.
Test whether w = baabbabaaabbaba is in L(G).
Solution: S→ aABa
=⇒ baaBa
=⇒ baaAaba
=⇒ baabaABbaba
=⇒ baabbaaBbaba
=⇒ baabbaaAabbaba
=⇒ baabbabaaabbaba=w
∴ w ∈ L(G)
If the grammar G is given by the productions S → aSa |bSb
|aa |bb |∧, show that:
L(G) has no strings of odd length
Any string in L(G) is of length 2n, n ≥ 0
the number of strings of length 2n is 2n
Regular Expression
Regular Expression
Regular Expression
Regular Expression
r=(aa)∗ (bb)∗ b
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
For Σ ={0,1}. Give a regular expression ’r’ such that
L(r)={w∈ Σ∗ |w has atleast one pair of consequtive zeroes}
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
For Σ ={0,1}. Give a regular expression ’r’ such that
L(r)={w∈ Σ∗ |w has atleast one pair of consequtive zeroes}
Solution: r=(0 + 1)∗ 00(0 + 1)∗
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
For Σ ={0,1}. Give a regular expression ’r’ such that
L(r)={w∈ Σ∗ |w has atleast one pair of consequtive zeroes}
Solution: r=(0 + 1)∗ 00(0 + 1)∗
Find R.E. for language
L={w ∈ {0, 1}∗ |w has no pair of consecutive zeroes}
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
For Σ ={0,1}. Give a regular expression ’r’ such that
L(r)={w∈ Σ∗ |w has atleast one pair of consequtive zeroes}
Solution: r=(0 + 1)∗ 00(0 + 1)∗
Find R.E. for language
L={w ∈ {0, 1}∗ |w has no pair of consecutive zeroes}
Solution: r=(1 + 01)∗ (0 + λ)
r=(1∗ 011∗ )∗ (0 + λ) + 1∗ (0 + λ)
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
For Σ ={0,1}. Give a regular expression ’r’ such that
L(r)={w∈ Σ∗ |w has atleast one pair of consequtive zeroes}
Solution: r=(0 + 1)∗ 00(0 + 1)∗
Find R.E. for language
L={w ∈ {0, 1}∗ |w has no pair of consecutive zeroes}
Solution: r=(1 + 01)∗ (0 + λ)
r=(1∗ 011∗ )∗ (0 + λ) + 1∗ (0 + λ)
Find all strings in L((a + b)∗ b(a + ab)∗ ) of length less than 4
r=(aa)∗ (bb)∗ b
denotes the set of all strings with even number of a’s followed
by an odd number of b’s
L(r)={a2n b 2m+1 |n≥0, m≥0}
For Σ ={0,1}. Give a regular expression ’r’ such that
L(r)={w∈ Σ∗ |w has atleast one pair of consequtive zeroes}
Solution: r=(0 + 1)∗ 00(0 + 1)∗
Find R.E. for language
L={w ∈ {0, 1}∗ |w has no pair of consecutive zeroes}
Solution: r=(1 + 01)∗ (0 + λ)
r=(1∗ 011∗ )∗ (0 + λ) + 1∗ (0 + λ)
Find all strings in L((a + b)∗ b(a + ab)∗ ) of length less than 4
Find R.E. for set {an b m :(n+m) is even}
L(a∗ + a∗ (a + b)c∗)
State Elimination method
Arden’s Theorem
1 φ+R=R
2 φR = R φ = φ
3 ΛR = RΛ =R
4 Λ∗ = Λ and φ∗ = Λ
5 R+R=R
6 R ∗R ∗ = R ∗
7 RR ∗ = R ∗ R
8 (R ∗ )∗ = R ∗
9 Λ + RR ∗ = R ∗ = Λ + R ∗ R
10 (PQ)∗ P = P(QP)∗
11 (P + Q)∗ = (P ∗ Q ∗ )∗ =(P ∗ + Q ∗ )∗
12 (P+Q)R = PR + QR and R(P+Q) = RP + RQ
-NFA
=⇒ Moving without reading a symbol from Input Tape.
-NFA
=⇒ Moving without reading a symbol from Input Tape.
State/Input 0 1
A B,C A B
B - B C
C C C -
-NFA
=⇒ Moving without reading a symbol from Input Tape.
State/Input 0 1
A B,C A B
B - B C
C C C -
Epsilon Closure
-closure for a given state X is a set of States which can be
reached from states X with only (null) or moves including the
state X itself.
-NFA
=⇒ Moving without reading a symbol from Input Tape.
State/Input 0 1
A B,C A B
B - B C
C C C -
Epsilon Closure
-closure for a given state X is a set of States which can be
reached from states X with only (null) or moves including the
state X itself.
Example: closure (A)={A,B,C}
closure (B)={B,C}
closure (C)={C}
Department of CSE Module 1 January 7, 2022 84/120
Regular Expression
Steps:
1 Take closure of initial state as begining state
2 Find states that can be traversed from present from present
state for each input symbol
3 If any new state is found, repeat step 2 till we get no new
state in the transition table.
4 Mark states containing final states as new final state.
State/Input 0 1
{A,B,C} {B,C} {A,B,C}
Steps:
1 Take closure of initial state as begining state
2 Find states that can be traversed from present from present
state for each input symbol
3 If any new state is found, repeat step 2 till we get no new
state in the transition table.
4 Mark states containing final states as new final state.
State/Input 0 1
{A,B,C} {B,C} {A,B,C}
{B,C} {C} {B,C}
Steps:
1 Take closure of initial state as begining state
2 Find states that can be traversed from present from present
state for each input symbol
3 If any new state is found, repeat step 2 till we get no new
state in the transition table.
4 Mark states containing final states as new final state.
State/Input 0 1
{A,B,C} {B,C} {A,B,C}
{B,C} {C} {B,C}
{C} {C} {C}
Steps:
1 Take closure of initial state as begining state
2 Find states that can be traversed from present from present
state for each input symbol
3 If any new state is found, repeat step 2 till we get no new
state in the transition table.
4 Mark states containing final states as new final state.
State/Input 0 1
{A,B,C} {B,C} {A,B,C}
{B,C} {C} {B,C}
{C} {C} {C}
Arden’s Theorem
Let P and Q be two regular expressions over Σ. If P doesnot
contain Λ, then the following equation in R i.e. R=Q+RP
has a unique solution R=QP ∗
Proof:
R = Q + RP (1)
putting ”R=Q+RP” in equation 1
R=Q+QP+RPP
putting R recursively again and again
we get:
R=Q+QP+QP 2 +QP 3 + . . .
R= Q (Λ + P + P 2 + P 3 + . . .)
R=QP ∗
Arden’s Theorem
Let P and Q be two regular expressions over Σ. If P doesnot
contain Λ, then the following equation in R i.e. R=Q+RP
has a unique solution R=QP ∗
Proof:
R = Q + RP (1)
putting ”R=Q+RP” in equation 1
R=Q+QP+RPP
putting R recursively again and again
we get:
R=Q+QP+QP 2 +QP 3 + . . .
R= Q (Λ + P + P 2 + P 3 + . . .)
R=QP ∗
Assumptions:
The transition diagram must not have null transitions.
It must only 1 initial state
Arden’s Theorem I
1. Find R.E. for the following DFA
q1 = q1 0 + q3 0 + ∧ (2)
q2 = q1 1 + q2 1 + q3 1 (3)
q3 = q2 0 (4)
putting equation 4 in equation 3
q2 = q1 1 + q2 1 + q3 1
= q1 1 + q2 1 + (q2 0)1
= q1 1 + q2 (1 + 01)
Department of CSE Module 1 January 7, 2022 87/120
Regular Expression
Arden’s Theorem II
Applying Arden’s Theorem
q2 = q1 1(1 + 01)∗ (5)
putting 5 in equation 2
q1 = q1 0 + q3 0 + ∧
= q1 0 + q2 00 + ∧
= q1 0 + (q1 1(1 + 01)∗ 00) + ∧
q1 (0 + 1(1 + 01)∗ 00) + ∧
using arden’s theorem again
∗
q1 = ∧(0 + 1(1 + 01)∗ 00)
∗
(0 + 1(1 + 01)∗ 00)
∗
As q1 is the final state. ∴ r= (0 + 1(1 + 01)∗ 00)
Department of CSE Module 1 January 7, 2022 88/120
Regular Expression
Arden’s Theorem
Arden’s Theorem I
Consider the transition system below. Prove that the strings
∗
recognized are (a + a(b + aa)∗ b) a(b + aa)∗ a
Solution:
q1 = q1 a + q2 b + ∧ (6)
q2 = q1 a + q2 b + q3 a (7)
q3 = q2 a (8)
Arden’s Theorem II
Putting equation 8 in equation 7
q2 = q1 a + q2 b + q2 aa
q2 = q1 a + q2 (b + aa)
q2 = q1 a(b + aa)∗
q1 = q1 a + q2 b + ∧
= q1 a + q1 a(b + aa)∗ b + ∧
= q1 (a + a(b + aa)∗ b) + ∧
∗
= ∧(a + a(b + aa)∗ b)
∗
= (a + a(b + aa)∗ b)
putting this in q2
∗
q2 = (a + a(b + aa)∗ b) a + q2 b + q2 aa
∗
= (a + a(b + aa)∗ b) a + q2 (b + aa)
∗
= (a + a(b + aa)∗ b) a(b + aa)∗
putting q2 in q3
∗
q3 = (a + a(b + aa)∗ b) a(b + aa)∗ a (9)
Arden’s Theorem I
Prove that the finite automaton whose transition diagram
below accepts the set of all strings over alphabet {a,b} with
an equal number of a’s and b’s, such that each prefix has
atmost has atmost one more a than the b’s and atmost one
more b than the a’s
Arden’s Theorem II
Solution:
q1 = q2 b + q3 a + ∧ (10)
q2 = q1 a (11)
q3 = q1 b (12)
q4 = q2 a + q3 b + q4 a + q4 b (13)
putting q2 and q3 in q1
q1 = q1 ab + q1 ba + ∧
q1 = q1 (ab + ba) + ∧
q1 = ∧(ab + ba)∗
q1 = (ab + ba)∗
Department of CSE Module 1 January 7, 2022 94/120
Regular Expression
Arden’s Theorem
Arden’s Theorem
2-way DFA
2-way DFA allows the read head to move left or right on the
input
Two end-markers
Needs only 1 accept or reject state.
A tuple M = {Q, Σ, `, a, δ, s, t, r }
where Q is the set of states
Σ is the input alphabet set
` is the left end marker
a is the right end marker
δ is Q × (Σ ∪ {`, λ}) → Q × {L, R}
s is start state
t is the accept state
r is reject state such that r 6= t
2-Way DFA
Determine the acceptability of 101001 for the following:
State/ Σ 0 1
→ q0 (q0 ,R) (q1 , R)
q1 (q1 ,R) (q2 , L)
q2 (q0 ,R) (q2 , L)
where Q={q0 , q1 , q2 }, s=q0 , t=q1 , r=q2
State/Σ 0 1
q0 q0 , q3 q0 , q4
q3 qf
q4 qf
qf qf qf