Introduction of Theory of Computation
Introduction of Theory of Computation
Number of Strings (of length 2)
that can be generated over the alphabet {a, b} -
- -
a a
a b
b a
b b
Conclusion:
For alphabet {a, b} with length n, number of
strings can be generated = 2n.
Note – If the number of Σ’s is represented by |Σ|, then number of strings
of length n, possible over Σ is |Σ|n.
Language: A language is a set of strings, chosen from some Σ* or we
can say- ‘A language is a subset of Σ* ‘. A language which can be formed
over ‘ Σ ‘ can be Finite or Infinite.
Introduction of Finite Automata
Difficulty Level : Easy
Last Updated : 18 Sep, 2020
One important thing to note is, there can be many possible DFAs for a
pattern. A DFA with minimum number of states is generally preferred.
2) Nondeterministic Finite Automata(NFA)
NFA is similar to DFA except following additional features:
1. Null (or ε) move is allowed i.e., it can move forward without reading symbols.
2. Ability to transmit to any number of states for a particular input.
However, these above features don’t add any power to NFA. If we compare
both in terms of power, both are equivalent.
Due to above additional features, NFA has a different transition function, rest is
same as DFA.
δ: Transition Function
δ: Q X (Σ U ε ) --> 2 ^ Q.
As you can see in transition function is for any input including null (or ε), NFA
can go to any state number of states.
For example, below is a NFA for above problem
One important thing to note is, in NFA, if any path for an input string leads
to a final state, then the input string accepted. For example, in above NFA,
there are multiple paths for input string “00”. Since, one of the paths leads to a
final state, “00” is accepted by above NFA.
Some Important Points:
Justification:
Since all the tuples in DFA and NFA are the same except for one of the tuples,
which is Transition Function (δ)
In case of DFA
δ : Q X Σ --> Q
In case of NFA
δ : Q X Σ --> 2Q
Now if you observe you’ll find out Q X Σ –> Q is part of Q X Σ –> 2 Q.
In the RHS side, Q is the subset of 2 Q which indicates Q is contained in 2 Q or Q
is a part of 2Q, however, the reverse isn’t true. So mathematically, we can
conclude that every DFA is NFA but not vice-versa. Yet there is a way to
convert an NFA to DFA, so there exists an equivalent DFA for every NFA.
1. Both NFA and DFA have same power and each NFA can be translated into a
DFA.
2. There can be multiple final states in both DFA and NFA.
3. NFA is more of a theoretical concept.
4. DFA is used in Lexical Analysis in Compiler.
where
is ( V + T)* V ( V + T)*
V : Variables
T : Terminals.