170 likes | 335 Views
Non-deterministic FSA. Reading: 2.2 & 2.3. Reminder: . A Language is called Regular iff there is a DFA acceptor that defines it. There exists some DFA M such that L = L(M). NFA Formal Definition. Same as DFA’s, but δ : Q X ( Σ { λ }) 2 Q Two non-deterministic elements:
E N D
Non-deterministic FSA Reading: 2.2 & 2.3
Reminder: A Language is called Regular iff there is a DFA acceptor that defines it. There exists some DFA M such that L = L(M).
NFA Formal Definition • Same as DFA’s, but δ: Q X (Σ {λ}) 2Q • Two non-deterministic elements: • Lambda transitions • 2 outarcs with same symbol • A String is accepted if there is SOME path that ends in an acceptor state.
The language defined by a NFA is the set of all strings for which there is a walk with the string’s label from the initial state to some accepting state. NFA’s and Languages
Example {ab, abc}* q1 a q0 b c,λ q2
Example Is aaa accepted? ab? What language is this? q1 a q0 b a λ q2
Things NFA’s make easy • L1 U L2 L1 λ λ L2 λ λ
L1 Things NFA’s make easy • L1 ٠L2 λ L2 λ λ
L1 Things NFA’s make easy • L1* λ λ λ λ
Intuitive NFA’s • Example: Write a DFA & NFA that accept the strings containing the substring abbab
Practice - write NFAs • Strings on {a,b}* that ends in aa. • A string on {a,b,c}* such that the final letter has occurred before.
Equivalence • DFA’s and NFA’s are equally powerful. • That is, For every language accepted by a NFA, there exists some DFA that also accepts the language.
Algorithm NFA -> DFA • start state in GD (deterministic graph) is {qo} U lambda-closure • While can add an edge to GD • Choose a state A = {qi,qj,…} with missing edge for some symbol a • Compute B = δ*(qi,a) U δ*(qj,a) U … • Add B to GD if it doesn’t exist • Add arc from A to B labeled a. • Add final states • If λ is in the language, make the start state final.
Example 1 b a q2 qo q1 λ a
Example 2 λ a q2 qo q1 b b a
Example 3 0 0,1 0,1 q2 qo q1 1
Questions • Argue: Any language accepted by an NFA can be accepted by a DFA • Graph construction has finite number of states • DFA construction algorithm halts