Non Deterministic Automata
Nondeterministic Finite Accepter (NFA) Alphabet =
Nondeterministic Finite Accepter (NFA) Alphabet = Two choices
Nondeterministic Finite Accepter (NFA) Alphabet = Two choices No transition No transition
First Choice
First Choice
First Choice
First Choice All input is consumed “accept”
Second Choice
Second Choice
Second Choice No transition: the automaton hangs
Second Choice Input cannot be consumed “reject”
An NFA accepts a string: when there is a computation of the NFA that accepts the string All the input is consumed and the automaton is in a final state
Example is accepted by the NFA: “accept” “reject” because this computation accepts
Rejection example
First Choice
First Choice “reject”
Second Choice
Second Choice
Second Choice “reject”
An NFA rejects a string: when there is no computation of the NFA that accepts the string All the input is consumed and the automaton is in a non final state The input cannot be consumed
Example is rejected by the NFA: “reject” “reject” All possible computations lead to rejection
Rejection example
First Choice
First Choice No transition: the automaton hangs
First Choice Input cannot be consumed “reject”
Second Choice
Second Choice
Second Choice No transition: the automaton hangs
Second Choice Input cannot be consumed “reject”
is rejected by the NFA: “reject” “reject” All possible computations lead to rejection
Language accepted:
Lambda Transitions
(read head doesn’t move)
all input is consumed “accept” String is accepted
Rejection Example
(read head doesn’t move)
No transition: the automaton hangs
Input cannot be consumed “reject” String is rejected
Language accepted:
Another NFA Example
“accept”
Another String
“accept”
Language accepted
Another NFA Example
Language accepted
Remarks: The symbol never appears on the input tape Extreme automata:
NFAs are interesting because we can express languages easier than DFAs NFA DFA
Formal Definition of NFAs Set of states, i.e. Input aplhabet, i.e. Transition function Initial state Final states
Transition Function
Extended Transition Function
Formally It holds if and only if there is a walk from to with label
The Language of an NFA
Formally The language accepted by NFA is: where and there is some (final state)
Equivalence of NFAs and DFAs
Equivalence of Machines For DFAs or NFAs: Machine is equivalent to machine if
Example NFA DFA
Since machines and are equivalent NFA DFA
Equivalence of NFAs and DFAs Question: NFAs = DFAs ? Same power? Accept the same languages?
Equivalence of NFAs and DFAs Question: NFAs = DFAs ? YES! Same power? Accept the same languages?
We will prove: Languages accepted by NFAs Languages accepted by DFAs NFAs and DFAs have the same computation power
Step 1 Languages accepted by NFAs Languages accepted by DFAs Proof: Every DFA is trivially an NFA A language accepted by a DFA is also accepted by an NFA
Step 2 Languages accepted by NFAs Languages accepted by DFAs Proof: Any NFA can be converted to an equivalent DFA A language accepted by an NFA is also accepted by a DFA
NFA to DFA NFA DFA
NFA to DFA NFA DFA
NFA to DFA NFA DFA
NFA to DFA NFA DFA
NFA to DFA NFA DFA
NFA to DFA NFA DFA
NFA to DFA NFA DFA
NFA to DFA: Remarks We are given an NFA We want to convert it to an equivalent DFA With
If the NFA has states the DFA has states in the powerset
Procedure NFA to DFA 1. Initial state of NFA: Initial state of DFA:
Example NFA DFA
Procedure NFA to DFA 2. For every DFA’s state Compute in the NFA Add transition to DFA
Exampe NFA DFA
Procedure NFA to DFA Repeat Step 2 for all letters in alphabet, until no more transitions can be added.
Example NFA DFA
Procedure NFA to DFA 3. For any DFA state If some is a final state in the NFA Then, is a final state in the DFA
Example NFA DFA
Theorem Take NFA Apply procedure to obtain DFA Then and are equivalent :
Finally We have proven Languages accepted by NFAs Languages accepted by DFAs
We have proven Languages accepted by NFAs Languages accepted by DFAs Regular Languages
We have proven Languages accepted by NFAs Languages accepted by DFAs Regular Languages Regular Languages
We have proven Languages accepted by NFAs Languages accepted by DFAs Regular Languages Regular Languages Thus, NFAs accept the regular languages