0% found this document useful (0 votes)
19 views54 pages

TOC Lectures

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views54 pages

TOC Lectures

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Theory of Computation

CSC 246

Dr. O.A Alabi


Theory of Computation
• In theoretical computer science, the theory of computation is the
branch that deals with whether and how efficiently problems can be
solved on a model of computation, using an algorithm.
• Automata theory is the study of abstract machines (or more
appropriately, abstract 'mathematical' machines or systems) and the
computational problems that can be solved using these machines.
• These abstract machines are called automata. This automaton
consists of • states (represented in the figure by circles), • and
transitions (represented by arrows).
Grammar
• Grammar in theory of computation is a finite set of
formal rules that are generating syntactically correct
sentences.

• The formal definition of grammar is that it is defined as


four tuples − G=(V,T,P,S)

• G is a grammar, which consists of a set of production


rules. It is used to generate the strings of a language.
Grammar
• T is the final set of terminal symbols. It is denoted by
lower case letters.
• V is the final set of non-terminal symbols. It is denoted
by capital letters.
• P is a set of production rules, which is used for replacing
non-terminal symbols (on the left side of production) in
a string with other terminals (on the right side of
production)
• S is the start symbol used to derive the string.
Grammar
• Grammar is composed of two basic elements
Grammar

• Terminal Symbols - Terminal symbols are the


components of the sentences that are generated using
grammar and are denoted using small case letters like
a, b, c etc.
• Non-Terminal Symbols - Non-Terminal Symbols take
part in the generation of the sentence but are not the
component of the sentence. These types of symbols are
also called Auxiliary Symbols and Variables. They are
represented using a capital letter like A, B, C, etc.
Grammar

• 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:

• A string is a finite sequence of symbols from some


alphabet. A string is generally denoted as w and the
length of a string is denoted as |w|.
Basic Terminologies of Theory of Computation:
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)

You might also like