3. NFAs
Jan 18, 2022
Nondeterministic Finite Automata
- same symbol may have multiple transitions (or none) from a state
- special transition with
- if input cannot be consumed automaton halts
- explore all paths: if any choice consumes all input symbols and ends in accept state, then the input is accepted
-
reject input if there is no computation of the NFA that accepts the string, i.e. when for all possible computation paths:
- all the input is consumed and the automaton is in a non-accepting state, or
- the input cannot be consumed
-
NFAs can express languages easier than DFAs (fewer states and transitions)
Formal definition
where is set of states is input alphabet and is transition function (non-deterministic) is initial state is set of accepting states (0 or more)
Transition function
(can be )- resulting states reached by following one transition with input symbol
Extended transition function
- extended transition function:
applied on string - special case: for any state
=> - in general:
there is a path from to and transition labels
Language accepted by NFA
- The language accepted by M is
where for each and there is some (accepting state) - NFA accepts the regular languages
- equivalence of machines: machine
is equivalent to if - NFAs and DFAs have the same the same computation power i.e. they accept the same set of languages
- Proof steps: show that Languages accepted by NFAs
Regular languages- Languages accepted by NFAs
Regular languages- every DFA is trivially a NFA
- any language L accepted by a DFA is also accepted by NFA
- Languages accepted by NFAs
Regular languages- any NFA can be converted to an equivalent DFA
- any language L accepted by NFA is also accepted by DFA
- Languages accepted by NFAs
Converting NFA to DFA
- input: an NFA M
- output: an equivalent DFA M' with
- NFA has states
- DFA has states from the power set
Steps
-
initial state of NFA:
and initial state of DFA: -
for every DFA's state
, compute in NFA (union):and add transitions to DFA:
-
Repeat step 2 for every state in DFA and symbols in alphabet until no more states can be added to the DFA
-
For every DFA's state
, if some is accepting state in NFA, then is accepting state in DFA