Unit -1
Basic Concepts and Automata Theory
Q .1) Difference between DFA and NFA?
Sol:
DFA | NFA |
The transition from a state is to a single Particular next state for each input symbol. Hence it is called deterministic.
| The transition from a state can be to Multiple next states for each input symbol. Hence it is called non-deterministic.
|
Empty string transitions are not seen in DFA. | NDFA permits empty string transitions. |
Requires more space. | Requires less space. |
Backtracking is allowed in DFA | In NDFA, backtracking is not always
Possible.
|
A string is accepted by a DFA, if it transits to a final state.
| A string is accepted by a NDFA, if at least One of all possible transitions ends in a Final state. |
Q.2) what is the application of Finite Automata ?
Sol : Application of Finite Automata is :
1. Finite Automata (FA) –
● Used in text editors.
● For the implementation of spell checkers.
2. Push Down Automata (PDA) –
● For designing the parsing phase of a compiler (Syntax Analysis).
● For evaluating the arithmetic expressions.
3. Linear Bounded Automata (LBA) –
● For implementation of genetic programming.
● For constructing syntactic parse trees for semantic analysis of the compiler.
4. Turing Machine (TM) –
● For implementation of neural networks and Robotics Applications.
● For implementation of artificial intelligence.
Q.3) How to convert NFA to DFA ?
Sol : In NFA, the device goes to multiple states when a particular input is given to the current state. On a given input symbol, it can have zero, one or more than a move. On the other hand, in DFA, the program goes to only one state when a particular input is given to the current state. On a given input symbol, a DFA has only one move.
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)
Q.4) Write the steps for converting from Mealy Machine to Moore Machine ?
Sol: The output is connected with each state in the Moore machine and the output is given across the edge with an input symbol in the Mealy machine. State output symbols are distributed to the input symbol paths to convert the Moore machine to the Mealy machine. But we will create a separate state for and new output symbol when converting the Mealy machine to Moore machine and are distributed according to incoming and outgoing edges.
The following steps are used for converting Mealy machine to the Moore machine:
Step 1: For each state(Qi), calculate the number of different outputs that are available in the transition table of the Mealy machine.
Step 2: Copy state Qi, if all the outputs of Qi are the same. Break qi into n states as Qin, if it has n distinct outputs where n = 0, 1, 2....
Step 3: If the output of initial state is 0, insert a new initial state at the starting which gives 1 output.
Q.5) For the given set make Transition Diagram and Transition Table for DFA ?
1. Q = {q0, q1, q2}
2. ∑ = {0,1}
3. q0 = {q0}
4. F = {q2}
Sol : Transition Diagram :
Transition Table :
Present State | Next State for Input 0 | Next state of Input 1 |
→q0 | q0 | q1 |
q1 | q2 | q1 |
*q2 | q2 | q2 |
Q.6) Convert the given Moore machine into its equivalent Mealy machine?
Sol : The transition table of given Moore machine is as follows:
Q | a | b | Output((λ) |
q0 | q1 | q0 | 0 |
q1 | q1 | q2 | 0 |
q2 | q1 | q0 | 1 |
The equivalent Mealy machine can be obtained as follows:
λ' (q0, a) = λ(δ(q0, a))
= λ(q1)
= 0
λ' (q0, b) = λ(δ(q0, b))
= λ(q0)
= 0
The λ for state q1 is as follows:
λ' (q1, a) = λ(δ(q1, a))
= λ(q1)
= 0
λ' (q1, b) = λ(δ(q1, b))
= λ(q2)
= 1
The λ for state q2 is as follows:
λ' (q2, a) = λ(δ(q2, a))
= λ(q1)
= 0
λ' (q2, b) = λ(δ(q2, b))
= λ(q0)
= 0
Hence the transition table for the Mealy machine can be drawn as follows:
The equivalent Mealy machine will be
Q.7) What are the advantages and disadvantages of Deterministic Finite Automata (DFA)?
Sol: There are some advantages and disadvantages of DFA,
❖ The union/intersection of the languages recognized by two given DFAs.
❖ The complement of the language recognized by a given DFA.
❖ DFAs were invented to model of a Turing machine, which was too general to study properties of real world machines.
❖ DFAs are one of the most practical models of computation, since there is a trivial linear time, constant-space, online algorithm there are efficient algorithms to find a DFA recognizing.
❖ The classical example of a simply described language that no DFA can recognize is bracket language, i.e language that consists of properly paired brackets such as word "(( )( ))".
❖ On the other hand, finite state automata are of strictly limited power in the
Languages they can recognize; many simple languages, including any
Problem that requires more than constant space to solve, cannot be
Recognized by a DFA.
Q.8) Define Finite Automata in detail and also define their types ?
Sol:finite automata is :
● 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.
A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F), where:
1. Q: finite set of states
2. ∑: finite set of the input symbol
3. q0: initial state
4. F: final state
5. δ: Transition function
Finite Automata model are as: - Finite automata can be represented by input tape and finite control.
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:
1. DFA(deterministic finite automata) - 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.
2. NFA(non-deterministic finite automata) - 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.
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.
Q.9) what is the simulation of DFA and NFA ?
Sol : Let N = (QN , Σ, δN , qN0 , FN ) be a NFA. The equivalent DFA D1 is obtained from the so-called subset construction (also called “power construction”).
We define D = (QD, Σ, δD, qD0 , FD),
Where
● The alphabet of D is that of N.
● The states of D are sets of states of N:
QD = P(QN )
● The initial state qD0 of D is {qN0 }.
● The final states of D are those sets that contain the final state of N:
FD = {S ∈ P(QN )| S ∩ FN 6= ∅}
● The transition function of D arises from the transition function of N as follows:
δD(S, a) = Uq∈S δN (q, a)
That is, δD(S, a) is the set of all states of N that are reachable from some state q via a.
Proposition. For every NFA N, there is a DFA D such that L(D) = L(N)
Q.10) Describe Transition table n Transition diagram ?
Sol : 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.
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.
Unit -1
Basic Concepts and Automata Theory
Q .1) Difference between DFA and NFA?
Sol:
DFA | NFA |
The transition from a state is to a single Particular next state for each input symbol. Hence it is called deterministic.
| The transition from a state can be to Multiple next states for each input symbol. Hence it is called non-deterministic.
|
Empty string transitions are not seen in DFA. | NDFA permits empty string transitions. |
Requires more space. | Requires less space. |
Backtracking is allowed in DFA | In NDFA, backtracking is not always
Possible.
|
A string is accepted by a DFA, if it transits to a final state.
| A string is accepted by a NDFA, if at least One of all possible transitions ends in a Final state. |
Q.2) what is the application of Finite Automata ?
Sol : Application of Finite Automata is :
1. Finite Automata (FA) –
● Used in text editors.
● For the implementation of spell checkers.
2. Push Down Automata (PDA) –
● For designing the parsing phase of a compiler (Syntax Analysis).
● For evaluating the arithmetic expressions.
3. Linear Bounded Automata (LBA) –
● For implementation of genetic programming.
● For constructing syntactic parse trees for semantic analysis of the compiler.
4. Turing Machine (TM) –
● For implementation of neural networks and Robotics Applications.
● For implementation of artificial intelligence.
Q.3) How to convert NFA to DFA ?
Sol : In NFA, the device goes to multiple states when a particular input is given to the current state. On a given input symbol, it can have zero, one or more than a move. On the other hand, in DFA, the program goes to only one state when a particular input is given to the current state. On a given input symbol, a DFA has only one move.
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)
Q.4) Write the steps for converting from Mealy Machine to Moore Machine ?
Sol: The output is connected with each state in the Moore machine and the output is given across the edge with an input symbol in the Mealy machine. State output symbols are distributed to the input symbol paths to convert the Moore machine to the Mealy machine. But we will create a separate state for and new output symbol when converting the Mealy machine to Moore machine and are distributed according to incoming and outgoing edges.
The following steps are used for converting Mealy machine to the Moore machine:
Step 1: For each state(Qi), calculate the number of different outputs that are available in the transition table of the Mealy machine.
Step 2: Copy state Qi, if all the outputs of Qi are the same. Break qi into n states as Qin, if it has n distinct outputs where n = 0, 1, 2....
Step 3: If the output of initial state is 0, insert a new initial state at the starting which gives 1 output.
Q.5) For the given set make Transition Diagram and Transition Table for DFA ?
1. Q = {q0, q1, q2}
2. ∑ = {0,1}
3. q0 = {q0}
4. F = {q2}
Sol : Transition Diagram :
Transition Table :
Present State | Next State for Input 0 | Next state of Input 1 |
→q0 | q0 | q1 |
q1 | q2 | q1 |
*q2 | q2 | q2 |
Q.6) Convert the given Moore machine into its equivalent Mealy machine?
Sol : The transition table of given Moore machine is as follows:
Q | a | b | Output((λ) |
q0 | q1 | q0 | 0 |
q1 | q1 | q2 | 0 |
q2 | q1 | q0 | 1 |
The equivalent Mealy machine can be obtained as follows:
λ' (q0, a) = λ(δ(q0, a))
= λ(q1)
= 0
λ' (q0, b) = λ(δ(q0, b))
= λ(q0)
= 0
The λ for state q1 is as follows:
λ' (q1, a) = λ(δ(q1, a))
= λ(q1)
= 0
λ' (q1, b) = λ(δ(q1, b))
= λ(q2)
= 1
The λ for state q2 is as follows:
λ' (q2, a) = λ(δ(q2, a))
= λ(q1)
= 0
λ' (q2, b) = λ(δ(q2, b))
= λ(q0)
= 0
Hence the transition table for the Mealy machine can be drawn as follows:
The equivalent Mealy machine will be
Q.7) What are the advantages and disadvantages of Deterministic Finite Automata (DFA)?
Sol: There are some advantages and disadvantages of DFA,
❖ The union/intersection of the languages recognized by two given DFAs.
❖ The complement of the language recognized by a given DFA.
❖ DFAs were invented to model of a Turing machine, which was too general to study properties of real world machines.
❖ DFAs are one of the most practical models of computation, since there is a trivial linear time, constant-space, online algorithm there are efficient algorithms to find a DFA recognizing.
❖ The classical example of a simply described language that no DFA can recognize is bracket language, i.e language that consists of properly paired brackets such as word "(( )( ))".
❖ On the other hand, finite state automata are of strictly limited power in the
Languages they can recognize; many simple languages, including any
Problem that requires more than constant space to solve, cannot be
Recognized by a DFA.
Q.8) Define Finite Automata in detail and also define their types ?
Sol:finite automata is :
● 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.
A finite automaton is a collection of 5-tuple (Q, ∑, δ, q0, F), where:
1. Q: finite set of states
2. ∑: finite set of the input symbol
3. q0: initial state
4. F: final state
5. δ: Transition function
Finite Automata model are as: - Finite automata can be represented by input tape and finite control.
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:
1. DFA(deterministic finite automata) - 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.
2. NFA(non-deterministic finite automata) - 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.
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.
Q.9) what is the simulation of DFA and NFA ?
Sol : Let N = (QN , Σ, δN , qN0 , FN ) be a NFA. The equivalent DFA D1 is obtained from the so-called subset construction (also called “power construction”).
We define D = (QD, Σ, δD, qD0 , FD),
Where
● The alphabet of D is that of N.
● The states of D are sets of states of N:
QD = P(QN )
● The initial state qD0 of D is {qN0 }.
● The final states of D are those sets that contain the final state of N:
FD = {S ∈ P(QN )| S ∩ FN 6= ∅}
● The transition function of D arises from the transition function of N as follows:
δD(S, a) = Uq∈S δN (q, a)
That is, δD(S, a) is the set of all states of N that are reachable from some state q via a.
Proposition. For every NFA N, there is a DFA D such that L(D) = L(N)
Q.10) Describe Transition table n Transition diagram ?
Sol : 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.
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.