0% found this document useful (0 votes)
32 views

Toc Unit1

This document provides an overview of the Theory of Computation course taught by Dr. K. Ananthajothi. The course covers topics such as finite automata, regular expressions, context-free grammars, pushdown automata, Turing machines, and the Chomsky hierarchy of languages. It also discusses formal proofs including deductive proofs, inductive proofs, and different forms of proofs like proof by contradiction and proof by counterexample. Later sections provide details on finite automata models, the definitions of DFAs and NFAs, and transition diagrams for representing automata states and transitions.

Uploaded by

210701014
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)
32 views

Toc Unit1

This document provides an overview of the Theory of Computation course taught by Dr. K. Ananthajothi. The course covers topics such as finite automata, regular expressions, context-free grammars, pushdown automata, Turing machines, and the Chomsky hierarchy of languages. It also discusses formal proofs including deductive proofs, inductive proofs, and different forms of proofs like proof by contradiction and proof by counterexample. Later sections provide details on finite automata models, the definitions of DFAs and NFAs, and transition diagrams for representing automata states and transitions.

Uploaded by

210701014
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/ 79

THEORY OF COMPUTATION

1 Dr.K.Ananthajothi., Ph.D
COURSE DESCRIPTION
 Finite automata;
 Nondeterministic finite automata;

 Regular expressions;

 Applications of the pumping lemma;

 Context-free grammars;

 Normal forms for context-free grammars;

 Pushdown automata;

 Chomsky hierarchy of languages;

 Turing machines.

 Undecidable Problem
2
UNIT I:
INTRODUCTION TO FINITE AUTOMATA

 Introduction to formal proof, Deductive proof.


 Additional forms of proofs
 Inductive proofs
 Induction on Integers,
 Central Concepts of Automata Theory

3
FORMAL PROOF
 Formal proof can be using deductive proof and
inductive proof

Dedutive proof
It consists of sequence of statements given with logical
reasoning in order to prove the first or initial statement.
The initial statement is called hypothesis.

4
ADDITIONAL FORMS OF PROOF
 Proof about sets
 Proof by Contradicition

 Proof byContrapositive

 Proof by Couter Example

 Inductive Proofs

5
PROOF ABOUT SETS
 Set- collection of elements or items
 By giving proofs about sets-try to prove certain
properties of sets
 Eg. Two expressions A and B

 To prove: Both the expressions are equivalent

 Proof: Set represented by expression A is same as the set


represented by expression B.
 PυQ=QυP => mapping expression A with PυQ and
expression B with QυP to prove A=B.
 The proof is of kind “ if and only if”, an element ‘x’ is
in A if and only if it is in B.
6
 To prove the equivalence make use of sequence of
statements along with logical justfication.

7
 Hence PυQ=QυP. Thus, A=B is true as element x is in
B if and only if x is in A. 8
PROOF BY CONTRADICITION
 The proof is of kind “if Athen B”.
 Start with statement A is not true, and thus by assuming
false A try to get conclusion of statement B.
 When it is impossible to reach to statement B contradict
our self and accept that A is true.
 Ex. PυQ=QυP

1. Assume the statement is not true.


2. Consider ‘x’ is in P or Q, we can say that ‘x’ is in PυQ
3. This also implies that ‘x’ is in QυP (definition of union)
4. Hence assumption made initially is false. PυQ=QυP
hence proved.

9
PROOF BY CONTRAPOSITIVE
 The contrapositive of the statement “if H then C” is “if not C
then not H”.
 A statement and its contrapositive are either both true or both
false, we ca prove either toprove the other.

10
There are four cases to consider, H and C both true, H true
and C false, C true and H false, H and C both false.

11
PROOF BY COUTER EXAMPLE
 To prove certain statements, need to see all possible
combinations in which the statements remains true.
 There are some situations, the statement cannot be true.

 Ex. There is no such pair of integers,

a mod b = b mod a
 Proof: a=2, b=3

2 mod 3 ≠ 3 mod 2
 The given pair is true for any pair of integers but if a=b
then a mod b = b mod a
 Proof is true only at some specific condition.

12
INDUCTIVE PROOFS
 It is a recursive kind of proof which consists of sequence
of parameterized statements that use the statement itself
with lower values of its parameter.
 special prooofs based on observations.

 used to prove resursively defined objects.

 This proof is also called as proof by mathematical


induction.
 Steps carried out in the proof of mathematical induction
are
* Basis
* Induction Hypothesis
* Inductive Step
13
 Basis- assume the lowest possible value, initial step in
the proof of mathematical induction.
Ex. prove that the result is true for n=1 or n=0.

 Induction Hypothesis- assign the value of n to some


other value k, and check whether the result is true for
n=k or not.

 Inductive Step- if n=k is true, check whether the result


is true for n=k+1 or not.
 - if we get the same result at n=k+1 then state that given
proof it true by priciple of mathematical induction.

14
15
16
17
18
19
20
CENTRAL CONCEPTS OF AUTOMATA THEORY

 Theory of automata is a theoretical branch of computer


science and mathematical.
 It is the study of abstract machines and the computation
problems that can be solved using these machines.
 The abstract machine is called the automata.

 An automaton with a finite number of states is called a


Finite automaton.

21
STATE AND TRANSITIONS
 The main motivation behind developing the automata
theory was to develop methods to describe and analyse
the dynamic behaviour of discrete systems.
 This automation consists of states and transitions.

 The State is represented by circles, and


the Transitions is represented by arrows.
 Automata is the kind of machine which takes some
string as input and this input goes through a finite
number of states and may enter in the final state.

22
BASIC TERMINOLOGIES
 Symbols:
 Symbols are an entity or individual objects, which can be any
letter, alphabet or any picture.
 Example:
 1, a, b, #
 Alphabets:
 Alphabets are a finite set of symbols. It is denoted by ∑.
 Examples:
 ∑ = {a, b}
 ∑ = {A, B, C, D}

 ∑ = {0, 1, 2}

 ∑ = {0, 1, ....., 5]

 ∑ = {#, β, Δ} 23
BASIC TERMINOLOGIES
 String:
 It is a finite collection of symbols from the alphabet. The
string is denoted by w.
 Example 1:
 If ∑ = {a, b}, various string that can be generated from ∑ are {ab, aa,
aaa, bb, bbb, ba, aba.....}.
 A string with zero occurrences of symbols is known as an empty

string. It is represented by ε.
 The number of symbols in a string w is called the length of a string.

It is denoted by |w|.
 Example 2:
 w = 010
 Number of Sting |w| = 3

24
BASIC TERMINOLOGIES
 Language:
A language is a collection of appropriate string. A
language which is formed over Σ can
be Finite or Infinite.
 Example: 1
 L1 = {Set of string of length 2} = {aa, bb, ba, bb} Finite
Language
 Example: 2
 L2 = {Set of all strings starts with 'a'} = {a, aa, aaa, abb, abbb,
ababb} Infinite Language

25
FINITE AUTOMATA
 Finite automata are used to recognize patterns.
 It takes the string of symbol as input and changes its
state accordingly.
 When the desired symbol is found, then the transition occurs.
 At the time of transition, the automata can either move to
the next state or stay in the same state.
 Finite automata have two states, Accept state or Reject
state.
 When the input string is processed successfully, and the
automata reached its final state, then it will accept.

26
FORMAL DEFINITION OF FA
 A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0,
F), where:
 Q: finite set of states
 ∑: finite set of the input symbol
 q0: initial state
 F: final state
 δ: Transition function

27
FINITE AUTOMATA MODEL
 Finite automata can be represented by input tape and finite
control.
 Input tape: It is a linear tape having some number of cells. Each
input symbol is placed in each cell.
 Finite control: The finite control decides the next state on receiving
particular input from input tape. The tape reader reads the cells one
by one from left to right, and at a time only one input symbol is read.
TYPES OF AUTOMATA
 There are two types of finite automata:
 DFA(deterministic
finite automata)
 NFA(non-deterministic finite automata)

29
TYPES OF AUTOMATA
 DFA
 DFA refers to deterministic finite automata.
 Deterministic refers to the uniqueness of the computation.
 In the DFA, the machine goes to one state only for a
particular input character.
 DFA does not accept the null move.

 NFA
 NFA stands for non-deterministic finite automata.
 It is used to transmit any number of states for a particular
input.
 It can accept the null move.

30
SOME IMPORTANT POINTS ABOUT
DFA AND NFA
1. Every DFA is NFA, but NFA is not DFA.
2. There can be multiple final states in both NFA and
DFA.
3. DFA is used in Lexical Analysis in Compiler.
4. NFA is more of a theoretical concept.

Lexical Analysis is the first phase of the compiler also known as a scanner.
It converts the High level input program into a sequence of Tokens.
Lexical Analysis can be implemented with the Deterministic finite Automata.

31
TRANSITION DIAGRAM
 A transition diagram or state transition diagram is a
directed graph which can be constructed as follows:
 There is a node for each state in Q, which is represented by
the circle.
 There is a directed edge from node q to node p labeled a if
δ(q, a) = p.
 In the start state, there is an arrow with no source.
 Accepting states or final states are indicating by a double
circle.

32
TRANSITION DIAGRAM NOTATIONS

33
HOW A DFA OPERATES
1. In DFA, the input to the automata can be any string.
2. Now, put a pointer to the start state q and read the input
string w from left to right and move the pointer according
to the transition function, δ.
3. We can read one symbol at a time.
4. If the next symbol of string w is ‘a’ and the pointer is on
state p, move the pointer to δ(p, a).
5. When the end of the input string w is encountered, then
the pointer is on some state F.

34
HOW A DFA OPERATES
2. The string w is said to be accepted by the DFA if r ∈ F
that means the input string w is processed successfully
and the automata reached its final state.
3. The string is said to be rejected by DFA if r ∉ F.

35
EXAMPLE 1
 DFA with ∑ = {0, 1} accepts all strings starting with 1.
 Solution:

 The finite automata can be represented using a transition graph.


 In the above diagram, the machine initially is in start state q0 then on

receiving input 1 the machine changes its state to q1.


 From q0 on receiving 0, the machine changes its state to q2, which is the

dead state.
 From q1 on receiving input 0, 1 the machine changes its state to q1,

which is the final state.


 The possible input strings that can be generated are 10, 11, 110, 101,

111......., that means all string starts with 1.


36
EXAMPLE 2
 NFA with ∑ = {0, 1} accepts all strings starting with 1.
 Solution:

 The NFA can be represented using a transition graph.


 In the above diagram, the machine initially is in start state
q0 then on receiving input 1 the machine changes its state to
q1.
 From q1 on receiving input 0, 1 the machine changes its
state to q1.
 The possible input string that can be generated is 10, 11, 37
110, 101, 111......, that means all string starts with 1.
TRANSITION TABLE
 The transition table is basically a tabular representation
of the transition function.
 It takes two arguments (a state and a symbol) and returns
a state (the "next state").
 A transition table is represented by the following things:
 Columns correspond to input symbols.
 Rows correspond to states.
 Entries correspond to the next state.
 The start state is denoted by an arrow with no source.
 The accept state is denoted by a star.

38
EXAMPLE 1 Solution: Transition table of given DFA is as follows:

Present Next state for Next State


State Input 0 of Input 1

→q0 q1 q2
q1 q0 q2
*q2 q2 q2

Explanation:
• In the above table, the first column indicates all the current states. Under column 0 and
1, the next states are shown.
• The first row of the transition table can be read as, when the current state is q0, on input
0 the next state will be q1 and on input 1 the next state will be q2.
• In the second row, when the current state is q1, on input 0, the next state will be q0, and
on 1 input the next state will be q2.
• In the third row, when the current state is q2 on input 0, the next state will be q2, and on
1 input the next state will be q2.
• The arrow marked to q0 indicates that it is a start state and circle marked to q2 indicates
that it is a final state.

39
EXAMPLE 2 Present
State
Next state for
Input 0
Next State
of Input 1

Solution: Transition table of given DFA is as follows: →q0 q0 q1

q1 q1, q2 q2

q2 q1 q3

*q3 q2 q2

•Explanation:
• The first row of the transition table can be read as, when the current state is q0, on input
0 the next state will be q0 and on input 1 the next state will be q1.
• In the second row, when the current state is q1, on input 0 the next state will be either q1
or q2, and on 1 input the next state will be q2.
• In the third row, when the current state is q2 on input 0, the next state will be q1, and on
1 input the next state will be q3.
• In the fourth row, when the current state is q3 on input 0, the next state will be q2, and
40
on 1 input the next state will be q2.
DFA (DETERMINISTIC FINITE
AUTOMATA)
 DFA refers to deterministic finite automata.
 Deterministic refers to the uniqueness of the computation.
 The finite automata are called deterministic finite automata if the
machine is read an input string one symbol at a time.
 In DFA, there is only one path for specific input from the current
state to the next state.
 DFA does not accept the null move,
 i.e., the DFA cannot change state without any input character.
 DFA can contain multiple final states.
 It is used in Lexical Analysis in Compiler.

41
EXAMPLE
In the following diagram, we can see that from state q0 for input a, there is only
one path which is going to q1.
Similarly, from q0, there is only one path for input b going to q2.

42
FORMAL DEFINITION OF DFA

 A DFA is a collection of 5-tuples same as we described


in the definition of FA.
 Q: finite set of states
 ∑: finite set of the input symbol
 q0: initial state
 F: final state
 δ: Transition function

 Transition function can be defined as:


 δ: Q x ∑→Q

43
GRAPHICAL REPRESENTATION OF DFA
 A DFA can be represented by digraphs called state
diagram. In which:
 The state is represented by vertices.
 The arc labeled with an input character show the transitions.
 The initial state is marked with an arrow.
 The final state is denoted by a double circle.

44
EXAMPLE 1
Q = {q0, q1, q2}
∑ = {0, 1}
q0 = {q0} Solution: Transition Diagram:
F = {q2}

Transition Table

Present State Next state for Input 0 Next State of Input


1

→q0 q0 q1

q1 q2 q1

*q2 q2 q2 45
EXAMPLE 2
DFA with ∑ = {0, 1} accepts all starting Solution: Transition Diagram:
with 0.

Explanation:
In the above diagram, we can see that on given 0 as input to DFA in state q0 the DFA
changes state to q1 and always go to final state q1 on starting input 0.
It can accept 00, 01, 000, 001....etc. It can't accept any string which starts with 1,
because it will never go to final state on a string starting with 1.

46
EXAMPLE 3
DFA with ∑ = {0, 1} accepts all ending
Solution: Transition Diagram:
with 0.

Explanation:

In the above diagram, we can see that on given 0 as input to DFA in state q0, the DFA
changes state to q1.
It can accept any string which ends with 0 like 00, 10, 110, 100....etc.
It can't accept any string which ends with 1, because it will never go to the final state q1
on 1 input, so the string ending with 1, will not be accepted or will be rejected.

47
EXAMPLE (1) OF DFA
Design a FA with ∑ = {0, 1} accepts those string which starts with 1 and ends with 0.

Solution:
The FA will have a start state q0 from which only the edge with input 1 will go to the next state.

Explanation:

In state q1, if we read 1, we will be in state q1, but if we read 0 at state q1, we will reach to state
q2 which is the final state.
In state q2, if we read either 0 or 1, we will go to q2 state or q1 state respectively. Note that if the
input ends with 0, it will be in the final state.
48
EXAMPLE (2) OF DFA
Design a FA with ∑ = {0, 1} accepts the only input 101.

Solution:
In the given solution, we can see that only input 101 will be accepted. Hence, for input 101, there is no other
path shown for other input.
EXAMPLE (3) OF DFA
Design FA with ∑ = {0, 1} accepts even number of 0's and even number of 1's.

Solution:
This FA will consider four different stages for input 0 and input 1. The stages could be:

Explanation:

Here q0 is a start state and the final state also. Note carefully that
a symmetry of 0's and 1's is maintained. We can associate
meanings to each state as:
q0: state of even number of 0's and even number of 1's.
q1: state of odd number of 0's and even number of 1's.
q2: state of odd number of 0's and odd number of 1's.
q3: state of even number of 0's and odd number of 1's.
EXAMPLE (4) OF DFA

Design FA with ∑ = {0, 1} accepts the set of all strings with three consecutive 0's.

Solution:
The strings that will be generated for this particular languages are 000, 0001, 1000, 10001, .... in which 0
always appears in a clump of 3. The transition graph is as follows:

Note that the sequence of triple zeros is maintained to reach the final state.

51
EXAMPLE (5) OF DFA

Design a DFA L(M) = {w | w ε {0, 1}*} and W is a string that does not contain consecutive 1's.

Solution:
When three consecutive 1's occur the DFA will be:

Here two consecutive 1's or single 1 is acceptable, hence

The stages q0, q1, q2 are the final states. The DFA will generate the strings that do not
contain consecutive 1's like 10, 110, 101,..... etc.
EXAMPLE (6) OF DFA

Design a FA with ∑ = {0, 1} accepts the strings with an even number of 0's followed by single 1.

Solution:
The DFA can be shown by a transition diagram as:

53
CONVERSION FROM NFA TO DFA
 Let, M = (Q, ∑, δ, q0, F) is an NFA which accepts the
language L(M). There should be equivalent DFA denoted
by M' = (Q', ∑', q0', δ', F') such that L(M) = L(M').
 Steps for converting NFA to DFA:
 Step 1: Initially Q' = ϕ
 Step 2: Add q0 of NFA to Q'. Then find the transitions from
this start state.
 Step 3: In Q', find the possible set of states for each input
symbol. If this set of states is not in Q', then add it to Q'.
 Step 4: In DFA, the final state will be all the states which
contain F(final states of NFA)
54
Example - 1
Example - 2
Example - 3
Example - 4
Example - 5
62
63
64
THEOREM: NFA TO DFA CONVERSION

74
75
ALTERNATE METHOD

76
THEOREM: NFA WITH Ε TO DFA DIRECTLY

77
THEOREM: NFA-Ε TO NFA WITHOUT Ε
IF L IS ACCEPTED BY AN NFA WITH Ε-TRANSITION THEN
SHOW THAT L IS ACCEPTED BY NFA WITHOUT Ε -
TRANSITION.

78
79

You might also like