11.07.2015 Views

Automata Theory - Computer Science - University of San Francisco

Automata Theory - Computer Science - University of San Francisco

Automata Theory - Computer Science - University of San Francisco

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Automata</strong> <strong>Theory</strong>CS411-2013F-04Non-Determinisitic Finite <strong>Automata</strong>David GallesDepartment <strong>of</strong> <strong>Computer</strong> <strong>Science</strong><strong>University</strong> <strong>of</strong> <strong>San</strong> <strong>Francisco</strong>


04-0: Non-DeterminismA Deterministic Finite <strong>Automata</strong>’s transitionfunction has exactly one transition for eachstate/symbol pairA Non-Deterministic Finite <strong>Automata</strong> can have 0, 1or more transitions for a single state/symbol pairExample: L = {w ∈ {a,b} : w starts with a}Regular expression?


04-1: NFA ExampleExample: L = {w ∈ {a,b} : w starts with a}a(a+b)*a,ba0 1


04-2: NFA ExampleExample: L = {w ∈ {a,b} : w starts with a}a(a+b)*a,ba0 1What happens if a ’b’ is seen in state q 0 ?The machine “crashes”, and does not acceptthe string


04-3: NFA ExampleExample: L = {w ∈ {a,b} : w contains thesubstring aa}Regular Expression?


04-4: NFA ExampleExample: L = {w ∈ {a,b} : w contains thesubstring aa}(a+b)*aa(a+b)*a,ba,ba a0 1 2What happens if a a is seen in state q 0 ?


04-5: NFA ExampleExample: L = {w ∈ {a,b} : w contains thesubstring aa}(a+b)*aa(a+b)*a,ba,ba a0 1 2What happens if a a is seen in state q 0 ?Stay in state q 0 , or go on to state q 1Multiple Computational Paths (board example)


04-6: NFA ExampleExample: L = {w ∈ {a,b} : w contains thesubstring aa}a,ba,ba a0 1 2(q0, abaa) (q0, baa) (q0,aa) (q0, a) (q0, ε) rejectcrashreject(q1, baa) (q1, a)(q1, ε)(q2, ε)rejectacceptDoes this machine accept abaa?


04-7: NFA AcceptanceIf there is any computational path that accepts astring, then the machine accepts the stringTwo ways to think about NFAs:Magic “Oracle”, which always picks the correctpath to takeTry all possible paths


04-8: NFA ExampleExample: L = {w ∈ {a,b} : w contains thesubstring aa}a,ba,ba a0 1 2If a string contains aa, will there be acomputational path that accepts it?If a string does not contain aa, will there be acomputational path that accepts it?


04-9: NFA DefinitionDifference between a DFA and an NFADFA has exactly only transition for eachstate/symbol pairδ : (K ×Σ) ↦→ KNFA has 0, 1 or more transitions for eachstate/symbol pair


04-10: NFA DefinitionDifference between a DFA and an NFADFA has exactly only transition for eachstate/symbol pairTransition function: δ : (K ×Σ) ↦→ KNFA has 0, 1 or more transitions for eachstate/symbol pairTransition relation: ∆ ⊆ ((K ×Σ)×K)


04-11: NFA DefinitionA NFA is a 5-tuple M = (K,Σ,∆,s,F)K Set <strong>of</strong> statesΣ Alphabet∆ : (K ×Σ)×K is a Transition relations ∈ K Initial stateF ⊆ K Final states


04-12: Fun with NFACreate an NFA for:All strings over {a, b} that start with a and end withb


04-13: Fun with NFACreate an NFA for:All strings over {a, b} that start with a and end withba,b0ab1 3(example compuational paths for ababb, abba, bbab)


04-14: Fun with NFACreate an NFA for:All strings over {0, 1} that contian 0110 or 1001


04-15: Fun with NFACreate an NFA for:All strings over {0, 1} that contian 0110 or 10010,101 11 1 10 01 10 01 1 10,13


04-16: ǫ-Transitionsǫ transition consumes no inputNFA (with ǫ transitions) for (ab)*(aab)*a1 1bεa a1 1 1b


04-17: ǫ-TransitionsCreate an NFA (with ǫ-transitions) for:All strings over {a, b, c} that are missing at leastone letter. For example, aabba, cbbc, ccacc ∈ L,while abbc ∉ L


04-18: ǫ-TransitionsCreate an NFA (with ǫ-transitions) for:All strings over {a, b, c} that are missing at leastone letter. For example, aabba, cbbc, ccacc ∈ L,while abbc ∉ L0ε ε ε123a,b b,c a,cabcb, bbab, abbab, abc


04-19: Yet More Formalismǫ-closureǫ-closure(q) = set <strong>of</strong> all states that can bereached following zero or more ǫ-transitionsfrom state q.


04-20: ǫ-closureǫ-closure examples0εa1 2abεcbε3 4 5 6ε ε a(quick review: What is L[M]?)


04-21: ǫ-closureǫ-closure examples0εa1 2abεcbε3 4 5ε ε aL[M] = {a, aa, ba, ca, aba}6


04-22: ǫ-closureǫ-closure examples0εa1 2abεcbε3 4 5ε εa6ǫ-closure(q 0 ) =ǫ-closure(q 3 ) =ǫ-closure(q 2 ) =ǫ-closure(q 5 ) =


04-23: ǫ-closureǫ-closure examples0εa1 2abεcbε3 4 5ε εa6ǫ-closure(q 0 ) = {q 0 ,q 1 ,q 4 ,q 5 }ǫ-closure(q 3 ) = {q 3 ,q 4 ,q 5 }ǫ-closure(q 2 ) = {q 2 ,q 6 }ǫ-closure(q 5 ) = {q 5 }


04-24: ǫ-closure – Setsǫ-closureǫ-closure(q) = set <strong>of</strong> all states that can bereached following zero or more ǫ-transitionsfrom state q.Can extend ǫ-closure to a set <strong>of</strong> statesǫ-closure(S) = ⋃ {A : q ∈ S∧ǫ-closure(q) = A}


04-25: NFA Definition (revised)A NFA is a 5-tuple M = (K,Σ,∆,s,F)K Set <strong>of</strong> statesΣ Alphabet∆ : (K ×(Σ∪{ǫ}))×K is a Transition relations ∈ K Initial stateF ⊆ K Final states


04-26: NFA ⊢ MBinary relation ⊢ M : What machine M yields in onestep⊢ M ⊆ (K ×Σ ∗ )×(K ×Σ ∗ )⊢ M = {((q 1 ,aw),(q 2 ,w)) : q 1 ,q 2 ∈ K M ,w ∈Σ ∗ M,a ∈ Σ M ∪{ǫ},((q 1 ,a),q 2 ) ∈ ∆ M }Binary relation ⊢ ∗ M : Transitive, reflexive closure <strong>of</strong>⊢ M


04-27: NFA LanguagesL[M] – Language defined by NFA ML[M] = {w : (s M ,w) ⊢ ∗ M (f,ǫ) for somef ∈ F M ∗}L NFA = {L : ∃NFA M,L[M] = L}


04-28: NFA ExamplesCreate an NFA for the languageGive an NFA for the language L = All stringsover {0,1} that contain two pairs <strong>of</strong> adjacent 0’sseparated by an even number <strong>of</strong> symbols. So,0100110011, 01100101100101, and 01001000are in the language, but 0100100, 1011001,and 0111011 are not in the language.


04-29: NFA ExamplesCreate an NFA for the languageGive an NFA for the language L = All stringsover {0,1} that contain two pairs <strong>of</strong> adjacent 0’sseparated by an even number <strong>of</strong> symbols. So,0100110011, 01100101100101, and 01001000are in the language, but 0100100, 1011001,and 0111011 are not in the language.0,10,10 0 0 00,1 0,1


04-30: NFA ExamplesCreate an NFA for the languageL = All strings over {a,b} that have an a as one<strong>of</strong> the last 3 charaters in the string. So, a, baab,bbbab, aabbaaabb ∈ L, but bb, baabbb,bbabbbbb ∉ L


04-31: NFA ExamplesCreate an NFA for the languageL = All strings over {a,b} that have an a as one<strong>of</strong> the last 3 charaters in the string. So, a, baab,bbbab, aabbaaabb ∈ L, but bb, baabbb,bbabbbbb ∉ La,ba b b

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!