TOC Lectures
TOC Lectures
CSC 246
• Consider a grammar
• G = (V , T , P , S)
• Where,
Types of grammar
Types of grammar
Basic Terminologies of Theory of Computation:
• Symbol:
• A symbol (often also called a character) is the smallest
building block, which can be any alphabet, letter, or
picture.
Basic Terminologies of Theory of Computation:
• Alphabets (Σ):
• Alphabets are a set of symbols, which are always finite.
Basic Terminologies of Theory of Computation:
• Language:
• A language is a set of strings, chosen from some Σ* or
we can say- ‘A language is a subset of Σ* ‘. A language
that can be formed over ‘ Σ ‘ can be Finite or Infinite.
REGULAR LANGUAGE
REGULAR LANGUAGE
REGULAR LANGUAGE
CHARACTERISTICS OF DFA
Constructing a DFA
• Example 1: Draw the state transition diagram over an alphabet Σ={a,b}
that accepts the string starting with ‘ab’.
• Solution
• The formal definition of Deterministic Finite Automata (DFA) is as follows
• A DFA is a collection of 5-tuples as shown below −
• M=(Q, Σ, δ,q0,F)
• Where,
• Q: Finite set called states.
• Σ: Finite set called alphabets.
• δ: Q × Σ → Q is the transition function.
• q0 ∈ Q is the initial stat
Constructing a DFA
• The language is generated as given below −
• L={ab,aba,abab,…….}
• The transition diagram is as follows
Constructing a DFA
• Example 2: Construct deterministic finite automata that
accepts at most 3 a’s over an alphabet ∑={a,b}.
• The string contains 0 to max 3 a’s and any number of
b’s.
• L= {,a,aa,aaa,ab,abb,bab,bbabaa, bbabaabbb,…..}
Constructing a DFA
• Example 3
• Construct DFA which accepts a string that contains
second symbol is zero and fourth symbol is 1 over an
alphabet ∑={0,1}.
CHARACTERISTICS OF NFA
Non-Deterministic Finite Automata
(NFA)
• Non-Deterministic means that there can be several
possible transitions on the same input symbol from
some state. The output is non-deterministic for a given
input. NFA can be represented as a nondeterministic
finite state machine.
Non-Deterministic Finite Automata
(NFA)
• Example1 :Design an NFA with ∑ = {0, 1} accepts all
string ending with 01.
Non-Deterministic Finite Automata
(NFA)
• Example 2 :Design an NFA with ∑ = {0, 1} accepts all
string ending with 01.
Non-Deterministic Finite Automata
(NFA)
• Example3: Design an NFA with ∑ = {0, 1} in which
double '1' is followed by double '0'
Non-Deterministic Finite Automata
(NFA)
• Example4: Design an NFA in which all the string contain
a substring 1110.
Non-Deterministic Finite Automata
(NFA)
• Example 5: Design an NFA with ∑ = {0, 1} accepts all
string in which the third symbol from the right end is
always 0.
NFA TO DFA
• Every DFA has an NFA but not every NFA is a DFA
• There is an equivalent DFA for every NFA
• we can convert a NFA into DFA.
• The transition function is
• NFA Qx ∑ = DFA Qx ∑ =Q (Where Q is state ∑ is sigma
• The equivalence is defined in terms of languages acceptance.
Since NFA is nothing but a finite automata in which zero, one or
more transitions on an input symbols are permitted.
• To construct DFA equivalent to NFA, it should be remembered
that states of DFA are a collection of states of NFA.
NFA TO DFA EXAMPLE 1
NFA TO DFA EXAMPLE 1 Contd
NFA TO DFA EXAMPLE 2
NFA TO DFA EXAMPLE 3
NFA TO DFA EXAMPLE 3 Contd
DFA vs NDFA
Minimization of DFA
Type of Equivalent
Minimization of DFA
Minimization of DFA
Minimization of DFA
Minimization of DFA
Finite Automata with Output
Finite Automata with Output
(Mealy Machine Example)
Finite Automata with Output
Finite Automata with Output
(Moore Machine Example)
Construction of a Mealy Machine
(Example)
Construction of a Mealy Machine
(Example2)
Construction of a Mealy Machine
(Example2)
Construction of a Mealy Machine
(Example3)
Construction of a Mealy Machine
(Example3)
Construction of a Moore Machine
(Example1)
Construction of a Moore Machine
(Example1)
Construction of a Moore Machine
(Example1)